Commit 2bfcb47d authored by Eike Ziller's avatar Eike Ziller

Add an action to show/hide the mode bar on the far left.

Change-Id: If7a74eed7fc77b1d0fd5e4045671b3767fe2d7a2
Reviewed-by: default avatarPetar Perisin <petar.perisin@gmail.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
(cherry picked from commit bde0627e)
parent be62b79f
......@@ -98,6 +98,7 @@ const char EXIT[] = "QtCreator.Exit";
const char OPTIONS[] = "QtCreator.Options";
const char TOGGLE_SIDEBAR[] = "QtCreator.ToggleSidebar";
const char TOGGLE_MODE_SELECTOR[] = "QtCreator.ToggleModeSelector";
const char TOGGLE_FULLSCREEN[] = "QtCreator.ToggleFullScreen";
const char MINIMIZE_WINDOW[] = "QtCreator.MinimizeWindow";
......
......@@ -427,8 +427,14 @@ FancyTabWidget::FancyTabWidget(QWidget *parent)
connect(m_tabBar, SIGNAL(currentChanged(int)), this, SLOT(showWidget(int)));
}
void FancyTabWidget::setSelectionWidgetHidden(bool hidden) {
m_selectionWidget->setHidden(hidden);
void FancyTabWidget::setSelectionWidgetVisible(bool visible)
{
m_selectionWidget->setVisible(visible);
}
bool FancyTabWidget::isSelectionWidgetVisible() const
{
return m_selectionWidget->isVisible();
}
void FancyTabWidget::insertTab(int index, QWidget *tab, const QIcon &icon, const QString &label)
......@@ -456,17 +462,19 @@ void FancyTabWidget::setBackgroundBrush(const QBrush &brush)
void FancyTabWidget::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
QPainter painter(this);
QRect rect = m_selectionWidget->rect().adjusted(0, 0, 1, 0);
rect = style()->visualRect(layoutDirection(), geometry(), rect);
Utils::StyleHelper::verticalGradient(&painter, rect, rect);
painter.setPen(Utils::StyleHelper::borderColor());
painter.drawLine(rect.topRight(), rect.bottomRight());
QColor light = Utils::StyleHelper::sidebarHighlight();
painter.setPen(light);
painter.drawLine(rect.bottomLeft(), rect.bottomRight());
if (m_selectionWidget->isVisible()) {
QPainter painter(this);
QRect rect = m_selectionWidget->rect().adjusted(0, 0, 1, 0);
rect = style()->visualRect(layoutDirection(), geometry(), rect);
Utils::StyleHelper::verticalGradient(&painter, rect, rect);
painter.setPen(Utils::StyleHelper::borderColor());
painter.drawLine(rect.topRight(), rect.bottomRight());
QColor light = Utils::StyleHelper::sidebarHighlight();
painter.setPen(light);
painter.drawLine(rect.bottomLeft(), rect.bottomRight());
}
}
void FancyTabWidget::insertCornerWidget(int pos, QWidget *widget)
......
......@@ -159,13 +159,15 @@ public:
void setTabEnabled(int index, bool enable);
bool isTabEnabled(int index) const;
bool isSelectionWidgetVisible() const;
signals:
void currentAboutToShow(int index);
void currentChanged(int index);
public slots:
void setCurrentIndex(int index);
void setSelectionWidgetHidden(bool hidden);
void setSelectionWidgetVisible(bool visible);
private slots:
void showWidget(int index);
......
......@@ -139,6 +139,7 @@ MainWindow::MainWindow() :
m_modeManager(0),
m_mimeDatabase(new MimeDatabase),
m_helpManager(new HelpManager),
m_modeStack(new FancyTabWidget(this)),
m_navigationWidget(0),
m_rightPaneWidget(0),
m_versionDialog(0),
......@@ -195,14 +196,14 @@ MainWindow::MainWindow() :
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
setCorner(Qt::BottomRightCorner, Qt::BottomDockWidgetArea);
m_modeManager = new ModeManager(this, m_modeStack);
registerDefaultContainers();
registerDefaultActions();
m_navigationWidget = new NavigationWidget(m_toggleSideBarAction);
m_rightPaneWidget = new RightPaneWidget();
m_modeStack = new FancyTabWidget(this);
m_modeManager = new ModeManager(this, m_modeStack);
m_statusBarManager = new StatusBarManager(this);
m_messageManager = new MessageManager;
m_editorManager = new EditorManager(this);
......@@ -727,6 +728,12 @@ void MainWindow::registerDefaultActions()
mwindow->addAction(cmd, Constants::G_WINDOW_VIEWS);
m_toggleSideBarAction->setEnabled(false);
// Show Mode Selector Action
m_toggleModeSelectorAction = new QAction(tr("Show Mode Selector"), this);
m_toggleModeSelectorAction->setCheckable(true);
cmd = ActionManager::registerAction(m_toggleModeSelectorAction, Constants::TOGGLE_MODE_SELECTOR, globalContext);
connect(m_toggleModeSelectorAction, SIGNAL(triggered(bool)), ModeManager::instance(), SLOT(setModeSelectorVisible(bool)));
mwindow->addAction(cmd, Constants::G_WINDOW_VIEWS);
#if defined(Q_OS_MAC)
const QString fullScreenActionText(tr("Enter Full Screen"));
......@@ -1169,6 +1176,7 @@ static const char settingsGroup[] = "MainWindow";
static const char colorKey[] = "Color";
static const char windowGeometryKey[] = "WindowGeometry";
static const char windowStateKey[] = "WindowState";
static const char modeSelectorVisibleKey[] = "ModeSelectorVisible";
void MainWindow::readSettings()
{
......@@ -1188,6 +1196,10 @@ void MainWindow::readSettings()
resize(1008, 700); // size without window decoration
restoreState(m_settings->value(QLatin1String(windowStateKey)).toByteArray());
bool modeSelectorVisible = m_settings->value(QLatin1String(modeSelectorVisibleKey), true).toBool();
ModeManager::instance()->setModeSelectorVisible(modeSelectorVisible);
m_toggleModeSelectorAction->setChecked(modeSelectorVisible);
m_settings->endGroup();
m_editorManager->readSettings();
......@@ -1204,6 +1216,7 @@ void MainWindow::writeSettings()
m_settings->setValue(QLatin1String(windowGeometryKey), saveGeometry());
m_settings->setValue(QLatin1String(windowStateKey), saveState());
m_settings->setValue(QLatin1String(modeSelectorVisibleKey), ModeManager::isModeSelectorVisible());
m_settings->endGroup();
......
......@@ -216,6 +216,7 @@ private:
QAction *m_exitAction;
QAction *m_optionsAction;
QAction *m_toggleSideBarAction;
QAction *m_toggleModeSelectorAction;
QAction *m_toggleFullScreenAction;
QAction *m_minimizeAction;
QAction *m_zoomAction;
......
......@@ -337,9 +337,14 @@ void ModeManager::setFocusToCurrentMode()
}
}
void ModeManager::setModeBarHidden(bool hidden)
void ModeManager::setModeSelectorVisible(bool visible)
{
d->m_modeStack->setSelectionWidgetHidden(hidden);
d->m_modeStack->setSelectionWidgetVisible(visible);
}
bool ModeManager::isModeSelectorVisible()
{
return d->m_modeStack->isSelectionWidgetVisible();
}
ModeManager *ModeManager::instance()
......
......@@ -66,9 +66,12 @@ public:
static void addWidget(QWidget *widget);
static void activateModeType(Id type);
static void setModeBarHidden(bool hidden);
static void activateMode(Id id);
static void setFocusToCurrentMode();
static bool isModeSelectorVisible();
public slots:
void setModeSelectorVisible(bool visible);
signals:
void currentModeAboutToChange(Core::IMode *mode);
......
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