]> git.lyx.org Git - lyx.git/blob - src/support/ConsoleApplicationPrivate.h
Backport one more deprecation fix
[lyx.git] / src / support / ConsoleApplicationPrivate.h
1 /**
2  * \file ConsoleApplicationPrivate.h
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Georg Baum
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #ifndef CONSOPLEAPPLICATIONPRIVATE_H
12 #define CONSOPLEAPPLICATIONPRIVATE_H
13
14 #include "support/qstring_helpers.h"
15
16 #include <QCoreApplication>
17 #include <QDateTime>
18 #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
19 #include <QRandomGenerator>
20 #endif
21 #include <QTimer>
22
23 #include <string>
24
25
26 namespace lyx {
27
28 namespace support {
29
30 class ConsoleApplication;
31
32 class ConsoleApplicationPrivate : public QCoreApplication
33 {
34         Q_OBJECT
35 public:
36         ConsoleApplicationPrivate(ConsoleApplication * owner,
37                 std::string const & app, int & argc, char ** argv)
38                 : QCoreApplication(argc, argv), owner_(owner)
39         {
40                 setOrganizationName("LyX");
41                 setOrganizationDomain("lyx.org");
42                 setApplicationName(toqstr(app));
43
44 #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
45                 QRandomGenerator(QDateTime::currentDateTime().toSecsSinceEpoch());
46 #else
47                 qsrand(QDateTime::currentDateTime().toTime_t());
48 #endif
49         }
50         int execute()
51         {
52                 // set timer to do the work asynchronously after the event
53                 // loop was started
54                 QTimer::singleShot(0, this, SLOT(doExec()));
55                 // start event loop
56                 return exec();
57         }
58 private Q_SLOTS:
59         void doExec()
60         {
61                 owner_->doExec();
62         }
63 private:
64         ConsoleApplication * owner_;
65 };
66
67
68 } // namespace support
69 } // namespace lyx
70
71 #endif // CONSOPLEAPPLICATIONPRIVATE_H