2 * Copyright (C) 2007 Petri Damsten <damu@iki.fi>
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 version 2 as
6 * published by the Free Software Foundation
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details
13 * You should have received a copy of the GNU Library General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #ifndef SM_APPLET_HEADER
20 #define SM_APPLET_HEADER
22 #include <Plasma/Applet>
24 #include "sm_export.h"
26 #define DEFAULT_MINIMUM_WIDTH 200
29 class QGraphicsLinearLayout
;
40 class SM_EXPORT Applet
: public Plasma::Applet
44 enum Mode
{ Monitor
, Panel
, Desktop
};
45 enum Detail
{ High
, Low
};
47 Applet(QObject
*parent
, const QVariantList
&args
);
50 virtual void constraintsEvent(Plasma::Constraints constraints
);
51 QSizeF
minSize() const { return m_min
; };
54 void geometryChecked();
57 void connectToEngine();
58 void connectSource(const QString
& source
);
59 void disconnectSources();
61 QGraphicsLinearLayout
* mainLayout();
62 void setTitle(const QString
& title
, bool spacer
= false);
63 KConfigGroup
persistentConfig() const;
64 uint
interval() { return m_interval
; };
65 void setInterval(uint interval
) { m_interval
= interval
; };
66 qreal
preferredItemHeight() { return m_preferredItemHeight
; };
67 void setPreferredItemHeight(qreal preferredItemHeight
)
68 { m_preferredItemHeight
= preferredItemHeight
; };
69 QString
title() { return m_title
; };
70 bool titleSpacer() { return m_titleSpacer
; };
71 Plasma::Frame
* header() { return m_header
; };
72 QStringList
items() { return m_items
; };
73 void appendItem(const QString
& item
) { m_items
.append(item
); };
74 void setItems(const QStringList
& items
) { m_items
= items
; };
75 void clearItems() { m_items
.clear(); };
76 QStringList
connectedSources() { return m_connectedSources
; };
77 void setEngine(Plasma::DataEngine
* engine
) { m_engine
= engine
; };
78 Plasma::DataEngine
* engine() { return m_engine
; };
79 Qt::Orientation
ratioOrientation() { return m_ratioOrientation
; };
80 void setRatioOrientation(Qt::Orientation ratioOrientation
)
81 { m_ratioOrientation
= ratioOrientation
; };
82 void appendKeepRatio(QGraphicsWidget
* w
) { m_keepRatio
.append(w
); };
83 QHash
<QString
,Plasma::Meter
*> meters() { return m_meters
; };
84 void appendMeter(const QString
& source
, Plasma::Meter
* meter
)
85 { m_meters
[source
] = meter
; };
86 QHash
<QString
,Plasma::SignalPlotter
*> plotters() { return m_plotters
; };
87 void appendPlotter(const QString
& source
, Plasma::SignalPlotter
* plotter
)
88 { m_plotters
[source
] = plotter
; };
89 Qt::Orientation
orientation() { return m_orientation
; };
90 Mode
mode() { return m_mode
; };
91 Detail
detail() { return m_detail
; };
92 qreal
minimumWidth() { return m_minimumWidth
; };
93 void setMinimumWidth(qreal minimumWidth
) { m_minimumWidth
= minimumWidth
; };
95 virtual bool addMeter(const QString
&) { return false; };
96 void displayNoAvailableSources();
97 virtual void deleteMeters(QGraphicsLinearLayout
* layout
= 0);
98 virtual void setDetail(Detail detail
);
99 //QSizeF sizeHint(Qt::SizeHint which, const QSizeF& constraint = QSizeF()) const;
103 qreal m_preferredItemHeight
;
106 Plasma::Frame
* m_header
;
108 QStringList m_connectedSources
;
109 Plasma::DataEngine
*m_engine
;
110 Qt::Orientation m_ratioOrientation
;
111 QList
<QGraphicsWidget
*> m_keepRatio
;
112 QHash
<QString
, Plasma::Meter
*> m_meters
;
113 QHash
<QString
, Plasma::SignalPlotter
*> m_plotters
;
114 Qt::Orientation m_orientation
;
115 Plasma::IconWidget
*m_noSourcesIcon
;
118 qreal m_minimumWidth
;
123 QGraphicsLinearLayout
*m_mainLayout
;
125 static QHash
< QString
, QList
<uint
> > s_configIds
;