mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2025-07-02 16:15:28 +08:00
update clang-format
This commit is contained in:
60
src/Def.h
60
src/Def.h
@ -59,11 +59,7 @@ namespace FluPageType {
|
||||
|
||||
namespace FluWindowType {
|
||||
Q_NAMESPACE
|
||||
enum LaunchMode {
|
||||
Standard = 0x0000,
|
||||
SingleTask = 0x0001,
|
||||
SingleInstance = 0x0002
|
||||
};
|
||||
enum LaunchMode { Standard = 0x0000, SingleTask = 0x0001, SingleInstance = 0x0002 };
|
||||
|
||||
Q_ENUM_NS(LaunchMode)
|
||||
|
||||
@ -72,11 +68,7 @@ namespace FluWindowType {
|
||||
|
||||
namespace FluTreeViewType {
|
||||
Q_NAMESPACE
|
||||
enum SelectionMode {
|
||||
None = 0x0000,
|
||||
Single = 0x0001,
|
||||
Multiple = 0x0002
|
||||
};
|
||||
enum SelectionMode { None = 0x0000, Single = 0x0001, Multiple = 0x0002 };
|
||||
|
||||
Q_ENUM_NS(SelectionMode)
|
||||
|
||||
@ -85,12 +77,7 @@ namespace FluTreeViewType {
|
||||
|
||||
namespace FluStatusLayoutType {
|
||||
Q_NAMESPACE
|
||||
enum StatusMode {
|
||||
Loading = 0x0000,
|
||||
Empty = 0x0001,
|
||||
Error = 0x0002,
|
||||
Success = 0x0004
|
||||
};
|
||||
enum StatusMode { Loading = 0x0000, Empty = 0x0001, Error = 0x0002, Success = 0x0004 };
|
||||
|
||||
Q_ENUM_NS(StatusMode)
|
||||
|
||||
@ -99,11 +86,7 @@ namespace FluStatusLayoutType {
|
||||
|
||||
namespace FluContentDialogType {
|
||||
Q_NAMESPACE
|
||||
enum ButtonFlag {
|
||||
NeutralButton = 0x0001,
|
||||
NegativeButton = 0x0002,
|
||||
PositiveButton = 0x0004
|
||||
};
|
||||
enum ButtonFlag { NeutralButton = 0x0001, NegativeButton = 0x0002, PositiveButton = 0x0004 };
|
||||
|
||||
Q_ENUM_NS(ButtonFlag)
|
||||
|
||||
@ -112,10 +95,7 @@ namespace FluContentDialogType {
|
||||
|
||||
namespace FluTimePickerType {
|
||||
Q_NAMESPACE
|
||||
enum HourFormat {
|
||||
H = 0x0000,
|
||||
HH = 0x0001
|
||||
};
|
||||
enum HourFormat { H = 0x0000, HH = 0x0001 };
|
||||
|
||||
Q_ENUM_NS(HourFormat)
|
||||
|
||||
@ -124,11 +104,7 @@ namespace FluTimePickerType {
|
||||
|
||||
namespace FluCalendarViewType {
|
||||
Q_NAMESPACE
|
||||
enum DisplayMode {
|
||||
Month = 0x0000,
|
||||
Year = 0x0001,
|
||||
Decade = 0x0002
|
||||
};
|
||||
enum DisplayMode { Month = 0x0000, Year = 0x0001, Decade = 0x0002 };
|
||||
|
||||
Q_ENUM_NS(DisplayMode)
|
||||
|
||||
@ -137,19 +113,11 @@ namespace FluCalendarViewType {
|
||||
|
||||
namespace FluTabViewType {
|
||||
Q_NAMESPACE
|
||||
enum TabWidthBehavior {
|
||||
Equal = 0x0000,
|
||||
SizeToContent = 0x0001,
|
||||
Compact = 0x0002
|
||||
};
|
||||
enum TabWidthBehavior { Equal = 0x0000, SizeToContent = 0x0001, Compact = 0x0002 };
|
||||
|
||||
Q_ENUM_NS(TabWidthBehavior)
|
||||
|
||||
enum CloseButtonVisibility {
|
||||
Never = 0x0000,
|
||||
Always = 0x0001,
|
||||
OnHover = 0x0002
|
||||
};
|
||||
enum CloseButtonVisibility { Never = 0x0000, Always = 0x0001, OnHover = 0x0002 };
|
||||
|
||||
Q_ENUM_NS(CloseButtonVisibility)
|
||||
|
||||
@ -158,19 +126,11 @@ namespace FluTabViewType {
|
||||
|
||||
namespace FluNavigationViewType {
|
||||
Q_NAMESPACE
|
||||
enum DisplayMode {
|
||||
Open = 0x0000,
|
||||
Compact = 0x0001,
|
||||
Minimal = 0x0002,
|
||||
Auto = 0x0004
|
||||
};
|
||||
enum DisplayMode { Open = 0x0000, Compact = 0x0001, Minimal = 0x0002, Auto = 0x0004 };
|
||||
|
||||
Q_ENUM_NS(DisplayMode)
|
||||
|
||||
enum PageMode {
|
||||
Stack = 0x0000,
|
||||
NoStack = 0x0001
|
||||
};
|
||||
enum PageMode { Stack = 0x0000, NoStack = 0x0001 };
|
||||
|
||||
Q_ENUM_NS(PageMode)
|
||||
|
||||
|
@ -9,15 +9,15 @@
|
||||
* @brief The FluAccentColor class
|
||||
*/
|
||||
class FluAccentColor : public QObject {
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY_AUTO(QColor, darkest)
|
||||
Q_PROPERTY_AUTO(QColor, darker)
|
||||
Q_PROPERTY_AUTO(QColor, dark)
|
||||
Q_PROPERTY_AUTO(QColor, normal)
|
||||
Q_PROPERTY_AUTO(QColor, light)
|
||||
Q_PROPERTY_AUTO(QColor, lighter)
|
||||
Q_PROPERTY_AUTO(QColor, lightest)
|
||||
Q_PROPERTY_AUTO(QColor, darkest)
|
||||
Q_PROPERTY_AUTO(QColor, darker)
|
||||
Q_PROPERTY_AUTO(QColor, dark)
|
||||
Q_PROPERTY_AUTO(QColor, normal)
|
||||
Q_PROPERTY_AUTO(QColor, light)
|
||||
Q_PROPERTY_AUTO(QColor, lighter)
|
||||
Q_PROPERTY_AUTO(QColor, lightest)
|
||||
QML_NAMED_ELEMENT(FluAccentColor)
|
||||
public:
|
||||
explicit FluAccentColor(QObject *parent = nullptr);
|
||||
|
@ -23,7 +23,7 @@ void FluApp::init(QObject *launcher, QLocale locale) {
|
||||
_translator = new QTranslator(this);
|
||||
QGuiApplication::installTranslator(_translator);
|
||||
const QStringList uiLanguages = _locale.uiLanguages();
|
||||
for (const QString &name: uiLanguages) {
|
||||
for (const QString &name : uiLanguages) {
|
||||
const QString baseName = "fluentui_" + QLocale(name).name();
|
||||
if (_translator->load(":/qt/qml/FluentUI/i18n/" + baseName)) {
|
||||
_engine->retranslate();
|
||||
@ -34,7 +34,8 @@ void FluApp::init(QObject *launcher, QLocale locale) {
|
||||
|
||||
[[maybe_unused]] QJsonArray FluApp::iconData(const QString &keyword) {
|
||||
QJsonArray arr;
|
||||
QMetaEnum enumType = FluentIcons::staticMetaObject.enumerator(FluentIcons::staticMetaObject.indexOfEnumerator("Type"));
|
||||
QMetaEnum enumType = FluentIcons::staticMetaObject.enumerator(
|
||||
FluentIcons::staticMetaObject.indexOfEnumerator("Type"));
|
||||
for (int i = 0; i <= enumType.keyCount() - 1; ++i) {
|
||||
QString name = enumType.key(i);
|
||||
int icon = enumType.value(i);
|
||||
|
17
src/FluApp.h
17
src/FluApp.h
@ -16,12 +16,11 @@
|
||||
* @brief The FluApp class
|
||||
*/
|
||||
class FluApp : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY_AUTO(bool, useSystemAppBar)
|
||||
Q_PROPERTY_AUTO(QString, windowIcon)
|
||||
Q_PROPERTY_AUTO(QLocale, locale)
|
||||
Q_PROPERTY_AUTO_P(QObject*,launcher)
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(bool, useSystemAppBar)
|
||||
Q_PROPERTY_AUTO(QString, windowIcon)
|
||||
Q_PROPERTY_AUTO(QLocale, locale)
|
||||
Q_PROPERTY_AUTO_P(QObject *, launcher)
|
||||
QML_NAMED_ELEMENT(FluApp)
|
||||
QML_SINGLETON
|
||||
|
||||
@ -31,9 +30,11 @@ private:
|
||||
~FluApp() override;
|
||||
|
||||
public:
|
||||
SINGLETON(FluApp)
|
||||
SINGLETON(FluApp)
|
||||
|
||||
static FluApp *create(QQmlEngine *, QJSEngine *) { return getInstance(); }
|
||||
static FluApp *create(QQmlEngine *, QJSEngine *) {
|
||||
return getInstance();
|
||||
}
|
||||
|
||||
Q_INVOKABLE void init(QObject *launcher, QLocale locale = QLocale::system());
|
||||
|
||||
|
@ -40,7 +40,8 @@ void FluCaptcha::paint(QPainter *painter) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
pen = QPen(QColor(generaNumber(255), generaNumber(255), generaNumber(255)));
|
||||
painter->setPen(pen);
|
||||
painter->drawText(15 + 35 * i, 10 + generaNumber(15), 30, 40, Qt::AlignCenter, QString(_code[i]));
|
||||
painter->drawText(15 + 35 * i, 10 + generaNumber(15), 30, 40, Qt::AlignCenter,
|
||||
QString(_code[i]));
|
||||
}
|
||||
painter->restore();
|
||||
}
|
||||
|
@ -9,10 +9,10 @@
|
||||
* @brief The FluCaptcha class
|
||||
*/
|
||||
class FluCaptcha : public QQuickPaintedItem {
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY_AUTO(QFont, font);
|
||||
Q_PROPERTY_AUTO(bool, ignoreCase);
|
||||
Q_PROPERTY_AUTO(QFont, font)
|
||||
Q_PROPERTY_AUTO(bool, ignoreCase)
|
||||
QML_NAMED_ELEMENT(FluCaptcha)
|
||||
|
||||
public:
|
||||
|
@ -11,41 +11,41 @@
|
||||
* @brief The FluColors class
|
||||
*/
|
||||
class FluColors : public QObject {
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY_AUTO(QColor, Transparent);
|
||||
Q_PROPERTY_AUTO(QColor, Black);
|
||||
Q_PROPERTY_AUTO(QColor, White);
|
||||
Q_PROPERTY_AUTO(QColor, Grey10);
|
||||
Q_PROPERTY_AUTO(QColor, Grey20);
|
||||
Q_PROPERTY_AUTO(QColor, Grey30);
|
||||
Q_PROPERTY_AUTO(QColor, Grey40);
|
||||
Q_PROPERTY_AUTO(QColor, Grey50);
|
||||
Q_PROPERTY_AUTO(QColor, Grey60);
|
||||
Q_PROPERTY_AUTO(QColor, Grey70);
|
||||
Q_PROPERTY_AUTO(QColor, Grey80);
|
||||
Q_PROPERTY_AUTO(QColor, Grey90);
|
||||
Q_PROPERTY_AUTO(QColor, Grey100);
|
||||
Q_PROPERTY_AUTO(QColor, Grey110);
|
||||
Q_PROPERTY_AUTO(QColor, Grey120);
|
||||
Q_PROPERTY_AUTO(QColor, Grey130);
|
||||
Q_PROPERTY_AUTO(QColor, Grey140);
|
||||
Q_PROPERTY_AUTO(QColor, Grey150);
|
||||
Q_PROPERTY_AUTO(QColor, Grey160);
|
||||
Q_PROPERTY_AUTO(QColor, Grey170);
|
||||
Q_PROPERTY_AUTO(QColor, Grey180);
|
||||
Q_PROPERTY_AUTO(QColor, Grey190);
|
||||
Q_PROPERTY_AUTO(QColor, Grey200);
|
||||
Q_PROPERTY_AUTO(QColor, Grey210);
|
||||
Q_PROPERTY_AUTO(QColor, Grey220);
|
||||
Q_PROPERTY_AUTO_P(FluAccentColor*, Yellow);
|
||||
Q_PROPERTY_AUTO_P(FluAccentColor*, Orange);
|
||||
Q_PROPERTY_AUTO_P(FluAccentColor*, Red);
|
||||
Q_PROPERTY_AUTO_P(FluAccentColor*, Magenta);
|
||||
Q_PROPERTY_AUTO_P(FluAccentColor*, Purple);
|
||||
Q_PROPERTY_AUTO_P(FluAccentColor*, Blue);
|
||||
Q_PROPERTY_AUTO_P(FluAccentColor*, Teal);
|
||||
Q_PROPERTY_AUTO_P(FluAccentColor*, Green);
|
||||
Q_PROPERTY_AUTO(QColor, Transparent)
|
||||
Q_PROPERTY_AUTO(QColor, Black)
|
||||
Q_PROPERTY_AUTO(QColor, White)
|
||||
Q_PROPERTY_AUTO(QColor, Grey10)
|
||||
Q_PROPERTY_AUTO(QColor, Grey20)
|
||||
Q_PROPERTY_AUTO(QColor, Grey30)
|
||||
Q_PROPERTY_AUTO(QColor, Grey40)
|
||||
Q_PROPERTY_AUTO(QColor, Grey50)
|
||||
Q_PROPERTY_AUTO(QColor, Grey60)
|
||||
Q_PROPERTY_AUTO(QColor, Grey70)
|
||||
Q_PROPERTY_AUTO(QColor, Grey80)
|
||||
Q_PROPERTY_AUTO(QColor, Grey90)
|
||||
Q_PROPERTY_AUTO(QColor, Grey100)
|
||||
Q_PROPERTY_AUTO(QColor, Grey110)
|
||||
Q_PROPERTY_AUTO(QColor, Grey120)
|
||||
Q_PROPERTY_AUTO(QColor, Grey130)
|
||||
Q_PROPERTY_AUTO(QColor, Grey140)
|
||||
Q_PROPERTY_AUTO(QColor, Grey150)
|
||||
Q_PROPERTY_AUTO(QColor, Grey160)
|
||||
Q_PROPERTY_AUTO(QColor, Grey170)
|
||||
Q_PROPERTY_AUTO(QColor, Grey180)
|
||||
Q_PROPERTY_AUTO(QColor, Grey190)
|
||||
Q_PROPERTY_AUTO(QColor, Grey200)
|
||||
Q_PROPERTY_AUTO(QColor, Grey210)
|
||||
Q_PROPERTY_AUTO(QColor, Grey220)
|
||||
Q_PROPERTY_AUTO_P(FluAccentColor *, Yellow)
|
||||
Q_PROPERTY_AUTO_P(FluAccentColor *, Orange)
|
||||
Q_PROPERTY_AUTO_P(FluAccentColor *, Red)
|
||||
Q_PROPERTY_AUTO_P(FluAccentColor *, Magenta)
|
||||
Q_PROPERTY_AUTO_P(FluAccentColor *, Purple)
|
||||
Q_PROPERTY_AUTO_P(FluAccentColor *, Blue)
|
||||
Q_PROPERTY_AUTO_P(FluAccentColor *, Teal)
|
||||
Q_PROPERTY_AUTO_P(FluAccentColor *, Green)
|
||||
QML_NAMED_ELEMENT(FluColors)
|
||||
QML_SINGLETON
|
||||
|
||||
@ -53,9 +53,11 @@ private:
|
||||
explicit FluColors(QObject *parent = nullptr);
|
||||
|
||||
public:
|
||||
SINGLETON(FluColors)
|
||||
SINGLETON(FluColors)
|
||||
|
||||
[[maybe_unused]] Q_INVOKABLE FluAccentColor *createAccentColor(const QColor &primaryColor);
|
||||
|
||||
static FluColors *create(QQmlEngine *, QJSEngine *) { return getInstance(); }
|
||||
static FluColors *create(QQmlEngine *, QJSEngine *) {
|
||||
return getInstance();
|
||||
}
|
||||
};
|
||||
|
@ -14,16 +14,15 @@ using QT_NATIVE_EVENT_RESULT_TYPE = long;
|
||||
using QT_ENTER_EVENT_TYPE = QEvent;
|
||||
#endif
|
||||
|
||||
|
||||
class FluFrameless : public QQuickItem, QAbstractNativeEventFilter {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO_P(QQuickItem*, appbar)
|
||||
Q_PROPERTY_AUTO_P(QQuickItem*, maximizeButton)
|
||||
Q_PROPERTY_AUTO_P(QQuickItem*, minimizedButton)
|
||||
Q_PROPERTY_AUTO_P(QQuickItem*, closeButton)
|
||||
Q_PROPERTY_AUTO(bool, topmost)
|
||||
Q_PROPERTY_AUTO(bool, disabled)
|
||||
Q_PROPERTY_AUTO(bool, fixSize)
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO_P(QQuickItem *, appbar)
|
||||
Q_PROPERTY_AUTO_P(QQuickItem *, maximizeButton)
|
||||
Q_PROPERTY_AUTO_P(QQuickItem *, minimizedButton)
|
||||
Q_PROPERTY_AUTO_P(QQuickItem *, closeButton)
|
||||
Q_PROPERTY_AUTO(bool, topmost)
|
||||
Q_PROPERTY_AUTO(bool, disabled)
|
||||
Q_PROPERTY_AUTO(bool, fixSize)
|
||||
QML_NAMED_ELEMENT(FluFrameless)
|
||||
public:
|
||||
explicit FluFrameless(QQuickItem *parent = nullptr);
|
||||
@ -32,7 +31,8 @@ public:
|
||||
|
||||
void componentComplete() override;
|
||||
|
||||
[[maybe_unused]] bool nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result) override;
|
||||
[[maybe_unused]] bool nativeEventFilter(const QByteArray &eventType, void *message,
|
||||
QT_NATIVE_EVENT_RESULT_TYPE *result) override;
|
||||
|
||||
[[maybe_unused]] Q_INVOKABLE void showFullScreen();
|
||||
|
||||
|
@ -1,31 +1,26 @@
|
||||
#include "FluHotkey.h"
|
||||
|
||||
|
||||
#include "QGuiApplication"
|
||||
|
||||
FluHotkey::FluHotkey(QObject *parent)
|
||||
: QObject{parent}
|
||||
{
|
||||
|
||||
FluHotkey::FluHotkey(QObject *parent) : QObject{parent} {
|
||||
_sequence = "";
|
||||
_isRegistered = false;
|
||||
connect(this,&FluHotkey::sequenceChanged,this,[=]{
|
||||
if(_hotkey){
|
||||
delete _hotkey;
|
||||
connect(this, &FluHotkey::sequenceChanged, this, [=] {
|
||||
if (_hotkey) {
|
||||
delete _hotkey;
|
||||
_hotkey = nullptr;
|
||||
}
|
||||
_hotkey = new QHotkey(QKeySequence(_sequence), true, qApp);
|
||||
this->isRegistered(_hotkey->isRegistered());
|
||||
QObject::connect(_hotkey, &QHotkey::activated, qApp, [=](){
|
||||
Q_EMIT this->activated();
|
||||
});
|
||||
QObject::connect(_hotkey, &QHotkey::registeredChanged, qApp, [=](){
|
||||
this->isRegistered(_hotkey->isRegistered());
|
||||
});
|
||||
QObject::connect(_hotkey, &QHotkey::activated, qApp, [=]() { Q_EMIT this->activated(); });
|
||||
QObject::connect(_hotkey, &QHotkey::registeredChanged, qApp,
|
||||
[=]() { this->isRegistered(_hotkey->isRegistered()); });
|
||||
});
|
||||
}
|
||||
|
||||
FluHotkey::~FluHotkey(){
|
||||
if(_hotkey){
|
||||
FluHotkey::~FluHotkey() {
|
||||
if (_hotkey) {
|
||||
delete _hotkey;
|
||||
_hotkey = nullptr;
|
||||
}
|
||||
|
@ -6,19 +6,20 @@
|
||||
#include "qhotkey/qhotkey.h"
|
||||
#include "stdafx.h"
|
||||
|
||||
class FluHotkey : public QObject
|
||||
{
|
||||
class FluHotkey : public QObject {
|
||||
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(QString,sequence)
|
||||
Q_PROPERTY_AUTO(QString,name)
|
||||
Q_PROPERTY_READONLY_AUTO(bool,isRegistered)
|
||||
Q_PROPERTY_AUTO(QString, sequence)
|
||||
Q_PROPERTY_AUTO(QString, name)
|
||||
Q_PROPERTY_READONLY_AUTO(bool, isRegistered)
|
||||
QML_NAMED_ELEMENT(FluHotkey)
|
||||
public:
|
||||
explicit FluHotkey(QObject *parent = nullptr);
|
||||
~FluHotkey();
|
||||
Q_SIGNAL void activated();
|
||||
|
||||
private:
|
||||
QHotkey* _hotkey = nullptr;
|
||||
QHotkey *_hotkey = nullptr;
|
||||
};
|
||||
|
||||
#endif // FLUHOTKEY_H
|
||||
|
@ -9,15 +9,15 @@
|
||||
* @brief The FluQrCodeItem class
|
||||
*/
|
||||
class FluQrCodeItem : public QQuickPaintedItem {
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY_AUTO(QString, text)
|
||||
Q_PROPERTY_AUTO(QColor, color)
|
||||
Q_PROPERTY_AUTO(QColor, bgColor)
|
||||
Q_PROPERTY_AUTO(int, size);
|
||||
Q_PROPERTY_AUTO(QString, text)
|
||||
Q_PROPERTY_AUTO(QColor, color)
|
||||
Q_PROPERTY_AUTO(QColor, bgColor)
|
||||
Q_PROPERTY_AUTO(int, size)
|
||||
QML_NAMED_ELEMENT(FluQrCodeItem)
|
||||
public:
|
||||
explicit FluQrCodeItem(QQuickItem *parent = nullptr);
|
||||
|
||||
void paint(QPainter *painter) override;
|
||||
};
|
||||
};
|
||||
|
@ -8,6 +8,7 @@ FluRectangle::FluRectangle(QQuickItem *parent) : QQuickPaintedItem(parent) {
|
||||
connect(this, &FluRectangle::radiusChanged, this, [=] { update(); });
|
||||
}
|
||||
|
||||
|
||||
void FluRectangle::paint(QPainter *painter) {
|
||||
painter->save();
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
@ -15,13 +16,19 @@ void FluRectangle::paint(QPainter *painter) {
|
||||
QRectF rect = boundingRect();
|
||||
path.moveTo(rect.bottomRight() - QPointF(0, _radius[2]));
|
||||
path.lineTo(rect.topRight() + QPointF(0, _radius[1]));
|
||||
path.arcTo(QRectF(QPointF(rect.topRight() - QPointF(_radius[1] * 2, 0)), QSize(_radius[1] * 2, _radius[1] * 2)), 0, 90);
|
||||
path.arcTo(QRectF(QPointF(rect.topRight() - QPointF(_radius[1] * 2, 0)),
|
||||
QSize(_radius[1] * 2, _radius[1] * 2)),
|
||||
0, 90);
|
||||
path.lineTo(rect.topLeft() + QPointF(_radius[0], 0));
|
||||
path.arcTo(QRectF(QPointF(rect.topLeft()), QSize(_radius[0] * 2, _radius[0] * 2)), 90, 90);
|
||||
path.lineTo(rect.bottomLeft() - QPointF(0, _radius[3]));
|
||||
path.arcTo(QRectF(QPointF(rect.bottomLeft() - QPointF(0, _radius[3] * 2)), QSize(_radius[3] * 2, _radius[3] * 2)), 180, 90);
|
||||
path.arcTo(QRectF(QPointF(rect.bottomLeft() - QPointF(0, _radius[3] * 2)),
|
||||
QSize(_radius[3] * 2, _radius[3] * 2)),
|
||||
180, 90);
|
||||
path.lineTo(rect.bottomRight() - QPointF(_radius[2], 0));
|
||||
path.arcTo(QRectF(QPointF(rect.bottomRight() - QPointF(_radius[2] * 2, _radius[2] * 2)), QSize(_radius[2] * 2, _radius[2] * 2)), 270, 90);
|
||||
path.arcTo(QRectF(QPointF(rect.bottomRight() - QPointF(_radius[2] * 2, _radius[2] * 2)),
|
||||
QSize(_radius[2] * 2, _radius[2] * 2)),
|
||||
270, 90);
|
||||
painter->fillPath(path, _color);
|
||||
painter->restore();
|
||||
}
|
||||
|
@ -9,9 +9,9 @@
|
||||
* @brief The FluRectangle class
|
||||
*/
|
||||
class FluRectangle : public QQuickPaintedItem {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(QColor, color)
|
||||
Q_PROPERTY_AUTO(QList<int>, radius)
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(QColor, color)
|
||||
Q_PROPERTY_AUTO(QList<int>, radius)
|
||||
QML_NAMED_ELEMENT(FluRectangle)
|
||||
public:
|
||||
explicit FluRectangle(QQuickItem *parent = nullptr);
|
||||
|
@ -1,13 +1,13 @@
|
||||
#include "FluTableModel.h"
|
||||
|
||||
FluTableModel::FluTableModel(QObject *parent) : QAbstractTableModel{parent} {
|
||||
|
||||
}
|
||||
|
||||
int FluTableModel::rowCount(const QModelIndex &parent) const {
|
||||
return _rows.count();
|
||||
}
|
||||
|
||||
|
||||
int FluTableModel::columnCount(const QModelIndex &parent) const {
|
||||
return this->_columnSource.size();
|
||||
}
|
||||
@ -26,8 +26,8 @@ QVariant FluTableModel::data(const QModelIndex &index, int role) const {
|
||||
|
||||
QHash<int, QByteArray> FluTableModel::roleNames() const {
|
||||
return {
|
||||
{FluTableModel::RowModel, "rowModel"},
|
||||
{FluTableModel::ColumnModel, "columnModel"}
|
||||
{FluTableModel::RowModel, "rowModel" },
|
||||
{FluTableModel::ColumnModel, "columnModel"}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -7,16 +7,14 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
class FluTableModel : public QAbstractTableModel {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(QList<QVariantMap>, columnSource)
|
||||
Q_PROPERTY_AUTO(QList<QVariantMap>, rows)
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(QList<QVariantMap>, columnSource)
|
||||
Q_PROPERTY_AUTO(QList<QVariantMap>, rows)
|
||||
Q_PROPERTY(int rowCount READ rowCount CONSTANT)
|
||||
QML_NAMED_ELEMENT(FluTableModel)
|
||||
public:
|
||||
enum TableModelRoles {
|
||||
RowModel = 0x0101,
|
||||
ColumnModel = 0x0102
|
||||
};
|
||||
enum TableModelRoles { RowModel = 0x0101, ColumnModel = 0x0102 };
|
||||
|
||||
|
||||
explicit FluTableModel(QObject *parent = nullptr);
|
||||
|
||||
@ -24,7 +22,8 @@ public:
|
||||
|
||||
[[nodiscard]] int columnCount(const QModelIndex &parent = {}) const override;
|
||||
|
||||
[[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
[[nodiscard]] QVariant data(const QModelIndex &index,
|
||||
int role = Qt::DisplayRole) const override;
|
||||
|
||||
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
@ -39,7 +38,6 @@ public:
|
||||
Q_INVOKABLE void removeRow(int rowIndex, int rows = 1);
|
||||
|
||||
Q_INVOKABLE void appendRow(QVariant row);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -2,13 +2,14 @@
|
||||
|
||||
#include <QJSValueList>
|
||||
|
||||
FluTableSortProxyModel::FluTableSortProxyModel(QSortFilterProxyModel *parent) : QSortFilterProxyModel{parent} {
|
||||
connect(this, &FluTableSortProxyModel::modelChanged, this, [=] {
|
||||
setSourceModel(this->model().value<QAbstractTableModel *>());
|
||||
});
|
||||
FluTableSortProxyModel::FluTableSortProxyModel(QSortFilterProxyModel *parent)
|
||||
: QSortFilterProxyModel{parent} {
|
||||
connect(this, &FluTableSortProxyModel::modelChanged, this,
|
||||
[=] { setSourceModel(this->model().value<QAbstractTableModel *>()); });
|
||||
}
|
||||
|
||||
bool FluTableSortProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const {
|
||||
bool FluTableSortProxyModel::filterAcceptsRow(int source_row,
|
||||
const QModelIndex &source_parent) const {
|
||||
QJSValue filter = _filter;
|
||||
if (filter.isUndefined()) {
|
||||
return true;
|
||||
@ -18,11 +19,13 @@ bool FluTableSortProxyModel::filterAcceptsRow(int source_row, const QModelIndex
|
||||
return filter.call(data).toBool();
|
||||
}
|
||||
|
||||
bool FluTableSortProxyModel::filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const {
|
||||
bool FluTableSortProxyModel::filterAcceptsColumn(int source_column,
|
||||
const QModelIndex &source_parent) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FluTableSortProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const {
|
||||
bool FluTableSortProxyModel::lessThan(const QModelIndex &source_left,
|
||||
const QModelIndex &source_right) const {
|
||||
QJSValue comparator = _comparator;
|
||||
if (comparator.isUndefined()) {
|
||||
return true;
|
||||
@ -58,18 +61,25 @@ bool FluTableSortProxyModel::lessThan(const QModelIndex &source_left, const QMod
|
||||
|
||||
[[maybe_unused]] QVariant FluTableSortProxyModel::getRow(int rowIndex) {
|
||||
QVariant result;
|
||||
QMetaObject::invokeMethod(_model.value<QAbstractTableModel *>(), "getRow", Q_RETURN_ARG(QVariant, result), Q_ARG(int, mapToSource(index(rowIndex, 0)).row()));
|
||||
QMetaObject::invokeMethod(_model.value<QAbstractTableModel *>(), "getRow",
|
||||
Q_RETURN_ARG(QVariant, result),
|
||||
Q_ARG(int, mapToSource(index(rowIndex, 0)).row()));
|
||||
return result;
|
||||
}
|
||||
|
||||
[[maybe_unused]] void FluTableSortProxyModel::setRow(int rowIndex, const QVariant &val) {
|
||||
QMetaObject::invokeMethod(_model.value<QAbstractTableModel *>(), "setRow", Q_ARG(int, mapToSource(index(rowIndex, 0)).row()), Q_ARG(QVariant, val));
|
||||
QMetaObject::invokeMethod(_model.value<QAbstractTableModel *>(), "setRow",
|
||||
Q_ARG(int, mapToSource(index(rowIndex, 0)).row()),
|
||||
Q_ARG(QVariant, val));
|
||||
}
|
||||
|
||||
[[maybe_unused]] void FluTableSortProxyModel::insertRow(int rowIndex, const QVariant &val) {
|
||||
QMetaObject::invokeMethod(_model.value<QAbstractTableModel *>(), "insertRow", Q_ARG(int, mapToSource(index(rowIndex, 0)).row()), Q_ARG(QVariant, val));
|
||||
QMetaObject::invokeMethod(_model.value<QAbstractTableModel *>(), "insertRow",
|
||||
Q_ARG(int, mapToSource(index(rowIndex, 0)).row()),
|
||||
Q_ARG(QVariant, val));
|
||||
}
|
||||
|
||||
[[maybe_unused]] void FluTableSortProxyModel::removeRow(int rowIndex, int rows) {
|
||||
QMetaObject::invokeMethod(_model.value<QAbstractTableModel *>(), "removeRow", Q_ARG(int, mapToSource(index(rowIndex, 0)).row()), Q_ARG(int, rows));
|
||||
QMetaObject::invokeMethod(_model.value<QAbstractTableModel *>(), "removeRow",
|
||||
Q_ARG(int, mapToSource(index(rowIndex, 0)).row()), Q_ARG(int, rows));
|
||||
}
|
||||
|
@ -7,8 +7,8 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
class FluTableSortProxyModel : public QSortFilterProxyModel {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO_P(QVariant, model)
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO_P(QVariant, model)
|
||||
QML_NAMED_ELEMENT(FluTableSortProxyModel)
|
||||
public:
|
||||
explicit FluTableSortProxyModel(QSortFilterProxyModel *parent = nullptr);
|
||||
|
@ -10,16 +10,17 @@
|
||||
* @brief The FluTextStyle class
|
||||
*/
|
||||
class FluTextStyle : public QObject {
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Q_PROPERTY_AUTO(QString, family)
|
||||
Q_PROPERTY_AUTO(QFont, Caption);
|
||||
Q_PROPERTY_AUTO(QFont, Body);
|
||||
Q_PROPERTY_AUTO(QFont, BodyStrong);
|
||||
Q_PROPERTY_AUTO(QFont, Subtitle);
|
||||
Q_PROPERTY_AUTO(QFont, Title);
|
||||
Q_PROPERTY_AUTO(QFont, TitleLarge);
|
||||
Q_PROPERTY_AUTO(QFont, Display);
|
||||
Q_PROPERTY_AUTO(QString, family)
|
||||
Q_PROPERTY_AUTO(QFont, Caption)
|
||||
Q_PROPERTY_AUTO(QFont, Body)
|
||||
Q_PROPERTY_AUTO(QFont, BodyStrong)
|
||||
Q_PROPERTY_AUTO(QFont, Subtitle)
|
||||
Q_PROPERTY_AUTO(QFont, Title)
|
||||
Q_PROPERTY_AUTO(QFont, TitleLarge)
|
||||
Q_PROPERTY_AUTO(QFont, Display)
|
||||
QML_NAMED_ELEMENT(FluTextStyle)
|
||||
QML_SINGLETON
|
||||
|
||||
@ -27,7 +28,9 @@ private:
|
||||
explicit FluTextStyle(QObject *parent = nullptr);
|
||||
|
||||
public:
|
||||
SINGLETON(FluTextStyle)
|
||||
SINGLETON(FluTextStyle)
|
||||
|
||||
static FluTextStyle *create(QQmlEngine *, QJSEngine *) { return getInstance(); }
|
||||
static FluTextStyle *create(QQmlEngine *, QJSEngine *) {
|
||||
return getInstance();
|
||||
}
|
||||
};
|
||||
|
@ -24,15 +24,13 @@ FluTheme::FluTheme(QObject *parent) : QObject{parent} {
|
||||
_blurBehindWindowEnabled = false;
|
||||
QGuiApplication::instance()->installEventFilter(this);
|
||||
refreshColors();
|
||||
connect(this, &FluTheme::darkModeChanged, this, [=] {
|
||||
Q_EMIT darkChanged();
|
||||
});
|
||||
connect(this, &FluTheme::darkModeChanged, this, [=] { Q_EMIT darkChanged(); });
|
||||
connect(this, &FluTheme::darkChanged, this, [=] { refreshColors(); });
|
||||
connect(this, &FluTheme::accentColorChanged, this, [=] { refreshColors(); });
|
||||
connect(&_watcher, &QFileSystemWatcher::fileChanged, this, [=](const QString &path) {
|
||||
Q_EMIT desktopImagePathChanged();
|
||||
});
|
||||
connect(this, &FluTheme::blurBehindWindowEnabledChanged, this, [=] { checkUpdateDesktopImage(); });
|
||||
connect(&_watcher, &QFileSystemWatcher::fileChanged, this,
|
||||
[=](const QString &path) { Q_EMIT desktopImagePathChanged(); });
|
||||
connect(this, &FluTheme::blurBehindWindowEnabledChanged, this,
|
||||
[=] { checkUpdateDesktopImage(); });
|
||||
startTimer(1000);
|
||||
}
|
||||
|
||||
@ -47,11 +45,16 @@ void FluTheme::refreshColors() {
|
||||
fontSecondaryColor(isDark ? QColor(222, 222, 222, 255) : QColor(102, 102, 102, 255));
|
||||
fontTertiaryColor(isDark ? QColor(200, 200, 200, 255) : QColor(153, 153, 153, 255));
|
||||
itemNormalColor(isDark ? QColor(255, 255, 255, 0) : QColor(0, 0, 0, 0));
|
||||
frameColor(isDark ? QColor(56, 56, 56, qRound(255 * 0.8)) : QColor(243, 243, 243, qRound(255 * 0.8)));
|
||||
frameActiveColor(isDark ? QColor(48, 48, 48, qRound(255 * 0.8)) : QColor(255, 255, 255, qRound(255 * 0.8)));
|
||||
itemHoverColor(isDark ? QColor(255, 255, 255, qRound(255 * 0.06)) : QColor(0, 0, 0, qRound(255 * 0.03)));
|
||||
itemPressColor(isDark ? QColor(255, 255, 255, qRound(255 * 0.09)) : QColor(0, 0, 0, qRound(255 * 0.06)));
|
||||
itemCheckColor(isDark ? QColor(255, 255, 255, qRound(255 * 0.12)) : QColor(0, 0, 0, qRound(255 * 0.09)));
|
||||
frameColor(isDark ? QColor(56, 56, 56, qRound(255 * 0.8))
|
||||
: QColor(243, 243, 243, qRound(255 * 0.8)));
|
||||
frameActiveColor(isDark ? QColor(48, 48, 48, qRound(255 * 0.8))
|
||||
: QColor(255, 255, 255, qRound(255 * 0.8)));
|
||||
itemHoverColor(isDark ? QColor(255, 255, 255, qRound(255 * 0.06))
|
||||
: QColor(0, 0, 0, qRound(255 * 0.03)));
|
||||
itemPressColor(isDark ? QColor(255, 255, 255, qRound(255 * 0.09))
|
||||
: QColor(0, 0, 0, qRound(255 * 0.06)));
|
||||
itemCheckColor(isDark ? QColor(255, 255, 255, qRound(255 * 0.12))
|
||||
: QColor(0, 0, 0, qRound(255 * 0.09)));
|
||||
}
|
||||
|
||||
bool FluTheme::eventFilter(QObject *, QEvent *event) {
|
||||
|
@ -16,28 +16,28 @@
|
||||
* @brief The FluTheme class
|
||||
*/
|
||||
class FluTheme : public QObject {
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool dark READ dark NOTIFY darkChanged)
|
||||
Q_PROPERTY_AUTO_P(FluAccentColor*, accentColor);
|
||||
Q_PROPERTY_AUTO(QColor, primaryColor);
|
||||
Q_PROPERTY_AUTO(QColor, backgroundColor);
|
||||
Q_PROPERTY_AUTO(QColor, dividerColor);
|
||||
Q_PROPERTY_AUTO(QColor, windowBackgroundColor);
|
||||
Q_PROPERTY_AUTO(QColor, windowActiveBackgroundColor);
|
||||
Q_PROPERTY_AUTO(QColor, fontPrimaryColor);
|
||||
Q_PROPERTY_AUTO(QColor, fontSecondaryColor);
|
||||
Q_PROPERTY_AUTO(QColor, fontTertiaryColor);
|
||||
Q_PROPERTY_AUTO(QColor, itemNormalColor);
|
||||
Q_PROPERTY_AUTO(QColor, frameColor);
|
||||
Q_PROPERTY_AUTO(QColor, frameActiveColor);
|
||||
Q_PROPERTY_AUTO(QColor, itemHoverColor);
|
||||
Q_PROPERTY_AUTO(QColor, itemPressColor);
|
||||
Q_PROPERTY_AUTO(QColor, itemCheckColor);
|
||||
Q_PROPERTY_AUTO(QString, desktopImagePath);
|
||||
Q_PROPERTY_AUTO(int, darkMode);
|
||||
Q_PROPERTY_AUTO(bool, nativeText);
|
||||
Q_PROPERTY_AUTO(bool, animationEnabled);
|
||||
Q_PROPERTY_AUTO(bool, blurBehindWindowEnabled);
|
||||
Q_PROPERTY_AUTO_P(FluAccentColor *, accentColor)
|
||||
Q_PROPERTY_AUTO(QColor, primaryColor)
|
||||
Q_PROPERTY_AUTO(QColor, backgroundColor)
|
||||
Q_PROPERTY_AUTO(QColor, dividerColor)
|
||||
Q_PROPERTY_AUTO(QColor, windowBackgroundColor)
|
||||
Q_PROPERTY_AUTO(QColor, windowActiveBackgroundColor)
|
||||
Q_PROPERTY_AUTO(QColor, fontPrimaryColor)
|
||||
Q_PROPERTY_AUTO(QColor, fontSecondaryColor)
|
||||
Q_PROPERTY_AUTO(QColor, fontTertiaryColor)
|
||||
Q_PROPERTY_AUTO(QColor, itemNormalColor)
|
||||
Q_PROPERTY_AUTO(QColor, frameColor)
|
||||
Q_PROPERTY_AUTO(QColor, frameActiveColor)
|
||||
Q_PROPERTY_AUTO(QColor, itemHoverColor)
|
||||
Q_PROPERTY_AUTO(QColor, itemPressColor)
|
||||
Q_PROPERTY_AUTO(QColor, itemCheckColor)
|
||||
Q_PROPERTY_AUTO(QString, desktopImagePath)
|
||||
Q_PROPERTY_AUTO(int, darkMode)
|
||||
Q_PROPERTY_AUTO(bool, nativeText)
|
||||
Q_PROPERTY_AUTO(bool, animationEnabled)
|
||||
Q_PROPERTY_AUTO(bool, blurBehindWindowEnabled)
|
||||
QML_NAMED_ELEMENT(FluTheme)
|
||||
QML_SINGLETON
|
||||
|
||||
@ -49,17 +49,18 @@ private:
|
||||
void refreshColors();
|
||||
|
||||
protected:
|
||||
|
||||
void timerEvent(QTimerEvent *event) override;
|
||||
|
||||
void checkUpdateDesktopImage();
|
||||
|
||||
public:
|
||||
SINGLETON(FluTheme)
|
||||
SINGLETON(FluTheme)
|
||||
|
||||
Q_SIGNAL void darkChanged();
|
||||
|
||||
static FluTheme *create(QQmlEngine *, QJSEngine *) { return getInstance(); }
|
||||
static FluTheme *create(QQmlEngine *, QJSEngine *) {
|
||||
return getInstance();
|
||||
}
|
||||
|
||||
bool dark() const;
|
||||
|
||||
@ -67,4 +68,4 @@ private:
|
||||
bool _systemDark;
|
||||
QFileSystemWatcher _watcher;
|
||||
QMutex _mutex;
|
||||
};
|
||||
};
|
||||
|
@ -17,15 +17,14 @@
|
||||
#include <QSettings>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#pragma comment (lib, "user32.lib")
|
||||
# pragma comment(lib, "user32.lib")
|
||||
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
# include <windows.h>
|
||||
# include <windowsx.h>
|
||||
|
||||
#endif
|
||||
|
||||
FluTools::FluTools(QObject *parent) : QObject{parent} {
|
||||
|
||||
}
|
||||
|
||||
void FluTools::clipText(const QString &text) {
|
||||
@ -164,11 +163,12 @@ void FluTools::showFileInFolder(const QString &path) {
|
||||
#if defined(Q_OS_LINUX)
|
||||
QFileInfo fileInfo(path);
|
||||
auto process = "xdg-open";
|
||||
auto arguments = { fileInfo.absoluteDir().absolutePath() };
|
||||
auto arguments = {fileInfo.absoluteDir().absolutePath()};
|
||||
QProcess::startDetached(process, arguments);
|
||||
#endif
|
||||
#if defined(Q_OS_MACOS)
|
||||
QProcess::execute("/usr/bin/osascript", {"-e", "tell application \"Finder\" to reveal POSIX file \"" + path + "\""});
|
||||
QProcess::execute("/usr/bin/osascript",
|
||||
{"-e", "tell application \"Finder\" to reveal POSIX file \"" + path + "\""});
|
||||
QProcess::execute("/usr/bin/osascript", {"-e", "tell application \"Finder\" to activate"});
|
||||
#endif
|
||||
}
|
||||
@ -206,7 +206,9 @@ int FluTools::cursorScreenIndex() {
|
||||
|
||||
int FluTools::windowBuildNumber() {
|
||||
#if defined(Q_OS_WIN)
|
||||
QSettings regKey{QString::fromUtf8(R"(HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion)"), QSettings::NativeFormat};
|
||||
QSettings regKey{
|
||||
QString::fromUtf8(R"(HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion)"),
|
||||
QSettings::NativeFormat};
|
||||
if (regKey.contains(QString::fromUtf8("CurrentBuildNumber"))) {
|
||||
auto buildNumber = regKey.value(QString::fromUtf8("CurrentBuildNumber")).toInt();
|
||||
return buildNumber;
|
||||
@ -289,7 +291,7 @@ QString FluTools::getWallpaperFilePath() {
|
||||
process.start("osascript", args);
|
||||
process.waitForFinished();
|
||||
QByteArray result = process.readAllStandardOutput().trimmed();
|
||||
if(result.isEmpty()){
|
||||
if (result.isEmpty()) {
|
||||
return "/System/Library/CoreServices/DefaultDesktop.heic";
|
||||
}
|
||||
return result;
|
||||
@ -313,5 +315,7 @@ QColor FluTools::imageMainColor(const QImage &image, double bright) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return QColor(int(bright * r / t) > 255 ? 255 : int(bright * r / t), int(bright * g / t) > 255 ? 255 : int(bright * g / t), int(bright * b / t) > 255 ? 255 : int(bright * b / t));
|
||||
return QColor(int(bright * r / t) > 255 ? 255 : int(bright * r / t),
|
||||
int(bright * g / t) > 255 ? 255 : int(bright * g / t),
|
||||
int(bright * b / t) > 255 ? 255 : int(bright * b / t));
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
* @brief The FluTools class
|
||||
*/
|
||||
class FluTools : public QObject {
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
QML_NAMED_ELEMENT(FluTools)
|
||||
QML_SINGLETON
|
||||
|
||||
@ -19,9 +19,11 @@ private:
|
||||
explicit FluTools(QObject *parent = nullptr);
|
||||
|
||||
public:
|
||||
SINGLETON(FluTools)
|
||||
SINGLETON(FluTools)
|
||||
|
||||
static FluTools *create(QQmlEngine *, QJSEngine *) { return getInstance(); }
|
||||
static FluTools *create(QQmlEngine *, QJSEngine *) {
|
||||
return getInstance();
|
||||
}
|
||||
|
||||
Q_INVOKABLE int qtMajor();
|
||||
|
||||
|
@ -31,8 +31,8 @@ QVariant FluTreeModel::data(const QModelIndex &index, int role) const {
|
||||
|
||||
QHash<int, QByteArray> FluTreeModel::roleNames() const {
|
||||
return {
|
||||
{TreeModelRoles::RowModel, "rowModel"},
|
||||
{TreeModelRoles::ColumnModel, "columnModel"}
|
||||
{TreeModelRoles::RowModel, "rowModel" },
|
||||
{TreeModelRoles::ColumnModel, "columnModel"}
|
||||
};
|
||||
}
|
||||
|
||||
@ -90,9 +90,9 @@ void FluTreeModel::checkRow(int row, bool checked) {
|
||||
QList<FluTreeNode *> children = item->_children;
|
||||
if (!children.isEmpty()) {
|
||||
std::reverse(children.begin(), children.end());
|
||||
foreach (auto c, children) {
|
||||
stack.append(c);
|
||||
}
|
||||
foreach (auto c, children) {
|
||||
stack.append(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -102,7 +102,6 @@ void FluTreeModel::checkRow(int row, bool checked) {
|
||||
itemData->_checked = checked;
|
||||
}
|
||||
Q_EMIT dataChanged(index(0, 0), index(rowCount() - 1, 0));
|
||||
|
||||
}
|
||||
|
||||
void FluTreeModel::setDataSource(QList<QMap<QString, QVariant>> data) {
|
||||
@ -184,9 +183,9 @@ void FluTreeModel::expand(int row) {
|
||||
QList<FluTreeNode *> children = item->_children;
|
||||
if (!children.isEmpty()) {
|
||||
std::reverse(children.begin(), children.end());
|
||||
foreach (auto c, children) {
|
||||
stack.append(c);
|
||||
}
|
||||
foreach (auto c, children) {
|
||||
stack.append(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
insertRows(row + 1, insertData);
|
||||
@ -223,9 +222,9 @@ void FluTreeModel::allExpand() {
|
||||
QList<FluTreeNode *> children = item->_children;
|
||||
if (!children.isEmpty()) {
|
||||
std::reverse(children.begin(), children.end());
|
||||
foreach (auto c, children) {
|
||||
stack.append(c);
|
||||
}
|
||||
foreach (auto c, children) {
|
||||
stack.append(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
_rows = data;
|
||||
@ -245,9 +244,9 @@ void FluTreeModel::allCollapse() {
|
||||
QList<FluTreeNode *> children = item->_children;
|
||||
if (!children.isEmpty()) {
|
||||
std::reverse(children.begin(), children.end());
|
||||
foreach (auto c, children) {
|
||||
stack.append(c);
|
||||
}
|
||||
foreach (auto c, children) {
|
||||
stack.append(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
_rows = _root->_children;
|
||||
@ -256,10 +255,10 @@ void FluTreeModel::allCollapse() {
|
||||
|
||||
QVariant FluTreeModel::selectionModel() {
|
||||
QList<FluTreeNode *> data;
|
||||
foreach (auto item, _dataSource) {
|
||||
if (item->checked()) {
|
||||
data.append(item);
|
||||
}
|
||||
foreach (auto item, _dataSource) {
|
||||
if (item->checked()) {
|
||||
data.append(item);
|
||||
}
|
||||
}
|
||||
return QVariant::fromValue(data);
|
||||
}
|
||||
|
@ -7,11 +7,12 @@
|
||||
#include <QtQml/qqml.h>
|
||||
#include "stdafx.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief The FluTreeNode class
|
||||
*/
|
||||
class FluTreeNode : public QObject {
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QVariantMap data READ data CONSTANT)
|
||||
Q_PROPERTY(int depth READ depth CONSTANT)
|
||||
Q_PROPERTY(bool isExpanded READ isExpanded CONSTANT)
|
||||
@ -19,13 +20,21 @@ Q_OBJECT
|
||||
public:
|
||||
explicit FluTreeNode(QObject *parent = nullptr);
|
||||
|
||||
[[nodiscard]] Q_INVOKABLE int depth() const { return _depth; };
|
||||
[[nodiscard]] Q_INVOKABLE int depth() const {
|
||||
return _depth;
|
||||
};
|
||||
|
||||
[[nodiscard]] Q_INVOKABLE bool isExpanded() const { return _isExpanded; };
|
||||
[[nodiscard]] Q_INVOKABLE bool isExpanded() const {
|
||||
return _isExpanded;
|
||||
};
|
||||
|
||||
[[nodiscard]] Q_INVOKABLE QVariantMap data() const { return _data; };
|
||||
[[nodiscard]] Q_INVOKABLE QVariantMap data() const {
|
||||
return _data;
|
||||
};
|
||||
|
||||
[[nodiscard]] Q_INVOKABLE bool hasChildren() const { return !_children.isEmpty(); };
|
||||
[[nodiscard]] Q_INVOKABLE bool hasChildren() const {
|
||||
return !_children.isEmpty();
|
||||
};
|
||||
|
||||
Q_INVOKABLE bool hasNextNodeByIndex(int index) {
|
||||
FluTreeNode *p = this;
|
||||
@ -87,15 +96,12 @@ public:
|
||||
};
|
||||
|
||||
class FluTreeModel : public QAbstractTableModel {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(int, dataSourceSize)
|
||||
Q_PROPERTY_AUTO(QList<QVariantMap>, columnSource)
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(int, dataSourceSize)
|
||||
Q_PROPERTY_AUTO(QList<QVariantMap>, columnSource)
|
||||
QML_NAMED_ELEMENT(FluTreeModel)
|
||||
public:
|
||||
enum TreeModelRoles {
|
||||
RowModel = 0x0101,
|
||||
ColumnModel = 0x0102
|
||||
};
|
||||
enum TreeModelRoles { RowModel = 0x0101, ColumnModel = 0x0102 };
|
||||
|
||||
explicit FluTreeModel(QObject *parent = nullptr);
|
||||
|
||||
@ -103,7 +109,8 @@ public:
|
||||
|
||||
[[nodiscard]] int columnCount(const QModelIndex &parent = {}) const override;
|
||||
|
||||
[[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
[[nodiscard]] QVariant data(const QModelIndex &index,
|
||||
int role = Qt::DisplayRole) const override;
|
||||
|
||||
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
|
@ -17,6 +17,7 @@ FluWatermark::FluWatermark(QQuickItem *parent) : QQuickPaintedItem(parent) {
|
||||
connect(this, &FluWatermark::textSizeChanged, this, [=] { update(); });
|
||||
}
|
||||
|
||||
|
||||
void FluWatermark::paint(QPainter *painter) {
|
||||
QFont font;
|
||||
font.setFamily(FluTextStyle::getInstance()->family());
|
||||
@ -37,7 +38,8 @@ void FluWatermark::paint(QPainter *painter) {
|
||||
painter->save();
|
||||
painter->translate(centerX, centerY);
|
||||
painter->rotate(_rotate);
|
||||
painter->drawText(QRectF(-fontWidth / 2.0, -fontHeight / 2.0, fontWidth, fontHeight), _text);
|
||||
painter->drawText(QRectF(-fontWidth / 2.0, -fontHeight / 2.0, fontWidth, fontHeight),
|
||||
_text);
|
||||
painter->restore();
|
||||
}
|
||||
}
|
||||
|
@ -8,10 +8,10 @@
|
||||
* @brief The FluentUI class
|
||||
*/
|
||||
class FluentUI : public QObject {
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SINGLETON(FluentUI)
|
||||
SINGLETON(FluentUI)
|
||||
|
||||
Q_DECL_EXPORT void registerTypes(QQmlEngine *engine);
|
||||
|
||||
@ -23,4 +23,4 @@ private:
|
||||
const int _major = 1;
|
||||
const int _minor = 0;
|
||||
const char *_uri = "FluentUI";
|
||||
};
|
||||
};
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @brief The FluentUIPlugin class
|
||||
*/
|
||||
class FluentUIPlugin : public QQmlExtensionPlugin {
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
|
||||
public:
|
||||
@ -15,4 +15,4 @@ public:
|
||||
void registerTypes(const char *uri) Q_DECL_OVERRIDE;
|
||||
|
||||
void initializeEngine(QQmlEngine *engine, const char *uri) Q_DECL_OVERRIDE;
|
||||
};
|
||||
};
|
||||
|
@ -1,24 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
/**
|
||||
* @brief The Singleton class
|
||||
*/
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
class Singleton {
|
||||
public:
|
||||
static T *getInstance();
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
T *Singleton<T>::getInstance() {
|
||||
static T *instance = new T();
|
||||
return instance;
|
||||
}
|
||||
|
||||
#define SINGLETON(Class) \
|
||||
private: \
|
||||
friend class Singleton<Class>; \
|
||||
public: \
|
||||
static Class* getInstance() { \
|
||||
return Singleton<Class>::getInstance(); \
|
||||
}
|
||||
#define SINGLETON(Class) \
|
||||
private: \
|
||||
friend class Singleton<Class>; \
|
||||
\
|
||||
public: \
|
||||
static Class *getInstance() { \
|
||||
return Singleton<Class>::getInstance(); \
|
||||
}
|
||||
|
82
src/stdafx.h
82
src/stdafx.h
@ -1,50 +1,48 @@
|
||||
#pragma once
|
||||
|
||||
#define Q_PROPERTY_AUTO_P(TYPE, M) \
|
||||
Q_PROPERTY(TYPE M MEMBER _##M NOTIFY M##Changed) \
|
||||
public: \
|
||||
Q_SIGNAL void M##Changed(); \
|
||||
void M(TYPE in_##M) \
|
||||
{ \
|
||||
_##M = in_##M; \
|
||||
Q_EMIT M##Changed(); \
|
||||
} \
|
||||
TYPE M() \
|
||||
{ \
|
||||
return _##M; \
|
||||
} \
|
||||
private: \
|
||||
|
||||
#define Q_PROPERTY_AUTO_P(TYPE, M) \
|
||||
Q_PROPERTY(TYPE M MEMBER _##M NOTIFY M##Changed) \
|
||||
public: \
|
||||
Q_SIGNAL void M##Changed(); \
|
||||
void M(TYPE in_##M) { \
|
||||
_##M = in_##M; \
|
||||
Q_EMIT M##Changed(); \
|
||||
} \
|
||||
TYPE M() { \
|
||||
return _##M; \
|
||||
} \
|
||||
\
|
||||
private: \
|
||||
TYPE _##M;
|
||||
|
||||
#define Q_PROPERTY_AUTO(TYPE, M) \
|
||||
Q_PROPERTY(TYPE M MEMBER _##M NOTIFY M##Changed) \
|
||||
public: \
|
||||
Q_SIGNAL void M##Changed(); \
|
||||
void M(const TYPE& in_##M) \
|
||||
{ \
|
||||
_##M = in_##M; \
|
||||
Q_EMIT M##Changed(); \
|
||||
} \
|
||||
TYPE M() \
|
||||
{ \
|
||||
return _##M; \
|
||||
} \
|
||||
private: \
|
||||
#define Q_PROPERTY_AUTO(TYPE, M) \
|
||||
Q_PROPERTY(TYPE M MEMBER _##M NOTIFY M##Changed) \
|
||||
public: \
|
||||
Q_SIGNAL void M##Changed(); \
|
||||
void M(const TYPE &in_##M) { \
|
||||
_##M = in_##M; \
|
||||
Q_EMIT M##Changed(); \
|
||||
} \
|
||||
TYPE M() { \
|
||||
return _##M; \
|
||||
} \
|
||||
\
|
||||
private: \
|
||||
TYPE _##M;
|
||||
|
||||
|
||||
#define Q_PROPERTY_READONLY_AUTO(TYPE, M) \
|
||||
Q_PROPERTY(TYPE M READ M NOTIFY M##Changed FINAL) \
|
||||
public: \
|
||||
Q_SIGNAL void M##Changed(); \
|
||||
void M(const TYPE& in_##M) \
|
||||
{ \
|
||||
_##M = in_##M; \
|
||||
Q_EMIT M##Changed(); \
|
||||
} \
|
||||
TYPE M() \
|
||||
{ \
|
||||
return _##M; \
|
||||
} \
|
||||
private: \
|
||||
#define Q_PROPERTY_READONLY_AUTO(TYPE, M) \
|
||||
Q_PROPERTY(TYPE M READ M NOTIFY M##Changed FINAL) \
|
||||
public: \
|
||||
Q_SIGNAL void M##Changed(); \
|
||||
void M(const TYPE &in_##M) { \
|
||||
_##M = in_##M; \
|
||||
Q_EMIT M##Changed(); \
|
||||
} \
|
||||
TYPE M() { \
|
||||
return _##M; \
|
||||
} \
|
||||
\
|
||||
private: \
|
||||
TYPE _##M;
|
||||
|
Reference in New Issue
Block a user