dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
styledbar.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of Qt Creator.
7 **
8 ** Commercial License Usage
9 ** Licensees holding valid commercial Qt licenses may use this file in
10 ** accordance with the commercial license agreement provided with the
11 ** Software or, alternatively, in accordance with the terms contained in
12 ** a written agreement between you and Digia. For licensing terms and
13 ** conditions see http://qt.digia.com/licensing. For further information
14 ** use the contact form at http://qt.digia.com/contact-us.
15 **
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23 **
24 ** In addition, as a special exception, Digia gives you certain additional
25 ** rights. These rights are described in the Digia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27 **
28 ****************************************************************************/
29 
30 #include "styledbar.h"
31 
32 #include <QVariant>
33 #include <QPainter>
34 #include <QPixmapCache>
35 #include <QStyle>
36 #include <QStyleOption>
37 
38 using namespace Utils;
39 
40 StyledBar::StyledBar(QWidget *parent)
41  : QWidget(parent)
42 {
43  setProperty("panelwidget", true);
44  setProperty("panelwidget_singlerow", true);
45  setProperty("lightColored", false);
46 }
47 
48 void StyledBar::setSingleRow(bool singleRow)
49 {
50  setProperty("panelwidget_singlerow", singleRow);
51 }
52 
54 {
55  return property("panelwidget_singlerow").toBool();
56 }
57 
58 void StyledBar::setLightColored(bool lightColored)
59 {
60  setProperty("lightColored", lightColored);
61 }
62 
64 {
65  return property("lightColored").toBool();
66 }
67 
68 void StyledBar::paintEvent(QPaintEvent *event)
69 {
70  Q_UNUSED(event)
71  QPainter painter(this);
72  QStyleOption option;
73  option.rect = rect();
74  option.state = QStyle::State_Horizontal;
75  style()->drawControl(QStyle::CE_ToolBar, &option, &painter, this);
76 }
77 
79  : QWidget(parent)
80 {
81  setFixedWidth(10);
82 }
83 
84 void StyledSeparator::paintEvent(QPaintEvent *event)
85 {
86  Q_UNUSED(event)
87  QPainter painter(this);
88  QStyleOption option;
89  option.rect = rect();
90  option.state = QStyle::State_Horizontal;
91  option.palette = palette();
92  style()->drawPrimitive(QStyle::PE_IndicatorToolBarSeparator, &option, &painter, this);
93 }
StyledBar(QWidget *parent=nullptr)
Definition: styledbar.cpp:40
void paintEvent(QPaintEvent *event)
Definition: styledbar.cpp:68
void paintEvent(QPaintEvent *event)
Definition: styledbar.cpp:84
bool isLightColored() const
Definition: styledbar.cpp:63
bool isSingleRow() const
Definition: styledbar.cpp:53
StyledSeparator(QWidget *parent=nullptr)
Definition: styledbar.cpp:78
void setLightColored(bool lightColored)
Definition: styledbar.cpp:58
void setSingleRow(bool singleRow)
Definition: styledbar.cpp:48