From 19c415cd9bd444fbf298828bc1cb06cd10833357 Mon Sep 17 00:00:00 2001 From: lupoDharkael Date: Mon, 15 May 2017 02:59:06 +0200 Subject: [PATCH] Add default configuration --- configwindow.cpp | 8 ++------ controller.cpp | 23 +++++++++++++++++++++-- controller.h | 1 + 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/configwindow.cpp b/configwindow.cpp index 93a166d4..fb40d706 100644 --- a/configwindow.cpp +++ b/configwindow.cpp @@ -23,6 +23,7 @@ #include #include #include +#include // ConfigWindow contains the menus where you can configure the application @@ -50,15 +51,10 @@ ConfigWindow::ConfigWindow(QWidget *parent) : QWidget(parent){ baseLayout->addWidget(m_buttonListView); show(); } -#include + void ConfigWindow::initButtonList() { for (int i = 0; i != static_cast(Button::Type::last); ++i) { auto t = static_cast(i); - // Blocked items - if (t ==Button::Type::mouseVisibility || t ==Button::Type::text || - t ==Button::Type::arrow) { - continue; - } QListWidgetItem *buttonItem = new QListWidgetItem(m_buttonListView); bool iconsAreWhite = false; diff --git a/controller.cpp b/controller.cpp index 5f8ae265..380fdd4b 100644 --- a/controller.cpp +++ b/controller.cpp @@ -23,17 +23,19 @@ #include #include #include +#include // Controller is the core component of Flameshot, creates the trayIcon and // launches the capture widget Controller::Controller(QObject *parent) : QObject(parent) { + // required for the button serialization + qRegisterMetaTypeStreamOperators >("QList"); createActions(); createTrayIcon(); m_trayIcon->show(); - // required for the button serialization - qRegisterMetaTypeStreamOperators >("QList"); + initDefaults(); m_nativeEventFilter = new NativeEventFilter(this); qApp->installNativeEventFilter(m_nativeEventFilter); @@ -70,6 +72,23 @@ void Controller::createTrayIcon() { m_trayIcon->setIcon(QIcon(":img/flameshot.svg")); } +// initDefaults inits the global config in the very first run of the program +void Controller::initDefaults() { + QSettings settings; + if (!settings.value("initiated").toBool()) { + settings.setValue("initiated", true); + settings.setValue("drawColor", QColor(Qt::red)); + settings.setValue("mouseVisible", false); + settings.setValue("uiColor", QColor(136, 0, 170)); + + QList buttons; + for (int i = 0; i < static_cast(Button::Type::last); ++i) { + buttons << i; + } + settings.setValue("buttons", QVariant::fromValue(buttons)); + } +} + // creation of a new capture void Controller::slotPrintHotkey() { if (!m_captureWindow) { diff --git a/controller.h b/controller.h index 49b9549a..0d647640 100644 --- a/controller.h +++ b/controller.h @@ -42,6 +42,7 @@ private slots: private: void createActions(); void createTrayIcon(); + void initDefaults(); QAction *m_configAction; QAction *m_infoAction;