Changeset View
Standalone View
containmentactions/contextmenu/menu.cpp
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 59 | { | |||
---|---|---|---|---|---|
60 | m_separator1 = new QAction(this); | 60 | m_separator1 = new QAction(this); | ||
61 | m_separator1->setSeparator(true); | 61 | m_separator1->setSeparator(true); | ||
62 | 62 | | |||
63 | m_printAction = new QAction(QIcon::fromTheme("edit"), "Print Message...", this); | 63 | m_printAction = new QAction(QIcon::fromTheme("edit"), "Print Message...", this); | ||
64 | connect(m_printAction, &QAction::triggered, [ = ]() { | 64 | connect(m_printAction, &QAction::triggered, [ = ]() { | ||
65 | qDebug() << "Action Trigerred !!!"; | 65 | qDebug() << "Action Trigerred !!!"; | ||
66 | }); | 66 | }); | ||
67 | 67 | | |||
68 | m_addWidgetsAction = new QAction(QIcon::fromTheme("add"), i18n("Add Widgets..."), this); | 68 | m_addWidgetsAction = new QAction(QIcon::fromTheme("add"), i18n("&Add Widgets..."), this); | ||
mvourlakos: when we add character & in the menus it means that a modifier+&Letter activates that option… | |||||
For example, "&Add widgets..."
trmdi: For example, "&Add widgets..."
- shortcut: `Alt+a`
- the shortcut only works when that menu is… | |||||
69 | m_addWidgetsAction->setStatusTip(i18n("Show Plasma Widget Explorer")); | 69 | m_addWidgetsAction->setStatusTip(i18n("Show Plasma Widget Explorer")); | ||
70 | connect(m_addWidgetsAction, &QAction::triggered, [ = ]() { | 70 | connect(m_addWidgetsAction, &QAction::triggered, [ = ]() { | ||
71 | QDBusInterface iface("org.kde.plasmashell", "/PlasmaShell", "", QDBusConnection::sessionBus()); | 71 | QDBusInterface iface("org.kde.plasmashell", "/PlasmaShell", "", QDBusConnection::sessionBus()); | ||
72 | 72 | | |||
73 | if (iface.isValid()) { | 73 | if (iface.isValid()) { | ||
74 | iface.call("toggleWidgetExplorer"); | 74 | iface.call("toggleWidgetExplorer"); | ||
75 | } | 75 | } | ||
76 | }); | 76 | }); | ||
77 | 77 | | |||
78 | m_configureAction = new QAction(QIcon::fromTheme("configure"), i18nc("view settings window", "View Settings..."), this); | 78 | m_configureAction = new QAction(QIcon::fromTheme("configure"), i18nc("view settings window", "View &Settings..."), this); | ||
79 | m_configureAction->setShortcut(QKeySequence()); | 79 | setConfigureActionText(); | ||
when we add character & in the menus it means that a modifier+&Letter activates that option what is the shortcut that shows dock settings? it has been chosen to be Meta+A so that change does not respond to something mvourlakos: when we add character & in the menus it means that a modifier+&Letter activates that option… | |||||
80 | connect(m_configureAction, &QAction::triggered, this, &Menu::requestConfiguration); | 80 | connect(m_configureAction, &QAction::triggered, this, &Menu::requestConfiguration); | ||
81 | 81 | | |||
82 | m_switchLayoutsMenu = new QMenu; | 82 | m_switchLayoutsMenu = new QMenu; | ||
83 | m_layoutsAction = m_switchLayoutsMenu->menuAction(); | 83 | m_layoutsAction = m_switchLayoutsMenu->menuAction(); | ||
84 | m_layoutsAction->setText(i18n("Layouts")); | 84 | m_layoutsAction->setText(i18n("&Layouts")); | ||
when we add character & in the menus it means that a modifier+&Letter activates that option what is the shortcut that shows Latte layouts menu? none, this shouldnt be applied also mvourlakos: when we add character & in the menus it means that a modifier+&Letter activates that option… | |||||
85 | m_layoutsAction->setIcon(QIcon::fromTheme("user-identity")); | 85 | m_layoutsAction->setIcon(QIcon::fromTheme("user-identity")); | ||
86 | m_layoutsAction->setStatusTip(i18n("Switch to another layout")); | 86 | m_layoutsAction->setStatusTip(i18n("Switch to another layout")); | ||
87 | 87 | | |||
88 | connect(m_switchLayoutsMenu, &QMenu::aboutToShow, this, &Menu::populateLayouts); | 88 | connect(m_switchLayoutsMenu, &QMenu::aboutToShow, this, &Menu::populateLayouts); | ||
89 | connect(m_switchLayoutsMenu, &QMenu::triggered, this, &Menu::switchToLayout); | 89 | connect(m_switchLayoutsMenu, &QMenu::triggered, this, &Menu::switchToLayout); | ||
90 | | ||||
91 | connect(this->containment(), &Plasma::Containment::userConfiguringChanged, this, [&](bool configuring){ | ||||
is this still needed if we check the value each time we show up the context menu? mvourlakos: is this still needed if we check the value each time we show up the context menu? | |||||
Yes, it's needed. Because when you're opening the Setting window and you right click on the view, it will close the Setting window, not a nice behavior. So we should hide it when the Setting window is opening. trmdi: Yes, it's needed. Because when you're opening the Setting window and you right click on the… | |||||
ok this a behavior change irrelevant with the patch but ok we can keep it mvourlakos: ok this a behavior change irrelevant with the patch but ok we can keep it | |||||
92 | m_configureAction->setVisible(!configuring); | ||||
mvourlakos: why this is needed? | |||||
trmdi: - when the user opens View Settings, there is a case that he change the viewType, so we should… | |||||
in this slot is also needed: m_configureAction->setEnabled(true); there are cases that the Dock Settings is shown when !configuring but it is not enabled mvourlakos: in this slot is also needed:
```
m_configureAction->setEnabled(true);
```
there are cases… | |||||
I don't understand. my code only change the visible property, why does it have to handle the "enable" one? You meant the setting is showing but configuring==false? Sound weird. How to make it happen? trmdi: I don't understand. my code only change the `visible` property, why does it have to handle the… | |||||
93 | if (!configuring) { | ||||
mvourlakos: style issue. even for single lines ifs
```
if (..) {
}
``` | |||||
94 | setConfigureActionText(); | ||||
95 | } | ||||
96 | }); | ||||
90 | } | 97 | } | ||
91 | 98 | | |||
92 | 99 | | |||
93 | void Menu::requestConfiguration() | 100 | void Menu::requestConfiguration() | ||
94 | { | 101 | { | ||
95 | if (this->containment()) { | 102 | if (this->containment()) { | ||
96 | emit this->containment()->configureRequested(containment()); | 103 | emit this->containment()->configureRequested(containment()); | ||
97 | } | 104 | } | ||
Show All 22 Lines | 126 | if (m_layoutsData.size() > 3) { | |||
120 | m_layoutsAction->setEnabled(true); | 127 | m_layoutsAction->setEnabled(true); | ||
121 | m_layoutsAction->setVisible(true); | 128 | m_layoutsAction->setVisible(true); | ||
122 | } else { | 129 | } else { | ||
123 | m_layoutsAction->setVisible(false); | 130 | m_layoutsAction->setVisible(false); | ||
124 | } | 131 | } | ||
125 | 132 | | |||
126 | return actions; | 133 | return actions; | ||
127 | } | 134 | } | ||
128 | 135 | | |||
same thing for these & characters, do not respond to any shortcut so they should be removed mvourlakos: same thing for these & characters, do not respond to any shortcut so they should be removed | |||||
129 | QAction *Menu::action(const QString &name) | 136 | QAction *Menu::action(const QString &name) | ||
130 | { | 137 | { | ||
131 | if (name == "add widgets") { | 138 | if (name == "add widgets") { | ||
132 | return m_addWidgetsAction; | 139 | return m_addWidgetsAction; | ||
133 | } else if (name == "configure") { | 140 | } else if (name == "configure") { | ||
134 | return m_configureAction; | 141 | return m_configureAction; | ||
135 | } else if (name == "layouts") { | 142 | } else if (name == "layouts") { | ||
136 | return m_layoutsAction; | 143 | return m_layoutsAction; | ||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | 209 | QTimer::singleShot(400, [this, layout]() { | |||
204 | 211 | | |||
205 | if (iface.isValid()) { | 212 | if (iface.isValid()) { | ||
206 | iface.call("switchToLayout", layout); | 213 | iface.call("switchToLayout", layout); | ||
207 | } | 214 | } | ||
208 | }); | 215 | }); | ||
209 | } | 216 | } | ||
210 | } | 217 | } | ||
211 | 218 | | |||
219 | void Menu::setConfigureActionText() | ||||
220 | { | ||||
221 | const int viewType = this->containment()->config().readEntry("viewType", static_cast<int>(Latte::Types::DockView)); | ||||
222 | m_configureAction->setText(i18nc("view settings window", viewType == Latte::Types::DockView ? "Dock &Settings..." : "Panel &Settings...")); | ||||
223 | } | ||||
224 | | ||||
212 | K_EXPORT_PLASMA_CONTAINMENTACTIONS_WITH_JSON(lattecontextmenu, Menu, "plasma-containmentactions-lattecontextmenu.json") | 225 | K_EXPORT_PLASMA_CONTAINMENTACTIONS_WITH_JSON(lattecontextmenu, Menu, "plasma-containmentactions-lattecontextmenu.json") | ||
213 | 226 | | |||
214 | #include "menu.moc" | 227 | #include "menu.moc" |
when we add character & in the menus it means that a modifier+&Letter activates that option what is the shortcut that add widgets?