Changeset View
Changeset View
Standalone View
Standalone View
krusader/Panel/listpanelactions.cpp
Show All 22 Lines | |||||
23 | #include "listpanel.h" | 23 | #include "listpanel.h" | ||
24 | #include "panelfunc.h" | 24 | #include "panelfunc.h" | ||
25 | #include "PanelView/krviewfactory.h" | 25 | #include "PanelView/krviewfactory.h" | ||
26 | #include "../krmainwindow.h" | 26 | #include "../krmainwindow.h" | ||
27 | #include "../Dialogs/krdialogs.h" | 27 | #include "../Dialogs/krdialogs.h" | ||
28 | #include "../KViewer/krviewer.h" | 28 | #include "../KViewer/krviewer.h" | ||
29 | #include "../icon.h" | 29 | #include "../icon.h" | ||
30 | 30 | | |||
31 | // QtCore | | |||
32 | #include <QSignalMapper> | | |||
33 | // QtWidgets | 31 | // QtWidgets | ||
34 | #include <QActionGroup> | 32 | #include <QActionGroup> | ||
35 | 33 | | |||
36 | #include <KI18n/KLocalizedString> | 34 | #include <KI18n/KLocalizedString> | ||
37 | #include <KXmlGui/KActionCollection> | 35 | #include <KXmlGui/KActionCollection> | ||
38 | 36 | | |||
39 | 37 | | |||
40 | ListPanelActions::ListPanelActions(QObject *parent, KrMainWindow *mainWindow) : | 38 | ListPanelActions::ListPanelActions(QObject *parent, KrMainWindow *mainWindow) : | ||
41 | ActionsBase(parent, mainWindow) | 39 | ActionsBase(parent, mainWindow) | ||
42 | { | 40 | { | ||
43 | // set view type | 41 | // set view type | ||
44 | auto *mapper = new QSignalMapper(this); | | |||
45 | connect(mapper, QOverload<int>::of(&QSignalMapper::mapped), this, &ListPanelActions::setView); | | |||
46 | auto *group = new QActionGroup(this); | 42 | auto *group = new QActionGroup(this); | ||
47 | group->setExclusive(true); | 43 | group->setExclusive(true); | ||
48 | QList<KrViewInstance*> views = KrViewFactory::registeredViews(); | 44 | QList<KrViewInstance*> views = KrViewFactory::registeredViews(); | ||
49 | for(int i = 0; i < views.count(); i++) { | 45 | for(int i = 0; i < views.count(); i++) { | ||
50 | KrViewInstance *inst = views[i]; | 46 | KrViewInstance *inst = views[i]; | ||
51 | QAction *action = new QAction(Icon(inst->iconName()), inst->description(), group); | 47 | QAction *action = new QAction(Icon(inst->iconName()), inst->description(), group); | ||
52 | action->setCheckable(true); | 48 | action->setCheckable(true); | ||
53 | connect(action, &QAction::triggered, mapper, QOverload<>::of(&QSignalMapper::map)); | 49 | connect(action, &QAction::triggered, this, [=] {setView(inst->id());}); | ||
54 | mapper->setMapping(action, inst->id()); | | |||
55 | _mainWindow->actions()->addAction("view" + QString::number(i), action); | 50 | _mainWindow->actions()->addAction("view" + QString::number(i), action); | ||
56 | _mainWindow->actions()->setDefaultShortcut(action, inst->shortcut()); | 51 | _mainWindow->actions()->setDefaultShortcut(action, inst->shortcut()); | ||
57 | setViewActions.insert(inst->id(), action); | 52 | setViewActions.insert(inst->id(), action); | ||
58 | } | 53 | } | ||
59 | 54 | | |||
60 | // standard actions | 55 | // standard actions | ||
61 | actHistoryBackward = stdAction(KStandardAction::Back, _func, SLOT(historyBackward())); | 56 | actHistoryBackward = stdAction(KStandardAction::Back, _func, SLOT(historyBackward())); | ||
62 | actHistoryForward = stdAction(KStandardAction::Forward, _func, SLOT(historyForward())); | 57 | actHistoryForward = stdAction(KStandardAction::Forward, _func, SLOT(historyForward())); | ||
▲ Show 20 Lines • Show All 157 Lines • Show Last 20 Lines |