OSDN Git Service

It's 2011 now.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / qmldesigner / components / formeditor / toolbox.cpp
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 **
9 ** No Commercial Usage
10 **
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
14 ** this package.
15 **
16 ** GNU Lesser General Public License Usage
17 **
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.
24 **
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.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **************************************************************************/
33
34 #include "toolbox.h"
35 #include "utils/styledbar.h"
36
37 #include <QToolBar>
38 #include <QHBoxLayout>
39 #include <QPainter>
40 #include <QtDebug>
41 #include <QFile>
42 #include <QVariant>
43
44 namespace QmlDesigner {
45
46 ToolBox::ToolBox(QWidget *parentWidget)
47     : Utils::StyledBar(parentWidget),
48   m_leftToolBar(new QToolBar("LeftSidebar", this)),
49   m_rightToolBar(new QToolBar("RightSidebar", this))
50 {
51     QHBoxLayout *fillLayout = new QHBoxLayout(this);
52     fillLayout->setMargin(0);
53     fillLayout->setSpacing(0);
54
55     m_leftToolBar->setFloatable(true);
56     m_leftToolBar->setMovable(true);
57     m_leftToolBar->setOrientation(Qt::Horizontal);
58     m_leftToolBar->setIconSize(QSize(24, 24));
59
60     QToolBar *stretchToolbar = new QToolBar(this);
61
62     m_leftToolBar->setProperty("panelwidget", true);
63     m_leftToolBar->setProperty("panelwidget_singlerow", true);
64
65     m_rightToolBar->setProperty("panelwidget", true);
66     m_rightToolBar->setProperty("panelwidget_singlerow", true);
67
68     stretchToolbar->setProperty("panelwidget", true);
69     stretchToolbar->setProperty("panelwidget_singlerow", true);
70
71     stretchToolbar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
72
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);
78
79     setLayout(fillLayout);
80 }
81
82 void ToolBox::setLeftSideActions(const QList<QAction*> &actions)
83 {
84     m_leftToolBar->clear();
85     m_leftToolBar->addActions(actions);
86     resize(sizeHint());
87 }
88
89 void ToolBox::setRightSideActions(const QList<QAction*> &actions)
90 {
91     m_rightToolBar->clear();
92     m_rightToolBar->addActions(actions);
93     resize(sizeHint());
94 }
95
96 void ToolBox::addLeftSideAction(QAction *action)
97 {
98     m_leftToolBar->addAction(action);
99 }
100
101 void ToolBox::addRightSideAction(QAction *action)
102 {
103     m_rightToolBar->addAction(action);
104 }
105
106
107 QList<QAction*> ToolBox::actions() const
108 {
109     return QList<QAction*>() << m_leftToolBar->actions() << m_rightToolBar->actions();
110 }
111
112 } // namespace QmlDesigner