This repository has been archived by the owner on Mar 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
95 lines (85 loc) · 3.6 KB
/
main.cpp
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include "daemon.h"
#include <DAboutDialog>
#include <DApplication>
#include <DApplicationSettings>
#include <DLog>
#include <DSettings>
#include <QDebug>
#ifdef RELEASE
#define APPLICATION_NAME "DTKStickyNotes"
#else
#define APPLICATION_NAME "DTKStickyNotes-develop"
#endif
//#define APP_VERSION "0.0.5-beta"
DWIDGET_USE_NAMESPACE
void myMessageOutput(QtMsgType type, const QMessageLogContext& context, const QString& msg)
{
QByteArray localMsg = msg.toLocal8Bit();
switch (type) {
case QtDebugMsg:
fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
break;
case QtInfoMsg:
fprintf(stderr, "Info: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
break;
case QtWarningMsg:
fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
break;
case QtCriticalMsg:
fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
break;
case QtFatalMsg:
fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
break;
}
}
int main(int argc, char* argv[])
{
DApplication::loadDXcbPlugin();
DApplication app(argc, argv);
#ifdef RELEASE
qInstallMessageHandler(myMessageOutput);
std::freopen((QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + APPLICATION_NAME + ".log").toStdString().c_str(), "a", stderr);
std::cerr << std::endl
<< std::endl;
#endif
QLoggingCategory::defaultCategory()->setEnabled(QtDebugMsg, true);
QTranslator qtTranslator;
qtTranslator.load("qt_" + QLocale::system().name(),
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
app.installTranslator(&qtTranslator);
QTranslator translator;
translator.load(QLocale::system(), ":/translations/" + QLocale::system().name() + ".qm");
app.installTranslator(&translator);
app.setAttribute(Qt::AA_UseHighDpiPixmaps);
app.setQuitOnLastWindowClosed(false);
app.setApplicationName(APPLICATION_NAME);
app.setApplicationLicense("GPLv2");
app.setApplicationHomePage("https://github.com/zhongyic00/DTKStickyNotes/");
app.setApplicationDescription(QObject::tr("基于DTK开发的linux桌面便笺工具"));
app.setApplicationAcknowledgementPage("https://github.com/zhongyic00/");
app.setApplicationAcknowledgementVisible(true);
app.setApplicationVersion(APP_VERSION);
app.setOrganizationName("RubbishTech");
app.setOrganizationDomain("https://github.com/zhongyic00/");
app.setProductName(QObject::tr("便笺"));
app.setProductIcon(QIcon(":/images/logo.svg.png"));
/*QIcon companyLogo(":/images/ZhYiclogo_v2");
app.aboutDialog()->setCompanyLogo(companyLogo.pixmap(100, 100));
app.aboutDialog()->setWebsiteName("By Rubbish_ZhYic");*/
if (!app.setSingleInstance(app.applicationName()))
return 0;
DApplicationSettings appSettings(&app); //initialize application theme settings
Daemon daemon;
/*DAboutDialog dlg;
dlg.setProductName("便笺");
dlg.setProductIcon(QIcon(":/images/logo.svg.png"));
dlg.setVersion("0.0.4-beta.1");
dlg.setDescription(QWidget::tr("基于DTK开发的linux桌面便笺工具"));
dlg.setWebsiteName("By Rubbish_ZhYic");
dlg.setWebsiteLink("https://github.com/zhongyic00/");
QIcon companyLogo(":/images/ZhYiclogo_v2");
dlg.setCompanyLogo(companyLogo.pixmap(100, 100));
app.setAboutDialog(&dlg);*/
return app.exec();
}