diff --git a/graphics.qrc b/graphics.qrc index b1c54d7f..1d9d0a1b 100644 --- a/graphics.qrc +++ b/graphics.qrc @@ -31,5 +31,11 @@ img/buttonIconsBlack/square.png img/buttonIconsWhite/square.png img/flameshot.png + img/configWhite/config.png + img/configWhite/graphics.png + img/configWhite/name_edition.png + img/configBlack/config.png + img/configBlack/graphics.png + img/configBlack/name_edition.png diff --git a/img/configBlack/config.png b/img/configBlack/config.png new file mode 100644 index 00000000..6944e593 Binary files /dev/null and b/img/configBlack/config.png differ diff --git a/img/configBlack/config.svg b/img/configBlack/config.svg new file mode 100755 index 00000000..1ee22978 --- /dev/null +++ b/img/configBlack/config.svg @@ -0,0 +1,4 @@ + + + + diff --git a/img/configBlack/graphics.png b/img/configBlack/graphics.png new file mode 100644 index 00000000..cbcf5275 Binary files /dev/null and b/img/configBlack/graphics.png differ diff --git a/img/configBlack/graphics.svg b/img/configBlack/graphics.svg new file mode 100755 index 00000000..903aa6f7 --- /dev/null +++ b/img/configBlack/graphics.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/img/configBlack/name_edition.png b/img/configBlack/name_edition.png new file mode 100644 index 00000000..b2801009 Binary files /dev/null and b/img/configBlack/name_edition.png differ diff --git a/img/configBlack/name_edition.svg b/img/configBlack/name_edition.svg new file mode 100644 index 00000000..f73c4f88 --- /dev/null +++ b/img/configBlack/name_edition.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/img/configWhite/config.png b/img/configWhite/config.png new file mode 100644 index 00000000..89f7f592 Binary files /dev/null and b/img/configWhite/config.png differ diff --git a/img/configWhite/config.svg b/img/configWhite/config.svg new file mode 100644 index 00000000..91cb3356 --- /dev/null +++ b/img/configWhite/config.svg @@ -0,0 +1,61 @@ + + + + + + image/svg+xml + + + + + + + + + + diff --git a/img/configWhite/graphics.png b/img/configWhite/graphics.png new file mode 100644 index 00000000..097fe658 Binary files /dev/null and b/img/configWhite/graphics.png differ diff --git a/img/configWhite/graphics.svg b/img/configWhite/graphics.svg new file mode 100644 index 00000000..92017402 --- /dev/null +++ b/img/configWhite/graphics.svg @@ -0,0 +1,64 @@ + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/img/configWhite/name_edition.png b/img/configWhite/name_edition.png new file mode 100644 index 00000000..03ce5a4f Binary files /dev/null and b/img/configWhite/name_edition.png differ diff --git a/img/configWhite/name_edition.svg b/img/configWhite/name_edition.svg new file mode 100644 index 00000000..fa4ad144 --- /dev/null +++ b/img/configWhite/name_edition.svg @@ -0,0 +1,56 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/src/config/buttonlistview.cpp b/src/config/buttonlistview.cpp index 436d8005..f70a6259 100644 --- a/src/config/buttonlistview.cpp +++ b/src/config/buttonlistview.cpp @@ -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 diff --git a/src/config/configwindow.cpp b/src/config/configwindow.cpp index 6f2fd4dd..71aa8adb 100644 --- a/src/config/configwindow.cpp +++ b/src/config/configwindow.cpp @@ -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 #include -#include #include #include // 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(); } diff --git a/src/config/configwindow.h b/src/config/configwindow.h index bd0d5b42..2c9acc29 100644 --- a/src/config/configwindow.h +++ b/src/config/configwindow.h @@ -18,14 +18,9 @@ #ifndef CONFIGURATION_H #define CONFIGURATION_H -#include +#include -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; - - }; diff --git a/src/config/filenameeditor.cpp b/src/config/filenameeditor.cpp index 6168a7ec..39ca15ce 100644 --- a/src/config/filenameeditor.cpp +++ b/src/config/filenameeditor.cpp @@ -24,35 +24,36 @@ #include #include -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); - } -} diff --git a/src/config/filenameeditor.h b/src/config/filenameeditor.h index ee1a4242..d8968c04 100644 --- a/src/config/filenameeditor.h +++ b/src/config/filenameeditor.h @@ -18,7 +18,7 @@ #ifndef FILENAMEEDITOR_H #define FILENAMEEDITOR_H -#include +#include #include 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 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 diff --git a/src/config/geneneralconf.cpp b/src/config/geneneralconf.cpp index 86d5ce9f..6faacdee 100644 --- a/src/config/geneneralconf.cpp +++ b/src/config/geneneralconf.cpp @@ -20,10 +20,9 @@ #include #include -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(); } diff --git a/src/config/geneneralconf.h b/src/config/geneneralconf.h index 3837d330..b97410ea 100644 --- a/src/config/geneneralconf.h +++ b/src/config/geneneralconf.h @@ -18,11 +18,11 @@ #ifndef GENENERALCONF_H #define GENENERALCONF_H -#include +#include class QVBoxLayout; -class GeneneralConf : public QFrame { +class GeneneralConf : public QGroupBox { Q_OBJECT public: GeneneralConf(QWidget *parent = nullptr); diff --git a/src/config/strftimechooserwidget.cpp b/src/config/strftimechooserwidget.cpp index 6b56aa3a..a7480ef6 100644 --- a/src/config/strftimechooserwidget.cpp +++ b/src/config/strftimechooserwidget.cpp @@ -21,8 +21,6 @@ #include 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);}); diff --git a/src/config/uicoloreditor.cpp b/src/config/uicoloreditor.cpp index 3acfbe82..c5106df3 100644 --- a/src/config/uicoloreditor.cpp +++ b/src/config/uicoloreditor.cpp @@ -23,9 +23,8 @@ #include #include -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; diff --git a/src/config/uicoloreditor.h b/src/config/uicoloreditor.h index 191d7d49..70d06346 100644 --- a/src/config/uicoloreditor.h +++ b/src/config/uicoloreditor.h @@ -20,14 +20,14 @@ #include "color_wheel.hpp" #include "src/capture/capturebutton.h" -#include +#include class QVBoxLayout; class QHBoxLayout; class CaptureButton; class ClickableLabel; -class UIcolorEditor : public QFrame { +class UIcolorEditor : public QGroupBox { Q_OBJECT public: explicit UIcolorEditor(QWidget *parent = nullptr);