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

Plasma

  • 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
27namespace Plasma
28{
29class SeparatorPrivate
30{
31 public:
32 Svg *svg;
33 Qt::Orientation orientation;
34};
35
36Separator::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
47Separator::~Separator()
48{
49 delete d->svg;
50 delete d;
51}
52
53void 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
64Qt::Orientation Separator::orientation()
65{
66 return d->orientation;
67}
68
69void 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
83QSizeF 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"
Plasma::Separator::orientation
Qt::Orientation orientation
Definition: separator.h:41
Plasma::Separator::setOrientation
void setOrientation(Qt::Orientation orientation)
Definition: separator.cpp:53
Plasma::Svg
A theme aware image-centric SVG class.
Definition: svg.h:57
QGraphicsWidget
QStyleOptionGraphicsItem
QWidget
Plasma
Namespace for everything in libplasma.
Definition: abstractdialogmanager.cpp:25
separator.h
svg.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 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
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
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