toolbox.cpp 4.28 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
2
**
3
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
7
**
hjk's avatar
hjk committed
8 9 10 11 12 13 14
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
15 16
**
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17 18 19 20 21 22 23 24 25
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
con's avatar
con committed
26 27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
29 30 31 32 33

#include "toolbox.h"

#include <QToolBar>
#include <QHBoxLayout>
hjk's avatar
hjk committed
34
#include <QDebug>
35
#include <QFrame>
36 37 38 39

namespace QmlDesigner {

ToolBox::ToolBox(QWidget *parentWidget)
40 41
    : Utils::StyledBar(parentWidget),
  m_leftToolBar(new QToolBar("LeftSidebar", this)),
Marco Bubke's avatar
Marco Bubke committed
42 43
  m_rightToolBar(new QToolBar("RightSidebar", this)),
  m_formEditorCrumbleBar(new FormEditorCrumbleBar(this))
44
{
45
    setMaximumHeight(44);
46 47 48 49 50 51 52 53
    setSingleRow(false);
    QFrame *frame = new QFrame(this);
    frame->setStyleSheet("background-color: #4e4e4e;");
    frame->setFrameShape(QFrame::NoFrame);
    QHBoxLayout *layout = new QHBoxLayout(frame);
    layout->setMargin(0);
    layout->setSpacing(0);
    frame->setLayout(layout);
Marco Bubke's avatar
Marco Bubke committed
54
    layout->addWidget(m_formEditorCrumbleBar->crumblePath());
55 56 57 58 59 60
    frame->setProperty("panelwidget", true);
    frame->setProperty("panelwidget_singlerow", false);
    QVBoxLayout *verticalLayout = new QVBoxLayout(this);
    verticalLayout->setMargin(0);
    verticalLayout->setSpacing(0);

61
    QHBoxLayout *horizontalLayout = new QHBoxLayout();
62 63 64 65
    verticalLayout->addLayout(horizontalLayout);
    verticalLayout->addWidget(frame);
    horizontalLayout->setMargin(0);
    horizontalLayout->setSpacing(0);
66

67 68 69 70
    m_leftToolBar->setFloatable(true);
    m_leftToolBar->setMovable(true);
    m_leftToolBar->setOrientation(Qt::Horizontal);
    m_leftToolBar->setIconSize(QSize(24, 24));
71

72
    QToolBar *stretchToolbar = new QToolBar(this);
73

74 75
    setSingleRow(false);

76
    m_leftToolBar->setProperty("panelwidget", true);
77
    m_leftToolBar->setProperty("panelwidget_singlerow", false);
78 79

    m_rightToolBar->setProperty("panelwidget", true);
80
    m_rightToolBar->setProperty("panelwidget_singlerow", false);
81 82

    stretchToolbar->setProperty("panelwidget", true);
83
    stretchToolbar->setProperty("panelwidget_singlerow", false);
84

85
    stretchToolbar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
86

87 88
    m_rightToolBar->setOrientation(Qt::Horizontal);
    m_rightToolBar->setIconSize(QSize(24, 24));
89 90 91
    horizontalLayout->addWidget(m_leftToolBar);
    horizontalLayout->addWidget(stretchToolbar);
    horizontalLayout->addWidget(m_rightToolBar);
92 93
}

94 95 96 97 98 99
void ToolBox::setLeftSideActions(const QList<QAction*> &actions)
{
    m_leftToolBar->clear();
    m_leftToolBar->addActions(actions);
    resize(sizeHint());
}
100

101
void ToolBox::setRightSideActions(const QList<QAction*> &actions)
102
{
103 104
    m_rightToolBar->clear();
    m_rightToolBar->addActions(actions);
105 106 107
    resize(sizeHint());
}

108
void ToolBox::addLeftSideAction(QAction *action)
109
{
110
    m_leftToolBar->addAction(action);
111 112
}

113 114 115 116 117 118
void ToolBox::addRightSideAction(QAction *action)
{
    m_rightToolBar->addAction(action);
}


119 120
QList<QAction*> ToolBox::actions() const
{
121
    return QList<QAction*>() << m_leftToolBar->actions() << m_rightToolBar->actions();
122 123
}

Marco Bubke's avatar
Marco Bubke committed
124
FormEditorCrumbleBar *ToolBox::formEditorCrumbleBar() const
125
{
Marco Bubke's avatar
Marco Bubke committed
126
    return m_formEditorCrumbleBar;
127 128
}

129
} // namespace QmlDesigner