summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlli Werwolff <qt-info@nokia.com>2010-04-01 13:58:52 +0200
committerOlli Werwolff <qt-info@nokia.com>2010-04-01 13:58:52 +0200
commit138529b93d24880a49f88600b5db7d0a5aa1e1f3 (patch)
treedbb44dfc08ce4e3306cf9c4d40419ae45f752cc5
parentb9684f795d182ac5027845ab44a7ab272cc35074 (diff)
Toolbox inherits QToolBox
In order to work properly, the toolbox has to be a scrollarea. Before the problem was worked around by embedding the toolbox into a scrollarea but this is not necessary when the toolbox itself inherits scrollarea. Reviewed-by: ckamm
-rw-r--r--library/remotecontrolwidget.cpp14
-rw-r--r--library/toolbox.cpp29
-rw-r--r--library/toolbox.h6
3 files changed, 26 insertions, 23 deletions
diff --git a/library/remotecontrolwidget.cpp b/library/remotecontrolwidget.cpp
index cb83db7..baf5c52 100644
--- a/library/remotecontrolwidget.cpp
+++ b/library/remotecontrolwidget.cpp
@@ -47,18 +47,8 @@ RemoteControlWidget::RemoteControlWidget(QWidget *parent)
mToolBox = new ToolBox(false);
mToolBox->setStyle(mManhattanStyle);
- QScrollArea *simulateArea = new QScrollArea;
- simulateArea->setWidgetResizable(true);
- // Some styles have extra up/down buttons in the scrollbar. We only support
- // the plain scrollbars and therefore force the style to be derived from cleanlooks for them.
- QStyle *forceScrollbarStyle = new ManhattanStyle("cleanlooks");
- simulateArea->setStyle(forceScrollbarStyle);
- simulateArea->verticalScrollBar()->setStyle(forceScrollbarStyle);
- simulateArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
- simulateArea->verticalScrollBar()->setProperty("styledScrollBar", true);
- simulateArea->setWidget(mToolBox);
-
- PageWidget *simulate = new PageWidget(tr("Simulate"), simulateArea);
+
+ PageWidget *simulate = new PageWidget(tr("Simulate"), mToolBox);
addPage(simulate);
}
diff --git a/library/toolbox.cpp b/library/toolbox.cpp
index 3442631..b5e84be 100644
--- a/library/toolbox.cpp
+++ b/library/toolbox.cpp
@@ -1,17 +1,19 @@
#include "toolbox.h"
#include "style/styledbar.h"
+#include "style/manhattanstyle.h"
#include <QtCore/QStringList>
-#include <QtCore/QDebug>
+#include <QtCore/QVariant>
#include <QtGui/QPushButton>
#include <QtGui/QToolButton>
#include <QtGui/QLabel>
#include <QtGui/QVBoxLayout>
#include <QtGui/QFormLayout>
#include <QtGui/QSpacerItem>
+#include <QtGui/QScrollBar>
-ToolBox::ToolBox(bool pagesOpenOnInsertion, QWidget *parent, Qt::WindowFlags f)
- : QFrame(parent, f)
+ToolBox::ToolBox(bool pagesOpenOnInsertion, QWidget *parent)
+ : QScrollArea(parent)
, mLayout(0)
, mLargestMinimalInputWidth(0)
, mDefaultPagesOpen(pagesOpenOnInsertion)
@@ -21,7 +23,18 @@ ToolBox::ToolBox(bool pagesOpenOnInsertion, QWidget *parent, Qt::WindowFlags f)
mLayout->setSpacing(0);
mLayout->setMargin(0);
mLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::MinimumExpanding));
- setLayout(mLayout);
+ QWidget *contentWidget = new QWidget();
+ contentWidget->setLayout(mLayout);
+
+ setWidgetResizable(true);
+ // Some styles have extra up/down buttons in the scrollbar. We only support
+ // the plain scrollbars and therefore force the style to be derived from cleanlooks for them.
+ QStyle *forceScrollbarStyle = new ManhattanStyle("cleanlooks");
+ setStyle(forceScrollbarStyle);
+ verticalScrollBar()->setStyle(forceScrollbarStyle);
+ setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
+ verticalScrollBar()->setProperty("styledScrollBar", true);
+ setWidget(contentWidget);
}
ToolBox::~ToolBox()
@@ -35,8 +48,8 @@ bool ToolBox::addPage(ToolBoxPage *page)
bool ToolBox::insertPage(int index, ToolBoxPage *page)
{
if (index == -1)
- index = layout()->count() - 1; //As the spacer is the layout's last item
- if (index < 0 || index > layout()->count() - 1)
+ index = mLayout->count() - 1; //As the spacer is the layout's last item
+ if (index < 0 || index > mLayout->count() - 1)
return false;
page->setStyle(style());
page->mHeaderBar->setStyle(style());
@@ -53,8 +66,8 @@ bool ToolBox::insertPage(int index, ToolBoxPage *page)
bool ToolBox::insertPageIntoLayout(int index, ToolBoxPage *page)
{
if (index == -1)
- index = layout()->count() - 1; //As the spacer is the layout's last item
- if (index < 0 || index > layout()->count() - 1)
+ index = mLayout->count() - 1; //As the spacer is the layout's last item
+ if (index < 0 || index > mLayout->count() - 1)
return false;
mLayout->insertWidget(index, page);
return true;
diff --git a/library/toolbox.h b/library/toolbox.h
index 16add15..f6683ec 100644
--- a/library/toolbox.h
+++ b/library/toolbox.h
@@ -4,7 +4,7 @@
#include "remotecontrolwidget_global.h"
#include "optionsitem.h"
-#include <QtGui/QFrame>
+#include <QtGui/QScrollArea>
#include <QtGui/QWidget>
#include <QtCore/QList>
@@ -17,12 +17,12 @@ class QStringList;
class QVBoxLayout;
class QHBoxLayout;
-class ToolBox : public QFrame
+class ToolBox : public QScrollArea
{
Q_OBJECT
public:
- explicit ToolBox(bool pagesOpenOnInsertion = false, QWidget *parent = 0, Qt::WindowFlags f = 0);
+ explicit ToolBox(bool pagesOpenOnInsertion = false, QWidget *parent = 0);
virtual ~ToolBox();
public: