Commit 58a248cb authored by con's avatar con

Navigation widgets need separate id and display name.

Such that the layout of the left hand sidebar can be restored
even if the display language is changed.
parent a47cfaa0
......@@ -774,12 +774,17 @@ BookmarkViewFactory::BookmarkViewFactory(BookmarkManager *bm)
}
QString BookmarkViewFactory::displayName()
QString BookmarkViewFactory::displayName() const
{
return BookmarkView::tr("Bookmarks");
}
QKeySequence BookmarkViewFactory::activationSequence()
QString BookmarkViewFactory::id() const
{
return QLatin1String("Bookmarks");
}
QKeySequence BookmarkViewFactory::activationSequence() const
{
return QKeySequence(Qt::ALT + Qt::Key_M);
}
......
......@@ -169,9 +169,10 @@ class BookmarkViewFactory : public Core::INavigationWidgetFactory
{
public:
BookmarkViewFactory(BookmarkManager *bm);
virtual QString displayName();
virtual QKeySequence activationSequence();
virtual Core::NavigationView createWidget();
QString displayName() const;
QString id() const;
QKeySequence activationSequence() const;
Core::NavigationView createWidget();
private:
BookmarkManager *m_manager;
};
......
......@@ -242,12 +242,17 @@ NavigationView OpenEditorsViewFactory::createWidget()
return n;
}
QString OpenEditorsViewFactory::displayName()
QString OpenEditorsViewFactory::displayName() const
{
return OpenEditorsWidget::tr("Open Documents");
}
QKeySequence OpenEditorsViewFactory::activationSequence()
QString OpenEditorsViewFactory::id() const
{
return QLatin1String("Open Documents");
}
QKeySequence OpenEditorsViewFactory::activationSequence() const
{
return QKeySequence(Qt::ALT + Qt::Key_O);
}
......
......@@ -88,9 +88,10 @@ class OpenEditorsViewFactory : public Core::INavigationWidgetFactory
{
public:
OpenEditorsViewFactory();
virtual ~OpenEditorsViewFactory();
QString displayName();
virtual QKeySequence activationSequence();
~OpenEditorsViewFactory();
QString displayName() const;
QString id() const;
QKeySequence activationSequence() const;
Core::NavigationView createWidget();
};
......
......@@ -41,7 +41,7 @@ INavigationWidgetFactory::~INavigationWidgetFactory()
{
}
QKeySequence INavigationWidgetFactory::activationSequence()
QKeySequence INavigationWidgetFactory::activationSequence() const
{
return QKeySequence();
}
......
......@@ -55,8 +55,9 @@ public:
INavigationWidgetFactory();
virtual ~INavigationWidgetFactory();
virtual QString displayName() = 0;
virtual QKeySequence activationSequence();
virtual QString displayName() const = 0;
virtual QString id() const = 0;
virtual QKeySequence activationSequence() const;
// This design is not optimal, think about it again once we need to extend it
// It could be implemented as returning an object which has both the widget
// and the docktoolbar widgets
......
......@@ -199,15 +199,15 @@ void NavigationWidget::activateSubWidget()
{
setShown(true);
QShortcut *original = qobject_cast<QShortcut *>(sender());
QString title = m_shortcutMap[original];
QString id = m_shortcutMap[original];
foreach (NavigationSubWidget *subWidget, m_subWidgets)
if (subWidget->factory()->displayName() == title) {
if (subWidget->factory()->id() == id) {
subWidget->setFocusWidget();
return;
}
m_subWidgets.first()->setFactory(title);
m_subWidgets.first()->setFactory(id);
m_subWidgets.first()->setFocusWidget();
}
......@@ -237,7 +237,7 @@ void NavigationWidget::saveSettings(QSettings *settings)
{
QStringList views;
for (int i=0; i<m_subWidgets.count(); ++i) {
views.append(m_subWidgets.at(i)->factory()->displayName());
views.append(m_subWidgets.at(i)->factory()->id());
}
settings->setValue("Navigation/Views", views);
settings->setValue("Navigation/Visible", isShown());
......@@ -349,16 +349,16 @@ void NavigationWidget::objectAdded(QObject * obj)
QList<int> navicontext = QList<int>() << core->uniqueIDManager()->
uniqueIdentifier(Core::Constants::C_NAVIGATION_PANE);
QString displayName = factory->displayName();
QString id = factory->id();
QShortcut *shortcut = new QShortcut(this);
shortcut->setWhatsThis(tr("Activate %1 Pane").arg(displayName));
shortcut->setWhatsThis(tr("Activate %1 Pane").arg(factory->displayName()));
Core::Command *cmd = am->registerShortcut(shortcut,
QLatin1String("QtCreator.Sidebar.") + displayName, navicontext);
QLatin1String("QtCreator.Sidebar.") + id, navicontext);
cmd->setDefaultKeySequence(factory->activationSequence());
connect(shortcut, SIGNAL(activated()), this, SLOT(activateSubWidget()));
m_shortcutMap.insert(shortcut, displayName);
m_commandMap.insert(displayName, cmd);
m_shortcutMap.insert(shortcut, id);
m_commandMap.insert(id, cmd);
}
////
......@@ -486,12 +486,12 @@ void NavigationSubWidget::setFactory(INavigationWidgetFactory *factory)
m_navigationComboBox->setCurrentIndex(index);
}
void NavigationSubWidget::setFactory(const QString &name)
void NavigationSubWidget::setFactory(const QString &id)
{
for (int i = 0; i < m_navigationComboBox->count(); ++i) {
INavigationWidgetFactory *factory =
m_navigationComboBox->itemData(i).value<INavigationWidgetFactory *>();
if (factory->displayName() == name)
if (factory->id() == id)
m_navigationComboBox->setCurrentIndex(i);
}
}
......
......@@ -128,7 +128,7 @@ public:
INavigationWidgetFactory *factory();
void setFactory(INavigationWidgetFactory *factory);
void setFactory(const QString &name);
void setFactory(const QString &id);
void setFocusWidget();
void saveSettings(int position);
......
......@@ -309,6 +309,7 @@ void OutputPaneManager::init()
#else
cmd->setDefaultKeySequence(QKeySequence("Alt+9"));
#endif
cmd->setAttribute(Command::CA_UpdateText);
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
m_minMaxButton->setDefaultAction(cmd->action());
connect(m_minMaxAction, SIGNAL(triggered()), this, SLOT(slotMinMax()));
......
......@@ -413,12 +413,17 @@ FolderNavigationWidgetFactory::~FolderNavigationWidgetFactory()
{
}
QString FolderNavigationWidgetFactory::displayName()
QString FolderNavigationWidgetFactory::displayName() const
{
return tr("File System");
}
QKeySequence FolderNavigationWidgetFactory::activationSequence()
QString FolderNavigationWidgetFactory::id() const
{
return QLatin1String("File System");
}
QKeySequence FolderNavigationWidgetFactory::activationSequence() const
{
return QKeySequence(Qt::ALT + Qt::Key_Y);
}
......
......@@ -97,11 +97,12 @@ class FolderNavigationWidgetFactory : public Core::INavigationWidgetFactory
Q_OBJECT
public:
FolderNavigationWidgetFactory();
virtual ~FolderNavigationWidgetFactory();
~FolderNavigationWidgetFactory();
virtual QString displayName();
virtual QKeySequence activationSequence();
virtual Core::NavigationView createWidget();
QString displayName() const;
QString id() const;
QKeySequence activationSequence() const;
Core::NavigationView createWidget();
};
} // namespace Internal
......
......@@ -365,12 +365,17 @@ ProjectTreeWidgetFactory::~ProjectTreeWidgetFactory()
{
}
QString ProjectTreeWidgetFactory::displayName()
QString ProjectTreeWidgetFactory::displayName() const
{
return tr("Projects");
}
QKeySequence ProjectTreeWidgetFactory::activationSequence()
QString ProjectTreeWidgetFactory::id() const
{
return QLatin1String("Projects");
}
QKeySequence ProjectTreeWidgetFactory::activationSequence() const
{
return QKeySequence(Qt::ALT + Qt::Key_X);
}
......
......@@ -98,10 +98,11 @@ class ProjectTreeWidgetFactory : public Core::INavigationWidgetFactory
Q_OBJECT
public:
ProjectTreeWidgetFactory();
virtual ~ProjectTreeWidgetFactory();
virtual QString displayName();
virtual QKeySequence activationSequence();
virtual Core::NavigationView createWidget();
~ProjectTreeWidgetFactory();
QString displayName() const;
QString id() const;
QKeySequence activationSequence() const;
Core::NavigationView createWidget();
void restoreSettings(int position, QWidget *widget);
void saveSettings(int position, QWidget *widget);
};
......
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