-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c43a413
commit 366fe0e
Showing
9 changed files
with
174 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "lithstyle.h" | ||
#include "liththeme.h" | ||
|
||
#include <QtQuickControls2/private/qquickstyleplugin_p.h> | ||
#include <QtQuickTemplates2/private/qquicktheme_p.h> | ||
|
||
extern void qml_register_types_Lith_Style(); | ||
Q_GHS_KEEP_REFERENCE(qml_register_types_Lith_Style); | ||
|
||
class Lith_StylePlugin : public QQuickStylePlugin { | ||
Q_OBJECT | ||
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) | ||
|
||
public: | ||
Lith_StylePlugin(QObject* parent = nullptr); | ||
|
||
QString name() const override; | ||
void initializeTheme(QQuickTheme* theme) override; | ||
|
||
LithTheme theme; | ||
}; | ||
|
||
Lith_StylePlugin::Lith_StylePlugin(QObject* parent) | ||
: QQuickStylePlugin(parent) { | ||
volatile auto registration = &qml_register_types_Lith_Style; | ||
Q_UNUSED(registration); | ||
} | ||
|
||
QString Lith_StylePlugin::name() const { | ||
return QStringLiteral("Lith.Style"); | ||
} | ||
|
||
void Lith_StylePlugin::initializeTheme(QQuickTheme* theme) { | ||
LithStyle::initialize(); | ||
this->theme.initialize(theme); | ||
} | ||
|
||
#include "lith_styleplugin.moc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "lithstyle.h" | ||
|
||
Border::Border(LithStyle* parent) | ||
: QObject(parent) { | ||
} | ||
|
||
|
||
QColor LithStyle::frameBorderColor() const { | ||
return m_frameBorderColor; | ||
} | ||
|
||
void LithStyle::setFrameBorderColor(const QColor& newFrameBorderColor) { | ||
if (m_frameBorderColor == newFrameBorderColor) { | ||
return; | ||
} | ||
m_frameBorderColor = newFrameBorderColor; | ||
emit paletteChanged(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#ifndef LITHSTYLE_H | ||
#define LITHSTYLE_H | ||
|
||
#include "common.h" | ||
|
||
#include <QQmlEngine> | ||
#include <QtQuickControls2/qquickattachedpropertypropagator.h> | ||
#include <QtQuick/private/qquickpalette_p.h> | ||
|
||
#include <QColor> | ||
|
||
class LithStyle; | ||
|
||
class Border : public QObject { | ||
Q_OBJECT | ||
PROPERTY(qreal, width, 0.0) | ||
PROPERTY(QColor, color, Qt::transparent) | ||
public: | ||
Border(LithStyle* parent); | ||
}; | ||
|
||
class Theme : public QQuickPalette { | ||
Q_OBJECT | ||
public: | ||
using QQuickPalette::QQuickPalette; | ||
}; | ||
|
||
class LithStyle : public QQuickAttachedPropertyPropagator { | ||
Q_OBJECT | ||
QML_NAMED_ELEMENT(LithStyle) | ||
QML_ATTACHED(LithStyle) | ||
QML_UNCREATABLE("") | ||
|
||
PROPERTY_PTR(Border, border, new Border(this)) | ||
PROPERTY(QColor, backgroundColor, Qt::transparent) | ||
|
||
Q_PROPERTY(QColor frameBorderColor READ frameBorderColor NOTIFY paletteChanged) | ||
public: | ||
explicit LithStyle(QObject* parent = nullptr) | ||
: QQuickAttachedPropertyPropagator(parent) { | ||
} | ||
|
||
static LithStyle* qmlAttachedProperties(QObject* object) { | ||
return new LithStyle(object); | ||
} | ||
|
||
static void initialize() { | ||
} | ||
|
||
QColor frameBorderColor() const; | ||
void setFrameBorderColor(const QColor& newFrameBorderColor); | ||
|
||
signals: | ||
void paletteChanged(); | ||
|
||
private: | ||
QColor m_frameBorderColor = {255, 0, 0}; | ||
}; | ||
|
||
#endif // LITHSTYLE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "liththeme.h" | ||
#include <QtQuickTemplates2/private/qquicktheme_p.h> | ||
#include <QFontInfo> | ||
|
||
void LithTheme::initialize(QQuickTheme* theme) { | ||
qCritical() << "HYR" << theme << theme->font(QQuickTheme::Scope::System); | ||
QFont systemFont; | ||
QFont groupBoxTitleFont; | ||
QFont tabButtonFont; | ||
theme->setUsePlatformPalette(false); | ||
theme->setPalette(QQuickTheme::System, QPalette(Qt::red)); | ||
|
||
const QFont font(QLatin1String("Segoe UI")); | ||
if (QFontInfo(font).family() == QLatin1String("Segoe UI")) { | ||
const QStringList families {font.family()}; | ||
systemFont.setFamilies(families); | ||
groupBoxTitleFont.setFamilies(families); | ||
tabButtonFont.setFamilies(families); | ||
} | ||
|
||
systemFont.setPixelSize(15); | ||
theme->setFont(QQuickTheme::System, systemFont); | ||
|
||
groupBoxTitleFont.setPixelSize(15); | ||
groupBoxTitleFont.setWeight(QFont::DemiBold); | ||
theme->setFont(QQuickTheme::GroupBox, groupBoxTitleFont); | ||
|
||
tabButtonFont.setPixelSize(24); | ||
tabButtonFont.setWeight(QFont::Light); | ||
theme->setFont(QQuickTheme::TabBar, tabButtonFont); | ||
theme->setFont(QQuickTheme::Label, tabButtonFont); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef LITHTHEME_H | ||
#define LITHTHEME_H | ||
|
||
|
||
class QQuickTheme; | ||
|
||
class LithTheme { | ||
public: | ||
static void initialize(QQuickTheme* theme); | ||
}; | ||
|
||
#endif // LITHTHEME_H |