diff --git a/src/config/CMakeLists.txt b/src/config/CMakeLists.txt index c431d975..0a518edc 100644 --- a/src/config/CMakeLists.txt +++ b/src/config/CMakeLists.txt @@ -12,4 +12,5 @@ target_sources( filepathconfiguration.cpp shortcutswidget.cpp setshortcutwidget.cpp + uploadstorageconfig.cpp ) diff --git a/src/config/configwindow.cpp b/src/config/configwindow.cpp index cc5f804c..b4baed4b 100644 --- a/src/config/configwindow.cpp +++ b/src/config/configwindow.cpp @@ -21,16 +21,15 @@ #include "src/config/geneneralconf.h" #include "src/config/shortcutswidget.h" #include "src/config/strftimechooserwidget.h" +#include "src/config/uploadstorageconfig.h" #include "src/config/visualseditor.h" #include "src/utils/colorutils.h" #include "src/utils/confighandler.h" #include "src/utils/globalvalues.h" #include "src/utils/pathinfo.h" -#include "src/widgets/capture/capturetoolbutton.h" #include #include #include -#include #include // ConfigWindow contains the menus where you can configure the application @@ -79,6 +78,12 @@ ConfigWindow::ConfigWindow(QWidget* parent) m_shortcuts = new ShortcutsWidget(); addTab(m_shortcuts, QIcon(modifier + "shortcut.svg"), tr("Shortcuts")); + // upload storage configuration + m_uploadStorageConfig = new UploadStorageConfig(); + addTab(m_uploadStorageConfig, + QIcon(modifier + "cloud-upload.svg"), + tr("Storage")); + // connect update sigslots connect(this, &ConfigWindow::updateChildren, diff --git a/src/config/configwindow.h b/src/config/configwindow.h index 088e363d..816244ab 100644 --- a/src/config/configwindow.h +++ b/src/config/configwindow.h @@ -25,6 +25,7 @@ class ShortcutsWidget; class GeneneralConf; class QFileSystemWatcher; class VisualsEditor; +class UploadStorageConfig; class ConfigWindow : public QTabWidget { @@ -42,6 +43,7 @@ private: FileNameEditor* m_filenameEditor; ShortcutsWidget* m_shortcuts; GeneneralConf* m_generalConfig; + UploadStorageConfig* m_uploadStorageConfig; VisualsEditor* m_visuals; QFileSystemWatcher* m_configWatcher; }; diff --git a/src/config/geneneralconf.cpp b/src/config/geneneralconf.cpp index 8b02ae37..a9d85eb3 100644 --- a/src/config/geneneralconf.cpp +++ b/src/config/geneneralconf.cpp @@ -18,21 +18,18 @@ #include "geneneralconf.h" #include "filepathconfiguration.h" #include "src/core/controller.h" -#include "src/tools/storage/imgstorages.h" #include "src/utils/confighandler.h" -#include "src/utils/filenamehandler.h" #include #include #include #include -#include #include #include #include -#include #include #include #include + GeneneralConf::GeneneralConf(QWidget* parent) : QWidget(parent) { @@ -48,7 +45,6 @@ GeneneralConf::GeneneralConf(QWidget* parent) initCopyAndCloseAfterUpload(); initSaveAfterCopy(); initCopyPathAfterSave(); - initUploadStorage(); initFilePathConfiguration(); // this has to be at the end @@ -398,41 +394,6 @@ void GeneneralConf::initCopyPathAfterSave() }); } -void GeneneralConf::initUploadStorage() -{ - QGroupBox* groupBox = new QGroupBox(tr("Upload storage")); - - // TODO - remove dependency injection (s3 & imgur) - // imgur - QRadioButton* storageImgUr = new QRadioButton(tr("Imgur storage")); - connect(storageImgUr, &QCheckBox::clicked, [](bool checked) { - ConfigHandler().setUploadStorage(SCREENSHOT_STORAGE_TYPE_IMGUR); - }); - - // s3 - QRadioButton* storageImgS3 = new QRadioButton( - tr("S3 storage (require config.ini file with s3 credentials)")); - connect(storageImgS3, &QCheckBox::clicked, [](bool checked) { - ConfigHandler().setUploadStorage(SCREENSHOT_STORAGE_TYPE_S3); - }); - - // set current storage radiobutton active - if (ConfigHandler().uploadStorage() == SCREENSHOT_STORAGE_TYPE_IMGUR) { - storageImgUr->setChecked(true); - - } else { - storageImgS3->setChecked(true); - } - - // draw configuration options for uploadStorage - QVBoxLayout* vbox = new QVBoxLayout; - vbox->addWidget(storageImgUr); - vbox->addWidget(storageImgS3); - vbox->addStretch(1); - groupBox->setLayout(vbox); - m_layout->addWidget(groupBox); -} - void GeneneralConf::initFilePathConfiguration() { m_filePathConfiguration = new FilePathConfiguration(); diff --git a/src/config/geneneralconf.h b/src/config/geneneralconf.h index 7f2aceb9..dd1e8054 100644 --- a/src/config/geneneralconf.h +++ b/src/config/geneneralconf.h @@ -79,6 +79,5 @@ private: void initCopyAndCloseAfterUpload(); void initSaveAfterCopy(); void initCopyPathAfterSave(); - void initUploadStorage(); void initFilePathConfiguration(); }; diff --git a/src/config/setshortcutwidget.cpp b/src/config/setshortcutwidget.cpp index b191d27a..7b570da4 100644 --- a/src/config/setshortcutwidget.cpp +++ b/src/config/setshortcutwidget.cpp @@ -1,3 +1,20 @@ +// Copyright(c) 2020 Yurii Puchkov at Namecheap & Contributors +// +// This file is part of Flameshot. +// +// Flameshot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Flameshot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Flameshot. If not, see . + #include "setshortcutwidget.h" #include #include diff --git a/src/config/setshortcutwidget.h b/src/config/setshortcutwidget.h index ba86df4c..70fb735b 100644 --- a/src/config/setshortcutwidget.h +++ b/src/config/setshortcutwidget.h @@ -1,3 +1,20 @@ +// Copyright(c) 2020 Yurii Puchkov at Namecheap & Contributors +// +// This file is part of Flameshot. +// +// Flameshot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Flameshot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Flameshot. If not, see . + #ifndef SETSHORTCUTWIDGET_H #define SETSHORTCUTWIDGET_H diff --git a/src/config/shortcutswidget.cpp b/src/config/shortcutswidget.cpp index 64c6ca14..84c9d292 100644 --- a/src/config/shortcutswidget.cpp +++ b/src/config/shortcutswidget.cpp @@ -1,3 +1,20 @@ +// Copyright(c) 2020 Yurii Puchkov at Namecheap & Contributors +// +// This file is part of Flameshot. +// +// Flameshot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Flameshot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Flameshot. If not, see . + #include "shortcutswidget.h" #include "setshortcutwidget.h" #include diff --git a/src/config/shortcutswidget.h b/src/config/shortcutswidget.h index 94410beb..20fc3909 100644 --- a/src/config/shortcutswidget.h +++ b/src/config/shortcutswidget.h @@ -1,3 +1,20 @@ +// Copyright(c) 2020 Yurii Puchkov at Namecheap & Contributors +// +// This file is part of Flameshot. +// +// Flameshot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Flameshot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Flameshot. If not, see . + #ifndef HOTKEYSCONFIG_H #define HOTKEYSCONFIG_H diff --git a/src/config/uploadstorageconfig.cpp b/src/config/uploadstorageconfig.cpp new file mode 100644 index 00000000..cf2d20bb --- /dev/null +++ b/src/config/uploadstorageconfig.cpp @@ -0,0 +1,64 @@ +// Copyright(c) 2020 Yurii Puchkov at Namecheap & Contributors +// +// This file is part of Flameshot. +// +// Flameshot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Flameshot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Flameshot. If not, see . + +#include "uploadstorageconfig.h" +#include "src/tools/storage/imgstorages.h" +#include "src/utils/confighandler.h" + +#include +#include +#include +#include + +UploadStorageConfig::UploadStorageConfig(QWidget* parent) + : QWidget(parent) +{ + m_layout = new QVBoxLayout(this); + m_layout->setAlignment(Qt::AlignTop); + + QGroupBox* groupBox = new QGroupBox(tr("Upload storage")); + + // TODO - remove dependency injection (s3 & imgur) + // imgur + QRadioButton* storageImgUr = new QRadioButton(tr("Imgur storage")); + connect(storageImgUr, &QCheckBox::clicked, [](bool checked) { + ConfigHandler().setUploadStorage(SCREENSHOT_STORAGE_TYPE_IMGUR); + }); + + // s3 + QRadioButton* storageImgS3 = new QRadioButton( + tr("S3 storage (require config.ini file with s3 credentials)")); + connect(storageImgS3, &QCheckBox::clicked, [](bool checked) { + ConfigHandler().setUploadStorage(SCREENSHOT_STORAGE_TYPE_S3); + }); + + // set current storage radiobutton active + if (ConfigHandler().uploadStorage() == SCREENSHOT_STORAGE_TYPE_IMGUR) { + storageImgUr->setChecked(true); + + } else { + storageImgS3->setChecked(true); + } + + // draw configuration options for uploadStorage + QVBoxLayout* vbox = new QVBoxLayout; + vbox->addWidget(storageImgUr); + vbox->addWidget(storageImgS3); + vbox->addStretch(1); + groupBox->setLayout(vbox); + m_layout->addWidget(groupBox); +} \ No newline at end of file diff --git a/src/config/uploadstorageconfig.h b/src/config/uploadstorageconfig.h new file mode 100644 index 00000000..91147478 --- /dev/null +++ b/src/config/uploadstorageconfig.h @@ -0,0 +1,36 @@ +// Copyright(c) 2020 Yurii Puchkov at Namecheap & Contributors +// +// This file is part of Flameshot. +// +// Flameshot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Flameshot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Flameshot. If not, see . + +#ifndef FLAMESHOT_UPLOADSTORAGECONFIG_H +#define FLAMESHOT_UPLOADSTORAGECONFIG_H + +#include +#include + +class QVBoxLayout; + +class UploadStorageConfig : public QWidget +{ + Q_OBJECT +public: + explicit UploadStorageConfig(QWidget* parent = nullptr); + +private: + QVBoxLayout* m_layout; +}; + +#endif // FLAMESHOT_UPLOADSTORAGECONFIG_H