mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2025-07-03 00:25:25 +08:00
Merge branch 'main' of https://github.com/zhuzichu520/FluentUI
This commit is contained in:
@ -21,4 +21,25 @@ FluTheme::FluTheme(QObject *parent)
|
||||
textSize(13);
|
||||
nativeText(false);
|
||||
frameless(true);
|
||||
if (follow_system()){dark(isDark());}
|
||||
(qobject_cast<QGuiApplication *>(QCoreApplication::instance()))->installEventFilter(this);
|
||||
}
|
||||
|
||||
bool FluTheme::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
Q_UNUSED(obj);
|
||||
if (event->type() == QEvent::ApplicationPaletteChange)
|
||||
{
|
||||
if (follow_system()){dark(isDark());}
|
||||
event->accept();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FluTheme::isDark()
|
||||
{
|
||||
QPalette palette = (qobject_cast<QGuiApplication *>(QCoreApplication::instance()))->palette();
|
||||
QColor color = palette.color(QPalette::Window).rgb();
|
||||
return !(color.red() * 0.2126 + color.green() * 0.7152 + color.blue() * 0.0722 > 255 / 2);
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ class FluTheme : public QObject
|
||||
Q_PROPERTY_AUTO(FluColorSet*,primaryColor)
|
||||
Q_PROPERTY_AUTO(bool,frameless);
|
||||
Q_PROPERTY_AUTO(bool,dark);
|
||||
Q_PROPERTY_AUTO(bool,follow_system);
|
||||
Q_PROPERTY_AUTO(bool,nativeText);
|
||||
Q_PROPERTY_AUTO(int,textSize);
|
||||
public:
|
||||
@ -18,7 +19,8 @@ public:
|
||||
static FluTheme *getInstance();
|
||||
private:
|
||||
static FluTheme* m_instance;
|
||||
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
bool isDark();
|
||||
};
|
||||
|
||||
#endif // FLUTHEME_H
|
||||
|
@ -61,9 +61,9 @@ Button {
|
||||
width: pressed ? 28 : 20
|
||||
anchors{
|
||||
left: selected ? undefined : parent.left
|
||||
leftMargin: selected ? 10 : 0
|
||||
leftMargin: selected ? 20 : 0
|
||||
right: selected ? parent.right : undefined
|
||||
rightMargin: selected ? 0: 10
|
||||
rightMargin: selected ? 0: 20
|
||||
}
|
||||
height: 20
|
||||
radius: 10
|
||||
|
Reference in New Issue
Block a user