Add option to disable help message

This commit is contained in:
lupoDharkael
2017-06-02 01:27:31 +02:00
parent 25f63c0098
commit 1802d05fde
9 changed files with 106 additions and 17 deletions

View File

@@ -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.

View File

@@ -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

View File

@@ -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);

View File

@@ -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 <QIcon>
#include <QVBoxLayout>
#include <QGroupBox>
#include <QLabel>
#include <QKeyEvent>
#include <QFrame>
// 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();
}

View File

@@ -20,6 +20,8 @@
#include <QWidget>
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;
};

View File

@@ -0,0 +1,28 @@
#include "geneneralconf.h"
#include <QVBoxLayout>
#include <QSettings>
#include <QCheckBox>
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);
}

View File

@@ -0,0 +1,22 @@
#ifndef GENENERALCONF_H
#define GENENERALCONF_H
#include <QFrame>
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

View File

@@ -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));

View File

@@ -167,7 +167,7 @@
<context>
<name>CaptureWidget</name>
<message>
<location filename="../src/capture/capturewidget.cpp" line="155"/>
<location filename="../src/capture/capturewidget.cpp" line="157"/>
<source>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.</source>
@@ -184,22 +184,27 @@ Presiona Click Derecho para elegir color de herramienta.</translation>
<context>
<name>ConfigWindow</name>
<message>
<location filename="../src/config/configwindow.cpp" line="35"/>
<location filename="../src/config/configwindow.cpp" line="37"/>
<source>Configuration</source>
<translation>Configuración</translation>
</message>
<message>
<location filename="../src/config/configwindow.cpp" line="39"/>
<location filename="../src/config/configwindow.cpp" line="42"/>
<source>UI color editor</source>
<translation>Editor de color de interfaz</translation>
</message>
<message>
<location filename="../src/config/configwindow.cpp" line="44"/>
<location filename="../src/config/configwindow.cpp" line="48"/>
<source>General</source>
<translation>General</translation>
</message>
<message>
<location filename="../src/config/configwindow.cpp" line="54"/>
<source>Button selection</source>
<translation>Selección de botones</translation>
</message>
<message>
<location filename="../src/config/configwindow.cpp" line="49"/>
<location filename="../src/config/configwindow.cpp" line="59"/>
<source>Select which buttons will appear arround the capture&apos;s selection by clicking on its checkbox.</source>
<translation>Selecciona qué botones aparecerán alrededor de la selección de captura clicando en su casilla.</translation>
</message>
@@ -222,6 +227,19 @@ Presiona Click Derecho para elegir color de herramienta.</translation>
<translation>&amp;Salir</translation>
</message>
</context>
<context>
<name>GeneneralConf</name>
<message>
<location filename="../src/config/geneneralconf.cpp" line="19"/>
<source>Show help message</source>
<translation>Mostrar mensaje de ayuda</translation>
</message>
<message>
<location filename="../src/config/geneneralconf.cpp" line="23"/>
<source>Show the help message at the beginning in the capture mode.</source>
<translation>Muestra el mensaje de ayuda al iniciar el modo de captura.</translation>
</message>
</context>
<context>
<name>InfoWindow</name>
<message>