Git commit 8f753e005c423afdec0185132d8066edd9bbfeb5 by Johnny Jazeix. Committed on 30/11/2025 at 14:28. Pushed by jjazeix into branch 'master'.
core, add command-line option to hide/show the Home button in the bar M +8 -0 docs/docbook/index.docbook M +10 -0 src/core/ApplicationSettings.cpp M +14 -0 src/core/ApplicationSettings.h M +1 -1 src/core/Bar.qml M +1 -0 src/core/ChangeLog.qml M +14 -0 src/core/main.cpp https://invent.kde.org/education/gcompris/-/commit/8f753e005c423afdec0185132d8066edd9bbfeb5 diff --git a/docs/docbook/index.docbook b/docs/docbook/index.docbook index f85b4d6e68..36db606ffc 100644 --- a/docs/docbook/index.docbook +++ b/docs/docbook/index.docbook @@ -317,6 +317,14 @@ or make it show real car images instead of filled rectangles (traffic).</para> <entry>Disable the kiosk mode (default).</entry> </row> <row> +<entry>--show-home-button</entry> +<entry>Show the Home button in the bar (default).</entry> +</row> +<row> +<entry>--hide-home-button</entry> +<entry>Hide the Home button in the bar.</entry> +</row> +<row> <entry>--renderer={renderer}</entry> <entry>Specify which graphical renderer to use. On all platforms, “opengl” and software are available. On Windows, you can use “direct3d11” or “direct3d12” (if it was compiled with Qt ≥ 6.6). On &macOS;, you can use “metal”.</entry> </row> diff --git a/src/core/ApplicationSettings.cpp b/src/core/ApplicationSettings.cpp index 11ecc7c310..7af561308a 100644 --- a/src/core/ApplicationSettings.cpp +++ b/src/core/ApplicationSettings.cpp @@ -64,6 +64,7 @@ namespace { const char *DEFAULT_CURSOR = "defaultCursor"; const char *NO_CURSOR = "noCursor"; const char *KIOSK_KEY = "kiosk"; + const char *HOME_BUTTON_VISIBLE_KEY = "homeButtonVisible"; const char *SECTION_VISIBLE = "sectionVisible"; const char *EXIT_CONFIRMATION = "exitConfirmation"; @@ -110,6 +111,7 @@ ApplicationSettings::ApplicationSettings(const QString &configPath, QObject *par #else m_isKioskMode = m_config.value(KIOSK_KEY, false).toBool(); #endif + m_isHomeButtonVisible = m_config.value(HOME_BUTTON_VISIBLE_KEY, true).toBool(); m_sectionVisible = m_config.value(SECTION_VISIBLE, true).toBool(); m_exitConfirmation = m_config.value(EXIT_CONFIRMATION, ApplicationInfo::getInstance()->isMobile() ? true : false).toBool(); @@ -166,6 +168,7 @@ ApplicationSettings::ApplicationSettings(const QString &configPath, QObject *par connect(this, &ApplicationSettings::sectionVisibleChanged, this, &ApplicationSettings::notifySectionVisibleChanged); connect(this, &ApplicationSettings::exitConfirmationChanged, this, &ApplicationSettings::notifyExitConfirmationChanged); connect(this, &ApplicationSettings::kioskModeChanged, this, &ApplicationSettings::notifyKioskModeChanged); + connect(this, &ApplicationSettings::homeButtonVisibleChanged, this, &ApplicationSettings::notifyHomeButtonVisibleChanged); connect(this, &ApplicationSettings::downloadServerUrlChanged, this, &ApplicationSettings::notifyDownloadServerUrlChanged); connect(this, &ApplicationSettings::cachePathChanged, this, &ApplicationSettings::notifyCachePathChanged); connect(this, &ApplicationSettings::userDataPathChanged, this, &ApplicationSettings::notifyUserDataPathChanged); @@ -202,6 +205,7 @@ ApplicationSettings::~ApplicationSettings() m_config.setValue(FILTER_LEVEL_MAX, m_filterLevelMax); } m_config.setValue(KIOSK_KEY, m_isKioskMode); + m_config.setValue(HOME_BUTTON_VISIBLE_KEY, m_isHomeButtonVisible); m_config.setValue(SECTION_VISIBLE, m_sectionVisible); m_config.setValue(EXIT_CONFIRMATION, m_exitConfirmation); m_config.setValue(DEFAULT_CURSOR, m_defaultCursor); @@ -359,6 +363,12 @@ void ApplicationSettings::notifyKioskModeChanged() qDebug() << "notifyKioskMode: " << m_isKioskMode; } +void ApplicationSettings::notifyHomeButtonVisibleChanged() +{ + updateValueInConfig(GENERAL_GROUP_KEY, HOME_BUTTON_VISIBLE_KEY, m_isHomeButtonVisible); + qDebug() << "notifyHomeButtonVisible: " << m_isHomeButtonVisible; +} + void ApplicationSettings::notifySectionVisibleChanged() { updateValueInConfig(GENERAL_GROUP_KEY, SECTION_VISIBLE, m_sectionVisible); diff --git a/src/core/ApplicationSettings.h b/src/core/ApplicationSettings.h index 14666dfafa..6ba679c97d 100644 --- a/src/core/ApplicationSettings.h +++ b/src/core/ApplicationSettings.h @@ -174,6 +174,10 @@ class ApplicationSettings : public QObject */ Q_PROPERTY(bool isKioskMode READ isKioskMode WRITE setKioskMode NOTIFY kioskModeChanged) + /** + * Whether hide/show home button in the bar. + */ + Q_PROPERTY(bool isHomeButtonVisible READ isHomeButtonVisible WRITE setHomeButtonVisible NOTIFY homeButtonVisibleChanged) /** * Whether the section selection row is visible in the menu view. */ @@ -417,6 +421,13 @@ public: Q_EMIT kioskModeChanged(); } + bool isHomeButtonVisible() const { return m_isHomeButtonVisible; } + void setHomeButtonVisible(const bool newMode) + { + m_isHomeButtonVisible = newMode; + Q_EMIT homeButtonVisibleChanged(); + } + bool sectionVisible() const { return m_sectionVisible; } void setSectionVisible(const bool newMode) { @@ -542,6 +553,7 @@ protected Q_SLOTS: Q_INVOKABLE void notifyFilterLevelMinChanged(); Q_INVOKABLE void notifyFilterLevelMaxChanged(); Q_INVOKABLE void notifyKioskModeChanged(); + Q_INVOKABLE void notifyHomeButtonVisibleChanged(); Q_INVOKABLE void notifySectionVisibleChanged(); Q_INVOKABLE void notifyExitConfirmationChanged(); Q_INVOKABLE void notifyFilteredBackgroundMusicChanged(); @@ -621,6 +633,7 @@ Q_SIGNALS: void filterLevelMaxChanged(); void filterLevelOverridedByCommandLineOptionChanged(); void kioskModeChanged(); + void homeButtonVisibleChanged(); void sectionVisibleChanged(); void exitConfirmationChanged(); void baseFontSizeChanged(); @@ -666,6 +679,7 @@ private: QString m_locale; QString m_font; bool m_isKioskMode; + bool m_isHomeButtonVisible = true; bool m_sectionVisible; bool m_exitConfirmation; QStringList m_filteredBackgroundMusic; diff --git a/src/core/Bar.qml b/src/core/Bar.qml index ffc2157479..5ae0798796 100644 --- a/src/core/Bar.qml +++ b/src/core/Bar.qml @@ -168,7 +168,7 @@ Item { { 'bid': home, 'contentId': content.home, - 'allowed': true + 'allowed': ApplicationSettings.isHomeButtonVisible }, { 'bid': previous, diff --git a/src/core/ChangeLog.qml b/src/core/ChangeLog.qml index 2ae9252648..ba07277382 100644 --- a/src/core/ChangeLog.qml +++ b/src/core/ChangeLog.qml @@ -29,6 +29,7 @@ QtObject { { "versionCode": 260000, "content": [ qsTr("Translation added for Kannada and Tamil"), qsTr("New command-line option to set the locale (--locale locale)"), + qsTr("New command-line option to show/hide the Home button (--hide-home-button/--show-home-button)"), qsTr("Many usability improvements"), qsTr("Many bug fixes") ], diff --git a/src/core/main.cpp b/src/core/main.cpp index 62d9003c46..7ff5800a04 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -143,6 +143,14 @@ int main(int argc, char *argv[]) QObject::tr("Specify the locale when starting GCompris."), "locale"); parser.addOption(clLocale); + QCommandLineOption clHideHomeButton("hide-home-button", + QObject::tr("Hide the Home button in the bar.")); + parser.addOption(clHideHomeButton); + + QCommandLineOption clShowHomeButton("show-home-button", + QObject::tr("Show the Home button in the bar (default).")); + parser.addOption(clShowHomeButton); + parser.process(app); #ifdef WITH_RCC @@ -205,6 +213,12 @@ int main(int argc, char *argv[]) if (parser.isSet(clWithKioskMode)) { ApplicationSettings::getInstance()->setKioskMode(true); } + if (parser.isSet(clHideHomeButton)) { + ApplicationSettings::getInstance()->setHomeButtonVisible(false); + } + if (parser.isSet(clShowHomeButton)) { + ApplicationSettings::getInstance()->setHomeButtonVisible(true); + } if (parser.isSet(clLocale)) { QString locale = parser.value(clLocale); if (locale != "system") {
