Changeset View
Changeset View
Standalone View
Standalone View
containmentactions/contextmenu/menu.cpp
Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Line(s) | 63 | { | |||
---|---|---|---|---|---|
66 | 66 | | |||
67 | m_actions.clear(); | 67 | m_actions.clear(); | ||
68 | m_actionOrder.clear(); | 68 | m_actionOrder.clear(); | ||
69 | QHash<QString, bool> actions; | 69 | QHash<QString, bool> actions; | ||
70 | QSet<QString> disabled; | 70 | QSet<QString> disabled; | ||
71 | 71 | | |||
72 | if (c->containmentType() == Plasma::Types::PanelContainment || | 72 | if (c->containmentType() == Plasma::Types::PanelContainment || | ||
73 | c->containmentType() == Plasma::Types::CustomPanelContainment) { | 73 | c->containmentType() == Plasma::Types::CustomPanelContainment) { | ||
74 | m_actionOrder << QStringLiteral("add widgets") << QStringLiteral("_add panel") << QStringLiteral("lock widgets") << QStringLiteral("_context") << QStringLiteral("configure") << QStringLiteral("remove"); | 74 | m_actionOrder << QStringLiteral("add widgets") << QStringLiteral("_add panel") << QStringLiteral("_context") << QStringLiteral("configure") << QStringLiteral("remove"); | ||
75 | } else { | 75 | } else { | ||
76 | actions.insert(QStringLiteral("configure shortcuts"), false); | 76 | actions.insert(QStringLiteral("configure shortcuts"), false); | ||
77 | m_actionOrder << QStringLiteral("_context") << QStringLiteral("_run_command") << QStringLiteral("add widgets") << QStringLiteral("_add panel") | 77 | m_actionOrder << QStringLiteral("_context") << QStringLiteral("_run_command") << QStringLiteral("add widgets") << QStringLiteral("_add panel") | ||
78 | << QStringLiteral("manage activities") << QStringLiteral("remove") << QStringLiteral("lock widgets") << QStringLiteral("edit mode") << QStringLiteral("_sep1") | 78 | << QStringLiteral("manage activities") << QStringLiteral("remove") << QStringLiteral("edit mode") << QStringLiteral("_sep1") | ||
79 | <<QStringLiteral("_lock_screen") << QStringLiteral("_logout") << QStringLiteral("_sep2") << QStringLiteral("run associated application") << QStringLiteral("configure") | 79 | <<QStringLiteral("_lock_screen") << QStringLiteral("_logout") << QStringLiteral("_sep2") << QStringLiteral("run associated application") << QStringLiteral("configure") | ||
80 | << QStringLiteral("configure shortcuts") << QStringLiteral("_sep3") << QStringLiteral("_wallpaper"); | 80 | << QStringLiteral("configure shortcuts") << QStringLiteral("_sep3") << QStringLiteral("_wallpaper"); | ||
81 | disabled.insert(QStringLiteral("configure shortcuts")); | 81 | disabled.insert(QStringLiteral("configure shortcuts")); | ||
82 | } | 82 | } | ||
83 | 83 | | |||
84 | foreach (const QString &name, m_actionOrder) { | 84 | foreach (const QString &name, m_actionOrder) { | ||
85 | actions.insert(name, !disabled.contains(name)); | 85 | actions.insert(name, !disabled.contains(name)); | ||
86 | } | 86 | } | ||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | 133 | if (!c->wallpaper().isEmpty()) { | |||
135 | if (wallpaperGraphicsObject) { | 135 | if (wallpaperGraphicsObject) { | ||
136 | actions << wallpaperGraphicsObject->property("contextualActions").value<QList<QAction *> >(); | 136 | actions << wallpaperGraphicsObject->property("contextualActions").value<QList<QAction *> >(); | ||
137 | } | 137 | } | ||
138 | } | 138 | } | ||
139 | } else if (QAction *a = action(name)) { | 139 | } else if (QAction *a = action(name)) { | ||
140 | // Bug 364292: show "Remove this Panel" option only when panelcontroller is opened | 140 | // Bug 364292: show "Remove this Panel" option only when panelcontroller is opened | ||
141 | if (name != QLatin1String("remove") || c->isUserConfiguring() || | 141 | if (name != QLatin1String("remove") || c->isUserConfiguring() || | ||
142 | (c->containmentType() != Plasma::Types::PanelContainment | 142 | (c->containmentType() != Plasma::Types::PanelContainment | ||
143 | && c->containmentType() != Plasma::Types::CustomPanelContainment)) { | 143 | && c->containmentType() != Plasma::Types::CustomPanelContainment | ||
144 | 144 | && c->corona()->immutability() != Plasma::Types::Mutable)) { | |||
145 | if (name != QLatin1String("lock widgets") || c->corona()->immutability() != Plasma::Types::Mutable) { | | |||
146 | actions << a; | 145 | actions << a; | ||
147 | } | 146 | } | ||
148 | } | 147 | } | ||
149 | } | 148 | } | ||
150 | } | | |||
151 | 149 | | |||
152 | return actions; | 150 | return actions; | ||
153 | } | 151 | } | ||
154 | 152 | | |||
155 | QAction *ContextMenu::action(const QString &name) | 153 | QAction *ContextMenu::action(const QString &name) | ||
156 | { | 154 | { | ||
157 | Plasma::Containment *c = containment(); | 155 | Plasma::Containment *c = containment(); | ||
158 | Q_ASSERT(c); | 156 | Q_ASSERT(c); | ||
Show All 14 Lines | |||||
173 | } else if (name == QLatin1String("_lock_screen")) { | 171 | } else if (name == QLatin1String("_lock_screen")) { | ||
174 | if (KAuthorized::authorizeAction(QStringLiteral("lock_screen"))) { | 172 | if (KAuthorized::authorizeAction(QStringLiteral("lock_screen"))) { | ||
175 | return m_lockScreenAction; | 173 | return m_lockScreenAction; | ||
176 | } | 174 | } | ||
177 | } else if (name == QLatin1String("_logout")) { | 175 | } else if (name == QLatin1String("_logout")) { | ||
178 | if (KAuthorized::authorize(QStringLiteral("logout"))) { | 176 | if (KAuthorized::authorize(QStringLiteral("logout"))) { | ||
179 | return m_logoutAction; | 177 | return m_logoutAction; | ||
180 | } | 178 | } | ||
181 | } else if (name == QLatin1String("lock widgets")) { | | |||
182 | if (c->corona()) { | | |||
183 | return c->corona()->actions()->action(QStringLiteral("lock widgets")); | | |||
184 | } | | |||
185 | } else if (name == QLatin1String("edit mode")) { | 179 | } else if (name == QLatin1String("edit mode")) { | ||
186 | if (c->corona()) { | 180 | if (c->corona()) { | ||
187 | return c->corona()->actions()->action(QStringLiteral("edit mode")); | 181 | return c->corona()->actions()->action(QStringLiteral("edit mode")); | ||
188 | } | 182 | } | ||
189 | } else if (name == QLatin1String("manage activities")) { | 183 | } else if (name == QLatin1String("manage activities")) { | ||
190 | if (c->corona()) { | 184 | if (c->corona()) { | ||
191 | return c->corona()->actions()->action(QStringLiteral("manage activities")); | 185 | return c->corona()->actions()->action(QStringLiteral("manage activities")); | ||
192 | } | 186 | } | ||
▲ Show 20 Lines • Show All 128 Lines • Show Last 20 Lines |