diff --git a/app/layouts/manager.cpp b/app/layouts/manager.cpp index 20d1b9696..15a9c5468 100644 --- a/app/layouts/manager.cpp +++ b/app/layouts/manager.cpp @@ -416,13 +416,10 @@ void Manager::importPreset(int presetNo, bool newInstanceIfPresent) } } -void Manager::showLatteSettingsDialog(int page) +void Manager::showLatteSettingsDialog(int firstPage, bool toggleCurrentPage) { - bool created{false}; - if (!m_latteSettingsDialog) { m_latteSettingsDialog = new SettingsDialog(nullptr, m_corona); - created = true; } m_latteSettingsDialog->show(); @@ -430,9 +427,10 @@ void Manager::showLatteSettingsDialog(int page) m_latteSettingsDialog->showNormal(); } - if (!created) { - Types::LatteConfigPage configPage = static_cast(page); + if (toggleCurrentPage) { m_latteSettingsDialog->toggleCurrentPage(); + } else { + m_latteSettingsDialog->setCurrentPage(firstPage); } m_latteSettingsDialog->activateWindow(); diff --git a/app/layouts/manager.h b/app/layouts/manager.h index 66fc18878..c03a7279c 100644 --- a/app/layouts/manager.h +++ b/app/layouts/manager.h @@ -111,7 +111,7 @@ public slots: void showAboutDialog(); void hideLatteSettingsDialog(); - Q_INVOKABLE void showLatteSettingsDialog(int page = Latte::Types::LayoutPage); + Q_INVOKABLE void showLatteSettingsDialog(int firstPage = Latte::Types::LayoutPage, bool toggleCurrentPage = false); //! switch to specified layout, default previousMemoryUsage means that it didn't change Q_INVOKABLE bool switchToLayout(QString layoutName, int previousMemoryUsage = -1); diff --git a/app/settings/settingsdialog.cpp b/app/settings/settingsdialog.cpp index c43c91673..bcc174121 100644 --- a/app/settings/settingsdialog.cpp +++ b/app/settings/settingsdialog.cpp @@ -368,7 +368,12 @@ void SettingsDialog::toggleCurrentPage() ui->tabWidget->setCurrentIndex(1); } else { ui->tabWidget->setCurrentIndex(0); - } + } +} + +void SettingsDialog::setCurrentPage(int page) +{ + ui->tabWidget->setCurrentIndex(page); } void SettingsDialog::on_newButton_clicked() diff --git a/app/settings/settingsdialog.h b/app/settings/settingsdialog.h index 5947d154a..bd7cc1386 100644 --- a/app/settings/settingsdialog.h +++ b/app/settings/settingsdialog.h @@ -56,6 +56,7 @@ public: ~SettingsDialog(); void toggleCurrentPage(); + void setCurrentPage(int page); void addActivityInCurrent(const QString &activityId); void removeActivityFromCurrent(const QString &activityId); diff --git a/app/shortcuts/globalshortcuts.cpp b/app/shortcuts/globalshortcuts.cpp index ee4ae3b27..e3f5b4dc3 100644 --- a/app/shortcuts/globalshortcuts.cpp +++ b/app/shortcuts/globalshortcuts.cpp @@ -120,7 +120,7 @@ void GlobalShortcuts::init() KGlobalAccel::setGlobalShortcut(layoutsAction, QKeySequence(Qt::META + Qt::Key_W)); connect(layoutsAction, &QAction::triggered, this, [this]() { m_modifierTracker->cancelMetaPressed(); - m_corona->layoutsManager()->showLatteSettingsDialog(Types::LayoutPage); + m_corona->layoutsManager()->showLatteSettingsDialog(Types::PreferencesPage, true); }); KActionCollection *taskbarActions = new KActionCollection(m_corona); diff --git a/containmentactions/contextmenu/menu.cpp b/containmentactions/contextmenu/menu.cpp index d80f20342..d326bb0b6 100644 --- a/containmentactions/contextmenu/menu.cpp +++ b/containmentactions/contextmenu/menu.cpp @@ -50,24 +50,28 @@ Menu::Menu(QObject *parent, const QVariantList &args) Menu::~Menu() { m_separator1->deleteLater(); + m_separator2->deleteLater(); m_addWidgetsAction->deleteLater(); m_configureAction->deleteLater(); m_printAction->deleteLater(); m_switchLayoutsMenu->deleteLater(); m_layoutsAction->deleteLater(); + m_preferenceAction->deleteLater(); } void Menu::makeActions() { m_separator1 = new QAction(this); m_separator1->setSeparator(true); + m_separator2 = new QAction(this); + m_separator2->setSeparator(true); m_printAction = new QAction(QIcon::fromTheme("edit"), "Print Message...", this); connect(m_printAction, &QAction::triggered, [ = ]() { qDebug() << "Action Trigerred !!!"; }); - m_addWidgetsAction = new QAction(QIcon::fromTheme("add"), i18n("&Add Widgets..."), this); + m_addWidgetsAction = new QAction(QIcon::fromTheme("list-add"), i18n("&Add Widgets..."), this); m_addWidgetsAction->setStatusTip(i18n("Show Plasma Widget Explorer")); connect(m_addWidgetsAction, &QAction::triggered, [ = ]() { QDBusInterface iface("org.kde.plasmashell", "/PlasmaShell", "", QDBusConnection::sessionBus()); @@ -77,7 +81,7 @@ void Menu::makeActions() } }); - m_configureAction = new QAction(QIcon::fromTheme("configure"), i18nc("view settings window", "View &Settings..."), this); + m_configureAction = new QAction(QIcon::fromTheme("document-edit"), i18nc("view settings window", "View &Settings..."), this); connect(m_configureAction, &QAction::triggered, this, &Menu::requestConfiguration); connect(this->containment(), &Plasma::Containment::userConfiguringChanged, this, [&](bool configuring){ @@ -95,6 +99,15 @@ void Menu::makeActions() connect(m_switchLayoutsMenu, &QMenu::aboutToShow, this, &Menu::populateLayouts); connect(m_switchLayoutsMenu, &QMenu::triggered, this, &Menu::switchToLayout); + + m_preferenceAction = new QAction(QIcon::fromTheme("configure"), i18nc("global settings window", "&Configure Latte..."), this); + connect(m_preferenceAction, &QAction::triggered, [=](){ + QDBusInterface iface("org.kde.lattedock", "/Latte", "", QDBusConnection::sessionBus()); + + if (iface.isValid()) { + iface.call("showSettingsWindow", (int)Latte::Types::PreferencesPage); + } + }); } @@ -109,12 +122,16 @@ void Menu::requestConfiguration() QList Menu::contextualActions() { QList actions; + actions << m_separator1; //actions << m_printAction; actions << m_layoutsAction; + actions << m_preferenceAction; + + actions << m_separator2; actions << m_addWidgetsAction; actions << m_configureAction; - + m_data.clear(); QDBusInterface iface("org.kde.lattedock", "/Latte", "", QDBusConnection::sessionBus()); @@ -138,7 +155,7 @@ QList Menu::contextualActions() viewType = static_cast((m_data[2]).toInt()); } - const QString configureActionText = (viewType == Latte::Types::DockView) ? i18nc("dock settings window", "Dock &Settings...") : i18nc("panel settings window", "Panel &Settings..."); + const QString configureActionText = (viewType == Latte::Types::DockView) ? i18nc("dock settings window", "&Edit Dock...") : i18nc("panel settings window", "&Edit Panel..."); m_configureAction->setText(configureActionText); return actions; @@ -198,7 +215,7 @@ void Menu::populateLayouts() m_switchLayoutsMenu->addSeparator(); - QAction *editLayoutsAction = new QAction(i18n("Configure..."), m_switchLayoutsMenu); + QAction *editLayoutsAction = new QAction(i18n("Manage &Layouts..."), m_switchLayoutsMenu); editLayoutsAction->setData(QStringLiteral(" _show_latte_settings_dialog_")); m_switchLayoutsMenu->addAction(editLayoutsAction); } diff --git a/containmentactions/contextmenu/menu.h b/containmentactions/contextmenu/menu.h index f44fe3921..1dd1d8df1 100644 --- a/containmentactions/contextmenu/menu.h +++ b/containmentactions/contextmenu/menu.h @@ -53,11 +53,13 @@ private: QListm_actions; QAction *m_separator1{nullptr}; + QAction *m_separator2{nullptr}; QAction *m_addWidgetsAction{nullptr}; QAction *m_configureAction{nullptr}; QAction *m_printAction{nullptr}; QAction *m_layoutsAction{nullptr}; + QAction *m_preferenceAction{nullptr}; QMenu *m_switchLayoutsMenu{nullptr}; }; diff --git a/plasmoid/package/contents/ui/ContextMenu.qml b/plasmoid/package/contents/ui/ContextMenu.qml index abf25cf40..70469f3dc 100644 --- a/plasmoid/package/contents/ui/ContextMenu.qml +++ b/plasmoid/package/contents/ui/ContextMenu.qml @@ -917,8 +917,10 @@ PlasmaComponents.ContextMenu { } PlasmaComponents.MenuItem { - text: i18n("Configure") - section: true + //text: i18n("Configure") + //section: true + separator: true + visible: preferenceMenuItem.visible } /* PlasmaComponents.MenuItem { @@ -934,6 +936,18 @@ PlasmaComponents.ContextMenu { visible: latteView && latteView.layoutsManager.menuLayouts.length>1 } + PlasmaComponents.MenuItem { + id: preferenceMenuItem + + action: latteView ? latteView.containmentActions()[2] : plasmoid.action("configure") + visible: latteView + } + + PlasmaComponents.MenuItem { + separator: true + visible: preferenceMenuItem.visible + } + PlasmaComponents.MenuItem { id: alternativesMenuItem visible: root.editMode && !visualParent.isSeparator @@ -946,7 +960,7 @@ PlasmaComponents.ContextMenu { PlasmaComponents.MenuItem { id: addWidgets - action: latteView ? latteView.containmentActions()[2] : plasmoid.action("configure"); + action: latteView ? latteView.containmentActions()[4] : plasmoid.action("configure"); visible: latteView } @@ -954,7 +968,7 @@ PlasmaComponents.ContextMenu { PlasmaComponents.MenuItem { id: configureItem - action: latteView ? latteView.containmentActions()[3] : plasmoid.action("configure") + action: latteView ? latteView.containmentActions()[5] : plasmoid.action("configure") } //! BEGIN: Plasmoid actions when it isnt inside a Latte dock