1 /*
2 Scan Tailor - Interactive post-processing tool for scanned pages.
3 Copyright (C) Joseph Artsimovich <joseph.artsimovich@gmail.com>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include "Application.h"
20 #include "ColorSchemeManager.h"
21 #include "CommandLine.h"
22 #include "DarkScheme.h"
23 #include "JpegMetadataLoader.h"
24 #include "LightScheme.h"
25 #include "MainWindow.h"
26 #include "PngMetadataLoader.h"
27 #include "TiffMetadataLoader.h"
28 #include "config.h"
29 #include "NativeScheme.h"
30
main(int argc,char ** argv)31 int main(int argc, char** argv) {
32 // rescaling for high DPI displays
33 QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
34
35 Application app(argc, argv);
36
37 #ifdef _WIN32
38 // Get rid of all references to Qt's installation directory.
39 Application::setLibraryPaths(QStringList(Application::applicationDirPath()));
40 #endif
41
42 // Initialize command line in gui mode.
43 CommandLine cli(Application::arguments());
44 CommandLine::set(cli);
45
46 // This information is used by QSettings.
47 Application::setApplicationName(APPLICATION_NAME);
48 Application::setOrganizationName(ORGANIZATION_NAME);
49
50 PngMetadataLoader::registerMyself();
51 TiffMetadataLoader::registerMyself();
52 JpegMetadataLoader::registerMyself();
53
54 QSettings::setDefaultFormat(QSettings::IniFormat);
55 if (app.isPortableVersion()) {
56 QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, app.getPortableConfigPath());
57 }
58
59 QSettings settings;
60
61 app.installLanguage(settings.value("settings/language", QLocale::system().name()).toString());
62
63 {
64 QString val = settings.value("settings/color_scheme", "dark").toString();
65 std::unique_ptr<ColorScheme> scheme;
66 if (val == "native") {
67 scheme = std::make_unique<NativeScheme>();
68 } else if (val == "light") {
69 scheme = std::make_unique<LightScheme>();
70 } else {
71 scheme = std::make_unique<DarkScheme>();
72 }
73
74 ColorSchemeManager::instance()->setColorScheme(*scheme);
75 }
76
77 auto* main_wnd = new MainWindow();
78 main_wnd->setAttribute(Qt::WA_DeleteOnClose);
79 if (settings.value("mainWindow/maximized") == false) {
80 main_wnd->show();
81 } else {
82 // main_wnd->showMaximized(); // Doesn't work for Windows.
83 QTimer::singleShot(0, main_wnd, &QMainWindow::showMaximized);
84 }
85
86 if (!cli.projectFile().isEmpty()) {
87 main_wnd->openProject(cli.projectFile());
88 }
89
90 return Application::exec();
91 } // main
92