-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
126 lines (99 loc) · 3.68 KB
/
main.cpp
File metadata and controls
126 lines (99 loc) · 3.68 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
Copyright (C) 2009–2014 jakago
Copyright (C) 2018–2026 CSReviser Team
This file is part of CaptureStream2, a recorder that supports HLS for
NHK radio language courses.
CaptureStream2 is a modified version of CaptureStream, originally
developed by jakago.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/gpl-2.0.html>.
*/
#include "mainwindow.h"
#include "clicontroller.h"
#include "settings.h"
#include "commandlineparser.h"
#include "utility.h"
#include <QApplication>
#include <QCoreApplication>
#include <QGuiApplication>
#include <QIcon>
#include <QScreen>
#include <QDebug>
#include <QFont>
#if defined(QT_NO_DEBUG)
static void releaseMessageHandler(QtMsgType type,
const QMessageLogContext &,
const QString &msg)
{
if (type == QtDebugMsg) {
return;
}
QByteArray localMsg = msg.toLocal8Bit();
fprintf(stderr, "%s\n", localMsg.constData());
}
#endif
int main(int argc, char *argv[])
{
#if defined(QT_NO_DEBUG)
// ログ出力先の設定(これはQtに依存しないので最初でOK)
#ifdef Q_OS_WIN
const char* nullDevice = "nul";
#else
const char* nullDevice = "/dev/null";
#endif
freopen(nullDevice, "a", stdout);
freopen(nullDevice, "a", stderr);
#endif
#if defined(QT_NO_DEBUG)
qInstallMessageHandler(releaseMessageHandler);
#endif
// ★ Qtを作る前に最小パース
SimpleCliOptions simple = CommandLineParser::parseSimple(argc, argv);
// =========================================================
// CLI MODE
// =========================================================
if (simple.nogui) {
fprintf(stderr, ">>> Entering CLI Mode <<<\n");
QCoreApplication app(argc, argv);
// 1. appができてからSettingsを読み込む
Settings::instance().load();
CLIController cli(Settings::instance(), argc, argv);
return cli.run();
} else {
// =========================================================
// GUI MODE
// =========================================================
QApplication a(argc, argv);
QScreen* screen = QGuiApplication::primaryScreen();
qDebug() << "\n===== DPI / Scale Info =====";
qDebug() << "Screen:" << screen->name();
qDebug() << "Logical DPI:" << screen->logicalDotsPerInch();
qDebug() << "Physical DPI:" << screen->physicalDotsPerInch();
qDebug() << "Device Pixel Ratio:" << screen->devicePixelRatio();
QFont f = QApplication::font();
qDebug() << "Font:" << f.family()
<< "PointSize:" << f.pointSizeF();
qDebug() << "============================\n";
// 1. appができてからSettingsを読み込む
Settings::instance().load();
// 2. 二重起動チェック
if (!Utility::tryLockFile()) {
return 0;
}
QFont font = QFontDatabase::systemFont(QFontDatabase::GeneralFont);
a.setFont(font);
// 3. 画面表示
MainWindow w(Settings::instance());
QGuiApplication::setWindowIcon(QIcon(":icon.png"));
w.show();
return a.exec();
}
}