diff --git a/AicsKnowledgeBase/qml/LoginWindow.qml b/AicsKnowledgeBase/qml/LoginWindow.qml index d3280ee..ba4debc 100644 --- a/AicsKnowledgeBase/qml/LoginWindow.qml +++ b/AicsKnowledgeBase/qml/LoginWindow.qml @@ -86,6 +86,8 @@ AppFluWindow { } } FluFilledButton { + id: btn_login + anchors.horizontalCenter: parent.horizontalCenter //normalColor: FluColors.Green.normal //normalColor: "#ffffff" @@ -95,7 +97,8 @@ AppFluWindow { "username": account.text, "password": password.text } - + btn_login.disabled = true + btn_login.text = "登录中" Request.post("login", JSON.stringify(param), function (result, data) { @@ -108,6 +111,8 @@ AppFluWindow { console.log(p2) //FluApp.navigate("/"); //window.close(); + btn_login.disabled = false + btn_login.text = "登录" }) //HttpClient.doGetRequest( diff --git a/AicsKnowledgeBase/qml/MainWindow.qml b/AicsKnowledgeBase/qml/MainWindow.qml index 79daf76..398f096 100644 --- a/AicsKnowledgeBase/qml/MainWindow.qml +++ b/AicsKnowledgeBase/qml/MainWindow.qml @@ -7,13 +7,14 @@ import FluentUI import org.wangwenx190.FramelessHelper import "qrc:///AicsKnowledgeBase/qml/global" import "qrc:///AicsKnowledgeBase/qml/page" +import "qrc:///AicsKnowledgeBase/qml/component" FluWindow { id: window width: 1000 height: 640 - FluAppBar { + CustomAppBar { id: title_bar title: window.title @@ -26,6 +27,7 @@ FluWindow { } RowLayout { + id: tool_bar anchors.top: parent.top anchors.right: parent.right anchors.rightMargin: 140 @@ -38,24 +40,6 @@ FluWindow { // anchors.fill: parent // color: "red" // } - Rectangle { - color: FluColors.White - radius: 50 - width: 32 - height: 32 - } - - Text { - Layout.margins: { - right: 10 - } - text: "用户名" - } - - Image { - height: 30 - source: "qrc:/AicsKnowledgeBase/res/transfer.svg" - } } RowLayout { @@ -119,6 +103,7 @@ FluWindow { setHitTestVisible(title_bar.minimizeButton()) setHitTestVisible(title_bar.maximizeButton()) setHitTestVisible(title_bar.closeButton()) + setHitTestVisible(title_bar.transferButton()) title_bar.maximizeButton.visible = true // window.backgroundVisible = false window.show() diff --git a/AicsKnowledgeBase/qml/component/CustomAppBar.qml b/AicsKnowledgeBase/qml/component/CustomAppBar.qml new file mode 100644 index 0000000..0745d7b --- /dev/null +++ b/AicsKnowledgeBase/qml/component/CustomAppBar.qml @@ -0,0 +1,200 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Window +import QtQuick.Layouts +import FluentUI + +Rectangle { + property string title: "" + property string darkText: "夜间模式" + property string minimizeText: "最小化" + property string restoreText: "向下还原" + property string maximizeText: "最大化" + property string closeText: "关闭" + property color textColor: FluTheme.dark ? "#FFFFFF" : "#000000" + property color minimizeNormalColor: Qt.rgba(0, 0, 0, 0) + property color minimizeHoverColor: FluTheme.dark ? Qt.rgba(1, 1, 1, + 0.1) : Qt.rgba( + 0, 0, 0, 0.06) + property color maximizeNormalColor: Qt.rgba(0, 0, 0, 0) + property color maximizeHoverColor: FluTheme.dark ? Qt.rgba(1, 1, 1, + 0.1) : Qt.rgba( + 0, 0, 0, 0.06) + property color closeNormalColor: Qt.rgba(0, 0, 0, 0) + property color closeHoverColor: Qt.rgba(251 / 255, 115 / 255, 115 / 255, 1) + property bool showDark: false + property bool titleVisible: true + property bool isMac: FluTools.isMacos() + property color borerlessColor: FluTheme.dark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark + property var maxClickListener: function () { + if (d.win.visibility === Window.Maximized) + d.win.visibility = Window.Windowed + else + d.win.visibility = Window.Maximized + } + property var minClickListener: function () { + d.win.visibility = Window.Minimized + } + property var closeClickListener: function () { + d.win.close() + } + property var darkClickListener: function () { + if (FluTheme.dark) { + FluTheme.darkMode = FluDarkMode.Light + } else { + FluTheme.darkMode = FluDarkMode.Dark + } + } + id: root + color: Qt.rgba(0, 0, 0, 0) + height: visible ? 44 : 0 + opacity: visible + z: 65535 + Item { + id: d + property var win: Window.window + property bool isRestore: win && Window.Maximized === win.visibility + property bool resizable: win + && !(win.minimumHeight === win.maximumHeight + && win.maximumWidth === win.minimumWidth) + } + TapHandler { + onTapped: if (tapCount === 2) + btn_maximize.clicked() + gesturePolicy: TapHandler.DragThreshold + } + DragHandler { + target: null + grabPermissions: TapHandler.CanTakeOverFromAnything + onActiveChanged: if (active) { + d.win.startSystemMove() + } + } + FluText { + text: title + anchors { + verticalCenter: parent.verticalCenter + left: isMac ? undefined : parent.left + leftMargin: isMac ? undefined : 10 + horizontalCenter: isMac ? parent.horizontalCenter : undefined + } + visible: root.titleVisible + color: root.textColor + } + RowLayout { + anchors.right: parent.right + height: root.height + spacing: 0 + + Item { + height: 32 + width: 32 + Layout.rightMargin: 10 + FluIconButton { + id: btn_transfer + anchors.fill: parent + onClicked: { + transferList_popup.open() + } + } + Image { + height: 18 + width: 18 + anchors.centerIn: parent + source: "qrc:/AicsKnowledgeBase/res/transfer.svg" + } + + TransferListPopup { + id: transferList_popup + } + } + + Text { + Layout.margins: { + right: 10 + } + text: "用户名" + } + + Rectangle { + Layout.rightMargin: 10 + color: FluColors.White + radius: 50 + width: 32 + height: 32 + } + RowLayout { + Layout.alignment: Qt.AlignVCenter + Layout.rightMargin: 5 + visible: showDark + spacing: 5 + FluText { + text: darkText + color: root.textColor + } + FluToggleSwitch { + id: btn_dark + checked: FluTheme.dark + clickListener: () => darkClickListener(btn_dark) + } + } + FluIconButton { + id: btn_minimize + width: 40 + height: 30 + iconSource: FluentIcons.ChromeMinimize + Layout.alignment: Qt.AlignTop + iconSize: 11 + text: minimizeText + radius: 0 + visible: !isMac + iconColor: root.textColor + color: hovered ? minimizeHoverColor : minimizeNormalColor + onClicked: minClickListener() + } + FluIconButton { + id: btn_maximize + width: 40 + height: 30 + iconSource: d.isRestore ? FluentIcons.ChromeRestore : FluentIcons.ChromeMaximize + color: hovered ? maximizeHoverColor : maximizeNormalColor + Layout.alignment: Qt.AlignTop + visible: d.resizable && !isMac + radius: 0 + iconColor: root.textColor + text: d.isRestore ? restoreText : maximizeText + iconSize: 11 + onClicked: maxClickListener() + } + FluIconButton { + id: btn_close + iconSource: FluentIcons.ChromeClose + Layout.alignment: Qt.AlignTop + text: closeText + width: 40 + height: 30 + visible: !isMac + radius: 0 + iconSize: 10 + iconColor: hovered ? Qt.rgba(1, 1, 1, 1) : root.textColor + color: hovered ? closeHoverColor : closeNormalColor + onClicked: closeClickListener() + } + } + + function minimizeButton() { + return btn_minimize + } + + function maximizeButton() { + return btn_maximize + } + + function closeButton() { + return btn_close + } + + function transferButton() { + return btn_transfer + } +} diff --git a/AicsKnowledgeBase/qml/component/TransferListPopup.qml b/AicsKnowledgeBase/qml/component/TransferListPopup.qml new file mode 100644 index 0000000..cd3142a --- /dev/null +++ b/AicsKnowledgeBase/qml/component/TransferListPopup.qml @@ -0,0 +1,66 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Window +import QtQuick.Layouts +import FluentUI + +Popup { + id: transfer_popup + x: parent ? (parent.width - implicitWidth) / 2 : 0 + y: parent ? parent.height : 0 + background: FluArea { + implicitWidth: 300 + implicitHeight: 200 + color: "#f8f8f8" + radius: 5 + FluShadow {} + } + + contentItem: Item { + anchors.top: parent.top + + ListModel //模型-提供数据 + { + id: itemModel + ListElement { + name: "Apple" + progressValue: 0.1 + } + ListElement { + name: "Orange" + progressValue: 1 + } + ListElement { + name: "Banana" + progressValue: 0.6 + } + } + + Component //委托-提供一个展示数据的示例(如何展示一个模型中的数据) + { + id: itemDelegate + + ColumnLayout { + spacing: 10 + width: parent.width + Text { + Layout.topMargin: 10 + text: name + } + + FluProgressBar { + Layout.fillWidth: true + progress: progressValue + indeterminate: false + } + } + } + + ListView //视图-设置委托和模型,根据委托提供的展示方式展示模型提供的数据 + { + anchors.fill: parent + model: itemModel + delegate: itemDelegate + } + } +} diff --git a/AicsKnowledgeBase/qml/page/AudioPage.qml b/AicsKnowledgeBase/qml/page/AudioPage.qml index 8cca0f4..b58495f 100644 --- a/AicsKnowledgeBase/qml/page/AudioPage.qml +++ b/AicsKnowledgeBase/qml/page/AudioPage.qml @@ -7,7 +7,7 @@ import FluentUI FluArea { property string url: '' - color: "#f9f9f9" + backgroundColor: "#f9f9f9" Layout.fillWidth: true Layout.fillHeight: true diff --git a/AicsKnowledgeBase/qml/page/ContentPage.qml b/AicsKnowledgeBase/qml/page/ContentPage.qml index b00a766..05b49ec 100644 --- a/AicsKnowledgeBase/qml/page/ContentPage.qml +++ b/AicsKnowledgeBase/qml/page/ContentPage.qml @@ -8,7 +8,7 @@ import FluentUI FluArea { paddings: 0 - color: "#f9f9f9" + backgroundColor: "#f9f9f9" // paddings: { // top: 10 diff --git a/AicsKnowledgeBase/qml/page/DocumentPage.qml b/AicsKnowledgeBase/qml/page/DocumentPage.qml index 52eea31..b4939f9 100644 --- a/AicsKnowledgeBase/qml/page/DocumentPage.qml +++ b/AicsKnowledgeBase/qml/page/DocumentPage.qml @@ -7,7 +7,7 @@ import FluentUI FluArea { property string url: '' - color: "#f9f9f9" + backgroundColor: "#f9f9f9" Layout.fillWidth: true Layout.fillHeight: true paddings: 10 diff --git a/AicsKnowledgeBase/qml/page/FavoritePage.qml b/AicsKnowledgeBase/qml/page/FavoritePage.qml index 2d4f405..53c1804 100644 --- a/AicsKnowledgeBase/qml/page/FavoritePage.qml +++ b/AicsKnowledgeBase/qml/page/FavoritePage.qml @@ -7,7 +7,7 @@ import FluentUI FluArea { property string url: '' - color: "#f9f9f9" + backgroundColor: "#f9f9f9" Layout.fillWidth: true Layout.fillHeight: true paddings: 10 diff --git a/AicsKnowledgeBase/qml/page/FilePage.qml b/AicsKnowledgeBase/qml/page/FilePage.qml index 9124f19..e82bae3 100644 --- a/AicsKnowledgeBase/qml/page/FilePage.qml +++ b/AicsKnowledgeBase/qml/page/FilePage.qml @@ -8,7 +8,7 @@ import "qrc:///AicsKnowledgeBase/qml/component" FluArea { property string url: '' - color: "#f9f9f9" + backgroundColor: "#f9f9f9" Layout.fillWidth: true Layout.fillHeight: true @@ -20,5 +20,9 @@ FluArea { text: "" } + FluButton { + text: "上传" + } + FileList {} } diff --git a/AicsKnowledgeBase/qml/page/HistoryPage.qml b/AicsKnowledgeBase/qml/page/HistoryPage.qml index 61303b5..b674143 100644 --- a/AicsKnowledgeBase/qml/page/HistoryPage.qml +++ b/AicsKnowledgeBase/qml/page/HistoryPage.qml @@ -7,7 +7,7 @@ import FluentUI FluArea { property string url: '' - color: "#f9f9f9" + backgroundColor: "#f9f9f9" Layout.fillWidth: true Layout.fillHeight: true paddings: 10 diff --git a/AicsKnowledgeBase/qml/page/HomePage.qml b/AicsKnowledgeBase/qml/page/HomePage.qml index 9a65ad6..88c679d 100644 --- a/AicsKnowledgeBase/qml/page/HomePage.qml +++ b/AicsKnowledgeBase/qml/page/HomePage.qml @@ -7,7 +7,7 @@ import FluentUI FluArea { property string url: '' - color: "#f9f9f9" + backgroundColor: "#f9f9f9" Layout.fillWidth: true Layout.fillHeight: true paddings: 10 diff --git a/AicsKnowledgeBase/qml/page/LocalPage.qml b/AicsKnowledgeBase/qml/page/LocalPage.qml index 12d4fa4..c8c832a 100644 --- a/AicsKnowledgeBase/qml/page/LocalPage.qml +++ b/AicsKnowledgeBase/qml/page/LocalPage.qml @@ -7,7 +7,7 @@ import FluentUI FluArea { property string url: '' - color: "#f9f9f9" + backgroundColor: "#f9f9f9" Layout.fillWidth: true Layout.fillHeight: true paddings: 10 diff --git a/AicsKnowledgeBase/qml/page/SearchPage.qml b/AicsKnowledgeBase/qml/page/SearchPage.qml index 92c3c1c..9117b62 100644 --- a/AicsKnowledgeBase/qml/page/SearchPage.qml +++ b/AicsKnowledgeBase/qml/page/SearchPage.qml @@ -7,7 +7,7 @@ import FluentUI FluArea { property string url: '' - color: "#f9f9f9" + backgroundColor: "#f9f9f9" Layout.fillHeight: true Layout.fillWidth: true Layout.topMargin: 20 diff --git a/AicsKnowledgeBase/qml/page/VideoPage.qml b/AicsKnowledgeBase/qml/page/VideoPage.qml index 13fb10b..52d56b9 100644 --- a/AicsKnowledgeBase/qml/page/VideoPage.qml +++ b/AicsKnowledgeBase/qml/page/VideoPage.qml @@ -7,7 +7,7 @@ import FluentUI FluArea { property string url: '' - color: "#f9f9f9" + backgroundColor: "#f9f9f9" Layout.fillWidth: true Layout.fillHeight: true paddings: 10 diff --git a/AicsKnowledgeBase/src/FileTransferManager.cpp b/AicsKnowledgeBase/src/FileTransferManager.cpp new file mode 100644 index 0000000..1373ef5 --- /dev/null +++ b/AicsKnowledgeBase/src/FileTransferManager.cpp @@ -0,0 +1,10 @@ +// +// Created by wuyiz on 2023/7/1. +// + +#include "FileTransferManager.h" + +FileTransferManager::FileTransferManager(QObject *parent) : QObject(parent) +{ + +} diff --git a/AicsKnowledgeBase/src/FileTransferManager.h b/AicsKnowledgeBase/src/FileTransferManager.h new file mode 100644 index 0000000..888d004 --- /dev/null +++ b/AicsKnowledgeBase/src/FileTransferManager.h @@ -0,0 +1,20 @@ +// +// Created by wuyiz on 2023/7/1. +// + +#ifndef AICSKNOWLEDGEBASE_FILETRANSFERMANAGER_H +#define AICSKNOWLEDGEBASE_FILETRANSFERMANAGER_H + + +#include + +class FileTransferManager: public QObject +{ +Q_OBJECT +public: + explicit FileTransferManager(QObject *parent = nullptr); + +}; + + +#endif //AICSKNOWLEDGEBASE_FILETRANSFERMANAGER_H diff --git a/AicsKnowledgeBase/src/main.cpp b/AicsKnowledgeBase/src/main.cpp index a7b041a..c7f388e 100644 --- a/AicsKnowledgeBase/src/main.cpp +++ b/AicsKnowledgeBase/src/main.cpp @@ -8,47 +8,54 @@ #include #include #include "HttpClient.h" +#include "FileTransferManager.h" FRAMELESSHELPER_USE_NAMESPACE -int main(int argc, char* argv[]) +int main(int argc, char *argv[]) { - //将样式设置为Basic,不然会导致组件显示异常 - qputenv("QT_QUICK_CONTROLS_STYLE", "Basic"); + //将样式设置为Basic,不然会导致组件显示异常 + qputenv("QT_QUICK_CONTROLS_STYLE", "Basic"); - QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts); - QtWebEngineQuick::initialize(); + QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts); + QtWebEngineQuick::initialize(); - FramelessHelper::Quick::initialize(); - QGuiApplication app(argc, argv); - app.setOrganizationName("HFUT Software"); - app.setApplicationName("Aics Knowledge"); + FramelessHelper::Quick::initialize(); + QGuiApplication app(argc, argv); + QGuiApplication::setOrganizationName("HFUT Software"); + QGuiApplication::setApplicationName("Aics Knowledge"); #ifdef Q_OS_WIN // 此设置仅在Windows下生效 - FramelessConfig::instance()->set(Global::Option::ForceHideWindowFrameBorder); + FramelessConfig::instance()->set(Global::Option::ForceHideWindowFrameBorder); #endif - FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial); - FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow); - FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur); - FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow); + FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial); + FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow); + FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur); + FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow); #ifdef Q_OS_MACOS - FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur, false); + FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur, false); #endif - QQmlApplicationEngine engine; - FramelessHelper::Quick::registerTypes(&engine); - HttpClient* httpClient = new HttpClient(engine); + QQmlApplicationEngine engine; + FramelessHelper::Quick::registerTypes(&engine); + auto httpClient = new HttpClient(engine); + auto fileTransferManager = new FileTransferManager(); + qmlRegisterSingletonInstance("AicsKB.HttpClient", 1, 0, "HttpClient", httpClient); + qmlRegisterSingletonInstance("AicsKB.FileTransferManager", 1, 0, "FileTransferManager", + fileTransferManager); - const QUrl url(u"qrc:/AicsKnowledgeBase/qml/App.qml"_qs); - QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, - &app, [url](QObject* obj, const QUrl& objUrl) { - if (!obj && url == objUrl) - QCoreApplication::exit(-1); - }, Qt::QueuedConnection); - engine.load(url); - auto result = app.exec(); + const QUrl url(u"qrc:/AicsKnowledgeBase/qml/App.qml"_qs); + QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, + &app, [url](QObject *obj, const QUrl &objUrl) { + if (!obj && url == objUrl) + QCoreApplication::exit(-1); + }, Qt::QueuedConnection); + engine.load(url); + auto result = QGuiApplication::exec(); httpClient->deleteLater(); + fileTransferManager->deleteLater(); + return result; } diff --git a/FluentUI b/FluentUI index 7b30ccf..04dc772 160000 --- a/FluentUI +++ b/FluentUI @@ -1 +1 @@ -Subproject commit 7b30ccfd22823c51f5ed8e3ff649737c76ae0ce6 +Subproject commit 04dc772cb4f99415687d5a4292917837c39d9874