This commit is contained in:
zhuzihcu
2023-03-06 18:08:01 +08:00
parent 1ad1aa058a
commit d9ed37d3af
23 changed files with 588 additions and 729 deletions

View File

@ -32,10 +32,6 @@ void Fluent::registerTypes(const char *uri){
qmlRegisterType<WindowHelper>(uri,major,minor,"WindowHelper");
qmlRegisterType<FluColorSet>(uri,major,minor,"FluColorSet");
// qmlRegisterSingletonType(QUrl("qrc:/com.zhuzichu/controls/FluColors.qml"),uri,major,minor,"FluColors");
// qmlRegisterSingletonType(QUrl("qrc:/com.zhuzichu/controls/FluTheme.qml"),uri,major,minor,"FluTheme");
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluColorSetOld.qml"),uri,major,minor,"FluColorSetOld");
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluMenu.qml"),uri,major,minor,"FluMenu");
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluMenuItem.qml"),uri,major,minor,"FluMenuItem");

View File

@ -12,15 +12,6 @@ public:
bool m_deleteLater = false;
QQuickItem *m_titleItem = nullptr;
};
static bool isMaxWin(QWindow* win)
{
return win->windowState() == Qt::WindowMaximized;
}
static bool isFullWin(QQuickView* win)
{
return win->windowState() == Qt::WindowFullScreen;
}
FramelessView::FramelessView(QWindow *parent) : Super(parent), d(new FramelessViewPrivate)
{
setFlags(Qt::CustomizeWindowHint | Qt::Window | Qt::FramelessWindowHint | Qt::WindowMinMaxButtonsHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint);
@ -109,53 +100,6 @@ bool FramelessView::nativeEvent(const QByteArray &eventType, void *message, qint
bool FramelessView::nativeEvent(const QByteArray &eventType, void *message, long *result)
#endif
{
if (!result)
{
return false;
}
#if (QT_VERSION == QT_VERSION_CHECK(5, 11, 1))
const auto msg = *reinterpret_cast<MSG**>(message);
#else
const auto msg = static_cast<LPMSG>(message);
#endif
if (!msg || !msg->hwnd)
{
return false;
}
switch (msg->message)
{
case WM_NCCALCSIZE: {
#if 1
const auto mode = static_cast<BOOL>(msg->wParam);
const auto clientRect = mode ? &(reinterpret_cast<LPNCCALCSIZE_PARAMS>(msg->lParam)->rgrc[0]) : reinterpret_cast<LPRECT>(msg->lParam);
if (mode == TRUE)
{
*result = WVR_REDRAW;
//规避 拖动border进行resize时界面闪烁
if (!isMaxWin(this) && !isFullWin(this))
{
if (clientRect->top != 0)
{
clientRect->top -= 0.1;
}
}
else
{
if (clientRect->top != 0)
{
clientRect->top += 0.1;
}
}
return true;
}
#else
*result = 0;
return true;
#endif
break;
}
}
return Super::nativeEvent(eventType, message, result);
}

View File

@ -6,7 +6,13 @@ import FluentUI 1.0
Rectangle{
id:root
color: FluTheme.isDark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
property color borerlessColor : FluTheme.isDark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
color: {
if(Window.window == null)
return borerlessColor
return Window.window.active ? borerlessColor : Qt.lighter(FluTheme.primaryColor.lightest,1.1)
}
height: 50
width: {
if(parent==null)
@ -19,30 +25,31 @@ Rectangle{
property bool showDark: false
property bool showFps: false
property var window: Window.window
property bool resizable: {
if(Window.window == null){
if(window == null){
return false
}
return !(Window.window.minimumHeight === Window.window.maximumHeight && Window.window.maximumWidth === Window.window.minimumWidth)
return !(window.minimumHeight === window.maximumHeight && window.maximumWidth === window.minimumWidth)
}
MouseArea{
anchors.fill: parent
anchors.topMargin: 5
acceptedButtons: Qt.LeftButton
hoverEnabled: true
onPressed: Window.window.startSystemMove()
onDoubleClicked: {
if(resizable)
toggleMaximized();
}
TapHandler {
onTapped: if (tapCount === 2) toggleMaximized()
gesturePolicy: TapHandler.DragThreshold
}
DragHandler {
target: null
grabPermissions: TapHandler.CanTakeOverFromAnything
onActiveChanged: if (active) { window.startSystemMove(); }
}
function toggleMaximized() {
if (Window.window.visibility === Window.Maximized) {
Window.window.showNormal();
if (window.visibility === Window.Maximized) {
window.showNormal();
} else {
Window.window.showMaximized();
window.showMaximized();
}
}
@ -98,14 +105,14 @@ Rectangle{
textColor: root.textColor
color:hovered ? "#20000000" : "#00000000"
onClicked: {
Window.window.showMinimized()
window.showMinimized()
}
}
FluIconButton{
property bool isRestore:{
if(Window.window == null)
if(window == null)
return false
return Window.Maximized === Window.window.visibility
return Window.Maximized === window.visibility
}
icon : isRestore ? FluentIcons.FA_window_restore : FluentIcons.FA_window_maximize
color:hovered ? "#20000000" : "#00000000"

View File

@ -1,13 +0,0 @@
import QtQuick 2.15
QtObject {
property color darkest: Qt.rgba(0/255,74/255,131/255,1)
property color darker:Qt.rgba(0/255,84/255,148/255,1)
property color dark:Qt.rgba(0/255,102/255,180/255,1)
property color normal:Qt.rgba(0/255,120/255,212/255,1)
property color light:Qt.rgba(38/255,140/255,218/255,1)
property color lighter:Qt.rgba(76/255,160/255,224/255,1)
property color lightest:Qt.rgba(96/255,171/255,228/255,1)
}

View File

@ -1,112 +0,0 @@
pragma Singleton
import QtQuick 2.15
QtObject {
property color _Black: Qt.rgba(0/255,0/255,0/255,1)
property color _White: Qt.rgba(255/255,255/255,255/255,1)
property color _Grey10: Qt.rgba(250/255,249/255,248/255,1)
property color _Grey20: Qt.rgba(243/255,242/255,241/255,1)
property color _Grey30: Qt.rgba(237/255,235/255,233/255,1)
property color _Grey40: Qt.rgba(225/255,223/255,221/255,1)
property color _Grey50: Qt.rgba(210/255,208/255,206/255,1)
property color _Grey60: Qt.rgba(200/255,198/255,196/255,1)
property color _Grey70: Qt.rgba(190/255,187/255,184/255,1)
property color _Grey80: Qt.rgba(179/255,176/255,173/255,1)
property color _Grey90: Qt.rgba(161/255,159/255,157/255,1)
property color _Grey100: Qt.rgba(151/255,149/255,147/255,1)
property color _Grey110: Qt.rgba(138/255,136/255,134/255,1)
property color _Grey120: Qt.rgba(121/255,119/255,117/255,1)
property color _Grey130: Qt.rgba(96/255,94/255,92/255,1)
property color _Grey140: Qt.rgba(72/255,70/255,68/255,1)
property color _Grey150: Qt.rgba(59/255,58/255,57/255,1)
property color _Grey160: Qt.rgba(50/255,49/255,48/255,1)
property color _Grey170: Qt.rgba(41/255,40/255,39/255,1)
property color _Grey180: Qt.rgba(37/255,36/255,35/255,1)
property color _Grey190: Qt.rgba(32/255,31/255,30/255,1)
property color _Grey200: Qt.rgba(27/255,26/255,25/255,1)
property color _Grey210: Qt.rgba(22/255,21/255,20/255,1)
property color _Grey220: Qt.rgba(17/255,16/255,15/255,1)
property FluColorSetOld _Yellow:FluColorSetOld{
darkest: Qt.rgba(249/255,168/255,37/255,1)
darker:Qt.rgba(251/255,192/255,45/255,1)
dark:Qt.rgba(253/255,216/255,53/255,1)
normal:Qt.rgba(255/255,235/255,59/255,1)
light:Qt.rgba(255/255,238/255,88/255,1)
lighter:Qt.rgba(255/255,241/255,118/255,1)
lightest:Qt.rgba(255/255,245/255,157/255,1)
}
property FluColorSetOld _Orange:FluColorSetOld{
darkest: Qt.rgba(153/255,61/255,7/255,1)
darker:Qt.rgba(172/255,68/255,8/255,1)
dark:Qt.rgba(209/255,84/255,10/255,1)
normal:Qt.rgba(247/255,99/255,12/255,1)
light:Qt.rgba(248/255,122/255,48/255,1)
lighter:Qt.rgba(249/255,145/255,84/255,1)
lightest:Qt.rgba(250/255,158/255,104/255,1)
}
property FluColorSetOld _Red:FluColorSetOld{
darkest: Qt.rgba(143/255,10/255,21/255,1)
darker:Qt.rgba(162/255,11/255,24/255,1)
dark:Qt.rgba(185/255,13/255,28/255,1)
normal:Qt.rgba(232/255,17/255,35/255,1)
light:Qt.rgba(236/255,64/255,79/255,1)
lighter:Qt.rgba(238/255,88/255,101/255,1)
lightest:Qt.rgba(240/255,107/255,118/255,1)
}
property FluColorSetOld _Magenta:FluColorSetOld{
darkest: Qt.rgba(111/255,0/255,79/255,1)
darker:Qt.rgba(126/255,0/255,110/255,1)
dark:Qt.rgba(144/255,0/255,126/255,1)
normal:Qt.rgba(180/255,0/255,158/255,1)
light:Qt.rgba(195/255,51/255,177/255,1)
lighter:Qt.rgba(202/255,76/255,187/255,1)
lightest:Qt.rgba(208/255,96/255,194/255,1)
}
property FluColorSetOld _Purple:FluColorSetOld{
darkest: Qt.rgba(71/255,47/255,104/255,1)
darker:Qt.rgba(81/255,53/255,118/255,1)
dark:Qt.rgba(100/255,66/255,147/255,1)
normal:Qt.rgba(116/255,77/255,169/255,1)
light:Qt.rgba(134/255,100/255,180/255,1)
lighter:Qt.rgba(157/255,130/255,194/255,1)
lightest:Qt.rgba(168/255,144/255,201/255,1)
}
property FluColorSetOld _Blue:FluColorSetOld{
darkest: Qt.rgba(0/255,74/255,131/255,1)
darker:Qt.rgba(0/255,84/255,148/255,1)
dark:Qt.rgba(0/255,102/255,180/255,1)
normal:Qt.rgba(0/255,120/255,212/255,1)
light:Qt.rgba(38/255,140/255,218/255,1)
lighter:Qt.rgba(76/255,160/255,224/255,1)
lightest:Qt.rgba(96/255,171/255,228/255,1)
}
property FluColorSetOld _Teal:FluColorSetOld{
darkest: Qt.rgba(0/255,110/255,91/255,1)
darker:Qt.rgba(0/255,124/255,103/255,1)
dark:Qt.rgba(0/255,151/255,125/255,1)
normal:Qt.rgba(0/255,178/255,148/255,1)
light:Qt.rgba(38/255,189/255,164/255,1)
lighter:Qt.rgba(76/255,201/255,180/255,1)
lightest:Qt.rgba(96/255,207/255,188/255,1)
}
property FluColorSetOld _Green:FluColorSetOld{
darkest: Qt.rgba(9/255,76/255,9/255,1)
darker:Qt.rgba(12/255,93/255,12/255,1)
dark:Qt.rgba(14/255,111/255,14/255,1)
normal:Qt.rgba(16/255,124/255,16/255,1)
light:Qt.rgba(39/255,137/255,39/255,1)
lighter:Qt.rgba(75/255,156/255,75/255,1)
lightest:Qt.rgba(106/255,173/255,106/255,1)
}
}

View File

@ -1,10 +0,0 @@
pragma Singleton
import QtQuick 2.15
QtObject {
property FluColorSetOld primaryColor: FluColorsOld._Teal
}

View File

@ -20,18 +20,20 @@ Item {
property int maximumWidth
property int minimumHeight
property int maximumHeight
property int borderless:{
if(Window.window == null)
if(window === null)
return 4
if(Window.window.visibility === Window.Maximized){
return 0
}
return 4
}
default property alias content: container.children
FluWindowResize{}
default property alias content: container.data
FluWindowResize{
border:borderless
}
Behavior on opacity{
NumberAnimation{
@ -39,13 +41,17 @@ Item {
}
}
Rectangle{
color: FluTheme.isDark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
property color borerlessColor : FluTheme.isDark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
color: {
if(window === null)
return borerlessColor
return window.active ? borerlessColor : Qt.lighter(FluTheme.primaryColor.lightest,1.1)
}
border.width: 1
anchors.fill: parent
radius: 4
border.color:FluTheme.isDark ? Qt.darker(FluTheme.primaryColor.lighter,1.3) : Qt.lighter(FluTheme.primaryColor.dark,1.3)
border.color:FluTheme.isDark ? Qt.darker(FluTheme.primaryColor.lighter,1.3) : Qt.lighter(FluTheme.primaryColor.dark,1.2)
}
Rectangle{

View File

@ -4,13 +4,14 @@ import QtQuick.Window 2.15
MouseArea {
property int border: 4
property var window: Window.window
property bool fixedSize: {
if(Window.window == null)
if(window == null)
return true
if(Window.window.visibility === Window.Maximized || Window.window.visibility === Window.FullScreen){
if(window.visibility === Window.Maximized || window.visibility === Window.FullScreen){
return true
}
return (Window.window.minimumWidth === Window.window.maximumWidth && Window.window.minimumHeight === Window.window.maximumHeight)
return (window.minimumWidth === window.maximumWidth && window.minimumHeight === window.maximumHeight)
}
anchors.fill: parent

View File

@ -32,8 +32,5 @@
<file>controls/FluMenuItem.qml</file>
<file>controls/FluShadow.qml</file>
<file>controls/FluTextButton.qml</file>
<file>controls/FluColorSetOld.qml</file>
<file>controls/FluColorsOld.qml</file>
<file>controls/FluThemeOld.qml</file>
</qresource>
</RCC>