2 * Copyright (C) 2006 Aaron Seigo <aseigo@kde.org>
3 * Copyright (C) 2007 Riccardo Iaconelli <riccardo@kde.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Library General Public License version 2 as
7 * published by the Free Software Foundation
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
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.
24 #include <QGraphicsView>
25 #include <QGraphicsItem>
27 // pulls in definition for Window
28 #include <KSelectionWatcher>
31 #include <plasma/abstractrunner.h>
32 #include <plasma/svg.h>
33 #include <plasma/widgets/pushbutton.h>
34 #include <plasma/widgets/lineedit.h>
35 #include <plasma/widgets/layoutitem.h>
36 #define KRUNNER_SIZE 350, 101
40 class QListWidgetItem
;
47 class CollapsibleWidget
;
53 class Plasma::LineEdit
;
55 class Interface
: public QGraphicsView
58 Q_CLASSINFO( "D-Bus Interface", "org.kde.krunner.Interface" )
61 explicit Interface( QWidget
* parent
= 0 );
65 // DBUS interface. if you change these methods, you MUST run:
66 // qdbuscpp2xml interface.h -o org.kde.krunner.Interface.xml
67 void display(const QString
& term
= QString());
71 void slotResize(int size
);
72 void match( const QString
& term
);
73 void setWidgetPalettes();
76 void matchActivated( QListWidgetItem
* );
78 void showOptions(bool show
);
79 void setDefaultItem( QListWidgetItem
* );
84 void showEvent( QShowEvent
* e
);
85 void hideEvent( QHideEvent
* e
);
86 // void paintEvent( QPaintEvent* e );
87 void resizeEvent( QResizeEvent
* e
);
90 void resetInterface();
92 Plasma::Svg
* m_background
;
98 Plasma::AbstractRunner::List m_runners
;
100 // QVBoxLayout* m_layout;
101 // KTitleWidget* m_header;
102 KLineEdit
* m_searchTerm
;
103 // QListWidget* m_matchList;
104 // QLabel* m_optionsLabel;
105 // KPushButton* m_cancelButton;
106 // KPushButton* m_runButton;
107 // KPushButton* m_optionsButton;
108 // CollapsibleWidget* m_expander;
109 PushIcon
*m_toggleExpand
;
111 GenericItem
*topleft
;
113 GenericItem
*topright
;
114 GenericItem
*separator
;
115 GenericItem
*separator2
;
116 GenericItem
*background
;
117 GenericItem
*bottomleft
;
119 GenericItem
*bottomright
;
120 Plasma::LineEdit
*lineEdit
;
123 SearchMatch
* m_defaultMatch
;
124 QMap
<Plasma::AbstractRunner
*, SearchMatch
*> m_matches
;
125 QList
<SearchMatch
*> m_searchMatches
;
128 class GenericItem
: public QGraphicsItem
,
130 // public Plasma::LayoutItem
135 GenericItem(Plasma::Svg
*renderer
, Interface
*qgv
);
136 void paint(QPainter
*painter
,
137 const QStyleOptionGraphicsItem
*option
,
139 virtual QRectF
boundingRect() const;
140 void setElement(const QString
&);
141 void setSize(int w
, int h
) { m_w
= w
; m_h
= h
; }
144 QRectF
itemRectF() const;
146 Plasma::Svg
* m_background
;
154 // class BackgroundItem : public QGraphicsItem, public QObject
158 // BackgroundItem(Plasma::Svg *renderer);
159 // void paint(QPainter *painter,
160 // const QStyleOptionGraphicsItem *option,
162 // virtual QRectF boundingRect() const;
163 // void setType(const QString &type);
166 // Plasma::Svg* m_background;
172 // class ForegroundItem : public QGraphicsItem, public QObject
176 // BackgroundItem(Plasma::Svg *renderer);
177 // void paint(QPainter *painter,
178 // const QStyleOptionGraphicsItem *option,
180 // virtual QRectF boundingRect() const;
182 // Plasma::Svg *m_background;
187 class PushIcon
: public Plasma::PushButton
190 PushIcon(Interface
*qgv
) { m_qgv
= qgv
; }
191 virtual void paint(QPainter
*painter
, const QStyleOptionGraphicsItem
*option
, QWidget
*widget
= 0);
192 virtual QRectF
boundingRect() const { return QRectF(0, 0, 22, 22); }
193 void setIcon(const QString
&icon
);