Improve context menu

Summary:
- Add `Configure Latte Global Settings...` because it's too hidden in Layout > Configure and does not relate to the Layout menu.
- Insert a new `Separator` to separate between Global settings and View settings (see screenshot)
- Rename `Panel/Dock Settings` to `Edit Panel/Dock` (Verb + Noun)
- Rename `Layout > Configure...` to `Layout > Manage Layouts` (Verb + Noun)

Menu Items Order:

   a.  -separator-
   b. Layouts->
   c. Configure Application...
   e.  -separator-
   f. Add Widgets...
   g. Edit Dock...
   h.  -separator- [only for Tasks plasmoid]
   i.  Close... [only for Tasks plasmoid]

BUG: 415584

Test Plan:
Before:
{F7844554}

After:
a. context menu of applets
{F7845184}
b. context menu of a task that hasn't/has one window shown
{F7844944}
{F7845185}
c. context menu of Latte Tasks plasmoid when used on the desktop
{F7845186}
{F7845187}

Reviewers: #latte_dock, #vdg, mvourlakos

Reviewed By: #latte_dock, mvourlakos

Subscribers: ngraham, ndavis, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D26238
pull/11/head
Tranter Madi 5 years ago
parent f93bec8893
commit fe5dbf9f2b

@ -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) { if (!m_latteSettingsDialog) {
m_latteSettingsDialog = new SettingsDialog(nullptr, m_corona); m_latteSettingsDialog = new SettingsDialog(nullptr, m_corona);
created = true;
} }
m_latteSettingsDialog->show(); m_latteSettingsDialog->show();
@ -430,9 +427,10 @@ void Manager::showLatteSettingsDialog(int page)
m_latteSettingsDialog->showNormal(); m_latteSettingsDialog->showNormal();
} }
if (!created) { if (toggleCurrentPage) {
Types::LatteConfigPage configPage = static_cast<Types::LatteConfigPage>(page);
m_latteSettingsDialog->toggleCurrentPage(); m_latteSettingsDialog->toggleCurrentPage();
} else {
m_latteSettingsDialog->setCurrentPage(firstPage);
} }
m_latteSettingsDialog->activateWindow(); m_latteSettingsDialog->activateWindow();

@ -111,7 +111,7 @@ public slots:
void showAboutDialog(); void showAboutDialog();
void hideLatteSettingsDialog(); 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 //! switch to specified layout, default previousMemoryUsage means that it didn't change
Q_INVOKABLE bool switchToLayout(QString layoutName, int previousMemoryUsage = -1); Q_INVOKABLE bool switchToLayout(QString layoutName, int previousMemoryUsage = -1);

@ -371,6 +371,11 @@ void SettingsDialog::toggleCurrentPage()
} }
} }
void SettingsDialog::setCurrentPage(int page)
{
ui->tabWidget->setCurrentIndex(page);
}
void SettingsDialog::on_newButton_clicked() void SettingsDialog::on_newButton_clicked()
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;

@ -56,6 +56,7 @@ public:
~SettingsDialog(); ~SettingsDialog();
void toggleCurrentPage(); void toggleCurrentPage();
void setCurrentPage(int page);
void addActivityInCurrent(const QString &activityId); void addActivityInCurrent(const QString &activityId);
void removeActivityFromCurrent(const QString &activityId); void removeActivityFromCurrent(const QString &activityId);

@ -120,7 +120,7 @@ void GlobalShortcuts::init()
KGlobalAccel::setGlobalShortcut(layoutsAction, QKeySequence(Qt::META + Qt::Key_W)); KGlobalAccel::setGlobalShortcut(layoutsAction, QKeySequence(Qt::META + Qt::Key_W));
connect(layoutsAction, &QAction::triggered, this, [this]() { connect(layoutsAction, &QAction::triggered, this, [this]() {
m_modifierTracker->cancelMetaPressed(); m_modifierTracker->cancelMetaPressed();
m_corona->layoutsManager()->showLatteSettingsDialog(Types::LayoutPage); m_corona->layoutsManager()->showLatteSettingsDialog(Types::PreferencesPage, true);
}); });
KActionCollection *taskbarActions = new KActionCollection(m_corona); KActionCollection *taskbarActions = new KActionCollection(m_corona);

@ -50,24 +50,28 @@ Menu::Menu(QObject *parent, const QVariantList &args)
Menu::~Menu() Menu::~Menu()
{ {
m_separator1->deleteLater(); m_separator1->deleteLater();
m_separator2->deleteLater();
m_addWidgetsAction->deleteLater(); m_addWidgetsAction->deleteLater();
m_configureAction->deleteLater(); m_configureAction->deleteLater();
m_printAction->deleteLater(); m_printAction->deleteLater();
m_switchLayoutsMenu->deleteLater(); m_switchLayoutsMenu->deleteLater();
m_layoutsAction->deleteLater(); m_layoutsAction->deleteLater();
m_preferenceAction->deleteLater();
} }
void Menu::makeActions() void Menu::makeActions()
{ {
m_separator1 = new QAction(this); m_separator1 = new QAction(this);
m_separator1->setSeparator(true); m_separator1->setSeparator(true);
m_separator2 = new QAction(this);
m_separator2->setSeparator(true);
m_printAction = new QAction(QIcon::fromTheme("edit"), "Print Message...", this); m_printAction = new QAction(QIcon::fromTheme("edit"), "Print Message...", this);
connect(m_printAction, &QAction::triggered, [ = ]() { connect(m_printAction, &QAction::triggered, [ = ]() {
qDebug() << "Action Trigerred !!!"; 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")); m_addWidgetsAction->setStatusTip(i18n("Show Plasma Widget Explorer"));
connect(m_addWidgetsAction, &QAction::triggered, [ = ]() { connect(m_addWidgetsAction, &QAction::triggered, [ = ]() {
QDBusInterface iface("org.kde.plasmashell", "/PlasmaShell", "", QDBusConnection::sessionBus()); 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(m_configureAction, &QAction::triggered, this, &Menu::requestConfiguration);
connect(this->containment(), &Plasma::Containment::userConfiguringChanged, this, [&](bool configuring){ 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::aboutToShow, this, &Menu::populateLayouts);
connect(m_switchLayoutsMenu, &QMenu::triggered, this, &Menu::switchToLayout); 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,9 +122,13 @@ void Menu::requestConfiguration()
QList<QAction *> Menu::contextualActions() QList<QAction *> Menu::contextualActions()
{ {
QList<QAction *> actions; QList<QAction *> actions;
actions << m_separator1; actions << m_separator1;
//actions << m_printAction; //actions << m_printAction;
actions << m_layoutsAction; actions << m_layoutsAction;
actions << m_preferenceAction;
actions << m_separator2;
actions << m_addWidgetsAction; actions << m_addWidgetsAction;
actions << m_configureAction; actions << m_configureAction;
@ -138,7 +155,7 @@ QList<QAction *> Menu::contextualActions()
viewType = static_cast<Latte::Types::ViewType>((m_data[2]).toInt()); viewType = static_cast<Latte::Types::ViewType>((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); m_configureAction->setText(configureActionText);
return actions; return actions;
@ -198,7 +215,7 @@ void Menu::populateLayouts()
m_switchLayoutsMenu->addSeparator(); 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_")); editLayoutsAction->setData(QStringLiteral(" _show_latte_settings_dialog_"));
m_switchLayoutsMenu->addAction(editLayoutsAction); m_switchLayoutsMenu->addAction(editLayoutsAction);
} }

@ -53,11 +53,13 @@ private:
QList<QAction *>m_actions; QList<QAction *>m_actions;
QAction *m_separator1{nullptr}; QAction *m_separator1{nullptr};
QAction *m_separator2{nullptr};
QAction *m_addWidgetsAction{nullptr}; QAction *m_addWidgetsAction{nullptr};
QAction *m_configureAction{nullptr}; QAction *m_configureAction{nullptr};
QAction *m_printAction{nullptr}; QAction *m_printAction{nullptr};
QAction *m_layoutsAction{nullptr}; QAction *m_layoutsAction{nullptr};
QAction *m_preferenceAction{nullptr};
QMenu *m_switchLayoutsMenu{nullptr}; QMenu *m_switchLayoutsMenu{nullptr};
}; };

@ -917,8 +917,10 @@ PlasmaComponents.ContextMenu {
} }
PlasmaComponents.MenuItem { PlasmaComponents.MenuItem {
text: i18n("Configure") //text: i18n("Configure")
section: true //section: true
separator: true
visible: preferenceMenuItem.visible
} }
/* PlasmaComponents.MenuItem { /* PlasmaComponents.MenuItem {
@ -934,6 +936,18 @@ PlasmaComponents.ContextMenu {
visible: latteView && latteView.layoutsManager.menuLayouts.length>1 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 { PlasmaComponents.MenuItem {
id: alternativesMenuItem id: alternativesMenuItem
visible: root.editMode && !visualParent.isSeparator visible: root.editMode && !visualParent.isSeparator
@ -946,7 +960,7 @@ PlasmaComponents.ContextMenu {
PlasmaComponents.MenuItem { PlasmaComponents.MenuItem {
id: addWidgets id: addWidgets
action: latteView ? latteView.containmentActions()[2] : plasmoid.action("configure"); action: latteView ? latteView.containmentActions()[4] : plasmoid.action("configure");
visible: latteView visible: latteView
} }
@ -954,7 +968,7 @@ PlasmaComponents.ContextMenu {
PlasmaComponents.MenuItem { PlasmaComponents.MenuItem {
id: configureItem 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 //! BEGIN: Plasmoid actions when it isnt inside a Latte dock

Loading…
Cancel
Save