-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathmain.cpp
More file actions
71 lines (63 loc) · 2.18 KB
/
main.cpp
File metadata and controls
71 lines (63 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <QtCore/qcommandlineparser.h>
#include <QtWidgets/qapplication.h>
#include <QtWidgets/qstylefactory.h>
#include <QtCore/qsystemsemaphore.h>
#include <QtCore/qsharedmemory.h>
#include "lafdup_window.h"
#include "lafdupapplication.h"
#include "qtnetworkng.h"
#include "lafdup_window_p.h"
int main(int argc, char **argv)
{
qSetMessagePattern("[%{time yyyyMMdd h:mm:ss.zzz}] - %{message}");
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
LafdupApplication app(argc, argv);
app.setOrganizationDomain("lafdup.gigacores.com");
app.setOrganizationName("GigaCores");
app.setApplicationDisplayName("Sync Clipboard");
app.setApplicationName("SyncClipboard");
app.setApplicationVersion("1.0");
app.setWindowIcon(QIcon(":/images/bluefish.png"));
app.setQuitOnLastWindowClosed(false);
QCommandLineParser parser;
parser.setApplicationDescription("Keep clipboard synchroized to other PCs.");
parser.addHelpOption();
QCommandLineOption minimizedOption("m", "minimized after started.");
parser.addOption(minimizedOption);
parser.process(app);
#ifdef Q_OS_WIN
QFont f = app.font();
f.setFamily("微软雅黑");
app.setFont(f);
app.setStyle(QStyleFactory::create("fusion"));
#endif
app.translationLanguage();
QSystemSemaphore sema("systemSemaphore", 1, QSystemSemaphore::Open);
sema.acquire();
QSharedMemory mem("memory");
if (!mem.create(1)) {
QMessageBox::information(nullptr, QObject::tr("tips"),
QObject::tr("The program is running, please exit first if necessary"));
sema.release();
return 0;
}
sema.release();
QSettings *settings = new QSettings;
if (settings->value("password").toString().isEmpty()) {
GuideDialog guide;
guide.show();
int result = guide.exec();
if (result != QDialog::Accepted) {
return 0;
}
}
LafdupWindow w;
if (settings->value("isMinimized").toBool()) {
w.showMinimized();
} else {
w.showAndGetFocus();
}
delete settings;
return qtng::startQtLoop();
}