Changeset View
Changeset View
Standalone View
Standalone View
src/Main.cpp
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | * Copyright 2019 David Redondo <kde@david-redondo.de> | ||||
2 | * Copyright (C) 2015 Boudhayan Gupta <bgupta@kde.org> | 3 | * Copyright (C) 2015 Boudhayan Gupta <bgupta@kde.org> | ||
3 | * | 4 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU Lesser General Public License as published by | 6 | * it under the terms of the GNU Lesser General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | 8 | * (at your option) any later version. | ||
8 | * | 9 | * | ||
9 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. | ||
13 | * | 14 | * | ||
14 | * You should have received a copy of the GNU Lesser General Public License | 15 | * You should have received a copy of the GNU Lesser General Public License | ||
15 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | * Boston, MA 02110-1301, USA. | 18 | * Boston, MA 02110-1301, USA. | ||
18 | */ | 19 | */ | ||
19 | 20 | | |||
20 | #include "Config.h" | 21 | #include "Config.h" | ||
22 | #include "settings.h" | ||||
21 | #include "SpectacleCommon.h" | 23 | #include "SpectacleCommon.h" | ||
22 | #include "SpectacleCore.h" | 24 | #include "SpectacleCore.h" | ||
23 | #include "SpectacleDBusAdapter.h" | 25 | #include "SpectacleDBusAdapter.h" | ||
24 | 26 | | |||
25 | #include <QApplication> | 27 | #include <QApplication> | ||
26 | #include <QCommandLineParser> | 28 | #include <QCommandLineParser> | ||
27 | #include <QDBusConnection> | 29 | #include <QDBusConnection> | ||
28 | 30 | | |||
▲ Show 20 Lines • Show All 111 Lines • ▼ Show 20 Line(s) | 36 | { | |||
140 | case SpectacleCore::StartMode::Gui: | 142 | case SpectacleCore::StartMode::Gui: | ||
141 | break; | 143 | break; | ||
142 | } | 144 | } | ||
143 | 145 | | |||
144 | // release the kraken | 146 | // release the kraken | ||
145 | 147 | | |||
146 | SpectacleCore lCore(lStartMode, lCaptureMode, lFileName, lDelayMsec, lNotify, lCopyToClipboard); | 148 | SpectacleCore lCore(lStartMode, lCaptureMode, lFileName, lDelayMsec, lNotify, lCopyToClipboard); | ||
147 | QObject::connect(&lCore, &SpectacleCore::allDone, qApp, &QApplication::quit); | 149 | QObject::connect(&lCore, &SpectacleCore::allDone, qApp, &QApplication::quit); | ||
150 | QObject::connect(qApp, &QApplication::aboutToQuit, Settings::self(), &Settings::save); | ||||
148 | 151 | | |||
149 | // create the dbus connections | 152 | // create the dbus connections | ||
150 | 153 | | |||
151 | new KDBusService(KDBusService::Multiple, &lCore); | 154 | new KDBusService(KDBusService::Multiple, &lCore); | ||
152 | SpectacleDBusAdapter *lDBusAdapter = new SpectacleDBusAdapter(&lCore); | 155 | SpectacleDBusAdapter *lDBusAdapter = new SpectacleDBusAdapter(&lCore); | ||
153 | QObject::connect(&lCore, &SpectacleCore::grabFailed, lDBusAdapter, &SpectacleDBusAdapter::ScreenshotFailed); | 156 | QObject::connect(&lCore, &SpectacleCore::grabFailed, lDBusAdapter, &SpectacleDBusAdapter::ScreenshotFailed); | ||
154 | QObject::connect(ExportManager::instance(), &ExportManager::imageSaved, &lCore, [&](const QUrl &savedAt) { | 157 | QObject::connect(ExportManager::instance(), &ExportManager::imageSaved, &lCore, [&](const QUrl &savedAt) { | ||
155 | emit lDBusAdapter->ScreenshotTaken(savedAt.toLocalFile()); | 158 | emit lDBusAdapter->ScreenshotTaken(savedAt.toLocalFile()); | ||
156 | }); | 159 | }); | ||
157 | QDBusConnection::sessionBus().registerObject(QStringLiteral("/"), &lCore); | 160 | QDBusConnection::sessionBus().registerObject(QStringLiteral("/"), &lCore); | ||
158 | QDBusConnection::sessionBus().registerService(QStringLiteral("org.kde.Spectacle")); | 161 | QDBusConnection::sessionBus().registerService(QStringLiteral("org.kde.Spectacle")); | ||
159 | 162 | | |||
160 | // fire it up | 163 | // fire it up | ||
161 | 164 | | |||
162 | return lApp.exec(); | 165 | return lApp.exec(); | ||
163 | } | 166 | } |