1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
35 #include "utils/styledbar.h"
38 #include <QHBoxLayout>
44 namespace QmlDesigner {
46 ToolBox::ToolBox(QWidget *parentWidget)
47 : Utils::StyledBar(parentWidget),
48 m_leftToolBar(new QToolBar("LeftSidebar", this)),
49 m_rightToolBar(new QToolBar("RightSidebar", this))
51 QHBoxLayout *fillLayout = new QHBoxLayout(this);
52 fillLayout->setMargin(0);
53 fillLayout->setSpacing(0);
55 m_leftToolBar->setFloatable(true);
56 m_leftToolBar->setMovable(true);
57 m_leftToolBar->setOrientation(Qt::Horizontal);
58 m_leftToolBar->setIconSize(QSize(24, 24));
60 QToolBar *stretchToolbar = new QToolBar(this);
62 m_leftToolBar->setProperty("panelwidget", true);
63 m_leftToolBar->setProperty("panelwidget_singlerow", true);
65 m_rightToolBar->setProperty("panelwidget", true);
66 m_rightToolBar->setProperty("panelwidget_singlerow", true);
68 stretchToolbar->setProperty("panelwidget", true);
69 stretchToolbar->setProperty("panelwidget_singlerow", true);
71 stretchToolbar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
73 m_rightToolBar->setOrientation(Qt::Horizontal);
74 m_rightToolBar->setIconSize(QSize(24, 24));
75 fillLayout->addWidget(m_leftToolBar);
76 fillLayout->addWidget(stretchToolbar);
77 fillLayout->addWidget(m_rightToolBar);
79 setLayout(fillLayout);
82 void ToolBox::setLeftSideActions(const QList<QAction*> &actions)
84 m_leftToolBar->clear();
85 m_leftToolBar->addActions(actions);
89 void ToolBox::setRightSideActions(const QList<QAction*> &actions)
91 m_rightToolBar->clear();
92 m_rightToolBar->addActions(actions);
96 void ToolBox::addLeftSideAction(QAction *action)
98 m_leftToolBar->addAction(action);
101 void ToolBox::addRightSideAction(QAction *action)
103 m_rightToolBar->addAction(action);
107 QList<QAction*> ToolBox::actions() const
109 return QList<QAction*>() << m_leftToolBar->actions() << m_rightToolBar->actions();
112 } // namespace QmlDesigner