From 346607bc340ce5cf9769cf8d1c964ab562c151ea Mon Sep 17 00:00:00 2001 From: lupoDharkael Date: Fri, 21 Jul 2017 10:59:45 +0200 Subject: [PATCH] Redesign of the config menu --- graphics.qrc | 6 +++ img/configBlack/config.png | Bin 0 -> 360 bytes img/configBlack/config.svg | 4 ++ img/configBlack/graphics.png | Bin 0 -> 254 bytes img/configBlack/graphics.svg | 5 +++ img/configBlack/name_edition.png | Bin 0 -> 159 bytes img/configBlack/name_edition.svg | 1 + img/configWhite/config.png | Bin 0 -> 361 bytes img/configWhite/config.svg | 61 +++++++++++++++++++++++++ img/configWhite/graphics.png | Bin 0 -> 269 bytes img/configWhite/graphics.svg | 64 +++++++++++++++++++++++++++ img/configWhite/name_edition.png | Bin 0 -> 167 bytes img/configWhite/name_edition.svg | 56 +++++++++++++++++++++++ src/config/buttonlistview.cpp | 3 +- src/config/configwindow.cpp | 48 +++++++++----------- src/config/configwindow.h | 12 +---- src/config/filenameeditor.cpp | 51 ++++++++++++--------- src/config/filenameeditor.h | 17 ++++--- src/config/geneneralconf.cpp | 5 +-- src/config/geneneralconf.h | 4 +- src/config/strftimechooserwidget.cpp | 3 +- src/config/uicoloreditor.cpp | 5 +-- src/config/uicoloreditor.h | 4 +- 23 files changed, 273 insertions(+), 76 deletions(-) create mode 100644 img/configBlack/config.png create mode 100755 img/configBlack/config.svg create mode 100644 img/configBlack/graphics.png create mode 100755 img/configBlack/graphics.svg create mode 100644 img/configBlack/name_edition.png create mode 100644 img/configBlack/name_edition.svg create mode 100644 img/configWhite/config.png create mode 100644 img/configWhite/config.svg create mode 100644 img/configWhite/graphics.png create mode 100644 img/configWhite/graphics.svg create mode 100644 img/configWhite/name_edition.png create mode 100644 img/configWhite/name_edition.svg 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 0000000000000000000000000000000000000000..6944e593a0c2c3028ed95046f0c6455c18b64a30 GIT binary patch literal 360 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjoCO|{#S9F5he4R}c>anMprB-l zYeY$Kep*R+Vo@qXd3m{BW?pu2a$-TMUVc&f>~}U&Kt*3YT^vI^I^SNh^>TI;Ir?#a zSCV8*7xxF|gKAUtj;eKa%kukrM0TLnH^Ssc*|GdQAqu5dng%z`y*1D_u6n&rKhW66<=Hi>gN>jW8lHrQo< z2-+H-$XmYkv-CsHZFQC1SN9%VBT#WvoKGpe^`o9#(4p|`>D9r9y!R|;c(7Eg;F3Vx zBTdl@`5fJAUxys + + + diff --git a/img/configBlack/graphics.png b/img/configBlack/graphics.png new file mode 100644 index 0000000000000000000000000000000000000000..cbcf5275b30145633e40b7ef6623f1d2b7ad8866 GIT binary patch literal 254 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjoCO|{#S9F5he4R}c>anMprB-l zYeY$Kep*R+Vo@qXd3m{BW?pu2a$-TMUVc&f>~}U&Kt<3QpTh6>*WM}OwdRx9w|G%42J)S~9- znx3bN3TM`-uPHXLVAA$<5o>%taYY2ns-gv)A#Xzt6?J>56z{sfNRH`bx7;tjC7<=4 wCdTl6TfKE!R)=c*5#iUBr{gzBF#k1D?|$c}vpHPV59llgPgg&ebxsLQ0Nm|eU;qFB literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..b280100992e7ebf13d9df964d48ca094ccc22c8d GIT binary patch literal 159 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjoCO|{#S9F5he4R}c>anMprB-l zYeY$Kep*R+Vo@qXd3m{BW?pu2a$-TMUVc&f>~}U&Kt(#9E{-7{oyiFjtcw#wF31=p y3I6u?HJ+(qlEcE_^@w419FKt%J5Y*;oq^%HBNO|t%;LE~eGHzielF{r5}E*9w<|vY literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..89f7f5926fb76b3754eb9ab32eff94b372dde59e GIT binary patch literal 361 zcmV-v0ha!WP)pF8FWQhbW?9;ba!ELWdL_~cP?peYja~^aAhuUa%Y?FJQ@H10QN~l zK~zYI?bJVN0#Ojh@!!Kgq|2Tq2T&xC#wwn}%4U@mT3UDklhz9u$RWIdH&~Dq0i(id zz^{c{tq$(f-6lBYz?;v^d&83o4wp^ z@C*XbyQWxR2HWfNa4VVDmz!r!&zR@l>#DJSX zY# + + + + + image/svg+xml + + + + + + + + + + diff --git a/img/configWhite/graphics.png b/img/configWhite/graphics.png new file mode 100644 index 0000000000000000000000000000000000000000..097fe658b2f8a5f48a8649355626cb97980323da GIT binary patch literal 269 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjoCO|{#S9F5he4R}c>anMprB-l zYeY$Kep*R+Vo@qXd3m{BW?pu2a$-TMUVc&f>~}U&Kt;1WT^vI^I^Tvk@*P&-*}U3z z@vZt@?Oz_>wBI8v)FpNCKosBXe3qo+Dhz)L#U{l~^7(7vIs194Y68QxgI2vyjEfXJ zU#0eanjUv(bA^kv`_&0c`X{IC)%&e#civHd&*Ci&>KTf<6W%&%Ojv8;RMi#L^6$*k z;4h_&{}(;q+x%i*bnTA4>|2}78%m$JvnJRDSl{U9Q#tv)@lX6wcJ{(-YO??U literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..03ce5a4fca5e1a6605079c7e2672d335b8517526 GIT binary patch literal 167 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjoCO|{#S9F5he4R}c>anMprB-l zYeY$Kep*R+Vo@qXd3m{BW?pu2a$-TMUVc&f>~}U&Kt(2=E{-7{oyiFjtcw#wF31=x z;{Nmh|9^W|HY1}&Gfuj6CMq*ekY#_7*vs8>?4X7O>tRL)hM#*l*so0DYXj + + + + + 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);