Commit 7967748c authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Move entries in a menu

parent c364f739
......@@ -16,6 +16,7 @@
#include <KActionCollection>
#include <KLocalizedString>
#include <KMessageBox>
#include <QMenu>
using namespace MessageViewer;
......@@ -98,11 +99,13 @@ void ViewerPluginExternalscriptInterface::clear()
void ViewerPluginExternalscriptInterface::createAction(KActionCollection *ac)
{
if (ac) {
QAction *mainMenu = new QAction(i18n("External Script"), this);
const QVector<ViewerPluginExternalScriptInfo> infos = ViewerPluginExternalScriptManager::self()->scriptInfos();
QMenu *menu = new QMenu;
if (!infos.isEmpty()) {
connect(mActionGroup, &QActionGroup::triggered, this, &ViewerPluginExternalscriptInterface::slotScriptActivated);
for (const ViewerPluginExternalScriptInfo &info : infos) {
QAction *act = new QAction(info.name(), this);
QAction *act = new QAction(info.name(), menu);
act->setIconText(info.name());
const QString &description = info.description();
if (!description.isEmpty()) {
......@@ -116,13 +119,25 @@ void ViewerPluginExternalscriptInterface::createAction(KActionCollection *ac)
const QStringList actionInfo{info.commandLine(), info.executable()};
act->setData(actionInfo);
mAction.append(act);
menu->addAction(act);
mActionGroup->addAction(act);
}
}
if (!infos.isEmpty()) {
menu->addSeparator();
}
QAction *act = new QAction(i18n("Configure"), menu);
connect(act, &QAction::triggered, this, &ViewerPluginExternalscriptInterface::slotConfigure);
menu->addAction(act);
mainMenu->setMenu(menu);
mAction << mainMenu;
}
}
void ViewerPluginExternalscriptInterface::slotConfigure()
{
}
void ViewerPluginExternalscriptInterface::slotScriptActivated(QAction *act)
{
mCurrentInfo = act->data().toStringList();
......
......@@ -32,8 +32,9 @@ private Q_SLOTS:
private:
void createAction(KActionCollection *ac);
void clear();
void slotConfigure();
QList<QAction *> mAction;
QStringList adaptArguments(const QStringList &scriptArguments);
Q_REQUIRED_RESULT QStringList adaptArguments(const QStringList &scriptArguments);
QStringList mCurrentInfo;
QString mText;
QString mAkonadiUrl;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment