Removed backup files
[krunner.git] / interface.h
blobeb1e6df66f950395353814f04c9be583ae1e52ab
1 /*
2 * Copyright (C) 2006 Aaron Seigo <aseigo@kde.org>
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 INTERFACE_H
20 #define INTERFACE_H
22 #include <QTimer>
23 #include <QGraphicsView>
24 #include <QGraphicsItem>
26 // pulls in definition for Window
27 #include <KSelectionWatcher>
29 // libplasma includes
30 #include <plasma/abstractrunner.h>
31 #include <plasma/svg.h>
32 #include <plasma/widgets/pushbutton.h>
33 #include <plasma/widgets/layoutitem.h>
34 #define KRUNNER_SIZE 350, 101
36 class QLabel;
37 class QListWidget;
38 class QListWidgetItem;
39 class QVBoxLayout;
41 class KLineEdit;
42 class KPushButton;
43 class KTitleWidget;
45 class CollapsibleWidget;
46 class SearchMatch;
48 class MainItem;
49 class PushIcon;
51 class Interface : public QGraphicsView
53 Q_OBJECT
54 Q_CLASSINFO( "D-Bus Interface", "org.kde.krunner.Interface" )
56 public:
57 explicit Interface( QWidget* parent = 0 );
58 ~Interface();
60 public Q_SLOTS:
61 // DBUS interface. if you change these methods, you MUST run:
62 // qdbuscpp2xml interface.h -o org.kde.krunner.Interface.xml
63 void display(const QString& term = QString());
64 void switchUser();
66 protected Q_SLOTS:
67 void match( const QString& term );
68 void setWidgetPalettes();
69 void updateMatches();
70 void exec();
71 void matchActivated( QListWidgetItem* );
72 void fuzzySearch();
73 void showOptions(bool show);
74 void setDefaultItem( QListWidgetItem* );
75 void expand();
76 void collapse();
78 protected:
79 void showEvent( QShowEvent* e );
80 void hideEvent( QHideEvent* e );
81 // void paintEvent( QPaintEvent* e );
82 void resizeEvent( QResizeEvent* e);
84 private:
85 void resetInterface();
87 Plasma::Svg* m_background;
88 bool m_expanded;
90 // MainItem *item;
92 QTimer m_searchTimer;
93 Plasma::AbstractRunner::List m_runners;
95 // QVBoxLayout* m_layout;
96 // KTitleWidget* m_header;
97 KLineEdit* m_searchTerm;
98 // QListWidget* m_matchList;
99 // QLabel* m_optionsLabel;
100 // KPushButton* m_cancelButton;
101 // KPushButton* m_runButton;
102 // KPushButton* m_optionsButton;
103 // CollapsibleWidget* m_expander;
104 PushIcon *m_toggleExpand;
106 SearchMatch* m_defaultMatch;
107 QMap<Plasma::AbstractRunner*, SearchMatch*> m_matches;
108 QList<SearchMatch*> m_searchMatches;
111 class GenericItem : public QGraphicsItem,
112 public QObject
113 // public Plasma::LayoutItem
115 // Q_OBJECT
117 public:
118 GenericItem(Plasma::Svg *renderer, Interface *qgv);
119 void paint(QPainter *painter,
120 const QStyleOptionGraphicsItem *option,
121 QWidget *widget);
122 virtual QRectF boundingRect() const;
123 void setElement(const QString &);
125 private:
126 Plasma::Svg* m_background;
127 bool m_expanded;
128 QString m_element;
129 Interface *m_qgv;
133 // class BackgroundItem : public QGraphicsItem, public QObject
134 // {
135 // // Q_OBJECT
136 // public:
137 // BackgroundItem(Plasma::Svg *renderer);
138 // void paint(QPainter *painter,
139 // const QStyleOptionGraphicsItem *option,
140 // QWidget *widget);
141 // virtual QRectF boundingRect() const;
142 // void setType(const QString &type);
143 // void setElement(
144 // private:
145 // Plasma::Svg* m_background;
146 // bool m_expanded;
147 // QString m_type;
149 // };
151 // class ForegroundItem : public QGraphicsItem, public QObject
152 // {
153 // // Q_OBJECT
154 // public:
155 // BackgroundItem(Plasma::Svg *renderer);
156 // void paint(QPainter *painter,
157 // const QStyleOptionGraphicsItem *option,
158 // QWidget *widget);
159 // virtual QRectF boundingRect() const;
160 // private:
161 // Plasma::Svg *m_background;
162 // bool m_expanded;
164 // };
166 class PushIcon : public Plasma::PushButton
168 public:
169 PushIcon(Interface *qgv) { m_qgv = qgv; }
170 virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
171 virtual QRectF boundingRect() const { return QRectF(0, 0, 22, 22); }
172 void setIcon(const QString &icon);
173 private:
174 QString m_icon;
175 Interface *m_qgv;
178 #endif