one thing one was using actionsFromMenu, not justifiable to put it here
This commit is contained in:
parent
e80bc7d48a
commit
14f9471784
34
plasma.cpp
34
plasma.cpp
@ -92,38 +92,4 @@ QGraphicsView *viewFor(const QGraphicsItem *item)
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QAction*> actionsFromMenu(QMenu *menu, const QString &prefix, QObject *parent)
|
|
||||||
{
|
|
||||||
Q_ASSERT(menu);
|
|
||||||
|
|
||||||
QList<QAction*> ret;
|
|
||||||
foreach (QAction *action, menu->actions()) {
|
|
||||||
if (QMenu *submenu = action->menu()) {
|
|
||||||
//Flatten hierarchy and prefix submenu text to all actions in submenu
|
|
||||||
ret << actionsFromMenu(submenu, action->text(), parent);
|
|
||||||
} else if (!action->isSeparator() && action->isEnabled()) {
|
|
||||||
QString text = action->text();
|
|
||||||
if (action->isCheckable()) {
|
|
||||||
if (action->isChecked()) {
|
|
||||||
text = QString("(%1) %2").arg(QChar(0x2613)).arg(text);
|
|
||||||
} else {
|
|
||||||
text = QString("( ) %1").arg(text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!prefix.isEmpty()) {
|
|
||||||
text = QString("%1: %2").arg(prefix).arg(text);
|
|
||||||
}
|
|
||||||
text = text.replace(QRegExp("&([\\S])"), "\\1");
|
|
||||||
|
|
||||||
QAction *a = new QAction(action->icon(), text, parent);
|
|
||||||
|
|
||||||
QObject::connect(a, SIGNAL(triggered(bool)), action, SIGNAL(triggered(bool)));
|
|
||||||
ret << a;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // Plasma namespace
|
} // Plasma namespace
|
||||||
|
15
plasma.h
15
plasma.h
@ -302,21 +302,6 @@ PLASMA_EXPORT Direction locationToInverseDirection(Location location);
|
|||||||
*/
|
*/
|
||||||
PLASMA_EXPORT QGraphicsView *viewFor(const QGraphicsItem *item);
|
PLASMA_EXPORT QGraphicsView *viewFor(const QGraphicsItem *item);
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a list of all actions in the given QMenu
|
|
||||||
* This method flattens the hierarchy of the menu by prefixing the
|
|
||||||
* text of all actions in a submenu with the submenu title.
|
|
||||||
*
|
|
||||||
* @param menu the QMenu storing the actions
|
|
||||||
* @param prefix text to display before the text of all actions in the menu
|
|
||||||
* @param parent QObject to be passed as parent of all the actions in the list
|
|
||||||
*
|
|
||||||
* @since 4.4
|
|
||||||
*/
|
|
||||||
PLASMA_EXPORT QList<QAction*> actionsFromMenu(QMenu *menu,
|
|
||||||
const QString &prefix = QString(),
|
|
||||||
QObject *parent = 0);
|
|
||||||
|
|
||||||
} // Plasma namespace
|
} // Plasma namespace
|
||||||
|
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::Constraints)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::Constraints)
|
||||||
|
Loading…
Reference in New Issue
Block a user