123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- #ifndef TIMEWIDGET_H
- #define TIMEWIDGET_H
- #include <QFrame>
- #include <QTime>
- class TimePartWidget;
- class QListWidgetItem;
- class ShadowWidget;
- namespace Ui {
- class TimeWidget;
- }
- class TimeWidget : public QFrame
- {
- Q_OBJECT
- public:
- enum ShowType{
- EditLine = 0,
- Dialog = 1,
- };
- explicit TimeWidget(QWidget *parent = nullptr , ShowType type = EditLine);
- explicit TimeWidget(ShowType type = EditLine);
- ~TimeWidget();
- void CreateTimeVector(const QVector<int>& types);
- void ClearVector(QVector<TimePartWidget*>& vec);
-
- void SetMainWindow(QWidget* pWidget);
- QTime getTime();
- QString getTimeStr();
- QTime getFormTime() const;
- void setTime(const QString& t);
- void setTime(const QTime& t);
- void clearTime();
- QString tipText() const;
-
- void setTimeAreaWidth(int w);
-
- void showTimeEditArea();
-
- void execShow();
-
- void setIcon(const QString& icon);
-
- void setIconShow(bool isShow);
-
- void setIconSize(int w, int h);
-
- void setDefaultStyle();
-
- void setEditLine(int w, int h);
- signals:
- void signal_nowTime(const QTime& time);
- void signal_formerTimer(const QTime& time);
- void signal_close();
- protected:
- bool eventFilter(QObject* obj, QEvent* e) override;
- void moveEvent(QMoveEvent *event) override;
- private slots:
- void onBtnTipClicked();
- void onListItemClicked(QListWidgetItem* item);
- void onDateTimeChanged(const QDateTime& dt);
- private:
- void UpdateProperty(QObject* obj, const char* name, bool flag);
- void UpdatePopupTime(const QDateTime& dt);
- void ShowTimeArea(bool bShow);
- void CreatePopupWidget();
-
- void Init();
- private:
- const int TIME_AREA_WIDTH = 56;
- const int TIME_AREA_HEIGHT = 32;
- const int SHADOW_MARGIN = 9;
- Ui::TimeWidget *ui;
- QVector<TimePartWidget*> m_vecTimePart;
- QVector<int> m_vecTimeSections;
- bool m_bTimeFlag{false};
- QScopedPointer<ShadowWidget> m_wdgTimeArea;
- QWidget* m_pMainWindow;
- ShowType m_type;
- int m_width = 0;
- };
- #endif
|