forked from Sepanta/console-emulator
17 changed files with 738 additions and 290 deletions
@ -1,4 +1,67 @@ |
|||||
#ifndef PROPERTY_H |
#ifndef PROPERTY_H |
||||
#define PROPERTY_H |
#define PROPERTY_H |
||||
|
|
||||
#endif // PROPERTY_H
|
#include <QObject> |
||||
|
#include <QDebug> |
||||
|
|
||||
|
//uncrustify off
|
||||
|
#define MVVM_PROPERTY(TYPE, NAME, DEFAULT_VALUE) \ |
||||
|
Q_PROPERTY(TYPE NAME READ NAME WRITE NAME NOTIFY NAME ## Changed ) \ |
||||
|
public: \ |
||||
|
TYPE NAME() const { return _ ## NAME ; } \ |
||||
|
void NAME(TYPE value) { \ |
||||
|
if (_ ## NAME == value) return; \ |
||||
|
_ ## NAME = value; \ |
||||
|
emit NAME ## Changed(value); \ |
||||
|
qDebug() << #NAME << value; \ |
||||
|
} \ |
||||
|
Q_SIGNAL void NAME ## Changed(TYPE value);\ |
||||
|
private: \ |
||||
|
TYPE _ ## NAME = DEFAULT_VALUE; \ |
||||
|
|
||||
|
/**************************************************************************************************/ |
||||
|
#define MVVM_PROPERTY_CUSTOM(TYPE, NAME, DEFAULT_VALUE) \ |
||||
|
Q_PROPERTY(TYPE NAME READ NAME WRITE NAME NOTIFY NAME ## Changed ) \ |
||||
|
public: \ |
||||
|
TYPE NAME() const { return _ ## NAME ; } \ |
||||
|
void NAME(TYPE value) { \ |
||||
|
if (_ ## NAME == value) return; \ |
||||
|
_ ## NAME = value; \ |
||||
|
emit NAME ## Changed(value); \ |
||||
|
NAME ## Handle(); \ |
||||
|
qDebug() << #NAME << value; \ |
||||
|
} \ |
||||
|
Q_SIGNAL void NAME ## Changed(TYPE value);\ |
||||
|
private: \ |
||||
|
TYPE _ ## NAME = DEFAULT_VALUE; \ |
||||
|
|
||||
|
/**************************************************************************************************/ |
||||
|
#define BUTTON_LED_PROPERTY(NAME, CAP_NAME, DEFAULT_VALUE, LED_DEF_VAL) \ |
||||
|
LED_PROPERTY(NAME, LED_DEF_VAL) \ |
||||
|
BUTTON_PROPERTY(NAME, CAP_NAME, DEFAULT_VALUE) |
||||
|
|
||||
|
/**************************************************************************************************/ |
||||
|
#define BUTTON_PROPERTY(NAME, CAP_NAME, DEFAULT_VALUE) \ |
||||
|
MVVM_PROPERTY_CUSTOM(bool, NAME, DEFAULT_VALUE) \ |
||||
|
void NAME ## Handle() { \ |
||||
|
if(_ ## NAME){ \ |
||||
|
panel->press ## CAP_NAME(); \ |
||||
|
} \ |
||||
|
else { \ |
||||
|
panel->release ## CAP_NAME(); \ |
||||
|
} \ |
||||
|
} \ |
||||
|
|
||||
|
/**************************************************************************************************/ |
||||
|
#define LED_PROPERTY(NAME, LED_DEF_VAL) \ |
||||
|
MVVM_PROPERTY(int, NAME ## Led, LED_DEF_VAL) \ |
||||
|
|
||||
|
/**************************************************************************************************/ |
||||
|
#define LED_SLOT(NAME) \ |
||||
|
void NAME ## LedHandle(char value) { \ |
||||
|
NAME ## Led(static_cast<int>(value)); \ |
||||
|
} \ |
||||
|
|
||||
|
//uncrustify on
|
||||
|
|
||||
|
#endif //PROPERTY_H
|
||||
|
@ -1,6 +1,20 @@ |
|||||
import QtQuick 2.10 |
import QtQuick 2.10 |
||||
|
import QtQuick.Window 2.13 |
||||
import de.skycoder42.QtMvvm.Quick 1.0 |
import de.skycoder42.QtMvvm.Quick 1.0 |
||||
|
import "qrc:/const/" |
||||
|
import "qrc:/theme/" |
||||
|
|
||||
QtMvvmApp { |
QtMvvmApp { |
||||
title: qsTr("consoleEmulator") |
title: qsTr("consoleEmulator") |
||||
|
id: mvvmApp |
||||
|
|
||||
|
onWidthChanged: Const.widthRatio = mvvmApp.width / Const.windowWidth |
||||
|
onHeightChanged: Const.heightRatio = mvvmApp.height / Const.windowHeight |
||||
|
|
||||
|
Component.onCompleted: { |
||||
|
width = Const.windowWidth |
||||
|
height = Const.windowHeight |
||||
|
x = (Screen.width - width) / 2 |
||||
|
y = (Screen.height - height) |
||||
|
} |
||||
} |
} |
||||
|
@ -1,70 +1,32 @@ |
|||||
import QtQuick 2.10 |
import QtQuick 2.10 |
||||
import QtQuick.Controls 2.3 |
import QtQuick.Controls 2.3 |
||||
|
import QtQuick.Window 2.13 |
||||
import QtQuick.Layouts 1.3 |
import QtQuick.Layouts 1.3 |
||||
import de.skycoder42.QtMvvm.Core 1.0 |
import de.skycoder42.QtMvvm.Core 1.0 |
||||
import de.skycoder42.QtMvvm.Quick 1.0 |
import de.skycoder42.QtMvvm.Quick 1.0 |
||||
import com.example.consoleemulator 1.0 |
import com.example.consoleemulator 1.0 |
||||
|
import "qrc:/emulator/" |
||||
|
import "qrc:/theme/" |
||||
|
import "qrc:/const/" |
||||
|
|
||||
Page { |
Page { |
||||
id: mainView |
id: mainView |
||||
property MainViewModel viewModel: null |
property MainViewModel viewModel: null |
||||
|
|
||||
header: ContrastToolBar { |
Rectangle{ |
||||
RowLayout { |
|
||||
anchors.fill: parent |
anchors.fill: parent |
||||
spacing: 0 |
color: Theme.current.background |
||||
|
|
||||
ToolBarLabel { |
|
||||
text: qsTr("MainViewModel") |
|
||||
Layout.fillWidth: true |
|
||||
} |
|
||||
|
|
||||
MenuButton { |
|
||||
MenuItem { |
|
||||
id: settings |
|
||||
text: qsTr("Settings") |
|
||||
onClicked: viewModel.showSettings() |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
PresenterProgress {} |
|
||||
|
|
||||
Pane { |
|
||||
anchors.fill: parent |
|
||||
|
|
||||
ColumnLayout { |
|
||||
anchors.fill: parent |
|
||||
|
|
||||
TextField { |
|
||||
id: textEdit |
|
||||
Layout.fillWidth: true |
|
||||
|
|
||||
MvvmBinding { |
|
||||
viewModel: mainView.viewModel |
|
||||
viewModelProperty: "text" |
|
||||
view: textEdit |
|
||||
viewProperty: "text" |
|
||||
} |
|
||||
} |
} |
||||
|
|
||||
Label { |
Rectangle { |
||||
id: textLabel |
id: correctedPosition |
||||
Layout.fillWidth: true |
width: Const.windowWidth |
||||
|
height: Const.windowHeight |
||||
|
scale: Const.ratio |
||||
|
color: Theme.current.background |
||||
|
x: (mainView.width - width) / 2 |
||||
|
y: (mainView.height - height) / 2 |
||||
|
|
||||
MvvmBinding { |
Emulator {} |
||||
viewModel: mainView.viewModel |
|
||||
viewModelProperty: "text" |
|
||||
view: textLabel |
|
||||
viewProperty: "text" |
|
||||
type: MvvmBinding.OneWayToView |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
Item { |
|
||||
Layout.fillHeight: true |
|
||||
} |
|
||||
} |
|
||||
} |
} |
||||
} |
} |
||||
|
@ -1,7 +1,127 @@ |
|||||
import QtQuick 2.0 |
import QtQuick 2.0 |
||||
|
|
||||
|
import de.skycoder42.QtMvvm.Core 1.0 |
||||
|
import de.skycoder42.QtMvvm.Quick 1.0 |
||||
|
import com.example.consoleemulator 1.0 |
||||
|
|
||||
import "qrc:/emulator/components" |
import "qrc:/emulator/components" |
||||
|
|
||||
Trackball { |
Trackball { |
||||
|
property bool leftPressed: leftDown |
||||
|
property bool rightPressed: rightDown |
||||
|
property bool topPressed: topDown |
||||
|
property bool bottomPressed: bottomDown |
||||
|
|
||||
|
property bool topLeftPressed: topLeftDown |
||||
|
property bool topRightPressed: topRightDown |
||||
|
property bool bottomLeftPressed: bottomLeftDown |
||||
|
property bool bottomRightPressed: bottomRightDown |
||||
|
|
||||
|
onLeftDownChanged: leftPressed = leftDown |
||||
|
onRightDownChanged: rightPressed = rightDown |
||||
|
onTopDownChanged: topPressed = topDown |
||||
|
onBottomDownChanged: bottomPressed = bottomDown |
||||
|
|
||||
|
onTopLeftDownChanged: topLeftPressed = topLeftDown |
||||
|
onTopRightDownChanged: topRightPressed = topRightDown |
||||
|
onBottomLeftDownChanged: bottomLeftPressed = bottomLeftDown |
||||
|
onBottomRightDownChanged: bottomRightPressed = bottomRightDown |
||||
|
|
||||
|
MvvmBinding { |
||||
|
viewModel: mainView.viewModel |
||||
|
viewProperty: "leftPressed" |
||||
|
viewModelProperty: "trackballLeft" |
||||
|
} |
||||
|
|
||||
|
MvvmBinding { |
||||
|
viewModel: mainView.viewModel |
||||
|
viewProperty: "rightPressed" |
||||
|
viewModelProperty: "trackballRight" |
||||
|
} |
||||
|
|
||||
|
MvvmBinding { |
||||
|
viewModel: mainView.viewModel |
||||
|
viewProperty: "topPressed" |
||||
|
viewModelProperty: "trackballTop" |
||||
|
} |
||||
|
|
||||
|
MvvmBinding { |
||||
|
viewModel: mainView.viewModel |
||||
|
viewProperty: "bottomPressed" |
||||
|
viewModelProperty: "trackballBottom" |
||||
|
} |
||||
|
|
||||
|
MvvmBinding { |
||||
|
viewModel: mainView.viewModel |
||||
|
viewProperty: "topLeftPressed" |
||||
|
viewModelProperty: "trackballTopLeft" |
||||
|
} |
||||
|
|
||||
|
MvvmBinding { |
||||
|
viewModel: mainView.viewModel |
||||
|
viewProperty: "topRightPressed" |
||||
|
viewModelProperty: "trackballTopRight" |
||||
|
} |
||||
|
|
||||
|
MvvmBinding { |
||||
|
viewModel: mainView.viewModel |
||||
|
viewProperty: "bottomLeftPressed" |
||||
|
viewModelProperty: "trackballBottomLeft" |
||||
|
} |
||||
|
|
||||
|
MvvmBinding { |
||||
|
viewModel: mainView.viewModel |
||||
|
viewProperty: "bottomRightPressed" |
||||
|
viewModelProperty: "trackballBottomRight" |
||||
|
} |
||||
|
|
||||
|
// Leds |
||||
|
|
||||
|
MvvmBinding { |
||||
|
viewModel: mainView.viewModel |
||||
|
viewProperty: "leftColor" |
||||
|
viewModelProperty: "trackballLeft" + "Led" |
||||
|
} |
||||
|
|
||||
|
MvvmBinding { |
||||
|
viewModel: mainView.viewModel |
||||
|
viewProperty: "rightColor" |
||||
|
viewModelProperty: "trackballRight" + "Led" |
||||
|
} |
||||
|
|
||||
|
MvvmBinding { |
||||
|
viewModel: mainView.viewModel |
||||
|
viewProperty: "topColor" |
||||
|
viewModelProperty: "trackballTop" + "Led" |
||||
|
} |
||||
|
|
||||
|
MvvmBinding { |
||||
|
viewModel: mainView.viewModel |
||||
|
viewProperty: "bottomColor" |
||||
|
viewModelProperty: "trackballBottom" + "Led" |
||||
|
} |
||||
|
|
||||
|
MvvmBinding { |
||||
|
viewModel: mainView.viewModel |
||||
|
viewProperty: "topLeftColor" |
||||
|
viewModelProperty: "trackballTopLeft" + "Led" |
||||
|
} |
||||
|
|
||||
|
MvvmBinding { |
||||
|
viewModel: mainView.viewModel |
||||
|
viewProperty: "topRightColor" |
||||
|
viewModelProperty: "trackballTopRight" + "Led" |
||||
|
} |
||||
|
|
||||
|
MvvmBinding { |
||||
|
viewModel: mainView.viewModel |
||||
|
viewProperty: "bottomLeftColor" |
||||
|
viewModelProperty: "trackballBottomLeft" + "Led" |
||||
|
} |
||||
|
|
||||
|
MvvmBinding { |
||||
|
viewModel: mainView.viewModel |
||||
|
viewProperty: "bottomRightColor" |
||||
|
viewModelProperty: "trackballBottomRight" + "Led" |
||||
|
} |
||||
} |
} |
||||
|
@ -1,44 +0,0 @@ |
|||||
import QtQuick 2.0 |
|
||||
import "qrc:/console/elements" |
|
||||
import "qrc:/ui" |
|
||||
|
|
||||
Item { |
|
||||
width: 290 * UI.ratio |
|
||||
height: 46 * UI.ratio |
|
||||
x: 1590 * UI.ratio |
|
||||
y: 510 * UI.ratio |
|
||||
|
|
||||
Row { |
|
||||
spacing: 10 * UI.ratio |
|
||||
|
|
||||
MiniButton { |
|
||||
name: "zoom" |
|
||||
image: "qrc:/ui/Images/miniButton/zoom.png" |
|
||||
} |
|
||||
|
|
||||
MiniButton { |
|
||||
name: "depth" |
|
||||
image: "qrc:/ui/Images/miniButton/depth.png" |
|
||||
} |
|
||||
|
|
||||
Item { |
|
||||
width: 10 * UI.ratio |
|
||||
height: 46 * UI.ratio |
|
||||
} |
|
||||
|
|
||||
MiniButton { |
|
||||
name: "angle" |
|
||||
image: "qrc:/ui/Images/miniButton/angle.png" |
|
||||
} |
|
||||
|
|
||||
MiniButton { |
|
||||
name: "focusZone" |
|
||||
image: "qrc:/ui/Images/miniButton/focusZone.png" |
|
||||
} |
|
||||
|
|
||||
MiniButton { |
|
||||
name: "focusDepth" |
|
||||
image: "qrc:/ui/Images/miniButton/focusDepth.png" |
|
||||
} |
|
||||
} |
|
||||
} |
|
Loading…
Reference in new issue