Add default configuration
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include <QListWidgetItem>
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QDebug>
|
||||
|
||||
// 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 <QDebug>
|
||||
|
||||
void ConfigWindow::initButtonList() {
|
||||
for (int i = 0; i != static_cast<int>(Button::Type::last); ++i) {
|
||||
auto t = static_cast<Button::Type>(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;
|
||||
|
||||
@@ -23,17 +23,19 @@
|
||||
#include <QApplication>
|
||||
#include <QMenu>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QSettings>
|
||||
|
||||
// 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<int> >("QList<int>");
|
||||
createActions();
|
||||
createTrayIcon();
|
||||
m_trayIcon->show();
|
||||
|
||||
// required for the button serialization
|
||||
qRegisterMetaTypeStreamOperators<QList<int> >("QList<int>");
|
||||
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<int> buttons;
|
||||
for (int i = 0; i < static_cast<int>(Button::Type::last); ++i) {
|
||||
buttons << i;
|
||||
}
|
||||
settings.setValue("buttons", QVariant::fromValue(buttons));
|
||||
}
|
||||
}
|
||||
|
||||
// creation of a new capture
|
||||
void Controller::slotPrintHotkey() {
|
||||
if (!m_captureWindow) {
|
||||
|
||||
@@ -42,6 +42,7 @@ private slots:
|
||||
private:
|
||||
void createActions();
|
||||
void createTrayIcon();
|
||||
void initDefaults();
|
||||
|
||||
QAction *m_configAction;
|
||||
QAction *m_infoAction;
|
||||
|
||||
Reference in New Issue
Block a user