Replace QToolBars with StyledBar. Remove minimum size constraints.

Reviewed-by: con
This commit is contained in:
kh1
2010-10-05 14:18:18 +02:00
parent 58865c35b0
commit 699e3657a9
4 changed files with 68 additions and 66 deletions

View File

@@ -82,7 +82,6 @@
#include <QtGui/QShortcut> #include <QtGui/QShortcut>
#include <QtGui/QStackedLayout> #include <QtGui/QStackedLayout>
#include <QtGui/QSplitter> #include <QtGui/QSplitter>
#include <QtGui/QToolBar>
#include <QtHelp/QHelpEngine> #include <QtHelp/QHelpEngine>
@@ -110,6 +109,16 @@ const char * const SB_OPENPAGES = "OpenPages";
# define DOCPATH "/../share/doc/qtcreator/" # define DOCPATH "/../share/doc/qtcreator/"
#endif #endif
namespace {
QToolButton* toolButton(QAction *action)
{
QToolButton *button = new QToolButton;
button->setDefaultAction(action);
button->setPopupMode(QToolButton::DelayedPopup);
return button;
}
}
HelpPlugin::HelpPlugin() HelpPlugin::HelpPlugin()
: m_mode(0), : m_mode(0),
m_core(0), m_core(0),
@@ -528,55 +537,44 @@ void HelpPlugin::createRightPaneContextViewer()
if (m_helpViewerForSideBar) if (m_helpViewerForSideBar)
return; return;
QAction *switchToHelp = new QAction(tr("Go to Help Mode"), this); Utils::StyledBar *toolBar = new Utils::StyledBar();
QAction *switchToHelp = new QAction(tr("Go to Help Mode"), toolBar);
connect(switchToHelp, SIGNAL(triggered()), this, SLOT(switchToHelpMode())); connect(switchToHelp, SIGNAL(triggered()), this, SLOT(switchToHelpMode()));
QAction *back = new QAction(QIcon(QLatin1String(IMAGEPATH "previous.png")), QAction *back = new QAction(QIcon(QLatin1String(IMAGEPATH "previous.png")),
tr("Previous"), this); tr("Previous"), toolBar);
QAction *next = new QAction(QIcon(QLatin1String(IMAGEPATH "next.png")), QAction *next = new QAction(QIcon(QLatin1String(IMAGEPATH "next.png")),
tr("Next"), this); tr("Next"), toolBar);
QAction *close = new QAction(QIcon(QLatin1String(Core::Constants::ICON_CLOSE)),
QLatin1String(""), toolBar);
connect(close, SIGNAL(triggered()), this, SLOT(slotHideRightPane()));
// Dummy layout to align the close button to the right setupNavigationMenus(back, next, toolBar);
QHBoxLayout *hboxLayout = new QHBoxLayout();
hboxLayout->setSpacing(0);
hboxLayout->setMargin(0);
// left side actions QHBoxLayout *layout = new QHBoxLayout(toolBar);
QToolBar *rightPaneToolBar = new QToolBar(); layout->setSpacing(0);
setupNavigationMenus(back, next, rightPaneToolBar); layout->setMargin(0);
rightPaneToolBar->addAction(switchToHelp); layout->addWidget(toolButton(switchToHelp));
rightPaneToolBar->addAction(back); layout->addWidget(toolButton(back));
rightPaneToolBar->addAction(next); layout->addWidget(toolButton(next));
layout->addStretch();
hboxLayout->addWidget(rightPaneToolBar); layout->addWidget(toolButton(close));
hboxLayout->addStretch();
QToolButton *closeButton = new QToolButton();
closeButton->setIcon(QIcon(QLatin1String(Core::Constants::ICON_CLOSE)));
connect(closeButton, SIGNAL(clicked()), this, SLOT(slotHideRightPane()));
// close button to the right
hboxLayout->addWidget(closeButton);
QVBoxLayout *rightPaneLayout = new QVBoxLayout;
rightPaneLayout->setMargin(0);
rightPaneLayout->setSpacing(0);
QWidget *rightPaneSideBar = new QWidget; QWidget *rightPaneSideBar = new QWidget;
rightPaneSideBar->setLayout(rightPaneLayout);
addAutoReleasedObject(new Core::BaseRightPaneWidget(rightPaneSideBar)); 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); m_helpViewerForSideBar = new HelpViewer(qreal(0.0), rightPaneSideBar);
connect(m_helpViewerForSideBar, SIGNAL(openFindToolBar()), this, connect(m_helpViewerForSideBar, SIGNAL(openFindToolBar()), this,
SLOT(openFindToolBar())); SLOT(openFindToolBar()));
#if !defined(QT_NO_WEBKIT) #if !defined(QT_NO_WEBKIT)
m_helpViewerForSideBar->pageAction(QWebPage::OpenLinkInNewWindow)->setVisible(false); m_helpViewerForSideBar->pageAction(QWebPage::OpenLinkInNewWindow)->setVisible(false);
#endif #endif
QVBoxLayout *rightPaneLayout = new QVBoxLayout(rightPaneSideBar);
rightPaneLayout->setMargin(0);
rightPaneLayout->setSpacing(0);
rightPaneLayout->addWidget(toolBar);
rightPaneLayout->addWidget(m_helpViewerForSideBar); rightPaneLayout->addWidget(m_helpViewerForSideBar);
rightPaneLayout->addWidget(new Core::FindToolBarPlaceHolder(rightPaneSideBar)); rightPaneLayout->addWidget(new Core::FindToolBarPlaceHolder(rightPaneSideBar));
rightPaneSideBar->setFocusProxy(m_helpViewerForSideBar); rightPaneSideBar->setFocusProxy(m_helpViewerForSideBar);
@@ -924,25 +922,15 @@ void HelpPlugin::activateBookmarks()
m_sideBar->activateItem(m_bookmarkItem); 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 = new QComboBox;
m_filterComboBox->setMinimumContentsLength(20); m_filterComboBox->setMinimumContentsLength(15);
toolBar->addWidget(m_filterComboBox);
connect(m_filterComboBox, SIGNAL(activated(QString)), this, connect(m_filterComboBox, SIGNAL(activated(QString)), this,
SLOT(filterDocumentation(QString))); SLOT(filterDocumentation(QString)));
connect(m_filterComboBox, SIGNAL(currentIndexChanged(int)), this, connect(m_filterComboBox, SIGNAL(currentIndexChanged(int)), this,
SLOT(updateSideBarSource())); SLOT(updateSideBarSource()));
QWidget *dummy = new QWidget;
QHBoxLayout *layout = new QHBoxLayout(dummy);
layout->addStretch();
toolBar->addWidget(dummy);
m_closeButton = new QToolButton(); m_closeButton = new QToolButton();
m_closeButton->setIcon(QIcon(QLatin1String(Core::Constants::ICON_CLOSE))); m_closeButton->setIcon(QIcon(QLatin1String(Core::Constants::ICON_CLOSE)));
m_closeButton->setToolTip(tr("Close current page")); m_closeButton->setToolTip(tr("Close current page"));
@@ -950,14 +938,26 @@ QToolBar *HelpPlugin::createWidgetToolBar()
SLOT(closeCurrentPage())); SLOT(closeCurrentPage()));
connect(&OpenPagesManager::instance(), SIGNAL(pagesChanged()), this, connect(&OpenPagesManager::instance(), SIGNAL(pagesChanged()), this,
SLOT(updateCloseButton())); 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; 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; QAction *home, *back, *next, *bookmark;
if (external) { if (external) {
@@ -992,14 +992,15 @@ QToolBar *HelpPlugin::createIconToolBar(bool external)
setupNavigationMenus(back, next, toolBar); setupNavigationMenus(back, next, toolBar);
toolBar->addAction(home); QHBoxLayout *layout = new QHBoxLayout(toolBar);
toolBar->addAction(back); layout->setMargin(0);
toolBar->addAction(next); layout->setSpacing(0);
toolBar->addSeparator(); layout->addWidget(toolButton(home));
toolBar->addAction(bookmark); layout->addWidget(toolButton(back));
toolBar->setMovable(false); layout->addWidget(toolButton(next));
toolBar->addSeparator(); layout->addWidget(new Utils::StyledSeparator(toolBar));
toolBar->setVisible(false); layout->addWidget(toolButton(bookmark));
layout->addWidget(new Utils::StyledSeparator(toolBar));
return toolBar; return toolBar;
} }

View File

@@ -37,7 +37,6 @@
QT_FORWARD_DECLARE_CLASS(QAction) QT_FORWARD_DECLARE_CLASS(QAction)
QT_FORWARD_DECLARE_CLASS(QComboBox) QT_FORWARD_DECLARE_CLASS(QComboBox)
QT_FORWARD_DECLARE_CLASS(QMenu) QT_FORWARD_DECLARE_CLASS(QMenu)
QT_FORWARD_DECLARE_CLASS(QToolBar)
QT_FORWARD_DECLARE_CLASS(QToolButton) QT_FORWARD_DECLARE_CLASS(QToolButton)
QT_FORWARD_DECLARE_CLASS(QUrl) QT_FORWARD_DECLARE_CLASS(QUrl)
@@ -49,6 +48,10 @@ class SideBar;
class SideBarItem; class SideBarItem;
} // Core } // Core
namespace Utils {
class StyledBar;
} // Utils
namespace Help { namespace Help {
namespace Internal { namespace Internal {
class CentralWidget; class CentralWidget;
@@ -116,8 +119,8 @@ private:
void setupUi(); void setupUi();
void resetFilter(); void resetFilter();
void activateHelpMode(); void activateHelpMode();
QToolBar *createWidgetToolBar(); Utils::StyledBar *createWidgetToolBar();
QToolBar *createIconToolBar(bool external); Utils::StyledBar *createIconToolBar(bool external);
HelpViewer* viewerForContextMode(); HelpViewer* viewerForContextMode();
void createRightPaneContextViewer(); void createRightPaneContextViewer();
@@ -162,8 +165,8 @@ private:
QMenu *m_backMenu; QMenu *m_backMenu;
QMenu *m_nextMenu; QMenu *m_nextMenu;
QToolBar *m_internalHelpBar; Utils::StyledBar *m_internalHelpBar;
QToolBar *m_externalHelpBar; Utils::StyledBar *m_externalHelpBar;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -69,7 +69,6 @@ OpenPagesManager::OpenPagesManager(QObject *parent)
m_comboBox = new QComboBox; m_comboBox = new QComboBox;
m_comboBox->setModel(m_model); m_comboBox->setModel(m_model);
m_comboBox->setMinimumContentsLength(40);
m_comboBox->setContextMenuPolicy(Qt::CustomContextMenu); m_comboBox->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_comboBox, SIGNAL(activated(int)), this, SLOT(setCurrentPage(int))); connect(m_comboBox, SIGNAL(activated(int)), this, SLOT(setCurrentPage(int)));
connect(m_comboBox, SIGNAL(customContextMenuRequested(QPoint)), this, connect(m_comboBox, SIGNAL(customContextMenuRequested(QPoint)), this,

View File

@@ -45,7 +45,6 @@
#include <QtGui/QMenu> #include <QtGui/QMenu>
#include <QtGui/QContextMenuEvent> #include <QtGui/QContextMenuEvent>
#include <QtGui/QListWidgetItem> #include <QtGui/QListWidgetItem>
#include <QtGui/QToolBar>
#include <QtHelp/QHelpEngine> #include <QtHelp/QHelpEngine>
#include <QtHelp/QHelpIndexWidget> #include <QtHelp/QHelpIndexWidget>