diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp index 043e3ed2d444f3707614087bde6a033231f969d0..decb9fa9af29933fe3b8c021b0d9753b37635b7d 100644 --- a/src/plugins/help/helpplugin.cpp +++ b/src/plugins/help/helpplugin.cpp @@ -82,7 +82,6 @@ #include <QtGui/QShortcut> #include <QtGui/QStackedLayout> #include <QtGui/QSplitter> -#include <QtGui/QToolBar> #include <QtHelp/QHelpEngine> @@ -110,6 +109,16 @@ const char * const SB_OPENPAGES = "OpenPages"; # define DOCPATH "/../share/doc/qtcreator/" #endif +namespace { + QToolButton* toolButton(QAction *action) + { + QToolButton *button = new QToolButton; + button->setDefaultAction(action); + button->setPopupMode(QToolButton::DelayedPopup); + return button; + } +} + HelpPlugin::HelpPlugin() : m_mode(0), m_core(0), @@ -528,55 +537,44 @@ void HelpPlugin::createRightPaneContextViewer() if (m_helpViewerForSideBar) return; - QAction *switchToHelp = new QAction(tr("Go to Help Mode"), this); - connect(switchToHelp, SIGNAL(triggered()), this, SLOT(switchToHelpMode())); + Utils::StyledBar *toolBar = new Utils::StyledBar(); + QAction *switchToHelp = new QAction(tr("Go to Help Mode"), toolBar); + connect(switchToHelp, SIGNAL(triggered()), this, SLOT(switchToHelpMode())); QAction *back = new QAction(QIcon(QLatin1String(IMAGEPATH "previous.png")), - tr("Previous"), this); + tr("Previous"), toolBar); QAction *next = new QAction(QIcon(QLatin1String(IMAGEPATH "next.png")), - tr("Next"), this); - - // Dummy layout to align the close button to the right - QHBoxLayout *hboxLayout = new QHBoxLayout(); - hboxLayout->setSpacing(0); - hboxLayout->setMargin(0); - - // left side actions - QToolBar *rightPaneToolBar = new QToolBar(); - setupNavigationMenus(back, next, rightPaneToolBar); + tr("Next"), toolBar); + QAction *close = new QAction(QIcon(QLatin1String(Core::Constants::ICON_CLOSE)), + QLatin1String(""), toolBar); + connect(close, SIGNAL(triggered()), this, SLOT(slotHideRightPane())); - rightPaneToolBar->addAction(switchToHelp); - rightPaneToolBar->addAction(back); - rightPaneToolBar->addAction(next); - - hboxLayout->addWidget(rightPaneToolBar); - hboxLayout->addStretch(); - - QToolButton *closeButton = new QToolButton(); - closeButton->setIcon(QIcon(QLatin1String(Core::Constants::ICON_CLOSE))); - connect(closeButton, SIGNAL(clicked()), this, SLOT(slotHideRightPane())); + setupNavigationMenus(back, next, toolBar); - // close button to the right - hboxLayout->addWidget(closeButton); + QHBoxLayout *layout = new QHBoxLayout(toolBar); + layout->setSpacing(0); + layout->setMargin(0); - QVBoxLayout *rightPaneLayout = new QVBoxLayout; - rightPaneLayout->setMargin(0); - rightPaneLayout->setSpacing(0); + layout->addWidget(toolButton(switchToHelp)); + layout->addWidget(toolButton(back)); + layout->addWidget(toolButton(next)); + layout->addStretch(); + layout->addWidget(toolButton(close)); QWidget *rightPaneSideBar = new QWidget; - rightPaneSideBar->setLayout(rightPaneLayout); addAutoReleasedObject(new Core::BaseRightPaneWidget(rightPaneSideBar)); - Utils::StyledBar *rightPaneStyledBar = new Utils::StyledBar; - rightPaneStyledBar->setLayout(hboxLayout); - rightPaneLayout->addWidget(rightPaneStyledBar); - m_helpViewerForSideBar = new HelpViewer(qreal(0.0), rightPaneSideBar); connect(m_helpViewerForSideBar, SIGNAL(openFindToolBar()), this, SLOT(openFindToolBar())); #if !defined(QT_NO_WEBKIT) m_helpViewerForSideBar->pageAction(QWebPage::OpenLinkInNewWindow)->setVisible(false); #endif + + QVBoxLayout *rightPaneLayout = new QVBoxLayout(rightPaneSideBar); + rightPaneLayout->setMargin(0); + rightPaneLayout->setSpacing(0); + rightPaneLayout->addWidget(toolBar); rightPaneLayout->addWidget(m_helpViewerForSideBar); rightPaneLayout->addWidget(new Core::FindToolBarPlaceHolder(rightPaneSideBar)); rightPaneSideBar->setFocusProxy(m_helpViewerForSideBar); @@ -594,12 +592,12 @@ void HelpPlugin::createRightPaneContextViewer() copy->setIcon(cmd->action()->icon()); connect(copy, SIGNAL(triggered()), m_helpViewerForSideBar, SLOT(copy())); - + next->setEnabled(m_helpViewerForSideBar->isForwardAvailable()); connect(next, SIGNAL(triggered()), m_helpViewerForSideBar, SLOT(forward())); connect(m_helpViewerForSideBar, SIGNAL(forwardAvailable(bool)), next, SLOT(setEnabled(bool))); - + back->setEnabled(m_helpViewerForSideBar->isBackwardAvailable()); connect(back, SIGNAL(triggered()), m_helpViewerForSideBar, SLOT(backward())); connect(m_helpViewerForSideBar, SIGNAL(backwardAvailable(bool)), back, @@ -924,25 +922,15 @@ void HelpPlugin::activateBookmarks() m_sideBar->activateItem(m_bookmarkItem); } -QToolBar *HelpPlugin::createWidgetToolBar() +Utils::StyledBar *HelpPlugin::createWidgetToolBar() { - QToolBar *toolBar = new QToolBar; - toolBar->addWidget(OpenPagesManager::instance().openPagesComboBox()); - - toolBar->addWidget(new QLabel(tr("Filtered by:"))); m_filterComboBox = new QComboBox; - m_filterComboBox->setMinimumContentsLength(20); - toolBar->addWidget(m_filterComboBox); + m_filterComboBox->setMinimumContentsLength(15); connect(m_filterComboBox, SIGNAL(activated(QString)), this, SLOT(filterDocumentation(QString))); connect(m_filterComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSideBarSource())); - QWidget *dummy = new QWidget; - QHBoxLayout *layout = new QHBoxLayout(dummy); - layout->addStretch(); - toolBar->addWidget(dummy); - m_closeButton = new QToolButton(); m_closeButton->setIcon(QIcon(QLatin1String(Core::Constants::ICON_CLOSE))); m_closeButton->setToolTip(tr("Close current page")); @@ -950,14 +938,26 @@ QToolBar *HelpPlugin::createWidgetToolBar() SLOT(closeCurrentPage())); connect(&OpenPagesManager::instance(), SIGNAL(pagesChanged()), this, SLOT(updateCloseButton())); - toolBar->addWidget(m_closeButton); + + Utils::StyledBar *toolBar = new Utils::StyledBar; + + QHBoxLayout *layout = new QHBoxLayout(toolBar); + layout->setMargin(0); + layout->setSpacing(0); + layout->addWidget(OpenPagesManager::instance().openPagesComboBox(), 10); + layout->addSpacing(5); + layout->addWidget(new QLabel(tr("Filtered by:"))); + layout->addWidget(m_filterComboBox); + layout->addStretch(); + layout->addWidget(m_closeButton); return toolBar; } -QToolBar *HelpPlugin::createIconToolBar(bool external) +Utils::StyledBar *HelpPlugin::createIconToolBar(bool external) { - QToolBar *toolBar = new QToolBar; + Utils::StyledBar *toolBar = new Utils::StyledBar; + toolBar->setVisible(false); QAction *home, *back, *next, *bookmark; if (external) { @@ -992,14 +992,15 @@ QToolBar *HelpPlugin::createIconToolBar(bool external) setupNavigationMenus(back, next, toolBar); - toolBar->addAction(home); - toolBar->addAction(back); - toolBar->addAction(next); - toolBar->addSeparator(); - toolBar->addAction(bookmark); - toolBar->setMovable(false); - toolBar->addSeparator(); - toolBar->setVisible(false); + QHBoxLayout *layout = new QHBoxLayout(toolBar); + layout->setMargin(0); + layout->setSpacing(0); + layout->addWidget(toolButton(home)); + layout->addWidget(toolButton(back)); + layout->addWidget(toolButton(next)); + layout->addWidget(new Utils::StyledSeparator(toolBar)); + layout->addWidget(toolButton(bookmark)); + layout->addWidget(new Utils::StyledSeparator(toolBar)); return toolBar; } diff --git a/src/plugins/help/helpplugin.h b/src/plugins/help/helpplugin.h index 8330b96f7f013e0ff4fe45d769959a08636b3b8b..0d387691cabb346f6b06f22623e0c5790e679ab6 100644 --- a/src/plugins/help/helpplugin.h +++ b/src/plugins/help/helpplugin.h @@ -37,7 +37,6 @@ QT_FORWARD_DECLARE_CLASS(QAction) QT_FORWARD_DECLARE_CLASS(QComboBox) QT_FORWARD_DECLARE_CLASS(QMenu) -QT_FORWARD_DECLARE_CLASS(QToolBar) QT_FORWARD_DECLARE_CLASS(QToolButton) QT_FORWARD_DECLARE_CLASS(QUrl) @@ -49,6 +48,10 @@ class SideBar; class SideBarItem; } // Core +namespace Utils { +class StyledBar; +} // Utils + namespace Help { namespace Internal { class CentralWidget; @@ -116,8 +119,8 @@ private: void setupUi(); void resetFilter(); void activateHelpMode(); - QToolBar *createWidgetToolBar(); - QToolBar *createIconToolBar(bool external); + Utils::StyledBar *createWidgetToolBar(); + Utils::StyledBar *createIconToolBar(bool external); HelpViewer* viewerForContextMode(); void createRightPaneContextViewer(); @@ -162,8 +165,8 @@ private: QMenu *m_backMenu; QMenu *m_nextMenu; - QToolBar *m_internalHelpBar; - QToolBar *m_externalHelpBar; + Utils::StyledBar *m_internalHelpBar; + Utils::StyledBar *m_externalHelpBar; }; } // namespace Internal diff --git a/src/plugins/help/openpagesmanager.cpp b/src/plugins/help/openpagesmanager.cpp index 7d6efefed117b0bc69e52b630e4bea0875f065d1..ebe15cb393b8a7f94d3e818f756cdb6c562353bf 100644 --- a/src/plugins/help/openpagesmanager.cpp +++ b/src/plugins/help/openpagesmanager.cpp @@ -69,7 +69,6 @@ OpenPagesManager::OpenPagesManager(QObject *parent) m_comboBox = new QComboBox; m_comboBox->setModel(m_model); - m_comboBox->setMinimumContentsLength(40); m_comboBox->setContextMenuPolicy(Qt::CustomContextMenu); connect(m_comboBox, SIGNAL(activated(int)), this, SLOT(setCurrentPage(int))); connect(m_comboBox, SIGNAL(customContextMenuRequested(QPoint)), this, diff --git a/src/shared/help/indexwindow.cpp b/src/shared/help/indexwindow.cpp index d58188b3f13313b327a970f17dc1d60244a0aa7b..03795f65ecd9bf9b190c38d1e671e0bc202ad3e3 100644 --- a/src/shared/help/indexwindow.cpp +++ b/src/shared/help/indexwindow.cpp @@ -45,7 +45,6 @@ #include <QtGui/QMenu> #include <QtGui/QContextMenuEvent> #include <QtGui/QListWidgetItem> -#include <QtGui/QToolBar> #include <QtHelp/QHelpEngine> #include <QtHelp/QHelpIndexWidget>