forked from qt-creator/qt-creator
Remove usage of QToolBar for navigation side bar.
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>OpenEditorsView</class>
|
<class>OpenEditorsView</class>
|
||||||
<widget class="QWidget" name="OpenEditorsView">
|
<widget class="QWidget" name="OpenEditorsView">
|
||||||
@@ -9,12 +10,6 @@
|
|||||||
<height>217</height>
|
<height>217</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize" >
|
|
||||||
<size>
|
|
||||||
<width>200</width>
|
|
||||||
<height>100</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout">
|
<layout class="QGridLayout">
|
||||||
<property name="margin">
|
<property name="margin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
|
|||||||
@@ -44,7 +44,6 @@
|
|||||||
#include <QtGui/QAction>
|
#include <QtGui/QAction>
|
||||||
#include <QtGui/QHBoxLayout>
|
#include <QtGui/QHBoxLayout>
|
||||||
#include <QtGui/QResizeEvent>
|
#include <QtGui/QResizeEvent>
|
||||||
#include <QtGui/QToolBar>
|
|
||||||
#include <QtGui/QToolButton>
|
#include <QtGui/QToolButton>
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(Core::INavigationWidgetFactory *)
|
Q_DECLARE_METATYPE(Core::INavigationWidgetFactory *)
|
||||||
@@ -363,27 +362,29 @@ NavigationSubWidget::NavigationSubWidget(NavigationWidget *parentWidget)
|
|||||||
this, SLOT(aboutToRemoveObject(QObject*)));
|
this, SLOT(aboutToRemoveObject(QObject*)));
|
||||||
|
|
||||||
m_navigationComboBox = new NavComboBox(this);
|
m_navigationComboBox = new NavComboBox(this);
|
||||||
|
m_navigationComboBox->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
|
||||||
|
m_navigationComboBox->setMinimumContentsLength(0);
|
||||||
m_navigationWidget = 0;
|
m_navigationWidget = 0;
|
||||||
#ifdef Q_WS_MAC
|
|
||||||
// this is to avoid ugly tool bar behavior
|
|
||||||
m_navigationComboBox->setMaximumWidth(130);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_toolBar = new QToolBar(this);
|
m_toolBar = new Core::Utils::StyledBar(this);
|
||||||
m_toolBar->setContentsMargins(0, 0, 0, 0);
|
QHBoxLayout *toolBarLayout = new QHBoxLayout;
|
||||||
m_toolBar->addWidget(m_navigationComboBox);
|
toolBarLayout->setMargin(0);
|
||||||
|
toolBarLayout->setSpacing(0);
|
||||||
|
m_toolBar->setLayout(toolBarLayout);
|
||||||
|
toolBarLayout->addWidget(m_navigationComboBox);
|
||||||
|
|
||||||
m_splitAction = new QAction(QIcon(":/core/images/splitbutton_horizontal.png"), tr("Split"), this);
|
QToolButton *splitAction = new QToolButton();
|
||||||
QAction *close = new QAction(QIcon(":/core/images/closebutton.png"), tr("Close"), this);
|
splitAction->setIcon(QIcon(":/core/images/splitbutton_horizontal.png"));
|
||||||
|
splitAction->setToolTip(tr("Split"));
|
||||||
|
QToolButton *close = new QToolButton();
|
||||||
|
close->setIcon(QIcon(":/core/images/closebutton.png"));
|
||||||
|
close->setToolTip(tr("Close"));
|
||||||
|
|
||||||
QWidget *spacerItem = new QWidget(this);
|
toolBarLayout->addWidget(splitAction);
|
||||||
spacerItem->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
|
toolBarLayout->addWidget(close);
|
||||||
m_toolBar->addWidget(spacerItem);
|
|
||||||
m_toolBar->addAction(m_splitAction);
|
|
||||||
m_toolBar->addAction(close);
|
|
||||||
|
|
||||||
m_toolBar->widgetForAction(m_splitAction)->setProperty("type", QLatin1String("dockbutton"));
|
splitAction->setProperty("type", QLatin1String("dockbutton"));
|
||||||
m_toolBar->widgetForAction(close)->setProperty("type", QLatin1String("dockbutton"));
|
close->setProperty("type", QLatin1String("dockbutton"));
|
||||||
|
|
||||||
QVBoxLayout *lay = new QVBoxLayout();
|
QVBoxLayout *lay = new QVBoxLayout();
|
||||||
lay->setMargin(0);
|
lay->setMargin(0);
|
||||||
@@ -391,8 +392,8 @@ NavigationSubWidget::NavigationSubWidget(NavigationWidget *parentWidget)
|
|||||||
setLayout(lay);
|
setLayout(lay);
|
||||||
lay->addWidget(m_toolBar);
|
lay->addWidget(m_toolBar);
|
||||||
|
|
||||||
connect(m_splitAction, SIGNAL(triggered()), this, SIGNAL(split()));
|
connect(splitAction, SIGNAL(triggered(QAction*)), this, SIGNAL(split()));
|
||||||
connect(close, SIGNAL(triggered()), this, SIGNAL(close()));
|
connect(close, SIGNAL(triggered(QAction*)), this, SIGNAL(close()));
|
||||||
connect(m_navigationComboBox, SIGNAL(currentIndexChanged(int)),
|
connect(m_navigationComboBox, SIGNAL(currentIndexChanged(int)),
|
||||||
this, SLOT(setCurrentIndex(int)));
|
this, SLOT(setCurrentIndex(int)));
|
||||||
|
|
||||||
@@ -426,8 +427,9 @@ void NavigationSubWidget::setCurrentIndex(int index)
|
|||||||
|
|
||||||
// Add Toolbutton
|
// Add Toolbutton
|
||||||
m_additionalToolBarWidgets = n.doockToolBarWidgets;
|
m_additionalToolBarWidgets = n.doockToolBarWidgets;
|
||||||
|
QHBoxLayout *layout = qobject_cast<QHBoxLayout *>(m_toolBar->layout());
|
||||||
foreach (QToolButton *w, m_additionalToolBarWidgets) {
|
foreach (QToolButton *w, m_additionalToolBarWidgets) {
|
||||||
m_toolBar->insertWidget(m_splitAction, w);
|
layout->insertWidget(layout->count()-2, w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,12 +30,14 @@
|
|||||||
#ifndef NAVIGATIONWIDGET_H
|
#ifndef NAVIGATIONWIDGET_H
|
||||||
#define NAVIGATIONWIDGET_H
|
#define NAVIGATIONWIDGET_H
|
||||||
|
|
||||||
|
#include <coreplugin/minisplitter.h>
|
||||||
|
#include <utils/styledbar.h>
|
||||||
|
|
||||||
#include <QtGui/QWidget>
|
#include <QtGui/QWidget>
|
||||||
#include <QtGui/QComboBox>
|
#include <QtGui/QComboBox>
|
||||||
#include <QtGui/QSplitter>
|
#include <QtGui/QSplitter>
|
||||||
#include <QtGui/QToolBar>
|
#include <QtGui/QToolBar>
|
||||||
#include <QtGui/QToolButton>
|
#include <QtGui/QToolButton>
|
||||||
#include <coreplugin/minisplitter.h>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QSettings;
|
class QSettings;
|
||||||
@@ -147,8 +149,7 @@ private:
|
|||||||
NavigationWidget *m_parentWidget;
|
NavigationWidget *m_parentWidget;
|
||||||
QComboBox *m_navigationComboBox;
|
QComboBox *m_navigationComboBox;
|
||||||
QWidget *m_navigationWidget;
|
QWidget *m_navigationWidget;
|
||||||
QToolBar *m_toolBar;
|
Core::Utils::StyledBar *m_toolBar;
|
||||||
QAction *m_splitAction;
|
|
||||||
QList<QToolButton *> m_additionalToolBarWidgets;
|
QList<QToolButton *> m_additionalToolBarWidgets;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user