mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2024-11-24 19:50:44 +08:00
Compare commits
No commits in common. "531f659e591402c4b390d0b445744a44368758b3" and "6a31e865057e939ddee85a5c020c7a82ef80f14c" have entirely different histories.
531f659e59
...
6a31e86505
@ -171,10 +171,5 @@ if (CMAKE_BUILD_TYPE MATCHES "Release")
|
||||
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
target_sources(Script-DeployRelease
|
||||
PRIVATE
|
||||
src/component/OpenGLItem.h src/component/OpenGLItem.cpp
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
@ -209,7 +209,5 @@
|
||||
<file>qml/page/T_GroupBox.qml</file>
|
||||
<file>res/image/bg_scenic.jpg</file>
|
||||
<file>qml/window/FluentInitializrWindow.qml</file>
|
||||
<file>qml/page/T_OpenGL.qml</file>
|
||||
</qresource>
|
||||
<qresource prefix="/"/>
|
||||
</RCC>
|
||||
|
@ -87,22 +87,22 @@
|
||||
<context>
|
||||
<name>InitializrHelper</name>
|
||||
<message>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="69"/>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="77"/>
|
||||
<source>The name cannot be empty</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="73"/>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="81"/>
|
||||
<source>The creation path cannot be empty</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="78"/>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="86"/>
|
||||
<source>The path does not exist</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="84"/>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="92"/>
|
||||
<source>%1 folder already exists</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
@ -475,7 +475,7 @@
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/global/ItemsOriginal.qml" line="430"/>
|
||||
<source>OpenGL</source>
|
||||
<source>CodeEditor</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
@ -550,6 +550,11 @@
|
||||
</context>
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="307"/>
|
||||
<source>Dark Mode</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="83"/>
|
||||
<location filename="qml/window/MainWindow.qml" line="91"/>
|
||||
@ -612,11 +617,6 @@
|
||||
<source>Previous</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="307"/>
|
||||
<source>Dark Mode</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/window/MainWindow.qml" line="307"/>
|
||||
<source>Here you can switch to night mode.</source>
|
||||
@ -1626,14 +1626,6 @@ My only desire is to be permitted to drive out the traitors and restore the Han.
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>T_OpenGL</name>
|
||||
<message>
|
||||
<location filename="qml/page/T_OpenGL.qml" line="11"/>
|
||||
<source>OpenGL</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>T_Pagination</name>
|
||||
<message>
|
||||
|
@ -87,22 +87,22 @@
|
||||
<context>
|
||||
<name>InitializrHelper</name>
|
||||
<message>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="69"/>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="77"/>
|
||||
<source>The name cannot be empty</source>
|
||||
<translation type="unfinished">名称不能为空</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="73"/>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="81"/>
|
||||
<source>The creation path cannot be empty</source>
|
||||
<translation type="unfinished">创建路径不能为空</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="78"/>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="86"/>
|
||||
<source>The path does not exist</source>
|
||||
<translation type="unfinished">路径不存在</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="84"/>
|
||||
<location filename="src/helper/InitializrHelper.cpp" line="92"/>
|
||||
<source>%1 folder already exists</source>
|
||||
<translation type="unfinished">%1 文件夹已经存在</translation>
|
||||
</message>
|
||||
@ -475,7 +475,7 @@
|
||||
</message>
|
||||
<message>
|
||||
<location filename="qml/global/ItemsOriginal.qml" line="430"/>
|
||||
<source>OpenGL</source>
|
||||
<source>CodeEditor</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
@ -1665,14 +1665,6 @@ My only desire is to be permitted to drive out the traitors and restore the Han.
|
||||
<translation type="unfinished">网络</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>T_OpenGL</name>
|
||||
<message>
|
||||
<location filename="qml/page/T_OpenGL.qml" line="11"/>
|
||||
<source>OpenGL</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>T_Pagination</name>
|
||||
<message>
|
||||
|
@ -427,9 +427,9 @@ FluObject{
|
||||
title: qsTr("Other")
|
||||
icon: FluentIcons.Shop
|
||||
FluPaneItem{
|
||||
title: qsTr("OpenGL")
|
||||
title: qsTr("CodeEditor")
|
||||
menuDelegate: paneItemMenu
|
||||
url: "qrc:/example/qml/page/T_OpenGL.qml"
|
||||
url: "qrc:/example/qml/page/T_CodeEditor.qml"
|
||||
onTap: { navigationView.push(url) }
|
||||
}
|
||||
FluPaneItem{
|
||||
|
@ -1,26 +0,0 @@
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Layouts 1.15
|
||||
import QtQuick.Window 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import FluentUI 1.0
|
||||
import example 1.0
|
||||
import "../component"
|
||||
|
||||
FluContentPage{
|
||||
|
||||
title: qsTr("OpenGL")
|
||||
|
||||
FluFrame{
|
||||
anchors.fill: parent
|
||||
OpenGLItem{
|
||||
anchors.fill: parent
|
||||
SequentialAnimation on t {
|
||||
NumberAnimation { to: 1; duration: 2500; easing.type: Easing.InQuad }
|
||||
NumberAnimation { to: 0; duration: 2500; easing.type: Easing.OutQuad }
|
||||
loops: Animation.Infinite
|
||||
running: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,15 +1,17 @@
|
||||
#include "AppInfo.h"
|
||||
|
||||
#include <QQmlContext>
|
||||
#include <QDebug>
|
||||
#include <QGuiApplication>
|
||||
#include "Version.h"
|
||||
|
||||
AppInfo::AppInfo(QObject *parent)
|
||||
: QObject{parent} {
|
||||
: QObject{parent}
|
||||
{
|
||||
version(APPLICATION_VERSION);
|
||||
}
|
||||
|
||||
[[maybe_unused]] void AppInfo::testCrash() {
|
||||
void AppInfo::testCrash(){
|
||||
auto *crash = reinterpret_cast<volatile int *>(0);
|
||||
*crash = 0;
|
||||
}
|
||||
|
@ -1,18 +1,20 @@
|
||||
#pragma once
|
||||
#ifndef APPINFO_H
|
||||
#define APPINFO_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include "stdafx.h"
|
||||
#include "singleton.h"
|
||||
|
||||
class AppInfo : public QObject {
|
||||
class AppInfo : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(QString,version)
|
||||
private:
|
||||
explicit AppInfo(QObject *parent = nullptr);
|
||||
|
||||
public:
|
||||
SINGLETON(AppInfo)
|
||||
|
||||
Q_INVOKABLE [[maybe_unused]] void testCrash();
|
||||
Q_INVOKABLE void testCrash();
|
||||
};
|
||||
|
||||
#endif // APPINFO_H
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef APP_DUMP_H
|
||||
#define APP_DUMP_H
|
||||
|
||||
#include <Windows.h>
|
||||
#include <DbgHelp.h>
|
||||
@ -11,22 +12,22 @@
|
||||
|
||||
#pragma comment(lib, "Dbghelp.lib")
|
||||
|
||||
static void
|
||||
miniDumpWriteDump(HANDLE hProcess, DWORD ProcessId, HANDLE hFile, CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam) {
|
||||
typedef HRESULT (WINAPI *MiniDumpWriteDumpPtr)(HANDLE hProcess, DWORD ProcessId, HANDLE hFile, MINIDUMP_TYPE DumpType, CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
|
||||
CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam);
|
||||
static void miniDumpWriteDump(HANDLE hProcess,DWORD ProcessId,HANDLE hFile,MINIDUMP_TYPE DumpType,CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam){
|
||||
typedef HRESULT (WINAPI* MiniDumpWriteDumpPtr)(HANDLE hProcess,DWORD ProcessId,HANDLE hFile,MINIDUMP_TYPE DumpType,CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam);
|
||||
HMODULE module = LoadLibraryW(L"Dbghelp.dll");
|
||||
if (module) {
|
||||
if (module)
|
||||
{
|
||||
MiniDumpWriteDumpPtr mini_dump_write_dump;
|
||||
mini_dump_write_dump= reinterpret_cast<MiniDumpWriteDumpPtr>(GetProcAddress(module, "MiniDumpWriteDump"));
|
||||
if (mini_dump_write_dump) {
|
||||
mini_dump_write_dump(hProcess, ProcessId, hFile, static_cast<MINIDUMP_TYPE>(80), ExceptionParam, nullptr, CallbackParam);
|
||||
if (mini_dump_write_dump)
|
||||
{
|
||||
mini_dump_write_dump(hProcess,ProcessId,hFile,DumpType,ExceptionParam,UserStreamParam,CallbackParam);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CALLBACK MyMiniDumpCallback(PVOID, const PMINIDUMP_CALLBACK_INPUT input, PMINIDUMP_CALLBACK_OUTPUT output) {
|
||||
if (input == nullptr || output == nullptr)
|
||||
if (input == NULL || output == NULL)
|
||||
return FALSE;
|
||||
|
||||
BOOL ret = FALSE;
|
||||
@ -42,8 +43,7 @@ BOOL CALLBACK MyMiniDumpCallback(PVOID, const PMINIDUMP_CALLBACK_INPUT input, PM
|
||||
output->ModuleWriteFlags &= ~ModuleWriteModule;
|
||||
}
|
||||
ret = TRUE;
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -51,15 +51,16 @@ BOOL CALLBACK MyMiniDumpCallback(PVOID, const PMINIDUMP_CALLBACK_INPUT input, PM
|
||||
}
|
||||
|
||||
void WriteDump(EXCEPTION_POINTERS* exp, const std::wstring& path) {
|
||||
HANDLE h = ::CreateFileW(path.c_str(), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
HANDLE h = ::CreateFileW(path.c_str(), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
MINIDUMP_EXCEPTION_INFORMATION info;
|
||||
info.ThreadId = ::GetCurrentThreadId();
|
||||
info.ExceptionPointers = exp;
|
||||
info.ClientPointers = FALSE;
|
||||
MINIDUMP_CALLBACK_INFORMATION mci;
|
||||
mci.CallbackRoutine = (MINIDUMP_CALLBACK_ROUTINE)MyMiniDumpCallback;
|
||||
mci.CallbackParam = nullptr;
|
||||
miniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), h, &info, &mci);
|
||||
mci.CallbackParam = 0;
|
||||
MINIDUMP_TYPE mdt = (MINIDUMP_TYPE)(MiniDumpWithIndirectlyReferencedMemory | MiniDumpScanMemory);
|
||||
miniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), h, mdt, &info, NULL, &mci);
|
||||
::CloseHandle(h);
|
||||
}
|
||||
|
||||
@ -74,6 +75,8 @@ LONG WINAPI MyUnhandledExceptionFilter(EXCEPTION_POINTERS *exp) {
|
||||
WriteDump(exp, dumpFilePath.toStdWString());
|
||||
QStringList arguments;
|
||||
arguments << "-crashed=" + dumpFilePath;
|
||||
QProcess::startDetached(QGuiApplication::applicationFilePath(), arguments);
|
||||
QProcess::startDetached(qApp->applicationFilePath(), arguments);
|
||||
return EXCEPTION_EXECUTE_HANDLER;
|
||||
}
|
||||
|
||||
#endif // APP_DUMP_H
|
||||
|
@ -3,13 +3,12 @@
|
||||
#include <QQuickItemGrabResult>
|
||||
#include <QPainterPath>
|
||||
|
||||
CircularReveal::CircularReveal(QQuickItem *parent) : QQuickPaintedItem(parent) {
|
||||
_target = nullptr;
|
||||
_radius = 0;
|
||||
CircularReveal::CircularReveal(QQuickItem* parent) : QQuickPaintedItem(parent)
|
||||
{
|
||||
_anim = new QPropertyAnimation(this, "radius", this);
|
||||
setVisible(false);
|
||||
_anim->setDuration(333);
|
||||
_anim->setEasingCurve(QEasingCurve::OutCubic);
|
||||
setVisible(false);
|
||||
connect(_anim, &QPropertyAnimation::finished,this,[=](){
|
||||
update();
|
||||
setVisible(false);
|
||||
@ -20,7 +19,8 @@ CircularReveal::CircularReveal(QQuickItem *parent) : QQuickPaintedItem(parent) {
|
||||
});
|
||||
}
|
||||
|
||||
void CircularReveal::paint(QPainter *painter) {
|
||||
void CircularReveal::paint(QPainter* painter)
|
||||
{
|
||||
painter->save();
|
||||
painter->drawImage(QRect(0, 0, static_cast<int>(width()), static_cast<int>(height())), _source);
|
||||
QPainterPath path;
|
||||
@ -31,7 +31,7 @@ void CircularReveal::paint(QPainter *painter) {
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
[[maybe_unused]] void CircularReveal::start(int w, int h, const QPoint ¢er, int radius) {
|
||||
void CircularReveal::start(int w,int h,const QPoint& center,int radius){
|
||||
_anim->setStartValue(0);
|
||||
_anim->setEndValue(radius);
|
||||
_center = center;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef CIRCULARREVEAL_H
|
||||
#define CIRCULARREVEAL_H
|
||||
|
||||
#include <QQuickItem>
|
||||
#include <QQuickPaintedItem>
|
||||
@ -6,26 +7,23 @@
|
||||
#include <QPropertyAnimation>
|
||||
#include "src/stdafx.h"
|
||||
|
||||
class CircularReveal : public QQuickPaintedItem {
|
||||
class CircularReveal : public QQuickPaintedItem
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO_P(QQuickItem*, target)
|
||||
Q_PROPERTY_AUTO(QQuickItem*,target)
|
||||
Q_PROPERTY_AUTO(int,radius)
|
||||
public:
|
||||
explicit CircularReveal(QQuickItem *parent = nullptr);
|
||||
|
||||
CircularReveal(QQuickItem* parent = nullptr);
|
||||
void paint(QPainter* painter) override;
|
||||
|
||||
Q_INVOKABLE [[maybe_unused]] void start(int w, int h, const QPoint ¢er, int radius);
|
||||
|
||||
Q_INVOKABLE void start(int w,int h,const QPoint& center,int radius);
|
||||
Q_SIGNAL void imageChanged();
|
||||
|
||||
Q_SIGNAL void animationFinished();
|
||||
|
||||
Q_SLOT void handleGrabResult();
|
||||
|
||||
private:
|
||||
QPropertyAnimation* _anim = nullptr;
|
||||
QImage _source;
|
||||
QPoint _center;
|
||||
QSharedPointer<QQuickItemGrabResult> _grabResult;
|
||||
};
|
||||
|
||||
#endif // CIRCULARREVEAL_H
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include "FileWatcher.h"
|
||||
|
||||
FileWatcher::FileWatcher(QObject *parent) : QObject{parent} {
|
||||
FileWatcher::FileWatcher(QObject *parent)
|
||||
: QObject{parent}
|
||||
{
|
||||
connect(&_watcher, &QFileSystemWatcher::fileChanged, this, [=](const QString &path){
|
||||
Q_EMIT fileChanged();
|
||||
clean();
|
||||
@ -16,8 +18,7 @@ FileWatcher::FileWatcher(QObject *parent) : QObject{parent} {
|
||||
}
|
||||
|
||||
void FileWatcher::clean(){
|
||||
for (int i = 0; i <= _watcher.files().size() - 1; ++i) {
|
||||
auto item = _watcher.files().at(i);
|
||||
foreach (const QString &item, _watcher.files()) {
|
||||
_watcher.removePath(item);
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,22 @@
|
||||
#pragma once
|
||||
#ifndef FILEWATCHER_H
|
||||
#define FILEWATCHER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QFileSystemWatcher>
|
||||
#include <QtQml/qqml.h>
|
||||
#include "src/stdafx.h"
|
||||
|
||||
class FileWatcher : public QObject {
|
||||
class FileWatcher : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(QString,path);
|
||||
public:
|
||||
explicit FileWatcher(QObject *parent = nullptr);
|
||||
|
||||
Q_SIGNAL void fileChanged();
|
||||
|
||||
private:
|
||||
void clean();
|
||||
|
||||
private:
|
||||
QFileSystemWatcher _watcher;
|
||||
};
|
||||
|
||||
#endif // FILEWATCHER_H
|
||||
|
@ -3,9 +3,9 @@
|
||||
#include <QTimer>
|
||||
#include <QQuickWindow>
|
||||
|
||||
FpsItem::FpsItem() {
|
||||
_fps = 0;
|
||||
auto *timer = new QTimer(this);
|
||||
FpsItem::FpsItem()
|
||||
{
|
||||
QTimer *timer = new QTimer(this);
|
||||
connect(timer, &QTimer::timeout, this, [this]{
|
||||
fps(_frameCount);
|
||||
_frameCount = 0;
|
||||
|
@ -1,9 +1,11 @@
|
||||
#pragma once
|
||||
#ifndef FPSITEM_H
|
||||
#define FPSITEM_H
|
||||
|
||||
#include <QQuickItem>
|
||||
#include "src/stdafx.h"
|
||||
|
||||
class FpsItem : public QQuickItem {
|
||||
class FpsItem : public QQuickItem
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(int,fps)
|
||||
public:
|
||||
@ -13,3 +15,5 @@ private:
|
||||
int _frameCount = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif // FPSITEM_H
|
||||
|
@ -1,93 +0,0 @@
|
||||
#include "OpenGLItem.h"
|
||||
|
||||
#include <QOpenGLFramebufferObjectFormat>
|
||||
#include <QOpenGLShaderProgram>
|
||||
|
||||
class FBORenderer : public QQuickFramebufferObject::Renderer, protected QOpenGLFunctions {
|
||||
public:
|
||||
explicit FBORenderer(const OpenGLItem *item);
|
||||
|
||||
void render() override;
|
||||
|
||||
QOpenGLFramebufferObject *createFramebufferObject(const QSize &size) override;
|
||||
|
||||
QOpenGLShaderProgram program;
|
||||
const OpenGLItem *item = nullptr;
|
||||
};
|
||||
|
||||
FBORenderer::FBORenderer(const OpenGLItem *item) {
|
||||
this->item = item;
|
||||
initializeOpenGLFunctions();
|
||||
program.addCacheableShaderFromSourceCode(QOpenGLShader::Vertex,
|
||||
"attribute highp vec4 vertices;"
|
||||
"varying highp vec2 coords;"
|
||||
"void main() {"
|
||||
" gl_Position = vertices;"
|
||||
" coords = vertices.xy;"
|
||||
"}");
|
||||
program.addCacheableShaderFromSourceCode(QOpenGLShader::Fragment,
|
||||
"uniform lowp float t;"
|
||||
"varying highp vec2 coords;"
|
||||
"void main() {"
|
||||
" lowp float i = 1. - (pow(abs(coords.x), 4.) + pow(abs(coords.y), 4.));"
|
||||
" i = smoothstep(t - 0.8, t + 0.8, i);"
|
||||
" i = floor(i * 20.) / 20.;"
|
||||
" gl_FragColor = vec4(coords * .5 + .5, i, i);"
|
||||
"}");
|
||||
|
||||
program.bindAttributeLocation("vertices", 0);
|
||||
program.link();
|
||||
}
|
||||
|
||||
QOpenGLFramebufferObject *FBORenderer::createFramebufferObject(const QSize &size) {
|
||||
QOpenGLFramebufferObjectFormat format;
|
||||
format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
|
||||
format.setSamples(4);
|
||||
return new QOpenGLFramebufferObject(size, format);
|
||||
}
|
||||
|
||||
void FBORenderer::render() {
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
program.bind();
|
||||
program.enableAttributeArray(0);
|
||||
float values[] = {
|
||||
-1, -1,
|
||||
1, -1,
|
||||
-1, 1,
|
||||
1, 1
|
||||
};
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
program.setAttributeArray(0, GL_FLOAT, values, 2);
|
||||
program.setUniformValue("t", (float) item->t());
|
||||
glViewport(0, 0, qRound(item->width()), qRound(item->height()));
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
program.disableAttributeArray(0);
|
||||
program.release();
|
||||
}
|
||||
|
||||
|
||||
OpenGLItem::OpenGLItem(QQuickItem *parent) : QQuickFramebufferObject(parent) {
|
||||
setMirrorVertically(true);
|
||||
startTimer(1);
|
||||
}
|
||||
|
||||
void OpenGLItem::timerEvent(QTimerEvent *) {
|
||||
update();
|
||||
}
|
||||
|
||||
void OpenGLItem::setT(qreal t) {
|
||||
if (t == m_t)
|
||||
return;
|
||||
m_t = t;
|
||||
emit tChanged();
|
||||
}
|
||||
|
||||
|
||||
QQuickFramebufferObject::Renderer *OpenGLItem::createRenderer() const {
|
||||
return new FBORenderer(this);
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <QtQuick/QQuickItem>
|
||||
#include <QOpenGLFunctions>
|
||||
#include <QQuickFramebufferObject>
|
||||
|
||||
class FBORenderer;
|
||||
|
||||
class OpenGLItem : public QQuickFramebufferObject, protected QOpenGLFunctions {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(qreal t READ t WRITE setT NOTIFY tChanged)
|
||||
public:
|
||||
explicit OpenGLItem(QQuickItem *parent = nullptr);
|
||||
|
||||
[[nodiscard]] QQuickFramebufferObject::Renderer *createRenderer() const override;
|
||||
|
||||
void timerEvent(QTimerEvent *) override;
|
||||
|
||||
[[nodiscard]] qreal t() const { return m_t; }
|
||||
|
||||
void setT(qreal t);
|
||||
|
||||
signals:
|
||||
|
||||
void tChanged();
|
||||
|
||||
private:
|
||||
qreal m_t{};
|
||||
};
|
@ -3,31 +3,39 @@
|
||||
#include <QDir>
|
||||
#include <QGuiApplication>
|
||||
|
||||
[[maybe_unused]] InitializrHelper::InitializrHelper(QObject *parent) : QObject(parent) {
|
||||
InitializrHelper::InitializrHelper(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
InitializrHelper::~InitializrHelper() = default;
|
||||
|
||||
bool InitializrHelper::copyDir(const QDir& fromDir, const QDir& toDir, bool coverIfFileExists){
|
||||
const QDir &_formDir = fromDir;
|
||||
QDir _formDir = fromDir;
|
||||
QDir _toDir = toDir;
|
||||
if (!_toDir.exists()) {
|
||||
if(!_toDir.exists())
|
||||
{
|
||||
if(!_toDir.mkdir(toDir.absolutePath()))
|
||||
return false;
|
||||
}
|
||||
QFileInfoList fileInfoList = _formDir.entryInfoList();
|
||||
foreach(QFileInfo fileInfo, fileInfoList) {
|
||||
foreach(QFileInfo fileInfo, fileInfoList)
|
||||
{
|
||||
if(fileInfo.fileName() == "." || fileInfo.fileName() == "..")
|
||||
continue;
|
||||
if (fileInfo.isDir()) {
|
||||
if(fileInfo.isDir())
|
||||
{
|
||||
if(!copyDir(fileInfo.filePath(), _toDir.filePath(fileInfo.fileName()),true))
|
||||
return false;
|
||||
} else {
|
||||
if (coverIfFileExists && _toDir.exists(fileInfo.fileName())) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if(coverIfFileExists && _toDir.exists(fileInfo.fileName()))
|
||||
{
|
||||
_toDir.remove(fileInfo.fileName());
|
||||
}
|
||||
if (!QFile::copy(fileInfo.filePath(), _toDir.filePath(fileInfo.fileName()))) {
|
||||
if(!QFile::copy(fileInfo.filePath(), _toDir.filePath(fileInfo.fileName())))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -64,7 +72,7 @@ void InitializrHelper::copyFile(const QString &source, const QString &dest) {
|
||||
QFile::setPermissions(dest, QFile::WriteOwner | QFile::WriteUser | QFile::WriteGroup | QFile::WriteOther);
|
||||
}
|
||||
|
||||
[[maybe_unused]] void InitializrHelper::generate(const QString &name, const QString &path) {
|
||||
void InitializrHelper::generate(const QString& name,const QString& path){
|
||||
if(name.isEmpty()){
|
||||
error(tr("The name cannot be empty"));
|
||||
return;
|
||||
|
@ -1,30 +1,26 @@
|
||||
#pragma once
|
||||
#ifndef INITIALIZRHELPER_H
|
||||
#define INITIALIZRHELPER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QtQml/qqml.h>
|
||||
#include <QDir>
|
||||
#include "src/singleton.h"
|
||||
|
||||
class InitializrHelper : public QObject {
|
||||
class InitializrHelper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
[[maybe_unused]] explicit InitializrHelper(QObject *parent = nullptr);
|
||||
|
||||
explicit InitializrHelper(QObject* parent = nullptr);
|
||||
bool copyDir(const QDir& fromDir, const QDir& toDir, bool coverIfFileExists = true);
|
||||
|
||||
static void copyFile(const QString &source, const QString &dest);
|
||||
|
||||
void copyFile(const QString& source,const QString& dest);
|
||||
template <typename...Args>
|
||||
void templateToFile(const QString& source,const QString& dest,Args &&...args);
|
||||
|
||||
public:
|
||||
SINGLETON(InitializrHelper)
|
||||
|
||||
~InitializrHelper() override;
|
||||
|
||||
Q_INVOKABLE [[maybe_unused]] void generate(const QString &name, const QString &path);
|
||||
|
||||
Q_INVOKABLE void generate(const QString& name,const QString& path);
|
||||
Q_SIGNAL void error(const QString& message);
|
||||
|
||||
Q_SIGNAL void success(const QString& path);
|
||||
};
|
||||
|
||||
#endif // INITIALIZRHELPER_H
|
||||
|
@ -11,11 +11,8 @@
|
||||
#include <QSettings>
|
||||
#include <QRegularExpression>
|
||||
#include "Version.h"
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#include <process.h>
|
||||
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
@ -45,7 +42,8 @@ std::map<QtMsgType, int> logLevelMap = {
|
||||
{QtDebugMsg,4}
|
||||
};
|
||||
|
||||
QString Log::prettyProductInfoWrapper() {
|
||||
QString Log::prettyProductInfoWrapper()
|
||||
{
|
||||
auto productName = QSysInfo::prettyProductName();
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
|
||||
#if defined(Q_OS_MACOS)
|
||||
@ -72,17 +70,20 @@ QString Log::prettyProductInfoWrapper() {
|
||||
#endif
|
||||
#endif
|
||||
#if defined(Q_OS_WIN)
|
||||
QSettings regKey{QString::fromUtf8(R"(HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion)"), QSettings::NativeFormat};
|
||||
QSettings regKey {QString::fromUtf8("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), QSettings::NativeFormat};
|
||||
if (regKey.contains(QString::fromUtf8("CurrentBuildNumber"))) {
|
||||
auto buildNumber = regKey.value(QString::fromUtf8("CurrentBuildNumber")).toInt();
|
||||
if (buildNumber > 0) {
|
||||
if (buildNumber < 9200) {
|
||||
productName = QString::fromUtf8("Windows 7 build %1").arg(buildNumber);
|
||||
} else if (buildNumber < 10240) {
|
||||
}
|
||||
else if (buildNumber < 10240) {
|
||||
productName = QString::fromUtf8("Windows 8 build %1").arg(buildNumber);
|
||||
} else if (buildNumber < 22000) {
|
||||
}
|
||||
else if (buildNumber < 22000) {
|
||||
productName = QString::fromUtf8("Windows 10 build %1").arg(buildNumber);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
productName = QString::fromUtf8("Windows 11 build %1").arg(buildNumber);
|
||||
}
|
||||
}
|
||||
@ -91,7 +92,8 @@ QString Log::prettyProductInfoWrapper() {
|
||||
return productName;
|
||||
}
|
||||
|
||||
static inline void messageHandler(const QtMsgType type, const QMessageLogContext &context, const QString &message) {
|
||||
static inline void messageHandler(const QtMsgType type, const QMessageLogContext &context, const QString &message)
|
||||
{
|
||||
if(message == "Could not get the INetworkConnection instance for the adapter GUID."){
|
||||
return;
|
||||
}
|
||||
@ -166,7 +168,8 @@ static inline void messageHandler(const QtMsgType type, const QMessageLogContext
|
||||
}
|
||||
}
|
||||
|
||||
void Log::setup(char *argv[], const QString &app, int level) {
|
||||
void Log::setup(char *argv[],const QString &app,int level)
|
||||
{
|
||||
Q_ASSERT(!app.isEmpty());
|
||||
if (app.isEmpty()) {
|
||||
return;
|
||||
|
@ -1,9 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef LOG_H
|
||||
#define LOG_H
|
||||
#include <QtCore/qstring.h>
|
||||
|
||||
namespace Log {
|
||||
namespace Log
|
||||
{
|
||||
QString prettyProductInfoWrapper();
|
||||
|
||||
void setup(char *argv[], const QString &app,int level = 4);
|
||||
}
|
||||
|
||||
#endif // LOG_H
|
||||
|
@ -17,14 +17,12 @@
|
||||
#include <QCryptographicHash>
|
||||
#include <QEventLoop>
|
||||
#include <QGuiApplication>
|
||||
#include <utility>
|
||||
|
||||
|
||||
NetworkCallable::NetworkCallable(QObject *parent):QObject{parent}{
|
||||
|
||||
}
|
||||
|
||||
QString NetworkParams::method2String() const {
|
||||
QString NetworkParams::method2String(){
|
||||
switch (_method) {
|
||||
case METHOD_GET:
|
||||
return "GET";
|
||||
@ -43,21 +41,21 @@ QString NetworkParams::method2String() const {
|
||||
}
|
||||
}
|
||||
|
||||
int NetworkParams::getTimeout() const {
|
||||
int NetworkParams::getTimeout(){
|
||||
if(_timeout != -1){
|
||||
return _timeout;
|
||||
}
|
||||
return Network::getInstance()->timeout();
|
||||
}
|
||||
|
||||
int NetworkParams::getRetry() const {
|
||||
int NetworkParams::getRetry(){
|
||||
if(_retry != -1){
|
||||
return _retry;
|
||||
}
|
||||
return Network::getInstance()->retry();
|
||||
}
|
||||
|
||||
bool NetworkParams::getOpenLog() const {
|
||||
bool NetworkParams::getOpenLog(){
|
||||
if(!_openLog.isNull()){
|
||||
return _openLog.toBool();
|
||||
}
|
||||
@ -65,49 +63,52 @@ bool NetworkParams::getOpenLog() const {
|
||||
}
|
||||
|
||||
FluDownloadParam::FluDownloadParam(QObject *parent)
|
||||
: QObject{parent} {
|
||||
: QObject{parent}
|
||||
{
|
||||
}
|
||||
|
||||
FluDownloadParam::FluDownloadParam(QString destPath,bool append,QObject *parent)
|
||||
: QObject{parent} {
|
||||
this->_destPath = std::move(destPath);
|
||||
: QObject{parent}
|
||||
{
|
||||
this->_destPath = destPath;
|
||||
this->_append = append;
|
||||
}
|
||||
|
||||
NetworkParams::NetworkParams(QObject *parent) : QObject{parent} {
|
||||
_method = NetworkParams::Method::METHOD_GET;
|
||||
_type = NetworkParams::Type::TYPE_BODY;
|
||||
NetworkParams::NetworkParams(QObject *parent)
|
||||
: QObject{parent}
|
||||
{
|
||||
}
|
||||
|
||||
NetworkParams::NetworkParams(QString url,Type type,Method method,QObject *parent)
|
||||
: QObject{parent} {
|
||||
: QObject{parent}
|
||||
{
|
||||
this->_method = method;
|
||||
this->_url = std::move(url);
|
||||
this->_url = url;
|
||||
this->_type = type;
|
||||
}
|
||||
|
||||
NetworkParams *NetworkParams::add(const QString &key, const QVariant &val) {
|
||||
NetworkParams* NetworkParams::add(QString key,QVariant val){
|
||||
_paramMap.insert(key,val);
|
||||
return this;
|
||||
}
|
||||
|
||||
NetworkParams *NetworkParams::addFile(const QString &key, const QVariant &val) {
|
||||
NetworkParams* NetworkParams::addFile(QString key,QVariant val){
|
||||
_fileMap.insert(key,val);
|
||||
return this;
|
||||
}
|
||||
|
||||
NetworkParams *NetworkParams::addHeader(const QString &key, const QVariant &val) {
|
||||
NetworkParams* NetworkParams::addHeader(QString key,QVariant val){
|
||||
_headerMap.insert(key,val);
|
||||
return this;
|
||||
}
|
||||
|
||||
NetworkParams *NetworkParams::addQuery(const QString &key, const QVariant &val) {
|
||||
NetworkParams* NetworkParams::addQuery(QString key,QVariant val){
|
||||
_queryMap.insert(key,val);
|
||||
return this;
|
||||
}
|
||||
|
||||
NetworkParams* NetworkParams::setBody(QString val){
|
||||
_body = std::move(val);
|
||||
_body = val;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -127,7 +128,7 @@ NetworkParams *NetworkParams::setCacheMode(int val) {
|
||||
}
|
||||
|
||||
NetworkParams* NetworkParams::toDownload(QString destPath,bool append){
|
||||
_downloadParam = new FluDownloadParam(std::move(destPath), append, this);
|
||||
_downloadParam = new FluDownloadParam(destPath,append,this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -137,11 +138,11 @@ NetworkParams *NetworkParams::bind(QObject *target) {
|
||||
}
|
||||
|
||||
NetworkParams* NetworkParams::openLog(QVariant val){
|
||||
_openLog = std::move(val);
|
||||
_openLog = val;
|
||||
return this;
|
||||
}
|
||||
|
||||
QString NetworkParams::buildCacheKey() const {
|
||||
QString NetworkParams::buildCacheKey(){
|
||||
QJsonObject obj;
|
||||
obj.insert("url",_url);
|
||||
obj.insert("method",method2String());
|
||||
@ -195,19 +196,19 @@ void Network::handle(NetworkParams *params, NetworkCallable *c) {
|
||||
manager.setTransferTimeout(params->getTimeout());
|
||||
QEventLoop loop;
|
||||
connect(&manager,&QNetworkAccessManager::finished,&manager,[&loop](QNetworkReply *reply){loop.quit();});
|
||||
for (int i = 0; i <= params->getRetry() - 1; ++i) {
|
||||
for (int i = 0; i < params->getRetry(); ++i) {
|
||||
QUrl url(params->_url);
|
||||
addQueryParam(&url,params->_queryMap);
|
||||
QNetworkRequest request(url);
|
||||
addHeaders(&request,params->_headerMap);
|
||||
QNetworkReply* reply;
|
||||
sendRequest(&manager,request,params,reply,i==0,callable);
|
||||
if (!QPointer<QCoreApplication>(QGuiApplication::instance())) {
|
||||
if(!QPointer<QGuiApplication>(qApp)){
|
||||
reply->deleteLater();
|
||||
reply = nullptr;
|
||||
return;
|
||||
}
|
||||
auto abortCallable = [reply, &i, params] {
|
||||
auto abortCallable = [&loop,reply,&i,params]{
|
||||
if(reply){
|
||||
i = params->getRetry();
|
||||
reply->abort();
|
||||
@ -218,7 +219,7 @@ void Network::handle(NetworkParams *params, NetworkCallable *c) {
|
||||
if(params->_target){
|
||||
conn_destroyed = connect(params->_target,&QObject::destroyed,&manager,abortCallable);
|
||||
}
|
||||
conn_quit = connect(QGuiApplication::instance(), &QGuiApplication::aboutToQuit, &manager, abortCallable);
|
||||
conn_quit = connect(qApp,&QGuiApplication::aboutToQuit,&manager, abortCallable);
|
||||
loop.exec();
|
||||
if(conn_destroyed){
|
||||
disconnect(conn_destroyed);
|
||||
@ -281,14 +282,14 @@ void Network::handleDownload(NetworkParams *params, NetworkCallable *c) {
|
||||
addHeaders(&request,params->_headerMap);
|
||||
QString cachePath = getCacheFilePath(cacheKey);
|
||||
QString destPath = params->_downloadParam->_destPath;
|
||||
auto *destFile = new QFile(destPath);
|
||||
auto *cacheFile = new QFile(cachePath);
|
||||
bool isOpen;
|
||||
qint64 seek;
|
||||
QFile* destFile = new QFile(destPath);
|
||||
QFile* cacheFile = new QFile(cachePath);
|
||||
bool isOpen = false;
|
||||
qint64 seek = 0;
|
||||
if(cacheFile->exists() && destFile->exists() && params->_downloadParam->_append){
|
||||
QJsonObject cacheInfo = QJsonDocument::fromJson(readCache(cacheKey).toUtf8()).object();
|
||||
qint64 fileSize = qRound(cacheInfo.value("fileSize").toDouble());
|
||||
qint64 contentLength = qRound(cacheInfo.value("contentLength").toDouble());
|
||||
qint64 fileSize = cacheInfo.value("fileSize").toDouble();
|
||||
qint64 contentLength = cacheInfo.value("contentLength").toDouble();
|
||||
if(fileSize == contentLength && destFile->size() == contentLength){
|
||||
if(!callable.isNull()){
|
||||
callable->downloadProgress(fileSize,contentLength);
|
||||
@ -315,7 +316,8 @@ void Network::handleDownload(NetworkParams *params, NetworkCallable *c) {
|
||||
return;
|
||||
}
|
||||
if(params->_downloadParam->_append){
|
||||
if (!cacheFile->open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
||||
if (!cacheFile->open(QIODevice::WriteOnly|QIODevice::Truncate))
|
||||
{
|
||||
if(!callable.isNull()){
|
||||
callable->error(-1,"cache file device not open","");
|
||||
callable->finish();
|
||||
@ -327,21 +329,22 @@ void Network::handleDownload(NetworkParams *params, NetworkCallable *c) {
|
||||
QNetworkReply *reply = manager.get(request);
|
||||
destFile->setParent(reply);
|
||||
cacheFile->setParent(reply);
|
||||
auto abortCallable = [reply] {
|
||||
auto abortCallable = [&loop,reply,params]{
|
||||
if(reply){
|
||||
reply->abort();
|
||||
}
|
||||
};
|
||||
connect(&manager,&QNetworkAccessManager::finished,&manager,[&loop](QNetworkReply *reply){loop.quit();});
|
||||
connect(QGuiApplication::instance(), &QGuiApplication::aboutToQuit, &manager, [&loop, reply]() { reply->abort(), loop.quit(); });
|
||||
connect(qApp,&QGuiApplication::aboutToQuit,&manager, [&loop,reply](){reply->abort(),loop.quit();});
|
||||
QMetaObject::Connection conn_destroyed = {};
|
||||
QMetaObject::Connection conn_quit = {};
|
||||
if(params->_target){
|
||||
conn_destroyed = connect(params->_target,&QObject::destroyed,&manager,abortCallable);
|
||||
}
|
||||
conn_quit = connect(QGuiApplication::instance(), &QGuiApplication::aboutToQuit, &manager, abortCallable);
|
||||
conn_quit = connect(qApp,&QGuiApplication::aboutToQuit,&manager, abortCallable);
|
||||
connect(reply,&QNetworkReply::readyRead,reply,[reply,seek,destFile,cacheFile,callable]{
|
||||
if (!reply || !destFile || reply->error() != QNetworkReply::NoError) {
|
||||
if (!reply || !destFile || reply->error() != QNetworkReply::NoError)
|
||||
{
|
||||
return;
|
||||
}
|
||||
QMap<QString, QVariant> downInfo;
|
||||
@ -430,29 +433,31 @@ QString Network::map2String(const QMap<QString, QVariant> &map) {
|
||||
return parameters.join(" ");
|
||||
}
|
||||
|
||||
void Network::sendRequest(QNetworkAccessManager *manager, QNetworkRequest request, NetworkParams *params, QNetworkReply *&reply, bool isFirst, const QPointer<NetworkCallable> &callable) {
|
||||
void Network::sendRequest(QNetworkAccessManager* manager,QNetworkRequest request,NetworkParams* params,QNetworkReply*& reply,bool isFirst,QPointer<NetworkCallable> callable){
|
||||
QByteArray verb = params->method2String().toUtf8();
|
||||
switch (params->_type) {
|
||||
case NetworkParams::TYPE_FORM:{
|
||||
bool isFormData = !params->_fileMap.isEmpty();
|
||||
if(isFormData){
|
||||
auto *multiPart = new QHttpMultiPart();
|
||||
QHttpMultiPart *multiPart = new QHttpMultiPart();
|
||||
multiPart->setContentType(QHttpMultiPart::FormDataType);
|
||||
for (const auto &each: params->_paramMap.toStdMap()) {
|
||||
for (const auto& each : params->_paramMap.toStdMap())
|
||||
{
|
||||
QHttpPart part;
|
||||
part.setHeader(QNetworkRequest::ContentDispositionHeader, QString("form-data; name=\"%1\"").arg(each.first));
|
||||
part.setBody(each.second.toByteArray());
|
||||
multiPart->append(part);
|
||||
}
|
||||
for (const auto &each: params->_fileMap.toStdMap()) {
|
||||
for (const auto& each : params->_fileMap.toStdMap())
|
||||
{
|
||||
QString filePath = each.second.toString();
|
||||
QString name = each.first;
|
||||
auto *file = new QFile(filePath);
|
||||
QFile *file = new QFile(filePath);
|
||||
QString fileName = QFileInfo(filePath).fileName();
|
||||
file->open(QIODevice::ReadOnly);
|
||||
file->setParent(multiPart);
|
||||
QHttpPart part;
|
||||
part.setHeader(QNetworkRequest::ContentDispositionHeader, QString(R"(form-data; name="%1"; filename="%2")").arg(name, fileName));
|
||||
part.setHeader(QNetworkRequest::ContentDispositionHeader, QString("form-data; name=\"%1\"; filename=\"%2\"").arg(name,fileName));
|
||||
part.setBodyDevice(file);
|
||||
multiPart->append(part);
|
||||
}
|
||||
@ -466,7 +471,8 @@ void Network::sendRequest(QNetworkAccessManager *manager, QNetworkRequest reques
|
||||
}else{
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, QString("application/x-www-form-urlencoded"));
|
||||
QString value;
|
||||
for (const auto &each: params->_paramMap.toStdMap()) {
|
||||
for (const auto& each : params->_paramMap.toStdMap())
|
||||
{
|
||||
value += QString("%1=%2").arg(each.first,each.second.toString());
|
||||
value += "&";
|
||||
}
|
||||
@ -481,7 +487,8 @@ void Network::sendRequest(QNetworkAccessManager *manager, QNetworkRequest reques
|
||||
case NetworkParams::TYPE_JSON:{
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, QString("application/json;charset=utf-8"));
|
||||
QJsonObject json;
|
||||
for (const auto &each: params->_paramMap.toStdMap()) {
|
||||
for (const auto& each : params->_paramMap.toStdMap())
|
||||
{
|
||||
json.insert(each.first,each.second.toJsonValue());
|
||||
}
|
||||
QByteArray data = QJsonDocument(json).toJson(QJsonDocument::Compact);
|
||||
@ -491,7 +498,8 @@ void Network::sendRequest(QNetworkAccessManager *manager, QNetworkRequest reques
|
||||
case NetworkParams::TYPE_JSONARRAY:{
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, QString("application/json;charset=utf-8"));
|
||||
QJsonArray jsonArray;
|
||||
for (const auto &each: params->_paramMap.toStdMap()) {
|
||||
for (const auto& each : params->_paramMap.toStdMap())
|
||||
{
|
||||
QJsonObject json;
|
||||
json.insert(each.first,each.second.toJsonValue());
|
||||
jsonArray.append(json);
|
||||
@ -515,7 +523,7 @@ void Network::sendRequest(QNetworkAccessManager *manager, QNetworkRequest reques
|
||||
}
|
||||
}
|
||||
|
||||
void Network::printRequestStartLog(const QNetworkRequest &request, NetworkParams *params) {
|
||||
void Network::printRequestStartLog(QNetworkRequest request,NetworkParams* params){
|
||||
if(!params->getOpenLog()){
|
||||
return;
|
||||
}
|
||||
@ -543,7 +551,7 @@ void Network::printRequestStartLog(const QNetworkRequest &request, NetworkParams
|
||||
}
|
||||
}
|
||||
|
||||
void Network::printRequestEndLog(const QNetworkRequest &request, NetworkParams *params, QNetworkReply *&reply, const QString &response) {
|
||||
void Network::printRequestEndLog(QNetworkRequest request,NetworkParams* params,QNetworkReply*& reply,const QString& response){
|
||||
if(!params->getOpenLog()){
|
||||
return;
|
||||
}
|
||||
@ -552,10 +560,11 @@ void Network::printRequestEndLog(const QNetworkRequest &request, NetworkParams *
|
||||
qDebug()<<"<Result>"<<qUtf8Printable(response);
|
||||
}
|
||||
|
||||
void Network::saveResponse(const QString &key, const QString &response) {
|
||||
void Network::saveResponse(QString key,QString response){
|
||||
QSharedPointer<QFile> file(new QFile(getCacheFilePath(key)));
|
||||
QIODevice::OpenMode mode = QIODevice::WriteOnly|QIODevice::Truncate;
|
||||
if (!file->open(mode)) {
|
||||
if (!file->open(mode))
|
||||
{
|
||||
return;
|
||||
}
|
||||
file->write(response.toUtf8().toBase64());
|
||||
@ -564,7 +573,8 @@ void Network::saveResponse(const QString &key, const QString &response) {
|
||||
void Network::addHeaders(QNetworkRequest* request,const QMap<QString, QVariant>& headers){
|
||||
request->setHeader(QNetworkRequest::UserAgentHeader,QString::fromStdString("Mozilla/5.0 %1/%2").arg(QGuiApplication::applicationName(),QGuiApplication::applicationVersion()));
|
||||
QMapIterator<QString, QVariant> iter(headers);
|
||||
while (iter.hasNext()) {
|
||||
while (iter.hasNext())
|
||||
{
|
||||
iter.next();
|
||||
request->setRawHeader(iter.key().toUtf8(), iter.value().toString().toUtf8());
|
||||
}
|
||||
@ -573,18 +583,20 @@ void Network::addHeaders(QNetworkRequest *request, const QMap<QString, QVariant>
|
||||
void Network::addQueryParam(QUrl* url,const QMap<QString, QVariant>& params){
|
||||
QMapIterator<QString, QVariant> iter(params);
|
||||
QUrlQuery urlQuery(*url);
|
||||
while (iter.hasNext()) {
|
||||
while (iter.hasNext())
|
||||
{
|
||||
iter.next();
|
||||
urlQuery.addQueryItem(iter.key(), iter.value().toString());
|
||||
}
|
||||
url->setQuery(urlQuery);
|
||||
}
|
||||
|
||||
Network::Network(QObject *parent) : QObject{parent} {
|
||||
_timeout = 5000;
|
||||
_retry = 3;
|
||||
_openLog = false;
|
||||
_cacheDir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation).append(QDir::separator()).append("network");
|
||||
Network::Network(QObject *parent): QObject{parent}
|
||||
{
|
||||
timeout(5000);
|
||||
retry(3);
|
||||
openLog(false);
|
||||
cacheDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation).append(QDir::separator()).append("network"));
|
||||
}
|
||||
|
||||
NetworkParams* Network::get(const QString& url){
|
||||
@ -660,5 +672,5 @@ NetworkParams *Network::deleteJsonArray(const QString &url) {
|
||||
}
|
||||
|
||||
void Network::setInterceptor(QJSValue interceptor){
|
||||
this->_interceptor = std::move(interceptor);
|
||||
this->_interceptor = interceptor;
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef NETWORK_H
|
||||
#define NETWORK_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QtQml/qqml.h>
|
||||
@ -18,9 +19,7 @@ namespace NetworkType {
|
||||
IfNoneCacheRequest = 0x0002,
|
||||
FirstCacheThenRequest = 0x0004,
|
||||
};
|
||||
|
||||
Q_ENUM_NS(CacheMode)
|
||||
|
||||
QML_NAMED_ELEMENT(NetworkType)
|
||||
}
|
||||
|
||||
@ -32,19 +31,12 @@ Q_OBJECT
|
||||
QML_NAMED_ELEMENT(NetworkCallable)
|
||||
public:
|
||||
explicit NetworkCallable(QObject *parent = nullptr);
|
||||
|
||||
Q_SIGNAL void start();
|
||||
|
||||
Q_SIGNAL void finish();
|
||||
|
||||
Q_SIGNAL void error(int status,QString errorString,QString result);
|
||||
|
||||
Q_SIGNAL void success(QString result);
|
||||
|
||||
Q_SIGNAL void cache(QString result);
|
||||
|
||||
Q_SIGNAL void uploadProgress(qint64 sent, qint64 total);
|
||||
|
||||
Q_SIGNAL void downloadProgress(qint64 recv, qint64 total);
|
||||
};
|
||||
|
||||
@ -55,18 +47,17 @@ class FluDownloadParam : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FluDownloadParam(QObject *parent = nullptr);
|
||||
|
||||
FluDownloadParam(QString destPath,bool append,QObject *parent = nullptr);
|
||||
|
||||
public:
|
||||
QString _destPath;
|
||||
bool _append{};
|
||||
bool _append;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The NetworkParams class
|
||||
*/
|
||||
class NetworkParams : public QObject {
|
||||
class NetworkParams : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
QML_NAMED_ELEMENT(NetworkParams)
|
||||
public:
|
||||
@ -85,45 +76,25 @@ public:
|
||||
TYPE_JSONARRAY,
|
||||
TYPE_BODY
|
||||
};
|
||||
|
||||
explicit NetworkParams(QObject *parent = nullptr);
|
||||
|
||||
NetworkParams(QString url,Type type,Method method,QObject *parent = nullptr);
|
||||
|
||||
Q_INVOKABLE NetworkParams *addQuery(const QString &key, const QVariant &val);
|
||||
|
||||
Q_INVOKABLE NetworkParams *addHeader(const QString &key, const QVariant &val);
|
||||
|
||||
Q_INVOKABLE NetworkParams *add(const QString &key, const QVariant &val);
|
||||
|
||||
Q_INVOKABLE NetworkParams *addFile(const QString &key, const QVariant &val);
|
||||
|
||||
Q_INVOKABLE NetworkParams* addQuery(QString key,QVariant val);
|
||||
Q_INVOKABLE NetworkParams* addHeader(QString key,QVariant val);
|
||||
Q_INVOKABLE NetworkParams* add(QString key,QVariant val);
|
||||
Q_INVOKABLE NetworkParams* addFile(QString key,QVariant val);
|
||||
Q_INVOKABLE NetworkParams* setBody(QString val);
|
||||
|
||||
Q_INVOKABLE NetworkParams* setTimeout(int val);
|
||||
|
||||
Q_INVOKABLE NetworkParams* setRetry(int val);
|
||||
|
||||
Q_INVOKABLE NetworkParams* setCacheMode(int val);
|
||||
|
||||
Q_INVOKABLE NetworkParams* toDownload(QString destPath,bool append = false);
|
||||
|
||||
Q_INVOKABLE NetworkParams* bind(QObject* target);
|
||||
|
||||
Q_INVOKABLE NetworkParams* openLog(QVariant val);
|
||||
|
||||
Q_INVOKABLE void go(NetworkCallable* result);
|
||||
|
||||
QString buildCacheKey() const;
|
||||
|
||||
QString method2String() const;
|
||||
|
||||
int getTimeout() const;
|
||||
|
||||
int getRetry() const;
|
||||
|
||||
bool getOpenLog() const;
|
||||
|
||||
QString buildCacheKey();
|
||||
QString method2String();
|
||||
int getTimeout();
|
||||
int getRetry();
|
||||
bool getOpenLog();
|
||||
public:
|
||||
FluDownloadParam* _downloadParam = nullptr;
|
||||
QObject* _target = nullptr;
|
||||
@ -144,7 +115,8 @@ public:
|
||||
/**
|
||||
* @brief The Network class
|
||||
*/
|
||||
class Network : public QObject {
|
||||
class Network : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(int,timeout)
|
||||
Q_PROPERTY_AUTO(int,retry)
|
||||
@ -152,80 +124,46 @@ Q_PROPERTY_AUTO(QString, cacheDir)
|
||||
Q_PROPERTY_AUTO(bool,openLog)
|
||||
QML_NAMED_ELEMENT(Network)
|
||||
QML_SINGLETON
|
||||
|
||||
private:
|
||||
explicit Network(QObject *parent = nullptr);
|
||||
|
||||
public:
|
||||
SINGLETON(Network)
|
||||
|
||||
static Network *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
|
||||
|
||||
Q_INVOKABLE NetworkParams* get(const QString& url);
|
||||
|
||||
Q_INVOKABLE NetworkParams* head(const QString& url);
|
||||
|
||||
Q_INVOKABLE NetworkParams* postBody(const QString& url);
|
||||
|
||||
Q_INVOKABLE NetworkParams* putBody(const QString& url);
|
||||
|
||||
Q_INVOKABLE NetworkParams* patchBody(const QString& url);
|
||||
|
||||
Q_INVOKABLE NetworkParams* deleteBody(const QString& url);
|
||||
|
||||
Q_INVOKABLE NetworkParams* postForm(const QString& url);
|
||||
|
||||
Q_INVOKABLE NetworkParams* putForm(const QString& url);
|
||||
|
||||
Q_INVOKABLE NetworkParams* patchForm(const QString& url);
|
||||
|
||||
Q_INVOKABLE NetworkParams* deleteForm(const QString& url);
|
||||
|
||||
Q_INVOKABLE NetworkParams* postJson(const QString& url);
|
||||
|
||||
Q_INVOKABLE NetworkParams* putJson(const QString& url);
|
||||
|
||||
Q_INVOKABLE NetworkParams* patchJson(const QString& url);
|
||||
|
||||
Q_INVOKABLE NetworkParams* deleteJson(const QString& url);
|
||||
|
||||
Q_INVOKABLE NetworkParams* postJsonArray(const QString& url);
|
||||
|
||||
Q_INVOKABLE NetworkParams* putJsonArray(const QString& url);
|
||||
|
||||
Q_INVOKABLE NetworkParams* patchJsonArray(const QString& url);
|
||||
|
||||
Q_INVOKABLE NetworkParams* deleteJsonArray(const QString& url);
|
||||
|
||||
Q_INVOKABLE void setInterceptor(QJSValue interceptor);
|
||||
|
||||
void handle(NetworkParams* params,NetworkCallable* result);
|
||||
|
||||
void handleDownload(NetworkParams* params,NetworkCallable* result);
|
||||
|
||||
private:
|
||||
static void sendRequest(QNetworkAccessManager *manager, QNetworkRequest request, NetworkParams *params, QNetworkReply *&reply, bool isFirst, const QPointer<NetworkCallable> &callable);
|
||||
|
||||
static void addQueryParam(QUrl *url, const QMap<QString, QVariant> ¶ms);
|
||||
|
||||
static void addHeaders(QNetworkRequest *request, const QMap<QString, QVariant> &headers);
|
||||
|
||||
void saveResponse(const QString &key, const QString &response);
|
||||
|
||||
void sendRequest(QNetworkAccessManager* manager,QNetworkRequest request,NetworkParams* params,QNetworkReply*& reply,bool isFirst,QPointer<NetworkCallable> callable);
|
||||
void addQueryParam(QUrl* url,const QMap<QString, QVariant>& params);
|
||||
void addHeaders(QNetworkRequest* request,const QMap<QString, QVariant>& headers);
|
||||
void saveResponse(QString key,QString response);
|
||||
QString readCache(const QString& key);
|
||||
|
||||
bool cacheExists(const QString& key);
|
||||
|
||||
QString getCacheFilePath(const QString& key);
|
||||
|
||||
static QString headerList2String(const QList<QNetworkReply::RawHeaderPair> &data);
|
||||
|
||||
static void printRequestStartLog(const QNetworkRequest &request, NetworkParams *params);
|
||||
|
||||
static void printRequestEndLog(const QNetworkRequest &request, NetworkParams *params, QNetworkReply *&reply, const QString &response);
|
||||
|
||||
static QString map2String(const QMap<QString, QVariant> &map);
|
||||
|
||||
QString map2String(const QMap<QString, QVariant>& map);
|
||||
QString headerList2String(const QList<QNetworkReply::RawHeaderPair>& data);
|
||||
void printRequestStartLog(QNetworkRequest request,NetworkParams* params);
|
||||
void printRequestEndLog(QNetworkRequest request,NetworkParams* params,QNetworkReply*& reply,const QString& response);
|
||||
public:
|
||||
QJSValue _interceptor;
|
||||
};
|
||||
|
||||
#endif // Network_H
|
||||
|
@ -3,13 +3,15 @@
|
||||
#include <QDataStream>
|
||||
#include <QStandardPaths>
|
||||
|
||||
SettingsHelper::SettingsHelper(QObject *parent) : QObject(parent) {
|
||||
SettingsHelper::SettingsHelper(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SettingsHelper::~SettingsHelper() = default;
|
||||
|
||||
void SettingsHelper::save(const QString &key, QVariant val) {
|
||||
void SettingsHelper::save(const QString& key,QVariant val)
|
||||
{
|
||||
m_settings->setValue(key, val);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef SETTINGSHELPER_H
|
||||
#define SETTINGSHELPER_H
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtQml/qqml.h>
|
||||
@ -9,35 +10,26 @@
|
||||
#include <QDir>
|
||||
#include "src/singleton.h"
|
||||
|
||||
class SettingsHelper : public QObject {
|
||||
class SettingsHelper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
explicit SettingsHelper(QObject* parent = nullptr);
|
||||
|
||||
public:
|
||||
SINGLETON(SettingsHelper)
|
||||
|
||||
~SettingsHelper() override;
|
||||
|
||||
void init(char *argv[]);
|
||||
|
||||
Q_INVOKABLE void saveDarkMode(int darkModel){save("darkMode",darkModel);}
|
||||
|
||||
Q_INVOKABLE int getDarkMode(){return get("darkMode",QVariant(0)).toInt();}
|
||||
|
||||
Q_INVOKABLE void saveUseSystemAppBar(bool useSystemAppBar){save("useSystemAppBar",useSystemAppBar);}
|
||||
|
||||
Q_INVOKABLE bool getUseSystemAppBar(){return get("useSystemAppBar",QVariant(false)).toBool();}
|
||||
|
||||
Q_INVOKABLE void saveLanguage(const QString &language) { save("language", language); }
|
||||
|
||||
Q_INVOKABLE void saveLanguage(QString language){save("language",language);}
|
||||
Q_INVOKABLE QString getLanguage(){return get("language",QVariant("en_US")).toString();}
|
||||
|
||||
private:
|
||||
void save(const QString& key,QVariant val);
|
||||
|
||||
QVariant get(const QString& key,QVariant def={});
|
||||
|
||||
private:
|
||||
QScopedPointer<QSettings> m_settings;
|
||||
};
|
||||
|
||||
#endif // SETTINGSHELPER_H
|
||||
|
@ -5,7 +5,8 @@
|
||||
|
||||
#include "SettingsHelper.h"
|
||||
|
||||
[[maybe_unused]] TranslateHelper::TranslateHelper(QObject *parent) : QObject(parent) {
|
||||
TranslateHelper::TranslateHelper(QObject *parent) : QObject(parent)
|
||||
{
|
||||
_languages<<"en_US";
|
||||
_languages<<"zh_CN";
|
||||
_current = SettingsHelper::getInstance()->getLanguage();
|
||||
@ -16,7 +17,7 @@ TranslateHelper::~TranslateHelper() = default;
|
||||
void TranslateHelper::init(QQmlEngine* engine){
|
||||
_engine = engine;
|
||||
_translator = new QTranslator(this);
|
||||
QGuiApplication::installTranslator(_translator);
|
||||
qApp->installTranslator(_translator);
|
||||
QString translatorPath = QGuiApplication::applicationDirPath()+"/i18n";
|
||||
if(_translator->load(QString::fromStdString("%1/example_%2.qm").arg(translatorPath,_current))){
|
||||
_engine->retranslate();
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef TRANSLATEHELPER_H
|
||||
#define TRANSLATEHELPER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QtQml/qqml.h>
|
||||
@ -6,21 +7,20 @@
|
||||
#include "src/singleton.h"
|
||||
#include "src/stdafx.h"
|
||||
|
||||
class TranslateHelper : public QObject {
|
||||
class TranslateHelper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(QString,current)
|
||||
Q_PROPERTY_READONLY_AUTO(QStringList,languages)
|
||||
private:
|
||||
[[maybe_unused]] explicit TranslateHelper(QObject *parent = nullptr);
|
||||
|
||||
explicit TranslateHelper(QObject* parent = nullptr);
|
||||
public:
|
||||
SINGLETON(TranslateHelper)
|
||||
|
||||
~TranslateHelper() override;
|
||||
|
||||
void init(QQmlEngine* engine);
|
||||
|
||||
private:
|
||||
QQmlEngine* _engine = nullptr;
|
||||
QTranslator* _translator = nullptr;
|
||||
};
|
||||
|
||||
#endif // TRANSLATEHELPER_H
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "src/component/CircularReveal.h"
|
||||
#include "src/component/FileWatcher.h"
|
||||
#include "src/component/FpsItem.h"
|
||||
#include "src/component/OpenGLItem.h"
|
||||
#include "src/helper/SettingsHelper.h"
|
||||
#include "src/helper/InitializrHelper.h"
|
||||
#include "src/helper/TranslateHelper.h"
|
||||
@ -76,9 +75,6 @@ int main(int argc, char *argv[])
|
||||
qmlRegisterType<FpsItem>(uri, major, minor, "FpsItem");
|
||||
qmlRegisterType<NetworkCallable>(uri,major,minor,"NetworkCallable");
|
||||
qmlRegisterType<NetworkParams>(uri,major,minor,"NetworkParams");
|
||||
qmlRegisterType<OpenGLItem>(uri,major,minor,"OpenGLItem");
|
||||
qmlRegisterUncreatableMetaObject(NetworkType::staticMetaObject, uri, major, minor, "NetworkType", "Access to enums & flags only");
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
TranslateHelper::getInstance()->init(&engine);
|
||||
engine.rootContext()->setContextProperty("AppInfo",AppInfo::getInstance());
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef SINGLETON_H
|
||||
#define SINGLETON_H
|
||||
|
||||
/**
|
||||
* @brief The Singleton class
|
||||
@ -22,3 +23,5 @@ private: \
|
||||
static Class* getInstance() { \
|
||||
return Singleton<Class>::getInstance(); \
|
||||
}
|
||||
|
||||
#endif // SINGLETON_H
|
||||
|
@ -1,26 +1,11 @@
|
||||
#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: \
|
||||
TYPE _##M; \
|
||||
#ifndef STDAFX_H
|
||||
#define STDAFX_H
|
||||
|
||||
#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) \
|
||||
void M(TYPE in_##M) \
|
||||
{ \
|
||||
_##M = in_##M; \
|
||||
Q_EMIT M##Changed(); \
|
||||
@ -37,7 +22,7 @@ Q_PROPERTY(TYPE M MEMBER _##M NOTIFY M##Changed)
|
||||
Q_PROPERTY(TYPE M READ M NOTIFY M##Changed FINAL) \
|
||||
public: \
|
||||
Q_SIGNAL void M##Changed(); \
|
||||
void M(const TYPE& in_##M) \
|
||||
void M(TYPE in_##M) \
|
||||
{ \
|
||||
_##M = in_##M; \
|
||||
Q_EMIT M##Changed(); \
|
||||
@ -48,3 +33,5 @@ Q_PROPERTY(TYPE M READ M NOTIFY M##Changed FINAL)
|
||||
} \
|
||||
private: \
|
||||
TYPE _##M; \
|
||||
|
||||
#endif // STDAFX_H
|
||||
|
@ -24,7 +24,7 @@ option(FLUENTUI_BUILD_STATIC_LIB "Build static library." OFF)
|
||||
|
||||
#导入Qt相关依赖包
|
||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Quick Qml)
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Quick)
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Quick Qml)
|
||||
|
||||
set(QT_SDK_DIR "${Qt${QT_VERSION_MAJOR}_DIR}/../../..")
|
||||
cmake_path(SET QT_SDK_DIR NORMALIZE ${QT_SDK_DIR})
|
||||
@ -59,7 +59,7 @@ file(GLOB QM_FILE_PATHS ${CMAKE_CURRENT_LIST_DIR}/ *.qm)
|
||||
file(COPY ${QM_FILE_PATHS} DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/Qt${QT_VERSION_MAJOR}/imports/FluentUI/i18n")
|
||||
|
||||
#遍历所有Cpp文件
|
||||
file(GLOB_RECURSE CPP_FILES *.cpp *.h *.cxx)
|
||||
file(GLOB_RECURSE CPP_FILES *.cpp *.h)
|
||||
foreach(filepath ${CPP_FILES})
|
||||
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
|
||||
list(APPEND sources_files ${filename})
|
||||
|
1
src/Def.cpp
Normal file
1
src/Def.cpp
Normal file
@ -0,0 +1 @@
|
||||
#include "Def.h"
|
35
src/Def.h
35
src/Def.h
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef DEF_H
|
||||
#define DEF_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QtQml/qqml.h>
|
||||
@ -11,9 +12,7 @@ namespace FluSheetType {
|
||||
Right = 0x0002,
|
||||
Bottom = 0x0004,
|
||||
};
|
||||
|
||||
Q_ENUM_NS(Position)
|
||||
|
||||
QML_NAMED_ELEMENT(FluSheetType)
|
||||
}
|
||||
|
||||
@ -24,9 +23,7 @@ namespace FluThemeType {
|
||||
Light = 0x0001,
|
||||
Dark = 0x0002,
|
||||
};
|
||||
|
||||
Q_ENUM_NS(DarkMode)
|
||||
|
||||
QML_NAMED_ELEMENT(FluThemeType)
|
||||
}
|
||||
|
||||
@ -37,9 +34,7 @@ namespace FluTimelineType {
|
||||
Right = 0x0001,
|
||||
Alternate = 0x0002,
|
||||
};
|
||||
|
||||
Q_ENUM_NS(Mode)
|
||||
|
||||
QML_NAMED_ELEMENT(FluTimelineType)
|
||||
}
|
||||
|
||||
@ -51,9 +46,7 @@ namespace FluPageType {
|
||||
SingleTop = 0x0002,
|
||||
SingleInstance = 0x0004
|
||||
};
|
||||
|
||||
Q_ENUM_NS(LaunchMode)
|
||||
|
||||
QML_NAMED_ELEMENT(FluPageType)
|
||||
}
|
||||
|
||||
@ -64,9 +57,7 @@ namespace FluWindowType {
|
||||
SingleTask = 0x0001,
|
||||
SingleInstance = 0x0002
|
||||
};
|
||||
|
||||
Q_ENUM_NS(LaunchMode)
|
||||
|
||||
QML_NAMED_ELEMENT(FluWindowType)
|
||||
}
|
||||
|
||||
@ -77,9 +68,7 @@ namespace FluTreeViewType {
|
||||
Single = 0x0001,
|
||||
Multiple = 0x0002
|
||||
};
|
||||
|
||||
Q_ENUM_NS(SelectionMode)
|
||||
|
||||
QML_NAMED_ELEMENT(FluTreeViewType)
|
||||
}
|
||||
|
||||
@ -91,9 +80,7 @@ namespace FluStatusLayoutType {
|
||||
Error = 0x0002,
|
||||
Success = 0x0004
|
||||
};
|
||||
|
||||
Q_ENUM_NS(StatusMode)
|
||||
|
||||
QML_NAMED_ELEMENT(FluStatusLayoutType)
|
||||
}
|
||||
|
||||
@ -104,9 +91,7 @@ namespace FluContentDialogType {
|
||||
NegativeButton = 0x0002,
|
||||
PositiveButton = 0x0004
|
||||
};
|
||||
|
||||
Q_ENUM_NS(ButtonFlag)
|
||||
|
||||
QML_NAMED_ELEMENT(FluContentDialogType)
|
||||
}
|
||||
|
||||
@ -116,9 +101,7 @@ namespace FluTimePickerType {
|
||||
H = 0x0000,
|
||||
HH = 0x0001
|
||||
};
|
||||
|
||||
Q_ENUM_NS(HourFormat)
|
||||
|
||||
QML_NAMED_ELEMENT(FluTimePickerType)
|
||||
}
|
||||
|
||||
@ -129,9 +112,7 @@ namespace FluCalendarViewType {
|
||||
Year = 0x0001,
|
||||
Decade = 0x0002
|
||||
};
|
||||
|
||||
Q_ENUM_NS(DisplayMode)
|
||||
|
||||
QML_NAMED_ELEMENT(FluCalendarViewType)
|
||||
}
|
||||
|
||||
@ -142,17 +123,13 @@ namespace FluTabViewType {
|
||||
SizeToContent = 0x0001,
|
||||
Compact = 0x0002
|
||||
};
|
||||
|
||||
Q_ENUM_NS(TabWidthBehavior)
|
||||
|
||||
enum CloseButtonVisibility {
|
||||
Never = 0x0000,
|
||||
Always = 0x0001,
|
||||
OnHover = 0x0002
|
||||
};
|
||||
|
||||
Q_ENUM_NS(CloseButtonVisibility)
|
||||
|
||||
QML_NAMED_ELEMENT(FluTabViewType)
|
||||
}
|
||||
|
||||
@ -164,16 +141,12 @@ namespace FluNavigationViewType {
|
||||
Minimal = 0x0002,
|
||||
Auto = 0x0004
|
||||
};
|
||||
|
||||
Q_ENUM_NS(DisplayMode)
|
||||
|
||||
enum PageMode {
|
||||
Stack = 0x0000,
|
||||
NoStack = 0x0001
|
||||
};
|
||||
|
||||
Q_ENUM_NS(PageMode)
|
||||
|
||||
QML_NAMED_ELEMENT(FluNavigationViewType)
|
||||
}
|
||||
|
||||
@ -1584,8 +1557,8 @@ namespace Fluent_Awesome {
|
||||
SpeechSolidBold=0xf8b2,
|
||||
ClickedOutLoudSolidBold=0xf8b3,
|
||||
};
|
||||
|
||||
Q_ENUM_NS(Fluent_AwesomeType)
|
||||
|
||||
QML_NAMED_ELEMENT(FluentIcons)
|
||||
}
|
||||
|
||||
#endif // DEF_H
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "FluAccentColor.h"
|
||||
|
||||
FluAccentColor::FluAccentColor(QObject *parent):QObject{parent}{
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef FLUACCENTCOLOR_H
|
||||
#define FLUACCENTCOLOR_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QtQml/qqml.h>
|
||||
@ -8,9 +9,9 @@
|
||||
/**
|
||||
* @brief The FluAccentColor class
|
||||
*/
|
||||
class FluAccentColor : public QObject {
|
||||
class FluAccentColor : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY_AUTO(QColor,darkest)
|
||||
Q_PROPERTY_AUTO(QColor,darker)
|
||||
Q_PROPERTY_AUTO(QColor,dark)
|
||||
@ -22,3 +23,5 @@ Q_PROPERTY_AUTO(QColor, lightest)
|
||||
public:
|
||||
explicit FluAccentColor(QObject *parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // FLUACCENTCOLOR_H
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <QQmlEngine>
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlContext>
|
||||
#include <QQuickItem>
|
||||
#include <QTimer>
|
||||
#include <QUuid>
|
||||
@ -10,10 +11,11 @@
|
||||
#include <QTranslator>
|
||||
|
||||
FluApp::FluApp(QObject *parent):QObject{parent}{
|
||||
_useSystemAppBar = false;
|
||||
useSystemAppBar(false);
|
||||
}
|
||||
|
||||
FluApp::~FluApp() = default;
|
||||
FluApp::~FluApp(){
|
||||
}
|
||||
|
||||
void FluApp::init(QObject *target,QLocale locale){
|
||||
_locale = locale;
|
||||
|
27
src/FluApp.h
27
src/FluApp.h
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef FLUAPP_H
|
||||
#define FLUAPP_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QWindow>
|
||||
@ -14,28 +15,24 @@
|
||||
/**
|
||||
* @brief The FluApp class
|
||||
*/
|
||||
class FluApp : public QObject {
|
||||
class FluApp : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY_AUTO(bool, useSystemAppBar)
|
||||
Q_PROPERTY_AUTO(QString, windowIcon)
|
||||
Q_PROPERTY_AUTO(QLocale, locale)
|
||||
Q_PROPERTY_AUTO(bool,useSystemAppBar);
|
||||
Q_PROPERTY_AUTO(QString,windowIcon);
|
||||
Q_PROPERTY_AUTO(QLocale,locale);
|
||||
QML_NAMED_ELEMENT(FluApp)
|
||||
QML_SINGLETON
|
||||
|
||||
private:
|
||||
explicit FluApp(QObject *parent = nullptr);
|
||||
|
||||
~FluApp() override;
|
||||
|
||||
~FluApp();
|
||||
public:
|
||||
SINGLETON(FluApp)
|
||||
|
||||
static FluApp *create(QQmlEngine *, QJSEngine *) { return getInstance(); }
|
||||
|
||||
static FluApp *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
|
||||
Q_INVOKABLE void init(QObject *target,QLocale locale = QLocale::system());
|
||||
|
||||
private:
|
||||
QQmlEngine *_engine{};
|
||||
QQmlEngine *_engine;
|
||||
QTranslator* _translator = nullptr;
|
||||
};
|
||||
|
||||
#endif // FLUAPP_H
|
||||
|
@ -3,17 +3,14 @@
|
||||
#include <QChar>
|
||||
#include <QPainter>
|
||||
#include <QRandomGenerator>
|
||||
|
||||
int generaNumber(int number) {
|
||||
return QRandomGenerator::global()->bounded(0, number);
|
||||
}
|
||||
#include <qmath.h>
|
||||
|
||||
FluCaptcha::FluCaptcha(QQuickItem *parent):QQuickPaintedItem(parent){
|
||||
_ignoreCase = false;
|
||||
QFont fontStyle;
|
||||
fontStyle.setPixelSize(28);
|
||||
fontStyle.setBold(true);
|
||||
font(fontStyle);
|
||||
ignoreCase(true);
|
||||
QFont fontStype;
|
||||
fontStype.setPixelSize(28);
|
||||
fontStype.setBold(true);
|
||||
font(fontStype);
|
||||
setWidth(180);
|
||||
setHeight(80);
|
||||
refresh();
|
||||
@ -24,42 +21,55 @@ void FluCaptcha::paint(QPainter *painter) {
|
||||
painter->fillRect(boundingRect().toRect(),QColor(255,255,255,255));
|
||||
QPen pen;
|
||||
painter->setFont(_font);
|
||||
for (int i = 0; i < 100; i++) {
|
||||
pen = QPen(QColor(generaNumber(256), generaNumber(256), generaNumber(256)));
|
||||
for(int i=0;i<100;i++)
|
||||
{
|
||||
pen = QPen(QColor(_generaNumber(256),_generaNumber(256),_generaNumber(256)));
|
||||
painter->setPen(pen);
|
||||
painter->drawPoint(generaNumber(180), generaNumber(80));
|
||||
painter->drawPoint(_generaNumber(180),_generaNumber(80));
|
||||
}
|
||||
for (int i = 0; i < 5; i++) {
|
||||
pen = QPen(QColor(generaNumber(256), generaNumber(256), generaNumber(256)));
|
||||
for(int i=0;i<5;i++)
|
||||
{
|
||||
pen = QPen(QColor(_generaNumber(256),_generaNumber(256),_generaNumber(256)));
|
||||
painter->setPen(pen);
|
||||
painter->drawLine(generaNumber(180), generaNumber(80), generaNumber(180), generaNumber(80));
|
||||
painter->drawLine(_generaNumber(180),_generaNumber(80),_generaNumber(180),_generaNumber(80));
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
pen = QPen(QColor(generaNumber(255), generaNumber(255), generaNumber(255)));
|
||||
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();
|
||||
}
|
||||
|
||||
int FluCaptcha::_generaNumber(int number){
|
||||
return QRandomGenerator::global()->bounded(0,number);
|
||||
}
|
||||
|
||||
void FluCaptcha::refresh(){
|
||||
this->_code.clear();
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
int num = generaNumber(3);
|
||||
if (num == 0) {
|
||||
this->_code += QString::number(generaNumber(10));
|
||||
} else if (num == 1) {
|
||||
for(int i = 0;i < 4;++i)
|
||||
{
|
||||
int num = _generaNumber(3);
|
||||
if(num == 0)
|
||||
{
|
||||
this->_code += QString::number(_generaNumber(10));
|
||||
}
|
||||
else if(num == 1)
|
||||
{
|
||||
int temp = 'A';
|
||||
this->_code += static_cast<QChar>(temp + generaNumber(26));
|
||||
} else if (num == 2) {
|
||||
this->_code += static_cast<QChar>(temp + _generaNumber(26));
|
||||
}
|
||||
else if(num == 2)
|
||||
{
|
||||
int temp = 'a';
|
||||
this->_code += static_cast<QChar>(temp + generaNumber(26));
|
||||
this->_code += static_cast<QChar>(temp + _generaNumber(26));
|
||||
}
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
[[maybe_unused]] bool FluCaptcha::verify(const QString &code) {
|
||||
bool FluCaptcha::verify(const QString& code){
|
||||
if(_ignoreCase){
|
||||
return this->_code.toUpper() == code.toUpper();
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef FLUCAPTCHA_H
|
||||
#define FLUCAPTCHA_H
|
||||
|
||||
#include <QQuickItem>
|
||||
#include <QQuickPaintedItem>
|
||||
@ -8,22 +9,21 @@
|
||||
/**
|
||||
* @brief The FluCaptcha class
|
||||
*/
|
||||
class FluCaptcha : public QQuickPaintedItem {
|
||||
class FluCaptcha : public QQuickPaintedItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY_AUTO(QFont,font);
|
||||
Q_PROPERTY_AUTO(bool,ignoreCase);
|
||||
QML_NAMED_ELEMENT(FluCaptcha)
|
||||
|
||||
private:
|
||||
int _generaNumber(int number);
|
||||
public:
|
||||
explicit FluCaptcha(QQuickItem *parent = nullptr);
|
||||
|
||||
void paint(QPainter* painter) override;
|
||||
|
||||
Q_INVOKABLE void refresh();
|
||||
|
||||
Q_INVOKABLE [[maybe_unused]] bool verify(const QString &code);
|
||||
|
||||
Q_INVOKABLE bool verify(const QString& code);
|
||||
private:
|
||||
QString _code;
|
||||
};
|
||||
|
||||
#endif // FLUCAPTCHA_H
|
||||
|
@ -2,33 +2,34 @@
|
||||
#include "FluTools.h"
|
||||
|
||||
FluColors::FluColors(QObject *parent):QObject{parent}{
|
||||
_Transparent = QColor(0, 0, 0, 0);
|
||||
_Black = QColor(0, 0, 0);
|
||||
_White = QColor(255, 255, 255);
|
||||
_Grey10 = QColor(250, 249, 248);
|
||||
_Grey20 = QColor(243, 242, 241);
|
||||
_Grey30 = QColor(237, 235, 233);
|
||||
_Grey40 = QColor(225, 223, 221);
|
||||
_Grey50 = QColor(210, 208, 206);
|
||||
_Grey60 = QColor(200, 198, 196);
|
||||
_Grey70 = QColor(190, 185, 184);
|
||||
_Grey80 = QColor(179, 176, 173);
|
||||
_Grey90 = QColor(161, 159, 157);
|
||||
_Grey100 = QColor(151, 149, 146);
|
||||
_Grey110 = QColor(138, 136, 134);
|
||||
_Grey120 = QColor(121, 119, 117);
|
||||
_Grey130 = QColor(96, 94, 92);
|
||||
_Grey140 = QColor(72, 70, 68);
|
||||
_Grey150 = QColor(59, 58, 57);
|
||||
_Grey160 = QColor(50, 49, 48);
|
||||
_Grey170 = QColor(41, 40, 39);
|
||||
_Grey180 = QColor(37, 36, 35);
|
||||
_Grey190 = QColor(32, 31, 30);
|
||||
_Grey200 = QColor(27, 26, 25);
|
||||
_Grey210 = QColor(22, 21, 20);
|
||||
_Grey220 = QColor(17, 16, 15);
|
||||
Transparent(QColor(0, 0, 0, 0));
|
||||
Black(QColor(0, 0, 0));
|
||||
White(QColor(255, 255, 255));
|
||||
Grey10(QColor(250, 249, 248));
|
||||
Grey20(QColor(243, 242, 241));
|
||||
Grey30(QColor(237, 235, 233));
|
||||
Grey40(QColor(225, 223, 221));
|
||||
Grey50(QColor(210, 208, 206));
|
||||
Grey60(QColor(200, 198, 196));
|
||||
Grey70(QColor(190, 185, 184));
|
||||
Grey80(QColor(179, 176, 173));
|
||||
Grey90(QColor(161, 159, 157));
|
||||
Grey100(QColor(151, 149, 146));
|
||||
Grey110(QColor(138, 136, 134));
|
||||
Grey120(QColor(121, 119, 117));
|
||||
Grey130(QColor(96, 94, 92));
|
||||
Grey140(QColor(72, 70, 68));
|
||||
Grey150(QColor(59, 58, 57));
|
||||
Grey160(QColor(50, 49, 48));
|
||||
Grey170(QColor(41, 40, 39));
|
||||
Grey180(QColor(37, 36, 35));
|
||||
Grey190(QColor(32, 31, 30));
|
||||
Grey200(QColor(27, 26, 25));
|
||||
Grey210(QColor(22, 21, 20));
|
||||
Grey220(QColor(17, 16, 15));
|
||||
|
||||
auto yellow = new FluAccentColor(this);
|
||||
|
||||
FluAccentColor *yellow = new FluAccentColor(this);
|
||||
yellow->darkest(QColor(249, 168, 37));
|
||||
yellow->darker(QColor(251, 192, 45));
|
||||
yellow->dark(QColor(253, 212, 53));
|
||||
@ -36,9 +37,9 @@ FluColors::FluColors(QObject *parent) : QObject{parent} {
|
||||
yellow->light(QColor(255, 238, 88));
|
||||
yellow->lighter(QColor(255, 241, 118));
|
||||
yellow->lightest(QColor(255, 245, 155));
|
||||
_Yellow = yellow;
|
||||
Yellow(yellow);
|
||||
|
||||
auto orange = new FluAccentColor(this);
|
||||
FluAccentColor *orange = new FluAccentColor(this);
|
||||
orange->darkest(QColor(153, 61, 7));
|
||||
orange->darker(QColor(172, 68, 8));
|
||||
orange->dark(QColor(209, 88, 10));
|
||||
@ -46,9 +47,9 @@ FluColors::FluColors(QObject *parent) : QObject{parent} {
|
||||
orange->light(QColor(248, 122, 48));
|
||||
orange->lighter(QColor(249, 145, 84));
|
||||
orange->lightest(QColor(250, 192, 106));
|
||||
_Orange = orange;
|
||||
Orange(orange);
|
||||
|
||||
auto red = new FluAccentColor(this);
|
||||
FluAccentColor *red = new FluAccentColor(this);
|
||||
red->darkest(QColor(143, 10, 21));
|
||||
red->darker(QColor(162, 11, 24));
|
||||
red->dark(QColor(185, 13, 28));
|
||||
@ -56,9 +57,9 @@ FluColors::FluColors(QObject *parent) : QObject{parent} {
|
||||
red->light(QColor(236, 64, 79));
|
||||
red->lighter(QColor(238, 88, 101));
|
||||
red->lightest(QColor(240, 107, 118));
|
||||
_Red = red;
|
||||
Red(red);
|
||||
|
||||
auto magenta = new FluAccentColor(this);
|
||||
FluAccentColor *magenta = new FluAccentColor(this);
|
||||
magenta->darkest(QColor(111, 0, 79));
|
||||
magenta->darker(QColor(160, 7, 108));
|
||||
magenta->dark(QColor(181, 13, 125));
|
||||
@ -66,9 +67,9 @@ FluColors::FluColors(QObject *parent) : QObject{parent} {
|
||||
magenta->light(QColor(234, 77, 168));
|
||||
magenta->lighter(QColor(238, 110, 193));
|
||||
magenta->lightest(QColor(241, 140, 213));
|
||||
_Magenta = magenta;
|
||||
Magenta(magenta);
|
||||
|
||||
auto purple = new FluAccentColor(this);
|
||||
FluAccentColor *purple = new FluAccentColor(this);
|
||||
purple->darkest(QColor(44, 15, 118));
|
||||
purple->darker(QColor(61, 15, 153));
|
||||
purple->dark(QColor(78, 17, 174));
|
||||
@ -76,9 +77,9 @@ FluColors::FluColors(QObject *parent) : QObject{parent} {
|
||||
purple->light(QColor(123, 76, 157));
|
||||
purple->lighter(QColor(141, 110, 189));
|
||||
purple->lightest(QColor(158, 142, 217));
|
||||
_Purple = purple;
|
||||
Purple(purple);
|
||||
|
||||
auto blue = new FluAccentColor(this);
|
||||
FluAccentColor *blue = new FluAccentColor(this);
|
||||
blue->darkest(QColor(0, 74, 131));
|
||||
blue->darker(QColor(0, 84, 148));
|
||||
blue->dark(QColor(0, 102, 180));
|
||||
@ -86,9 +87,9 @@ FluColors::FluColors(QObject *parent) : QObject{parent} {
|
||||
blue->light(QColor(38, 140, 220));
|
||||
blue->lighter(QColor(76, 160, 224));
|
||||
blue->lightest(QColor(96, 171, 228));
|
||||
_Blue = blue;
|
||||
Blue(blue);
|
||||
|
||||
auto teal = new FluAccentColor(this);
|
||||
FluAccentColor *teal = new FluAccentColor(this);
|
||||
teal->darkest(QColor(0, 110, 91));
|
||||
teal->darker(QColor(0, 124, 103));
|
||||
teal->dark(QColor(0, 151, 125));
|
||||
@ -96,9 +97,9 @@ FluColors::FluColors(QObject *parent) : QObject{parent} {
|
||||
teal->light(QColor(38, 189, 164));
|
||||
teal->lighter(QColor(77, 201, 180));
|
||||
teal->lightest(QColor(96, 207, 188));
|
||||
_Teal = teal;
|
||||
Teal(teal);
|
||||
|
||||
auto green = new FluAccentColor(this);
|
||||
FluAccentColor *green = new FluAccentColor(this);
|
||||
green->darkest(QColor(9, 76, 9));
|
||||
green->darker(QColor(12, 93, 12));
|
||||
green->dark(QColor(14, 111, 14));
|
||||
@ -106,11 +107,11 @@ FluColors::FluColors(QObject *parent) : QObject{parent} {
|
||||
green->light(QColor(39, 137, 57));
|
||||
green->lighter(QColor(76, 156, 76));
|
||||
green->lightest(QColor(106, 173, 106));
|
||||
_Green = green;
|
||||
Green(green);
|
||||
}
|
||||
|
||||
[[maybe_unused]] FluAccentColor *FluColors::createAccentColor(QColor primaryColor) {
|
||||
auto accentColor = new FluAccentColor(this);
|
||||
FluAccentColor* FluColors::createAccentColor(QColor primaryColor){
|
||||
FluAccentColor *accentColor = new FluAccentColor(this);
|
||||
accentColor->darkest(FluTools::getInstance()->withOpacity(primaryColor,0.7));
|
||||
accentColor->darker(FluTools::getInstance()->withOpacity(primaryColor,0.8));
|
||||
accentColor->dark(FluTools::getInstance()->withOpacity(primaryColor,0.9));
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef FLUCOLORS_H
|
||||
#define FLUCOLORS_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QtQml/qqml.h>
|
||||
@ -10,9 +11,9 @@
|
||||
/**
|
||||
* @brief The FluColors class
|
||||
*/
|
||||
class FluColors : public QObject {
|
||||
class FluColors : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY_AUTO(QColor,Transparent);
|
||||
Q_PROPERTY_AUTO(QColor,Black);
|
||||
Q_PROPERTY_AUTO(QColor,White);
|
||||
@ -38,24 +39,22 @@ 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(FluAccentColor*,Yellow);
|
||||
Q_PROPERTY_AUTO(FluAccentColor*,Orange);
|
||||
Q_PROPERTY_AUTO(FluAccentColor*,Red);
|
||||
Q_PROPERTY_AUTO(FluAccentColor*,Magenta);
|
||||
Q_PROPERTY_AUTO(FluAccentColor*,Purple);
|
||||
Q_PROPERTY_AUTO(FluAccentColor*,Blue);
|
||||
Q_PROPERTY_AUTO(FluAccentColor*,Teal);
|
||||
Q_PROPERTY_AUTO(FluAccentColor*,Green);
|
||||
QML_NAMED_ELEMENT(FluColors)
|
||||
QML_SINGLETON
|
||||
|
||||
private:
|
||||
explicit FluColors(QObject *parent = nullptr);
|
||||
|
||||
public:
|
||||
SINGLETON(FluColors)
|
||||
|
||||
Q_INVOKABLE [[maybe_unused]] FluAccentColor *createAccentColor(QColor primaryColor);
|
||||
|
||||
static FluColors *create(QQmlEngine *, QJSEngine *) { return getInstance(); }
|
||||
Q_INVOKABLE FluAccentColor* createAccentColor(QColor primaryColor);
|
||||
static FluColors *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
|
||||
};
|
||||
|
||||
#endif // FLUCOLORS_H
|
||||
|
@ -8,59 +8,48 @@
|
||||
#ifdef Q_OS_WIN
|
||||
#pragma comment (lib,"user32.lib")
|
||||
#pragma comment (lib,"dwmapi.lib")
|
||||
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <dwmapi.h>
|
||||
|
||||
static inline QByteArray qtNativeEventType() {
|
||||
static inline QByteArray qtNativeEventType()
|
||||
{
|
||||
static const auto result = "windows_generic_MSG";
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline bool isCompositionEnabled(){
|
||||
typedef HRESULT (WINAPI* DwmIsCompositionEnabledPtr)(BOOL *pfEnabled);
|
||||
HMODULE module = ::LoadLibraryW(L"dwmapi.dll");
|
||||
if (module) {
|
||||
if (module)
|
||||
{
|
||||
BOOL composition_enabled = false;
|
||||
DwmIsCompositionEnabledPtr dwm_is_composition_enabled;
|
||||
dwm_is_composition_enabled= reinterpret_cast<DwmIsCompositionEnabledPtr>(::GetProcAddress(module, "DwmIsCompositionEnabled"));
|
||||
if (dwm_is_composition_enabled) {
|
||||
if (dwm_is_composition_enabled)
|
||||
{
|
||||
dwm_is_composition_enabled(&composition_enabled);
|
||||
}
|
||||
return composition_enabled;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
bool containsCursorToItem(QQuickItem *item) {
|
||||
if (!item || !item->isVisible()) {
|
||||
return false;
|
||||
}
|
||||
auto point = QCursor::pos();
|
||||
auto rect = QRectF(item->mapToGlobal(QPoint(0, 0)), item->size());
|
||||
if (point.x() > rect.x() && point.x() < (rect.x() + rect.width()) && point.y() > rect.y() && point.y() < (rect.y() + rect.height())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
FluFrameless::FluFrameless(QQuickItem *parent)
|
||||
: QQuickItem{parent}
|
||||
{
|
||||
appbar(nullptr);
|
||||
maximizeButton(nullptr);
|
||||
minimizedButton(nullptr);
|
||||
closeButton(nullptr);
|
||||
topmost(false);
|
||||
disabled(false);
|
||||
}
|
||||
|
||||
FluFrameless::FluFrameless(QQuickItem *parent) : QQuickItem{parent} {
|
||||
_fixSize = false;
|
||||
_appbar = nullptr;
|
||||
_maximizeButton = nullptr;
|
||||
_minimizedButton = nullptr;
|
||||
_closeButton = nullptr;
|
||||
_topmost = false;
|
||||
_disabled = false;
|
||||
FluFrameless::~FluFrameless(){
|
||||
}
|
||||
|
||||
FluFrameless::~FluFrameless() = default;
|
||||
|
||||
[[maybe_unused]] void FluFrameless::onDestruction() {
|
||||
QGuiApplication::instance()->removeNativeEventFilter(this);
|
||||
void FluFrameless::onDestruction(){
|
||||
qApp->removeNativeEventFilter(this);
|
||||
}
|
||||
|
||||
void FluFrameless::componentComplete(){
|
||||
@ -78,7 +67,7 @@ void FluFrameless::componentComplete() {
|
||||
window()->setFlag(Qt::WindowMaximizeButtonHint);
|
||||
}
|
||||
window()->installEventFilter(this);
|
||||
QGuiApplication::instance()->installNativeEventFilter(this);
|
||||
qApp->installNativeEventFilter(this);
|
||||
if(_maximizeButton){
|
||||
setHitTestVisible(_maximizeButton);
|
||||
}
|
||||
@ -93,8 +82,8 @@ void FluFrameless::componentComplete() {
|
||||
DWORD style = ::GetWindowLongPtr(hwnd, GWL_STYLE);
|
||||
if(_fixSize){
|
||||
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME);
|
||||
for (int i = 0; i <= QGuiApplication::screens().count() - 1; ++i) {
|
||||
connect(QGuiApplication::screens().at(i), &QScreen::logicalDotsPerInchChanged, this, [=] {
|
||||
for (int i = 0; i < qApp->screens().count(); ++i) {
|
||||
connect( qApp->screens().at(i),&QScreen::logicalDotsPerInchChanged,this,[=]{
|
||||
SetWindowPos(hwnd,nullptr,0,0,0,0,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_FRAMECHANGED);
|
||||
});
|
||||
}
|
||||
@ -103,8 +92,8 @@ void FluFrameless::componentComplete() {
|
||||
}
|
||||
SetWindowPos(hwnd,nullptr,0,0,0,0,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
|
||||
connect(window(),&QQuickWindow::screenChanged,this,[hwnd]{
|
||||
::SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOOWNERZORDER);
|
||||
::RedrawWindow(hwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW);
|
||||
::SetWindowPos(hwnd,0,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOOWNERZORDER);
|
||||
::RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
|
||||
});
|
||||
#endif
|
||||
connect(this,&FluFrameless::topmostChanged,this,[this]{
|
||||
@ -113,27 +102,28 @@ void FluFrameless::componentComplete() {
|
||||
_setWindowTopmost(topmost());
|
||||
}
|
||||
|
||||
[[maybe_unused]] bool FluFrameless::nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result) {
|
||||
bool FluFrameless::nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result){
|
||||
#ifdef Q_OS_WIN
|
||||
if ((eventType != qtNativeEventType()) || !message) {
|
||||
return false;
|
||||
}
|
||||
const auto msg = static_cast<const MSG *>(message);
|
||||
auto hwnd = msg->hwnd;
|
||||
if (!hwnd) {
|
||||
const HWND hwnd = msg->hwnd;
|
||||
if (!hwnd || !msg) {
|
||||
return false;
|
||||
}
|
||||
const quint64 wid = reinterpret_cast<qint64>(hwnd);
|
||||
const qint64 wid = reinterpret_cast<qint64>(hwnd);
|
||||
if(wid != _current){
|
||||
return false;
|
||||
}
|
||||
const auto uMsg = msg->message;
|
||||
const auto wParam = msg->wParam;
|
||||
const auto lParam = msg->lParam;
|
||||
const UINT uMsg = msg->message;
|
||||
const WPARAM wParam = msg->wParam;
|
||||
const LPARAM lParam = msg->lParam;
|
||||
static QPoint offsetXY;
|
||||
if(uMsg == WM_WINDOWPOSCHANGING){
|
||||
auto *wp = reinterpret_cast<WINDOWPOS *>(lParam);
|
||||
if (wp != nullptr && (wp->flags & SWP_NOSIZE) == 0) {
|
||||
WINDOWPOS* wp = reinterpret_cast<WINDOWPOS*>(lParam);
|
||||
if (wp != nullptr && (wp->flags & SWP_NOSIZE) == 0)
|
||||
{
|
||||
wp->flags |= SWP_NOCOPYBITS;
|
||||
*result = ::DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
||||
return true;
|
||||
@ -150,7 +140,7 @@ void FluFrameless::componentComplete() {
|
||||
*result = hitTestResult;
|
||||
return true;
|
||||
}
|
||||
int offsetSize;
|
||||
int offsetSize = 0;
|
||||
bool isMaximum = ::IsZoomed(hwnd);
|
||||
offsetXY = QPoint(abs(clientRect->left - originalLeft),abs(clientRect->top - originalTop));
|
||||
if(isMaximum || _isFullScreen()){
|
||||
@ -161,19 +151,12 @@ void FluFrameless::componentComplete() {
|
||||
if(!isCompositionEnabled()){
|
||||
offsetSize = 0;
|
||||
}
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
if (!isMaximum) {
|
||||
if (!isMaximum || QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) {
|
||||
clientRect->top = originalTop + offsetSize;
|
||||
clientRect->bottom = originalBottom - offsetSize;
|
||||
clientRect->left = originalLeft + offsetSize;
|
||||
clientRect->right = originalRight - offsetSize;
|
||||
}
|
||||
#else
|
||||
clientRect->top = originalTop + offsetSize;
|
||||
clientRect->bottom = originalBottom - offsetSize;
|
||||
clientRect->left = originalLeft + offsetSize;
|
||||
clientRect->right = originalRight - offsetSize;
|
||||
#endif
|
||||
_setMaximizeHovered(false);
|
||||
*result = WVR_REDRAW;
|
||||
return true;
|
||||
@ -249,15 +232,15 @@ void FluFrameless::componentComplete() {
|
||||
*result = ::DefWindowProcW(hwnd, WM_NCACTIVATE, wParam, -1);
|
||||
return true;
|
||||
}else if(uMsg == WM_GETMINMAXINFO){
|
||||
auto *minmaxInfo = reinterpret_cast<MINMAXINFO *>(lParam);
|
||||
MINMAXINFO* minmaxInfo = reinterpret_cast<MINMAXINFO *>(lParam);
|
||||
auto pixelRatio = window()->devicePixelRatio();
|
||||
auto geometry = window()->screen()->availableGeometry();
|
||||
RECT rect;
|
||||
SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0);
|
||||
minmaxInfo->ptMaxPosition.x = rect.left - offsetXY.x();
|
||||
minmaxInfo->ptMaxPosition.y = rect.top - offsetXY.x();
|
||||
minmaxInfo->ptMaxSize.x = qRound(geometry.width() * pixelRatio) + offsetXY.x() * 2;
|
||||
minmaxInfo->ptMaxSize.y = qRound(geometry.height() * pixelRatio) + offsetXY.y() * 2;
|
||||
minmaxInfo->ptMaxSize.x = geometry.width()*pixelRatio + offsetXY.x() * 2;
|
||||
minmaxInfo->ptMaxSize.y = geometry.height()*pixelRatio + offsetXY.y() * 2;
|
||||
return false;
|
||||
}else if(uMsg == WM_NCRBUTTONDOWN){
|
||||
if (wParam == HTCAPTION) {
|
||||
@ -268,7 +251,7 @@ void FluFrameless::componentComplete() {
|
||||
const bool spacePressed = ((wParam == VK_SPACE) || (::GetKeyState(VK_SPACE) < 0));
|
||||
if (altPressed && spacePressed) {
|
||||
auto pos = window()->position();
|
||||
_showSystemMenu(QPoint(pos.x(), qRound(pos.y() + _appbar->height())));
|
||||
_showSystemMenu(QPoint(pos.x(),pos.y()+_appbar->height()));
|
||||
}
|
||||
}else if(uMsg == WM_SYSCOMMAND){
|
||||
if(wParam == SC_MINIMIZE){
|
||||
@ -282,9 +265,8 @@ void FluFrameless::componentComplete() {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FluFrameless::_isMaximized(){
|
||||
@ -300,7 +282,7 @@ void FluFrameless::_showSystemMenu(QPoint point) {
|
||||
HWND hwnd = reinterpret_cast<HWND>(window()->winId());
|
||||
DWORD style = ::GetWindowLongPtr(hwnd,GWL_STYLE);
|
||||
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_SYSMENU);
|
||||
auto hMenu = ::GetSystemMenu(hwnd, FALSE);
|
||||
const HMENU hMenu = ::GetSystemMenu(hwnd, FALSE);
|
||||
if(_isMaximized() || _isFullScreen()){
|
||||
::EnableMenuItem(hMenu,SC_MOVE,MFS_DISABLED);
|
||||
::EnableMenuItem(hMenu,SC_RESTORE,MFS_ENABLED);
|
||||
@ -315,8 +297,7 @@ void FluFrameless::_showSystemMenu(QPoint point) {
|
||||
::EnableMenuItem(hMenu,SC_SIZE,MFS_DISABLED);
|
||||
::EnableMenuItem(hMenu,SC_MAXIMIZE,MFS_DISABLED);
|
||||
}
|
||||
const int result = ::TrackPopupMenu(hMenu, (TPM_RETURNCMD | (QGuiApplication::isRightToLeft() ? TPM_RIGHTALIGN : TPM_LEFTALIGN)), qRound(point.x() * window()->devicePixelRatio()),
|
||||
qRound(point.y() * window()->devicePixelRatio()), 0, hwnd, nullptr);
|
||||
const int result = ::TrackPopupMenu(hMenu, (TPM_RETURNCMD | (QGuiApplication::isRightToLeft() ? TPM_RIGHTALIGN : TPM_LEFTALIGN)), point.x()*window()->devicePixelRatio(), point.y()*window()->devicePixelRatio(), 0, hwnd, nullptr);
|
||||
if (result != FALSE) {
|
||||
::PostMessageW(hwnd, WM_SYSCOMMAND, result, 0);
|
||||
}
|
||||
@ -324,21 +305,32 @@ void FluFrameless::_showSystemMenu(QPoint point) {
|
||||
#endif
|
||||
}
|
||||
|
||||
bool FluFrameless::_containsCursorToItem(QQuickItem* item){
|
||||
if(!item || !item->isVisible()){
|
||||
return false;
|
||||
}
|
||||
auto point = QCursor::pos();
|
||||
auto rect = QRectF(item->mapToGlobal(QPoint(0,0)),item->size());
|
||||
if(point.x()>rect.x() && point.x()<(rect.x()+rect.width()) && point.y()>rect.y() && point.y()<(rect.y()+rect.height())){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FluFrameless::_hitAppBar(){
|
||||
for (int i = 0; i <= _hitTestList.size() - 1; ++i) {
|
||||
auto item = _hitTestList.at(i);
|
||||
if (containsCursorToItem(item)) {
|
||||
foreach (auto item, _hitTestList) {
|
||||
if(_containsCursorToItem(item)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (containsCursorToItem(_appbar)) {
|
||||
if(_containsCursorToItem(_appbar)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FluFrameless::_hitMaximizeButton(){
|
||||
if (containsCursorToItem(_maximizeButton)) {
|
||||
if(_containsCursorToItem(_maximizeButton)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -373,12 +365,10 @@ void FluFrameless::_updateCursor(int edges) {
|
||||
case Qt::LeftEdge | Qt::BottomEdge:
|
||||
window()->setCursor(Qt::SizeBDiagCursor);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[[maybe_unused]] void FluFrameless::showFullScreen() {
|
||||
void FluFrameless::showFullScreen(){
|
||||
window()->showFullScreen();
|
||||
}
|
||||
|
||||
@ -391,7 +381,7 @@ void FluFrameless::showMaximized() {
|
||||
#endif
|
||||
}
|
||||
|
||||
[[maybe_unused]] void FluFrameless::showMinimized() {
|
||||
void FluFrameless::showMinimized(){
|
||||
window()->showMinimized();
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef FLUFRAMELESS_H
|
||||
#define FLUFRAMELESS_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QQuickItem>
|
||||
@ -14,63 +15,47 @@ using QT_ENTER_EVENT_TYPE = QEvent;
|
||||
#endif
|
||||
|
||||
|
||||
class FluFrameless : public QQuickItem, QAbstractNativeEventFilter {
|
||||
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(QQuickItem*,appbar)
|
||||
Q_PROPERTY_AUTO(bool,topmost)
|
||||
Q_PROPERTY_AUTO(QQuickItem*,maximizeButton)
|
||||
Q_PROPERTY_AUTO(QQuickItem*,minimizedButton)
|
||||
Q_PROPERTY_AUTO(QQuickItem*,closeButton)
|
||||
Q_PROPERTY_AUTO(bool,disabled)
|
||||
Q_PROPERTY_AUTO(bool,fixSize)
|
||||
QML_NAMED_ELEMENT(FluFrameless)
|
||||
public:
|
||||
explicit FluFrameless(QQuickItem* parent = nullptr);
|
||||
|
||||
~FluFrameless() override;
|
||||
|
||||
~FluFrameless();
|
||||
void componentComplete() override;
|
||||
|
||||
[[maybe_unused]] bool nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result) override;
|
||||
|
||||
Q_INVOKABLE [[maybe_unused]] void showFullScreen();
|
||||
|
||||
bool nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result) override;
|
||||
Q_INVOKABLE void showFullScreen();
|
||||
Q_INVOKABLE void showMaximized();
|
||||
|
||||
Q_INVOKABLE [[maybe_unused]] void showMinimized();
|
||||
|
||||
Q_INVOKABLE void showMinimized();
|
||||
Q_INVOKABLE void showNormal();
|
||||
|
||||
Q_INVOKABLE void setHitTestVisible(QQuickItem*);
|
||||
|
||||
Q_INVOKABLE [[maybe_unused]] void onDestruction();
|
||||
|
||||
Q_INVOKABLE void onDestruction();
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
|
||||
private:
|
||||
bool _isFullScreen();
|
||||
|
||||
bool _isMaximized();
|
||||
|
||||
void _updateCursor(int edges);
|
||||
|
||||
void _setWindowTopmost(bool topmost);
|
||||
|
||||
void _showSystemMenu(QPoint point);
|
||||
|
||||
bool _containsCursorToItem(QQuickItem* item);
|
||||
bool _hitAppBar();
|
||||
|
||||
bool _hitMaximizeButton();
|
||||
|
||||
void _setMaximizePressed(bool val);
|
||||
|
||||
void _setMaximizeHovered(bool val);
|
||||
|
||||
private:
|
||||
quint64 _current = 0;
|
||||
qint64 _current;
|
||||
int _edges = 0;
|
||||
int _margins = 8;
|
||||
quint64 _clickTimer = 0;
|
||||
qint64 _clickTimer = 0;
|
||||
QList<QPointer<QQuickItem>> _hitTestList;
|
||||
};
|
||||
|
||||
#endif // FLUFRAMELESS_H
|
||||
|
@ -3,9 +3,9 @@
|
||||
#include "qrcode/qrencode.h"
|
||||
|
||||
FluQrCodeItem::FluQrCodeItem(QQuickItem* parent):QQuickPaintedItem(parent){
|
||||
_color = QColor(0, 0, 0, 255);
|
||||
_bgColor = QColor(255, 255, 255, 255);
|
||||
_size = 100;
|
||||
color(QColor(0,0,0,255));
|
||||
bgColor(QColor(255,255,255,255));
|
||||
size(100);
|
||||
setWidth(_size);
|
||||
setHeight(_size);
|
||||
connect(this,&FluQrCodeItem::textChanged,this,[=]{update();});
|
||||
@ -18,6 +18,7 @@ FluQrCodeItem::FluQrCodeItem(QQuickItem *parent) : QQuickPaintedItem(parent) {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void FluQrCodeItem::paint(QPainter* painter){
|
||||
if(_text.isEmpty()){
|
||||
return;
|
||||
@ -27,8 +28,8 @@ void FluQrCodeItem::paint(QPainter *painter) {
|
||||
}
|
||||
painter->save();
|
||||
QRcode *qrcode = QRcode_encodeString(_text.toUtf8().constData(), 2, QR_ECLEVEL_Q, QR_MODE_8, 1);
|
||||
auto w = qint32(width());
|
||||
auto h = qint32(height());
|
||||
qint32 w = width();
|
||||
qint32 h = height();
|
||||
qint32 qrcodeW = qrcode->width > 0 ? qrcode->width : 1;
|
||||
double scaleX = (double)w / (double)qrcodeW;
|
||||
double scaleY = (double)h / (double)qrcodeW;
|
||||
@ -38,10 +39,13 @@ void FluQrCodeItem::paint(QPainter *painter) {
|
||||
p.setPen(Qt::NoPen);
|
||||
p.drawRect(0, 0, w, h);
|
||||
p.setBrush(_color);
|
||||
for (qint32 y = 0; y < qrcodeW; y++) {
|
||||
for (qint32 x = 0; x < qrcodeW; x++) {
|
||||
for (qint32 y = 0; y < qrcodeW; y++)
|
||||
{
|
||||
for (qint32 x = 0; x < qrcodeW; x++)
|
||||
{
|
||||
unsigned char b = qrcode->data[y*qrcodeW + x];
|
||||
if (b & 0x01) {
|
||||
if (b & 0x01)
|
||||
{
|
||||
QRectF r(x * scaleX,y * scaleY, scaleX, scaleY);
|
||||
p.drawRects(&r, 1);
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef FLUQRCODEITEM_H
|
||||
#define FLUQRCODEITEM_H
|
||||
|
||||
#include <QQuickItem>
|
||||
#include <QQuickPaintedItem>
|
||||
@ -8,9 +9,9 @@
|
||||
/**
|
||||
* @brief The FluQrCodeItem class
|
||||
*/
|
||||
class FluQrCodeItem : public QQuickPaintedItem {
|
||||
class FluQrCodeItem : public QQuickPaintedItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY_AUTO(QString,text)
|
||||
Q_PROPERTY_AUTO(QColor,color)
|
||||
Q_PROPERTY_AUTO(QColor,bgColor)
|
||||
@ -18,6 +19,7 @@ Q_PROPERTY_AUTO(int, size);
|
||||
QML_NAMED_ELEMENT(FluQrCodeItem)
|
||||
public:
|
||||
explicit FluQrCodeItem(QQuickItem *parent = nullptr);
|
||||
|
||||
void paint(QPainter* painter) override;
|
||||
};
|
||||
|
||||
#endif // FLUQRCODEITEM_H
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef FLURECTANGLE_H
|
||||
#define FLURECTANGLE_H
|
||||
|
||||
#include <QQuickItem>
|
||||
#include <QQuickPaintedItem>
|
||||
@ -8,13 +9,15 @@
|
||||
/**
|
||||
* @brief The FluRectangle class
|
||||
*/
|
||||
class FluRectangle : public QQuickPaintedItem {
|
||||
class FluRectangle : public QQuickPaintedItem
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(QColor,color)
|
||||
Q_PROPERTY_AUTO(QList<int>,radius)
|
||||
QML_NAMED_ELEMENT(FluRectangle)
|
||||
public:
|
||||
explicit FluRectangle(QQuickItem *parent = nullptr);
|
||||
|
||||
void paint(QPainter* painter) override;
|
||||
};
|
||||
|
||||
#endif // FLURECTANGLE_H
|
||||
|
@ -2,7 +2,9 @@
|
||||
|
||||
#include <QJSValueList>
|
||||
|
||||
FluTableSortProxyModel::FluTableSortProxyModel(QSortFilterProxyModel *parent) : QSortFilterProxyModel{parent} {
|
||||
FluTableSortProxyModel::FluTableSortProxyModel(QSortFilterProxyModel *parent)
|
||||
: QSortFilterProxyModel {parent}
|
||||
{
|
||||
_model = nullptr;
|
||||
connect(this,&FluTableSortProxyModel::modelChanged,this,[=]{
|
||||
setSourceModel(this->model());
|
||||
@ -39,7 +41,7 @@ bool FluTableSortProxyModel::lessThan(const QModelIndex &source_left, const QMod
|
||||
}
|
||||
}
|
||||
|
||||
[[maybe_unused]] void FluTableSortProxyModel::setComparator(const QJSValue &comparator) {
|
||||
void FluTableSortProxyModel::setComparator(QJSValue comparator){
|
||||
int column = 0;
|
||||
if(comparator.isUndefined()){
|
||||
column = -1;
|
||||
@ -52,22 +54,22 @@ bool FluTableSortProxyModel::lessThan(const QModelIndex &source_left, const QMod
|
||||
}
|
||||
}
|
||||
|
||||
[[maybe_unused]] void FluTableSortProxyModel::setFilter(const QJSValue &filter) {
|
||||
void FluTableSortProxyModel::setFilter(QJSValue filter){
|
||||
this->_filter = filter;
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
[[maybe_unused]] QVariant FluTableSortProxyModel::getRow(int rowIndex) {
|
||||
QVariant FluTableSortProxyModel::getRow(int rowIndex){
|
||||
QVariant result;
|
||||
QMetaObject::invokeMethod(_model, "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) {
|
||||
void FluTableSortProxyModel::setRow(int rowIndex,QVariant val){
|
||||
QMetaObject::invokeMethod(_model, "setRow",Q_ARG(int, mapToSource(index(rowIndex,0)).row()),Q_ARG(QVariant,val));
|
||||
}
|
||||
|
||||
[[maybe_unused]] void FluTableSortProxyModel::removeRow(int rowIndex, int rows) {
|
||||
void FluTableSortProxyModel::removeRow(int rowIndex,int rows){
|
||||
QMetaObject::invokeMethod(_model, "removeRow",Q_ARG(int, mapToSource(index(rowIndex,0)).row()),Q_ARG(int,rows));
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef FLUTABLESORTPROXYMODEL_H
|
||||
#define FLUTABLESORTPROXYMODEL_H
|
||||
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QAbstractTableModel>
|
||||
@ -6,30 +7,24 @@
|
||||
#include <QJSValue>
|
||||
#include "stdafx.h"
|
||||
|
||||
class FluTableSortProxyModel : public QSortFilterProxyModel {
|
||||
class FluTableSortProxyModel : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO_P(QAbstractTableModel*, model)
|
||||
Q_PROPERTY_AUTO(QAbstractTableModel*,model)
|
||||
QML_NAMED_ELEMENT(FluTableSortProxyModel)
|
||||
public:
|
||||
explicit FluTableSortProxyModel(QSortFilterProxyModel *parent = nullptr);
|
||||
|
||||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
||||
|
||||
bool filterAcceptsColumn(int sourceColumn, const QModelIndex &sourceParent) const override;
|
||||
|
||||
bool lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight) const override;
|
||||
|
||||
Q_INVOKABLE [[maybe_unused]] QVariant getRow(int rowIndex);
|
||||
|
||||
Q_INVOKABLE [[maybe_unused]] void setRow(int rowIndex, const QVariant &val);
|
||||
|
||||
Q_INVOKABLE [[maybe_unused]] void removeRow(int rowIndex, int rows);
|
||||
|
||||
Q_INVOKABLE [[maybe_unused]] [[maybe_unused]] void setComparator(const QJSValue &comparator);
|
||||
|
||||
Q_INVOKABLE [[maybe_unused]] void setFilter(const QJSValue &filter);
|
||||
|
||||
Q_INVOKABLE QVariant getRow(int rowIndex);
|
||||
Q_INVOKABLE void setRow(int rowIndex,QVariant val);
|
||||
Q_INVOKABLE void removeRow(int rowIndex,int rows);
|
||||
Q_INVOKABLE void setComparator(QJSValue comparator);
|
||||
Q_INVOKABLE void setFilter(QJSValue filter);
|
||||
private:
|
||||
QJSValue _filter;
|
||||
QJSValue _comparator;
|
||||
};
|
||||
|
||||
#endif // FLUTABLESORTPROXYMODEL_H
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef FLUTEXTSTYLE_H
|
||||
#define FLUTEXTSTYLE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QtQml/qqml.h>
|
||||
@ -9,7 +10,8 @@
|
||||
/**
|
||||
* @brief The FluTextStyle class
|
||||
*/
|
||||
class FluTextStyle : public QObject {
|
||||
class FluTextStyle : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Q_PROPERTY_AUTO(QString,family)
|
||||
@ -22,12 +24,11 @@ Q_PROPERTY_AUTO(QFont, TitleLarge);
|
||||
Q_PROPERTY_AUTO(QFont,Display);
|
||||
QML_NAMED_ELEMENT(FluTextStyle)
|
||||
QML_SINGLETON
|
||||
|
||||
private:
|
||||
explicit FluTextStyle(QObject *parent = nullptr);
|
||||
|
||||
public:
|
||||
SINGLETON(FluTextStyle)
|
||||
|
||||
static FluTextStyle *create(QQmlEngine *, QJSEngine *) { return getInstance(); }
|
||||
static FluTextStyle *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
|
||||
};
|
||||
|
||||
#endif // FLUTEXTSTYLE_H
|
||||
|
@ -5,25 +5,18 @@
|
||||
#include "Def.h"
|
||||
#include "FluColors.h"
|
||||
|
||||
bool systemDark() {
|
||||
QPalette palette = QGuiApplication::palette();
|
||||
QColor color = palette.color(QPalette::Window).rgb();
|
||||
return color.red() * 0.2126 + color.green() * 0.7152 + color.blue() * 0.0722 <= 255.0f / 2;
|
||||
}
|
||||
|
||||
FluTheme::FluTheme(QObject *parent):QObject{parent}{
|
||||
_accentColor = FluColors::getInstance()->Blue();
|
||||
_darkMode = FluThemeType::DarkMode::Light;
|
||||
_nativeText = false;
|
||||
_animationEnabled = true;
|
||||
_systemDark = systemDark();
|
||||
QGuiApplication::instance()->installEventFilter(this);
|
||||
connect(this,&FluTheme::darkModeChanged,this,[=]{
|
||||
Q_EMIT darkChanged();
|
||||
});
|
||||
connect(this,&FluTheme::darkChanged,this,[=]{refreshColors();});
|
||||
connect(this,&FluTheme::accentColorChanged,this,[=]{refreshColors();});
|
||||
refreshColors();
|
||||
accentColor(FluColors::getInstance()->Blue());
|
||||
darkMode(FluThemeType::DarkMode::Light);
|
||||
nativeText(false);
|
||||
animationEnabled(true);
|
||||
_systemDark = systemDark();
|
||||
qApp->installEventFilter(this);
|
||||
}
|
||||
|
||||
void FluTheme::refreshColors(){
|
||||
@ -37,13 +30,15 @@ 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));
|
||||
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)));
|
||||
itemHoverColor(isDark ? QColor(255,255,255,255*0.06) : QColor(0,0,0,255*0.03));
|
||||
itemPressColor(isDark ? QColor(255,255,255,255*0.09) : QColor(0,0,0,255*0.06));
|
||||
itemCheckColor(isDark ? QColor(255,255,255,255*0.12) : QColor(0,0,0,255*0.09));
|
||||
}
|
||||
|
||||
bool FluTheme::eventFilter(QObject *, QEvent *event) {
|
||||
if (event->type() == QEvent::ApplicationPaletteChange || event->type() == QEvent::ThemeChange) {
|
||||
bool FluTheme::eventFilter(QObject *obj, QEvent *event){
|
||||
Q_UNUSED(obj);
|
||||
if (event->type() == QEvent::ApplicationPaletteChange || event->type() == QEvent::ThemeChange)
|
||||
{
|
||||
_systemDark = systemDark();
|
||||
Q_EMIT darkChanged();
|
||||
event->accept();
|
||||
@ -52,10 +47,10 @@ bool FluTheme::eventFilter(QObject *, QEvent *event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
[[maybe_unused]] QJsonArray FluTheme::awesomeList(const QString &keyword) {
|
||||
QJsonArray FluTheme::awesomeList(const QString& keyword){
|
||||
QJsonArray arr;
|
||||
QMetaEnum enumType = Fluent_Awesome::staticMetaObject.enumerator(Fluent_Awesome::staticMetaObject.indexOfEnumerator("Fluent_AwesomeType"));
|
||||
for (int i = 0; i <= enumType.keyCount() - 1; ++i) {
|
||||
for(int i=0; i < enumType.keyCount(); ++i){
|
||||
QString name = enumType.key(i);
|
||||
int icon = enumType.value(i);
|
||||
if(keyword.isEmpty() || name.contains(keyword)){
|
||||
@ -68,9 +63,17 @@ bool FluTheme::eventFilter(QObject *, QEvent *event) {
|
||||
return arr;
|
||||
}
|
||||
|
||||
bool FluTheme::dark() const {
|
||||
bool FluTheme::systemDark(){
|
||||
QPalette palette = qApp->palette();
|
||||
QColor color = palette.color(QPalette::Window).rgb();
|
||||
return !(color.red() * 0.2126 + color.green() * 0.7152 + color.blue() * 0.0722 > 255 / 2);
|
||||
}
|
||||
|
||||
bool FluTheme::dark(){
|
||||
if(_darkMode == FluThemeType::DarkMode::Dark){
|
||||
return true;
|
||||
}else if(_darkMode == FluThemeType::DarkMode::Light){
|
||||
return false;
|
||||
}else if(_darkMode == FluThemeType::DarkMode::System){
|
||||
return _systemDark;
|
||||
}else{
|
||||
|
@ -13,10 +13,11 @@
|
||||
/**
|
||||
* @brief The FluTheme class
|
||||
*/
|
||||
class FluTheme : public QObject {
|
||||
class FluTheme : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool dark READ dark NOTIFY darkChanged)
|
||||
Q_PROPERTY_AUTO_P(FluAccentColor*, accentColor);
|
||||
Q_PROPERTY_AUTO(FluAccentColor*,accentColor);
|
||||
Q_PROPERTY_AUTO(QColor,primaryColor);
|
||||
Q_PROPERTY_AUTO(QColor,backgroundColor);
|
||||
Q_PROPERTY_AUTO(QColor,dividerColor);
|
||||
@ -34,25 +35,17 @@ Q_PROPERTY_AUTO(bool, nativeText);
|
||||
Q_PROPERTY_AUTO(bool,animationEnabled);
|
||||
QML_NAMED_ELEMENT(FluTheme)
|
||||
QML_SINGLETON
|
||||
|
||||
private:
|
||||
explicit FluTheme(QObject *parent = nullptr);
|
||||
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
bool systemDark();
|
||||
void refreshColors();
|
||||
|
||||
public:
|
||||
SINGLETON(FluTheme)
|
||||
|
||||
Q_INVOKABLE [[maybe_unused]] static QJsonArray awesomeList(const QString &keyword = "");
|
||||
|
||||
Q_INVOKABLE QJsonArray awesomeList(const QString& keyword = "");
|
||||
Q_SIGNAL void darkChanged();
|
||||
|
||||
static FluTheme *create(QQmlEngine *, QJSEngine *) { return getInstance(); }
|
||||
|
||||
bool dark() const;
|
||||
|
||||
static FluTheme *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
|
||||
bool dark();
|
||||
private:
|
||||
bool _systemDark;
|
||||
};
|
||||
|
@ -75,20 +75,21 @@ int FluTools::qtMinor() {
|
||||
}
|
||||
|
||||
void FluTools::setQuitOnLastWindowClosed(bool val){
|
||||
QGuiApplication::setQuitOnLastWindowClosed(val);
|
||||
qApp->setQuitOnLastWindowClosed(val);
|
||||
}
|
||||
|
||||
void FluTools::setOverrideCursor(Qt::CursorShape shape){
|
||||
QGuiApplication::setOverrideCursor(QCursor(shape));
|
||||
qApp->setOverrideCursor(QCursor(shape));
|
||||
}
|
||||
|
||||
void FluTools::restoreOverrideCursor(){
|
||||
QGuiApplication::restoreOverrideCursor();
|
||||
qApp->restoreOverrideCursor();
|
||||
}
|
||||
|
||||
void FluTools::deleteLater(QObject *p){
|
||||
if(p){
|
||||
p->deleteLater();
|
||||
p = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,11 +108,11 @@ QString FluTools::html2PlantText(const QString &html) {
|
||||
}
|
||||
|
||||
QRect FluTools::getVirtualGeometry(){
|
||||
return QGuiApplication::primaryScreen()->virtualGeometry();
|
||||
return qApp->primaryScreen()->virtualGeometry();
|
||||
}
|
||||
|
||||
QString FluTools::getApplicationDirPath(){
|
||||
return QGuiApplication::applicationDirPath();
|
||||
return qApp->applicationDirPath();
|
||||
}
|
||||
|
||||
QUrl FluTools::getUrlByFilePath(const QString& path){
|
||||
@ -123,33 +124,33 @@ QColor FluTools::withOpacity(const QColor &color, qreal opacity) {
|
||||
return QColor::fromRgba((alpha << 24) | (color.rgba() & 0xffffff));
|
||||
}
|
||||
|
||||
QString FluTools::md5(const QString &text) {
|
||||
QString FluTools::md5(QString text){
|
||||
return QCryptographicHash::hash(text.toUtf8(), QCryptographicHash::Md5).toHex();
|
||||
}
|
||||
|
||||
QString FluTools::toBase64(const QString &text) {
|
||||
QString FluTools::toBase64(QString text){
|
||||
return text.toUtf8().toBase64();
|
||||
}
|
||||
|
||||
QString FluTools::fromBase64(const QString &text) {
|
||||
QString FluTools::fromBase64(QString text){
|
||||
return QByteArray::fromBase64(text.toUtf8());
|
||||
}
|
||||
|
||||
bool FluTools::removeDir(const QString &dirPath) {
|
||||
bool FluTools::removeDir(QString dirPath){
|
||||
QDir qDir(dirPath);
|
||||
return qDir.removeRecursively();
|
||||
}
|
||||
|
||||
bool FluTools::removeFile(const QString &filePath) {
|
||||
bool FluTools::removeFile(QString filePath){
|
||||
QFile file(filePath);
|
||||
return file.remove();
|
||||
}
|
||||
|
||||
QString FluTools::sha256(const QString &text) {
|
||||
QString FluTools::sha256(QString text){
|
||||
return QCryptographicHash::hash(text.toUtf8(), QCryptographicHash::Sha256).toHex();
|
||||
}
|
||||
|
||||
void FluTools::showFileInFolder(const QString &path) {
|
||||
void FluTools::showFileInFolder(QString path){
|
||||
#if defined(Q_OS_WIN)
|
||||
QProcess::startDetached("explorer.exe", {"/select,", QDir::toNativeSeparators(path)});
|
||||
#endif
|
||||
@ -183,11 +184,11 @@ QIcon FluTools::windowIcon() {
|
||||
|
||||
int FluTools::cursorScreenIndex(){
|
||||
int screenIndex = 0;
|
||||
int screenCount = QGuiApplication::screens().count();
|
||||
int screenCount = qApp->screens().count();
|
||||
if (screenCount > 1) {
|
||||
QPoint pos = QCursor::pos();
|
||||
for (int i = 0; i <= screenCount - 1; ++i) {
|
||||
if (QGuiApplication::screens().at(i)->geometry().contains(pos)) {
|
||||
for (int i = 0; i < screenCount; ++i) {
|
||||
if (qApp->screens().at(i)->geometry().contains(pos)) {
|
||||
screenIndex = i;
|
||||
break;
|
||||
}
|
||||
@ -198,7 +199,7 @@ 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("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;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef FLUTOOLS_H
|
||||
#define FLUTOOLS_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QFile>
|
||||
@ -10,86 +11,51 @@
|
||||
/**
|
||||
* @brief The FluTools class
|
||||
*/
|
||||
class FluTools : public QObject {
|
||||
class FluTools : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
QML_NAMED_ELEMENT(FluTools)
|
||||
QML_SINGLETON
|
||||
|
||||
private:
|
||||
explicit FluTools(QObject *parent = nullptr);
|
||||
|
||||
public:
|
||||
SINGLETON(FluTools)
|
||||
|
||||
static FluTools *create(QQmlEngine *, QJSEngine *) { return getInstance(); }
|
||||
|
||||
static FluTools *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
|
||||
Q_INVOKABLE int qtMajor();
|
||||
|
||||
Q_INVOKABLE int qtMinor();
|
||||
|
||||
Q_INVOKABLE bool isMacos();
|
||||
|
||||
Q_INVOKABLE bool isLinux();
|
||||
|
||||
Q_INVOKABLE bool isWin();
|
||||
|
||||
Q_INVOKABLE void clipText(const QString& text);
|
||||
|
||||
Q_INVOKABLE QString uuid();
|
||||
|
||||
Q_INVOKABLE QString readFile(const QString& fileName);
|
||||
|
||||
Q_INVOKABLE void setQuitOnLastWindowClosed(bool val);
|
||||
|
||||
Q_INVOKABLE void setOverrideCursor(Qt::CursorShape shape);
|
||||
|
||||
Q_INVOKABLE void restoreOverrideCursor();
|
||||
|
||||
Q_INVOKABLE QString html2PlantText(const QString& html);
|
||||
|
||||
Q_INVOKABLE QString toLocalPath(const QUrl& url);
|
||||
|
||||
Q_INVOKABLE void deleteLater(QObject *p);
|
||||
|
||||
Q_INVOKABLE QString getFileNameByUrl(const QUrl& url);
|
||||
|
||||
Q_INVOKABLE QRect getVirtualGeometry();
|
||||
|
||||
Q_INVOKABLE QString getApplicationDirPath();
|
||||
|
||||
Q_INVOKABLE QUrl getUrlByFilePath(const QString& path);
|
||||
|
||||
Q_INVOKABLE QColor withOpacity(const QColor&,qreal alpha);
|
||||
|
||||
Q_INVOKABLE QString md5(const QString &text);
|
||||
|
||||
Q_INVOKABLE QString sha256(const QString &text);
|
||||
|
||||
Q_INVOKABLE QString toBase64(const QString &text);
|
||||
|
||||
Q_INVOKABLE QString fromBase64(const QString &text);
|
||||
|
||||
Q_INVOKABLE bool removeDir(const QString &dirPath);
|
||||
|
||||
Q_INVOKABLE bool removeFile(const QString &filePath);
|
||||
|
||||
Q_INVOKABLE void showFileInFolder(const QString &path);
|
||||
|
||||
Q_INVOKABLE QString md5(QString text);
|
||||
Q_INVOKABLE QString sha256(QString text);
|
||||
Q_INVOKABLE QString toBase64(QString text);
|
||||
Q_INVOKABLE QString fromBase64(QString text);
|
||||
Q_INVOKABLE bool removeDir(QString dirPath);
|
||||
Q_INVOKABLE bool removeFile(QString filePath);
|
||||
Q_INVOKABLE void showFileInFolder(QString path);
|
||||
Q_INVOKABLE bool isSoftware();
|
||||
|
||||
Q_INVOKABLE qint64 currentTimestamp();
|
||||
|
||||
Q_INVOKABLE QPoint cursorPos();
|
||||
|
||||
Q_INVOKABLE QIcon windowIcon();
|
||||
|
||||
Q_INVOKABLE int cursorScreenIndex();
|
||||
|
||||
Q_INVOKABLE int windowBuildNumber();
|
||||
|
||||
Q_INVOKABLE bool isWindows11OrGreater();
|
||||
|
||||
Q_INVOKABLE bool isWindows10OrGreater();
|
||||
|
||||
Q_INVOKABLE QRect desktopAvailableGeometry(QQuickWindow* window);
|
||||
};
|
||||
|
||||
#endif // FLUTOOLS_H
|
||||
|
@ -1,32 +1,31 @@
|
||||
#include "FluTreeModel.h"
|
||||
|
||||
#include <QMetaEnum>
|
||||
#include <utility>
|
||||
|
||||
FluTreeNode::FluTreeNode(QObject *parent): QObject{parent}{
|
||||
}
|
||||
|
||||
FluTreeModel::FluTreeModel(QObject *parent): QAbstractItemModel{parent}{
|
||||
_dataSourceSize = 0;
|
||||
dataSourceSize(0);
|
||||
}
|
||||
|
||||
QModelIndex FluTreeModel::parent(const QModelIndex &child) const{
|
||||
return {};
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
QModelIndex FluTreeModel::index(int row, int column,const QModelIndex &parent) const{
|
||||
if (!hasIndex(row, column, parent) || parent.isValid())
|
||||
return {};
|
||||
return QModelIndex();
|
||||
return createIndex(row, column, _rows.at(row));
|
||||
}
|
||||
|
||||
int FluTreeModel::rowCount(const QModelIndex &parent) const {
|
||||
return _rows.count();
|
||||
}
|
||||
};
|
||||
|
||||
int FluTreeModel::columnCount(const QModelIndex &parent) const {
|
||||
return this->_columnSource.size();
|
||||
}
|
||||
};
|
||||
|
||||
QVariant FluTreeModel::data(const QModelIndex &index, int role) const {
|
||||
switch (role) {
|
||||
@ -37,19 +36,19 @@ QVariant FluTreeModel::data(const QModelIndex &index, int role) const {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
return QVariant();
|
||||
};
|
||||
|
||||
QHash<int, QByteArray> FluTreeModel::roleNames() const {
|
||||
return {
|
||||
{TreeModelRoles::RowModel, "rowModel"},
|
||||
{TreeModelRoles::ColumnModel, "columnModel"}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
void FluTreeModel::setData(QList<FluTreeNode*> data){
|
||||
beginResetModel();
|
||||
_rows = std::move(data);
|
||||
_rows = data;
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
@ -65,9 +64,9 @@ void FluTreeModel::removeRows(int row, int count) {
|
||||
endRemoveRows();
|
||||
}
|
||||
|
||||
void FluTreeModel::insertRows(int row, const QList<FluTreeNode *> &data) {
|
||||
if (row < 0 || row > _rows.size() || data.empty())
|
||||
return;
|
||||
void FluTreeModel::insertRows(int row,QList<FluTreeNode*> data){
|
||||
if (row < 0 || row > _rows.size() || data.size() == 0)
|
||||
return;;
|
||||
beginInsertRows(QModelIndex(), row, row + data.size() - 1);
|
||||
QList<FluTreeNode*> firstPart = _rows.mid(0, row);
|
||||
QList<FluTreeNode*> secondPart = _rows.mid(row);
|
||||
@ -83,7 +82,7 @@ QObject *FluTreeModel::getRow(int row) {
|
||||
}
|
||||
|
||||
void FluTreeModel::setRow(int row,QVariantMap data){
|
||||
_rows.at(row)->_data = std::move(data);
|
||||
_rows.at(row)->_data = data;
|
||||
Q_EMIT dataChanged(index(row,0),index(row,columnCount()-1));
|
||||
}
|
||||
|
||||
@ -135,7 +134,7 @@ void FluTreeModel::setDataSource(QList<QMap<QString, QVariant>> data) {
|
||||
while (data.count() > 0) {
|
||||
auto item = data.at(data.count()-1);
|
||||
data.pop_back();
|
||||
auto *node = new FluTreeNode(this);
|
||||
FluTreeNode* node = new FluTreeNode(this);
|
||||
node->_depth = item.value("__depth").toInt();
|
||||
node->_parent = item.value("__parent").value<FluTreeNode*>();
|
||||
node->_data = item;
|
||||
@ -151,9 +150,9 @@ void FluTreeModel::setDataSource(QList<QMap<QString, QVariant>> data) {
|
||||
QList<QVariant> children = item.value("children").toList();
|
||||
if(!children.isEmpty()){
|
||||
std::reverse(children.begin(), children.end());
|
||||
for (int i = 0; i <= children.count() - 1; ++i) {
|
||||
for (int i = 0; i < children.count(); ++i) {
|
||||
auto child = children.at(i).toMap();
|
||||
child.insert("__depth", item.value("__depth").toInt(nullptr) + 1);
|
||||
child.insert("__depth",item.value("__depth").toInt(0)+1);
|
||||
child.insert("__parent",QVariant::fromValue(node));
|
||||
data.append(child);
|
||||
}
|
||||
@ -221,7 +220,7 @@ bool FluTreeModel::hitHasChildrenExpanded(int row) {
|
||||
|
||||
void FluTreeModel::refreshNode(int row){
|
||||
Q_EMIT dataChanged(index(row,0),index(row,0));
|
||||
}
|
||||
};
|
||||
|
||||
FluTreeNode* FluTreeModel::getNode(int row){
|
||||
return _rows.at(row);
|
||||
@ -250,7 +249,6 @@ void FluTreeModel::allExpand() {
|
||||
_rows = data;
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void FluTreeModel::allCollapse(){
|
||||
beginResetModel();
|
||||
QList<FluTreeNode*> stack = _root->_children;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef FLUTREEMODEL_H
|
||||
#define FLUTREEMODEL_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QAbstractTableModel>
|
||||
@ -18,18 +19,13 @@ Q_OBJECT
|
||||
Q_PROPERTY(bool checked READ checked CONSTANT)
|
||||
public:
|
||||
explicit FluTreeNode(QObject *parent = nullptr);
|
||||
|
||||
[[nodiscard]] Q_INVOKABLE int depth() const { return _depth; };
|
||||
|
||||
[[nodiscard]] Q_INVOKABLE bool isExpanded() const { return _isExpanded; };
|
||||
|
||||
[[nodiscard]] Q_INVOKABLE QVariantMap data() const { return _data; };
|
||||
|
||||
[[nodiscard]] Q_INVOKABLE bool hasChildren() const { return !_children.isEmpty(); };
|
||||
|
||||
Q_INVOKABLE int depth(){return _depth;};
|
||||
Q_INVOKABLE bool isExpanded(){return _isExpanded;};
|
||||
Q_INVOKABLE QVariantMap data(){return _data;};
|
||||
Q_INVOKABLE bool hasChildren(){ return !_children.isEmpty();};
|
||||
Q_INVOKABLE bool hasNextNodeByIndex(int index){
|
||||
FluTreeNode* p = this;
|
||||
for (int i = 0; i <= _depth - index - 1; i++) {
|
||||
for(int i=0;i<(_depth - index -1);i++){
|
||||
p = p->_parent;
|
||||
}
|
||||
if(p->_parent->_children.indexOf(p) == p->_parent->_children.count()-1){
|
||||
@ -37,20 +33,18 @@ public:
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
[[nodiscard]] Q_INVOKABLE bool checked() const {
|
||||
Q_INVOKABLE bool checked(){
|
||||
if(!hasChildren()){
|
||||
return _checked;
|
||||
}
|
||||
for (int i = 0; i <= _children.size() - 1; ++i) {
|
||||
auto item = _children.at(i);
|
||||
foreach (auto item, _children) {
|
||||
if(!item->checked()){
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
Q_INVOKABLE bool hideLineFooter(){
|
||||
if(_parent){
|
||||
auto childIndex = _parent->_children.indexOf(this);
|
||||
@ -64,8 +58,7 @@ public:
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
[[nodiscard]] bool isShown() const {
|
||||
bool isShown(){
|
||||
auto p = _parent;
|
||||
while (p) {
|
||||
if(!p->_isExpanded){
|
||||
@ -75,7 +68,6 @@ public:
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public:
|
||||
QString _title="";
|
||||
int _depth=0;
|
||||
@ -86,7 +78,8 @@ public:
|
||||
FluTreeNode* _parent = nullptr;
|
||||
};
|
||||
|
||||
class FluTreeModel : public QAbstractItemModel {
|
||||
class FluTreeModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(int,dataSourceSize)
|
||||
Q_PROPERTY_AUTO(QList<FluTreeNode*>,selectionModel)
|
||||
@ -98,51 +91,32 @@ public:
|
||||
RowModel = 0x0101,
|
||||
ColumnModel = 0x0102
|
||||
};
|
||||
|
||||
explicit FluTreeModel(QObject *parent = nullptr);
|
||||
|
||||
[[nodiscard]] int rowCount(const QModelIndex &parent = {}) const override;
|
||||
|
||||
[[nodiscard]] int columnCount(const QModelIndex &parent = {}) const override;
|
||||
|
||||
[[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
[[nodiscard]] QModelIndex parent(const QModelIndex &child) const override;
|
||||
|
||||
[[nodiscard]] QModelIndex index(int row, int column, const QModelIndex &parent = {}) const override;
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
QModelIndex parent(const QModelIndex &child) const override;
|
||||
QModelIndex index(int row, int column,const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
Q_INVOKABLE void removeRows(int row,int count);
|
||||
|
||||
Q_INVOKABLE void insertRows(int row, const QList<FluTreeNode *> &data);
|
||||
|
||||
Q_INVOKABLE void insertRows(int row,QList<FluTreeNode*> data);
|
||||
Q_INVOKABLE QObject* getRow(int row);
|
||||
|
||||
Q_INVOKABLE void setRow(int row,QVariantMap data);
|
||||
|
||||
Q_INVOKABLE void setData(QList<FluTreeNode*> data);
|
||||
|
||||
Q_INVOKABLE void setDataSource(QList<QMap<QString,QVariant>> data);
|
||||
|
||||
Q_INVOKABLE void collapse(int row);
|
||||
|
||||
Q_INVOKABLE void expand(int row);
|
||||
|
||||
Q_INVOKABLE FluTreeNode* getNode(int row);
|
||||
|
||||
Q_INVOKABLE void refreshNode(int row);
|
||||
|
||||
Q_INVOKABLE void checkRow(int row,bool checked);
|
||||
|
||||
Q_INVOKABLE bool hitHasChildrenExpanded(int row);
|
||||
|
||||
Q_INVOKABLE void allExpand();
|
||||
|
||||
Q_INVOKABLE void allCollapse();
|
||||
|
||||
private:
|
||||
QList<FluTreeNode*> _rows;
|
||||
QList<FluTreeNode*> _dataSource;
|
||||
FluTreeNode* _root = nullptr;
|
||||
};
|
||||
|
||||
#endif // FLUTREEMODEL_H
|
||||
|
@ -3,12 +3,12 @@
|
||||
#include "FluTextStyle.h"
|
||||
|
||||
FluWatermark::FluWatermark(QQuickItem* parent) : QQuickPaintedItem(parent){
|
||||
_gap = QPoint(100, 100);
|
||||
_offset = QPoint(_gap.x() / 2, _gap.y() / 2);
|
||||
_rotate = 22;
|
||||
_textColor = QColor(222, 222, 222, 222);
|
||||
_textSize = 16;
|
||||
gap(QPoint(100,100));
|
||||
offset(QPoint(_gap.x()/2,_gap.y()/2));
|
||||
rotate(22);
|
||||
setZ(9999);
|
||||
textColor(QColor(222,222,222,222));
|
||||
textSize(16);
|
||||
connect(this,&FluWatermark::textColorChanged,this,[=]{update();});
|
||||
connect(this,&FluWatermark::gapChanged,this,[=]{update();});
|
||||
connect(this,&FluWatermark::offsetChanged,this,[=]{update();});
|
||||
@ -26,12 +26,14 @@ void FluWatermark::paint(QPainter *painter) {
|
||||
QFontMetricsF fontMetrics(font);
|
||||
qreal fontWidth = fontMetrics.horizontalAdvance(_text);
|
||||
qreal fontHeight = fontMetrics.height();
|
||||
int stepX = qRound(fontWidth + _gap.x());
|
||||
int stepY = qRound(fontHeight + _gap.y());
|
||||
int rowCount = qRound(width() / stepX + 1);
|
||||
int colCount = qRound(height() / stepY + 1);
|
||||
for (int r = 0; r < rowCount; r++) {
|
||||
for (int c = 0; c < colCount; c++) {
|
||||
int stepX = fontWidth + _gap.x();
|
||||
int stepY = fontHeight + _gap.y();
|
||||
int rowCount = width() / stepX+1;
|
||||
int colCount = height() / stepY+1;
|
||||
for (int r = 0; r < rowCount; r++)
|
||||
{
|
||||
for (int c = 0; c < colCount; c++)
|
||||
{
|
||||
qreal centerX = stepX * r + _offset.x() + fontWidth / 2.0;
|
||||
qreal centerY = stepY * c + _offset.y() + fontHeight / 2.0;
|
||||
painter->save();
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef FLUWATERMARK_H
|
||||
#define FLUWATERMARK_H
|
||||
|
||||
#include <QQuickItem>
|
||||
#include <QQuickPaintedItem>
|
||||
@ -8,7 +9,8 @@
|
||||
/**
|
||||
* @brief The FluWatermark class
|
||||
*/
|
||||
class FluWatermark : public QQuickPaintedItem {
|
||||
class FluWatermark : public QQuickPaintedItem
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(QString,text)
|
||||
Q_PROPERTY_AUTO(QPoint,gap)
|
||||
@ -19,6 +21,7 @@ Q_PROPERTY_AUTO(int, textSize);
|
||||
QML_NAMED_ELEMENT(FluWatermark)
|
||||
public:
|
||||
explicit FluWatermark(QQuickItem *parent = nullptr);
|
||||
|
||||
void paint(QPainter* painter) override;
|
||||
};
|
||||
|
||||
#endif // FLUWATERMARK_H
|
||||
|
@ -16,15 +16,14 @@
|
||||
#include "FluFrameless.h"
|
||||
|
||||
void FluentUI::registerTypes(QQmlEngine *engine){
|
||||
initializeEngine(engine, _uri);
|
||||
registerTypes(_uri);
|
||||
initializeEngine(engine,uri);
|
||||
registerTypes(uri);
|
||||
}
|
||||
|
||||
void FluentUI::registerTypes(const char *uri) const {
|
||||
void FluentUI::registerTypes(const char *uri){
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 2, 0))
|
||||
Q_INIT_RESOURCE(fluentui);
|
||||
int major = _major;
|
||||
int minor = _minor;
|
||||
|
||||
//@uri FluentUI
|
||||
qmlRegisterType<FluQrCodeItem>(uri,major,minor,"FluQrCodeItem");
|
||||
qmlRegisterType<FluCaptcha>(uri,major,minor,"FluCaptcha");
|
||||
@ -149,7 +148,7 @@ void FluentUI::registerTypes(const char *uri) const {
|
||||
#endif
|
||||
}
|
||||
|
||||
void FluentUI::initializeEngine(QQmlEngine *engine, [[maybe_unused]] const char *uri) {
|
||||
void FluentUI::initializeEngine(QQmlEngine *engine, const char *uri){
|
||||
engine->rootContext()->setContextProperty("FluApp",FluApp::getInstance());
|
||||
engine->rootContext()->setContextProperty("FluColors",FluColors::getInstance());
|
||||
engine->rootContext()->setContextProperty("FluTheme",FluTheme::getInstance());
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef FLUENTUI_H
|
||||
#define FLUENTUI_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QQmlEngine>
|
||||
@ -7,20 +8,18 @@
|
||||
/**
|
||||
* @brief The FluentUI class
|
||||
*/
|
||||
class FluentUI : public QObject {
|
||||
class FluentUI : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SINGLETON(FluentUI)
|
||||
|
||||
Q_DECL_EXPORT void registerTypes(QQmlEngine *engine);
|
||||
|
||||
void registerTypes(const char *uri) const;
|
||||
|
||||
void initializeEngine(QQmlEngine *engine, [[maybe_unused]] const char *uri);
|
||||
|
||||
void registerTypes(const char *uri);
|
||||
void initializeEngine(QQmlEngine *engine, const char *uri);
|
||||
private:
|
||||
const int _major = 1;
|
||||
const int _minor = 0;
|
||||
const char *_uri = "FluentUI";
|
||||
const int major = 1;
|
||||
const int minor = 0;
|
||||
const char *uri = "FluentUI";
|
||||
};
|
||||
|
||||
#endif // FLUENTUI_H
|
||||
|
@ -2,12 +2,18 @@
|
||||
|
||||
#include "FluentUI.h"
|
||||
|
||||
FluentUIPlugin::FluentUIPlugin() = default;
|
||||
FluentUIPlugin::FluentUIPlugin()
|
||||
{
|
||||
|
||||
void FluentUIPlugin::registerTypes(const char *uri) {
|
||||
}
|
||||
|
||||
void FluentUIPlugin::registerTypes(const char *uri)
|
||||
{
|
||||
FluentUI::getInstance()->registerTypes(uri);
|
||||
}
|
||||
|
||||
void FluentUIPlugin::initializeEngine(QQmlEngine *engine, const char *uri) {
|
||||
void FluentUIPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
|
||||
{
|
||||
Q_UNUSED(uri)
|
||||
FluentUI::getInstance()->initializeEngine(engine,uri);
|
||||
}
|
||||
|
@ -1,18 +1,19 @@
|
||||
#pragma once
|
||||
#ifndef FLUENTUIPLUGIN_H
|
||||
#define FLUENTUIPLUGIN_H
|
||||
|
||||
#include <QQmlExtensionPlugin>
|
||||
|
||||
/**
|
||||
* @brief The FluentUIPlugin class
|
||||
*/
|
||||
class FluentUIPlugin : public QQmlExtensionPlugin {
|
||||
class FluentUIPlugin : public QQmlExtensionPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
|
||||
public:
|
||||
FluentUIPlugin();
|
||||
|
||||
void registerTypes(const char *uri) Q_DECL_OVERRIDE;
|
||||
|
||||
void initializeEngine(QQmlEngine *engine, const char *uri) Q_DECL_OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // FLUENTUIPLUGIN_H
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef SINGLETON_H
|
||||
#define SINGLETON_H
|
||||
|
||||
/**
|
||||
* @brief The Singleton class
|
||||
@ -22,3 +23,5 @@ private: \
|
||||
static Class* getInstance() { \
|
||||
return Singleton<Class>::getInstance(); \
|
||||
}
|
||||
|
||||
#endif // SINGLETON_H
|
||||
|
25
src/stdafx.h
25
src/stdafx.h
@ -1,26 +1,11 @@
|
||||
#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: \
|
||||
TYPE _##M; \
|
||||
#ifndef STDAFX_H
|
||||
#define STDAFX_H
|
||||
|
||||
#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) \
|
||||
void M(TYPE in_##M) \
|
||||
{ \
|
||||
_##M = in_##M; \
|
||||
Q_EMIT M##Changed(); \
|
||||
@ -37,7 +22,7 @@ Q_PROPERTY(TYPE M MEMBER _##M NOTIFY M##Changed)
|
||||
Q_PROPERTY(TYPE M READ M NOTIFY M##Changed FINAL) \
|
||||
public: \
|
||||
Q_SIGNAL void M##Changed(); \
|
||||
void M(const TYPE& in_##M) \
|
||||
void M(TYPE in_##M) \
|
||||
{ \
|
||||
_##M = in_##M; \
|
||||
Q_EMIT M##Changed(); \
|
||||
@ -48,3 +33,5 @@ Q_PROPERTY(TYPE M READ M NOTIFY M##Changed FINAL)
|
||||
} \
|
||||
private: \
|
||||
TYPE _##M; \
|
||||
|
||||
#endif // STDAFX_H
|
||||
|
Loading…
Reference in New Issue
Block a user