mirror of
https://invent.kde.org/marcoa/a-la-karte.git
synced 2026-03-27 01:03:09 +00:00
feat: add --couch-mode and --desktop-mode CLI flags
Config::setCliUiMode() stores a session-only override in a static before the QML engine creates App/Config. uiMode() checks the static first; save() always writes m_uiMode so the override never persists.
This commit is contained in:
parent
f360ebe278
commit
a1e9ce73cd
3 changed files with 23 additions and 0 deletions
|
|
@ -6,6 +6,13 @@
|
||||||
#include <KConfigGroup>
|
#include <KConfigGroup>
|
||||||
#include <KSharedConfig>
|
#include <KSharedConfig>
|
||||||
|
|
||||||
|
int Config::s_cliUiMode = -1;
|
||||||
|
|
||||||
|
void Config::setCliUiMode(UiMode mode)
|
||||||
|
{
|
||||||
|
s_cliUiMode = static_cast<int>(mode);
|
||||||
|
}
|
||||||
|
|
||||||
Config::Config(QObject *parent)
|
Config::Config(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
|
|
@ -28,6 +35,8 @@ void Config::setViewMode(ViewMode mode)
|
||||||
|
|
||||||
Config::UiMode Config::uiMode() const
|
Config::UiMode Config::uiMode() const
|
||||||
{
|
{
|
||||||
|
if (s_cliUiMode >= 0)
|
||||||
|
return static_cast<UiMode>(s_cliUiMode);
|
||||||
return m_uiMode;
|
return m_uiMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -125,6 +125,8 @@ public:
|
||||||
bool mirrorNotifications() const;
|
bool mirrorNotifications() const;
|
||||||
void setMirrorNotifications(bool mirror);
|
void setMirrorNotifications(bool mirror);
|
||||||
|
|
||||||
|
static void setCliUiMode(UiMode mode);
|
||||||
|
|
||||||
Q_INVOKABLE void save();
|
Q_INVOKABLE void save();
|
||||||
Q_INVOKABLE void load();
|
Q_INVOKABLE void load();
|
||||||
Q_INVOKABLE void resetToDefaults();
|
Q_INVOKABLE void resetToDefaults();
|
||||||
|
|
@ -158,6 +160,8 @@ Q_SIGNALS:
|
||||||
void mirrorNotificationsChanged();
|
void mirrorNotificationsChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static int s_cliUiMode;
|
||||||
|
|
||||||
ViewMode m_viewMode = GridView;
|
ViewMode m_viewMode = GridView;
|
||||||
UiMode m_uiMode = Auto;
|
UiMode m_uiMode = Auto;
|
||||||
int m_gridSize = 180;
|
int m_gridSize = 180;
|
||||||
|
|
|
||||||
10
src/main.cpp
10
src/main.cpp
|
|
@ -66,12 +66,22 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
const QCommandLineOption quitOnCloseOption(QStringLiteral("quit-on-close"), i18n("Quit when the main window is closed"));
|
const QCommandLineOption quitOnCloseOption(QStringLiteral("quit-on-close"), i18n("Quit when the main window is closed"));
|
||||||
const QCommandLineOption closeToTrayOption(QStringLiteral("close-to-tray"), i18n("Hide the main window to the system tray when closed"));
|
const QCommandLineOption closeToTrayOption(QStringLiteral("close-to-tray"), i18n("Hide the main window to the system tray when closed"));
|
||||||
|
const QCommandLineOption couchModeOption(QStringLiteral("couch-mode"), i18n("Start in couch/TV mode (full-screen console UI)"));
|
||||||
|
const QCommandLineOption desktopModeOption(QStringLiteral("desktop-mode"), i18n("Start in desktop mode (windowed UI with sidebar)"));
|
||||||
parser.addOption(quitOnCloseOption);
|
parser.addOption(quitOnCloseOption);
|
||||||
parser.addOption(closeToTrayOption);
|
parser.addOption(closeToTrayOption);
|
||||||
|
parser.addOption(couchModeOption);
|
||||||
|
parser.addOption(desktopModeOption);
|
||||||
|
|
||||||
parser.process(app);
|
parser.process(app);
|
||||||
aboutData.processCommandLine(&parser);
|
aboutData.processCommandLine(&parser);
|
||||||
|
|
||||||
|
if (parser.isSet(couchModeOption)) {
|
||||||
|
Config::setCliUiMode(Config::Couch);
|
||||||
|
} else if (parser.isSet(desktopModeOption)) {
|
||||||
|
Config::setCliUiMode(Config::Desktop);
|
||||||
|
}
|
||||||
|
|
||||||
bool terminalLaunched = false;
|
bool terminalLaunched = false;
|
||||||
#if defined(Q_OS_UNIX)
|
#if defined(Q_OS_UNIX)
|
||||||
terminalLaunched = (isatty(STDIN_FILENO) || isatty(STDOUT_FILENO) || isatty(STDERR_FILENO));
|
terminalLaunched = (isatty(STDIN_FILENO) || isatty(STDOUT_FILENO) || isatty(STDERR_FILENO));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue