diff --git a/packages/omamobile-settings/PKGBUILD b/packages/omamobile-settings/PKGBUILD index a99e7a27a..28ab9ed7f 100644 --- a/packages/omamobile-settings/PKGBUILD +++ b/packages/omamobile-settings/PKGBUILD @@ -6,7 +6,7 @@ pkgdesc="Native mobile Settings framework and device information" arch=(aarch64 x86_64) url="https://github.com/derekross/omarchy-mobile" license=(MIT) -depends=(omarchy qt6-base qt6-declarative qt6-svg) +depends=(omarchy bash brightnessctl python qt6-base qt6-declarative qt6-svg) makedepends=(gcc make) checkdepends=(dbus python) diff --git a/packages/omamobile-settings/README.md b/packages/omamobile-settings/README.md index af3ae948d..4b4b88960 100644 --- a/packages/omamobile-settings/README.md +++ b/packages/omamobile-settings/README.md @@ -6,8 +6,13 @@ palette and a read-only About page. It shows the model, operating system, kernel architecture, memory, root-filesystem capacity and installed package versions. Unknown values remain unavailable. It opens from the desktop launcher. -This initial package contains the read-only foundation. Omarchy's existing tools -continue to provide settings changes. Network, wallpaper, app management and +This package contains the read-only foundation and one settings page, Display +(brightness and, where the monitor lists more than one, the refresh rate; the +refresh rate changes the running session only: turning the phone makes +auto-rotate apply the monitor's preferred mode again, and a session restart or a +reload of Hyprland's config does too). The page runs +`backends/display.sh` through a fixed-argument runner, with no shell string. +Omarchy's existing tools continue to provide the other settings changes. Network, wallpaper, app management and recording controls are separate future contributions with their own runtime contracts and tests; this catalog does not offer those routes. @@ -28,7 +33,7 @@ the implemented detail page directly. The application reads the current theme's colors.toml and observes atomic theme replacements. Rounded corners follow Hyprland's read-only decoration:rounding -option. It does not change compositor settings. A session D-Bus service handles +option. Apart from the Display page's live refresh rate it does not change compositor settings. A session D-Bus service handles repeat launches. Copyright 2026 Marsel Nenaj, MIT; see LICENSE. Extracted from my own native diff --git a/packages/omamobile-settings/app/DisplayPage.qml b/packages/omamobile-settings/app/DisplayPage.qml new file mode 100644 index 000000000..20609134d --- /dev/null +++ b/packages/omamobile-settings/app/DisplayPage.qml @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: MIT +import QtQuick +import QtQuick.Layouts +import "." +ColumnLayout { + id: page + spacing: 14 + property int brightness: -1 + property int refresh: -1 + property var rates: [] + property string status: qsTr("Reading the display...") + property bool busy: true + property int reqId: -1 + readonly property var levels: [10, 25, 50, 75, 100] + function apply(r) { + busy = false + if (r.error) { status = r.error; return } + if (r.brightness === undefined || r.refresh === undefined) { status = qsTr("The display backend gave no values."); return } + brightness = r.brightness; refresh = r.refresh; rates = r.rates || [] + status = rates.length > 1 ? qsTr("Tap a value; it applies at once. The refresh rate lasts until the phone is turned or the session restarts.") + : qsTr("Tap a value; it applies at once.") + } + Connections { target: actions; function onFinished(tool, r, id) { if (tool === "display" && id === page.reqId) page.apply(r) } } + Component.onCompleted: reqId = actions.run("display", ["get"]) + SettingsLabel { text: qsTr("Brightness"); font.weight: Font.DemiBold; color: backend.foreground; Layout.fillWidth: true } + Flow { + Layout.fillWidth: true; spacing: 8 + Repeater { + model: page.levels + delegate: SettingsButton { + required property int modelData + text: modelData + "%"; highlighted: page.brightness === modelData; enabled: !page.busy + onClicked: { page.busy = true; page.reqId = actions.run("display", ["set", "brightness", String(modelData)]) } + } + } + } + SettingsLabel { + visible: page.rates.length > 1 + text: qsTr("Refresh rate"); font.weight: Font.DemiBold; color: backend.foreground; Layout.fillWidth: true; Layout.topMargin: 8 + } + Flow { + visible: page.rates.length > 1 + Layout.fillWidth: true; spacing: 8 + Repeater { + model: page.rates + delegate: SettingsButton { + required property int modelData + text: modelData + " Hz"; highlighted: page.refresh === modelData; enabled: !page.busy + onClicked: { page.busy = true; page.reqId = actions.run("display", ["set", "refresh", String(modelData)]) } + } + } + } + SettingsLabel { text: page.status; color: backend.muted; font.pixelSize: SettingsStyle.fontPx(13); wrapMode: Text.Wrap; Layout.fillWidth: true } + Item { Layout.fillHeight: true } +} diff --git a/packages/omamobile-settings/app/Main.qml b/packages/omamobile-settings/app/Main.qml index ebf1da4ee..25a26417f 100644 --- a/packages/omamobile-settings/app/Main.qml +++ b/packages/omamobile-settings/app/Main.qml @@ -24,6 +24,8 @@ ApplicationWindow { if (backend.searching) search.clear() backend.back() } + readonly property var customPages: ({ display: "DisplayPage.qml" }) + readonly property string customSource: backend.searching ? "" : (customPages[backend.page] || "") readonly property bool showingAbout: backend.page === "about" && !backend.searching Connections { target: backend @@ -52,16 +54,17 @@ ApplicationWindow { id: search objectName: "settingsSearch" Layout.fillWidth: true; Layout.preferredHeight: 52 - visible: !window.showingAbout + visible: !window.showingAbout && window.customSource === "" placeholderText: qsTr("Search settings") color: backend.foreground; placeholderTextColor: backend.muted onTextEdited: backend.search(text) background: Rectangle { radius: Math.min(backend.radius, width / 2, height / 2); color: SettingsStyle.fill("normal") } } AboutPage { visible: window.showingAbout; Layout.fillWidth: true; Layout.fillHeight: true; controller: deviceInfo; colors: backend } + Loader { id: pageLoader; active: window.customSource !== ""; source: window.customSource; visible: active; Layout.fillWidth: true; Layout.fillHeight: true } ListView { id: list - visible: !window.showingAbout + visible: !window.showingAbout && window.customSource === "" Layout.fillWidth: true; Layout.fillHeight: true clip: true; model: backend.rows delegate: SettingsItemDelegate { diff --git a/packages/omamobile-settings/app/actionrunner.cpp b/packages/omamobile-settings/app/actionrunner.cpp new file mode 100644 index 000000000..a118095f2 --- /dev/null +++ b/packages/omamobile-settings/app/actionrunner.cpp @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: MIT +#include "actionrunner.h" +#include +#include +#include +#include +#include +#include +#include +#include + +// finished() is always emitted from the event loop, never before run() has returned its id. +void ActionRunner::post(const QString &tool, const QVariantMap &result, int id) { + QMetaObject::invokeMethod(this, [this, tool, result, id] { emit finished(tool, result, id); }, Qt::QueuedConnection); +} + +int ActionRunner::run(const QString &tool, const QStringList &args) { + static const QRegularExpression word("\\A[a-z0-9]{1,16}\\z"); + static const QStringList tools = {"display"}; + const int id = ++m_next; + auto fail = [this, &tool, id](const QString &why) { post(tool, {{"error", why}}, id); return id; }; + if (!tools.contains(tool) || args.size() > 3) return fail("unknown action"); + for (const auto &a : args) if (!word.match(a).hasMatch()) return fail("bad argument"); + const QString dir = "/usr/lib/omamobile-settings/backends"; + auto *p = new QProcess(this); + // bash would run a startup file named by these + auto env = QProcessEnvironment::systemEnvironment(); + env.remove("BASH_ENV"); + env.remove("ENV"); + p->setProcessEnvironment(env); + p->setProgram("/usr/bin/bash"); + p->setArguments(QStringList{dir + "/" + tool + ".sh"} + args); + connect(p, &QProcess::finished, this, [this, p, tool, id](int code, QProcess::ExitStatus st) { + const auto raw = p->readAllStandardOutput().left(4096); + p->readAllStandardError(); + auto obj = QJsonDocument::fromJson(raw).object(); + if (obj.isEmpty() || st != QProcess::NormalExit) + obj = QJsonObject{{"error", QStringLiteral("the backend failed (exit %1)").arg(code)}}; + post(tool, obj.toVariantMap(), id); + p->deleteLater(); + }); + connect(p, &QProcess::errorOccurred, this, [this, p, tool, id](QProcess::ProcessError e) { + if (e == QProcess::FailedToStart) { post(tool, {{"error", "cannot start the backend"}}, id); p->deleteLater(); } + }); + p->start(); + p->closeWriteChannel(); + QTimer::singleShot(20000, p, [p] { if (p->state() != QProcess::NotRunning) p->kill(); }); + return id; +} diff --git a/packages/omamobile-settings/app/actionrunner.h b/packages/omamobile-settings/app/actionrunner.h new file mode 100644 index 000000000..e56a52234 --- /dev/null +++ b/packages/omamobile-settings/app/actionrunner.h @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT +#pragma once +#include +#include +#include + +// Runs the source-owned backend scripts (display) with a fixed argument list and no shell. Pages call run(); +// the JSON the script prints comes back through finished(), always from the event loop and never before run() +// has returned its id. +class ActionRunner : public QObject { + Q_OBJECT +public: + explicit ActionRunner(QObject *parent = nullptr) : QObject(parent) {} + Q_INVOKABLE int run(const QString &tool, const QStringList &args); +signals: + void finished(const QString &tool, const QVariantMap &result, int id); +private: + void post(const QString &tool, const QVariantMap &result, int id); + int m_next = 0; +}; diff --git a/packages/omamobile-settings/app/catalog.json b/packages/omamobile-settings/app/catalog.json index 9cd019e4f..23efec22b 100644 --- a/packages/omamobile-settings/app/catalog.json +++ b/packages/omamobile-settings/app/catalog.json @@ -2,6 +2,13 @@ "root": { "title": "Settings", "rows": [ + { + "id": "display", + "title": "Display", + "detail": "Brightness and refresh rate", + "icon": "display", + "page": "display" + }, { "id": "about", "title": "About this device", @@ -14,5 +21,9 @@ "about": { "title": "About this device", "rows": [] + }, + "display": { + "title": "Display", + "rows": [] } } diff --git a/packages/omamobile-settings/app/icons/display.svg b/packages/omamobile-settings/app/icons/display.svg new file mode 100644 index 000000000..27abb70ce --- /dev/null +++ b/packages/omamobile-settings/app/icons/display.svg @@ -0,0 +1 @@ + diff --git a/packages/omamobile-settings/app/main.cpp b/packages/omamobile-settings/app/main.cpp index 5848e68ca..ab0826a12 100644 --- a/packages/omamobile-settings/app/main.cpp +++ b/packages/omamobile-settings/app/main.cpp @@ -2,6 +2,7 @@ // Copyright (c) 2026 Marsel Nenaj #include "backend.h" #include "deviceinfocontroller.h" +#include "actionrunner.h" #include #include #include @@ -62,9 +63,11 @@ int main(int argc, char **argv) { if (!bus.registerObject("/Settings", &backend, QDBusConnection::ExportScriptableSlots | QDBusConnection::ExportScriptableInvokables)) return 1; } + ActionRunner actions; QQmlApplicationEngine engine; engine.rootContext()->setContextProperty("backend", &backend); engine.rootContext()->setContextProperty("deviceInfo", &deviceInfo); + engine.rootContext()->setContextProperty("actions", &actions); engine.load(QUrl("qrc:/Main.qml")); if (engine.rootObjects().isEmpty()) return 1; return app.exec(); diff --git a/packages/omamobile-settings/app/resources.qrc b/packages/omamobile-settings/app/resources.qrc index 7d3fb01f4..0f18d70dc 100644 --- a/packages/omamobile-settings/app/resources.qrc +++ b/packages/omamobile-settings/app/resources.qrc @@ -3,6 +3,8 @@ Main.qml AboutPage.qml + DisplayPage.qml + icons/display.svg catalog.json icons/system.svg SettingsStyle.qml diff --git a/packages/omamobile-settings/backends/display.sh b/packages/omamobile-settings/backends/display.sh new file mode 100755 index 000000000..68090ed0a --- /dev/null +++ b/packages/omamobile-settings/backends/display.sh @@ -0,0 +1,107 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# Display settings for the Settings app: brightness (the backlight, through brightnessctl, on the device +# omarchy-hw-display names like the shell does) and the refresh rate (applied live through +# `hyprctl eval hl.monitor{...}` with the monitor's own name, size, position, scale and transform). +# Prints one line of JSON. +# display.sh get {"brightness":50,"refresh":120,"rates":[60,120]} +# display.sh set brightness N N is 10, 25, 50, 75 or 100 (never below 10, so the screen cannot go black) +# display.sh set refresh N N must be one of the rates the monitor lists at its current size +# The rates are the monitor's own availableModes at its current width and height. The change is live only: turning the phone +# (omamobile-sensors' auto-rotate applies the monitor's preferred mode again each time), a restart of the +# session or a reload of Hyprland's config sets the configured mode again. The monitor is the +# built-in panel (DSI-* or eDP-*), else the only one, else the focused one. Without a monitor the brightness +# still works and "refresh" reads -1 with no rates. +# The test runs a copy of this script with `fake` set to a file holding the brightness (a number) and the monitor +# JSON (two lines): no tool is run then. Nothing in the environment sets it. +set -euo pipefail +set +x +verb=${1:-}; key=${2:-}; value=${3:-} +fail() { printf '{"error":"%s"}\n' "$1"; exit 2; } +fake='' +[[ -z $fake || -r $fake ]] || fail "cannot read the test file" + +get_brightness() { + local v dev + if [[ -n $fake ]]; then v=$(sed -n 1p "$fake") + else + dev=$(omarchy-hw-display 2>/dev/null || true) + if [[ -n $dev ]]; then v=$(brightnessctl -d "$dev" -m 2>/dev/null | head -n1 | awk -F, '{gsub("%","",$4); print $4}') + else v=$(brightnessctl --class=backlight -m 2>/dev/null | head -n1 | awk -F, '{gsub("%","",$4); print $4}'); fi + fi + [[ $v =~ ^[0-9]+$ ]] || return 1 + echo "$v" +} +set_brightness() { + local dev + dev=$(omarchy-hw-display 2>/dev/null || true) + if [[ -n $dev ]]; then brightnessctl -d "$dev" --quiet set "${1}%" >/dev/null 2>&1 + else brightnessctl --class=backlight --quiet set "${1}%" >/dev/null 2>&1; fi +} +monitors_json() { + if [[ -n $fake ]]; then sed -n 2p "$fake"; else hyprctl monitors -j 2>/dev/null; fi +} +# prints: name width height x y scale transform refresh rates(comma separated); fails on anything odd, so +# nothing unchecked reaches the eval below +mon_info() { + monitors_json | /usr/bin/python3 -I -c ' +import sys, json, re +ms = json.load(sys.stdin) +pick = [m for m in ms if re.match(r"(DSI|eDP)-", m.get("name", ""))] +if not pick and len(ms) == 1: pick = ms +if not pick: pick = [m for m in ms if m.get("focused")] +m = pick[0] +w, h, x, y = (int(m[k]) for k in ("width", "height", "x", "y")) +name = m["name"] +scale = float(m["scale"]) +transform = int(m.get("transform", 0)) +if not re.fullmatch(r"[A-Za-z0-9_.-]{1,32}", name) or not 0 <= transform <= 7: raise SystemExit(1) +rates = set() +for mode in m.get("availableModes", []): + size, _, hz = mode.partition("@") + if size == "%dx%d" % (w, h): + try: + rates.add(int(round(float(hz.rstrip("Hz"))))) + except ValueError: + pass # a mode this parser does not know is left out +cur = int(round(float(m["refreshRate"]))) +rates.add(cur) +print(name, w, h, x, y, "%g" % scale, transform, cur, ",".join(str(r) for r in sorted(rates)))' 2>/dev/null +} +read_all() { + bright=$(get_brightness) || fail "cannot read the backlight" + if ! read -r name w h x y scale transform refresh rates < <(mon_info); then + name=""; refresh=-1; rates="" + fi +} +out() { printf '{"brightness":%s,"refresh":%s,"rates":[%s]}\n' "$bright" "$refresh" "$rates"; } + +case $verb in +get) + read_all; out ;; +set) + read_all + case $key in + brightness) + case $value in 10|25|50|75|100) ;; *) fail "bad value" ;; esac + if [[ -z $fake ]]; then set_brightness "$value" || fail "could not set the brightness"; fi + bright=$value ;; + refresh) + [[ $value =~ ^[0-9]{1,3}$ ]] || fail "bad value" + [[ -n $name ]] || fail "cannot read the monitor" + [[ ,$rates, == *",$value,"* ]] || fail "this display does not list that rate" + if [[ -z $fake ]]; then + res=$(hyprctl eval "hl.monitor({ output = \"$name\", mode = \"${w}x${h}@${value}\", position = \"${x}x${y}\", scale = $scale, transform = $transform })" 2>&1) \ + || fail "the screen did not accept the change" + [[ ${res,,} != *error* ]] || fail "the screen did not accept the change" + sleep 1 + read -r name w h x y scale transform refresh rates < <(mon_info) || fail "cannot read the monitor" + else + refresh=$value + fi ;; + *) fail "unknown key" ;; + esac + out ;; +*) + fail "usage: get|set" ;; +esac diff --git a/packages/omamobile-settings/install b/packages/omamobile-settings/install index 9458d0709..2963f0a8b 100755 --- a/packages/omamobile-settings/install +++ b/packages/omamobile-settings/install @@ -10,3 +10,4 @@ install -Dm755 "$build_dir/omamobile-settings" "$dest/usr/bin/omamobile-settings install -Dm644 "$source_dir/org.omamobile.Settings.desktop" "$dest/usr/share/applications/org.omamobile.Settings.desktop" install -Dm644 "$source_dir/org.omamobile.Settings.svg" "$dest/usr/share/icons/hicolor/scalable/apps/org.omamobile.Settings.svg" install -Dm644 "$source_dir/LICENSE" "$dest/usr/share/licenses/omamobile-settings/LICENSE" +install -Dm755 "$source_dir/backends/display.sh" "$dest/usr/lib/omamobile-settings/backends/display.sh" diff --git a/packages/omamobile-settings/omamobile-settings.pro b/packages/omamobile-settings/omamobile-settings.pro index b4e55810f..a06eeff4a 100644 --- a/packages/omamobile-settings/omamobile-settings.pro +++ b/packages/omamobile-settings/omamobile-settings.pro @@ -4,8 +4,8 @@ CONFIG += c++17 release no_include_pwd TEMPLATE = app TARGET = omamobile-settings INCLUDEPATH += $$PWD/app -HEADERS += app/backend.h app/deviceinfocontroller.h -SOURCES += app/main.cpp app/backend.cpp app/deviceinfocontroller.cpp +HEADERS += app/backend.h app/deviceinfocontroller.h app/actionrunner.h +SOURCES += app/main.cpp app/backend.cpp app/deviceinfocontroller.cpp app/actionrunner.cpp RESOURCES += app/resources.qrc include(version.pri) diff --git a/packages/omamobile-settings/test/all b/packages/omamobile-settings/test/all index 1d2ca963d..d0c6618eb 100755 --- a/packages/omamobile-settings/test/all +++ b/packages/omamobile-settings/test/all @@ -4,6 +4,7 @@ set -eu source_dir=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) build_dir=${OMAMOBILE_SETTINGS_TEST_BUILD_DIR:-"$source_dir/build/tests"} "$source_dir/bin/build" +"$source_dir/test/display-backend.sh" mkdir -p "$build_dir" fixture=$(mktemp -d) trap 'rm -rf -- "$fixture"' EXIT HUP INT TERM diff --git a/packages/omamobile-settings/test/display-backend.sh b/packages/omamobile-settings/test/display-backend.sh new file mode 100755 index 000000000..83a61ec96 --- /dev/null +++ b/packages/omamobile-settings/test/display-backend.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# backends/display.sh against a fake brightness and monitor, in a copy of the script with `fake` set: no tool is run. +set -euo pipefail +src=$(CDPATH='' cd -- "$(dirname -- "$0")/.." && pwd) +tmp=$(mktemp -d); trap 'rm -rf -- "$tmp"' EXIT +fake=$tmp/fake +cat > "$fake" <<'EOT' +50 +[{"name":"DSI-1","width":1344,"height":2992,"x":0,"y":0,"scale":3.2,"refreshRate":120.000,"availableModes":["1344x2992@120.00Hz","1344x2992@60.00Hz","1008x2244@120.00Hz"]}] +EOT +sed "s|^fake=.*|fake=$fake|" "$src/backends/display.sh" > "$tmp/display.sh" +grep -q "^fake=$fake" "$tmp/display.sh" +run() { bash "$tmp/display.sh" "$@" || true; } +eq() { [[ $1 == "$2" ]] || { echo "FAIL: got $1, want $2" >&2; exit 1; }; } + +eq "$(run get)" '{"brightness":50,"refresh":120,"rates":[60,120]}' +eq "$(run set brightness 25)" '{"brightness":25,"refresh":120,"rates":[60,120]}' +eq "$(run set brightness 5)" '{"error":"bad value"}' +eq "$(run set brightness 101)" '{"error":"bad value"}' +eq "$(run set refresh 60)" '{"brightness":50,"refresh":60,"rates":[60,120]}' +eq "$(run set refresh 90)" '{"error":"this display does not list that rate"}' +eq "$(run set refresh abc)" '{"error":"bad value"}' +eq "$(run set night on)" '{"error":"unknown key"}' +eq "$(run nonsense)" '{"error":"usage: get|set"}' + +# one rate only: the page hides the refresh rate buttons +sed -i '2s/.*/[{"name":"HDMI-A-1","width":1920,"height":1080,"x":0,"y":0,"scale":1,"refreshRate":60.0,"availableModes":["1920x1080@60.00Hz"]}]/' "$fake" +eq "$(run get)" '{"brightness":50,"refresh":60,"rates":[60]}' +# two monitors: the built-in panel is picked +sed -i '2s/.*/[{"name":"HDMI-A-1","width":1920,"height":1080,"x":0,"y":0,"scale":1,"refreshRate":60.0,"availableModes":["1920x1080@60.00Hz"]},{"name":"DSI-1","width":1344,"height":2992,"x":0,"y":0,"scale":3.2,"transform":1,"refreshRate":120.0,"availableModes":["1344x2992@120.00Hz","1344x2992@60.00Hz"]}]/' "$fake" +eq "$(run get)" '{"brightness":50,"refresh":120,"rates":[60,120]}' +# two external monitors and none focused: no monitor, but the brightness still works +sed -i '2s/.*/[{"name":"A-1","width":1,"height":1,"x":0,"y":0,"scale":1,"refreshRate":60.0},{"name":"B-1","width":1,"height":1,"x":0,"y":0,"scale":1,"refreshRate":60.0}]/' "$fake" +eq "$(run get)" '{"brightness":50,"refresh":-1,"rates":[]}' +eq "$(run set brightness 75)" '{"brightness":75,"refresh":-1,"rates":[]}' +eq "$(run set refresh 60)" '{"error":"cannot read the monitor"}' +# a monitor name that is not a plain connector name never reaches hyprctl +sed -i '2s/.*/[{"name":"X\"-1","width":1,"height":1,"x":0,"y":0,"scale":1,"refreshRate":60.0}]/' "$fake" +eq "$(run set refresh 60)" '{"error":"cannot read the monitor"}' +# one odd mode string does not take the others down +sed -i '2s/.*/[{"name":"DSI-1","width":1344,"height":2992,"x":0,"y":0,"scale":3.2,"refreshRate":120.0,"availableModes":["1344x2992@odd","1344x2992@60.00Hz","1344x2992@120.00Hz"]}]/' "$fake" +eq "$(run get)" '{"brightness":50,"refresh":120,"rates":[60,120]}' +# the monitor query failing leaves the brightness working +sed -i '2s/.*/not json/' "$fake" +eq "$(run get)" '{"brightness":50,"refresh":-1,"rates":[]}' +echo "display backend: ok" diff --git a/packages/omamobile-settings/tests/core_tests.cpp b/packages/omamobile-settings/tests/core_tests.cpp index 67fefaf8b..e8e0a2e77 100644 --- a/packages/omamobile-settings/tests/core_tests.cpp +++ b/packages/omamobile-settings/tests/core_tests.cpp @@ -18,7 +18,7 @@ private slots: void navigationRejectsUnknownAndHiddenActions() { Backend backend; QVERIFY(backend.catalogProblems().isEmpty()); - QCOMPARE(backend.rows().size(), 1); + QCOMPARE(backend.rows().size(), 2); QVERIFY(!backend.navigate("recording")); backend.activate("arbitrary-command"); QCOMPARE(backend.page(), QString("root")); @@ -29,10 +29,20 @@ private slots: backend.back(); QCOMPARE(backend.page(), QString("root")); } + void displayPageGoesBackToRoot() { + Backend backend; + QVERIFY(backend.navigate("display")); + QCOMPARE(backend.page(), QString("display")); + backend.back(); + QCOMPARE(backend.page(), QString("root")); + } void searchHasOnlyImplementedRoutesAndBackClearsIt() { Backend backend; backend.search("STORAGE"); QCOMPARE(backend.rows().size(), 1); + backend.search("brightness"); + QCOMPARE(backend.rows().size(), 1); + QCOMPARE(backend.rows().first().toMap()["id"].toString(), QString("display")); QVERIFY(backend.searching()); backend.back(); QVERIFY(!backend.searching()); diff --git a/packages/omamobile-settings/tests/session_app.pro b/packages/omamobile-settings/tests/session_app.pro index 64b50dec5..f1e538b50 100644 --- a/packages/omamobile-settings/tests/session_app.pro +++ b/packages/omamobile-settings/tests/session_app.pro @@ -5,7 +5,7 @@ TEMPLATE = app TARGET = settings-session-test-app INCLUDEPATH += ../app DEFINES += OMAMOBILE_SETTINGS_TEST_DEVICE_INFO -HEADERS += ../app/backend.h ../app/deviceinfocontroller.h -SOURCES += ../app/main.cpp ../app/backend.cpp ../app/deviceinfocontroller.cpp +HEADERS += ../app/backend.h ../app/deviceinfocontroller.h ../app/actionrunner.h +SOURCES += ../app/main.cpp ../app/backend.cpp ../app/deviceinfocontroller.cpp ../app/actionrunner.cpp RESOURCES += ../app/resources.qrc include(../version.pri) diff --git a/packages/omamobile-settings/version b/packages/omamobile-settings/version index 17e51c385..d917d3e26 100644 --- a/packages/omamobile-settings/version +++ b/packages/omamobile-settings/version @@ -1 +1 @@ -0.1.1 +0.1.2