Commit 69da534f authored by Serhii Moroz's avatar Serhii Moroz

TextEditor: add right sidebar

Task-number: QTCREATORBUG-9436
Change-Id: Ic0406758a30d52c22c58433f5f35305b798cb462
Reviewed-by: Eike Ziller's avatarEike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale's avatarAlessandro Portale <alessandro.portale@qt.io>
Reviewed-by: default avatarAndré Hartmann <aha_1980@gmx.de>
parent 69f978ef
......@@ -80,8 +80,10 @@
<file>images/replace_b.png</file>
<file>images/replace_b@2x.png</file>
<file>images/reset.png</file>
<file>images/sidebaricon.png</file>
<file>images/sidebaricon@2x.png</file>
<file>images/leftsidebaricon.png</file>
<file>images/leftsidebaricon@2x.png</file>
<file>images/rightsidebaricon.png</file>
<file>images/rightsidebaricon@2x.png</file>
<file>images/splitbutton_horizontal.png</file>
<file>images/splitbutton_horizontal@2x.png</file>
<file>images/undo.png</file>
......
......@@ -131,10 +131,14 @@ const Icon CLEAN_TOOLBAR({
{QLatin1String(":/utils/images/clean_pane_small.png"), Theme::IconsBaseColor}});
const Icon RELOAD({
{QLatin1String(":/utils/images/reload_gray.png"), Theme::IconsBaseColor}});
const Icon TOGGLE_SIDEBAR({
{QLatin1String(":/utils/images/sidebaricon.png"), Theme::PanelTextColorMid}}, Icon::MenuTintedStyle);
const Icon TOGGLE_SIDEBAR_TOOLBAR({
{QLatin1String(":/utils/images/sidebaricon.png"), Theme::IconsBaseColor}});
const Icon TOGGLE_LEFT_SIDEBAR({
{QLatin1String(":/utils/images/leftsidebaricon.png"), Theme::PanelTextColorMid}}, Icon::MenuTintedStyle);
const Icon TOGGLE_LEFT_SIDEBAR_TOOLBAR({
{QLatin1String(":/utils/images/leftsidebaricon.png"), Theme::IconsBaseColor}});
const Icon TOGGLE_RIGHT_SIDEBAR({
{QLatin1String(":/utils/images/rightsidebaricon.png"), Theme::PanelTextColorMid}}, Icon::MenuTintedStyle);
const Icon TOGGLE_RIGHT_SIDEBAR_TOOLBAR({
{QLatin1String(":/utils/images/rightsidebaricon.png"), Theme::IconsBaseColor}});
const Icon CLOSE_TOOLBAR({
{QLatin1String(":/utils/images/close.png"), Theme::IconsBaseColor}});
const Icon CLOSE_FOREGROUND({
......
......@@ -81,8 +81,10 @@ QTCREATOR_UTILS_EXPORT extern const Icon MAGNIFIER;
QTCREATOR_UTILS_EXPORT extern const Icon CLEAN;
QTCREATOR_UTILS_EXPORT extern const Icon CLEAN_TOOLBAR;
QTCREATOR_UTILS_EXPORT extern const Icon RELOAD;
QTCREATOR_UTILS_EXPORT extern const Icon TOGGLE_SIDEBAR;
QTCREATOR_UTILS_EXPORT extern const Icon TOGGLE_SIDEBAR_TOOLBAR;
QTCREATOR_UTILS_EXPORT extern const Icon TOGGLE_LEFT_SIDEBAR;
QTCREATOR_UTILS_EXPORT extern const Icon TOGGLE_LEFT_SIDEBAR_TOOLBAR;
QTCREATOR_UTILS_EXPORT extern const Icon TOGGLE_RIGHT_SIDEBAR;
QTCREATOR_UTILS_EXPORT extern const Icon TOGGLE_RIGHT_SIDEBAR_TOOLBAR;
QTCREATOR_UTILS_EXPORT extern const Icon CLOSE_TOOLBAR;
QTCREATOR_UTILS_EXPORT extern const Icon CLOSE_FOREGROUND;
QTCREATOR_UTILS_EXPORT extern const Icon CLOSE_BACKGROUND;
......
......@@ -162,7 +162,7 @@ public:
BookmarkViewFactory(BookmarkManager *bm);
private:
Core::NavigationView createWidget();
Core::NavigationView createWidget() override;
BookmarkManager *m_manager;
};
......
......@@ -70,33 +70,29 @@ Core::NavigationView NavigationWidgetFactory::createWidget()
*/
static QString settingsPrefix(int position)
{
return QString::fromLatin1("ClassView/Treewidget.%1/FlatMode").arg(position);
return QString::fromLatin1("ClassView.Treewidget.%1.FlatMode").arg(position);
}
//! Flat mode settings
void NavigationWidgetFactory::saveSettings(int position, QWidget *widget)
void NavigationWidgetFactory::saveSettings(QSettings *settings, int position, QWidget *widget)
{
NavigationWidget *pw = qobject_cast<NavigationWidget *>(widget);
QTC_ASSERT(pw, return);
// .beginGroup is not used - to prevent simultaneous access
QString group = settingsPrefix(position);
// Save settings
Core::ICore::settings()->setValue(group, pw->flatMode());
QString settingsGroup = settingsPrefix(position);
settings->setValue(settingsGroup, pw->flatMode());
}
void NavigationWidgetFactory::restoreSettings(int position, QWidget *widget)
void NavigationWidgetFactory::restoreSettings(QSettings *settings, int position, QWidget *widget)
{
NavigationWidget *pw = qobject_cast<NavigationWidget *>(widget);
QTC_ASSERT(pw, return);
// .beginGroup is not used - to prevent simultaneous access
QString group = settingsPrefix(position);
// Load settings
pw->setFlatMode(Core::ICore::settings()->value(group, false).toBool());
QString settingsGroup = settingsPrefix(position);
pw->setFlatMode(settings->value(settingsGroup, false).toBool());
}
} // namespace Internal
......
......@@ -38,13 +38,13 @@ public:
NavigationWidgetFactory();
//! \implements Core::INavigationWidgetFactory::createWidget
Core::NavigationView createWidget();
Core::NavigationView createWidget() override;
//! \implements Core::INavigationWidgetFactory::saveSettings
void saveSettings(int position, QWidget *widget);
void saveSettings(QSettings *settings, int position, QWidget *widget) override;
//! \implements Core::INavigationWidgetFactory::restoreSettings
void restoreSettings(int position, QWidget *widget);
void restoreSettings(QSettings *settings, int position, QWidget *widget) override;
};
} // namespace Internal
......
......@@ -89,13 +89,17 @@ const char PRINT[] = "QtCreator.Print";
const char EXIT[] = "QtCreator.Exit";
const char OPTIONS[] = "QtCreator.Options";
const char TOGGLE_SIDEBAR[] = "QtCreator.ToggleSidebar";
const char TOGGLE_LEFT_SIDEBAR[] = "QtCreator.ToggleLeftSidebar";
const char TOGGLE_RIGHT_SIDEBAR[] = "QtCreator.ToggleRightSidebar";
const char TOGGLE_MODE_SELECTOR[] = "QtCreator.ToggleModeSelector";
const char TOGGLE_FULLSCREEN[] = "QtCreator.ToggleFullScreen";
const char THEMEOPTIONS[] = "QtCreator.ThemeOptions";
const char TR_SHOW_SIDEBAR[] = QT_TRANSLATE_NOOP("Core", "Show Sidebar");
const char TR_HIDE_SIDEBAR[] = QT_TRANSLATE_NOOP("Core", "Hide Sidebar");
const char TR_SHOW_LEFT_SIDEBAR[] = QT_TRANSLATE_NOOP("Core", "Show Left Sidebar");
const char TR_HIDE_LEFT_SIDEBAR[] = QT_TRANSLATE_NOOP("Core", "Hide Left Sidebar");
const char TR_SHOW_RIGHT_SIDEBAR[] = QT_TRANSLATE_NOOP("Core", "Show Right Sidebar");
const char TR_HIDE_RIGHT_SIDEBAR[] = QT_TRANSLATE_NOOP("Core", "Hide Right Sidebar");
const char MINIMIZE_WINDOW[] = "QtCreator.MinimizeWindow";
const char ZOOM_WINDOW[] = "QtCreator.ZoomWindow";
......
......@@ -76,10 +76,12 @@ EditMode::EditMode() :
splitter->setStretchFactor(0, 3);
splitter->setStretchFactor(1, 0);
m_splitter->insertWidget(0, new NavigationWidgetPlaceHolder(Constants::MODE_EDIT));
m_splitter->insertWidget(0, new NavigationWidgetPlaceHolder(Constants::MODE_EDIT, Side::Left));
m_splitter->insertWidget(1, splitter);
m_splitter->insertWidget(2, new NavigationWidgetPlaceHolder(Constants::MODE_EDIT, Side::Right));
m_splitter->setStretchFactor(0, 0);
m_splitter->setStretchFactor(1, 1);
m_splitter->setStretchFactor(2, 0);
connect(ModeManager::instance(), &ModeManager::currentModeChanged,
this, &EditMode::grabEditorManager);
......
......@@ -147,7 +147,7 @@ QKeySequence INavigationWidgetFactory::activationSequence() const
\sa INavigationWidgetFactory::restoreSettings()
*/
void INavigationWidgetFactory::saveSettings(int /* position */, QWidget * /* widget */)
void INavigationWidgetFactory::saveSettings(QSettings * /* settings */, int /* position */, QWidget * /* widget */)
{
}
......@@ -157,6 +157,6 @@ void INavigationWidgetFactory::saveSettings(int /* position */, QWidget * /* wid
\sa INavigationWidgetFactory::saveSettings()
*/
void INavigationWidgetFactory::restoreSettings(int /* position */, QWidget * /* widget */)
void INavigationWidgetFactory::restoreSettings(QSettings * /* settings */, int /* position */, QWidget * /* widget */)
{
}
......@@ -32,6 +32,7 @@
#include <QKeySequence>
QT_BEGIN_NAMESPACE
class QSettings;
class QToolButton;
class QWidget;
QT_END_NAMESPACE
......@@ -69,8 +70,8 @@ public:
// Similar to how IView
virtual NavigationView createWidget() = 0;
virtual void saveSettings(int position, QWidget *widget);
virtual void restoreSettings(int position, QWidget *widget);
virtual void saveSettings(QSettings *settings, int position, QWidget *widget);
virtual void restoreSettings(QSettings *settings, int position, QWidget *widget);
private:
QString m_displayName;
......
......@@ -122,7 +122,8 @@ MainWindow::MainWindow() :
m_toolSettings(new ToolSettings),
m_mimeTypeSettings(new MimeTypeSettings),
m_systemEditor(new SystemEditor),
m_toggleSideBarButton(new QToolButton)
m_toggleLeftSideBarButton(new QToolButton),
m_toggleRightSideBarButton(new QToolButton)
{
(void) new DocumentManager(this);
OutputPaneManager::create();
......@@ -171,7 +172,8 @@ MainWindow::MainWindow() :
registerDefaultContainers();
registerDefaultActions();
m_navigationWidget = new NavigationWidget(m_toggleSideBarAction);
m_leftNavigationWidget = new NavigationWidget(m_toggleLeftSideBarAction, Side::Left);
m_rightNavigationWidget = new NavigationWidget(m_toggleRightSideBarAction, Side::Right);
m_rightPaneWidget = new RightPaneWidget();
m_statusBarManager = new StatusBarManager(this);
......@@ -184,8 +186,11 @@ MainWindow::MainWindow() :
m_progressManager->progressView()->setReferenceWidget(m_modeStack->statusBar());
connect(qApp, &QApplication::focusChanged, this, &MainWindow::updateFocusWidget);
// Add a small Toolbutton for toggling the navigation widget
statusBar()->insertPermanentWidget(0, m_toggleSideBarButton);
// Add small Toolbuttons for toggling the navigation widgets
statusBar()->insertPermanentWidget(0, m_toggleLeftSideBarButton);
int childsCount = statusBar()->findChildren<QWidget *>(QString(), Qt::FindDirectChildrenOnly).count();
statusBar()->insertPermanentWidget(childsCount - 1, m_toggleRightSideBarButton); // before QSizeGrip
// setUnifiedTitleAndToolBarOnMac(true);
//if (HostOsInfo::isAnyUnixHost())
......@@ -200,22 +205,22 @@ MainWindow::MainWindow() :
this, &MainWindow::openDroppedFiles);
}
void MainWindow::setSidebarVisible(bool visible)
NavigationWidget *MainWindow::navigationWidget(Side side) const
{
if (NavigationWidgetPlaceHolder::current()) {
if (m_navigationWidget->isSuppressed() && visible) {
m_navigationWidget->setShown(true);
m_navigationWidget->setSuppressed(false);
} else {
m_navigationWidget->setShown(visible);
}
}
return side == Side::Left ? m_leftNavigationWidget : m_rightNavigationWidget;
}
void MainWindow::setSuppressNavigationWidget(bool suppress)
void MainWindow::setSidebarVisible(bool visible, Side side)
{
if (NavigationWidgetPlaceHolder::current())
m_navigationWidget->setSuppressed(suppress);
if (NavigationWidgetPlaceHolder::current(side)) {
NavigationWidget *navWidget = navigationWidget(side);
if (navWidget->isSuppressed() && visible) {
navWidget->setShown(true);
navWidget->setSuppressed(false);
} else {
navWidget->setShown(visible);
}
}
}
void MainWindow::setOverrideColor(const QColor &color)
......@@ -281,8 +286,10 @@ MainWindow::~MainWindow()
PluginManager::removeObject(m_outputView);
delete m_outputView;
delete m_navigationWidget;
m_navigationWidget = nullptr;
delete m_leftNavigationWidget;
delete m_rightNavigationWidget;
m_leftNavigationWidget = nullptr;
m_rightNavigationWidget = nullptr;
delete m_editorManager;
m_editorManager = nullptr;
......@@ -341,7 +348,8 @@ void MainWindow::extensionsInitialized()
m_statusBarManager->extensionsInitalized();
OutputPaneManager::instance()->init();
m_vcsManager->extensionsInitialized();
m_navigationWidget->setFactories(PluginManager::getObjects<INavigationWidgetFactory>());
m_leftNavigationWidget->setFactories(PluginManager::getObjects<INavigationWidgetFactory>());
m_rightNavigationWidget->setFactories(PluginManager::getObjects<INavigationWidgetFactory>());
readSettings();
updateContext();
......@@ -373,7 +381,8 @@ void MainWindow::closeEvent(QCloseEvent *event)
saveWindowSettings();
m_navigationWidget->closeSubWidgets();
m_leftNavigationWidget->closeSubWidgets();
m_rightNavigationWidget->closeSubWidgets();
event->accept();
}
......@@ -678,21 +687,37 @@ void MainWindow::registerDefaultActions()
mwindow->addSeparator(Constants::G_WINDOW_SIZE);
}
// Show Sidebar Action
m_toggleSideBarAction = new QAction(Utils::Icons::TOGGLE_SIDEBAR.icon(),
QCoreApplication::translate("Core", Constants::TR_SHOW_SIDEBAR),
this);
m_toggleSideBarAction->setCheckable(true);
cmd = ActionManager::registerAction(m_toggleSideBarAction, Constants::TOGGLE_SIDEBAR);
// Show Left Sidebar Action
m_toggleLeftSideBarAction = new QAction(Utils::Icons::TOGGLE_LEFT_SIDEBAR.icon(),
QCoreApplication::translate("Core", Constants::TR_SHOW_LEFT_SIDEBAR),
this);
m_toggleLeftSideBarAction->setCheckable(true);
cmd = ActionManager::registerAction(m_toggleLeftSideBarAction, Constants::TOGGLE_LEFT_SIDEBAR);
cmd->setAttribute(Command::CA_UpdateText);
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+0") : tr("Alt+0")));
connect(m_toggleSideBarAction, &QAction::triggered, this, &MainWindow::setSidebarVisible);
ProxyAction *toggleSideBarProxyAction =
ProxyAction::proxyActionWithIcon(cmd->action(),
Utils::Icons::TOGGLE_SIDEBAR_TOOLBAR.icon());
m_toggleSideBarButton->setDefaultAction(toggleSideBarProxyAction);
connect(m_toggleLeftSideBarAction, &QAction::triggered,
this, [this](bool visible) { setSidebarVisible(visible, Side::Left); });
ProxyAction *toggleLeftSideBarProxyAction =
ProxyAction::proxyActionWithIcon(cmd->action(), Utils::Icons::TOGGLE_LEFT_SIDEBAR_TOOLBAR.icon());
m_toggleLeftSideBarButton->setDefaultAction(toggleLeftSideBarProxyAction);
mwindow->addAction(cmd, Constants::G_WINDOW_VIEWS);
m_toggleLeftSideBarAction->setEnabled(false);
// Show Right Sidebar Action
m_toggleRightSideBarAction = new QAction(Utils::Icons::TOGGLE_RIGHT_SIDEBAR.icon(),
QCoreApplication::translate("Core", Constants::TR_SHOW_RIGHT_SIDEBAR),
this);
m_toggleRightSideBarAction->setCheckable(true);
cmd = ActionManager::registerAction(m_toggleRightSideBarAction, Constants::TOGGLE_RIGHT_SIDEBAR);
cmd->setAttribute(Command::CA_UpdateText);
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Meta+0") : tr("Ctrl+Shift+0")));
connect(m_toggleRightSideBarAction, &QAction::triggered,
this, [this](bool visible) { setSidebarVisible(visible, Side::Right); });
ProxyAction *toggleRightSideBarProxyAction =
ProxyAction::proxyActionWithIcon(cmd->action(), Utils::Icons::TOGGLE_RIGHT_SIDEBAR_TOOLBAR.icon());
m_toggleRightSideBarButton->setDefaultAction(toggleRightSideBarProxyAction);
mwindow->addAction(cmd, Constants::G_WINDOW_VIEWS);
m_toggleSideBarAction->setEnabled(false);
m_toggleRightSideBarButton->setEnabled(false);
// Show Mode Selector Action
m_toggleModeSelectorAction = new QAction(tr("Show Mode Selector"), this);
......@@ -959,7 +984,8 @@ void MainWindow::readSettings()
settings->endGroup();
EditorManagerPrivate::readSettings();
m_navigationWidget->restoreSettings(settings);
m_leftNavigationWidget->restoreSettings(settings);
m_rightNavigationWidget->restoreSettings(settings);
m_rightPaneWidget->readSettings(settings);
}
......@@ -976,7 +1002,8 @@ void MainWindow::saveSettings()
DocumentManager::saveSettings();
ActionManager::saveSettings();
EditorManagerPrivate::saveSettings();
m_navigationWidget->saveSettings(settings);
m_leftNavigationWidget->saveSettings(settings);
m_rightNavigationWidget->saveSettings(settings);
}
void MainWindow::saveWindowSettings()
......
......@@ -56,6 +56,7 @@ class MessageManager;
class ModeManager;
class ProgressManager;
class NavigationWidget;
enum class Side;
class RightPaneWidget;
class SettingsDatabase;
class VcsManager;
......@@ -102,8 +103,6 @@ public:
void updateAdditionalContexts(const Context &remove, const Context &add,
ICore::ContextPriority priority);
void setSuppressNavigationWidget(bool suppress);
void setOverrideColor(const QColor &color);
QStringList additionalAboutInformation() const;
......@@ -135,7 +134,8 @@ private:
void aboutQtCreator();
void aboutPlugins();
void updateFocusWidget(QWidget *old, QWidget *now);
void setSidebarVisible(bool visible);
NavigationWidget *navigationWidget(Side side) const;
void setSidebarVisible(bool visible, Side side);
void destroyVersionDialog();
void openDroppedFiles(const QList<Utils::DropSupport::FileSpec> &files);
void restoreWindowState();
......@@ -166,7 +166,8 @@ private:
ModeManager *m_modeManager = nullptr;
HelpManager *m_helpManager = nullptr;
FancyTabWidget *m_modeStack = nullptr;
NavigationWidget *m_navigationWidget = nullptr;
NavigationWidget *m_leftNavigationWidget = nullptr;
NavigationWidget *m_rightNavigationWidget = nullptr;
RightPaneWidget *m_rightPaneWidget = nullptr;
StatusBarWidget *m_outputView = nullptr;
VersionDialog *m_versionDialog = nullptr;
......@@ -190,11 +191,13 @@ private:
QAction *m_saveAllAction = nullptr;
QAction *m_exitAction = nullptr;
QAction *m_optionsAction = nullptr;
QAction *m_toggleSideBarAction = nullptr;
QAction *m_toggleLeftSideBarAction = nullptr;
QAction *m_toggleRightSideBarAction = nullptr;
QAction *m_toggleModeSelectorAction = nullptr;
QAction *m_themeAction = nullptr;
QToolButton *m_toggleSideBarButton = nullptr;
QToolButton *m_toggleLeftSideBarButton = nullptr;
QToolButton *m_toggleRightSideBarButton = nullptr;
QColor m_overrideColor;
QList<std::function<bool()>> m_preCloseListeners;
};
......
......@@ -30,6 +30,7 @@
#include "actionmanager/command.h"
#include "id.h"
#include <coreplugin/icore.h>
#include <utils/styledbar.h>
#include <utils/utilsicons.h>
......@@ -137,6 +138,7 @@ void NavigationSubWidget::comboBoxIndexChanged(int factoryIndex)
}
restoreSettings();
emit factoryIndexChanged(factoryIndex);
}
void NavigationSubWidget::populateSplitMenu()
......@@ -167,14 +169,22 @@ void NavigationSubWidget::saveSettings()
{
if (!m_navigationWidget || !factory())
return;
factory()->saveSettings(position(), m_navigationWidget);
QSettings *settings = Core::ICore::settings();
settings->beginGroup(m_parentWidget->settingsGroup());
factory()->saveSettings(settings, position(), m_navigationWidget);
settings->endGroup();
}
void NavigationSubWidget::restoreSettings()
{
if (!m_navigationWidget || !factory())
return;
factory()->restoreSettings(position(), m_navigationWidget);
QSettings *settings = Core::ICore::settings();
settings->beginGroup(m_parentWidget->settingsGroup());
factory()->restoreSettings(settings, position(), m_navigationWidget);
settings->endGroup();
}
Core::Command *NavigationSubWidget::command(const QString &title) const
......
......@@ -47,7 +47,7 @@ class NavigationSubWidget : public QWidget
{
Q_OBJECT
public:
NavigationSubWidget(NavigationWidget *parentWidget, int position, int index);
NavigationSubWidget(NavigationWidget *parentWidget, int position, int factoryIndex);
virtual ~NavigationSubWidget();
INavigationWidgetFactory *factory();
......@@ -71,6 +71,7 @@ public:
signals:
void splitMe(int factoryIndex);
void closeMe();
void factoryIndexChanged(int factoryIndex);
private:
void comboBoxIndexChanged(int);
......
This diff is collapsed.
......@@ -43,22 +43,30 @@ class NavigationWidget;
struct NavigationWidgetPrivate;
namespace Internal { class NavigationSubWidget; }
enum class Side {
Left,
Right
};
class CORE_EXPORT NavigationWidgetPlaceHolder : public QWidget
{
Q_OBJECT
friend class Core::NavigationWidget;
public:
explicit NavigationWidgetPlaceHolder(Id mode, QWidget *parent = 0);
explicit NavigationWidgetPlaceHolder(Id mode, Side side, QWidget *parent = 0);
virtual ~NavigationWidgetPlaceHolder();
static NavigationWidgetPlaceHolder* current();
static NavigationWidgetPlaceHolder *current(Side side);
static void setCurrent(Side side, NavigationWidgetPlaceHolder *navWidget);
void applyStoredSize(int width);
private:
void currentModeAboutToChange(Id mode);
Id m_mode;
static NavigationWidgetPlaceHolder* m_current;
Side m_side;
static NavigationWidgetPlaceHolder *s_currentLeft;
static NavigationWidgetPlaceHolder *s_currentRight;
};
class CORE_EXPORT NavigationWidget : public MiniSplitter
......@@ -72,15 +80,16 @@ public:
FactoryPriorityRole
};
explicit NavigationWidget(QAction *toggleSideBarAction);
explicit NavigationWidget(QAction *toggleSideBarAction, Side side);
virtual ~NavigationWidget();
void setFactories(const QList<INavigationWidgetFactory*> &factories);
QString settingsGroup() const;
void saveSettings(QSettings *settings);
void restoreSettings(QSettings *settings);
QWidget *activateSubWidget(Id factoryId);
QWidget *activateSubWidget(Id factoryId, int preferredPosition);
void closeSubWidgets();
bool isShown() const;
......@@ -89,7 +98,8 @@ public:
bool isSuppressed() const;
void setSuppressed(bool b);
static NavigationWidget* instance();
static NavigationWidget *instance(Side side);
static QWidget *activateSubWidget(Id factoryId, Side fallbackSide);
int storedWidth();
......@@ -106,8 +116,10 @@ private:
void splitSubWidget(int factoryIndex);
void closeSubWidget();
void updateToggleText();
Internal::NavigationSubWidget *insertSubItem(int position, int index);
Internal::NavigationSubWidget *insertSubItem(int position, int factoryIndex);
int factoryIndex(Id id);
QString settingsKey(const QString &key) const;
void onSubWidgetFactoryIndexChanged(int factoryIndex);
NavigationWidgetPrivate *d;
};
......
......@@ -366,8 +366,7 @@ QList<QObject *> CppEditorPlugin::createTestObjects() const
void CppEditorPlugin::openTypeHierarchy()
{
if (currentCppEditorWidget()) {
NavigationWidget *navigation = NavigationWidget::instance();
navigation->activateSubWidget(Constants::TYPE_HIERARCHY_ID);
NavigationWidget::activateSubWidget(Constants::TYPE_HIERARCHY_ID, Side::Left);
emit typeHierarchyRequested();
}
}
......@@ -375,8 +374,7 @@ void CppEditorPlugin::openTypeHierarchy()
void CppEditorPlugin::openIncludeHierarchy()
{
if (currentCppEditorWidget()) {
NavigationWidget *navigation = NavigationWidget::instance();
navigation->activateSubWidget(Id(Constants::INCLUDE_HIERARCHY_ID));
NavigationWidget::activateSubWidget(Constants::INCLUDE_HIERARCHY_ID, Side::Left);
emit includeHierarchyRequested();
}
}
......
......@@ -104,7 +104,7 @@ class CppTypeHierarchyFactory : public Core::INavigationWidgetFactory
public:
CppTypeHierarchyFactory();
virtual Core::NavigationView createWidget();
Core::NavigationView createWidget() override;
};
} // namespace Internal
......
......@@ -258,7 +258,7 @@ QWidget *createModeWindow(const Core::Id &mode, DebuggerMainWindow *mainWindow)
// Navigation and right-side window.
auto splitter = new MiniSplitter;
splitter->setFocusProxy(mainWindow->centralWidgetStack());
splitter->addWidget(new NavigationWidgetPlaceHolder(mode));
splitter->addWidget(new NavigationWidgetPlaceHolder(mode, Side::Left));
splitter->addWidget(mainWindowSplitter);
splitter->setStretchFactor(0, 0);
splitter->setStretchFactor(1, 1);
......
......@@ -127,19 +127,19 @@ HelpWidget::HelpWidget(const Core::Context &context, WidgetStyle style, QWidget
setAttribute(Qt::WA_QuitOnClose, false); // don't prevent Qt Creator from closing
}
if (style != SideBarWidget) {
m_toggleSideBarAction = new QAction(Utils::Icons::TOGGLE_SIDEBAR_TOOLBAR.icon(),
QCoreApplication::translate("Core", Core::Constants::TR_SHOW_SIDEBAR),
m_toggleSideBarAction = new QAction(Utils::Icons::TOGGLE_LEFT_SIDEBAR_TOOLBAR.icon(),
QCoreApplication::translate("Core", Core::Constants::TR_SHOW_LEFT_SIDEBAR),
toolBar);
m_toggleSideBarAction->setCheckable(true);
m_toggleSideBarAction->setChecked(false);
cmd = Core::ActionManager::registerAction(m_toggleSideBarAction,
Core::Constants::TOGGLE_SIDEBAR, context);
Core::Constants::TOGGLE_LEFT_SIDEBAR, context);
connect(m_toggleSideBarAction, &QAction::toggled, m_toggleSideBarAction,
[this](bool checked) {
m_toggleSideBarAction->setText(
QCoreApplication::translate("Core",
checked ? Core::Constants::TR_HIDE_SIDEBAR
: Core::Constants::TR_SHOW_SIDEBAR));
checked ? Core::Constants::TR_HIDE_LEFT_SIDEBAR
: Core::Constants::TR_SHOW_LEFT_SIDEBAR));
});
addSideBar();
m_toggleSideBarAction->setChecked(m_sideBar->isVisibleTo(this));
......@@ -299,7 +299,7 @@ HelpWidget::~HelpWidget()
Core::ActionManager::unregisterAction(m_copy, Core::Constants::COPY);
Core::ActionManager::unregisterAction(m_printAction, Core::Constants::PRINT);
if (m_toggleSideBarAction)
Core::ActionManager::unregisterAction(m_toggleSideBarAction, Core::Constants::TOGGLE_SIDEBAR);
Core::ActionManager::unregisterAction(m_toggleSideBarAction, Core::Constants::TOGGLE_LEFT_SIDEBAR);
if (m_switchToHelp)
Core::ActionManager::unregisterAction(m_switchToHelp, Constants::CONTEXT_HELP);
Core::ActionManager::unregisterAction(m_homeAction, Constants::HELP_HOME);
......
......@@ -433,21 +433,19 @@ Core::NavigationView FolderNavigationWidgetFactory::createWidget()
return n;
}
void FolderNavigationWidgetFactory::saveSettings(int position, QWidget *widget)
void FolderNavigationWidgetFactory::saveSettings(QSettings *settings, int position, QWidget *widget)
{
auto fnw = qobject_cast<FolderNavigationWidget *>(widget);
QTC_ASSERT(fnw, return);
QSettings *settings = Core::ICore::settings();
const QString baseKey = QLatin1String("FolderNavigationWidget.") + QString::number(position);
settings->setValue(baseKey + QLatin1String(".HiddenFilesFilter"), fnw->hiddenFilesFilter());
settings->setValue(baseKey + QLatin1String(".SyncWithEditor"), fnw->autoSynchronization());
}
void FolderNavigationWidgetFactory::restoreSettings(int position, QWidget *widget)
void FolderNavigationWidgetFactory::restoreSettings(QSettings *settings, int position, QWidget *widget)
{
auto fnw = qobject_cast<FolderNavigationWidget *>(widget);
QTC_ASSERT(fnw, return);
QSettings *settings = Core::ICore::settings();
const QString baseKey = QLatin1String("FolderNavigationWidget.") + QString::number(position);
fnw->setHiddenFilesFilter(settings->value(baseKey + QLatin1String(".HiddenFilesFilter"), false).toBool());
fnw->setAutoSynchronization(settings->value(baseKey + QLatin1String(".SyncWithEditor"), true).toBool());
......
......@@ -94,8 +94,8 @@ public:
FolderNavigationWidgetFactory();
Core::NavigationView createWidget() override;
void saveSettings(int position, QWidget *widget) override;
void restoreSettings(int position, QWidget *widget) override;
void saveSettings(QSettings *settings, int position, QWidget *widget) override;
void restoreSettings(QSettings *settings, int position, QWidget *widget) override;
};
} // namespace Internal
......
......@@ -366,10 +366,9 @@ void ProjectTree::highlightProject(Project *project, const QString &message)
{
Core::ModeManager::activateMode(Core::Constants::MODE_EDIT);
Core::NavigationWidget *navigation = Core::NavigationWidget::instance();
// Shows and focusses a project tree
QWidget *widget = navigation->activateSubWidget(ProjectExplorer::Constants::PROJECTTREE_ID);
QWidget *widget = Core::NavigationWidget::activateSubWidget(ProjectExplorer::Constants::PROJECTTREE_ID, Core::Side::Left);
if (auto *projectTreeWidget = qobject_cast<ProjectTreeWidget *>(widget))
projectTreeWidget->showMessage(project->rootProjectNode(), message);
......
......@@ -468,22 +468,20 @@ NavigationView ProjectTreeWidgetFactory::createWidget()
return n;