From efa7cb7983c9e6fa6cd1cca147d0c831e4ceeca7 Mon Sep 17 00:00:00 2001 From: Yuriy Puchkov Date: Mon, 13 Jul 2020 10:56:08 +0300 Subject: [PATCH] Add default path configration for screenshots --- flameshot.pro | 2 + src/config/configwindow.cpp | 9 ++- src/config/configwindow.h | 2 + src/config/filenameeditor.cpp | 2 +- src/config/filepathconfiguration.cpp | 77 ++++++++++++++++++++++ src/config/filepathconfiguration.h | 33 ++++++++++ src/utils/confighandler.cpp | 19 +++++- src/utils/confighandler.h | 2 + translations/Internationalization_ca.ts | 33 ++++++++++ translations/Internationalization_de_DE.ts | 33 ++++++++++ translations/Internationalization_es.ts | 33 ++++++++++ translations/Internationalization_fr.ts | 33 ++++++++++ translations/Internationalization_hu.ts | 27 ++++++++ translations/Internationalization_ja.ts | 33 ++++++++++ translations/Internationalization_ka.ts | 33 ++++++++++ translations/Internationalization_nl.ts | 33 ++++++++++ translations/Internationalization_pl.ts | 33 ++++++++++ translations/Internationalization_pt_br.ts | 33 ++++++++++ translations/Internationalization_ru.ts | 33 ++++++++++ translations/Internationalization_sk.ts | 33 ++++++++++ translations/Internationalization_sr.ts | 33 ++++++++++ translations/Internationalization_tr.ts | 33 ++++++++++ translations/Internationalization_uk.ts | 33 ++++++++++ translations/Internationalization_zh_CN.ts | 33 ++++++++++ translations/Internationalization_zh_TW.ts | 33 ++++++++++ update_release_version.sh | 4 ++ 26 files changed, 700 insertions(+), 5 deletions(-) create mode 100644 src/config/filepathconfiguration.cpp create mode 100644 src/config/filepathconfiguration.h diff --git a/flameshot.pro b/flameshot.pro index 1b94a1dd..e0fc6049 100644 --- a/flameshot.pro +++ b/flameshot.pro @@ -82,6 +82,7 @@ include(src/third-party/Qt-Color-Widgets//color_widgets.pri) DEFINES += QAPPLICATION_CLASS=QApplication SOURCES += src/main.cpp \ + src/config/filepathconfiguration.cpp \ src/widgets/capture/buttonhandler.cpp \ src/widgets/infowindow.cpp \ src/config/configwindow.cpp \ @@ -157,6 +158,7 @@ SOURCES += src/main.cpp \ src/widgets/panel/sidepanelwidget.cpp HEADERS += src/widgets/capture/buttonhandler.h \ + src/config/filepathconfiguration.h \ src/widgets/infowindow.h \ src/config/configwindow.h \ src/widgets/capture/capturewidget.h \ diff --git a/src/config/configwindow.cpp b/src/config/configwindow.cpp index 56687e60..43ba57ea 100644 --- a/src/config/configwindow.cpp +++ b/src/config/configwindow.cpp @@ -22,6 +22,7 @@ #include "src/widgets/capture/capturebutton.h" #include "src/config/geneneralconf.h" #include "src/config/filenameeditor.h" +#include "src/config/filepathconfiguration.h" #include "src/config/strftimechooserwidget.h" #include "src/config/visualseditor.h" #include "src/utils/globalvalues.h" @@ -35,8 +36,7 @@ ConfigWindow::ConfigWindow(QWidget *parent) : QTabWidget(parent) { setAttribute(Qt::WA_DeleteOnClose); - const int size = GlobalValues::buttonBaseSize() * 12; - setMinimumSize(size, size); + setMinimumSize(GlobalValues::buttonBaseSize() * 14, GlobalValues::buttonBaseSize() * 12); setWindowIcon(QIcon(":img/app/flameshot.svg")); setWindowTitle(tr("Configuration")); @@ -67,6 +67,11 @@ ConfigWindow::ConfigWindow(QWidget *parent) : QTabWidget(parent) { addTab(m_filenameEditor, QIcon(modifier + "name_edition.svg"), tr("Filename Editor")); + // filepath + m_filePathConfiguration = new FilePathConfiguration(); + addTab(m_filePathConfiguration, QIcon(modifier + "name_edition.svg"), + tr("Path Default")); + // general m_generalConfig = new GeneneralConf(); addTab(m_generalConfig, QIcon(modifier + "config.svg"), diff --git a/src/config/configwindow.h b/src/config/configwindow.h index f7671fb0..f2646aa6 100644 --- a/src/config/configwindow.h +++ b/src/config/configwindow.h @@ -20,6 +20,7 @@ #include class FileNameEditor; +class FilePathConfiguration; class GeneneralConf; class QFileSystemWatcher; class VisualsEditor; @@ -37,6 +38,7 @@ protected: private: FileNameEditor *m_filenameEditor; + FilePathConfiguration *m_filePathConfiguration; GeneneralConf *m_generalConfig; VisualsEditor *m_visuals; QFileSystemWatcher *m_configWatcher; diff --git a/src/config/filenameeditor.cpp b/src/config/filenameeditor.cpp index 36b6cddb..46bc7c88 100644 --- a/src/config/filenameeditor.cpp +++ b/src/config/filenameeditor.cpp @@ -27,7 +27,7 @@ FileNameEditor::FileNameEditor(QWidget *parent) : QWidget(parent) { initWidgets(); - initLayout(); + initLayout(); } void FileNameEditor::initLayout() { diff --git a/src/config/filepathconfiguration.cpp b/src/config/filepathconfiguration.cpp new file mode 100644 index 00000000..7ecafb43 --- /dev/null +++ b/src/config/filepathconfiguration.cpp @@ -0,0 +1,77 @@ +#include "filepathconfiguration.h" +#include "src/utils/filenamehandler.h" +#include "src/config/strftimechooserwidget.h" +#include "src/utils/confighandler.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "src/utils/confighandler.h" + + +FilePathConfiguration::FilePathConfiguration(QWidget *parent) : QWidget(parent) { + initWidgets(); + initLayout(); +} + +void FilePathConfiguration::initLayout() { + m_layout = new QVBoxLayout(this); + + m_layout->addWidget(new QLabel(tr("Screenshot path default:"))); + m_layout->addWidget(m_screenshotPathFixed); + m_layout->addWidget(m_screenshotPathFixedDefault); + m_layout->addStretch(); + QHBoxLayout *horizScreenshotButtonsLayout = new QHBoxLayout(); + horizScreenshotButtonsLayout->addStretch(); + horizScreenshotButtonsLayout->addWidget(m_screenshotPathFixedClear); + horizScreenshotButtonsLayout->addWidget(m_screenshotPathFixedBrowse); + m_layout->addLayout(horizScreenshotButtonsLayout); +} + +void FilePathConfiguration::initWidgets() { + ConfigHandler config; + + // Screenshot path default + m_screenshotPathFixed = new QCheckBox(tr("Use fixed path for screenshots to save"), this); + m_screenshotPathFixed->setChecked(!config.savePathFixed().isEmpty()); + connect(m_screenshotPathFixed, SIGNAL(toggled(bool)), this, SLOT(sreenshotPathFixed())); + m_screenshotPathFixedDefault = new QLineEdit(this); + m_screenshotPathFixedDefault->setText(config.savePathFixed()); + m_screenshotPathFixedDefault->setDisabled(config.savePathFixed().isEmpty()); + m_screenshotPathFixedBrowse = new QPushButton(tr("Browse"), this); + m_screenshotPathFixedBrowse->setDisabled(config.savePathFixed().isEmpty()); + connect(m_screenshotPathFixedBrowse, SIGNAL(released()),this, SLOT (screenshotPathFixedSet())); + m_screenshotPathFixedClear = new QPushButton(tr("Clear"), this); + m_screenshotPathFixedClear->setDisabled(config.savePathFixed().isEmpty()); + connect(m_screenshotPathFixedClear, SIGNAL(released()),this, SLOT (screenshotPathFixedClear())); +} + +void FilePathConfiguration::sreenshotPathFixed() { + bool status = m_screenshotPathFixedDefault->isEnabled(); + m_screenshotPathFixedDefault->setEnabled(!status); + m_screenshotPathFixedBrowse->setEnabled(!status); + m_screenshotPathFixedClear->setEnabled(!status); + screenshotPathFixedClear(); +} + +void FilePathConfiguration::screenshotPathFixedSet() { + QFileDialog *dirDialog = new QFileDialog(this, tr("Select default path for Screenshots")); + dirDialog->setFileMode(QFileDialog::DirectoryOnly); + dirDialog->setOption(QFileDialog::ShowDirsOnly, true); + QString filePath = dirDialog->getOpenFileName(); + QDir d = QFileInfo(filePath).absoluteDir(); + QString absolutePath = d.absolutePath(); + m_screenshotPathFixedDefault->setText(absolutePath); + ConfigHandler config; + config.setSavePathFixed(absolutePath); +} + +void FilePathConfiguration::screenshotPathFixedClear() { + ConfigHandler config; + m_screenshotPathFixedDefault->setText(""); + config.setSavePathFixed(m_screenshotPathFixedDefault->text()); +} diff --git a/src/config/filepathconfiguration.h b/src/config/filepathconfiguration.h new file mode 100644 index 00000000..0d4fc7fc --- /dev/null +++ b/src/config/filepathconfiguration.h @@ -0,0 +1,33 @@ +#pragma once + +#include +//#include + +class QVBoxLayout; +class QLineEdit; +class QCheckBox; +class FileNameHandler; +class QPushButton; + +class FilePathConfiguration : public QWidget { + Q_OBJECT +public: + explicit FilePathConfiguration(QWidget *parent = nullptr); + +private: + QVBoxLayout *m_layout; + QCheckBox *m_screenshotPathFixed; + QLineEdit *m_screenshotPathFixedDefault; + QPushButton *m_screenshotPathFixedBrowse; + QPushButton *m_screenshotPathFixedClear; + + void initLayout(); + void initWidgets(); + +public slots: + +private slots: + void sreenshotPathFixed(); + void screenshotPathFixedSet(); + void screenshotPathFixedClear(); +}; diff --git a/src/utils/confighandler.cpp b/src/utils/confighandler.cpp index 3c4d0e98..20960a45 100644 --- a/src/utils/confighandler.cpp +++ b/src/utils/confighandler.cpp @@ -118,11 +118,26 @@ void ConfigHandler::setUserColors(const QVector &l) { } QString ConfigHandler::savePathValue() { - return m_settings.value(QStringLiteral("savePath")).toString(); + QString savePath = m_settings.value(QStringLiteral("savePathFixed")).toString(); + if( savePath.isEmpty() ) { + savePath = m_settings.value(QStringLiteral("savePath")).toString(); + } + return savePath; } void ConfigHandler::setSavePath(const QString &savePath) { - m_settings.setValue(QStringLiteral("savePath"), savePath); + QString savePathFixed = m_settings.value(QStringLiteral("savePathFixed")).toString(); + if( savePathFixed.isEmpty() ) { + m_settings.setValue(QStringLiteral("savePath"), savePath); + } +} + +QString ConfigHandler::savePathFixed() { + return m_settings.value(QStringLiteral("savePathFixed")).toString(); +} + +void ConfigHandler::setSavePathFixed(const QString &savePathFixed) { + m_settings.setValue(QStringLiteral("savePathFixed"), savePathFixed); } QColor ConfigHandler::uiMainColorValue() { diff --git a/src/utils/confighandler.h b/src/utils/confighandler.h index 1886882c..f37704cf 100644 --- a/src/utils/confighandler.h +++ b/src/utils/confighandler.h @@ -33,6 +33,8 @@ public: QString savePathValue(); void setSavePath(const QString &); + QString savePathFixed(); + void setSavePathFixed(const QString &); QColor uiMainColorValue(); void setUIMainColor(const QColor &); diff --git a/translations/Internationalization_ca.ts b/translations/Internationalization_ca.ts index 535d87c7..1337f05f 100644 --- a/translations/Internationalization_ca.ts +++ b/translations/Internationalization_ca.ts @@ -172,6 +172,11 @@ Press Space to open the side panel. + Path Default + + + + General General @@ -286,6 +291,34 @@ Press Space to open the side panel. Elimina el patró + + FilePathConfiguration + + + Screenshot path default: + + + + + Use fixed path for screenshots to save + + + + + Browse + + + + + Clear + Neteja + + + + Select default path for Screenshots + + + GeneneralConf diff --git a/translations/Internationalization_de_DE.ts b/translations/Internationalization_de_DE.ts index ca7833d1..ea8ae725 100644 --- a/translations/Internationalization_de_DE.ts +++ b/translations/Internationalization_de_DE.ts @@ -175,6 +175,11 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. + Path Default + + + + General Allgemein @@ -289,6 +294,34 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. Löscht den Namen + + FilePathConfiguration + + + Screenshot path default: + + + + + Use fixed path for screenshots to save + + + + + Browse + + + + + Clear + Löschen + + + + Select default path for Screenshots + + + GeneneralConf diff --git a/translations/Internationalization_es.ts b/translations/Internationalization_es.ts index 0a5eca1b..bc660893 100644 --- a/translations/Internationalization_es.ts +++ b/translations/Internationalization_es.ts @@ -175,6 +175,11 @@ Presiona Espacio para abrir el panel lateral. + Path Default + + + + General General @@ -289,6 +294,34 @@ Presiona Espacio para abrir el panel lateral. Borra el patrón + + FilePathConfiguration + + + Screenshot path default: + + + + + Use fixed path for screenshots to save + + + + + Browse + + + + + Clear + Limpiar + + + + Select default path for Screenshots + + + GeneneralConf diff --git a/translations/Internationalization_fr.ts b/translations/Internationalization_fr.ts index ccc92f2f..038e7298 100644 --- a/translations/Internationalization_fr.ts +++ b/translations/Internationalization_fr.ts @@ -175,6 +175,11 @@ Appuyer sur Espace pour ouvrir le panneau latéral. + Path Default + + + + General Général @@ -289,6 +294,34 @@ Appuyer sur Espace pour ouvrir le panneau latéral. Supprime le nom + + FilePathConfiguration + + + Screenshot path default: + + + + + Use fixed path for screenshots to save + + + + + Browse + + + + + Clear + Purger + + + + Select default path for Screenshots + + + GeneneralConf diff --git a/translations/Internationalization_hu.ts b/translations/Internationalization_hu.ts index be551b04..d2973c84 100644 --- a/translations/Internationalization_hu.ts +++ b/translations/Internationalization_hu.ts @@ -154,6 +154,10 @@ Press Space to open the side panel. General Általános + + Path Default + + Controller @@ -257,6 +261,29 @@ Press Space to open the side panel. Képernyőmentés + + FilePathConfiguration + + Screenshot path default: + + + + Use fixed path for screenshots to save + + + + Browse + + + + Clear + Töröl + + + Select default path for Screenshots + + + FlameshotDBusAdapter diff --git a/translations/Internationalization_ja.ts b/translations/Internationalization_ja.ts index 34a3c27b..fc1be83c 100644 --- a/translations/Internationalization_ja.ts +++ b/translations/Internationalization_ja.ts @@ -175,6 +175,11 @@ Enter を押すと画面をキャプチャー。 + Path Default + + + + General 全般 @@ -289,6 +294,34 @@ Enter を押すと画面をキャプチャー。 名前を削除する + + FilePathConfiguration + + + Screenshot path default: + + + + + Use fixed path for screenshots to save + + + + + Browse + + + + + Clear + 消去 + + + + Select default path for Screenshots + + + GeneneralConf diff --git a/translations/Internationalization_ka.ts b/translations/Internationalization_ka.ts index 28433e79..aff2d115 100644 --- a/translations/Internationalization_ka.ts +++ b/translations/Internationalization_ka.ts @@ -171,6 +171,11 @@ Press Space to open the side panel. + Path Default + + + + General ზოგადი @@ -285,6 +290,34 @@ Press Space to open the side panel. სახელის წაშლა + + FilePathConfiguration + + + Screenshot path default: + + + + + Use fixed path for screenshots to save + + + + + Browse + + + + + Clear + გაწმენდა + + + + Select default path for Screenshots + + + GeneneralConf diff --git a/translations/Internationalization_nl.ts b/translations/Internationalization_nl.ts index cf1249a6..16870878 100644 --- a/translations/Internationalization_nl.ts +++ b/translations/Internationalization_nl.ts @@ -175,6 +175,11 @@ Druk op spatie om het zijpaneel te openen. + Path Default + + + + General Algemeen @@ -289,6 +294,34 @@ Druk op spatie om het zijpaneel te openen. Wist de naam + + FilePathConfiguration + + + Screenshot path default: + + + + + Use fixed path for screenshots to save + + + + + Browse + + + + + Clear + Wissen + + + + Select default path for Screenshots + + + GeneneralConf diff --git a/translations/Internationalization_pl.ts b/translations/Internationalization_pl.ts index c06245d7..ef6c4a1c 100644 --- a/translations/Internationalization_pl.ts +++ b/translations/Internationalization_pl.ts @@ -174,6 +174,11 @@ Spacja, aby pokazać panel boczny. + Path Default + + + + General Ogólne @@ -288,6 +293,34 @@ Spacja, aby pokazać panel boczny. Czyści wzorzec + + FilePathConfiguration + + + Screenshot path default: + + + + + Use fixed path for screenshots to save + + + + + Browse + + + + + Clear + Wyczyść + + + + Select default path for Screenshots + + + GeneneralConf diff --git a/translations/Internationalization_pt_br.ts b/translations/Internationalization_pt_br.ts index 1c33bb61..493032b3 100644 --- a/translations/Internationalization_pt_br.ts +++ b/translations/Internationalization_pt_br.ts @@ -175,6 +175,11 @@ Pressione espaço abrir o painel lateral. + Path Default + + + + General Geral @@ -289,6 +294,34 @@ Pressione espaço abrir o painel lateral. Deleta o nome + + FilePathConfiguration + + + Screenshot path default: + + + + + Use fixed path for screenshots to save + + + + + Browse + + + + + Clear + Limpar + + + + Select default path for Screenshots + + + GeneneralConf diff --git a/translations/Internationalization_ru.ts b/translations/Internationalization_ru.ts index 661450d6..ecf3ec86 100644 --- a/translations/Internationalization_ru.ts +++ b/translations/Internationalization_ru.ts @@ -175,6 +175,11 @@ Press Space to open the side panel. + Path Default + Путь + + + General Общие @@ -289,6 +294,34 @@ Press Space to open the side panel. Удаляет имя + + FilePathConfiguration + + + Screenshot path default: + Путь скриншотов по умолчанию + + + + Use fixed path for screenshots to save + Использовать фиксированный путь для скриншотов + + + + Browse + Обзор + + + + Clear + Очистить + + + + Select default path for Screenshots + Выбрать путь по умлочанию для скриншотов + + GeneneralConf diff --git a/translations/Internationalization_sk.ts b/translations/Internationalization_sk.ts index 02599ac1..7d82d0b4 100644 --- a/translations/Internationalization_sk.ts +++ b/translations/Internationalization_sk.ts @@ -175,6 +175,11 @@ Stlačte medzerník pre otvorenie postranného panelu. + Path Default + + + + General Všeobecné @@ -289,6 +294,34 @@ Stlačte medzerník pre otvorenie postranného panelu. Vymaže meno + + FilePathConfiguration + + + Screenshot path default: + + + + + Use fixed path for screenshots to save + + + + + Browse + + + + + Clear + Vyčistiť + + + + Select default path for Screenshots + + + GeneneralConf diff --git a/translations/Internationalization_sr.ts b/translations/Internationalization_sr.ts index a3de7d9a..42d77f86 100644 --- a/translations/Internationalization_sr.ts +++ b/translations/Internationalization_sr.ts @@ -175,6 +175,11 @@ Press Space to open the side panel. + Path Default + + + + General Опште @@ -289,6 +294,34 @@ Press Space to open the side panel. Брише име + + FilePathConfiguration + + + Screenshot path default: + + + + + Use fixed path for screenshots to save + + + + + Browse + + + + + Clear + Очисти + + + + Select default path for Screenshots + + + GeneneralConf diff --git a/translations/Internationalization_tr.ts b/translations/Internationalization_tr.ts index a56a6c9a..511eb343 100644 --- a/translations/Internationalization_tr.ts +++ b/translations/Internationalization_tr.ts @@ -175,6 +175,11 @@ Yan paneli açmak için Boşluk tuşuna basın. + Path Default + + + + General Genel @@ -289,6 +294,34 @@ Yan paneli açmak için Boşluk tuşuna basın. İsmi siler + + FilePathConfiguration + + + Screenshot path default: + + + + + Use fixed path for screenshots to save + + + + + Browse + + + + + Clear + Temizle + + + + Select default path for Screenshots + + + GeneneralConf diff --git a/translations/Internationalization_uk.ts b/translations/Internationalization_uk.ts index 406df45c..b1406f0e 100644 --- a/translations/Internationalization_uk.ts +++ b/translations/Internationalization_uk.ts @@ -175,6 +175,11 @@ Press Space to open the side panel. + Path Default + Шлях + + + General Загальне @@ -289,6 +294,34 @@ Press Space to open the side panel. Видаляє ім'я + + FilePathConfiguration + + + Screenshot path default: + Шлях за замовчуванням + + + + Use fixed path for screenshots to save + Використовувати шлях за замовчуванням + + + + Browse + Обрати + + + + Clear + Очистити + + + + Select default path for Screenshots + Обрати шлях за замовчуванням + + GeneneralConf diff --git a/translations/Internationalization_zh_CN.ts b/translations/Internationalization_zh_CN.ts index 1ce7fd82..156af1a4 100644 --- a/translations/Internationalization_zh_CN.ts +++ b/translations/Internationalization_zh_CN.ts @@ -176,6 +176,11 @@ Press Space to open the side panel. + Path Default + + + + General 常规 @@ -290,6 +295,34 @@ Press Space to open the side panel. 删除这个名字 + + FilePathConfiguration + + + Screenshot path default: + + + + + Use fixed path for screenshots to save + + + + + Browse + + + + + Clear + 清空 + + + + Select default path for Screenshots + + + GeneneralConf diff --git a/translations/Internationalization_zh_TW.ts b/translations/Internationalization_zh_TW.ts index 6e073fbf..a957d514 100644 --- a/translations/Internationalization_zh_TW.ts +++ b/translations/Internationalization_zh_TW.ts @@ -171,6 +171,11 @@ Press Space to open the side panel. + Path Default + + + + General 一般 @@ -285,6 +290,34 @@ Press Space to open the side panel. 刪除這個名稱 + + FilePathConfiguration + + + Screenshot path default: + + + + + Use fixed path for screenshots to save + + + + + Browse + + + + + Clear + 清空 + + + + Select default path for Screenshots + + + GeneneralConf diff --git a/update_release_version.sh b/update_release_version.sh index 6feba775..4d4815f5 100755 --- a/update_release_version.sh +++ b/update_release_version.sh @@ -27,8 +27,12 @@ BASE_VERSION_CUR_EXT=$(cat ./win_setup/flameshot.iss |grep "AppVersion=[0-9]\+\. echo "BASE_VERSION_CUR_EXT: ${BASE_VERSION_CUR_EXT}" sed -i "s/AppVersion=${BASE_VERSION_CUR_EXT}/AppVersion=${BASE_VERSION_NEW_EXT}/g" ./win_setup/flameshot.iss +# Run qmake and generate Makefile qmake +# update qt translations, ignore if no `lupdate` utils is installed +lupdate -recursive ./ -ts ./translations/* || true + # push current release git add flameshot.pro ./win_setup/flameshot.iss appveyor.yml .travis.yml git commit -m "Update version to ${BASE_VERSION_NEW}"