Merge branch 'master' into chore/statusradiobutton
This commit is contained in:
commit
afc16b4216
|
@ -89,4 +89,7 @@ GridLayout {
|
||||||
StatusRadioButton {
|
StatusRadioButton {
|
||||||
text: "i'm radio!"
|
text: "i'm radio!"
|
||||||
}
|
}
|
||||||
|
StatusSwitch {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,12 @@ import QtQuick 2.14
|
||||||
import QtQuick.Window 2.14
|
import QtQuick.Window 2.14
|
||||||
import QtQuick.Controls 2.14
|
import QtQuick.Controls 2.14
|
||||||
|
|
||||||
|
import Sandbox 0.1
|
||||||
|
|
||||||
import StatusQ.Core 0.1
|
import StatusQ.Core 0.1
|
||||||
import StatusQ.Core.Theme 0.1
|
import StatusQ.Core.Theme 0.1
|
||||||
|
|
||||||
Window {
|
StatusWindow {
|
||||||
id: rootWindow
|
id: rootWindow
|
||||||
width: 1024
|
width: 1024
|
||||||
height: 840
|
height: 840
|
||||||
|
|
|
@ -12,7 +12,7 @@ SOURCES += \
|
||||||
sandboxapp.cpp
|
sandboxapp.cpp
|
||||||
|
|
||||||
OBJECTIVE_SOURCES += \
|
OBJECTIVE_SOURCES += \
|
||||||
sandboxapp_mac.mm
|
statuswindow_mac.mm
|
||||||
|
|
||||||
RESOURCES += qml.qrc
|
RESOURCES += qml.qrc
|
||||||
|
|
||||||
|
@ -28,10 +28,12 @@ OTHER_FILES += $$files($$PWD/../src/*, true)
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
handler.h \
|
handler.h \
|
||||||
sandboxapp.h
|
sandboxapp.h \
|
||||||
|
statuswindow.h
|
||||||
|
|
||||||
DISTFILES += \
|
DISTFILES += \
|
||||||
../src/StatusQ/Controls/StatusBaseButton.qml \
|
../src/StatusQ/Controls/StatusBaseButton.qml \
|
||||||
../src/StatusQ/Controls/StatusButton.qml \
|
../src/StatusQ/Controls/StatusButton.qml \
|
||||||
../src/StatusQ/Controls/StatusFlatRoundButton.qml \
|
../src/StatusQ/Controls/StatusFlatRoundButton.qml \
|
||||||
../src/StatusQ/Controls/StatusRadioButton.qml
|
../src/StatusQ/Controls/StatusRadioButton.qml \
|
||||||
|
../src/StatusQ/Controls/StatusSwitch.qml
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
#include <QWindow>
|
#include <QWindow>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include "statuswindow.h"
|
||||||
|
|
||||||
SandboxApp::SandboxApp(int &argc, char **argv)
|
SandboxApp::SandboxApp(int &argc, char **argv)
|
||||||
: QGuiApplication(argc, argv),
|
: QGuiApplication(argc, argv),
|
||||||
m_handler(new Handler(this))
|
m_handler(new Handler(this))
|
||||||
|
@ -13,6 +15,8 @@ SandboxApp::SandboxApp(int &argc, char **argv)
|
||||||
|
|
||||||
void SandboxApp::startEngine()
|
void SandboxApp::startEngine()
|
||||||
{
|
{
|
||||||
|
qmlRegisterType<StatusWindow>("Sandbox", 0, 1, "StatusWindow");
|
||||||
|
|
||||||
const QUrl url(applicationDirPath() + "/../main.qml");
|
const QUrl url(applicationDirPath() + "/../main.qml");
|
||||||
|
|
||||||
m_engine.rootContext()->setContextProperty("app", m_handler);
|
m_engine.rootContext()->setContextProperty("app", m_handler);
|
||||||
|
@ -25,13 +29,6 @@ void SandboxApp::startEngine()
|
||||||
QCoreApplication::exit(-1);
|
QCoreApplication::exit(-1);
|
||||||
}, Qt::QueuedConnection);
|
}, Qt::QueuedConnection);
|
||||||
m_engine.load(url);
|
m_engine.load(url);
|
||||||
|
|
||||||
QWindow *rootWindow = qobject_cast<QWindow*>(m_engine.rootObjects().at(0));
|
|
||||||
if (rootWindow) {
|
|
||||||
removeTitleBar(rootWindow->winId());
|
|
||||||
} else {
|
|
||||||
qDebug() << "Window doesn't exist";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SandboxApp::restartEngine()
|
void SandboxApp::restartEngine()
|
||||||
|
|
|
@ -13,8 +13,6 @@ public:
|
||||||
|
|
||||||
void startEngine();
|
void startEngine();
|
||||||
|
|
||||||
void removeTitleBar(WId wid);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void restartEngine();
|
void restartEngine();
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
#ifndef STATUSWINDOW_H
|
||||||
|
#define STATUSWINDOW_H
|
||||||
|
|
||||||
|
#include <QQuickWindow>
|
||||||
|
|
||||||
|
class StatusWindow: public QQuickWindow
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit StatusWindow(QWindow *parent = nullptr)
|
||||||
|
: QQuickWindow(parent)
|
||||||
|
{
|
||||||
|
removeTitleBar(winId());
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void removeTitleBar(WId wid);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // STATUSWINDOW_H
|
|
@ -1,4 +1,4 @@
|
||||||
#include "sandboxapp.h"
|
#include "statuswindow.h"
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
||||||
#include <AppKit/NSWindow.h>
|
#include <AppKit/NSWindow.h>
|
||||||
#include <AppKit/NSColor.h>
|
#include <AppKit/NSColor.h>
|
||||||
|
|
||||||
void SandboxApp::removeTitleBar(WId wid)
|
void StatusWindow::removeTitleBar(WId wid)
|
||||||
{
|
{
|
||||||
NSView *nsView = reinterpret_cast<NSView*>(wid);
|
NSView *nsView = reinterpret_cast<NSView*>(wid);
|
||||||
NSWindow *window = [nsView window];
|
NSWindow *window = [nsView window];
|
|
@ -0,0 +1,66 @@
|
||||||
|
import QtQuick 2.12
|
||||||
|
import QtQuick.Controls 2.14
|
||||||
|
import QtGraphicalEffects 1.14
|
||||||
|
import StatusQ.Core 0.1
|
||||||
|
import StatusQ.Core.Theme 0.1
|
||||||
|
import StatusQ.Components 0.1
|
||||||
|
|
||||||
|
Switch {
|
||||||
|
id: statusSwitch
|
||||||
|
|
||||||
|
indicator: Rectangle {
|
||||||
|
id: oval
|
||||||
|
implicitWidth: 52
|
||||||
|
implicitHeight: 28
|
||||||
|
x: statusSwitch.leftPadding
|
||||||
|
y: parent.height / 2 - height / 2
|
||||||
|
radius: 14
|
||||||
|
color: statusSwitch.checked ? Theme.palette.primaryColor1
|
||||||
|
: Theme.palette.directColor8
|
||||||
|
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: circle
|
||||||
|
y: 4
|
||||||
|
width: 20
|
||||||
|
height: 20
|
||||||
|
radius: 10
|
||||||
|
color: Theme.palette.white
|
||||||
|
layer.enabled: true
|
||||||
|
layer.effect: DropShadow {
|
||||||
|
width: parent.width
|
||||||
|
height: parent.height
|
||||||
|
visible: true
|
||||||
|
verticalOffset: 1
|
||||||
|
fast: true
|
||||||
|
cached: true
|
||||||
|
color: Theme.palette.dropShadow
|
||||||
|
}
|
||||||
|
|
||||||
|
states: [
|
||||||
|
State {
|
||||||
|
name: "on"
|
||||||
|
when: statusSwitch.checked
|
||||||
|
PropertyChanges { target: circle; x: oval.width - circle.width - 4 }
|
||||||
|
},
|
||||||
|
State {
|
||||||
|
name: "off"
|
||||||
|
when: !statusSwitch.checked
|
||||||
|
PropertyChanges { target: circle; x: 4 }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
transitions: Transition {
|
||||||
|
reversible: true
|
||||||
|
NumberAnimation { properties: "x"; easing.type: Easing.Linear; duration: 120; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contentItem: StatusBaseText {
|
||||||
|
text: statusSwitch.text
|
||||||
|
opacity: enabled ? 1.0 : 0.3
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
leftPadding: !!statusSwitch.text ? statusSwitch.indicator.width + statusSwitch.spacing : statusSwitch.indicator.width
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,3 +9,4 @@ StatusFlatButton 0.1 StatusFlatButton.qml
|
||||||
StatusRoundButton 0.1 StatusRoundButton.qml
|
StatusRoundButton 0.1 StatusRoundButton.qml
|
||||||
StatusFlatRoundButton 0.1 StatusFlatRoundButton.qml
|
StatusFlatRoundButton 0.1 StatusFlatRoundButton.qml
|
||||||
StatusRadioButton 0.1 StatusRadioButton.qml
|
StatusRadioButton 0.1 StatusRadioButton.qml
|
||||||
|
StatusSwitch 0.1 StatusSwitch.qml
|
||||||
|
|
|
@ -25,6 +25,8 @@ QtObject {
|
||||||
property color black: getColor('black')
|
property color black: getColor('black')
|
||||||
property color white: getColor('white')
|
property color white: getColor('white')
|
||||||
|
|
||||||
|
property color dropShadow: getColor('black', 0.12)
|
||||||
|
|
||||||
property color baseColor1
|
property color baseColor1
|
||||||
property color baseColor2
|
property color baseColor2
|
||||||
property color baseColor3
|
property color baseColor3
|
||||||
|
|
Loading…
Reference in New Issue