加入LoginPage

main
wuyize 2023-06-16 21:07:11 +08:00
parent 34ba4f0f8e
commit 88437b5fb9
8 changed files with 213 additions and 23 deletions

View File

@ -0,0 +1,2 @@
[*]
charset = utf-8

View File

@ -5,16 +5,38 @@ project(AicsKnowledgeBase LANGUAGES CXX)
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_STANDARD_REQUIRED 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 qt_add_executable(AicsKnowledgeBase
main.cpp ${sources_files}
) )
qt_add_qml_module(AicsKnowledgeBase qt_add_qml_module(AicsKnowledgeBase
URI AicsKnowledgeBase URI AicsKnowledgeBase
VERSION 1.0 VERSION 1.0
QML_FILES main.qml QML_FILES ${qml_files}
RESOURCES ${resource_files}
) )
set_target_properties(AicsKnowledgeBase PROPERTIES set_target_properties(AicsKnowledgeBase PROPERTIES

View File

@ -1,19 +0,0 @@
#include <QGuiApplication>
#include <QQmlApplicationEngine>
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();
}

View File

@ -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"
// }
}
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@ -0,0 +1,57 @@
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QDir>
#include <QQuickWindow>
#include <QProcess>
#include <FramelessHelper/Quick/framelessquickmodule.h>
#include <FramelessHelper/Core/private/framelessconfig_p.h>
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();
//}

View File

@ -22,7 +22,7 @@ Qt 6.4.3Qt Core, Qt Quick, Qt QML, Qt ShaderTool, Qt 5 Compatibility Module.
git clone --recursive http://101.34.228.45:3000/auto/AicsKnowledgeBase_client.git 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 ```json
"env": { "env": {