libyui-qt
Loading...
Searching...
No Matches
YQUI.h
1/*
2 Copyright (C) 2000-2012 Novell, Inc
3 This library is free software; you can redistribute it and/or modify
4 it under the terms of the GNU Lesser General Public License as
5 published by the Free Software Foundation; either version 2.1 of the
6 License, or (at your option) version 3.0 of the License. This library
7 is distributed in the hope that it will be useful, but WITHOUT ANY
8 WARRANTY; without even the implied warranty of MERCHANTABILITY or
9 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10 License for more details. You should have received a copy of the GNU
11 Lesser General Public License along with this library; if not, write
12 to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13 Floor, Boston, MA 02110-1301 USA
14*/
15
16
17/*-/
18
19 File: YQUI.h
20
21 Author: Stefan Hundhammer <shundhammer@suse.de>
22
23/-*/
24
25#ifndef YQUI_h
26#define YQUI_h
27
28#include <qapplication.h>
29#include <QMap>
30#include <QTimer>
31#include <QIcon>
32#include <vector>
33#include <type_traits>
34
35#include <yui/YUI.h>
36#include <yui/YSimpleEventHandler.h>
37#include <yui/YCommandLine.h>
38
39#define YQWidgetMargin 4
40#define YQWidgetSpacing 4
41#define YQButtonBorder 3
42
44// To be used in connect(foo, &pclass(foo)::mysignal, bar, &pclass(bar)::myslot);
45// That checks types at compile time,
46// unlike the string based SIGNAL and SLOT macros.
47#define pclass(ptr) std::remove_reference<decltype(*ptr)>::type
48
49
50class QCursor;
51class QFrame;
52class QStackedWidget;
53class YEvent;
55class YQWidgetFactory;
56class YQApplication;
58
59using std::string;
60using std::vector;
61
62class YQUI: public YUI
63{
64 friend class YQUISignalReceiver;
65
66public:
67
73 YQUI( bool withThreads, bool topmostConstructor = true );
74
78 virtual ~YQUI();
79
83 static YQUI * ui() { return _ui; }
84
89 virtual void initUI();
90
91protected:
98 virtual YWidgetFactory * createWidgetFactory();
99
107 virtual YOptionalWidgetFactory * createOptionalWidgetFactory();
108
109 /*
110 * Create the YApplication object that provides global methods.
111 *
112 * Reimplemented from YUI.
113 **/
114 virtual YApplication * createApplication();
115
116public:
117
126 static YQApplication * yqApp();
127
137 void sendEvent( YEvent * event );
138
142 bool eventPendingFor( YWidget * widget ) const
143 { return _eventHandler.eventPendingFor( widget ); }
144
150 YEvent * pendingEvent() const { return _eventHandler.pendingEvent(); }
151
157 YEvent * consumePendingEvent() { return _eventHandler.consumePendingEvent(); }
158
164 virtual void deleteNotify( YWidget * widget );
165
169 bool fullscreen() const { return _fullscreen; }
170
175 bool noBorder() const { return _noborder; }
180 bool fatalError() const { return _fatalError; }
181
187 void raiseFatalError() { _fatalError = true; }
188
192 int defaultSize( YUIDimension dim ) const;
193
198 void makeScreenShot( std::string filename );
199
206 virtual YEvent * runPkgSelection( YWidget * packageSelector );
207
214 void toggleRecordMacro();
215
220 void askPlayMacro();
221
226 void askSendWidgetID();
227
234 virtual void blockEvents( bool block = true );
235
241 virtual bool eventsBlocked() const;
242
247 void forceUnblockEvents();
248
252 void busyCursor();
253
257 void normalCursor();
258
263 void timeoutBusyCursor();
264
269 void askSaveLogs();
270
275 void askConfigureLogging();
276
280 static void setTextdomain( const char * domain );
281
285 QString applicationTitle() { return _applicationTitle; }
286
290 void setApplicationTitle( const QString & title ) { _applicationTitle = title; }
291
309 QIcon loadIcon( const string & iconName ) const;
310
311
312protected:
313
318 QIcon loadThemeIcon( const QString & iconName ) const;
319
323 QIcon loadIconFromPath( const QString & iconPath ) const;
324
332 QIcon loadBuiltInIcon( const QString & iconName ) const;
333
334
338 void processCommandLineArgs( int argc, char **argv );
339
343 void calcDefaultSize();
344
351 virtual void idleLoop( int fd_ycp );
352
358 virtual void uiThreadDestructor();
359
364 void receivedYCPCommand();
365
369 bool close();
370
371
372 //
373 // Data members
374 //
375
376 static YQUI * _ui;
377
378 QMap<QString, int> screenShotNo;
379
380 bool _fullscreen;
381 bool _noborder;
382 QSize _defaultSize;
383
384 bool _do_exit_loop;
385 bool _received_ycp_command;
386 bool _fatalError;
387
388 QTimer * _busyCursorTimer;
389
390 YSimpleEventHandler _eventHandler;
391 int _blockedLevel;
392
393 bool _leftHandedMouse;
394 bool _askedForLeftHandedMouse;
395
396 bool _uiInitialized;
397
398 YQUISignalReceiver * _signalReceiver;
399 QString _applicationTitle;
400
401 // Qt copies the _reference_ to argc, so we need to store argc
402 int _ui_argc;
403};
404
405
411class YQUISignalReceiver : public QObject
412{
413 Q_OBJECT
414
415public:
417
418public slots:
419
420 void slotBusyCursor();
421 void slotReceivedYCPCommand();
422};
423
424
431YUI * createUI( bool withThreads );
432
433
434#endif // YQUI_h
Definition YQApplication.h:44
Definition YQOptionalWidgetFactory.h:55
Definition YQUI.h:412
Definition YQUI.h:63
void toggleRecordMacro()
Definition YQUI_builtins.cc:279
bool fatalError() const
Definition YQUI.h:180
virtual void deleteNotify(YWidget *widget)
Definition YQUI.cc:570
virtual bool eventsBlocked() const
Definition YQUI.cc:533
void busyCursor()
Definition YQUI.cc:539
virtual void idleLoop(int fd_ycp)
Definition YQUI.cc:418
virtual ~YQUI()
Definition YQUI.cc:300
void processCommandLineArgs(int argc, char **argv)
Definition YQUI.cc:251
void setApplicationTitle(const QString &title)
Definition YQUI.h:290
QIcon loadBuiltInIcon(const QString &iconName) const
Definition YQUI.cc:714
virtual YOptionalWidgetFactory * createOptionalWidgetFactory()
Definition YQUI.cc:349
void askSendWidgetID()
Definition YQUI.cc:584
void askConfigureLogging()
Definition YQUI_builtins.cc:258
void timeoutBusyCursor()
Definition YQUI.cc:555
QIcon loadIconFromPath(const QString &iconPath) const
Definition YQUI.cc:701
YEvent * pendingEvent() const
Definition YQUI.h:150
virtual YEvent * runPkgSelection(YWidget *packageSelector)
Definition YQUI_builtins.cc:64
bool noBorder() const
Definition YQUI.h:175
void sendEvent(YEvent *event)
Definition YQUI.cc:457
static YQApplication * yqApp()
Definition YQUI.cc:245
QString applicationTitle()
Definition YQUI.h:285
virtual void initUI()
Definition YQUI.cc:130
int defaultSize(YUIDimension dim) const
Definition YQUI.cc:564
void askSaveLogs()
Definition YQUI_builtins.cc:205
QIcon loadThemeIcon(const QString &iconName) const
Definition YQUI.cc:694
void forceUnblockEvents()
Definition YQUI.cc:525
virtual void blockEvents(bool block=true)
Definition YQUI.cc:491
bool close()
Definition YQUI.cc:576
static YQUI * ui()
Definition YQUI.h:83
void receivedYCPCommand()
Definition YQUI.cc:451
void calcDefaultSize()
Definition YQUI.cc:368
QIcon loadIcon(const string &iconName) const
Definition YQUI.cc:675
virtual void uiThreadDestructor()
Definition YQUI.cc:318
void askPlayMacro()
Definition YQUI_builtins.cc:314
bool eventPendingFor(YWidget *widget) const
Definition YQUI.h:142
void normalCursor()
Definition YQUI.cc:545
bool fullscreen() const
Definition YQUI.h:169
YEvent * consumePendingEvent()
Definition YQUI.h:157
static void setTextdomain(const char *domain)
Definition YQUI.cc:477
void raiseFatalError()
Definition YQUI.h:187
void makeScreenShot(std::string filename)
Definition YQUI_builtins.cc:94
virtual YWidgetFactory * createWidgetFactory()
Definition YQUI.cc:339
Definition YQWidgetFactory.h:72