diff --git a/AicsKnowledgeBase/.editorconfig b/AicsKnowledgeBase/.editorconfig new file mode 100644 index 0000000..f8af8bc --- /dev/null +++ b/AicsKnowledgeBase/.editorconfig @@ -0,0 +1,2 @@ +[*] +charset = utf-8 \ No newline at end of file diff --git a/AicsKnowledgeBase/CMakeLists.txt b/AicsKnowledgeBase/CMakeLists.txt index 71afe59..ef8b931 100644 --- a/AicsKnowledgeBase/CMakeLists.txt +++ b/AicsKnowledgeBase/CMakeLists.txt @@ -5,16 +5,38 @@ project(AicsKnowledgeBase LANGUAGES CXX) set(CMAKE_AUTOMOC ON) set(CMAKE_CXX_STANDARD_REQUIRED ON) -find_package(Qt6 6.2 COMPONENTS Quick REQUIRED) +find_package(Qt6 COMPONENTS Quick REQUIRED) + +#遍历所有Cpp文件 +file(GLOB_RECURSE CPP_FILES src/*.cpp src/*.h) +foreach(filepath ${CPP_FILES}) + string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath}) + list(APPEND sources_files ${filename}) +endforeach(filepath) + +#遍历所有qml文件 +file(GLOB_RECURSE QML_PATHS qml/*.qml) +foreach(filepath ${QML_PATHS}) + string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath}) + list(APPEND qml_files ${filename}) +endforeach(filepath) + +#遍历所有资源文件 +file(GLOB_RECURSE RES_PATHS res/*.png res/*.jpg res/*.svg res/*.ico res/*.ttf res/*.webp res/qmldir) +foreach(filepath ${RES_PATHS}) + string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath}) + list(APPEND resource_files ${filename}) +endforeach(filepath) qt_add_executable(AicsKnowledgeBase - main.cpp + ${sources_files} ) qt_add_qml_module(AicsKnowledgeBase URI AicsKnowledgeBase VERSION 1.0 - QML_FILES main.qml + QML_FILES ${qml_files} + RESOURCES ${resource_files} ) set_target_properties(AicsKnowledgeBase PROPERTIES diff --git a/AicsKnowledgeBase/main.cpp b/AicsKnowledgeBase/main.cpp deleted file mode 100644 index ca036e0..0000000 --- a/AicsKnowledgeBase/main.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include - - -int main(int argc, char *argv[]) -{ - QGuiApplication app(argc, argv); - - QQmlApplicationEngine engine; - const QUrl url(u"qrc:/AicsKnowledgeBase/main.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); - - return app.exec(); -} diff --git a/AicsKnowledgeBase/qml/LoginPage.qml b/AicsKnowledgeBase/qml/LoginPage.qml new file mode 100644 index 0000000..5c67daa --- /dev/null +++ b/AicsKnowledgeBase/qml/LoginPage.qml @@ -0,0 +1,128 @@ +import QtQuick +import FluentUI +import QtQuick.Controls +import QtQuick.Window +import QtQuick.Layouts +import org.wangwenx190.FramelessHelper + +FluWindow{ + width: 640 + height: 480 + visible: true + title: qsTr("Hello World") + color: "transparent" + + property alias titleVisible: title_bar.titleVisible + property bool appBarVisible: true + + FluAppBar { + id: title_bar + title: window.title + visible: window.appBarVisible + anchors { + top: parent.top + left: parent.left + right: parent.right + } + darkText: lang.dark_mode + } + + Item{ + id:container + anchors{ + top: title_bar.bottom + left: parent.left + right: parent.right + bottom: parent.bottom + } + clip: true + } + + FramelessHelper{ + id:framless_helper + onReady: { + setTitleBarItem(title_bar) + moveWindowToDesktopCenter() + setHitTestVisible(title_bar.minimizeButton()) + setHitTestVisible(title_bar.maximizeButton()) + setHitTestVisible(title_bar.closeButton()) + setWindowFixedSize(fixSize) + title_bar.maximizeButton.visible = !fixSize + if (blurBehindWindowEnabled) + window.backgroundVisible = false + window.show() + } + } + function setHitTestVisible(com){ + framless_helper.setHitTestVisible(com) + } + + function setTitleBarItem(com){ + framless_helper.setTitleBarItem(com) + } + Row{ + anchors.fill: parent + Item{ + id: introdutcitonItem + height: parent.height + width: parent.width * 0.5 + Image { + anchors.fill: parent + source: "qrc:/AicsKnowledgeBase/res/login_background.webp" + + } + } + Item{ + id: loginItem + height: parent.height + width: parent.width * 0.5 + FluPivot{ + anchors.fill: parent + anchors.margins: 20 + + FluPivotItem{ + title: "Sign in" + contentItem:Column{ + anchors.fill: parent + anchors.margins: 20 + anchors.centerIn: parent + spacing: 12 + + FluTextBox{ + placeholderText: "Account" + id: account + } + FluPasswordBox{ + placeholderText: "Password" + id: password + } + Row{ + spacing: 25 + FluCheckBox{ + text: "Remember me" + } + FluTextButton{ + text: "Forgot your password?" + } + } + FluFilledButton{ + text: "Sign in" + anchors.horizontalCenter: parent.horizontalCenter + normalColor: "green" + } + + + + } + } + FluPivotItem{ + title: "Register" +// Rectangle{ +// anchors.fill: parent +// color: "blue" +// } + } + } + } + } +} diff --git a/AicsKnowledgeBase/main.qml b/AicsKnowledgeBase/qml/main.qml similarity index 100% rename from AicsKnowledgeBase/main.qml rename to AicsKnowledgeBase/qml/main.qml diff --git a/AicsKnowledgeBase/res/login_background.webp b/AicsKnowledgeBase/res/login_background.webp new file mode 100644 index 0000000..2641afa Binary files /dev/null and b/AicsKnowledgeBase/res/login_background.webp differ diff --git a/AicsKnowledgeBase/src/main.cpp b/AicsKnowledgeBase/src/main.cpp new file mode 100644 index 0000000..6d0b5e4 --- /dev/null +++ b/AicsKnowledgeBase/src/main.cpp @@ -0,0 +1,57 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +FRAMELESSHELPER_USE_NAMESPACE + +int main(int argc, char* argv[]) +{ + //将样式设置为Basic,不然会导致组件显示异常 + qputenv("QT_QUICK_CONTROLS_STYLE", "Basic"); + FramelessHelper::Quick::initialize(); + QGuiApplication app(argc, argv); +#ifdef Q_OS_WIN // 此设置仅在Windows下生效 + 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); +#ifdef Q_OS_MACOS + FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur, false); +#endif + + QQmlApplicationEngine engine; + FramelessHelper::Quick::registerTypes(&engine); + const QUrl url(u"qrc:/AicsKnowledgeBase/qml/LoginPage.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); + return app.exec(); +} + + + +//int main(int argc, char *argv[]) +//{ +// QGuiApplication app(argc, argv); +// +// QQmlApplicationEngine engine; +// const QUrl url(u"qrc:/AicsKnowledgeBase/main.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); +// +// return app.exec(); +//} diff --git a/README.md b/README.md index 622b9d7..c724861 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Qt 6.4.3:Qt Core, Qt Quick, Qt QML, Qt ShaderTool, Qt 5 Compatibility Module. git clone --recursive http://101.34.228.45:3000/auto/AicsKnowledgeBase_client.git ``` -在调试配置launch.vs.json中添加 +若使用Visual Studio,需配置环境变量Qt_DIR和Qt6_DIR为Qt msvc2019_64目录,然后在调试配置launch.vs.json中添加 ```json "env": {