Move storage upload configuration to separate tab, later it can be uses for a plugin manager

This commit is contained in:
Yuriy Puchkov
2020-09-25 15:08:14 +03:00
parent 34bfe5a6c0
commit d0c8cea61f
11 changed files with 179 additions and 43 deletions

View File

@@ -12,4 +12,5 @@ target_sources(
filepathconfiguration.cpp
shortcutswidget.cpp
setshortcutwidget.cpp
uploadstorageconfig.cpp
)

View File

@@ -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 <QFileSystemWatcher>
#include <QIcon>
#include <QKeyEvent>
#include <QLabel>
#include <QVBoxLayout>
// 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,

View File

@@ -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;
};

View File

@@ -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 <QCheckBox>
#include <QFile>
#include <QFileDialog>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QLineEdit>
#include <QMessageBox>
#include <QPushButton>
#include <QRadioButton>
#include <QStandardPaths>
#include <QTextCodec>
#include <QVBoxLayout>
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();

View File

@@ -79,6 +79,5 @@ private:
void initCopyAndCloseAfterUpload();
void initSaveAfterCopy();
void initCopyPathAfterSave();
void initUploadStorage();
void initFilePathConfiguration();
};

View File

@@ -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 <http://www.gnu.org/licenses/>.
#include "setshortcutwidget.h"
#include <QIcon>
#include <QKeyEvent>

View File

@@ -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 <http://www.gnu.org/licenses/>.
#ifndef SETSHORTCUTWIDGET_H
#define SETSHORTCUTWIDGET_H

View File

@@ -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 <http://www.gnu.org/licenses/>.
#include "shortcutswidget.h"
#include "setshortcutwidget.h"
#include <QHeaderView>

View File

@@ -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 <http://www.gnu.org/licenses/>.
#ifndef HOTKEYSCONFIG_H
#define HOTKEYSCONFIG_H

View File

@@ -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 <http://www.gnu.org/licenses/>.
#include "uploadstorageconfig.h"
#include "src/tools/storage/imgstorages.h"
#include "src/utils/confighandler.h"
#include <QCheckBox>
#include <QGroupBox>
#include <QRadioButton>
#include <QVBoxLayout>
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);
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
#ifndef FLAMESHOT_UPLOADSTORAGECONFIG_H
#define FLAMESHOT_UPLOADSTORAGECONFIG_H
#include <QObject>
#include <QWidget>
class QVBoxLayout;
class UploadStorageConfig : public QWidget
{
Q_OBJECT
public:
explicit UploadStorageConfig(QWidget* parent = nullptr);
private:
QVBoxLayout* m_layout;
};
#endif // FLAMESHOT_UPLOADSTORAGECONFIG_H