• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

Plasma

  • sources
  • kde-4.12
  • kdelibs
  • plasma
  • widgets
separator.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2009 by Davide Bettio <davide.bettio@kdemail.net>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Library General Public License as
6  * published by the Free Software Foundation; either version 2, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this program; if not, write to the
16  * Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
20 #include "separator.h"
21 
22 #include <QtGui/QPainter>
23 #include <QtGui/QGraphicsSceneMouseEvent>
24 
25 #include "svg.h"
26 
27 namespace Plasma
28 {
29 class SeparatorPrivate
30 {
31  public:
32  Svg *svg;
33  Qt::Orientation orientation;
34 };
35 
36 Separator::Separator(QGraphicsItem *parent, Qt::WindowFlags wFlags)
37  : QGraphicsWidget(parent, wFlags),
38  d(new SeparatorPrivate())
39 {
40  d->svg = new Svg();
41  d->svg->setImagePath("widgets/line");
42  d->svg->setContainsMultipleImages(true);
43 
44  setOrientation(Qt::Horizontal);
45 }
46 
47 Separator::~Separator()
48 {
49  delete d->svg;
50  delete d;
51 }
52 
53 void Separator::setOrientation(Qt::Orientation orientation)
54 {
55  d->orientation = orientation;
56 
57  if (orientation == Qt::Horizontal) {
58  setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
59  } else {
60  setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
61  }
62 }
63 
64 Qt::Orientation Separator::orientation()
65 {
66  return d->orientation;
67 }
68 
69 void Separator::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
70 {
71  Q_UNUSED(option);
72  Q_UNUSED(widget);
73 
74  if (d->svg){
75  if (d->orientation == Qt::Horizontal){
76  d->svg->paint(painter, boundingRect(), "horizontal-line");
77  } else {
78  d->svg->paint(painter, boundingRect(), "vertical-line");
79  }
80  }
81 }
82 
83 QSizeF Separator::sizeHint(Qt::SizeHint which, const QSizeF & constraint) const
84 {
85  QSizeF hint = QGraphicsWidget::sizeHint(which, constraint);
86 
87  if (d->orientation == Qt::Horizontal) {
88  hint.setHeight(d->svg->elementSize("horizontal-line").height());
89  } else {
90  hint.setWidth(d->svg->elementSize("vertical-line").width());
91  }
92 
93  return hint;
94 }
95 
96 
97 } // Plasma namespace
98 
99 #include "separator.moc"
QWidget
Plasma::Separator::Separator
Separator(QGraphicsItem *parent=0, Qt::WindowFlags wFlags=0)
Definition: separator.cpp:36
Plasma::Separator::paint
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
Definition: separator.cpp:69
Plasma::Horizontal
The applet is constrained vertically, but can expand horizontally.
Definition: plasma.h:75
separator.h
Plasma::Separator::setOrientation
void setOrientation(Qt::Orientation orientation)
Definition: separator.cpp:53
Plasma::Separator::sizeHint
QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
Definition: separator.cpp:83
Plasma::Separator::orientation
Qt::Orientation orientation()
Plasma::Separator::~Separator
virtual ~Separator()
Definition: separator.cpp:47
QStyleOptionGraphicsItem
Plasma::Svg
A theme aware image-centric SVG class.
Definition: svg.h:56
svg.h
QGraphicsWidget
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:34 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal