mirror of
https://github.com/KDE/latte-dock.git
synced 2024-12-23 13:33:50 +03:00
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
This commit is contained in:
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) {
|
||||
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<Types::LatteConfigPage>(page);
|
||||
if (toggleCurrentPage) {
|
||||
m_latteSettingsDialog->toggleCurrentPage();
|
||||
} else {
|
||||
m_latteSettingsDialog->setCurrentPage(firstPage);
|
||||
}
|
||||
|
||||
m_latteSettingsDialog->activateWindow();
|
||||
|
@ -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);
|
||||
|
@ -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()
|
||||
|
@ -56,6 +56,7 @@ public:
|
||||
~SettingsDialog();
|
||||
|
||||
void toggleCurrentPage();
|
||||
void setCurrentPage(int page);
|
||||
|
||||
void addActivityInCurrent(const QString &activityId);
|
||||
void removeActivityFromCurrent(const QString &activityId);
|
||||
|
@ -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);
|
||||
|
@ -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<QAction *> Menu::contextualActions()
|
||||
{
|
||||
QList<QAction *> 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<QAction *> Menu::contextualActions()
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -53,11 +53,13 @@ private:
|
||||
QList<QAction *>m_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};
|
||||
};
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user