forked from qt-creator/qt-creator
ModeManager: Remove one use of Id::fromUniqueIdentifier and Co.
Change-Id: I9013d5de89e40fc60a5f021088fb7213eea3dc03 Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
@@ -44,13 +44,11 @@
|
|||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
#include <QSignalMapper>
|
|
||||||
#include <QAction>
|
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -70,7 +68,6 @@ struct ModeManagerPrivate
|
|||||||
QMap<QAction*, int> m_actions;
|
QMap<QAction*, int> m_actions;
|
||||||
QVector<IMode*> m_modes;
|
QVector<IMode*> m_modes;
|
||||||
QVector<Command*> m_modeCommands;
|
QVector<Command*> m_modeCommands;
|
||||||
QSignalMapper *m_signalMapper;
|
|
||||||
Context m_addedContexts;
|
Context m_addedContexts;
|
||||||
int m_oldCurrent;
|
int m_oldCurrent;
|
||||||
bool m_modeSelectorVisible;
|
bool m_modeSelectorVisible;
|
||||||
@@ -96,7 +93,6 @@ ModeManager::ModeManager(Internal::MainWindow *mainWindow,
|
|||||||
d = new ModeManagerPrivate();
|
d = new ModeManagerPrivate();
|
||||||
d->m_mainWindow = mainWindow;
|
d->m_mainWindow = mainWindow;
|
||||||
d->m_modeStack = modeStack;
|
d->m_modeStack = modeStack;
|
||||||
d->m_signalMapper = new QSignalMapper(this);
|
|
||||||
d->m_oldCurrent = -1;
|
d->m_oldCurrent = -1;
|
||||||
d->m_actionBar = new Internal::FancyActionBar(modeStack);
|
d->m_actionBar = new Internal::FancyActionBar(modeStack);
|
||||||
d->m_modeStack->addCornerWidget(d->m_actionBar);
|
d->m_modeStack->addCornerWidget(d->m_actionBar);
|
||||||
@@ -105,7 +101,6 @@ ModeManager::ModeManager(Internal::MainWindow *mainWindow,
|
|||||||
|
|
||||||
connect(d->m_modeStack, SIGNAL(currentAboutToShow(int)), SLOT(currentTabAboutToChange(int)));
|
connect(d->m_modeStack, SIGNAL(currentAboutToShow(int)), SLOT(currentTabAboutToChange(int)));
|
||||||
connect(d->m_modeStack, SIGNAL(currentChanged(int)), SLOT(currentTabChanged(int)));
|
connect(d->m_modeStack, SIGNAL(currentChanged(int)), SLOT(currentTabChanged(int)));
|
||||||
connect(d->m_signalMapper, SIGNAL(mapped(int)), this, SLOT(slotActivateMode(int)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModeManager::init()
|
void ModeManager::init()
|
||||||
@@ -139,12 +134,6 @@ IMode *ModeManager::mode(Id id)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModeManager::slotActivateMode(int id)
|
|
||||||
{
|
|
||||||
m_instance->activateMode(Id::fromUniqueIdentifier(id));
|
|
||||||
ICore::raiseWindow(d->m_modeStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ModeManager::activateMode(Id id)
|
void ModeManager::activateMode(Id id)
|
||||||
{
|
{
|
||||||
const int index = indexOf(id);
|
const int index = indexOf(id);
|
||||||
@@ -190,8 +179,12 @@ void ModeManager::objectAdded(QObject *obj)
|
|||||||
currentCmd->setKeySequence(currentCmd->defaultKeySequence());
|
currentCmd->setKeySequence(currentCmd->defaultKeySequence());
|
||||||
}
|
}
|
||||||
|
|
||||||
d->m_signalMapper->setMapping(action, mode->id().uniqueIdentifier());
|
Id id = mode->id();
|
||||||
connect(action, SIGNAL(triggered()), d->m_signalMapper, SLOT(map()));
|
connect(action, &QAction::triggered, [id] {
|
||||||
|
m_instance->activateMode(id);
|
||||||
|
ICore::raiseWindow(d->m_modeStack);
|
||||||
|
});
|
||||||
|
|
||||||
connect(mode, SIGNAL(enabledStateChanged(bool)),
|
connect(mode, SIGNAL(enabledStateChanged(bool)),
|
||||||
m_instance, SLOT(enabledStateChanged()));
|
m_instance, SLOT(enabledStateChanged()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,6 @@ signals:
|
|||||||
void currentModeChanged(Core::IMode *mode, Core::IMode *oldMode = 0);
|
void currentModeChanged(Core::IMode *mode, Core::IMode *oldMode = 0);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void slotActivateMode(int id);
|
|
||||||
void objectAdded(QObject *obj);
|
void objectAdded(QObject *obj);
|
||||||
void aboutToRemoveObject(QObject *obj);
|
void aboutToRemoveObject(QObject *obj);
|
||||||
void currentTabAboutToChange(int index);
|
void currentTabAboutToChange(int index);
|
||||||
|
|||||||
Reference in New Issue
Block a user