Merge branch 'test_branch' of https://github.com/parker-int64/FluentUI into test_branch
commit
33b916a172
|
@ -18,6 +18,10 @@ FluWindow {
|
|||
launchMode: FluWindow.SingleTask
|
||||
visible: true
|
||||
|
||||
Component.onCompleted: {
|
||||
// FluApp.init(window)
|
||||
}
|
||||
|
||||
FluNavigationView2{
|
||||
id:nav_view
|
||||
anchors.fill: parent
|
||||
|
|
|
@ -24,6 +24,11 @@ FluExpander{
|
|||
color:FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(247/255,247/255,247/255,1)
|
||||
border.color: FluTheme.dark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(226/255,229/255,234/255,1)
|
||||
border.width: 1
|
||||
Behavior on color{
|
||||
ColorAnimation {
|
||||
duration: 300
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#include "AppInfo.h"
|
||||
|
||||
#include <QQmlContext>
|
||||
#include <QDebug>
|
||||
#include "lang/En.h"
|
||||
#include "lang/Zh.h"
|
||||
#include <QDebug>
|
||||
|
||||
#define STR(x) #x
|
||||
#define VER_JOIN(a,b,c,d) STR(a.b.c.d)
|
||||
|
@ -15,6 +17,16 @@ AppInfo::AppInfo(QObject *parent)
|
|||
lang(new En());
|
||||
}
|
||||
|
||||
void AppInfo::init(QQmlApplicationEngine *engine){
|
||||
QQmlContext * context = engine->rootContext();
|
||||
Lang* lang = this->lang();
|
||||
context->setContextProperty("lang",lang);
|
||||
QObject::connect(this,&AppInfo::langChanged,this,[=]{
|
||||
context->setContextProperty("lang",this->lang());
|
||||
});
|
||||
context->setContextProperty("appInfo",this);
|
||||
}
|
||||
|
||||
void AppInfo::changeLang(const QString& locale){
|
||||
if(_lang){
|
||||
_lang->deleteLater();
|
||||
|
@ -27,3 +39,18 @@ void AppInfo::changeLang(const QString& locale){
|
|||
lang(new En());
|
||||
}
|
||||
}
|
||||
|
||||
bool AppInfo::isOwnerProcess(IPC *ipc){
|
||||
QString activeWindowEvent = "activeWindow";
|
||||
if(!ipc->isCurrentOwner()){
|
||||
ipc->postEvent(activeWindowEvent,QString().toUtf8(),0);
|
||||
return false;
|
||||
}
|
||||
if(ipc->isAttached()){
|
||||
ipc->registerEventHandler(activeWindowEvent,[=](const QByteArray&){
|
||||
Q_EMIT this->activeWindow();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
#define APPINFO_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include "tool/IPC.h"
|
||||
#include "lang/Lang.h"
|
||||
#include "stdafx.h"
|
||||
|
||||
|
@ -12,6 +14,8 @@ class AppInfo : public QObject
|
|||
Q_PROPERTY_AUTO(Lang*,lang)
|
||||
public:
|
||||
explicit AppInfo(QObject *parent = nullptr);
|
||||
void init(QQmlApplicationEngine *engine);
|
||||
bool isOwnerProcess(IPC *ipc);
|
||||
Q_INVOKABLE void changeLang(const QString& locale);
|
||||
Q_SIGNAL void activeWindow();
|
||||
};
|
||||
|
|
|
@ -6,13 +6,11 @@
|
|||
#include <QProcess>
|
||||
#include <FramelessHelper/Quick/framelessquickmodule.h>
|
||||
#include <FramelessHelper/Core/private/framelessconfig_p.h>
|
||||
#include "lang/Lang.h"
|
||||
#include "AppInfo.h"
|
||||
#include "tool/IPC.h"
|
||||
|
||||
FRAMELESSHELPER_USE_NAMESPACE
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
//将样式设置为Basic,不然会导致组件显示异常
|
||||
qputenv("QT_QUICK_CONTROLS_STYLE","Basic");
|
||||
|
@ -33,28 +31,13 @@ FRAMELESSHELPER_USE_NAMESPACE
|
|||
#endif
|
||||
AppInfo* appInfo = new AppInfo();
|
||||
IPC ipc(0);
|
||||
QString activeWindowEvent = "activeWindow";
|
||||
if(!ipc.isCurrentOwner()){
|
||||
ipc.postEvent(activeWindowEvent,QString().toUtf8(),0);
|
||||
delete appInfo;
|
||||
if(!appInfo->isOwnerProcess(&ipc)){
|
||||
return 0;
|
||||
}
|
||||
if(ipc.isAttached()){
|
||||
ipc.registerEventHandler(activeWindowEvent,[&appInfo](const QByteArray&){
|
||||
Q_EMIT appInfo->activeWindow();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
app.setQuitOnLastWindowClosed(false);
|
||||
QQmlApplicationEngine engine;
|
||||
FramelessHelper::Quick::registerTypes(&engine);
|
||||
QQmlContext * context = engine.rootContext();
|
||||
Lang* lang = appInfo->lang();
|
||||
context->setContextProperty("lang",lang);
|
||||
QObject::connect(appInfo,&AppInfo::langChanged,&app,[context,appInfo]{
|
||||
context->setContextProperty("lang",appInfo->lang());
|
||||
});
|
||||
context->setContextProperty("appInfo",appInfo);
|
||||
appInfo->init(&engine);
|
||||
const QUrl url(QStringLiteral("qrc:/example/qml/App.qml"));
|
||||
// const QUrl url(QStringLiteral("qrc:/example/qml/TestWindow.qml"));
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
|
||||
|
|
|
@ -23,11 +23,9 @@ FluApp *FluApp::getInstance()
|
|||
FluApp::FluApp(QObject *parent)
|
||||
: QObject{parent}
|
||||
{
|
||||
QFontDatabase::addApplicationFont(":/FluentUI/Font/Segoe_Fluent_Icons.ttf");
|
||||
}
|
||||
|
||||
FluApp::~FluApp(){
|
||||
|
||||
}
|
||||
|
||||
void FluApp::init(QQuickWindow *window){
|
||||
|
|
|
@ -27,6 +27,7 @@ class FluApp : public QObject
|
|||
*/
|
||||
Q_PROPERTY_AUTO(QJsonObject,routes);
|
||||
|
||||
QML_FOREIGN(FluApp)
|
||||
QML_NAMED_ELEMENT(FluApp)
|
||||
QML_SINGLETON
|
||||
private:
|
||||
|
|
|
@ -4,15 +4,13 @@ import QtQuick.Controls
|
|||
import QtQuick.Window
|
||||
import FluentUI
|
||||
|
||||
Popup {
|
||||
FluPopup {
|
||||
id: popup
|
||||
property string title: "Title"
|
||||
property string message: "Message"
|
||||
property string neutralText: "Neutral"
|
||||
property string negativeText: "Negative"
|
||||
property string positiveText: "Positive"
|
||||
property alias blurSource: blur.sourceItem
|
||||
property bool blurBackground: true
|
||||
signal neutralClicked
|
||||
signal negativeClicked
|
||||
signal positiveClicked
|
||||
|
@ -27,32 +25,7 @@ Popup {
|
|||
return 400
|
||||
return Math.min(Window.window.width,400)
|
||||
}
|
||||
modal:true
|
||||
anchors.centerIn: Overlay.overlay
|
||||
closePolicy: Popup.CloseOnEscape
|
||||
background:Item{}
|
||||
enter: Transition {
|
||||
reversible: true
|
||||
NumberAnimation {
|
||||
properties: "opacity,scale"
|
||||
from:0
|
||||
to:1
|
||||
duration: 167
|
||||
easing.type: Easing.BezierSpline
|
||||
easing.bezierCurve: [ 0, 0, 0, 1 ]
|
||||
}
|
||||
}
|
||||
exit:Transition {
|
||||
NumberAnimation {
|
||||
properties: "opacity,scale"
|
||||
from:1
|
||||
to:0
|
||||
duration: 167
|
||||
easing.type: Easing.BezierSpline
|
||||
easing.bezierCurve: [ 1, 0, 0, 0 ]
|
||||
}
|
||||
}
|
||||
contentItem:
|
||||
|
||||
Rectangle {
|
||||
id:layout_content
|
||||
anchors.fill: parent
|
||||
|
@ -60,20 +33,6 @@ Popup {
|
|||
implicitHeight: text_title.height + text_message.height + layout_actions.height
|
||||
color: 'transparent'
|
||||
radius:5
|
||||
FluAcrylic{
|
||||
id:blur
|
||||
anchors{
|
||||
top:parent.top
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
bottom: layout_actions.bottom
|
||||
}
|
||||
height: parent.height
|
||||
color: FluTheme.dark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(249/255,249/255,249/255,1)
|
||||
rectX: popup.x
|
||||
rectY: popup.y
|
||||
acrylicOpacity:blurBackground ? 0.8 : 1
|
||||
}
|
||||
FluText{
|
||||
id:text_title
|
||||
font: FluTextStyle.TitleLarge
|
||||
|
@ -107,7 +66,7 @@ Popup {
|
|||
id:layout_actions
|
||||
height: 68
|
||||
radius: 5
|
||||
color: FluTheme.dark ? Qt.rgba(32/255,32/255,32/255, blurBackground ? blur.acrylicOpacity - 0.4 : 1) : Qt.rgba(243/255,243/255,243/255,blurBackground ? blur.acrylicOpacity - 0.4 : 1)
|
||||
color: FluTheme.dark ? Qt.rgba(32/255,32/255,32/255, blurBackground ? blurOpacity - 0.4 : 1) : Qt.rgba(243/255,243/255,243/255,blurBackground ? blurOpacity - 0.4 : 1)
|
||||
anchors{
|
||||
top:text_message.bottom
|
||||
left: parent.left
|
||||
|
|
|
@ -4,9 +4,4 @@ import FluentUI
|
|||
|
||||
Rectangle {
|
||||
color: FluTheme.dark ? Window.active ? Qt.rgba(55/255,55/255,55/255,1):Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(226/255,230/255,234/255,1)
|
||||
Behavior on color{
|
||||
ColorAnimation {
|
||||
duration: 300
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,4 +13,9 @@ Text {
|
|||
verticalAlignment: Text.AlignVCenter
|
||||
color: iconColor
|
||||
text: (String.fromCharCode(iconSource).toString(16))
|
||||
|
||||
FontLoader{
|
||||
source: "../Font/Segoe_Fluent_Icons.ttf"
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -51,17 +51,15 @@ Button {
|
|||
}
|
||||
}
|
||||
contentItem: Item{
|
||||
Text {
|
||||
FluIcon {
|
||||
id:text_icon
|
||||
font.family: "Segoe Fluent Icons"
|
||||
font.pixelSize: iconSize
|
||||
width: iconSize
|
||||
height: iconSize
|
||||
iconSize: control.iconSize
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
anchors.centerIn: parent
|
||||
color:control.iconColor
|
||||
text: (String.fromCharCode(iconSource).toString(16));
|
||||
iconColor: control.iconColor
|
||||
iconSource: control.iconSource;
|
||||
}
|
||||
FluTooltip{
|
||||
id:tool_tip
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Window
|
||||
import FluentUI
|
||||
|
||||
Popup {
|
||||
id: popup
|
||||
padding: 0
|
||||
modal:true
|
||||
anchors.centerIn: Overlay.overlay
|
||||
closePolicy: Popup.CloseOnEscape
|
||||
property alias blurSource: blur.sourceItem
|
||||
property bool blurBackground: true
|
||||
property alias blurOpacity: blur.acrylicOpacity
|
||||
|
||||
enter: Transition {
|
||||
reversible: true
|
||||
NumberAnimation {
|
||||
properties: "opacity,scale"
|
||||
from:0
|
||||
to:1
|
||||
duration: 167
|
||||
easing.type: Easing.BezierSpline
|
||||
easing.bezierCurve: [ 0, 0, 0, 1 ]
|
||||
}
|
||||
}
|
||||
exit:Transition {
|
||||
NumberAnimation {
|
||||
properties: "opacity,scale"
|
||||
from:1
|
||||
to:0
|
||||
duration: 167
|
||||
easing.type: Easing.BezierSpline
|
||||
easing.bezierCurve: [ 1, 0, 0, 0 ]
|
||||
}
|
||||
}
|
||||
|
||||
background: FluAcrylic{
|
||||
id:blur
|
||||
color: FluTheme.dark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(249/255,249/255,249/255,1)
|
||||
rectX: popup.x
|
||||
rectY: popup.y
|
||||
acrylicOpacity:blurBackground ? 0.8 : 1
|
||||
}
|
||||
}
|
|
@ -48,7 +48,7 @@ Rectangle{
|
|||
}
|
||||
Behavior on height{
|
||||
NumberAnimation{
|
||||
duration: 167
|
||||
duration: 83
|
||||
easing.type: Easing.BezierSpline
|
||||
easing.bezierCurve: [ 1, 0, 0, 0 ]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue