Redesign of the config menu
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
|
||||
ButtonListView::ButtonListView(QWidget *parent) : QListWidget(parent) {
|
||||
setMouseTracking(true);
|
||||
setFlow(QListWidget::TopToBottom);
|
||||
initButtonList();
|
||||
connect(this, &QListWidget::itemChanged, this,
|
||||
&ButtonListView::updateActiveButtons);
|
||||
@@ -40,7 +41,7 @@ void ButtonListView::initButtonList() {
|
||||
CaptureTool *tool = factory.CreateTool(t);
|
||||
|
||||
// add element to the local map
|
||||
m_buttonTypeByName[tool->getName()] = t;
|
||||
m_buttonTypeByName.insert(tool->getName(), t);
|
||||
|
||||
// init the menu option
|
||||
|
||||
|
||||
@@ -21,48 +21,44 @@
|
||||
#include "src/config/uicoloreditor.h"
|
||||
#include "src/config/geneneralconf.h"
|
||||
#include "src/config/filenameeditor.h"
|
||||
#include "src/config/strftimechooserwidget.h"
|
||||
#include <QIcon>
|
||||
#include <QVBoxLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QLabel>
|
||||
#include <QKeyEvent>
|
||||
|
||||
// ConfigWindow contains the menus where you can configure the application
|
||||
|
||||
ConfigWindow::ConfigWindow(QWidget *parent) : QWidget(parent) {
|
||||
ConfigWindow::ConfigWindow(QWidget *parent) : QTabWidget(parent) {
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
setFixedSize(410, 540);
|
||||
setWindowIcon(QIcon(":img/flameshot.png"));
|
||||
setWindowTitle(tr("Configuration"));
|
||||
|
||||
m_layout = new QVBoxLayout(this);
|
||||
QColor background = this->palette().background().color();
|
||||
bool isWhite = CaptureButton::iconIsWhiteByColor(background);
|
||||
QString modifier = isWhite ? ":img/configWhite/" : ":img/configBlack/";
|
||||
|
||||
// color editor
|
||||
QLabel *colorSelectionLabel = new QLabel(tr("UI color editor"), this);
|
||||
m_layout->addWidget(colorSelectionLabel);
|
||||
// visuals
|
||||
auto visuals = new QWidget();
|
||||
QVBoxLayout *layoutUI= new QVBoxLayout();
|
||||
visuals->setLayout(layoutUI);
|
||||
layoutUI->addWidget(new UIcolorEditor());
|
||||
auto boxButtons = new QGroupBox();
|
||||
boxButtons->setTitle(tr("Button Selection"));
|
||||
auto listLayout = new QVBoxLayout(boxButtons);
|
||||
listLayout->addWidget(new ButtonListView());
|
||||
layoutUI->addWidget(boxButtons);
|
||||
|
||||
m_layout->addWidget(new UIcolorEditor(this));
|
||||
addTab(visuals, "Interface");
|
||||
setTabIcon(0, QIcon(modifier + "graphics.png"));
|
||||
|
||||
// general config
|
||||
QLabel *configLabel = new QLabel(tr("General"), this);
|
||||
m_layout->addWidget(configLabel);
|
||||
// filename
|
||||
addTab(new FileNameEditor(), "Name Editor");
|
||||
setTabIcon(1, QIcon(modifier + "name_edition.png"));
|
||||
|
||||
m_layout->addWidget(new GeneneralConf(this));
|
||||
|
||||
// button selection
|
||||
QLabel *buttonSelectLabel = new QLabel(tr("Button selection"), this);
|
||||
m_layout->addWidget(buttonSelectLabel);
|
||||
|
||||
ButtonListView *m_buttonListView = new ButtonListView(this);
|
||||
m_buttonListView->setFlow(QListWidget::TopToBottom);
|
||||
m_layout->addWidget(m_buttonListView);
|
||||
|
||||
// name editor
|
||||
QLabel *nameEditLabel = new QLabel(tr("Filename editor"), this);
|
||||
m_layout->addWidget(nameEditLabel);
|
||||
|
||||
FileNameEditor *nameEditor = new FileNameEditor(this);
|
||||
m_layout->addWidget(nameEditor);
|
||||
addTab(new GeneneralConf(), "General");
|
||||
setTabIcon(2, QIcon(modifier + "config.png"));
|
||||
|
||||
show();
|
||||
}
|
||||
|
||||
@@ -18,14 +18,9 @@
|
||||
#ifndef CONFIGURATION_H
|
||||
#define CONFIGURATION_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QTabWidget>
|
||||
|
||||
class QVBoxLayout;
|
||||
|
||||
class QListWidgetItem;
|
||||
class QListWidget;
|
||||
|
||||
class ConfigWindow : public QWidget {
|
||||
class ConfigWindow : public QTabWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ConfigWindow(QWidget *parent = nullptr);
|
||||
@@ -34,9 +29,6 @@ protected:
|
||||
void keyPressEvent(QKeyEvent *);
|
||||
|
||||
private:
|
||||
QVBoxLayout *m_layout;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -24,35 +24,36 @@
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
|
||||
FileNameEditor::FileNameEditor(QWidget *parent) : QFrame(parent) {
|
||||
setFrameStyle(QFrame::StyledPanel);
|
||||
FileNameEditor::FileNameEditor(QWidget *parent) : QGroupBox(parent) {
|
||||
initWidgets();
|
||||
initLayout();
|
||||
}
|
||||
|
||||
void FileNameEditor::initLayout() {
|
||||
m_layout = new QVBoxLayout(this);
|
||||
m_layout->addWidget(m_helperButtons);
|
||||
m_layout->addWidget(m_nameEditor);
|
||||
m_layout->addWidget(m_outputLabel);
|
||||
|
||||
QPushButton *openHelp = new QPushButton(tr("Open Helper"), this);
|
||||
connect(openHelp, &QPushButton::clicked, this, &FileNameEditor::openHelper);
|
||||
m_layout->addWidget(m_saveButton);
|
||||
QHBoxLayout *horizLayout = new QHBoxLayout();
|
||||
horizLayout->addWidget(m_saveButton);
|
||||
horizLayout->addWidget(openHelp);
|
||||
horizLayout->addWidget(m_resetButton);
|
||||
horizLayout->addWidget(m_clearButton);
|
||||
m_layout->addLayout(horizLayout);
|
||||
}
|
||||
|
||||
void FileNameEditor::initWidgets() {
|
||||
m_nameHandler = new FileNameHandler(this);
|
||||
|
||||
// editor
|
||||
m_nameEditor = new QLineEdit(this);
|
||||
m_nameEditor->setMaxLength(FileNameHandler::MAX_CHARACTERS);
|
||||
|
||||
// preview
|
||||
m_outputLabel = new QLineEdit(this);
|
||||
m_outputLabel->setReadOnly(true);
|
||||
m_outputLabel->setFocusPolicy(Qt::NoFocus);
|
||||
m_outputLabel->setDisabled(true);
|
||||
QString foreground = this->palette().foreground().color().name();
|
||||
m_outputLabel->setStyleSheet(QString("color: %1").arg(foreground));
|
||||
QPalette pal = m_outputLabel->palette();
|
||||
QColor color = pal.color(QPalette::Disabled, m_outputLabel->backgroundRole());
|
||||
pal.setColor(QPalette::Active, m_outputLabel->backgroundRole(), color);
|
||||
@@ -63,9 +64,26 @@ void FileNameEditor::initWidgets() {
|
||||
m_nameEditor->setText(ConfigHandler().getFilenamePattern());
|
||||
m_outputLabel->setText(m_nameHandler->getParsedPattern());
|
||||
|
||||
// helper buttons
|
||||
m_helperButtons = new StrftimeChooserWidget(this);
|
||||
connect(m_helperButtons, &StrftimeChooserWidget::variableEmitted,
|
||||
this, &FileNameEditor::addToNameEditor);
|
||||
|
||||
// save
|
||||
m_saveButton = new QPushButton(tr("Save"), this);
|
||||
connect(m_saveButton, &QPushButton::clicked, this, &FileNameEditor::savePattern);
|
||||
}
|
||||
m_saveButton->setToolTip(tr("Saves the pattern"));
|
||||
// reset
|
||||
m_resetButton = new QPushButton(tr("Reset"), this);
|
||||
connect(m_resetButton, &QPushButton::clicked,
|
||||
this, &FileNameEditor::resetName);
|
||||
m_resetButton->setToolTip(tr("Restores the saved pattern"));
|
||||
// clear
|
||||
m_clearButton = new QPushButton(tr("Clear"), this);
|
||||
connect(m_clearButton, &QPushButton::clicked, this,
|
||||
[this](){ m_nameEditor->setText("");
|
||||
});
|
||||
m_clearButton->setToolTip(tr("Deletes the name"));}
|
||||
|
||||
void FileNameEditor::savePattern() {
|
||||
QString pattern = m_nameEditor->text();
|
||||
@@ -77,17 +95,10 @@ void FileNameEditor::showParsedPattern(const QString &p) {
|
||||
m_outputLabel->setText(output);
|
||||
}
|
||||
|
||||
void FileNameEditor::resetName() {
|
||||
m_nameEditor->setText(ConfigHandler().getFilenamePattern());
|
||||
}
|
||||
|
||||
void FileNameEditor::addToNameEditor(QString s) {
|
||||
m_nameEditor->setText(m_nameEditor->text() + s);
|
||||
}
|
||||
|
||||
void FileNameEditor::openHelper() {
|
||||
if (!m_buttonHelper) {
|
||||
m_buttonHelper = new StrftimeChooserWidget();
|
||||
m_buttonHelper.data()->show();
|
||||
connect(this, &FileNameEditor::destroyed,
|
||||
m_buttonHelper, &StrftimeChooserWidget::deleteLater);
|
||||
connect(m_buttonHelper, &StrftimeChooserWidget::variableEmitted,
|
||||
this, &FileNameEditor::addToNameEditor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef FILENAMEEDITOR_H
|
||||
#define FILENAMEEDITOR_H
|
||||
|
||||
#include <QFrame>
|
||||
#include <QGroupBox>
|
||||
#include <QPointer>
|
||||
|
||||
class QVBoxLayout;
|
||||
@@ -27,7 +27,7 @@ class FileNameHandler;
|
||||
class QPushButton;
|
||||
class StrftimeChooserWidget;
|
||||
|
||||
class FileNameEditor : public QFrame
|
||||
class FileNameEditor : public QGroupBox
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -37,19 +37,22 @@ private:
|
||||
QVBoxLayout *m_layout;
|
||||
QLineEdit *m_outputLabel;
|
||||
QLineEdit *m_nameEditor;
|
||||
QPushButton *m_saveButton;
|
||||
FileNameHandler *m_nameHandler;
|
||||
|
||||
QPointer<StrftimeChooserWidget> m_buttonHelper;
|
||||
StrftimeChooserWidget *m_helperButtons;
|
||||
QPushButton *m_saveButton;
|
||||
QPushButton *m_resetButton;
|
||||
QPushButton *m_clearButton;
|
||||
|
||||
void initLayout();
|
||||
void initWidgets();
|
||||
|
||||
public slots:
|
||||
void addToNameEditor(QString s);
|
||||
|
||||
private slots:
|
||||
void savePattern();
|
||||
void showParsedPattern(const QString &);
|
||||
void addToNameEditor(QString s);
|
||||
void openHelper();
|
||||
void resetName();
|
||||
};
|
||||
|
||||
#endif // FILENAMEEDITOR_H
|
||||
|
||||
@@ -20,10 +20,9 @@
|
||||
#include <QVBoxLayout>
|
||||
#include <QCheckBox>
|
||||
|
||||
GeneneralConf::GeneneralConf(QWidget *parent) : QFrame(parent) {
|
||||
setFrameStyle(QFrame::StyledPanel);
|
||||
|
||||
GeneneralConf::GeneneralConf(QWidget *parent) : QGroupBox(parent) {
|
||||
m_layout = new QVBoxLayout(this);
|
||||
m_layout->setAlignment(Qt::AlignTop);
|
||||
initShowHelp();
|
||||
initShowDesktopNotification();
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
#ifndef GENENERALCONF_H
|
||||
#define GENENERALCONF_H
|
||||
|
||||
#include <QFrame>
|
||||
#include <QGroupBox>
|
||||
|
||||
class QVBoxLayout;
|
||||
|
||||
class GeneneralConf : public QFrame {
|
||||
class GeneneralConf : public QGroupBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
GeneneralConf(QWidget *parent = nullptr);
|
||||
|
||||
@@ -21,8 +21,6 @@
|
||||
#include <QPushButton>
|
||||
|
||||
StrftimeChooserWidget::StrftimeChooserWidget(QWidget *parent) : QWidget(parent) {
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
setWindowIcon(QIcon(":img/flameshot.png"));
|
||||
QGridLayout *layout = new QGridLayout(this);
|
||||
auto k = m_buttonData.keys();
|
||||
int middle = k.length()/2;
|
||||
@@ -35,6 +33,7 @@ StrftimeChooserWidget::StrftimeChooserWidget(QWidget *parent) : QWidget(parent)
|
||||
QPushButton *button = new QPushButton(this);
|
||||
button->setText(key);
|
||||
button->setToolTip(variable);
|
||||
button->setFixedHeight(30);
|
||||
layout->addWidget(button, j, i);
|
||||
connect(button, &QPushButton::clicked,
|
||||
this, [variable, this](){Q_EMIT variableEmitted(variable);});
|
||||
|
||||
@@ -23,9 +23,8 @@
|
||||
#include <QComboBox>
|
||||
#include <QMap>
|
||||
|
||||
UIcolorEditor::UIcolorEditor(QWidget *parent) : QFrame(parent) {
|
||||
setFrameStyle(QFrame::StyledPanel);
|
||||
|
||||
UIcolorEditor::UIcolorEditor(QWidget *parent) : QGroupBox(parent) {
|
||||
setTitle(tr("UI Color Editor"));
|
||||
hLayout = new QHBoxLayout;
|
||||
vLayout = new QVBoxLayout;
|
||||
|
||||
|
||||
@@ -20,14 +20,14 @@
|
||||
|
||||
#include "color_wheel.hpp"
|
||||
#include "src/capture/capturebutton.h"
|
||||
#include <QFrame>
|
||||
#include <QGroupBox>
|
||||
|
||||
class QVBoxLayout;
|
||||
class QHBoxLayout;
|
||||
class CaptureButton;
|
||||
class ClickableLabel;
|
||||
|
||||
class UIcolorEditor : public QFrame {
|
||||
class UIcolorEditor : public QGroupBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit UIcolorEditor(QWidget *parent = nullptr);
|
||||
|
||||
Reference in New Issue
Block a user