dde-control-center
Deepin Control Center
载入中...
搜索中...
未找到
comboxwidget.h
1//SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
2//
3//SPDX-License-Identifier: GPL-3.0-or-later
4#pragma once
5
6#include "interface/namespace.h"
7#include "widgets/settingsitem.h"
8#include <QComboBox>
9
10QT_BEGIN_NAMESPACE
11class QStringList;
12class QLabel;
13QT_END_NAMESPACE
14
15namespace DCC_NAMESPACE {
16
17class AlertComboBox;
18
20{
21 Q_OBJECT
22
23public:
24 explicit ComboxWidget(QFrame *parent = nullptr);
25 explicit ComboxWidget(const QString &title, QFrame *parent = nullptr);
26 explicit ComboxWidget(QWidget *widget, QFrame *parent = nullptr);
27
28 void setComboxOption(const QStringList &options);
29 void setCurrentText(const QString &curText);
30 void setCurrentIndex(const int index);
31 void setTitle(const QString &title);
32
33 AlertComboBox *comboBox();
34
35Q_SIGNALS:
36 void onIndexChanged(int index);
37 void onSelectChanged(const QString &selected);
38 void dataChanged(const QVariant &data);
39 void clicked();
40
41protected:
42 void mouseReleaseEvent(QMouseEvent *event) override;
43 void resizeEvent(QResizeEvent *event) override;
44
45private:
46 QWidget *m_leftWidget;
47 AlertComboBox *m_switchComboBox;
48 QLabel *m_titleLabel;
49 QString m_str;
50};
51
52class AlertComboBox : public QComboBox
53{
54 Q_OBJECT
55
56 Q_PROPERTY(bool isWarning READ isWarning WRITE setIsWarning)
57
58public:
59 explicit AlertComboBox(QWidget *parent = Q_NULLPTR);
60 ~AlertComboBox() override;
61 void setIsWarning(bool isWarning);
62 bool isWarning();
63 bool eventFilter(QObject *o, QEvent *e) override;
64
65Q_SIGNALS:
66 void clicked();
67
68protected Q_SLOTS:
69 void onValueChange(const QString &text);
70
71protected:
72 void paintEvent(QPaintEvent *e) override;
73
74private:
75 bool m_isWarning;
76};
77
78}
Definition comboxwidget.h:53
Definition comboxwidget.h:20
Definition settingsitem.h:11