Merge branch 'central-widget'
[krunner.git] / interface.h
blob8fa8ed5c9ef17d6bc7f557ffc5193eb97a9fe5f5
1 /*
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.
20 #ifndef INTERFACE_H
21 #define INTERFACE_H
23 #include <QTimer>
24 #include <QGraphicsView>
25 #include <QGraphicsItem>
27 // pulls in definition for Window
28 #include <KSelectionWatcher>
30 // libplasma includes
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
38 class QLabel;
39 class QListWidget;
40 class QListWidgetItem;
41 class QVBoxLayout;
43 class KLineEdit;
44 class KPushButton;
45 class KTitleWidget;
47 class CollapsibleWidget;
48 class SearchMatch;
50 class PushIcon;
51 class GenericItem;
53 class Plasma::LineEdit;
55 class Interface : public QGraphicsView
57 Q_OBJECT
58 Q_CLASSINFO( "D-Bus Interface", "org.kde.krunner.Interface" )
60 public:
61 explicit Interface( QWidget* parent = 0 );
62 ~Interface();
64 public Q_SLOTS:
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());
68 void switchUser();
70 protected Q_SLOTS:
71 void slotResize(int size);
72 void match( const QString& term );
73 void setWidgetPalettes();
74 void updateMatches();
75 void exec();
76 void matchActivated( QListWidgetItem* );
77 void fuzzySearch();
78 void showOptions(bool show);
79 void setDefaultItem( QListWidgetItem* );
80 void expand();
81 void collapse();
83 protected:
84 void showEvent( QShowEvent* e );
85 void hideEvent( QHideEvent* e );
86 // void paintEvent( QPaintEvent* e );
87 void resizeEvent( QResizeEvent* e);
89 private:
90 void resetInterface();
92 Plasma::Svg* m_background;
93 bool m_expanded;
95 // MainItem *item;
97 QTimer m_searchTimer;
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;
110 PushIcon *close;
111 GenericItem *topleft;
112 GenericItem *top;
113 GenericItem *topright;
114 GenericItem *separator;
115 GenericItem *separator2;
116 GenericItem *background;
117 GenericItem *bottomleft;
118 GenericItem *bottom;
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,
129 public QObject
130 // public Plasma::LayoutItem
132 // Q_OBJECT
134 public:
135 GenericItem(Plasma::Svg *renderer, Interface *qgv);
136 void paint(QPainter *painter,
137 const QStyleOptionGraphicsItem *option,
138 QWidget *widget);
139 virtual QRectF boundingRect() const;
140 void setElement(const QString &);
141 void setSize(int w, int h) { m_w = w; m_h = h; }
143 private:
144 QRectF itemRectF() const;
146 Plasma::Svg* m_background;
147 bool m_expanded;
148 QString m_element;
149 Interface *m_qgv;
150 int m_w, m_h;
154 // class BackgroundItem : public QGraphicsItem, public QObject
155 // {
156 // // Q_OBJECT
157 // public:
158 // BackgroundItem(Plasma::Svg *renderer);
159 // void paint(QPainter *painter,
160 // const QStyleOptionGraphicsItem *option,
161 // QWidget *widget);
162 // virtual QRectF boundingRect() const;
163 // void setType(const QString &type);
164 // void setElement(
165 // private:
166 // Plasma::Svg* m_background;
167 // bool m_expanded;
168 // QString m_type;
170 // };
172 // class ForegroundItem : public QGraphicsItem, public QObject
173 // {
174 // // Q_OBJECT
175 // public:
176 // BackgroundItem(Plasma::Svg *renderer);
177 // void paint(QPainter *painter,
178 // const QStyleOptionGraphicsItem *option,
179 // QWidget *widget);
180 // virtual QRectF boundingRect() const;
181 // private:
182 // Plasma::Svg *m_background;
183 // bool m_expanded;
185 // };
187 class PushIcon : public Plasma::PushButton
189 public:
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);
194 private:
195 QString m_icon;
196 Interface *m_qgv;
199 #endif