libyui-qt
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 
50 class QCursor;
51 class QFrame;
52 class QStackedWidget;
53 class YEvent;
55 class YQWidgetFactory;
56 class YQApplication;
57 class YQUISignalReceiver;
58 
59 using std::string;
60 using std::vector;
61 
62 class YQUI: public YUI
63 {
64  friend class YQUISignalReceiver;
65 
66 public:
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 
91 protected:
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 
116 public:
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 protected:
312 
316  void processCommandLineArgs( int argc, char **argv );
317 
322  void probeX11Display( const YCommandLine & cmdLine );
323 
327  void calcDefaultSize();
328 
335  virtual void idleLoop( int fd_ycp );
336 
342  virtual void uiThreadDestructor();
343 
348  void receivedYCPCommand();
349 
353  bool close();
354 
355 
356  //
357  // Data members
358  //
359 
360  static YQUI * _ui;
361 
362  QMap<QString, int> screenShotNo;
363 
364  bool _fullscreen;
365  bool _noborder;
366  QSize _defaultSize;
367 
368  bool _do_exit_loop;
369  bool _received_ycp_command;
370  bool _fatalError;
371 
372  QTimer * _busyCursorTimer;
373 
374  YSimpleEventHandler _eventHandler;
375  int _blockedLevel;
376 
377  bool _leftHandedMouse;
378  bool _askedForLeftHandedMouse;
379 
380  bool _uiInitialized;
381 
382  YQUISignalReceiver * _signalReceiver;
383  QString _applicationTitle;
384 
385  // Qt copies the _reference_ to argc, so we need to store argc
386  int _ui_argc;
387 };
388 
389 
395 class YQUISignalReceiver : public QObject
396 {
397  Q_OBJECT
398 
399 public:
401 
402 public slots:
403 
404  void slotBusyCursor();
405  void slotReceivedYCPCommand();
406 };
407 
408 
415 YUI * createUI( bool withThreads );
416 
417 
418 #endif // YQUI_h
int defaultSize(YUIDimension dim) const
Definition: YQUI.cc:561
bool fatalError() const
Definition: YQUI.h:180
void receivedYCPCommand()
Definition: YQUI.cc:448
bool eventPendingFor(YWidget *widget) const
Definition: YQUI.h:142
static YQApplication * yqApp()
Definition: YQUI.cc:242
void askConfigureLogging()
Definition: YQUI_builtins.cc:274
void forceUnblockEvents()
Definition: YQUI.cc:522
bool noBorder() const
Definition: YQUI.h:175
void setApplicationTitle(const QString &title)
Definition: YQUI.h:290
YEvent * pendingEvent() const
Definition: YQUI.h:150
void makeScreenShot(std::string filename)
Definition: YQUI_builtins.cc:97
void askSaveLogs()
Definition: YQUI_builtins.cc:215
virtual YEvent * runPkgSelection(YWidget *packageSelector)
Definition: YQUI_builtins.cc:67
void toggleRecordMacro()
Definition: YQUI_builtins.cc:302
Definition: YQApplication.h:43
virtual YOptionalWidgetFactory * createOptionalWidgetFactory()
Definition: YQUI.cc:346
void askSendWidgetID()
Definition: YQUI.cc:587
QString applicationTitle()
Definition: YQUI.h:285
void calcDefaultSize()
Definition: YQUI.cc:365
QIcon loadIcon(const string &iconName) const
Definition: YQUI.cc:682
Definition: YQUI.h:395
void sendEvent(YEvent *event)
Definition: YQUI.cc:454
virtual void idleLoop(int fd_ycp)
Definition: YQUI.cc:415
void probeX11Display(const YCommandLine &cmdLine)
Definition: YQUI.cc:567
virtual void deleteNotify(YWidget *widget)
Definition: YQUI.cc:573
void busyCursor()
Definition: YQUI.cc:536
Definition: YQUI.h:62
void processCommandLineArgs(int argc, char **argv)
Definition: YQUI.cc:248
YQUI(bool withThreads, bool topmostConstructor=true)
Definition: YQUI.cc:104
bool fullscreen() const
Definition: YQUI.h:169
YEvent * consumePendingEvent()
Definition: YQUI.h:157
Definition: YQWidgetFactory.h:71
virtual void uiThreadDestructor()
Definition: YQUI.cc:315
virtual void blockEvents(bool block=true)
Definition: YQUI.cc:488
void timeoutBusyCursor()
Definition: YQUI.cc:552
bool close()
Definition: YQUI.cc:579
void normalCursor()
Definition: YQUI.cc:542
virtual void initUI()
Definition: YQUI.cc:132
void askPlayMacro()
Definition: YQUI_builtins.cc:344
virtual ~YQUI()
Definition: YQUI.cc:297
void raiseFatalError()
Definition: YQUI.h:187
static void setTextdomain(const char *domain)
Definition: YQUI.cc:474
static YQUI * ui()
Definition: YQUI.h:83
Definition: YQOptionalWidgetFactory.h:54
virtual bool eventsBlocked() const
Definition: YQUI.cc:530
virtual YWidgetFactory * createWidgetFactory()
Definition: YQUI.cc:336