2023-10-08 17:34:24 +08:00
|
|
|
/*
|
|
|
|
* Qt5-UKUI's Library
|
|
|
|
*
|
|
|
|
* Copyright (C) 2023, KylinSoft Co., Ltd.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this library. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Authors: Yan Wang <wangyan@kylinos.cn>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2022-06-18 20:35:09 +08:00
|
|
|
#ifndef KYSTYLEHELPER_H
|
|
|
|
#define KYSTYLEHELPER_H
|
|
|
|
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QQuickItem>
|
|
|
|
#include <QPalette>
|
|
|
|
#include <QColor>
|
|
|
|
|
|
|
|
class KyStyleHelper : public QQuickItem
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_DISABLE_COPY(KyStyleHelper)
|
|
|
|
|
|
|
|
Q_PROPERTY(QPalette palette READ palette NOTIFY paletteChanged)
|
|
|
|
Q_PROPERTY(QFont font READ font NOTIFY fontChanged)
|
|
|
|
|
|
|
|
Q_PROPERTY(QColor buttoncolorrole READ buttoncolor NOTIFY qcolorChanged)
|
|
|
|
Q_PROPERTY(QColor windowcolorrole READ windowcolor NOTIFY qcolorChanged)
|
|
|
|
Q_PROPERTY(QColor darkcolorrole READ darkcolor NOTIFY qcolorChanged)
|
|
|
|
Q_PROPERTY(QColor windowtextcolorrole READ windowtextcolor NOTIFY qcolorChanged)
|
|
|
|
Q_PROPERTY(QColor basecolorrole READ basecolor NOTIFY qcolorChanged)
|
|
|
|
Q_PROPERTY(QColor textcolorrole READ textcolor NOTIFY qcolorChanged)
|
|
|
|
Q_PROPERTY(QColor buttontextcolorrole READ buttontextcolor NOTIFY qcolorChanged)
|
|
|
|
Q_PROPERTY(QColor highlightcolorrole READ highlightcolor NOTIFY qcolorChanged)
|
|
|
|
Q_PROPERTY(QColor highlightedtextcolorrole READ highlightedtextcolor NOTIFY qcolorChanged)
|
|
|
|
Q_PROPERTY(QColor tooltipbasecolorrole READ tooltipbasecolor NOTIFY qcolorChanged)
|
|
|
|
Q_PROPERTY(QColor tooltiptextcolorrole READ tooltiptextcolor NOTIFY qcolorChanged)
|
|
|
|
Q_PROPERTY(QColor lightcolorrole READ lightcolor NOTIFY qcolorChanged)
|
|
|
|
Q_PROPERTY(QColor midlightcolorrole READ midlightcolor NOTIFY qcolorChanged)
|
|
|
|
Q_PROPERTY(QColor midcolorrole READ midcolor NOTIFY qcolorChanged)
|
|
|
|
Q_PROPERTY(QColor shadowcolorrole READ shadowcolor NOTIFY qcolorChanged)
|
|
|
|
Q_PROPERTY(QColor alternatebasecolorrole READ alternatebasecolor NOTIFY qcolorChanged)
|
|
|
|
Q_PROPERTY(QColor linkcolorrole READ linkcolor NOTIFY qcolorChanged)
|
|
|
|
Q_PROPERTY(QColor linkvisitedcolorrole READ linkvisitedcolor NOTIFY qcolorChanged)
|
|
|
|
|
2022-07-11 17:12:45 +08:00
|
|
|
Q_PROPERTY( QString buttonType READ buttonType WRITE setbuttonType NOTIFY buttonTypeChanged)
|
|
|
|
|
2022-06-18 20:35:09 +08:00
|
|
|
public:
|
|
|
|
explicit KyStyleHelper(QQuickItem *parent = nullptr);
|
|
|
|
~KyStyleHelper() override;
|
|
|
|
|
|
|
|
static KyStyleHelper* qmlAttachedProperties(QObject* parent);
|
|
|
|
|
2022-07-11 17:12:45 +08:00
|
|
|
QString buttonType() const { return m_buttonType;}
|
|
|
|
void setbuttonType(QString buttonType) {
|
|
|
|
m_buttonType = buttonType ;
|
|
|
|
emit buttonTypeChanged();
|
|
|
|
}
|
|
|
|
|
2022-06-18 20:35:09 +08:00
|
|
|
/* Get palette */
|
|
|
|
QPalette palette() {
|
|
|
|
return qApp->palette();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get font */
|
|
|
|
QFont font() {
|
|
|
|
return qApp->font();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get different type of color */
|
|
|
|
QColor buttoncolor() {
|
|
|
|
return qApp->palette().button().color();
|
|
|
|
}
|
|
|
|
QColor windowcolor() {
|
|
|
|
return qApp->palette().window().color();
|
|
|
|
}
|
|
|
|
QColor darkcolor() {
|
|
|
|
return qApp->palette().dark().color();
|
|
|
|
}
|
|
|
|
QColor windowtextcolor() {
|
|
|
|
return qApp->palette().windowText().color();
|
|
|
|
}
|
|
|
|
QColor basecolor() {
|
|
|
|
return qApp->palette().base().color();
|
|
|
|
}
|
|
|
|
QColor textcolor() {
|
|
|
|
return qApp->palette().text().color();
|
|
|
|
}
|
|
|
|
QColor buttontextcolor() {
|
|
|
|
return qApp->palette().buttonText().color();
|
|
|
|
}
|
|
|
|
QColor highlightcolor() {
|
|
|
|
return qApp->palette().highlight().color();
|
|
|
|
}
|
|
|
|
QColor highlightedtextcolor() {
|
|
|
|
return qApp->palette().highlightedText().color();
|
|
|
|
}
|
|
|
|
QColor tooltipbasecolor() {
|
|
|
|
return qApp->palette().toolTipBase().color();
|
|
|
|
}
|
|
|
|
QColor tooltiptextcolor() {
|
|
|
|
return qApp->palette().toolTipText().color();
|
|
|
|
}
|
|
|
|
QColor lightcolor() {
|
|
|
|
return qApp->palette().light().color();
|
|
|
|
}
|
|
|
|
QColor midlightcolor() {
|
|
|
|
return qApp->palette().midlight().color();
|
|
|
|
}
|
|
|
|
QColor midcolor() {
|
|
|
|
return qApp->palette().mid().color();
|
|
|
|
}
|
|
|
|
QColor shadowcolor() {
|
|
|
|
return qApp->palette().shadow().color();
|
|
|
|
}
|
|
|
|
QColor alternatebasecolor() {
|
|
|
|
return qApp->palette().alternateBase().color();
|
|
|
|
}
|
|
|
|
QColor linkcolor() {
|
|
|
|
return qApp->palette().link().color();
|
|
|
|
}
|
|
|
|
QColor linkvisitedcolor() {
|
|
|
|
return qApp->palette().linkVisited().color();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void paletteChanged();
|
|
|
|
void fontChanged();
|
|
|
|
void qcolorChanged();
|
2022-07-11 17:12:45 +08:00
|
|
|
void buttonTypeChanged();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
QString m_buttonType;
|
2022-06-18 20:35:09 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
QML_DECLARE_TYPEINFO(KyStyleHelper, QML_HAS_ATTACHED_PROPERTIES)
|
|
|
|
#endif // KYSTYLEHELPER_H
|