Major Controller refactor (#2295)
* Change Controller interface to mimic the CLI Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Remove obsolete handleCaptureTaken Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Extract system tray icon into separate class The implementation is not complete and full of bugs Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Remove Controller::handleCaptureFailed Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Fix a QObject connection Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Controller: remove unused includes Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Make check for updates work again Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Move functionality to daemon and tray icon Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Rename SystemTray to TrayIcon Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Add missing trayicon.* files Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Add missing QDesktopWidget Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Fix syntax errors Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Add missing include Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Include missing QOperatingSystemVersion on Mac Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Move update checking to daemon Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Remove obsolete method Controller::doLater Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Some cleanup Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Rename Controller to Flameshot Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Final touches Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>
This commit is contained in:
31
src/main.cpp
31
src/main.cpp
@@ -11,7 +11,7 @@
|
||||
#include "src/cli/commandlineparser.h"
|
||||
#include "src/config/styleoverride.h"
|
||||
#include "src/core/capturerequest.h"
|
||||
#include "src/core/controller.h"
|
||||
#include "src/core/flameshot.h"
|
||||
#include "src/core/flameshotdaemon.h"
|
||||
#include "src/utils/confighandler.h"
|
||||
#include "src/utils/filenamehandler.h"
|
||||
@@ -47,16 +47,15 @@ void wayland_hacks()
|
||||
|
||||
void requestCaptureAndWait(const CaptureRequest& req)
|
||||
{
|
||||
Controller* controller = Controller::getInstance();
|
||||
controller->requestCapture(req);
|
||||
QObject::connect(
|
||||
controller, &Controller::captureTaken, [&](QPixmap, QRect) {
|
||||
// Only useful on MacOS because each instance hosts its own widgets
|
||||
if (!FlameshotDaemon::isThisInstanceHostingWidgets()) {
|
||||
qApp->exit(0);
|
||||
}
|
||||
});
|
||||
QObject::connect(controller, &Controller::captureFailed, []() {
|
||||
Flameshot* flameshot = Flameshot::instance();
|
||||
flameshot->requestCapture(req);
|
||||
QObject::connect(flameshot, &Flameshot::captureTaken, [&](QPixmap) {
|
||||
// Only useful on MacOS because each instance hosts its own widgets
|
||||
if (!FlameshotDaemon::isThisInstanceHostingWidgets()) {
|
||||
qApp->exit(0);
|
||||
}
|
||||
});
|
||||
QObject::connect(flameshot, &Flameshot::captureFailed, []() {
|
||||
AbstractLogger::info() << "Screenshot aborted.";
|
||||
qApp->exit(1);
|
||||
});
|
||||
@@ -124,7 +123,7 @@ int main(int argc, char* argv[])
|
||||
qApp->installTranslator(&qtTranslator);
|
||||
qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true);
|
||||
|
||||
auto* c = Controller::getInstance();
|
||||
auto c = Flameshot::instance();
|
||||
FlameshotDaemon::start();
|
||||
|
||||
#if !(defined(Q_OS_MACOS) || defined(Q_OS_WIN))
|
||||
@@ -328,13 +327,13 @@ int main(int argc, char* argv[])
|
||||
|
||||
// PROCESS DATA
|
||||
//--------------
|
||||
Controller::setOrigin(Controller::CLI);
|
||||
Flameshot::setOrigin(Flameshot::CLI);
|
||||
if (parser.isSet(helpOption) || parser.isSet(versionOption)) {
|
||||
} else if (parser.isSet(launcherArgument)) { // LAUNCHER
|
||||
delete qApp;
|
||||
new QApplication(argc, argv);
|
||||
Controller* controller = Controller::getInstance();
|
||||
controller->openLauncherWindow();
|
||||
Flameshot* flameshot = Flameshot::instance();
|
||||
flameshot->launcher();
|
||||
qApp->exec();
|
||||
} else if (parser.isSet(guiArgument)) { // GUI
|
||||
delete qApp;
|
||||
@@ -514,7 +513,7 @@ int main(int argc, char* argv[])
|
||||
new QApplication(argc, argv);
|
||||
QObject::connect(
|
||||
qApp, &QApplication::lastWindowClosed, qApp, &QApplication::quit);
|
||||
Controller::getInstance()->openConfigWindow();
|
||||
Flameshot::instance()->config();
|
||||
qApp->exec();
|
||||
} else {
|
||||
ConfigHandler config;
|
||||
|
||||
Reference in New Issue
Block a user