]> git.lyx.org Git - lyx.git/blob - src/support/ConsoleApplicationPrivate.h
Add acmart template
[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 #include <QTimer>
19
20 #include <string>
21
22
23 namespace lyx {
24
25 namespace support {
26
27 class ConsoleApplication;
28
29 class ConsoleApplicationPrivate : public QCoreApplication
30 {
31         Q_OBJECT
32 public:
33         ConsoleApplicationPrivate(ConsoleApplication * owner,
34                 std::string const & app, int & argc, char ** argv)
35                 : QCoreApplication(argc, argv), owner_(owner)
36         {
37                 setOrganizationName("LyX");
38                 setOrganizationDomain("lyx.org");
39                 setApplicationName(toqstr(app));
40
41                 qsrand(QDateTime::currentDateTime().toTime_t());
42         }
43         int execute()
44         {
45                 // set timer to do the work asynchronously after the event
46                 // loop was started
47                 QTimer::singleShot(0, this, SLOT(doExec()));
48                 // start event loop
49                 return exec();
50         }
51 private Q_SLOTS:
52         void doExec()
53         {
54                 owner_->doExec();
55         }
56 private:
57         ConsoleApplication * owner_;
58 };
59
60
61 } // namespace support
62 } // namespace lyx
63
64 #endif // CONSOPLEAPPLICATIONPRIVATE_H