From 1802d05fdec2c448c2d4bfb417be80c82e750589 Mon Sep 17 00:00:00 2001 From: lupoDharkael Date: Fri, 2 Jun 2017 01:27:31 +0200 Subject: [PATCH] Add option to disable help message --- docs/dev/qsettings.md | 4 ++++ flameshot.pro | 6 ++++-- src/capture/capturewidget.cpp | 4 +++- src/config/configwindow.cpp | 22 ++++++++++++++------ src/config/configwindow.h | 8 +++++--- src/config/geneneralconf.cpp | 28 ++++++++++++++++++++++++++ src/config/geneneralconf.h | 22 ++++++++++++++++++++ src/controller.cpp | 1 + translation/Internationalization_es.ts | 28 +++++++++++++++++++++----- 9 files changed, 106 insertions(+), 17 deletions(-) create mode 100644 src/config/geneneralconf.cpp create mode 100644 src/config/geneneralconf.h diff --git a/docs/dev/qsettings.md b/docs/dev/qsettings.md index f0f73f3c..6a4c439a 100644 --- a/docs/dev/qsettings.md +++ b/docs/dev/qsettings.md @@ -22,3 +22,7 @@ - value: "contastUiColor" - type: QColor - description: color of buttons awhile selected. +- show Help message + - value: "showHelp" + - type: bool + - description: show Help message in capture mode. diff --git a/flameshot.pro b/flameshot.pro index 08e0bf34..b4bf964d 100644 --- a/flameshot.pro +++ b/flameshot.pro @@ -46,7 +46,8 @@ SOURCES += src/main.cpp\ src/capture/capturemodification.cpp \ src/capture/colorpicker.cpp \ src/config/buttonlistview.cpp \ - src/config/uicoloreditor.cpp + src/config/uicoloreditor.cpp \ + src/config/geneneralconf.cpp HEADERS += \ src/nativeeventfilter.h \ @@ -60,7 +61,8 @@ HEADERS += \ src/capture/capturemodification.h \ src/capture/colorpicker.h \ src/config/buttonlistview.h \ - src/config/uicoloreditor.h + src/config/uicoloreditor.h \ + src/config/geneneralconf.h RESOURCES += \ graphics.qrc diff --git a/src/capture/capturewidget.cpp b/src/capture/capturewidget.cpp index e6d94165..485f8362 100644 --- a/src/capture/capturewidget.cpp +++ b/src/capture/capturewidget.cpp @@ -52,8 +52,10 @@ namespace { CaptureWidget::CaptureWidget(QWidget *parent) : QWidget(parent), m_mouseOverHandle(0), m_mouseIsClicked(false), m_rightClick(false), m_newSelection(false), m_grabbing(false), - m_onButton(false), m_showInitialMsg(true), m_state(Button::Type::move) + m_onButton(false), m_state(Button::Type::move) { + m_showInitialMsg = QSettings().value("showHelp").toBool(); + setAttribute(Qt::WA_DeleteOnClose); // create selection handlers QRect baseRect(0, 0, HANDLE_SIZE, HANDLE_SIZE); diff --git a/src/config/configwindow.cpp b/src/config/configwindow.cpp index 2aab2612..f2654a94 100644 --- a/src/config/configwindow.cpp +++ b/src/config/configwindow.cpp @@ -19,30 +19,40 @@ #include "src/capture/button.h" #include "src/config/buttonlistview.h" #include "src/config/uicoloreditor.h" +#include "src/config/geneneralconf.h" #include #include #include #include #include +#include // ConfigWindow contains the menus where you can configure the application ConfigWindow::ConfigWindow(QWidget *parent) : QWidget(parent) { setAttribute(Qt::WA_DeleteOnClose); - setFixedSize(400, 400); + setFixedSize(400, 450); setWindowFlags(Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint); setWindowIcon(QIcon(":img/flameshot.svg")); setWindowTitle(tr("Configuration")); - QVBoxLayout *baseLayout = new QVBoxLayout(this); + m_layout = new QVBoxLayout(this); + // color editor QLabel *colorSelectionLabel = new QLabel(tr("UI color editor"), this); - baseLayout->addWidget(colorSelectionLabel); + m_layout->addWidget(colorSelectionLabel); - baseLayout->addWidget(new UIcolorEditor(this)); + m_layout->addWidget(new UIcolorEditor(this)); + // general config + QLabel *configLabel = new QLabel(tr("General"), this); + m_layout->addWidget(configLabel); + + m_layout->addWidget(new GeneneralConf(this)); + + // button selection QLabel *buttonSelectLabel = new QLabel(tr("Button selection"), this); - baseLayout->addWidget(buttonSelectLabel); + m_layout->addWidget(buttonSelectLabel); ButtonListView *m_buttonListView = new ButtonListView(this); m_buttonListView->setFlow(QListWidget::TopToBottom); @@ -50,7 +60,7 @@ ConfigWindow::ConfigWindow(QWidget *parent) : QWidget(parent) { "the capture's selection by clicking on its" " checkbox.")); - baseLayout->addWidget(m_buttonListView); + m_layout->addWidget(m_buttonListView); show(); } diff --git a/src/config/configwindow.h b/src/config/configwindow.h index 3ca7b1d2..28ae5fc4 100644 --- a/src/config/configwindow.h +++ b/src/config/configwindow.h @@ -20,6 +20,8 @@ #include +class QVBoxLayout; + class QListWidgetItem; class QListWidget; @@ -28,13 +30,13 @@ class ConfigWindow : public QWidget { public: explicit ConfigWindow(QWidget *parent = 0); -signals: - void setDefaults(); - protected: void keyPressEvent(QKeyEvent *); private: + QVBoxLayout *m_layout; + + }; diff --git a/src/config/geneneralconf.cpp b/src/config/geneneralconf.cpp new file mode 100644 index 00000000..839a8bd0 --- /dev/null +++ b/src/config/geneneralconf.cpp @@ -0,0 +1,28 @@ +#include "geneneralconf.h" + +#include +#include +#include + +GeneneralConf::GeneneralConf(QWidget *parent) : QFrame(parent) { + setFrameStyle(QFrame::StyledPanel); + + m_layout = new QVBoxLayout(this); + initHelpShow(); +} + +void GeneneralConf::showHelpChanged(bool checked) { + QSettings().setValue("showHelp", checked); +} + +void GeneneralConf::initHelpShow() { + QCheckBox *c = new QCheckBox(tr("Show help message"), this); + QSettings settings; + bool checked = settings.value("showHelp").toBool(); + c->setChecked(checked); + c->setWhatsThis(tr("Show the help message at the beginning " + "in the capture mode.")); + m_layout->addWidget(c); + + connect(c, &QCheckBox::clicked, this, &GeneneralConf::showHelpChanged); +} diff --git a/src/config/geneneralconf.h b/src/config/geneneralconf.h new file mode 100644 index 00000000..8244c887 --- /dev/null +++ b/src/config/geneneralconf.h @@ -0,0 +1,22 @@ +#ifndef GENENERALCONF_H +#define GENENERALCONF_H + +#include + +class QVBoxLayout; + +class GeneneralConf : public QFrame { + Q_OBJECT +public: + GeneneralConf(QWidget *parent = 0); + +private slots: + void showHelpChanged(bool checked); + +private: + QVBoxLayout *m_layout; + + void initHelpShow(); +}; + +#endif // GENENERALCONF_H diff --git a/src/controller.cpp b/src/controller.cpp index 2cb22337..799ca5a7 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -87,6 +87,7 @@ void Controller::initDefaults() { //settings.setValue("initiated", false); // testing change if (!settings.value("initiated").toBool()) { settings.setValue("initiated", true); + settings.setValue("showHelp", true); settings.setValue("drawColor", QColor(Qt::red)); //settings.setValue("mouseVisible", false); settings.setValue("uiColor", QColor(116, 0, 150)); diff --git a/translation/Internationalization_es.ts b/translation/Internationalization_es.ts index d9cd12ee..19fc415f 100644 --- a/translation/Internationalization_es.ts +++ b/translation/Internationalization_es.ts @@ -167,7 +167,7 @@ CaptureWidget - + Select an area with the mouse, or press Esc to exit. Press Enter to capture the screen. Press Right Click to choose the tool color. @@ -184,22 +184,27 @@ Presiona Click Derecho para elegir color de herramienta. ConfigWindow - + Configuration Configuración - + UI color editor Editor de color de interfaz - + + General + General + + + Button selection Selección de botones - + Select which buttons will appear arround the capture's selection by clicking on its checkbox. Selecciona qué botones aparecerán alrededor de la selección de captura clicando en su casilla. @@ -222,6 +227,19 @@ Presiona Click Derecho para elegir color de herramienta. &Salir + + GeneneralConf + + + Show help message + Mostrar mensaje de ayuda + + + + Show the help message at the beginning in the capture mode. + Muestra el mensaje de ayuda al iniciar el modo de captura. + + InfoWindow