From cb1cd84c5a61d041ed9e8c343581b7b72b470598 Mon Sep 17 00:00:00 2001 From: con Date: Thu, 16 Jul 2009 15:00:29 +0200 Subject: [PATCH] Remove usage of QToolBar for navigation side bar. --- .../editormanager/openeditorsview.ui | 25 +++++------ src/plugins/coreplugin/navigationwidget.cpp | 42 ++++++++++--------- src/plugins/coreplugin/navigationwidget.h | 7 ++-- 3 files changed, 36 insertions(+), 38 deletions(-) diff --git a/src/plugins/coreplugin/editormanager/openeditorsview.ui b/src/plugins/coreplugin/editormanager/openeditorsview.ui index 00962bcbec6..a94a803135d 100644 --- a/src/plugins/coreplugin/editormanager/openeditorsview.ui +++ b/src/plugins/coreplugin/editormanager/openeditorsview.ui @@ -1,7 +1,8 @@ - + + OpenEditorsView - - + + 0 0 @@ -9,22 +10,16 @@ 217 - - - 200 - 100 - - - - + + 0 - + 0 - - - + + + true diff --git a/src/plugins/coreplugin/navigationwidget.cpp b/src/plugins/coreplugin/navigationwidget.cpp index 5f2231f627b..fa585831976 100644 --- a/src/plugins/coreplugin/navigationwidget.cpp +++ b/src/plugins/coreplugin/navigationwidget.cpp @@ -44,7 +44,6 @@ #include #include #include -#include #include Q_DECLARE_METATYPE(Core::INavigationWidgetFactory *) @@ -363,27 +362,29 @@ NavigationSubWidget::NavigationSubWidget(NavigationWidget *parentWidget) this, SLOT(aboutToRemoveObject(QObject*))); m_navigationComboBox = new NavComboBox(this); + m_navigationComboBox->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); + m_navigationComboBox->setMinimumContentsLength(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->setContentsMargins(0, 0, 0, 0); - m_toolBar->addWidget(m_navigationComboBox); + m_toolBar = new Core::Utils::StyledBar(this); + QHBoxLayout *toolBarLayout = new QHBoxLayout; + 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); - QAction *close = new QAction(QIcon(":/core/images/closebutton.png"), tr("Close"), this); + QToolButton *splitAction = new QToolButton(); + 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); - spacerItem->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); - m_toolBar->addWidget(spacerItem); - m_toolBar->addAction(m_splitAction); - m_toolBar->addAction(close); + toolBarLayout->addWidget(splitAction); + toolBarLayout->addWidget(close); - m_toolBar->widgetForAction(m_splitAction)->setProperty("type", QLatin1String("dockbutton")); - m_toolBar->widgetForAction(close)->setProperty("type", QLatin1String("dockbutton")); + splitAction->setProperty("type", QLatin1String("dockbutton")); + close->setProperty("type", QLatin1String("dockbutton")); QVBoxLayout *lay = new QVBoxLayout(); lay->setMargin(0); @@ -391,8 +392,8 @@ NavigationSubWidget::NavigationSubWidget(NavigationWidget *parentWidget) setLayout(lay); lay->addWidget(m_toolBar); - connect(m_splitAction, SIGNAL(triggered()), this, SIGNAL(split())); - connect(close, SIGNAL(triggered()), this, SIGNAL(close())); + connect(splitAction, SIGNAL(triggered(QAction*)), this, SIGNAL(split())); + connect(close, SIGNAL(triggered(QAction*)), this, SIGNAL(close())); connect(m_navigationComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setCurrentIndex(int))); @@ -426,8 +427,9 @@ void NavigationSubWidget::setCurrentIndex(int index) // Add Toolbutton m_additionalToolBarWidgets = n.doockToolBarWidgets; + QHBoxLayout *layout = qobject_cast(m_toolBar->layout()); foreach (QToolButton *w, m_additionalToolBarWidgets) { - m_toolBar->insertWidget(m_splitAction, w); + layout->insertWidget(layout->count()-2, w); } } diff --git a/src/plugins/coreplugin/navigationwidget.h b/src/plugins/coreplugin/navigationwidget.h index aaa28788247..c8aee5895e8 100644 --- a/src/plugins/coreplugin/navigationwidget.h +++ b/src/plugins/coreplugin/navigationwidget.h @@ -30,12 +30,14 @@ #ifndef NAVIGATIONWIDGET_H #define NAVIGATIONWIDGET_H +#include +#include + #include #include #include #include #include -#include QT_BEGIN_NAMESPACE class QSettings; @@ -147,8 +149,7 @@ private: NavigationWidget *m_parentWidget; QComboBox *m_navigationComboBox; QWidget *m_navigationWidget; - QToolBar *m_toolBar; - QAction *m_splitAction; + Core::Utils::StyledBar *m_toolBar; QList m_additionalToolBarWidgets; };