Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mobile UI] Introduce separate keypad fill modes (#297) #298

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions qml/ConfigPageEmulation.qml
Original file line number Diff line number Diff line change
Expand Up @@ -92,28 +92,42 @@ ColumnLayout {
font.pixelSize: TextMetrics.title2Size
Layout.topMargin: 10
Layout.bottomMargin: 5
visible: Emu.isMobile()
}

FBLabel {
Layout.maximumWidth: parent.width
wrapMode: Text.WordWrap
text: qsTr("Change the side of the keypad in landscape orientation.")
text: qsTr("Change the side of the keypad.")
font.pixelSize: TextMetrics.normalSize
visible: Emu.isMobile()
}

CheckBox {
text: qsTr("Left-handed mode")

checked: Emu.leftHanded
visible: Emu.isMobile()
onCheckedChanged: {
Emu.leftHanded = checked;
checked = Qt.binding(function() { return Emu.leftHanded; });
}
}

FBLabel {
Layout.maximumWidth: parent.width
wrapMode: Text.WordWrap
text: qsTr("Whether the keypad scrolls vertically in portrait orientation.")
font.pixelSize: TextMetrics.normalSize
}

CheckBox {
text: qsTr("Scrolling keypad")

checked: Emu.keypadFillMode === Emu.FillWidth
onCheckedChanged: {
Emu.keypadFillMode = checked ? Emu.FillWidth : Emu.ResizeToFit
checked = Qt.binding(function() { return Emu.keypadFillMode === Emu.FillWidth; });
}
}

Item {
Layout.fillHeight: true
}
Expand Down
16 changes: 16 additions & 0 deletions qml/MobileUIFront.qml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ GridLayout {
}
}

Item {
visible: Emu.keypadFillMode !== Emu.FillWidth
Layout.fillHeight: true
Layout.fillWidth: true
Layout.columnSpan: 2

Keypad {
id: keypad2
x: Emu.leftHanded ? 0 : parent.width - width
property double myScale: Math.min(parent.height/height, parent.width/width)
transform: Scale { origin.x: Emu.leftHanded ? 0 : keypad2.width; origin.y: 0; xScale: keypad2.myScale; yScale: keypad2.myScale }
}
}

Flickable {
id: controls

Expand All @@ -53,6 +67,7 @@ GridLayout {
contentHeight: keypad.height*controls.width/keypad.width + iosmargin.height
clip: true
pixelAligned: true
visible: Emu.keypadFillMode === Emu.FillWidth

Keypad {
id: keypad
Expand All @@ -79,6 +94,7 @@ GridLayout {
Layout.fillWidth: true
Layout.columnSpan: 2
color: keypad.color
visible: Emu.keypadFillMode === Emu.FillWidth
}

states: [ State {
Expand Down
14 changes: 14 additions & 0 deletions qmlbridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,20 @@ void QMLBridge::setDefaultKit(unsigned int id)
emit defaultKitChanged();
}

QMLBridge::KeypadFillMode QMLBridge::getKeypadFillMode()
{
return settings.value(QStringLiteral("keypadFillMode"), KeypadFillMode::FillWidth).value<KeypadFillMode>();
}

void QMLBridge::setKeypadFillMode(KeypadFillMode mode)
{
if(getKeypadFillMode() == mode)
return;

settings.setValue(QStringLiteral("keypadFillMode"), mode);
emit keypadFillModeChanged();
}

bool QMLBridge::getLeftHanded()
{
return settings.value(QStringLiteral("leftHanded"), false).toBool();
Expand Down
10 changes: 10 additions & 0 deletions qmlbridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ class QMLBridge : public QObject
explicit QMLBridge(QObject *parent = 0);
~QMLBridge();

enum KeypadFillMode {
FillWidth = 0,
ResizeToFit
};
Q_ENUM(KeypadFillMode);

Q_PROPERTY(unsigned int gdbPort READ getGDBPort WRITE setGDBPort NOTIFY gdbPortChanged)
Q_PROPERTY(bool gdbEnabled READ getGDBEnabled WRITE setGDBEnabled NOTIFY gdbEnabledChanged)
Q_PROPERTY(unsigned int rdbPort READ getRDBPort WRITE setRDBPort NOTIFY rdbPortChanged)
Expand All @@ -23,6 +29,7 @@ class QMLBridge : public QObject
Q_PROPERTY(bool autostart READ getAutostart WRITE setAutostart NOTIFY autostartChanged)
Q_PROPERTY(unsigned int defaultKit READ getDefaultKit WRITE setDefaultKit NOTIFY defaultKitChanged)
Q_PROPERTY(bool leftHanded READ getLeftHanded WRITE setLeftHanded NOTIFY leftHandedChanged)
Q_PROPERTY(KeypadFillMode keypadFillMode READ getKeypadFillMode WRITE setKeypadFillMode NOTIFY keypadFillModeChanged)
Q_PROPERTY(bool suspendOnClose READ getSuspendOnClose WRITE setSuspendOnClose NOTIFY suspendOnCloseChanged)
Q_PROPERTY(QString usbdir READ getUSBDir WRITE setUSBDir NOTIFY usbDirChanged)
Q_PROPERTY(QString version READ getVersion CONSTANT)
Expand Down Expand Up @@ -55,6 +62,8 @@ class QMLBridge : public QObject
bool getAutostart();
unsigned int getDefaultKit();
void setDefaultKit(unsigned int id);
KeypadFillMode getKeypadFillMode();
void setKeypadFillMode(KeypadFillMode mode);
bool getLeftHanded();
void setLeftHanded(bool e);
bool getSuspendOnClose();
Expand Down Expand Up @@ -146,6 +155,7 @@ public slots:
void autostartChanged();
void defaultKitChanged();
void leftHandedChanged();
void keypadFillModeChanged();
void suspendOnCloseChanged();
void usbDirChanged();
void isRunningChanged();
Expand Down