diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..c4ac57ae --- /dev/null +++ b/.clang-format @@ -0,0 +1,6 @@ +Language: Cpp +BasedOnStyle: Mozilla +IndentWidth: 4 +AccessModifierOffset: -4 +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None diff --git a/flameshot.pro b/flameshot.pro index cd80d8c9..11b7b0c7 100644 --- a/flameshot.pro +++ b/flameshot.pro @@ -87,7 +87,7 @@ SOURCES += src/main.cpp \ src/config/filepathconfiguration.cpp \ src/config/setshortcutwidget.cpp \ src/config/shortcutswidget.cpp \ - src/tools/imgs3/imgs3settings.cpp \ + src/tools/storage/storagemanager.cpp \ src/utils/configshortcuts.cpp \ src/widgets/historywidget.cpp \ src/utils/configenterprise.cpp \ @@ -112,8 +112,6 @@ SOURCES += src/main.cpp \ src/tools/circle/circletool.cpp \ src/tools/copy/copytool.cpp \ src/tools/exit/exittool.cpp \ - src/tools/imgur/imguruploadertool.cpp \ - src/tools/imgs3/imgs3uploadertool.cpp \ src/tools/line/linetool.cpp \ src/tools/marker/markertool.cpp \ src/tools/move/movetool.cpp \ @@ -130,8 +128,12 @@ SOURCES += src/main.cpp \ src/cli/commandoption.cpp \ src/cli/commandargument.cpp \ src/utils/screenshotsaver.cpp \ - src/tools/imgur/imguruploader.cpp \ - src/tools/imgs3/imgs3uploader.cpp \ + src/tools/storage/imguploader.cpp \ + src/tools/storage/imgur/imguruploadertool.cpp \ + src/tools/storage/imgur/imguruploader.cpp \ + src/tools/storage/s3/imgs3uploadertool.cpp \ + src/tools/storage/s3/imgs3uploader.cpp \ + src/tools/storage/s3/imgs3settings.cpp \ src/widgets/loadspinner.cpp \ src/widgets/imagelabel.cpp \ src/widgets/notificationwidget.cpp \ @@ -170,7 +172,8 @@ HEADERS += src/widgets/capture/buttonhandler.h \ src/config/filepathconfiguration.h \ src/config/setshortcutwidget.h \ src/config/shortcutswidget.h \ - src/tools/imgs3/imgs3settings.h \ + src/tools/storage/imgstorages.h \ + src/tools/storage/storagemanager.h \ src/utils/configshortcuts.h \ src/widgets/historywidget.h \ src/utils/configenterprise.h \ @@ -196,8 +199,6 @@ HEADERS += src/widgets/capture/buttonhandler.h \ src/tools/circle/circletool.h \ src/tools/copy/copytool.h \ src/tools/exit/exittool.h \ - src/tools/imgur/imguruploadertool.h \ - src/tools/imgs3/imgs3uploadertool.h \ src/tools/line/linetool.h \ src/tools/marker/markertool.h \ src/tools/move/movetool.h \ @@ -213,8 +214,12 @@ HEADERS += src/widgets/capture/buttonhandler.h \ src/cli/commandoption.h \ src/cli/commandargument.h \ src/utils/screenshotsaver.h \ - src/tools/imgur/imguruploader.h \ - src/tools/imgs3/imgs3uploader.h \ + src/tools/storage/imguploader.h \ + src/tools/storage/imgur/imguruploadertool.h \ + src/tools/storage/imgur/imguruploader.h \ + src/tools/storage/s3/imgs3uploader.h \ + src/tools/storage/s3/imgs3uploadertool.h \ + src/tools/storage/s3/imgs3settings.h \ src/widgets/loadspinner.h \ src/widgets/imagelabel.h \ src/widgets/notificationwidget.h \ diff --git a/src/config/configwindow.cpp b/src/config/configwindow.cpp index 26cbea4e..c3c2aa14 100644 --- a/src/config/configwindow.cpp +++ b/src/config/configwindow.cpp @@ -16,32 +16,35 @@ // along with Flameshot. If not, see . #include "configwindow.h" -#include "src/utils/colorutils.h" -#include "src/utils/confighandler.h" -#include "src/utils/pathinfo.h" -#include "src/widgets/capture/capturebutton.h" -#include "src/config/geneneralconf.h" #include "src/config/filenameeditor.h" #include "src/config/filepathconfiguration.h" +#include "src/config/geneneralconf.h" #include "src/config/shortcutswidget.h" #include "src/config/strftimechooserwidget.h" #include "src/config/visualseditor.h" +#include "src/utils/colorutils.h" +#include "src/utils/confighandler.h" #include "src/utils/globalvalues.h" -#include -#include -#include -#include +#include "src/utils/pathinfo.h" +#include "src/widgets/capture/capturebutton.h" #include +#include +#include +#include +#include // ConfigWindow contains the menus where you can configure the application -ConfigWindow::ConfigWindow(QWidget *parent) : QTabWidget(parent) { +ConfigWindow::ConfigWindow(QWidget* parent) + : QTabWidget(parent) +{ setAttribute(Qt::WA_DeleteOnClose); - setMinimumSize(GlobalValues::buttonBaseSize() * 14, GlobalValues::buttonBaseSize() * 12); + setMinimumSize(GlobalValues::buttonBaseSize() * 14, + GlobalValues::buttonBaseSize() * 12); setWindowIcon(QIcon(":img/app/flameshot.svg")); setWindowTitle(tr("Configuration")); - auto changedSlot = [this](QString s){ + auto changedSlot = [this](QString s) { QStringList files = m_configWatcher->files(); if (!files.contains(s)) { this->m_configWatcher->addPath(s); @@ -50,50 +53,50 @@ ConfigWindow::ConfigWindow(QWidget *parent) : QTabWidget(parent) { }; m_configWatcher = new QFileSystemWatcher(this); m_configWatcher->addPath(ConfigHandler().configFilePath()); - connect(m_configWatcher, &QFileSystemWatcher::fileChanged, - this, changedSlot); + connect( + m_configWatcher, &QFileSystemWatcher::fileChanged, this, changedSlot); QColor background = this->palette().background().color(); bool isDark = ColorUtils::colorIsDark(background); - QString modifier = isDark ? PathInfo::whiteIconPath() : - PathInfo::blackIconPath(); + QString modifier = + isDark ? PathInfo::whiteIconPath() : PathInfo::blackIconPath(); // visuals m_visuals = new VisualsEditor(); - addTab(m_visuals, QIcon(modifier + "graphics.svg"), - tr("Interface")); + addTab(m_visuals, QIcon(modifier + "graphics.svg"), tr("Interface")); // filename m_filenameEditor = new FileNameEditor(); - addTab(m_filenameEditor, QIcon(modifier + "name_edition.svg"), + addTab(m_filenameEditor, + QIcon(modifier + "name_edition.svg"), tr("Filename Editor")); // general m_generalConfig = new GeneneralConf(); - addTab(m_generalConfig, QIcon(modifier + "config.svg"), - tr("General")); + addTab(m_generalConfig, QIcon(modifier + "config.svg"), tr("General")); // shortcuts m_shortcuts = new ShortcutsWidget(); - addTab(m_shortcuts, QIcon(modifier + "shortcut.svg"), - tr("Shortcuts")); - - // filepath - m_filePathConfiguration = new FilePathConfiguration(); - addTab(m_filePathConfiguration, QIcon(modifier + "filepath.svg"), - tr("Path Default")); + addTab(m_shortcuts, QIcon(modifier + "shortcut.svg"), tr("Shortcuts")); // connect update sigslots - connect(this, &ConfigWindow::updateChildren, - m_filenameEditor, &FileNameEditor::updateComponents); - connect(this, &ConfigWindow::updateChildren, - m_visuals, &VisualsEditor::updateComponents); - connect(this, &ConfigWindow::updateChildren, - m_generalConfig, &GeneneralConf::updateComponents); + connect(this, + &ConfigWindow::updateChildren, + m_filenameEditor, + &FileNameEditor::updateComponents); + connect(this, + &ConfigWindow::updateChildren, + m_visuals, + &VisualsEditor::updateComponents); + connect(this, + &ConfigWindow::updateChildren, + m_generalConfig, + &GeneneralConf::updateComponents); } -void ConfigWindow::keyPressEvent(QKeyEvent *e) { +void ConfigWindow::keyPressEvent(QKeyEvent* e) +{ if (e->key() == Qt::Key_Escape) { - close(); + close(); } } diff --git a/src/config/configwindow.h b/src/config/configwindow.h index 7bdc36be..088e363d 100644 --- a/src/config/configwindow.h +++ b/src/config/configwindow.h @@ -26,22 +26,22 @@ class GeneneralConf; class QFileSystemWatcher; class VisualsEditor; -class ConfigWindow : public QTabWidget { +class ConfigWindow : public QTabWidget +{ Q_OBJECT public: - explicit ConfigWindow(QWidget *parent = nullptr); + explicit ConfigWindow(QWidget* parent = nullptr); signals: void updateChildren(); protected: - void keyPressEvent(QKeyEvent *); + void keyPressEvent(QKeyEvent*); private: - FileNameEditor *m_filenameEditor; - FilePathConfiguration *m_filePathConfiguration; - ShortcutsWidget *m_shortcuts; - GeneneralConf *m_generalConfig; - VisualsEditor *m_visuals; - QFileSystemWatcher *m_configWatcher; + FileNameEditor* m_filenameEditor; + ShortcutsWidget* m_shortcuts; + GeneneralConf* m_generalConfig; + VisualsEditor* m_visuals; + QFileSystemWatcher* m_configWatcher; }; diff --git a/src/config/geneneralconf.cpp b/src/config/geneneralconf.cpp index 0732d631..58e55687 100644 --- a/src/config/geneneralconf.cpp +++ b/src/config/geneneralconf.cpp @@ -16,20 +16,24 @@ // along with Flameshot. If not, see . #include "geneneralconf.h" -#include "src/utils/confighandler.h" -#include "src/utils/confighandler.h" +#include "filepathconfiguration.h" #include "src/core/controller.h" -#include -#include +#include "src/tools/storage/imgstorages.h" +#include "src/utils/confighandler.h" #include -#include -#include -#include #include -#include +#include #include +#include +#include +#include +#include +#include +#include -GeneneralConf::GeneneralConf(QWidget *parent) : QWidget(parent) { +GeneneralConf::GeneneralConf(QWidget* parent) + : QWidget(parent) +{ m_layout = new QVBoxLayout(this); m_layout->setAlignment(Qt::AlignTop); initShowHelp(); @@ -40,19 +44,23 @@ GeneneralConf::GeneneralConf(QWidget *parent) : QWidget(parent) { initCloseAfterCapture(); initCopyAndCloseAfterUpload(); initCopyPathAfterSave(); + initUploadStorage(); + initFilePathConfiguration(); // this has to be at the end initConfingButtons(); updateComponents(); } -void GeneneralConf::updateComponents() { +void GeneneralConf::updateComponents() +{ ConfigHandler config; m_helpMessage->setChecked(config.showHelpValue()); m_sysNotifications->setChecked(config.desktopNotificationValue()); m_autostart->setChecked(config.startupLaunchValue()); m_closeAfterCapture->setChecked(config.closeAfterScreenshotValue()); - m_copyAndCloseAfterUpload->setChecked(config.copyAndCloseAfterUploadEnabled()); + m_copyAndCloseAfterUpload->setChecked( + config.copyAndCloseAfterUploadEnabled()); m_copyPathAfterSave->setChecked(config.copyPathAfterSaveEnabled()); #if defined(Q_OS_LINUX) || defined(Q_OS_UNIX) @@ -60,15 +68,18 @@ void GeneneralConf::updateComponents() { #endif } -void GeneneralConf::showHelpChanged(bool checked) { +void GeneneralConf::showHelpChanged(bool checked) +{ ConfigHandler().setShowHelp(checked); } -void GeneneralConf::showDesktopNotificationChanged(bool checked) { +void GeneneralConf::showDesktopNotificationChanged(bool checked) +{ ConfigHandler().setDesktopNotification(checked); } -void GeneneralConf::showTrayIconChanged(bool checked) { +void GeneneralConf::showTrayIconChanged(bool checked) +{ auto controller = Controller::getInstance(); if (checked) { controller->enableTrayIcon(); @@ -77,25 +88,29 @@ void GeneneralConf::showTrayIconChanged(bool checked) { } } -void GeneneralConf::autostartChanged(bool checked) { +void GeneneralConf::autostartChanged(bool checked) +{ ConfigHandler().setStartupLaunch(checked); } -void GeneneralConf::showStartupLaunchMessageChanged(bool checked) { +void GeneneralConf::showStartupLaunchMessageChanged(bool checked) +{ ConfigHandler().setShowStartupLaunchMessage(checked); } -void GeneneralConf::closeAfterCaptureChanged(bool checked) { +void GeneneralConf::closeAfterCaptureChanged(bool checked) +{ ConfigHandler().setCloseAfterScreenshot(checked); } -void GeneneralConf::importConfiguration() { +void GeneneralConf::importConfiguration() +{ QString fileName = QFileDialog::getOpenFileName(this, tr("Import")); if (fileName.isEmpty()) { return; } QFile file(fileName); - QTextCodec *codec = QTextCodec::codecForLocale(); + QTextCodec* codec = QTextCodec::codecForLocale(); if (!file.open(QFile::ReadOnly)) { QMessageBox::about(this, tr("Error"), tr("Unable to read file.")); return; @@ -105,16 +120,17 @@ void GeneneralConf::importConfiguration() { QFile config(ConfigHandler().configFilePath()); if (!config.open(QFile::WriteOnly)) { - QMessageBox::about(this, tr("Error"), tr("Unable to write file.")); - return; + QMessageBox::about(this, tr("Error"), tr("Unable to write file.")); + return; } config.write(codec->fromUnicode(text)); config.close(); } -void GeneneralConf::exportFileConfiguration() { - QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), - QStringLiteral("flameshot.conf")); +void GeneneralConf::exportFileConfiguration() +{ + QString fileName = QFileDialog::getSaveFileName( + this, tr("Save File"), QStringLiteral("flameshot.conf")); // Cancel button if (fileName.isNull()) { @@ -131,45 +147,52 @@ void GeneneralConf::exportFileConfiguration() { } } -void GeneneralConf::resetConfiguration() { +void GeneneralConf::resetConfiguration() +{ QMessageBox::StandardButton reply; reply = QMessageBox::question( - this, tr("Confirm Reset"), - tr("Are you sure you want to reset the configuration?"), - QMessageBox::Yes | QMessageBox::No); + this, + tr("Confirm Reset"), + tr("Are you sure you want to reset the configuration?"), + QMessageBox::Yes | QMessageBox::No); if (reply == QMessageBox::Yes) { ConfigHandler().setDefaults(); } } - -void GeneneralConf::initShowHelp() { +void GeneneralConf::initShowHelp() +{ m_helpMessage = new QCheckBox(tr("Show help message"), this); ConfigHandler config; bool checked = config.showHelpValue(); m_helpMessage->setChecked(checked); m_helpMessage->setToolTip(tr("Show the help message at the beginning " - "in the capture mode.")); + "in the capture mode.")); m_layout->addWidget(m_helpMessage); - connect(m_helpMessage, &QCheckBox::clicked, this, + connect(m_helpMessage, + &QCheckBox::clicked, + this, &GeneneralConf::showHelpChanged); } -void GeneneralConf::initShowDesktopNotification() { - m_sysNotifications = - new QCheckBox(tr("Show desktop notifications"), this); +void GeneneralConf::initShowDesktopNotification() +{ + m_sysNotifications = new QCheckBox(tr("Show desktop notifications"), this); ConfigHandler config; bool checked = config.desktopNotificationValue(); m_sysNotifications->setChecked(checked); m_sysNotifications->setToolTip(tr("Show desktop notifications")); m_layout->addWidget(m_sysNotifications); - connect(m_sysNotifications, &QCheckBox::clicked, this, + connect(m_sysNotifications, + &QCheckBox::clicked, + this, &GeneneralConf::showDesktopNotificationChanged); } -void GeneneralConf::initShowTrayIcon() { +void GeneneralConf::initShowTrayIcon() +{ #if defined(Q_OS_LINUX) || defined(Q_OS_UNIX) m_showTray = new QCheckBox(tr("Show tray icon"), this); ConfigHandler config; @@ -178,36 +201,46 @@ void GeneneralConf::initShowTrayIcon() { m_showTray->setToolTip(tr("Show the systemtray icon")); m_layout->addWidget(m_showTray); - connect(m_showTray, &QCheckBox::stateChanged, this, + connect(m_showTray, + &QCheckBox::stateChanged, + this, &GeneneralConf::showTrayIconChanged); #endif } -void GeneneralConf::initConfingButtons() { - QHBoxLayout *buttonLayout = new QHBoxLayout(); +void GeneneralConf::initConfingButtons() +{ + QHBoxLayout* buttonLayout = new QHBoxLayout(); m_layout->addStretch(); - QGroupBox *box = new QGroupBox(tr("Configuration File")); + QGroupBox* box = new QGroupBox(tr("Configuration File")); box->setFlat(true); box->setLayout(buttonLayout); m_layout->addWidget(box); m_exportButton = new QPushButton(tr("Export")); buttonLayout->addWidget(m_exportButton); - connect(m_exportButton, &QPushButton::clicked, this, + connect(m_exportButton, + &QPushButton::clicked, + this, &GeneneralConf::exportFileConfiguration); m_importButton = new QPushButton(tr("Import")); buttonLayout->addWidget(m_importButton); - connect(m_importButton, &QPushButton::clicked, this, + connect(m_importButton, + &QPushButton::clicked, + this, &GeneneralConf::importConfiguration); m_resetButton = new QPushButton(tr("Reset")); buttonLayout->addWidget(m_resetButton); - connect(m_resetButton, &QPushButton::clicked, this, + connect(m_resetButton, + &QPushButton::clicked, + this, &GeneneralConf::resetConfiguration); } -void GeneneralConf::initAutostart() { +void GeneneralConf::initAutostart() +{ m_autostart = new QCheckBox(tr("Launch at startup"), this); ConfigHandler config; bool checked = config.startupLaunchValue(); @@ -215,12 +248,14 @@ void GeneneralConf::initAutostart() { m_autostart->setToolTip(tr("Launch Flameshot")); m_layout->addWidget(m_autostart); - connect(m_autostart, &QCheckBox::clicked, this, - &GeneneralConf::autostartChanged); + connect( + m_autostart, &QCheckBox::clicked, this, &GeneneralConf::autostartChanged); } -void GeneneralConf::initShowStartupLaunchMessage() { - m_showStartupLaunchMessage = new QCheckBox(tr("Show welcome message on launch"), this); +void GeneneralConf::initShowStartupLaunchMessage() +{ + m_showStartupLaunchMessage = + new QCheckBox(tr("Show welcome message on launch"), this); ConfigHandler config; bool checked = config.showStartupLaunchMessage(); m_showStartupLaunchMessage->setChecked(checked); @@ -232,23 +267,31 @@ void GeneneralConf::initShowStartupLaunchMessage() { }); } -void GeneneralConf::initCloseAfterCapture() { - m_closeAfterCapture = new QCheckBox(tr("Close application after capture"), this); +void GeneneralConf::initCloseAfterCapture() +{ + m_closeAfterCapture = + new QCheckBox(tr("Close application after capture"), this); ConfigHandler config; bool checked = config.closeAfterScreenshotValue(); m_closeAfterCapture->setChecked(checked); m_closeAfterCapture->setToolTip(tr("Close after taking a screenshot")); m_layout->addWidget(m_closeAfterCapture); - connect(m_closeAfterCapture, &QCheckBox::clicked, this, + connect(m_closeAfterCapture, + &QCheckBox::clicked, + this, &GeneneralConf::closeAfterCaptureChanged); } -void GeneneralConf::initCopyAndCloseAfterUpload() { - m_copyAndCloseAfterUpload = new QCheckBox(tr("Copy URL after upload"), this); +void GeneneralConf::initCopyAndCloseAfterUpload() +{ + m_copyAndCloseAfterUpload = + new QCheckBox(tr("Copy URL after upload"), this); ConfigHandler config; - m_copyAndCloseAfterUpload->setChecked(config.copyAndCloseAfterUploadEnabled()); - m_copyAndCloseAfterUpload->setToolTip(tr("Copy URL and close window after upload")); + m_copyAndCloseAfterUpload->setChecked( + config.copyAndCloseAfterUploadEnabled()); + m_copyAndCloseAfterUpload->setToolTip( + tr("Copy URL and close window after upload")); m_layout->addWidget(m_copyAndCloseAfterUpload); connect(m_copyAndCloseAfterUpload, &QCheckBox::clicked, [](bool checked) { @@ -256,7 +299,8 @@ void GeneneralConf::initCopyAndCloseAfterUpload() { }); } -void GeneneralConf::initCopyPathAfterSave() { +void GeneneralConf::initCopyPathAfterSave() +{ m_copyPathAfterSave = new QCheckBox(tr("Copy file path after save"), this); ConfigHandler config; m_copyPathAfterSave->setChecked(config.copyPathAfterSaveEnabled()); @@ -266,3 +310,44 @@ void GeneneralConf::initCopyPathAfterSave() { ConfigHandler().setCopyPathAfterSaveEnabled(checked); }); } + +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(); + m_layout->addWidget(m_filePathConfiguration); +} diff --git a/src/config/geneneralconf.h b/src/config/geneneralconf.h index e387a750..e5d881f7 100644 --- a/src/config/geneneralconf.h +++ b/src/config/geneneralconf.h @@ -22,39 +22,42 @@ class QVBoxLayout; class QCheckBox; class QPushButton; +class FilePathConfiguration; -class GeneneralConf : public QWidget { +class GeneneralConf : public QWidget +{ Q_OBJECT public: - explicit GeneneralConf(QWidget *parent = nullptr); + explicit GeneneralConf(QWidget* parent = nullptr); public slots: void updateComponents(); private slots: - void showHelpChanged(bool checked); - void showDesktopNotificationChanged(bool checked); - void showTrayIconChanged(bool checked); - void autostartChanged(bool checked); - void showStartupLaunchMessageChanged(bool checked); - void closeAfterCaptureChanged(bool checked); - void importConfiguration(); - void exportFileConfiguration(); - void resetConfiguration(); + void showHelpChanged(bool checked); + void showDesktopNotificationChanged(bool checked); + void showTrayIconChanged(bool checked); + void autostartChanged(bool checked); + void showStartupLaunchMessageChanged(bool checked); + void closeAfterCaptureChanged(bool checked); + void importConfiguration(); + void exportFileConfiguration(); + void resetConfiguration(); private: - QVBoxLayout *m_layout; - QCheckBox *m_sysNotifications; - QCheckBox *m_showTray; - QCheckBox *m_helpMessage; - QCheckBox *m_autostart; - QCheckBox *m_showStartupLaunchMessage; - QCheckBox *m_closeAfterCapture; - QCheckBox *m_copyAndCloseAfterUpload; - QCheckBox *m_copyPathAfterSave; - QPushButton *m_importButton; - QPushButton *m_exportButton; - QPushButton *m_resetButton; + QVBoxLayout* m_layout; + QCheckBox* m_sysNotifications; + QCheckBox* m_showTray; + QCheckBox* m_helpMessage; + QCheckBox* m_autostart; + QCheckBox* m_showStartupLaunchMessage; + QCheckBox* m_closeAfterCapture; + QCheckBox* m_copyAndCloseAfterUpload; + QCheckBox* m_copyPathAfterSave; + QPushButton* m_importButton; + QPushButton* m_exportButton; + QPushButton* m_resetButton; + FilePathConfiguration* m_filePathConfiguration; void initShowHelp(); void initShowDesktopNotification(); @@ -65,4 +68,6 @@ private: void initCloseAfterCapture(); void initCopyAndCloseAfterUpload(); void initCopyPathAfterSave(); + void initUploadStorage(); + void initFilePathConfiguration(); }; diff --git a/src/tools/imgs3/imgs3uploader.cpp b/src/tools/imgs3/imgs3uploader.cpp deleted file mode 100644 index a6afaa14..00000000 --- a/src/tools/imgs3/imgs3uploader.cpp +++ /dev/null @@ -1,467 +0,0 @@ -// Copyright(c) 2017-2019 Alejandro Sirgo Rica & 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 "imgs3uploader.h" -#include "src/utils/filenamehandler.h" -#include "src/utils/systemnotification.h" -#include "src/widgets/loadspinner.h" -#include "src/widgets/imagelabel.h" -#include "src/widgets/notificationwidget.h" -#include "src/utils/confighandler.h" -#include "src/utils/history.h" -#include "src/utils/configenterprise.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -ImgS3Uploader::ImgS3Uploader(const QPixmap &capture, QWidget *parent) : - QWidget(parent), m_pixmap(capture) -{ - init(tr("Upload image to S3"), tr("Uploading Image")); -} - -ImgS3Uploader::ImgS3Uploader(QWidget *parent) : - QWidget(parent) -{ - init(tr("Delete image from S3"), tr("Deleting image...")); -} - -void ImgS3Uploader::init(const QString &title, const QString &label) { - m_imageLabel = nullptr; - m_spinner = nullptr; - - m_proxy = nullptr; - m_NetworkAMUpload = nullptr; - m_NetworkAMGetCreds = nullptr; - m_NetworkAMRemove = nullptr; - - m_success = false; - setWindowTitle(title); - setWindowIcon(QIcon(":img/app/flameshot.svg")); - - m_spinner = new LoadSpinner(this); - m_spinner->setColor(ConfigHandler().uiMainColorValue()); - m_spinner->start(); - - m_infoLabel = new QLabel(label); - m_infoLabel->setAlignment(Qt::AlignCenter); - - m_vLayout = new QVBoxLayout(); - setLayout(m_vLayout); - m_vLayout->addWidget(m_spinner, 0, Qt::AlignHCenter); - m_vLayout->addWidget(m_infoLabel); - - setAttribute(Qt::WA_DeleteOnClose); -} - -QNetworkProxy *ImgS3Uploader::proxy() { - if(m_proxy == nullptr) { - initProxy(); - } - return m_proxy; -} - -QNetworkProxy *ImgS3Uploader::initProxy() { - // get enterprise settings - ConfigEnterprise *configEnterprise = new ConfigEnterprise(); - - // get proxy settings from "config.ini" file - QSettings *settings = configEnterprise->settings(); - QString httpProxyHost = settings->value("HTTP_PROXY_HOST").toString(); - - if(httpProxyHost.length() > 0) { - m_proxy = new QNetworkProxy(); - - if(settings->contains("HTTP_PROXY_TYPE")) { - switch (settings->value("HTTP_PROXY_TYPE").toInt()) { - case 0: - m_proxy->setType(QNetworkProxy::DefaultProxy); - break; - case 1: - m_proxy->setType(QNetworkProxy::Socks5Proxy); - break; - case 2: - m_proxy->setType(QNetworkProxy::NoProxy); - break; - case 4: - m_proxy->setType(QNetworkProxy::HttpCachingProxy); - break; - case 5: - m_proxy->setType(QNetworkProxy::FtpCachingProxy); - break; - case 3: - default: - m_proxy->setType(QNetworkProxy::HttpProxy); - break; - } - } - - m_proxy->setHostName(httpProxyHost); - int nProxyPort = 3128; - if(settings->contains("HTTP_PROXY_PORT")) { - nProxyPort = settings->value("HTTP_PROXY_PORT").toInt(); - } - m_proxy->setPort(nProxyPort); - - if(settings->contains("HTTP_PROXY_USER")) { - qDebug() << "Proxy user" << settings->value("HTTP_PROXY_PASSWORD").toString(); - m_proxy->setUser(settings->value("HTTP_PROXY_USER").toString()); - } - if(settings->contains("HTTP_PROXY_PASSWORD")) { - qDebug() << "Proxy password is not empty"; - m_proxy->setPassword(settings->value("HTTP_PROXY_PASSWORD").toString()); - } - } - else { - // Get proxy settings from OS settings - QNetworkProxyQuery q(QUrl(m_s3Settings.credsUrl().toUtf8())); - q.setQueryType(QNetworkProxyQuery::UrlRequest); - q.setProtocolTag("http"); - - QList proxies = QNetworkProxyFactory::systemProxyForQuery(q); - if( proxies.size() > 0 && proxies[0].type() != QNetworkProxy::NoProxy ){ - m_proxy = new QNetworkProxy(); - m_proxy->setHostName(proxies[0].hostName()); - m_proxy->setPort(proxies[0].port()); - m_proxy->setType(proxies[0].type()); - m_proxy->setUser(proxies[0].user()); - m_proxy->setPassword(proxies[0].password()); - } - } -#ifdef QT_DEBUG - if(m_proxy != nullptr) { - qDebug() << "Using proxy server"; - qDebug() << "proxy host:" << m_proxy->hostName(); - qDebug() << "proxy port:" << m_proxy->port(); - qDebug() << "proxy type:" << m_proxy->type(); - qDebug() << "proxy user:" << (m_proxy->user().length() > 0 ? m_proxy->user() : "no user"); - qDebug() << "proxy password:" << (m_proxy->password().length() > 0 ? "***" : "no password"); - } - else { - qDebug() << "No proxy"; - } -#endif - return m_proxy; -} - -void ImgS3Uploader::clearProxy() { - if(m_proxy != nullptr) { - delete m_proxy; - m_proxy = nullptr; - } -} - - -void ImgS3Uploader::handleReplyUpload(QNetworkReply *reply) { - hideSpinner(); - m_s3ImageName.clear(); - if (reply->error() == QNetworkReply::NoError) { - // save history - QString imageName = m_imageURL.toString(); - int lastSlash = imageName.lastIndexOf("/"); - if (lastSlash >= 0) { - imageName = imageName.mid(lastSlash + 1); - } - m_s3ImageName = imageName; - History history; - imageName = history.packFileName(SCREENSHOT_STORAGE_TYPE_S3, m_deleteToken, imageName); - history.save(m_pixmap, imageName); - m_success = true; - - // Copy url to clipboard if required - if (ConfigHandler().copyAndCloseAfterUploadEnabled()) { - QApplication::clipboard()->setText(m_imageURL.toString()); - SystemNotification().sendMessage(tr("URL copied to clipboard.")); - close(); - } else { - onUploadOk(); - } - } else { - QString reason = reply->attribute( QNetworkRequest::HttpReasonPhraseAttribute ).toString(); - setInfoLabelText(reply->errorString()); - } - new QShortcut(Qt::Key_Escape, this, SLOT(close())); -} - -void ImgS3Uploader::removeImagePreview() { - // remove local file - History history; - QString packedFileName = history.packFileName(SCREENSHOT_STORAGE_TYPE_S3, m_deleteToken, m_s3ImageName); - QString fullFileName = history.path() + packedFileName; - - QFile file(fullFileName); - if (file.exists()) { - file.remove(); - } - m_deleteToken.clear(); - m_s3ImageName.clear(); - m_success = true; -} - -void ImgS3Uploader::handleReplyDeleteResource(QNetworkReply *reply) { - auto replyError = reply->error(); - if (replyError == QNetworkReply::NoError) { - removeImagePreview(); - } else { - hide(); - - // generate error message - QString message = tr("Unable to remove screenshot from the remote storage."); - if(replyError == QNetworkReply::UnknownNetworkError) { - message += "\n" + tr("Network error"); - } - else if(replyError == QNetworkReply::UnknownServerError) { - message += "\n" + tr("Possibly it doesn't exist anymore"); - } - message += "\n\n" + reply->errorString(); - message += "\n\n" + tr("Do you want to remove screenshot from local history anyway?"); - - if (QMessageBox::Yes == QMessageBox::question(NULL, - tr("Remove screenshot from history?"), - message, - QMessageBox::Yes|QMessageBox::No)) { - removeImagePreview(); - } - } - close(); -} - -void ImgS3Uploader::startDrag() { - QMimeData *mimeData = new QMimeData; - mimeData->setUrls(QList { m_imageURL }); - mimeData->setImageData(m_pixmap); - - QDrag *dragHandler = new QDrag(this); - dragHandler->setMimeData(mimeData); - dragHandler->setPixmap(m_pixmap.scaled(256, 256, Qt::KeepAspectRatioByExpanding, - Qt::SmoothTransformation)); - dragHandler->exec(); -} - -void ImgS3Uploader::handleReplyGetCreds(QNetworkReply *reply){ - if (reply->error() == QNetworkReply::NoError) { - QJsonDocument response = QJsonDocument::fromJson(reply->readAll()); - uploadToS3(response); - } else { - if(m_s3Settings.credsUrl().length() == 0){ - setInfoLabelText(tr("S3 Creds URL is not found in your configuration file")); - } - else { - setInfoLabelText(reply->errorString()); - } - } - new QShortcut(Qt::Key_Escape, this, SLOT(close())); -} - -void ImgS3Uploader::uploadToS3(QJsonDocument &response) { - // set paramets from "fields" - QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType); - - // read JSON response - QJsonObject json = response.object(); - QString resultURL = json["resultURL"].toString(); - QJsonObject formData = json["formData"].toObject(); - QString url = formData["url"].toString(); - m_deleteToken = json["deleteToken"].toString(); - - QJsonObject fields = formData["fields"].toObject(); - foreach (auto key, fields.keys()) { - QString field = fields[key].toString(); - QHttpPart part; - part.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"" + key + "\"")); - part.setBody(field.toLatin1()); - multiPart->append(part); - } - - QHttpPart imagePart; - imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/png")); - imagePart.setHeader(QNetworkRequest::ContentDispositionHeader, - QVariant("form-data; name=\"file\"")); - - QByteArray byteArray; - QBuffer buffer(&byteArray); - buffer.open(QIODevice::WriteOnly); - m_pixmap.save(&buffer, "PNG"); - - imagePart.setBody(byteArray); - multiPart->append(imagePart); - - m_imageURL.setUrl(resultURL); - - QUrl qUrl(url); - QNetworkRequest request(qUrl); - - // upload - m_NetworkAMUpload->post(request, multiPart); -} - -void ImgS3Uploader::deleteResource(const QString &fileName, const QString &deleteToken) { - // read network settings on each call to simplify configuration management without restarting - clearProxy(); - if(m_NetworkAMRemove != nullptr) { - delete m_NetworkAMRemove; - m_NetworkAMRemove = nullptr; - } - m_NetworkAMRemove = new QNetworkAccessManager(this); - connect(m_NetworkAMRemove, &QNetworkAccessManager::finished, this, &ImgS3Uploader::handleReplyDeleteResource); - if(proxy() != nullptr) { - m_NetworkAMRemove->setProxy(*proxy()); - } - - QNetworkRequest request; - m_s3ImageName = fileName; - m_deleteToken = deleteToken; - request.setUrl(m_s3Settings.credsUrl().toUtf8() + fileName); - request.setRawHeader("X-API-Key", m_s3Settings.xApiKey().toLatin1()); - request.setRawHeader("Authorization", "Bearer " + deleteToken.toLatin1()); - m_NetworkAMRemove->deleteResource(request); -} - -void ImgS3Uploader::upload() { - m_deleteToken.clear(); - m_s3ImageName.clear(); - - // read network settings on each call to simplify configuration management without restarting - // init creds and upload network access managers - clearProxy(); - if(m_NetworkAMGetCreds != nullptr) { - delete m_NetworkAMGetCreds; - m_NetworkAMGetCreds = nullptr; - } - m_NetworkAMGetCreds = new QNetworkAccessManager(this); - connect(m_NetworkAMGetCreds, &QNetworkAccessManager::finished, this, &ImgS3Uploader::handleReplyGetCreds); - - if(m_NetworkAMUpload != nullptr) { - delete m_NetworkAMUpload; - m_NetworkAMUpload = nullptr; - } - m_NetworkAMUpload = new QNetworkAccessManager(this); - connect(m_NetworkAMUpload, &QNetworkAccessManager::finished, this, &ImgS3Uploader::handleReplyUpload); - if(proxy() != nullptr) { - m_NetworkAMGetCreds->setProxy(*proxy()); - m_NetworkAMUpload->setProxy(*proxy()); - } - - // get creads - QUrl creds(m_s3Settings.credsUrl()); - QNetworkRequest requestCreds(creds); - if(m_s3Settings.xApiKey().length() > 0) { - requestCreds.setRawHeader(QByteArray("X-API-Key"), QByteArray(m_s3Settings.xApiKey().toLocal8Bit())); - } - m_NetworkAMGetCreds->get(requestCreds); -} - -void ImgS3Uploader::onUploadOk() { - hideSpinner(); - - m_notification = new NotificationWidget(); - m_vLayout->addWidget(m_notification); - - if(nullptr == m_imageLabel) { - m_imageLabel = new ImageLabel(); - m_imageLabel->setScreenshot(m_pixmap); - m_imageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - connect(m_imageLabel, &ImageLabel::dragInitiated, this, &ImgS3Uploader::startDrag); - m_vLayout->addWidget(m_imageLabel); - } - - m_hLayout = new QHBoxLayout(); - m_vLayout->addLayout(m_hLayout); - - m_copyUrlButton = new QPushButton(tr("Copy URL")); - m_openUrlButton = new QPushButton(tr("Open URL")); - m_deleteImageOnS3 = new QPushButton(tr("Delete image")); - m_toClipboardButton = new QPushButton(tr("Image to Clipboard.")); - m_hLayout->addWidget(m_copyUrlButton); - m_hLayout->addWidget(m_openUrlButton); - m_hLayout->addWidget(m_deleteImageOnS3); - m_hLayout->addWidget(m_toClipboardButton); - - connect(m_copyUrlButton, &QPushButton::clicked, - this, &ImgS3Uploader::copyURL); - connect(m_openUrlButton, &QPushButton::clicked, - this, &ImgS3Uploader::openURL); - connect(m_deleteImageOnS3, &QPushButton::clicked, - this, &ImgS3Uploader::deleteImageOnS3); - connect(m_toClipboardButton, &QPushButton::clicked, - this, &ImgS3Uploader::copyImage); -} - -void ImgS3Uploader::openURL() { - bool successful = QDesktopServices::openUrl(m_imageURL); - if (!successful) { - m_notification->showMessage(tr("Unable to open the URL.")); - } -} - -void ImgS3Uploader::copyURL() { - QApplication::clipboard()->setText(m_imageURL.toString()); - m_notification->showMessage(tr("URL copied to clipboard.")); -} - -void ImgS3Uploader::copyImage() { - QApplication::clipboard()->setPixmap(m_pixmap); - m_notification->showMessage(tr("Screenshot copied to clipboard.")); -} - -void ImgS3Uploader::deleteImageOnS3() { - if(nullptr != m_imageLabel) { - m_imageLabel->hide(); - } - m_spinner->show(); - setInfoLabelText(tr("Deleting image...")); - deleteResource(m_s3ImageName, m_deleteToken); -} - -bool ImgS3Uploader::success() { - return m_success; -} - -void ImgS3Uploader::hideSpinner() { - if(nullptr != m_spinner) { - m_spinner->hide(); - } - if(nullptr != m_imageLabel) { - m_imageLabel->hide(); - } -} - -void ImgS3Uploader::setInfoLabelText(const QString &infoText) { - m_infoLabel->setText(infoText); - m_infoLabel->show(); -} diff --git a/src/tools/imgs3/imgs3uploader.h b/src/tools/imgs3/imgs3uploader.h deleted file mode 100644 index 755fa01b..00000000 --- a/src/tools/imgs3/imgs3uploader.h +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright(c) 2017-2019 Alejandro Sirgo Rica & 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 . - -#pragma once - -#define S3_API_IMG_PATH "v2/image/" - -#include "imgs3settings.h" -#include -#include - -class QNetworkReply; -class QNetworkProxy; -class QNetworkAccessManager; -class QHBoxLayout; -class QVBoxLayout; -class QLabel; -class LoadSpinner; -class QPushButton; -class QUrl; -class NotificationWidget; -class ConfigEnterprise; -class ImageLabel; - -class ImgS3Uploader : public QWidget { - Q_OBJECT -public: - explicit ImgS3Uploader(const QPixmap &capture, QWidget *parent = nullptr); - explicit ImgS3Uploader(QWidget *parent = nullptr); - void upload(); - void deleteResource(const QString &, const QString &); - bool success(); - -private slots: - void handleReplyUpload(QNetworkReply *reply); - void handleReplyGetCreds(QNetworkReply *reply); - void handleReplyDeleteResource(QNetworkReply *reply); - void startDrag(); - - void openURL(); - void copyURL(); - void copyImage(); - void deleteImageOnS3(); - -private: - void init(const QString &title, const QString &label); - void uploadToS3(QJsonDocument &response); - QNetworkProxy *initProxy(); - void clearProxy(); - void removeImagePreview(); - - void onUploadOk(); - - void hideSpinner(); - void setInfoLabelText(const QString &); - QNetworkProxy *proxy(); - - -// class members -private: - bool m_success; - ImgS3Settings m_s3Settings; - - ImageLabel *m_imageLabel; - - QString m_hostName; - QPixmap m_pixmap; - QNetworkProxy *m_proxy; - QNetworkAccessManager *m_NetworkAMUpload; - QNetworkAccessManager *m_NetworkAMGetCreds; - QNetworkAccessManager *m_NetworkAMRemove; - - QVBoxLayout *m_vLayout; - QHBoxLayout *m_hLayout; - // loading - QLabel *m_infoLabel; - LoadSpinner *m_spinner; - // uploaded - QPushButton *m_openUrlButton; - QPushButton *m_copyUrlButton; - QPushButton *m_toClipboardButton; - QPushButton *m_deleteImageOnS3; - QUrl m_imageURL; - NotificationWidget *m_notification; - - // Temporary variables - QString m_deleteToken; - QString m_s3ImageName; -}; diff --git a/src/tools/imgur/imguruploader.cpp b/src/tools/imgur/imguruploader.cpp deleted file mode 100644 index cd0dfc63..00000000 --- a/src/tools/imgur/imguruploader.cpp +++ /dev/null @@ -1,182 +0,0 @@ -// Copyright(c) 2017-2019 Alejandro Sirgo Rica & 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 "imguruploader.h" -#include "src/utils/filenamehandler.h" -#include "src/utils/systemnotification.h" -#include "src/widgets/loadspinner.h" -#include "src/widgets/imagelabel.h" -#include "src/widgets/notificationwidget.h" -#include "src/utils/confighandler.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -ImgurUploader::ImgurUploader(const QPixmap &capture, QWidget *parent) : - QWidget(parent), m_pixmap(capture) -{ - setWindowTitle(tr("Upload to Imgur")); - setWindowIcon(QIcon(":img/app/flameshot.svg")); - - m_spinner = new LoadSpinner(this); - m_spinner->setColor(ConfigHandler().uiMainColorValue()); - m_spinner->start(); - - m_infoLabel = new QLabel(tr("Uploading Image")); - - m_vLayout = new QVBoxLayout(); - setLayout(m_vLayout); - m_vLayout->addWidget(m_spinner, 0, Qt::AlignHCenter); - m_vLayout->addWidget(m_infoLabel); - - m_NetworkAM = new QNetworkAccessManager(this); - connect(m_NetworkAM, &QNetworkAccessManager::finished, this, - &ImgurUploader::handleReply); - - setAttribute(Qt::WA_DeleteOnClose); - - upload(); - // QTimer::singleShot(2000, this, &ImgurUploader::onUploadOk); // testing -} - -void ImgurUploader::handleReply(QNetworkReply *reply) { - m_spinner->deleteLater(); - if (reply->error() == QNetworkReply::NoError) { - QJsonDocument response = QJsonDocument::fromJson(reply->readAll()); - QJsonObject json = response.object(); - QJsonObject data = json[QStringLiteral("data")].toObject(); - m_imageURL.setUrl(data[QStringLiteral("link")].toString()); - m_deleteImageURL.setUrl(QStringLiteral("https://imgur.com/delete/%1").arg( - data[QStringLiteral("deletehash")].toString())); - if (ConfigHandler().copyAndCloseAfterUploadEnabled()) { - QApplication::clipboard()->setText(m_imageURL.toString()); - SystemNotification().sendMessage(QObject::tr("URL copied to clipboard.")); - close(); - } else { - onUploadOk(); - } - } else { - m_infoLabel->setText(reply->errorString()); - } - new QShortcut(Qt::Key_Escape, this, SLOT(close())); -} - -void ImgurUploader::startDrag() { - QMimeData *mimeData = new QMimeData; - mimeData->setUrls(QList { m_imageURL }); - mimeData->setImageData(m_pixmap); - - QDrag *dragHandler = new QDrag(this); - dragHandler->setMimeData(mimeData); - dragHandler->setPixmap(m_pixmap.scaled(256, 256, Qt::KeepAspectRatioByExpanding, - Qt::SmoothTransformation)); - dragHandler->exec(); -} - -void ImgurUploader::upload() { - QByteArray byteArray; - QBuffer buffer(&byteArray); - m_pixmap.save(&buffer, "PNG"); - - QUrlQuery urlQuery; - urlQuery.addQueryItem(QStringLiteral("title"), QStringLiteral("flameshot_screenshot")); - QString description = FileNameHandler().parsedPattern(); - urlQuery.addQueryItem(QStringLiteral("description"), description); - - QUrl url(QStringLiteral("https://api.imgur.com/3/image")); - url.setQuery(urlQuery); - QNetworkRequest request(url); - request.setHeader(QNetworkRequest::ContentTypeHeader, - "application/application/x-www-form-urlencoded"); - request.setRawHeader("Authorization", QStringLiteral("Client-ID %1").arg(IMGUR_CLIENT_ID).toUtf8()); - - m_NetworkAM->post(request, byteArray); -} - -void ImgurUploader::onUploadOk() { - m_infoLabel->deleteLater(); - - m_notification = new NotificationWidget(); - m_vLayout->addWidget(m_notification); - - ImageLabel *imageLabel = new ImageLabel(); - imageLabel->setScreenshot(m_pixmap); - imageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - connect(imageLabel, &ImageLabel::dragInitiated, this, &ImgurUploader::startDrag); - m_vLayout->addWidget(imageLabel); - - m_hLayout = new QHBoxLayout(); - m_vLayout->addLayout(m_hLayout); - - m_copyUrlButton = new QPushButton(tr("Copy URL")); - m_openUrlButton = new QPushButton(tr("Open URL")); - m_openDeleteUrlButton = new QPushButton(tr("Delete image")); - m_toClipboardButton = new QPushButton(tr("Image to Clipboard.")); - m_hLayout->addWidget(m_copyUrlButton); - m_hLayout->addWidget(m_openUrlButton); - m_hLayout->addWidget(m_openDeleteUrlButton); - m_hLayout->addWidget(m_toClipboardButton); - - connect(m_copyUrlButton, &QPushButton::clicked, - this, &ImgurUploader::copyURL); - connect(m_openUrlButton, &QPushButton::clicked, - this, &ImgurUploader::openURL); - connect(m_openDeleteUrlButton, &QPushButton::clicked, - this, &ImgurUploader::openDeleteURL); - connect(m_toClipboardButton, &QPushButton::clicked, - this, &ImgurUploader::copyImage); -} - -void ImgurUploader::openURL() { - bool successful = QDesktopServices::openUrl(m_imageURL); - if (!successful) { - m_notification->showMessage(tr("Unable to open the URL.")); - } -} - -void ImgurUploader::copyURL() { - QApplication::clipboard()->setText(m_imageURL.toString()); - m_notification->showMessage(tr("URL copied to clipboard.")); -} - -void ImgurUploader::openDeleteURL() -{ - bool successful = QDesktopServices::openUrl(m_deleteImageURL); - if (!successful) { - m_notification->showMessage(tr("Unable to open the URL.")); - } -} - -void ImgurUploader::copyImage() { - QApplication::clipboard()->setPixmap(m_pixmap); - m_notification->showMessage(tr("Screenshot copied to clipboard.")); -} diff --git a/src/tools/storage/imgstorages.h b/src/tools/storage/imgstorages.h new file mode 100644 index 00000000..ad7822f7 --- /dev/null +++ b/src/tools/storage/imgstorages.h @@ -0,0 +1,8 @@ +#ifndef IMGSTORAGES_H +#define IMGSTORAGES_H + +#define SCREENSHOT_STORAGE_TYPE_LOCAL "" +#define SCREENSHOT_STORAGE_TYPE_S3 "s3" +#define SCREENSHOT_STORAGE_TYPE_IMGUR "imgur" + +#endif // IMGSTORAGES_H diff --git a/src/tools/storage/imguploader.cpp b/src/tools/storage/imguploader.cpp new file mode 100644 index 00000000..1e2b160a --- /dev/null +++ b/src/tools/storage/imguploader.cpp @@ -0,0 +1,209 @@ +// Copyright(c) 2017-2019 Alejandro Sirgo Rica & 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 "imguploader.h" +#include "src/utils/configenterprise.h" +#include "src/utils/confighandler.h" +#include "src/utils/filenamehandler.h" +#include "src/utils/history.h" +#include "src/utils/systemnotification.h" +#include "src/widgets/imagelabel.h" +#include "src/widgets/loadspinner.h" +#include "src/widgets/notificationwidget.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +ImgUploader::ImgUploader(const QPixmap& capture, QWidget* parent) + : QWidget(parent) + , m_pixmap(capture) +{ + init(tr("Upload image to S3"), tr("Uploading Image")); +} + +ImgUploader::ImgUploader(QWidget* parent) + : QWidget(parent) +{ + init(tr("Upload image"), tr("Uploading Image")); +} + +void ImgUploader::init(const QString& title, const QString& label) +{ + m_imageLabel = nullptr; + m_spinner = nullptr; + + resultStatus = false; + setWindowTitle(title); + setWindowIcon(QIcon(":img/app/flameshot.svg")); + + m_spinner = new LoadSpinner(this); + m_spinner->setColor(ConfigHandler().uiMainColorValue()); + m_spinner->start(); + + m_infoLabel = new QLabel(label); + m_infoLabel->setAlignment(Qt::AlignCenter); + + m_vLayout = new QVBoxLayout(); + setLayout(m_vLayout); + m_vLayout->addWidget(m_spinner, 0, Qt::AlignHCenter); + m_vLayout->addWidget(m_infoLabel); + + setAttribute(Qt::WA_DeleteOnClose); +} + +void ImgUploader::openURL() +{ + bool successful = QDesktopServices::openUrl(imageUrl()); + if (!successful) { + m_notification->showMessage(tr("Unable to open the URL.")); + } +} + +void ImgUploader::copyURL() +{ + QApplication::clipboard()->setText(imageUrl().toString()); + m_notification->showMessage(tr("URL copied to clipboard.")); +} + +void ImgUploader::copyImage() +{ + QApplication::clipboard()->setPixmap(m_pixmap); + m_notification->showMessage(tr("Screenshot copied to clipboard.")); +} + +void ImgUploader::deleteImageOnStorage() +{ + if (nullptr != m_imageLabel) { + m_imageLabel->hide(); + } + m_spinner->show(); + setInfoLabelText(tr("Deleting image...")); + deleteResource(m_storageImageName, m_deleteToken); +} + +void ImgUploader::startDrag() +{ + QMimeData* mimeData = new QMimeData; + mimeData->setUrls(QList{ imageUrl() }); + mimeData->setImageData(m_pixmap); + + QDrag* dragHandler = new QDrag(this); + dragHandler->setMimeData(mimeData); + dragHandler->setPixmap(m_pixmap.scaled( + 256, 256, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation)); + dragHandler->exec(); +} + +void ImgUploader::hideSpinner() +{ + if (nullptr != m_spinner) { + m_spinner->hide(); + } + if (nullptr != m_imageLabel) { + m_imageLabel->hide(); + } +} + +void ImgUploader::setInfoLabelText(const QString& infoText) +{ + m_infoLabel->setText(infoText); + m_infoLabel->show(); +} + +const QPixmap& ImgUploader::pixmap() +{ + return m_pixmap; +} + +void ImgUploader::onUploadOk() +{ + hideSpinner(); + + m_notification = new NotificationWidget(); + m_vLayout->addWidget(m_notification); + + if (nullptr == m_imageLabel) { + m_imageLabel = new ImageLabel(); + m_imageLabel->setScreenshot(pixmap()); + m_imageLabel->setSizePolicy(QSizePolicy::Expanding, + QSizePolicy::Expanding); + connect(m_imageLabel, + &ImageLabel::dragInitiated, + this, + &ImgUploader::startDrag); + m_vLayout->addWidget(m_imageLabel); + } + + m_hLayout = new QHBoxLayout(); + m_vLayout->addLayout(m_hLayout); + + m_copyUrlButton = new QPushButton(tr("Copy URL")); + m_openUrlButton = new QPushButton(tr("Open URL")); + m_deleteImageOnStorage = new QPushButton(tr("Delete image")); + m_toClipboardButton = new QPushButton(tr("Image to Clipboard.")); + m_hLayout->addWidget(m_copyUrlButton); + m_hLayout->addWidget(m_openUrlButton); + m_hLayout->addWidget(m_deleteImageOnStorage); + m_hLayout->addWidget(m_toClipboardButton); + + connect( + m_copyUrlButton, &QPushButton::clicked, this, &ImgUploader::copyURL); + connect( + m_openUrlButton, &QPushButton::clicked, this, &ImgUploader::openURL); + connect(m_deleteImageOnStorage, + &QPushButton::clicked, + this, + &ImgUploader::deleteImageOnStorage); + connect(m_toClipboardButton, + &QPushButton::clicked, + this, + &ImgUploader::copyImage); +} + +void ImgUploader::setImageUrl(const QUrl& imageURL) +{ + m_imageURL = imageURL; +} +const QUrl& ImgUploader::imageUrl() +{ + return m_imageURL; +} + +void ImgUploader::showNotificationMessage(const QString& notificationMessage) { + m_notification->showMessage(notificationMessage); +} + diff --git a/src/tools/storage/imguploader.h b/src/tools/storage/imguploader.h new file mode 100644 index 00000000..5369f183 --- /dev/null +++ b/src/tools/storage/imguploader.h @@ -0,0 +1,96 @@ +// Copyright(c) 2017-2019 Alejandro Sirgo Rica & 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 . + +#pragma once + +#include "imgstorages.h" +#include "s3/imgs3settings.h" +#include +#include + +class QNetworkReply; +class QNetworkProxy; +class QNetworkAccessManager; +class QHBoxLayout; +class QVBoxLayout; +class QLabel; +class LoadSpinner; +class QPushButton; +class QUrl; +class NotificationWidget; +class ConfigEnterprise; +class ImageLabel; + +class ImgUploader : public QWidget +{ + Q_OBJECT +public: + explicit ImgUploader(const QPixmap& capture, QWidget* parent = nullptr); + explicit ImgUploader(QWidget* parent = nullptr); + + virtual void upload(){}; + virtual void deleteResource(const QString&, const QString&){}; + +protected: + const QPixmap& pixmap(); + void setImageUrl(const QUrl&); + const QUrl& imageUrl(); + void onUploadOk(); + void hideSpinner(); + void setInfoLabelText(const QString&); + void showNotificationMessage(const QString&); + +public slots: + virtual void openURL(); + virtual void copyURL(); + virtual void copyImage(); + virtual void deleteImageOnStorage(); + virtual void startDrag(); + +private: + void init(const QString& title, const QString& label); + + // class members +private: + QPixmap m_pixmap; + + QUrl m_imageURL; + ImageLabel* m_imageLabel; + + NotificationWidget* m_notification; + + QVBoxLayout* m_vLayout; + QHBoxLayout* m_hLayout; + // loading + LoadSpinner* m_spinner; + QLabel* m_infoLabel; + // uploaded + QPushButton* m_openUrlButton; + QPushButton* m_copyUrlButton; + QPushButton* m_toClipboardButton; + QPushButton* m_deleteImageOnStorage; + +protected: + // bool m_success; + + // Temporary variables + QString m_deleteToken; + QString m_storageImageName; + +public: + bool resultStatus; +}; diff --git a/src/tools/storage/imgur/imguruploader.cpp b/src/tools/storage/imgur/imguruploader.cpp new file mode 100644 index 00000000..02bff6d8 --- /dev/null +++ b/src/tools/storage/imgur/imguruploader.cpp @@ -0,0 +1,129 @@ +// Copyright(c) 2017-2019 Alejandro Sirgo Rica & 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 "imguruploader.h" +#include "src/utils/confighandler.h" +#include "src/utils/filenamehandler.h" +#include "src/utils/history.h" +#include "src/utils/systemnotification.h" +#include "src/widgets/imagelabel.h" +#include "src/widgets/loadspinner.h" +#include "src/widgets/notificationwidget.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +ImgurUploader::ImgurUploader(const QPixmap& capture, QWidget* parent) + : ImgUploader(capture, parent) +{ + setWindowTitle(tr("Upload to Imgur")); + + m_NetworkAM = new QNetworkAccessManager(this); + connect(m_NetworkAM, + &QNetworkAccessManager::finished, + this, + &ImgurUploader::handleReply); + // QTimer::singleShot(2000, this, &ImgurUploader::onUploadOk); // testing +} + +void ImgurUploader::handleReply(QNetworkReply* reply) +{ + if (reply->error() == QNetworkReply::NoError) { + QJsonDocument response = QJsonDocument::fromJson(reply->readAll()); + QJsonObject json = response.object(); + QJsonObject data = json[QStringLiteral("data")].toObject(); + setImageUrl(data[QStringLiteral("link")].toString()); + m_deleteToken = data[QStringLiteral("deletehash")].toString(); + + m_deleteImageURL.setUrl( + QStringLiteral("https://imgur.com/delete/%1").arg(m_deleteToken)); + + // save history + QString imageName = imageUrl().toString(); + int lastSlash = imageName.lastIndexOf("/"); + if (lastSlash >= 0) { + imageName = imageName.mid(lastSlash + 1); + } + m_storageImageName = imageName; + + // save image to history + History history; + imageName = history.packFileName( + SCREENSHOT_STORAGE_TYPE_IMGUR, m_deleteToken, imageName); + history.save(pixmap(), imageName); + resultStatus = true; + + if (ConfigHandler().copyAndCloseAfterUploadEnabled()) { + QApplication::clipboard()->setText(imageUrl().toString()); + SystemNotification().sendMessage( + QObject::tr("URL copied to clipboard.")); + close(); + } else { + onUploadOk(); + } + } else { + setInfoLabelText(reply->errorString()); + } + new QShortcut(Qt::Key_Escape, this, SLOT(close())); +} + +void ImgurUploader::upload() +{ + QByteArray byteArray; + QBuffer buffer(&byteArray); + pixmap().save(&buffer, "PNG"); + + QUrlQuery urlQuery; + urlQuery.addQueryItem(QStringLiteral("title"), + QStringLiteral("flameshot_screenshot")); + QString description = FileNameHandler().parsedPattern(); + urlQuery.addQueryItem(QStringLiteral("description"), description); + + QUrl url(QStringLiteral("https://api.imgur.com/3/image")); + url.setQuery(urlQuery); + QNetworkRequest request(url); + request.setHeader(QNetworkRequest::ContentTypeHeader, + "application/application/x-www-form-urlencoded"); + request.setRawHeader( + "Authorization", + QStringLiteral("Client-ID %1").arg(IMGUR_CLIENT_ID).toUtf8()); + + m_NetworkAM->post(request, byteArray); +} + +void ImgurUploader::deleteImageOnStorage() +{ + bool successful = QDesktopServices::openUrl(m_deleteImageURL); + if (!successful) { + showNotificationMessage(tr("Unable to open the URL.")); + } +} diff --git a/src/tools/imgur/imguruploader.h b/src/tools/storage/imgur/imguruploader.h similarity index 61% rename from src/tools/imgur/imguruploader.h rename to src/tools/storage/imgur/imguruploader.h index 94458655..89145011 100644 --- a/src/tools/imgur/imguruploader.h +++ b/src/tools/storage/imgur/imguruploader.h @@ -17,8 +17,9 @@ #pragma once -#include +#include "../imguploader.h" #include +#include class QNetworkReply; class QNetworkAccessManager; @@ -30,38 +31,21 @@ class QPushButton; class QUrl; class NotificationWidget; -class ImgurUploader : public QWidget { +class ImgurUploader : public ImgUploader +{ Q_OBJECT public: - explicit ImgurUploader(const QPixmap &capture, QWidget *parent = nullptr); + explicit ImgurUploader(const QPixmap& capture, QWidget* parent = nullptr); + void upload(); private slots: - void handleReply(QNetworkReply *reply); - void startDrag(); + void handleReply(QNetworkReply* reply); - void openURL(); - void copyURL(); - void openDeleteURL(); - void copyImage(); +protected slots: + void deleteImageOnStorage(); + // class members private: - QPixmap m_pixmap; - QNetworkAccessManager *m_NetworkAM; - - QVBoxLayout *m_vLayout; - QHBoxLayout *m_hLayout; - // loading - QLabel *m_infoLabel; - LoadSpinner *m_spinner; - // uploaded - QPushButton *m_openUrlButton; - QPushButton *m_openDeleteUrlButton; - QPushButton *m_copyUrlButton; - QPushButton *m_toClipboardButton; - QUrl m_imageURL; + QNetworkAccessManager* m_NetworkAM; QUrl m_deleteImageURL; - NotificationWidget *m_notification; - - void upload(); - void onUploadOk(); }; diff --git a/src/tools/imgur/imguruploadertool.cpp b/src/tools/storage/imgur/imguruploadertool.cpp similarity index 65% rename from src/tools/imgur/imguruploadertool.cpp rename to src/tools/storage/imgur/imguruploadertool.cpp index ea68303c..44dabf4a 100644 --- a/src/tools/imgur/imguruploadertool.cpp +++ b/src/tools/storage/imgur/imguruploadertool.cpp @@ -19,39 +19,55 @@ #include "imguruploader.h" #include -ImgurUploaderTool::ImgurUploaderTool(QObject *parent) : AbstractActionTool(parent) { +ImgurUploaderTool::ImgurUploaderTool(QObject* parent) + : AbstractActionTool(parent) +{} -} - -bool ImgurUploaderTool::closeOnButtonPressed() const { +bool ImgurUploaderTool::closeOnButtonPressed() const +{ return true; } -QIcon ImgurUploaderTool::icon(const QColor &background, bool inEditor) const { +QIcon ImgurUploaderTool::icon(const QColor& background, bool inEditor) const +{ Q_UNUSED(inEditor); return QIcon(iconPath(background) + "cloud-upload.svg"); } -QString ImgurUploaderTool::name() const { + +QString ImgurUploaderTool::name() const +{ return tr("Image Uploader"); } -QString ImgurUploaderTool::nameID() { +QString ImgurUploaderTool::nameID() +{ return QLatin1String(""); } -QString ImgurUploaderTool::description() const { +QString ImgurUploaderTool::description() const +{ return tr("Upload the selection to Imgur"); } -QWidget* ImgurUploaderTool::widget() { - return new ImgurUploader(capture); +QWidget* ImgurUploaderTool::widget() +{ + ImgurUploader* p = new ImgurUploader(capture); + p->upload(); + return p; } -CaptureTool* ImgurUploaderTool::copy(QObject *parent) { +void ImgurUploaderTool::setCapture(const QPixmap& pixmap) +{ + capture = pixmap; +} + +CaptureTool* ImgurUploaderTool::copy(QObject* parent) +{ return new ImgurUploaderTool(parent); } -void ImgurUploaderTool::pressed(const CaptureContext &context) { +void ImgurUploaderTool::pressed(const CaptureContext& context) +{ capture = context.selectedScreenshotArea(); emit requestAction(REQ_CAPTURE_DONE_OK); emit requestAction(REQ_ADD_EXTERNAL_WIDGETS); diff --git a/src/tools/imgur/imguruploadertool.h b/src/tools/storage/imgur/imguruploadertool.h similarity index 76% rename from src/tools/imgur/imguruploadertool.h rename to src/tools/storage/imgur/imguruploadertool.h index e0e49617..8ce93082 100644 --- a/src/tools/imgur/imguruploadertool.h +++ b/src/tools/storage/imgur/imguruploadertool.h @@ -19,24 +19,26 @@ #include "src/tools/abstractactiontool.h" -class ImgurUploaderTool : public AbstractActionTool { +class ImgurUploaderTool : public AbstractActionTool +{ Q_OBJECT public: - explicit ImgurUploaderTool(QObject *parent = nullptr); + explicit ImgurUploaderTool(QObject* parent = nullptr); bool closeOnButtonPressed() const; - QIcon icon(const QColor &background, bool inEditor) const override; + QIcon icon(const QColor& background, bool inEditor) const override; QString name() const override; static QString nameID(); QString description() const override; QWidget* widget() override; - CaptureTool* copy(QObject *parent = nullptr) override; + CaptureTool* copy(QObject* parent = nullptr) override; + void setCapture(const QPixmap&); public slots: - void pressed(const CaptureContext &context) override; + void pressed(const CaptureContext& context) override; private: QPixmap capture; diff --git a/src/tools/imgs3/imgs3settings.cpp b/src/tools/storage/s3/imgs3settings.cpp similarity index 52% rename from src/tools/imgs3/imgs3settings.cpp rename to src/tools/storage/s3/imgs3settings.cpp index 41695aee..fcf23ec0 100644 --- a/src/tools/imgs3/imgs3settings.cpp +++ b/src/tools/storage/s3/imgs3settings.cpp @@ -7,28 +7,38 @@ ImgS3Settings::ImgS3Settings() m_configEnterprise = new ConfigEnterprise(); // get s3 credentials - QSettings *settings = m_configEnterprise->settings(); + QSettings* settings = m_configEnterprise->settings(); settings->beginGroup("S3"); m_credsUrl = settings->value("S3_CREDS_URL").toString(); - m_credsUrl = m_credsUrl + ((m_credsUrl.length() > 0 && m_credsUrl[m_credsUrl.length() - 1] == '/') ? "" : "/") + S3_API_IMG_PATH; + m_credsUrl = + m_credsUrl + + ((m_credsUrl.length() > 0 && m_credsUrl[m_credsUrl.length() - 1] == '/') + ? "" + : "/") + + S3_API_IMG_PATH; m_xApiKey = settings->value("S3_X_API_KEY").toString(); m_url = settings->value("S3_URL").toString(); - m_url = m_url + ((m_url.length() > 0 && m_url[m_url.length() - 1] == '/') ? "" : "/"); + m_url = + m_url + + ((m_url.length() > 0 && m_url[m_url.length() - 1] == '/') ? "" : "/"); settings->endGroup(); } -const QString &ImgS3Settings::credsUrl() { +const QString& ImgS3Settings::credsUrl() +{ return m_credsUrl; } -const QString &ImgS3Settings::xApiKey() { +const QString& ImgS3Settings::xApiKey() +{ return m_xApiKey; } -const QString &ImgS3Settings::url() { +const QString& ImgS3Settings::url() +{ return m_url; } diff --git a/src/tools/imgs3/imgs3settings.h b/src/tools/storage/s3/imgs3settings.h similarity index 68% rename from src/tools/imgs3/imgs3settings.h rename to src/tools/storage/s3/imgs3settings.h index d44b79e2..c4b8689b 100644 --- a/src/tools/imgs3/imgs3settings.h +++ b/src/tools/storage/s3/imgs3settings.h @@ -3,7 +3,6 @@ #define S3_API_IMG_PATH "v2/image/" - #include class ConfigEnterprise; @@ -13,12 +12,12 @@ class ImgS3Settings public: ImgS3Settings(); - const QString &credsUrl(); - const QString &xApiKey(); - const QString &url(); + const QString& credsUrl(); + const QString& xApiKey(); + const QString& url(); private: - ConfigEnterprise *m_configEnterprise; + ConfigEnterprise* m_configEnterprise; QString m_credsUrl; QString m_xApiKey; QString m_url; diff --git a/src/tools/storage/s3/imgs3uploader.cpp b/src/tools/storage/s3/imgs3uploader.cpp new file mode 100644 index 00000000..09b53795 --- /dev/null +++ b/src/tools/storage/s3/imgs3uploader.cpp @@ -0,0 +1,396 @@ +// Copyright(c) 2017-2019 Alejandro Sirgo Rica & 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 "imgs3uploader.h" +#include "src/utils/configenterprise.h" +#include "src/utils/confighandler.h" +#include "src/utils/filenamehandler.h" +#include "src/utils/history.h" +#include "src/utils/systemnotification.h" +#include "src/widgets/imagelabel.h" +#include "src/widgets/loadspinner.h" +#include "src/widgets/notificationwidget.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +ImgS3Uploader::ImgS3Uploader(const QPixmap& capture, QWidget* parent) + : ImgUploader(capture, parent) +{ + init(tr("Upload image to S3"), tr("Uploading Image")); +} + +ImgS3Uploader::ImgS3Uploader(QWidget* parent) + : ImgUploader(parent) +{ + init(tr("Delete image from S3"), tr("Deleting image...")); +} + +void ImgS3Uploader::init(const QString& title, const QString& label) +{ + m_proxy = nullptr; + m_NetworkAMUpload = nullptr; + m_NetworkAMGetCreds = nullptr; + m_NetworkAMRemove = nullptr; + + resultStatus = false; + setWindowTitle(title); + setWindowIcon(QIcon(":img/app/flameshot.svg")); +} + +QNetworkProxy* ImgS3Uploader::proxy() +{ + if (m_proxy == nullptr) { + initProxy(); + } + return m_proxy; +} + +QNetworkProxy* ImgS3Uploader::initProxy() +{ + // get enterprise settings + ConfigEnterprise* configEnterprise = new ConfigEnterprise(); + + // get proxy settings from "config.ini" file + QSettings* settings = configEnterprise->settings(); + QString httpProxyHost = settings->value("HTTP_PROXY_HOST").toString(); + + if (httpProxyHost.length() > 0) { + m_proxy = new QNetworkProxy(); + + if (settings->contains("HTTP_PROXY_TYPE")) { + switch (settings->value("HTTP_PROXY_TYPE").toInt()) { + case 0: + m_proxy->setType(QNetworkProxy::DefaultProxy); + break; + case 1: + m_proxy->setType(QNetworkProxy::Socks5Proxy); + break; + case 2: + m_proxy->setType(QNetworkProxy::NoProxy); + break; + case 4: + m_proxy->setType(QNetworkProxy::HttpCachingProxy); + break; + case 5: + m_proxy->setType(QNetworkProxy::FtpCachingProxy); + break; + case 3: + default: + m_proxy->setType(QNetworkProxy::HttpProxy); + break; + } + } + + m_proxy->setHostName(httpProxyHost); + int nProxyPort = 3128; + if (settings->contains("HTTP_PROXY_PORT")) { + nProxyPort = settings->value("HTTP_PROXY_PORT").toInt(); + } + m_proxy->setPort(nProxyPort); + + if (settings->contains("HTTP_PROXY_USER")) { + qDebug() << "Proxy user" + << settings->value("HTTP_PROXY_PASSWORD").toString(); + m_proxy->setUser(settings->value("HTTP_PROXY_USER").toString()); + } + if (settings->contains("HTTP_PROXY_PASSWORD")) { + qDebug() << "Proxy password is not empty"; + m_proxy->setPassword( + settings->value("HTTP_PROXY_PASSWORD").toString()); + } + } else { + // Get proxy settings from OS settings + QNetworkProxyQuery q(QUrl(m_s3Settings.credsUrl().toUtf8())); + q.setQueryType(QNetworkProxyQuery::UrlRequest); + q.setProtocolTag("http"); + + QList proxies = + QNetworkProxyFactory::systemProxyForQuery(q); + if (proxies.size() > 0 && proxies[0].type() != QNetworkProxy::NoProxy) { + m_proxy = new QNetworkProxy(); + m_proxy->setHostName(proxies[0].hostName()); + m_proxy->setPort(proxies[0].port()); + m_proxy->setType(proxies[0].type()); + m_proxy->setUser(proxies[0].user()); + m_proxy->setPassword(proxies[0].password()); + } + } +#ifdef QT_DEBUG + if (m_proxy != nullptr) { + qDebug() << "Using proxy server"; + qDebug() << "proxy host:" << m_proxy->hostName(); + qDebug() << "proxy port:" << m_proxy->port(); + qDebug() << "proxy type:" << m_proxy->type(); + qDebug() << "proxy user:" + << (m_proxy->user().length() > 0 ? m_proxy->user() + : "no user"); + qDebug() << "proxy password:" + << (m_proxy->password().length() > 0 ? "***" : "no password"); + } else { + qDebug() << "No proxy"; + } +#endif + return m_proxy; +} + +void ImgS3Uploader::clearProxy() +{ + if (m_proxy != nullptr) { + delete m_proxy; + m_proxy = nullptr; + } +} + +void ImgS3Uploader::handleReplyUpload(QNetworkReply* reply) +{ + hideSpinner(); + m_storageImageName.clear(); + if (reply->error() == QNetworkReply::NoError) { + // save history + QString imageName = imageUrl().toString(); + int lastSlash = imageName.lastIndexOf("/"); + if (lastSlash >= 0) { + imageName = imageName.mid(lastSlash + 1); + } + m_storageImageName = imageName; + + // save image to history + History history; + imageName = history.packFileName( + SCREENSHOT_STORAGE_TYPE_S3, m_deleteToken, imageName); + history.save(pixmap(), imageName); + resultStatus = true; + + // Copy url to clipboard if required + if (ConfigHandler().copyAndCloseAfterUploadEnabled()) { + QApplication::clipboard()->setText(imageUrl().toString()); + SystemNotification().sendMessage(tr("URL copied to clipboard.")); + close(); + } else { + onUploadOk(); + } + } else { + QString reason = + reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute) + .toString(); + setInfoLabelText(reply->errorString()); + } + new QShortcut(Qt::Key_Escape, this, SLOT(close())); +} + +void ImgS3Uploader::handleReplyDeleteResource(QNetworkReply* reply) +{ + auto replyError = reply->error(); + if (replyError == QNetworkReply::NoError) { + removeImagePreview(); + } else { + hide(); + + // generate error message + QString message = + tr("Unable to remove screenshot from the remote storage."); + if (replyError == QNetworkReply::UnknownNetworkError) { + message += "\n" + tr("Network error"); + } else if (replyError == QNetworkReply::UnknownServerError) { + message += "\n" + tr("Possibly it doesn't exist anymore"); + } + message += "\n\n" + reply->errorString(); + message += + "\n\n" + + tr("Do you want to remove screenshot from local history anyway?"); + + if (QMessageBox::Yes == + QMessageBox::question(NULL, + tr("Remove screenshot from history?"), + message, + QMessageBox::Yes | QMessageBox::No)) { + removeImagePreview(); + } + } + close(); +} + +void ImgS3Uploader::handleReplyGetCreds(QNetworkReply* reply) +{ + if (reply->error() == QNetworkReply::NoError) { + QJsonDocument response = QJsonDocument::fromJson(reply->readAll()); + uploadToS3(response); + } else { + if (m_s3Settings.credsUrl().length() == 0) { + setInfoLabelText( + tr("S3 Creds URL is not found in your configuration file")); + } else { + setInfoLabelText(reply->errorString()); + } + } + new QShortcut(Qt::Key_Escape, this, SLOT(close())); +} + +void ImgS3Uploader::uploadToS3(QJsonDocument& response) +{ + // set paramets from "fields" + QHttpMultiPart* multiPart = + new QHttpMultiPart(QHttpMultiPart::FormDataType); + + // read JSON response + QJsonObject json = response.object(); + QString resultUrl = json["resultURL"].toString(); + QJsonObject formData = json["formData"].toObject(); + QString url = formData["url"].toString(); + m_deleteToken = json["deleteToken"].toString(); + + QJsonObject fields = formData["fields"].toObject(); + foreach (auto key, fields.keys()) { + QString field = fields[key].toString(); + QHttpPart part; + part.setHeader(QNetworkRequest::ContentDispositionHeader, + QVariant("form-data; name=\"" + key + "\"")); + part.setBody(field.toLatin1()); + multiPart->append(part); + } + + QHttpPart imagePart; + imagePart.setHeader(QNetworkRequest::ContentTypeHeader, + QVariant("image/png")); + imagePart.setHeader(QNetworkRequest::ContentDispositionHeader, + QVariant("form-data; name=\"file\"")); + + QByteArray byteArray; + QBuffer buffer(&byteArray); + buffer.open(QIODevice::WriteOnly); + pixmap().save(&buffer, "PNG"); + + imagePart.setBody(byteArray); + multiPart->append(imagePart); + + setImageUrl(QUrl(resultUrl)); + + QUrl qUrl(url); + QNetworkRequest request(qUrl); + + // upload + m_NetworkAMUpload->post(request, multiPart); +} + +void ImgS3Uploader::deleteResource(const QString& fileName, + const QString& deleteToken) +{ + // read network settings on each call to simplify configuration management + // without restarting + clearProxy(); + if (m_NetworkAMRemove != nullptr) { + delete m_NetworkAMRemove; + m_NetworkAMRemove = nullptr; + } + m_NetworkAMRemove = new QNetworkAccessManager(this); + connect(m_NetworkAMRemove, + &QNetworkAccessManager::finished, + this, + &ImgS3Uploader::handleReplyDeleteResource); + if (proxy() != nullptr) { + m_NetworkAMRemove->setProxy(*proxy()); + } + + QNetworkRequest request; + m_storageImageName = fileName; + m_deleteToken = deleteToken; + request.setUrl(m_s3Settings.credsUrl().toUtf8() + fileName); + request.setRawHeader("X-API-Key", m_s3Settings.xApiKey().toLatin1()); + request.setRawHeader("Authorization", "Bearer " + deleteToken.toLatin1()); + m_NetworkAMRemove->deleteResource(request); +} + +void ImgS3Uploader::upload() +{ + m_deleteToken.clear(); + m_storageImageName.clear(); + + // read network settings on each call to simplify configuration management + // without restarting init creds and upload network access managers + clearProxy(); + if (m_NetworkAMGetCreds != nullptr) { + delete m_NetworkAMGetCreds; + m_NetworkAMGetCreds = nullptr; + } + m_NetworkAMGetCreds = new QNetworkAccessManager(this); + connect(m_NetworkAMGetCreds, + &QNetworkAccessManager::finished, + this, + &ImgS3Uploader::handleReplyGetCreds); + + if (m_NetworkAMUpload != nullptr) { + delete m_NetworkAMUpload; + m_NetworkAMUpload = nullptr; + } + m_NetworkAMUpload = new QNetworkAccessManager(this); + connect(m_NetworkAMUpload, + &QNetworkAccessManager::finished, + this, + &ImgS3Uploader::handleReplyUpload); + if (proxy() != nullptr) { + m_NetworkAMGetCreds->setProxy(*proxy()); + m_NetworkAMUpload->setProxy(*proxy()); + } + + // get creads + QUrl creds(m_s3Settings.credsUrl()); + QNetworkRequest requestCreds(creds); + if (m_s3Settings.xApiKey().length() > 0) { + requestCreds.setRawHeader( + QByteArray("X-API-Key"), + QByteArray(m_s3Settings.xApiKey().toLocal8Bit())); + } + m_NetworkAMGetCreds->get(requestCreds); +} + +void ImgS3Uploader::removeImagePreview() +{ + // remove local file + History history; + QString packedFileName = history.packFileName( + SCREENSHOT_STORAGE_TYPE_S3, m_deleteToken, m_storageImageName); + QString fullFileName = history.path() + packedFileName; + + QFile file(fullFileName); + if (file.exists()) { + file.remove(); + } + m_deleteToken.clear(); + m_storageImageName.clear(); + resultStatus = true; +} diff --git a/src/tools/storage/s3/imgs3uploader.h b/src/tools/storage/s3/imgs3uploader.h new file mode 100644 index 00000000..3168bf29 --- /dev/null +++ b/src/tools/storage/s3/imgs3uploader.h @@ -0,0 +1,70 @@ +// Copyright(c) 2017-2019 Alejandro Sirgo Rica & 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 . + +#pragma once + +#define S3_API_IMG_PATH "v2/image/" + +#include "../imguploader.h" +#include "imgs3settings.h" +#include +#include + +class QNetworkReply; +class QNetworkProxy; +class QNetworkAccessManager; +class QHBoxLayout; +class QVBoxLayout; +class QLabel; +class QPushButton; +class QUrl; +class NotificationWidget; +class ConfigEnterprise; +class ImageLabel; + +class ImgS3Uploader : public ImgUploader +{ + Q_OBJECT +public: + explicit ImgS3Uploader(const QPixmap& capture, QWidget* parent = nullptr); + explicit ImgS3Uploader(QWidget* parent = nullptr); + void upload(); + void deleteResource(const QString&, const QString&); + +private slots: + void handleReplyUpload(QNetworkReply* reply); + void handleReplyGetCreds(QNetworkReply* reply); + void handleReplyDeleteResource(QNetworkReply* reply); + +private: + void init(const QString& title, const QString& label); + void uploadToS3(QJsonDocument& response); + void removeImagePreview(); + + QNetworkProxy* initProxy(); + void clearProxy(); + QNetworkProxy* proxy(); + + // class members +private: + ImgS3Settings m_s3Settings; + + QNetworkProxy* m_proxy; + QNetworkAccessManager* m_NetworkAMUpload; + QNetworkAccessManager* m_NetworkAMGetCreds; + QNetworkAccessManager* m_NetworkAMRemove; +}; diff --git a/src/tools/imgs3/imgs3uploadertool.cpp b/src/tools/storage/s3/imgs3uploadertool.cpp similarity index 66% rename from src/tools/imgs3/imgs3uploadertool.cpp rename to src/tools/storage/s3/imgs3uploadertool.cpp index 45f04aaf..e1694470 100644 --- a/src/tools/imgs3/imgs3uploadertool.cpp +++ b/src/tools/storage/s3/imgs3uploadertool.cpp @@ -18,49 +18,56 @@ #include "imgs3uploadertool.h" #include "imgs3uploader.h" #include -#include -#include +ImgS3UploaderTool::ImgS3UploaderTool(QObject* parent) + : AbstractActionTool(parent) +{} -ImgS3UploaderTool::ImgS3UploaderTool(QObject *parent) : AbstractActionTool(parent) { -} - -bool ImgS3UploaderTool::closeOnButtonPressed() const { +bool ImgS3UploaderTool::closeOnButtonPressed() const +{ return true; } -QIcon ImgS3UploaderTool::icon(const QColor &background, bool inEditor) const { +QIcon ImgS3UploaderTool::icon(const QColor& background, bool inEditor) const +{ Q_UNUSED(inEditor); return QIcon(iconPath(background) + "cloud-upload.svg"); } -QString ImgS3UploaderTool::name() const { +QString ImgS3UploaderTool::name() const +{ return tr("Image Uploader"); } -QString ImgS3UploaderTool::nameID() { +QString ImgS3UploaderTool::nameID() +{ return QLatin1String(""); } -QString ImgS3UploaderTool::description() const { +QString ImgS3UploaderTool::description() const +{ return tr("Upload the selection to S3 bucket"); } -QWidget *ImgS3UploaderTool::widget() { - ImgS3Uploader *p = new ImgS3Uploader(capture); +QWidget* ImgS3UploaderTool::widget() +{ + ImgS3Uploader* p = new ImgS3Uploader(capture); p->upload(); return p; } -void ImgS3UploaderTool::setCapture(const QPixmap &pixmap) { +void ImgS3UploaderTool::setCapture(const QPixmap& pixmap) +{ capture = pixmap; } -CaptureTool *ImgS3UploaderTool::copy(QObject *parent) { +CaptureTool* ImgS3UploaderTool::copy(QObject* parent) +{ return new ImgS3UploaderTool(parent); } -void ImgS3UploaderTool::pressed(const CaptureContext &context) { +void ImgS3UploaderTool::pressed(const CaptureContext& context) +{ capture = context.selectedScreenshotArea(); emit requestAction(REQ_CAPTURE_DONE_OK); emit requestAction(REQ_ADD_EXTERNAL_WIDGETS); diff --git a/src/tools/imgs3/imgs3uploadertool.h b/src/tools/storage/s3/imgs3uploadertool.h similarity index 76% rename from src/tools/imgs3/imgs3uploadertool.h rename to src/tools/storage/s3/imgs3uploadertool.h index 8b1846ce..4d5bdbc9 100644 --- a/src/tools/imgs3/imgs3uploadertool.h +++ b/src/tools/storage/s3/imgs3uploadertool.h @@ -19,25 +19,26 @@ #include "src/tools/abstractactiontool.h" -class ImgS3UploaderTool : public AbstractActionTool { +class ImgS3UploaderTool : public AbstractActionTool +{ Q_OBJECT public: - explicit ImgS3UploaderTool(QObject *parent = nullptr); + explicit ImgS3UploaderTool(QObject* parent = nullptr); bool closeOnButtonPressed() const; - QIcon icon(const QColor &background, bool inEditor) const override; + QIcon icon(const QColor& background, bool inEditor) const override; QString name() const override; static QString nameID(); QString description() const override; QWidget* widget() override; - CaptureTool* copy(QObject *parent = nullptr) override; - void setCapture(const QPixmap &pixmap); + CaptureTool* copy(QObject* parent = nullptr) override; + void setCapture(const QPixmap& pixmap); public slots: - void pressed(const CaptureContext &context) override; + void pressed(const CaptureContext& context) override; private: QPixmap capture; diff --git a/src/tools/storage/storagemanager.cpp b/src/tools/storage/storagemanager.cpp new file mode 100644 index 00000000..d8231650 --- /dev/null +++ b/src/tools/storage/storagemanager.cpp @@ -0,0 +1,33 @@ +#include "storagemanager.h" +#include "imguploader.h" +#include "imgur/imguruploader.h" +#include "imgur/imguruploadertool.h" +#include "s3/imgs3uploader.h" +#include "s3/imgs3uploadertool.h" +#include "src/tools/storage/s3/imgs3settings.h" +#include "src/tools/capturetool.h" + +#include + +StorageManager::StorageManager() {} + +CaptureTool* StorageManager::imgUploaderTool(const QString& imgUploaderType, + QObject* parent) +{ + if (imgUploaderType == SCREENSHOT_STORAGE_TYPE_S3) { + return new ImgS3UploaderTool(parent); + } else if (imgUploaderType == SCREENSHOT_STORAGE_TYPE_IMGUR) { + return new ImgurUploaderTool(parent); + } + return nullptr; +} + +const QString& StorageManager::storageUrl(const QString& imgUploaderType) { + if (imgUploaderType == SCREENSHOT_STORAGE_TYPE_S3) { + ImgS3Settings s3Settings; + m_qstr = s3Settings.url(); + } else if (imgUploaderType == SCREENSHOT_STORAGE_TYPE_IMGUR) { + m_qstr = "https://i.imgur.com/"; + } + return m_qstr; +} diff --git a/src/tools/storage/storagemanager.h b/src/tools/storage/storagemanager.h new file mode 100644 index 00000000..4d1c4a7d --- /dev/null +++ b/src/tools/storage/storagemanager.h @@ -0,0 +1,25 @@ +#ifndef STORAGEMANAGER_H +#define STORAGEMANAGER_H + +#include +#include + +class QObject; +class ImgUploader; +class CaptureTool; + +class StorageManager +{ +public: + explicit StorageManager(); + + CaptureTool* imgUploaderTool(const QString& imgUploaderType, + QObject* parent = nullptr); + const QString& storageUrl(const QString& imgUploaderType); + +// class members +private: + QString m_qstr; +}; + +#endif // STORAGEMANAGER_H diff --git a/src/tools/toolfactory.cpp b/src/tools/toolfactory.cpp index f76d7ca8..682e81b1 100644 --- a/src/tools/toolfactory.cpp +++ b/src/tools/toolfactory.cpp @@ -17,97 +17,98 @@ #include "toolfactory.h" #include "arrow/arrowtool.h" +#include "blur/blurtool.h" #include "circle/circletool.h" #include "copy/copytool.h" #include "exit/exittool.h" -#include "imgur/imguruploadertool.h" -#include "imgs3/imgs3uploadertool.h" +#include "launcher/applaunchertool.h" #include "line/linetool.h" #include "marker/markertool.h" #include "move/movetool.h" #include "pencil/penciltool.h" +#include "pin/pintool.h" #include "rectangle/rectangletool.h" +#include "redo/redotool.h" #include "save/savetool.h" #include "selection/selectiontool.h" #include "sizeindicator/sizeindicatortool.h" -#include "undo/undotool.h" -#include "launcher/applaunchertool.h" -#include "blur/blurtool.h" -#include "redo/redotool.h" -#include "pin/pintool.h" +#include "src/utils/confighandler.h" +#include "storage/storagemanager.h" #include "text/texttool.h" +#include "undo/undotool.h" -ToolFactory::ToolFactory(QObject *parent) : QObject(parent) { +ToolFactory::ToolFactory(QObject* parent) + : QObject(parent) +{} -} - -CaptureTool* ToolFactory::CreateTool( - CaptureButton::ButtonType t, - QObject *parent) +CaptureTool* ToolFactory::CreateTool(CaptureButton::ButtonType t, + QObject* parent) { - CaptureTool *tool; + StorageManager storageManager; + + CaptureTool* tool; switch (t) { - case CaptureButton::TYPE_ARROW: - tool = new ArrowTool(parent); - break; - case CaptureButton::TYPE_CIRCLE: - tool = new CircleTool(parent); - break; - case CaptureButton::TYPE_COPY: - tool = new CopyTool(parent); - break; - case CaptureButton::TYPE_EXIT: - tool = new ExitTool(parent); - break; - case CaptureButton::TYPE_IMAGEUPLOADER: -// tool = new ImgurUploaderTool(parent); - tool = new ImgS3UploaderTool(parent); - break; - case CaptureButton::TYPE_DRAWER: - tool = new LineTool(parent); - break; - case CaptureButton::TYPE_MARKER: - tool = new MarkerTool(parent); - break; - case CaptureButton::TYPE_MOVESELECTION: - tool = new MoveTool(parent); - break; - case CaptureButton::TYPE_PENCIL: - tool = new PencilTool(parent); - break; - case CaptureButton::TYPE_RECTANGLE: - tool = new RectangleTool(parent); - break; - case CaptureButton::TYPE_SAVE: - tool = new SaveTool(parent); - break; - case CaptureButton::TYPE_SELECTION: - tool = new SelectionTool(parent); - break; - case CaptureButton::TYPE_SELECTIONINDICATOR: - tool = new SizeIndicatorTool(parent); - break; - case CaptureButton::TYPE_UNDO: - tool = new UndoTool(parent); - break; - case CaptureButton::TYPE_REDO: - tool = new RedoTool(parent); - break; - case CaptureButton::TYPE_OPEN_APP: - tool = new AppLauncher(parent); - break; - case CaptureButton::TYPE_BLUR: - tool = new BlurTool(parent); - break; - case CaptureButton::TYPE_PIN: - tool = new PinTool(parent); - break; - case CaptureButton::TYPE_TEXT: - tool = new TextTool(parent); - break; - default: - tool = nullptr; - break; + case CaptureButton::TYPE_ARROW: + tool = new ArrowTool(parent); + break; + case CaptureButton::TYPE_CIRCLE: + tool = new CircleTool(parent); + break; + case CaptureButton::TYPE_COPY: + tool = new CopyTool(parent); + break; + case CaptureButton::TYPE_EXIT: + tool = new ExitTool(parent); + break; + case CaptureButton::TYPE_IMAGEUPLOADER: + tool = storageManager.imgUploaderTool( + ConfigHandler().uploadStorage(), parent); + break; + case CaptureButton::TYPE_DRAWER: + tool = new LineTool(parent); + break; + case CaptureButton::TYPE_MARKER: + tool = new MarkerTool(parent); + break; + case CaptureButton::TYPE_MOVESELECTION: + tool = new MoveTool(parent); + break; + case CaptureButton::TYPE_PENCIL: + tool = new PencilTool(parent); + break; + case CaptureButton::TYPE_RECTANGLE: + tool = new RectangleTool(parent); + break; + case CaptureButton::TYPE_SAVE: + tool = new SaveTool(parent); + break; + case CaptureButton::TYPE_SELECTION: + tool = new SelectionTool(parent); + break; + case CaptureButton::TYPE_SELECTIONINDICATOR: + tool = new SizeIndicatorTool(parent); + break; + case CaptureButton::TYPE_UNDO: + tool = new UndoTool(parent); + break; + case CaptureButton::TYPE_REDO: + tool = new RedoTool(parent); + break; + case CaptureButton::TYPE_OPEN_APP: + tool = new AppLauncher(parent); + break; + case CaptureButton::TYPE_BLUR: + tool = new BlurTool(parent); + break; + case CaptureButton::TYPE_PIN: + tool = new PinTool(parent); + break; + case CaptureButton::TYPE_TEXT: + tool = new TextTool(parent); + break; + default: + tool = nullptr; + break; } return tool; } diff --git a/src/utils/confighandler.cpp b/src/utils/confighandler.cpp index 849289a1..c9836247 100644 --- a/src/utils/confighandler.cpp +++ b/src/utils/confighandler.cpp @@ -17,92 +17,82 @@ #include "confighandler.h" #include "src/tools/capturetool.h" +#include "src/tools/storage/imgstorages.h" #include "src/utils/configshortcuts.h" -#include -#include -#include #include +#include +#include #include +#include -ConfigHandler::ConfigHandler(){ +ConfigHandler::ConfigHandler() +{ m_settings.setDefaultFormat(QSettings::IniFormat); } -QVector ConfigHandler::getButtons() { +QVector ConfigHandler::getButtons() +{ QVector buttons; if (m_settings.contains(QStringLiteral("buttons"))) { // TODO: remove toList in v1.0 - QVector buttonsInt = - m_settings.value(QStringLiteral("buttons")).value >().toVector(); + QVector buttonsInt = m_settings.value(QStringLiteral("buttons")) + .value>() + .toVector(); bool modified = normalizeButtons(buttonsInt); if (modified) { - m_settings.setValue(QStringLiteral("buttons"), QVariant::fromValue(buttonsInt.toList())); + m_settings.setValue(QStringLiteral("buttons"), + QVariant::fromValue(buttonsInt.toList())); } buttons = fromIntToButton(buttonsInt); } else { // Default tools - buttons << CaptureButton::TYPE_PENCIL - << CaptureButton::TYPE_DRAWER - << CaptureButton::TYPE_ARROW - << CaptureButton::TYPE_SELECTION - << CaptureButton::TYPE_RECTANGLE - << CaptureButton::TYPE_CIRCLE - << CaptureButton::TYPE_MARKER - << CaptureButton::TYPE_BLUR + buttons << CaptureButton::TYPE_PENCIL << CaptureButton::TYPE_DRAWER + << CaptureButton::TYPE_ARROW << CaptureButton::TYPE_SELECTION + << CaptureButton::TYPE_RECTANGLE << CaptureButton::TYPE_CIRCLE + << CaptureButton::TYPE_MARKER << CaptureButton::TYPE_BLUR << CaptureButton::TYPE_SELECTIONINDICATOR - << CaptureButton::TYPE_MOVESELECTION - << CaptureButton::TYPE_UNDO - << CaptureButton::TYPE_REDO - << CaptureButton::TYPE_COPY - << CaptureButton::TYPE_SAVE - << CaptureButton::TYPE_EXIT + << CaptureButton::TYPE_MOVESELECTION << CaptureButton::TYPE_UNDO + << CaptureButton::TYPE_REDO << CaptureButton::TYPE_COPY + << CaptureButton::TYPE_SAVE << CaptureButton::TYPE_EXIT << CaptureButton::TYPE_IMAGEUPLOADER #if defined(Q_OS_LINUX) || defined(Q_OS_UNIX) << CaptureButton::TYPE_OPEN_APP #endif - << CaptureButton::TYPE_PIN - << CaptureButton::TYPE_TEXT; + << CaptureButton::TYPE_PIN << CaptureButton::TYPE_TEXT; } using bt = CaptureButton::ButtonType; - std::sort(buttons.begin(), buttons.end(), [](bt a, bt b){ + std::sort(buttons.begin(), buttons.end(), [](bt a, bt b) { return CaptureButton::getPriorityByButton(a) < - CaptureButton::getPriorityByButton(b); + CaptureButton::getPriorityByButton(b); }); return buttons; } -void ConfigHandler::setButtons(const QVector &buttons) { +void ConfigHandler::setButtons( + const QVector& buttons) +{ QVector l = fromButtonToInt(buttons); normalizeButtons(l); // TODO: remove toList in v1.0 - m_settings.setValue(QStringLiteral("buttons"), QVariant::fromValue(l.toList())); + m_settings.setValue(QStringLiteral("buttons"), + QVariant::fromValue(l.toList())); } -QVector ConfigHandler::getUserColors() { +QVector ConfigHandler::getUserColors() +{ QVector colors; - const QVector &defaultColors = { - Qt::white, - Qt::red, - Qt::green, - Qt::blue, - Qt::black, - Qt::darkRed, - Qt::darkGreen, - Qt::darkBlue, - Qt::darkGray, - Qt::cyan, - Qt::magenta, - Qt::yellow, - Qt::lightGray, - Qt::darkCyan, - Qt::darkMagenta, - Qt::darkYellow, + const QVector& defaultColors = { + Qt::white, Qt::red, Qt::green, Qt::blue, + Qt::black, Qt::darkRed, Qt::darkGreen, Qt::darkBlue, + Qt::darkGray, Qt::cyan, Qt::magenta, Qt::yellow, + Qt::lightGray, Qt::darkCyan, Qt::darkMagenta, Qt::darkYellow, QColor() }; if (m_settings.contains(QStringLiteral("userColors"))) { - for (const QString &hex : m_settings.value(QStringLiteral("userColors")).toStringList()) { + for (const QString& hex : + m_settings.value(QStringLiteral("userColors")).toStringList()) { if (QColor::isValidColor(hex)) { colors.append(QColor(hex)); } @@ -118,40 +108,49 @@ QVector ConfigHandler::getUserColors() { return colors; } -void ConfigHandler::setUserColors(const QVector &l) { +void ConfigHandler::setUserColors(const QVector& l) +{ QStringList hexColors; - for (const QColor &color : l) { + for (const QColor& color : l) { hexColors.append(color.name()); } - m_settings.setValue(QStringLiteral("userColors"), QVariant::fromValue(hexColors)); + m_settings.setValue(QStringLiteral("userColors"), + QVariant::fromValue(hexColors)); } -QString ConfigHandler::savePathValue() { - QString savePath = m_settings.value(QStringLiteral("savePathFixed")).toString(); - if( savePath.isEmpty() ) { +QString ConfigHandler::savePathValue() +{ + 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) { - QString savePathFixed = m_settings.value(QStringLiteral("savePathFixed")).toString(); - if( savePathFixed.isEmpty() ) { +void ConfigHandler::setSavePath(const QString& savePath) +{ + QString savePathFixed = + m_settings.value(QStringLiteral("savePathFixed")).toString(); + if (savePathFixed.isEmpty()) { m_settings.setValue(QStringLiteral("savePath"), savePath); } } -QString ConfigHandler::savePathFixed() { +QString ConfigHandler::savePathFixed() +{ return m_settings.value(QStringLiteral("savePathFixed")).toString(); } -void ConfigHandler::setSavePathFixed(const QString &savePathFixed) { +void ConfigHandler::setSavePathFixed(const QString& savePathFixed) +{ m_settings.setValue(QStringLiteral("savePathFixed"), savePathFixed); } -QColor ConfigHandler::uiMainColorValue() { +QColor ConfigHandler::uiMainColorValue() +{ QColor res = QColor(116, 0, 150); if (m_settings.contains(QStringLiteral("uiColor"))) { @@ -164,15 +163,18 @@ QColor ConfigHandler::uiMainColorValue() { return res; } -void ConfigHandler::setUIMainColor(const QColor &c) { +void ConfigHandler::setUIMainColor(const QColor& c) +{ m_settings.setValue(QStringLiteral("uiColor"), c.name()); } -QColor ConfigHandler::uiContrastColorValue() { +QColor ConfigHandler::uiContrastColorValue() +{ QColor res = QColor(39, 0, 50); if (m_settings.contains(QStringLiteral("contastUiColor"))) { - QString hex = m_settings.value(QStringLiteral("contastUiColor")).toString(); + QString hex = + m_settings.value(QStringLiteral("contastUiColor")).toString(); if (QColor::isValidColor(hex)) { res = QColor(hex); @@ -182,11 +184,13 @@ QColor ConfigHandler::uiContrastColorValue() { return res; } -void ConfigHandler::setUIContrastColor(const QColor &c) { +void ConfigHandler::setUIContrastColor(const QColor& c) +{ m_settings.setValue(QStringLiteral("contastUiColor"), c.name()); } -QColor ConfigHandler::drawColorValue() { +QColor ConfigHandler::drawColorValue() +{ QColor res(Qt::red); if (m_settings.contains(QStringLiteral("drawColor"))) { @@ -200,11 +204,13 @@ QColor ConfigHandler::drawColorValue() { return res; } -void ConfigHandler::setDrawColor(const QColor &c) { +void ConfigHandler::setDrawColor(const QColor& c) +{ m_settings.setValue(QStringLiteral("drawColor"), c.name()); } -bool ConfigHandler::showHelpValue() { +bool ConfigHandler::showHelpValue() +{ bool res = true; if (m_settings.contains(QStringLiteral("showHelp"))) { res = m_settings.value(QStringLiteral("showHelp")).toBool(); @@ -212,31 +218,39 @@ bool ConfigHandler::showHelpValue() { return res; } -void ConfigHandler::setShowHelp(const bool showHelp) { +void ConfigHandler::setShowHelp(const bool showHelp) +{ m_settings.setValue(QStringLiteral("showHelp"), showHelp); } -bool ConfigHandler::desktopNotificationValue() { +bool ConfigHandler::desktopNotificationValue() +{ bool res = true; if (m_settings.contains(QStringLiteral("showDesktopNotification"))) { - res = m_settings.value(QStringLiteral("showDesktopNotification")).toBool(); + res = + m_settings.value(QStringLiteral("showDesktopNotification")).toBool(); } return res; } -void ConfigHandler::setDesktopNotification(const bool showDesktopNotification) { - m_settings.setValue(QStringLiteral("showDesktopNotification"), showDesktopNotification); +void ConfigHandler::setDesktopNotification(const bool showDesktopNotification) +{ + m_settings.setValue(QStringLiteral("showDesktopNotification"), + showDesktopNotification); } -QString ConfigHandler::filenamePatternValue() { +QString ConfigHandler::filenamePatternValue() +{ return m_settings.value(QStringLiteral("filenamePattern")).toString(); } -void ConfigHandler::setFilenamePattern(const QString &pattern) { +void ConfigHandler::setFilenamePattern(const QString& pattern) +{ return m_settings.setValue(QStringLiteral("filenamePattern"), pattern); } -bool ConfigHandler::disabledTrayIconValue() { +bool ConfigHandler::disabledTrayIconValue() +{ bool res = false; if (m_settings.contains(QStringLiteral("disabledTrayIcon"))) { res = m_settings.value(QStringLiteral("disabledTrayIcon")).toBool(); @@ -244,11 +258,13 @@ bool ConfigHandler::disabledTrayIconValue() { return res; } -void ConfigHandler::setDisabledTrayIcon(const bool disabledTrayIcon) { +void ConfigHandler::setDisabledTrayIcon(const bool disabledTrayIcon) +{ m_settings.setValue(QStringLiteral("disabledTrayIcon"), disabledTrayIcon); } -int ConfigHandler::drawThicknessValue() { +int ConfigHandler::drawThicknessValue() +{ int res = 0; if (m_settings.contains(QStringLiteral("drawThickness"))) { res = m_settings.value(QStringLiteral("drawThickness")).toInt(); @@ -256,19 +272,23 @@ int ConfigHandler::drawThicknessValue() { return res; } -void ConfigHandler::setdrawThickness(const int thickness) { +void ConfigHandler::setdrawThickness(const int thickness) +{ m_settings.setValue(QStringLiteral("drawThickness"), thickness); } -bool ConfigHandler::keepOpenAppLauncherValue() { +bool ConfigHandler::keepOpenAppLauncherValue() +{ return m_settings.value(QStringLiteral("keepOpenAppLauncher")).toBool(); } -void ConfigHandler::setKeepOpenAppLauncher(const bool keepOpen) { +void ConfigHandler::setKeepOpenAppLauncher(const bool keepOpen) +{ m_settings.setValue(QStringLiteral("keepOpenAppLauncher"), keepOpen); } -bool ConfigHandler::startupLaunchValue() { +bool ConfigHandler::startupLaunchValue() +{ bool res = false; if (m_settings.contains(QStringLiteral("startupLaunch"))) { @@ -282,7 +302,8 @@ bool ConfigHandler::startupLaunchValue() { return res; } -bool ConfigHandler::verifyLaunchFile() { +bool ConfigHandler::verifyLaunchFile() +{ bool res = false; #if defined(Q_OS_LINUX) || defined(Q_OS_UNIX) @@ -290,15 +311,16 @@ bool ConfigHandler::verifyLaunchFile() { res = QFile(path).exists(); #elif defined(Q_OS_WIN) QSettings bootUpSettings( - "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", - QSettings::NativeFormat); + "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", + QSettings::NativeFormat); res = bootUpSettings.value("Flameshot").toString() == - QDir::toNativeSeparators(QCoreApplication::applicationFilePath()); + QDir::toNativeSeparators(QCoreApplication::applicationFilePath()); #endif return res; } -void ConfigHandler::setStartupLaunch(const bool start) { +void ConfigHandler::setStartupLaunch(const bool start) +{ #if defined(Q_OS_LINUX) || defined(Q_OS_UNIX) QString path = QDir::homePath() + "/.config/autostart/"; QDir autostartDir(path); @@ -319,15 +341,16 @@ void ConfigHandler::setStartupLaunch(const bool start) { } #elif defined(Q_OS_WIN) QSettings bootUpSettings( - "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", - QSettings::NativeFormat); + "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", + QSettings::NativeFormat); // set workdir for flameshot on startup QSettings bootUpPath( - "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths", - QSettings::NativeFormat); + "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App " + "Paths", + QSettings::NativeFormat); if (start) { QString app_path = - QDir::toNativeSeparators(QCoreApplication::applicationFilePath()); + QDir::toNativeSeparators(QCoreApplication::applicationFilePath()); bootUpSettings.setValue("Flameshot", app_path); // set application workdir @@ -347,18 +370,24 @@ void ConfigHandler::setStartupLaunch(const bool start) { m_settings.setValue(QStringLiteral("startupLaunch"), start); } -bool ConfigHandler::showStartupLaunchMessage() { +bool ConfigHandler::showStartupLaunchMessage() +{ if (!m_settings.contains(QStringLiteral("showStartupLaunchMessage"))) { m_settings.setValue(QStringLiteral("showStartupLaunchMessage"), true); } - return m_settings.value(QStringLiteral("showStartupLaunchMessage")).toBool(); + return m_settings.value(QStringLiteral("showStartupLaunchMessage")) + .toBool(); } -void ConfigHandler::setShowStartupLaunchMessage(const bool showStartupLaunchMessage){ - m_settings.setValue(QStringLiteral("showStartupLaunchMessage"), showStartupLaunchMessage); +void ConfigHandler::setShowStartupLaunchMessage( + const bool showStartupLaunchMessage) +{ + m_settings.setValue(QStringLiteral("showStartupLaunchMessage"), + showStartupLaunchMessage); } -int ConfigHandler::contrastOpacityValue() { +int ConfigHandler::contrastOpacityValue() +{ int opacity = 190; if (m_settings.contains(QStringLiteral("contrastOpacity"))) { opacity = m_settings.value(QStringLiteral("contrastOpacity")).toInt(); @@ -367,31 +396,38 @@ int ConfigHandler::contrastOpacityValue() { return opacity; } -void ConfigHandler::setContrastOpacity(const int transparency) { +void ConfigHandler::setContrastOpacity(const int transparency) +{ m_settings.setValue(QStringLiteral("contrastOpacity"), transparency); } -bool ConfigHandler::closeAfterScreenshotValue() { +bool ConfigHandler::closeAfterScreenshotValue() +{ return m_settings.value(QStringLiteral("closeAfterScreenshot")).toBool(); } -void ConfigHandler::setCloseAfterScreenshot(const bool close) { +void ConfigHandler::setCloseAfterScreenshot(const bool close) +{ m_settings.setValue(QStringLiteral("closeAfterScreenshot"), close); } -bool ConfigHandler::copyAndCloseAfterUploadEnabled() { +bool ConfigHandler::copyAndCloseAfterUploadEnabled() +{ bool res = true; if (m_settings.contains(QStringLiteral("copyAndCloseAfterUpload"))) { - res = m_settings.value(QStringLiteral("copyAndCloseAfterUpload")).toBool(); + res = + m_settings.value(QStringLiteral("copyAndCloseAfterUpload")).toBool(); } return res; } -void ConfigHandler::setCopyAndCloseAfterUploadEnabled(const bool value) { +void ConfigHandler::setCopyAndCloseAfterUploadEnabled(const bool value) +{ m_settings.setValue(QStringLiteral("copyAndCloseAfterUpload"), value); } -bool ConfigHandler::copyPathAfterSaveEnabled() { +bool ConfigHandler::copyPathAfterSaveEnabled() +{ bool res = false; if (m_settings.contains(QStringLiteral("copyPathAfterSave"))) { res = m_settings.value(QStringLiteral("copyPathAfterSave")).toBool(); @@ -399,32 +435,53 @@ bool ConfigHandler::copyPathAfterSaveEnabled() { return res; } -void ConfigHandler::setCopyPathAfterSaveEnabled(const bool value) { +void ConfigHandler::setCopyPathAfterSaveEnabled(const bool value) +{ m_settings.setValue(QStringLiteral("copyPathAfterSave"), value); } -void ConfigHandler::setDefaults() { +void ConfigHandler::setUploadStorage(const QString& uploadStorage) +{ + m_settings.setValue(QStringLiteral("uploadStorage"), uploadStorage); +} + +const QString& ConfigHandler::uploadStorage() +{ + m_strRes = m_settings.value(QStringLiteral("uploadStorage")).toString(); + if (m_strRes.isEmpty()) { + m_strRes = SCREENSHOT_STORAGE_TYPE_IMGUR; + setUploadStorage(m_strRes); + } + return m_strRes; +} + +void ConfigHandler::setDefaults() +{ m_settings.clear(); } -void ConfigHandler::setAllTheButtons() { +void ConfigHandler::setAllTheButtons() +{ QVector buttons; auto listTypes = CaptureButton::getIterableButtonTypes(); - for (const CaptureButton::ButtonType t: listTypes) { + for (const CaptureButton::ButtonType t : listTypes) { buttons << static_cast(t); } // TODO: remove toList in v1.0 - m_settings.setValue(QStringLiteral("buttons"), QVariant::fromValue(buttons.toList())); + m_settings.setValue(QStringLiteral("buttons"), + QVariant::fromValue(buttons.toList())); } -QString ConfigHandler::configFilePath() const { +QString ConfigHandler::configFilePath() const +{ return m_settings.fileName(); } -bool ConfigHandler::normalizeButtons(QVector &buttons) { +bool ConfigHandler::normalizeButtons(QVector& buttons) +{ auto listTypes = CaptureButton::getIterableButtonTypes(); QVector listTypesInt; - for(auto i: listTypes) + for (auto i : listTypes) listTypesInt << static_cast(i); bool hasChanged = false; @@ -438,32 +495,34 @@ bool ConfigHandler::normalizeButtons(QVector &buttons) { } QVector ConfigHandler::fromIntToButton( - const QVector &l) + const QVector& l) { QVector buttons; - for (auto const i: l) + for (auto const i : l) buttons << static_cast(i); return buttons; } QVector ConfigHandler::fromButtonToInt( - const QVector &l) + const QVector& l) { QVector buttons; - for (auto const i: l) + for (auto const i : l) buttons << static_cast(i); return buttons; } -QVector ConfigHandler::shortcuts() { +QVector ConfigHandler::shortcuts() +{ ConfigShortcuts configShortcuts; m_shortcuts = configShortcuts.captureShortcutsDefault(getButtons()); return m_shortcuts; } -void ConfigHandler::setShortcutsDefault() { +void ConfigHandler::setShortcutsDefault() +{ ConfigShortcuts configShortcuts; - for (auto shortcutItem: shortcuts()) { + for (auto shortcutItem : shortcuts()) { QString shortcutName = shortcutItem.at(0); QString shortcutDescription = shortcutItem.at(1); QString shortcutValueDefault = shortcutItem.at(2); @@ -471,49 +530,48 @@ void ConfigHandler::setShortcutsDefault() { QString shortcutValue = shortcut(shortcutName); QKeySequence ks = QKeySequence(); - if(shortcutValue.isNull()) { + if (shortcutValue.isNull()) { ks = QKeySequence(shortcutValueDefault); if (!setShortcut(shortcutName, ks.toString())) { shortcutValue = shortcutValueDefault; } } - m_shortcuts << (QStringList() - << shortcutName - << shortcutDescription - << shortcutValue); + m_shortcuts << (QStringList() << shortcutName << shortcutDescription + << shortcutValue); } } -bool ConfigHandler::setShortcut(const QString& shortcutName, const QString& shortutValue) { +bool ConfigHandler::setShortcut(const QString& shortcutName, + const QString& shortutValue) +{ bool error = false; m_settings.beginGroup("Shortcuts"); QVector reservedShortcuts; - reservedShortcuts << QKeySequence(Qt::Key_Backspace) << QKeySequence(Qt::Key_Escape); - if(shortutValue.isEmpty()){ + reservedShortcuts << QKeySequence(Qt::Key_Backspace) + << QKeySequence(Qt::Key_Escape); + if (shortutValue.isEmpty()) { m_settings.setValue(shortcutName, ""); - } - else if (reservedShortcuts.contains(QKeySequence(shortutValue))) { + } else if (reservedShortcuts.contains(QKeySequence(shortutValue))) { // do not allow to set reserved shortcuts error = true; - } - else { + } else { // Make no difference for Return and Enter keys QString shortcutItem = shortutValue; - if(shortcutItem == "Enter") { + if (shortcutItem == "Enter") { shortcutItem = QKeySequence(Qt::Key_Return).toString(); } // do not allow to set overlapped shortcuts foreach (auto currentShortcutName, m_settings.allKeys()) { - if(m_settings.value(currentShortcutName) == shortcutItem) { + if (m_settings.value(currentShortcutName) == shortcutItem) { m_settings.setValue(shortcutName, ""); error = true; break; } } - if(!error) { + if (!error) { m_settings.setValue(shortcutName, shortcutItem); } } @@ -521,7 +579,8 @@ bool ConfigHandler::setShortcut(const QString& shortcutName, const QString& shor return !error; } -const QString& ConfigHandler::shortcut(const QString& shortcutName) { +const QString& ConfigHandler::shortcut(const QString& shortcutName) +{ m_settings.beginGroup("Shortcuts"); m_strRes = m_settings.value(shortcutName).toString(); m_settings.endGroup(); diff --git a/src/utils/confighandler.h b/src/utils/confighandler.h index 58367610..f720d16d 100644 --- a/src/utils/confighandler.h +++ b/src/utils/confighandler.h @@ -18,34 +18,35 @@ #pragma once #include "src/widgets/capture/capturebutton.h" -#include -#include #include +#include +#include -class ConfigHandler : public QObject { +class ConfigHandler : public QObject +{ public: explicit ConfigHandler(); QVector getButtons(); - void setButtons(const QVector &); + void setButtons(const QVector&); QVector getUserColors(); - void setUserColors(const QVector &); + void setUserColors(const QVector&); QString savePathValue(); - void setSavePath(const QString &); + void setSavePath(const QString&); QString savePathFixed(); - void setSavePathFixed(const QString &); + void setSavePathFixed(const QString&); QColor uiMainColorValue(); - void setUIMainColor(const QColor &); + void setUIMainColor(const QColor&); QColor uiContrastColorValue(); - void setUIContrastColor(const QColor &); + void setUIContrastColor(const QColor&); QColor drawColorValue(); - void setDrawColor(const QColor &); + void setDrawColor(const QColor&); bool showHelpValue(); void setShowHelp(const bool); @@ -54,7 +55,7 @@ public: void setDesktopNotification(const bool); QString filenamePatternValue(); - void setFilenamePattern(const QString &); + void setFilenamePattern(const QString&); bool disabledTrayIconValue(); void setDisabledTrayIcon(const bool); @@ -84,6 +85,9 @@ public: bool copyPathAfterSaveEnabled(); void setCopyPathAfterSaveEnabled(const bool); + void setUploadStorage(const QString&); + const QString& uploadStorage(); + void setDefaults(); void setAllTheButtons(); @@ -99,8 +103,8 @@ private: QSettings m_settings; QVector m_shortcuts; - bool normalizeButtons(QVector &); + bool normalizeButtons(QVector&); - QVector fromIntToButton(const QVector &l); - QVector fromButtonToInt(const QVector &l); + QVector fromIntToButton(const QVector& l); + QVector fromButtonToInt(const QVector& l); }; diff --git a/src/utils/history.cpp b/src/utils/history.cpp index d3a4ba33..f5ce6ae6 100644 --- a/src/utils/history.cpp +++ b/src/utils/history.cpp @@ -4,7 +4,6 @@ #include #include - History::History() { // Get cache history path @@ -21,27 +20,32 @@ History::History() dir.mkpath("."); } -const QString &History::path() { +const QString& History::path() +{ return m_historyPath; } -void History::save(const QPixmap &pixmap, const QString &fileName) { +void History::save(const QPixmap& pixmap, const QString& fileName) +{ QFile file(path() + fileName); file.open(QIODevice::WriteOnly); pixmap.save(&file, "PNG"); history(); } -const QList &History::history() { +const QList& History::history() +{ QDir directory(path()); - QStringList images = directory.entryList(QStringList() << "*.png" << "*.PNG", QDir::Files, QDir::Time); + QStringList images = directory.entryList(QStringList() << "*.png" + << "*.PNG", + QDir::Files, + QDir::Time); int cnt = 0; m_thumbs.clear(); - foreach(QString fileName, images) { - if(++cnt <= HISTORY_MAX_SIZE) { + foreach (QString fileName, images) { + if (++cnt <= HISTORY_MAX_SIZE) { m_thumbs.append(fileName); - } - else { + } else { QFile file(path() + fileName); file.remove(); } @@ -49,42 +53,46 @@ const QList &History::history() { return m_thumbs; } -const HISTORY_FILE_NAME &History::unpackFileName(const QString &fileNamePacked) { +const HISTORY_FILE_NAME& History::unpackFileName(const QString& fileNamePacked) +{ int nPathIndex = fileNamePacked.lastIndexOf("/"); QStringList unpackedFileName; - if(nPathIndex == -1) { + if (nPathIndex == -1) { unpackedFileName = fileNamePacked.split("-"); } else { unpackedFileName = fileNamePacked.mid(nPathIndex + 1).split("-"); } switch (unpackedFileName.length()) { - case 3: - m_unpackedFileName.file = unpackedFileName[2]; - m_unpackedFileName.token = unpackedFileName[1]; - m_unpackedFileName.type = unpackedFileName[0]; - break; - case 2: - m_unpackedFileName.file = unpackedFileName[1]; - m_unpackedFileName.token = ""; - m_unpackedFileName.type = unpackedFileName[0]; - break; - default: - m_unpackedFileName.file = unpackedFileName[0]; - m_unpackedFileName.token = ""; - m_unpackedFileName.type = SCREENSHOT_STORAGE_TYPE_LOCAL; - break; + case 3: + m_unpackedFileName.file = unpackedFileName[2]; + m_unpackedFileName.token = unpackedFileName[1]; + m_unpackedFileName.type = unpackedFileName[0]; + break; + case 2: + m_unpackedFileName.file = unpackedFileName[1]; + m_unpackedFileName.token = ""; + m_unpackedFileName.type = unpackedFileName[0]; + break; + default: + m_unpackedFileName.file = unpackedFileName[0]; + m_unpackedFileName.token = ""; + m_unpackedFileName.type = ""; + break; } return m_unpackedFileName; } -const QString &History::packFileName(const QString &storageType, const QString &deleteToken, const QString &fileName) { +const QString& History::packFileName(const QString& storageType, + const QString& deleteToken, + const QString& fileName) +{ m_packedFileName = fileName; - if(storageType.length() > 0) { - if(deleteToken.length() > 0) { - m_packedFileName = storageType + "-" + deleteToken + "-" + m_packedFileName; - } - else { + if (storageType.length() > 0) { + if (deleteToken.length() > 0) { + m_packedFileName = + storageType + "-" + deleteToken + "-" + m_packedFileName; + } else { m_packedFileName = storageType + "-" + m_packedFileName; } } diff --git a/src/utils/history.h b/src/utils/history.h index fc111615..a4569175 100644 --- a/src/utils/history.h +++ b/src/utils/history.h @@ -4,15 +4,11 @@ #define HISTORY_MAX_SIZE 25 #include -#include #include +#include - -#define SCREENSHOT_STORAGE_TYPE_LOCAL "" -#define SCREENSHOT_STORAGE_TYPE_S3 "s3" -#define SCREENSHOT_STORAGE_TYPE_IMGUR "imgur" - -struct HISTORY_FILE_NAME { +struct HISTORY_FILE_NAME +{ QString file; QString token; QString type; @@ -23,12 +19,12 @@ class History public: History(); - void save(const QPixmap &, const QString &); - const QList &history(); - const QString &path(); + void save(const QPixmap&, const QString&); + const QList& history(); + const QString& path(); - const HISTORY_FILE_NAME &unpackFileName(const QString &); - const QString &packFileName(const QString &, const QString &, const QString &); + const HISTORY_FILE_NAME& unpackFileName(const QString&); + const QString& packFileName(const QString&, const QString&, const QString&); private: QString m_historyPath; diff --git a/src/widgets/capture/capturewidget.cpp b/src/widgets/capture/capturewidget.cpp index b4799890..21214f24 100644 --- a/src/widgets/capture/capturewidget.cpp +++ b/src/widgets/capture/capturewidget.cpp @@ -15,55 +15,71 @@ // You should have received a copy of the GNU General Public License // along with Flameshot. If not, see . -// Based on Lightscreen areadialog.cpp, Copyright 2017 Christian Kaiser -// released under the GNU GPL2 +// Based on Lightscreen areadialog.cpp, Copyright 2017 Christian Kaiser +// released under the GNU GPL2 +// -// Based on KDE's KSnapshot regiongrabber.cpp, revision 796531, Copyright 2007 Luca Gugelmann -// released under the GNU LGPL +// Based on KDE's KSnapshot regiongrabber.cpp, revision 796531, Copyright 2007 +// Luca Gugelmann released under the GNU LGPL +// #include "capturewidget.h" -#include "src/widgets/capture/hovereventfilter.h" -#include "src/widgets/panel/sidepanelwidget.h" +#include "src/core/controller.h" +#include "src/tools/storage/storagemanager.h" +#include "src/tools/toolfactory.h" #include "src/utils/colorutils.h" #include "src/utils/globalvalues.h" -#include "src/widgets/capture/notifierbox.h" -#include "src/widgets/capture/colorpicker.h" #include "src/utils/screengrabber.h" -#include "src/utils/systemnotification.h" #include "src/utils/screenshotsaver.h" -#include "src/core/controller.h" +#include "src/utils/systemnotification.h" +#include "src/widgets/capture/colorpicker.h" +#include "src/widgets/capture/hovereventfilter.h" #include "src/widgets/capture/modificationcommand.h" -#include "src/tools/imgs3/imgs3uploadertool.h" -#include "src/tools/toolfactory.h" -#include -#include -#include +#include "src/widgets/capture/notifierbox.h" +#include "src/widgets/panel/sidepanelwidget.h" #include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include +#include -// CaptureWidget is the main component used to capture the screen. It contains an -// are of selection with its respective buttons. +// CaptureWidget is the main component used to capture the screen. It contains +// an are of selection with its respective buttons. // enableSaveWIndow -CaptureWidget::CaptureWidget(const uint id, const QString &savePath, - bool fullScreen, QWidget *parent) : - QWidget(parent), m_mouseIsClicked(false), m_rightClick(false), - m_newSelection(false), m_grabbing(false), m_captureDone(false), - m_previewEnabled(true), m_adjustmentButtonPressed(false), m_activeButton(nullptr), - m_activeTool(nullptr), m_toolWidget(nullptr), - m_mouseOverHandle(SelectionWidget::NO_SIDE), m_id(id) +CaptureWidget::CaptureWidget(const uint id, + const QString& savePath, + bool fullScreen, + QWidget* parent) + : QWidget(parent) + , m_mouseIsClicked(false) + , m_rightClick(false) + , m_newSelection(false) + , m_grabbing(false) + , m_captureDone(false) + , m_previewEnabled(true) + , m_adjustmentButtonPressed(false) + , m_activeButton(nullptr) + , m_activeTool(nullptr) + , m_toolWidget(nullptr) + , m_mouseOverHandle(SelectionWidget::NO_SIDE) + , m_id(id) { // Base config of the widget m_eventFilter = new HoverEventFilter(this); - connect(m_eventFilter, &HoverEventFilter::hoverIn, - this, &CaptureWidget::childEnter); - connect(m_eventFilter, &HoverEventFilter::hoverOut, - this, &CaptureWidget::childLeave); + connect(m_eventFilter, + &HoverEventFilter::hoverIn, + this, + &CaptureWidget::childEnter); + connect(m_eventFilter, + &HoverEventFilter::hoverOut, + this, + &CaptureWidget::childLeave); setAttribute(Qt::WA_DeleteOnClose); m_showInitialMsg = m_config.showHelpValue(); m_opacity = m_config.contrastOpacityValue(); @@ -73,36 +89,33 @@ CaptureWidget::CaptureWidget(const uint id, const QString &savePath, #ifdef Q_OS_WIN // Top left of the whole set of screens - QPoint topLeft(0,0); + QPoint topLeft(0, 0); #endif if (fullScreen) { // Grab Screenshot bool ok = true; m_context.screenshot = ScreenGrabber().grabEntireDesktop(ok); - if(!ok) { + if (!ok) { SystemNotification().sendMessage(tr("Unable to capture screen")); this->close(); } m_context.origScreenshot = m_context.screenshot; #ifdef Q_OS_WIN - setWindowFlags(Qt::WindowStaysOnTopHint - | Qt::FramelessWindowHint - | Qt::Popup); + setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | + Qt::Popup); - for (QScreen *const screen : QGuiApplication::screens()) { + for (QScreen* const screen : QGuiApplication::screens()) { QPoint topLeftScreen = screen->geometry().topLeft(); if (topLeft.x() > topLeftScreen.x() || - topLeft.y() > topLeftScreen.y()) { + topLeft.y() > topLeftScreen.y()) { topLeft = topLeftScreen; } } move(topLeft); #else - setWindowFlags(Qt::BypassWindowManagerHint - | Qt::WindowStaysOnTopHint - | Qt::FramelessWindowHint - | Qt::Tool); + setWindowFlags(Qt::BypassWindowManagerHint | Qt::WindowStaysOnTopHint | + Qt::FramelessWindowHint | Qt::Tool); #endif resize(pixmap().size()); } @@ -111,7 +124,7 @@ CaptureWidget::CaptureWidget(const uint id, const QString &savePath, updateButtons(); QVector areas; if (m_context.fullscreen) { - for (QScreen *const screen : QGuiApplication::screens()) { + for (QScreen* const screen : QGuiApplication::screens()) { QRect r = screen->geometry(); #ifdef Q_OS_WIN r.moveTo(r.topLeft() - topLeft); @@ -129,20 +142,24 @@ CaptureWidget::CaptureWidget(const uint id, const QString &savePath, // Init color picker m_colorPicker = new ColorPicker(this); - connect(m_colorPicker, &ColorPicker::colorSelected, - this, &CaptureWidget::setDrawColor); + connect(m_colorPicker, + &ColorPicker::colorSelected, + this, + &CaptureWidget::setDrawColor); m_colorPicker->hide(); // Init notification widget m_notifierBox = new NotifierBox(this); m_notifierBox->hide(); - connect(&m_undoStack, &QUndoStack::indexChanged, - this, [this](int){ this->update(); }); + connect(&m_undoStack, &QUndoStack::indexChanged, this, [this](int) { + this->update(); + }); initPanel(); } -CaptureWidget::~CaptureWidget() { +CaptureWidget::~CaptureWidget() +{ if (m_captureDone) { emit captureTaken(m_id, this->pixmap()); } else { @@ -153,13 +170,14 @@ CaptureWidget::~CaptureWidget() { // redefineButtons retrieves the buttons configured to be shown with the // selection in the capture -void CaptureWidget::updateButtons() { +void CaptureWidget::updateButtons() +{ m_uiColor = m_config.uiMainColorValue(); m_contrastUiColor = m_config.uiContrastColorValue(); QVector vectorButtons; - for (const CaptureButton::ButtonType &t: m_config.getButtons()) { - CaptureButton *b = new CaptureButton(t, this); + for (const CaptureButton::ButtonType& t : m_config.getButtons()) { + CaptureButton* b = new CaptureButton(t, this); if (t == CaptureButton::TYPE_SELECTIONINDICATOR) { m_sizeIndButton = b; } @@ -168,37 +186,44 @@ void CaptureWidget::updateButtons() { makeChild(b); switch (t) { - case CaptureButton::ButtonType::TYPE_EXIT: - case CaptureButton::ButtonType::TYPE_SAVE: - case CaptureButton::ButtonType::TYPE_COPY: - case CaptureButton::ButtonType::TYPE_UNDO: - case CaptureButton::ButtonType::TYPE_REDO: - case CaptureButton::ButtonType::TYPE_IMAGEUPLOADER: - // nothing to do, just skip non-dynamic buttons with existing hard coded slots - break; - default: - // Set shortcuts for a tool - QString shortcut = ConfigHandler().shortcut(QVariant::fromValue(t).toString()); - if( !shortcut.isNull() ){ - QShortcut *key = new QShortcut(QKeySequence(shortcut), this); - CaptureWidget *captureWidget = this; - connect(key, &QShortcut::activated, this, [=]() { - emit captureWidget->setState(b); - }); - } - break; + case CaptureButton::ButtonType::TYPE_EXIT: + case CaptureButton::ButtonType::TYPE_SAVE: + case CaptureButton::ButtonType::TYPE_COPY: + case CaptureButton::ButtonType::TYPE_UNDO: + case CaptureButton::ButtonType::TYPE_REDO: + case CaptureButton::ButtonType::TYPE_IMAGEUPLOADER: + // nothing to do, just skip non-dynamic buttons with existing + // hard coded slots + break; + default: + // Set shortcuts for a tool + QString shortcut = + ConfigHandler().shortcut(QVariant::fromValue(t).toString()); + if (!shortcut.isNull()) { + QShortcut* key = + new QShortcut(QKeySequence(shortcut), this); + CaptureWidget* captureWidget = this; + connect(key, &QShortcut::activated, this, [=]() { + emit captureWidget->setState(b); + }); + } + break; } - connect(b, &CaptureButton::pressedButton, this, &CaptureWidget::setState); - connect(b->tool(), &CaptureTool::requestAction, - this, &CaptureWidget::handleButtonSignal); + connect( + b, &CaptureButton::pressedButton, this, &CaptureWidget::setState); + connect(b->tool(), + &CaptureTool::requestAction, + this, + &CaptureWidget::handleButtonSignal); vectorButtons << b; } m_buttonHandler->setButtons(vectorButtons); } -QPixmap CaptureWidget::pixmap() { +QPixmap CaptureWidget::pixmap() +{ QPixmap p; if (m_toolWidget && m_activeTool) { p = m_context.selectedScreenshotArea().copy(); @@ -210,11 +235,11 @@ QPixmap CaptureWidget::pixmap() { return m_context.selectedScreenshotArea(); } -void CaptureWidget::deleteToolwidgetOrClose() { - if(m_panel->isVisible()){ +void CaptureWidget::deleteToolwidgetOrClose() +{ + if (m_panel->isVisible()) { m_panel->hide(); - } - else if (m_toolWidget) { + } else if (m_toolWidget) { m_toolWidget->deleteLater(); m_toolWidget = nullptr; } else { @@ -222,7 +247,8 @@ void CaptureWidget::deleteToolwidgetOrClose() { } } -void CaptureWidget::paintEvent(QPaintEvent *) { +void CaptureWidget::paintEvent(QPaintEvent*) +{ QPainter painter(this); painter.drawPixmap(0, 0, m_context.screenshot); @@ -231,8 +257,7 @@ void CaptureWidget::paintEvent(QPaintEvent *) { m_activeTool->process(painter, m_context.screenshot); painter.restore(); } else if (m_activeButton && m_activeButton->tool()->showMousePreview() && - m_previewEnabled) - { + m_previewEnabled) { painter.save(); m_activeButton->tool()->paintMousePreview(painter, m_context); painter.restore(); @@ -255,14 +280,16 @@ void CaptureWidget::paintEvent(QPaintEvent *) { QRect helpRect = QGuiApplication::primaryScreen()->geometry(); helpRect.moveTo(mapFromGlobal(helpRect.topLeft())); - QString helpTxt = tr("Select an area with the mouse, or press Esc to exit." - "\nPress Enter to capture the screen." - "\nPress Right Click to show the color picker." - "\nUse the Mouse Wheel to change the thickness of your tool." - "\nPress Space to open the side panel."); + QString helpTxt = + tr("Select an area with the mouse, or press Esc to exit." + "\nPress Enter to capture the screen." + "\nPress Right Click to show the color picker." + "\nUse the Mouse Wheel to change the thickness of your tool." + "\nPress Space to open the side panel."); // We draw the white contrasting background for the text, using the - //same text and options to get the boundingRect that the text will have. + // same text and options to get the boundingRect that the text will + // have. QRectF bRect = painter.boundingRect(helpRect, Qt::AlignCenter, helpTxt); // These four calls provide padding for the rect @@ -274,8 +301,8 @@ void CaptureWidget::paintEvent(QPaintEvent *) { QColor rectColor(m_uiColor); rectColor.setAlpha(180); - QColor textColor((ColorUtils::colorIsDark(rectColor) ? - Qt::white : Qt::black)); + QColor textColor( + (ColorUtils::colorIsDark(rectColor) ? Qt::white : Qt::black)); painter.setBrush(QBrush(rectColor, Qt::SolidPattern)); painter.setPen(QPen(textColor)); @@ -289,13 +316,14 @@ void CaptureWidget::paintEvent(QPaintEvent *) { painter.setPen(m_uiColor); painter.setRenderHint(QPainter::Antialiasing); painter.setBrush(m_uiColor); - for(auto r: m_selection->handlerAreas()) { + for (auto r : m_selection->handlerAreas()) { painter.drawRoundRect(r, 100, 100); } } } -void CaptureWidget::mousePressEvent(QMouseEvent *e) { +void CaptureWidget::mousePressEvent(QMouseEvent* e) +{ if (e->button() == Qt::RightButton) { m_rightClick = true; m_colorPicker->move(e->pos().x() - m_colorPicker->width() / 2, @@ -320,12 +348,18 @@ void CaptureWidget::mousePressEvent(QMouseEvent *e) { } m_activeTool = m_activeButton->tool()->copy(this); - connect(this, &CaptureWidget::colorChanged, - m_activeTool, &CaptureTool::colorChanged); - connect(this, &CaptureWidget::thicknessChanged, - m_activeTool, &CaptureTool::thicknessChanged); - connect(m_activeTool, &CaptureTool::requestAction, - this, &CaptureWidget::handleButtonSignal); + connect(this, + &CaptureWidget::colorChanged, + m_activeTool, + &CaptureTool::colorChanged); + connect(this, + &CaptureWidget::thicknessChanged, + m_activeTool, + &CaptureTool::thicknessChanged); + connect(m_activeTool, + &CaptureTool::requestAction, + this, + &CaptureWidget::handleButtonSignal); m_activeTool->drawStart(m_context); return; } @@ -334,8 +368,7 @@ void CaptureWidget::mousePressEvent(QMouseEvent *e) { m_selection->saveGeometry(); // New selection if (!m_selection->geometry().contains(e->pos()) && - m_mouseOverHandle == SelectionWidget::NO_SIDE) - { + m_mouseOverHandle == SelectionWidget::NO_SIDE) { m_selection->setGeometry(QRect(e->pos(), e->pos())); m_selection->setVisible(false); m_newSelection = true; @@ -348,7 +381,8 @@ void CaptureWidget::mousePressEvent(QMouseEvent *e) { updateCursor(); } -void CaptureWidget::mouseMoveEvent(QMouseEvent *e) { +void CaptureWidget::mouseMoveEvent(QMouseEvent* e) +{ m_context.mousePos = e->pos(); if (m_mouseIsClicked && !m_activeButton) { @@ -358,12 +392,13 @@ void CaptureWidget::mouseMoveEvent(QMouseEvent *e) { if (m_newSelection) { m_selection->setVisible(true); m_selection->setGeometry( - QRect(m_dragStartPoint, m_context.mousePos).normalized()); + QRect(m_dragStartPoint, m_context.mousePos).normalized()); update(); } else if (m_mouseOverHandle == SelectionWidget::NO_SIDE) { // Moving the whole selection QRect initialRect = m_selection->savedGeometry().normalized(); - QPoint newTopLeft = initialRect.topLeft() + (e->pos() - m_dragStartPoint); + QPoint newTopLeft = + initialRect.topLeft() + (e->pos() - m_dragStartPoint); QRect finalRect(newTopLeft, initialRect.size()); if (finalRect.left() < rect().left()) { @@ -376,7 +411,8 @@ void CaptureWidget::mouseMoveEvent(QMouseEvent *e) { } else if (finalRect.bottom() > rect().bottom()) { finalRect.setBottom(rect().bottom()); } - m_selection->setGeometry(finalRect.normalized().intersected(rect())); + m_selection->setGeometry( + finalRect.normalized().intersected(rect())); update(); } else { // Dragging a handle @@ -385,37 +421,37 @@ void CaptureWidget::mouseMoveEvent(QMouseEvent *e) { bool symmetryMod = qApp->keyboardModifiers() & Qt::ShiftModifier; using sw = SelectionWidget; - if (m_mouseOverHandle == sw::TOPLEFT_SIDE - || m_mouseOverHandle == sw::TOP_SIDE - || m_mouseOverHandle == sw::TOPRIGHT_SIDE) - { // dragging one of the top handles + if (m_mouseOverHandle == sw::TOPLEFT_SIDE || + m_mouseOverHandle == sw::TOP_SIDE || + m_mouseOverHandle == + sw::TOPRIGHT_SIDE) { // dragging one of the top handles r.setTop(r.top() + offset.y()); if (symmetryMod) { r.setBottom(r.bottom() - offset.y()); } } - if (m_mouseOverHandle == sw::TOPLEFT_SIDE - || m_mouseOverHandle == sw::LEFT_SIDE - || m_mouseOverHandle == sw::BOTTONLEFT_SIDE) - { // dragging one of the left handles + if (m_mouseOverHandle == sw::TOPLEFT_SIDE || + m_mouseOverHandle == sw::LEFT_SIDE || + m_mouseOverHandle == + sw::BOTTONLEFT_SIDE) { // dragging one of the left handles r.setLeft(r.left() + offset.x()); if (symmetryMod) { r.setRight(r.right() - offset.x()); } } - if (m_mouseOverHandle == sw::BOTTONLEFT_SIDE - || m_mouseOverHandle == sw::BOTTON_SIDE - || m_mouseOverHandle == sw::BOTTONRIGHT_SIDE) - { // dragging one of the bottom handles + if (m_mouseOverHandle == sw::BOTTONLEFT_SIDE || + m_mouseOverHandle == sw::BOTTON_SIDE || + m_mouseOverHandle == + sw::BOTTONRIGHT_SIDE) { // dragging one of the bottom handles r.setBottom(r.bottom() + offset.y()); if (symmetryMod) { r.setTop(r.top() - offset.y()); } } - if (m_mouseOverHandle == sw::TOPRIGHT_SIDE - || m_mouseOverHandle == sw::RIGHT_SIDE - || m_mouseOverHandle == sw::BOTTONRIGHT_SIDE) - { // dragging one of the right handles + if (m_mouseOverHandle == sw::TOPRIGHT_SIDE || + m_mouseOverHandle == sw::RIGHT_SIDE || + m_mouseOverHandle == + sw::BOTTONRIGHT_SIDE) { // dragging one of the right handles r.setRight(r.right() + offset.x()); if (symmetryMod) { r.setLeft(r.left() - offset.x()); @@ -432,9 +468,11 @@ void CaptureWidget::mouseMoveEvent(QMouseEvent *e) { m_activeTool->drawMove(e->pos()); } update(); - // Hides the buttons under the mouse. If the mouse leaves, it shows them. + // Hides the buttons under the mouse. If the mouse leaves, it shows + // them. if (m_buttonHandler->buttonsAreInside()) { - const bool containsMouse = m_buttonHandler->contains(m_context.mousePos); + const bool containsMouse = + m_buttonHandler->contains(m_context.mousePos); if (containsMouse) { m_buttonHandler->hide(); } else { @@ -452,20 +490,21 @@ void CaptureWidget::mouseMoveEvent(QMouseEvent *e) { } } -void CaptureWidget::mouseReleaseEvent(QMouseEvent *e) { +void CaptureWidget::mouseReleaseEvent(QMouseEvent* e) +{ if (e->button() == Qt::RightButton || m_colorPicker->isVisible()) { m_colorPicker->hide(); m_rightClick = false; - if(!m_context.color.isValid()) { + if (!m_context.color.isValid()) { m_panel->show(); } - // when we end the drawing we have to register the last point and - //add the temp modification to the list of modifications + // when we end the drawing we have to register the last point and + // add the temp modification to the list of modifications } else if (m_mouseIsClicked && m_activeTool) { m_activeTool->drawEnd(m_context.mousePos); if (m_activeTool->isValid()) { pushToolToStack(); - } else if (!m_toolWidget){ + } else if (!m_toolWidget) { m_activeTool->deleteLater(); m_activeTool = nullptr; } @@ -500,7 +539,8 @@ void CaptureWidget::mouseReleaseEvent(QMouseEvent *e) { updateCursor(); } -void CaptureWidget::leftMove() { +void CaptureWidget::leftMove() +{ if (m_selection->geometry().left() > rect().left()) { m_selection->move(QPoint(m_selection->x() - 1, m_selection->y())); m_buttonHandler->updatePosition(m_selection->geometry()); @@ -508,9 +548,10 @@ void CaptureWidget::leftMove() { } } -void CaptureWidget::rightMove() { +void CaptureWidget::rightMove() +{ if (m_selection->geometry().right() < rect().right()) { - m_selection->move(QPoint(m_selection->x() +1, m_selection->y())); + m_selection->move(QPoint(m_selection->x() + 1, m_selection->y())); QRect newGeometry = m_selection->geometry().intersected(rect()); m_context.selection = extendedRect(&newGeometry); m_buttonHandler->updatePosition(m_selection->geometry()); @@ -518,9 +559,10 @@ void CaptureWidget::rightMove() { } } -void CaptureWidget::upMove() { +void CaptureWidget::upMove() +{ if (m_selection->geometry().top() > rect().top()) { - m_selection->move(QPoint(m_selection->x(), m_selection->y() -1)); + m_selection->move(QPoint(m_selection->x(), m_selection->y() - 1)); QRect newGeometry = m_selection->geometry().intersected(rect()); m_context.selection = extendedRect(&newGeometry); m_buttonHandler->updatePosition(m_selection->geometry()); @@ -528,9 +570,10 @@ void CaptureWidget::upMove() { } } -void CaptureWidget::downMove() { +void CaptureWidget::downMove() +{ if (m_selection->geometry().bottom() < rect().bottom()) { - m_selection->move(QPoint(m_selection->x(), m_selection->y() +1)); + m_selection->move(QPoint(m_selection->x(), m_selection->y() + 1)); QRect newGeometry = m_selection->geometry().intersected(rect()); m_context.selection = extendedRect(&newGeometry); m_buttonHandler->updatePosition(m_selection->geometry()); @@ -538,30 +581,35 @@ void CaptureWidget::downMove() { } } - -void CaptureWidget::keyPressEvent(QKeyEvent *e) { +void CaptureWidget::keyPressEvent(QKeyEvent* e) +{ if (!m_selection->isVisible()) { return; } else if (e->key() == Qt::Key_Control) { m_adjustmentButtonPressed = true; } else if (e->key() == Qt::Key_Enter) { // Make no difference for Return and Enter keys - QKeyEvent * keyReturn = new QKeyEvent (QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier); - QCoreApplication::postEvent (this, keyReturn); + QKeyEvent* keyReturn = + new QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier); + QCoreApplication::postEvent(this, keyReturn); } } -void CaptureWidget::keyReleaseEvent(QKeyEvent *e) { +void CaptureWidget::keyReleaseEvent(QKeyEvent* e) +{ if (e->key() == Qt::Key_Control) { m_adjustmentButtonPressed = false; } } -void CaptureWidget::wheelEvent(QWheelEvent *e) { +void CaptureWidget::wheelEvent(QWheelEvent* e) +{ m_context.thickness += e->delta() / 120; m_context.thickness = qBound(0, m_context.thickness, 100); - QPoint topLeft = qApp->desktop()->screenGeometry( - qApp->desktop()->screenNumber(QCursor::pos())).topLeft(); + QPoint topLeft = + qApp->desktop() + ->screenGeometry(qApp->desktop()->screenNumber(QCursor::pos())) + .topLeft(); int offset = m_notifierBox->width() / 4; m_notifierBox->move(mapFromGlobal(topLeft) + QPoint(offset, offset)); m_notifierBox->showMessage(QString::number(m_context.thickness)); @@ -571,32 +619,36 @@ void CaptureWidget::wheelEvent(QWheelEvent *e) { emit thicknessChanged(m_context.thickness); } -void CaptureWidget::resizeEvent(QResizeEvent *e) { +void CaptureWidget::resizeEvent(QResizeEvent* e) +{ QWidget::resizeEvent(e); m_context.widgetDimensions = rect(); - m_context.widgetOffset = mapToGlobal(QPoint(0,0)); + m_context.widgetOffset = mapToGlobal(QPoint(0, 0)); m_panel->setFixedHeight(height()); if (!m_context.fullscreen) { m_buttonHandler->updateScreenRegions(rect()); } } -void CaptureWidget::moveEvent(QMoveEvent *e) { +void CaptureWidget::moveEvent(QMoveEvent* e) +{ QWidget::moveEvent(e); - m_context.widgetOffset = mapToGlobal(QPoint(0,0)); + m_context.widgetOffset = mapToGlobal(QPoint(0, 0)); } -void CaptureWidget::initContext(const QString &savePath, bool fullscreen) { +void CaptureWidget::initContext(const QString& savePath, bool fullscreen) +{ m_context.widgetDimensions = rect(); m_context.color = m_config.drawColorValue(); m_context.savePath = savePath; - m_context.widgetOffset = mapToGlobal(QPoint(0,0)); - m_context.mousePos= mapFromGlobal(QCursor::pos()); + m_context.widgetOffset = mapToGlobal(QPoint(0, 0)); + m_context.mousePos = mapFromGlobal(QCursor::pos()); m_context.thickness = m_config.drawThicknessValue(); m_context.fullscreen = fullscreen; } -void CaptureWidget::initPanel() { +void CaptureWidget::initPanel() +{ m_panel = new UtilityPanel(this); makeChild(m_panel); QRect panelRect = rect(); @@ -607,34 +659,43 @@ void CaptureWidget::initPanel() { panelRect.setWidth(m_colorPicker->width() * 1.5); m_panel->setGeometry(panelRect); - SidePanelWidget *sidePanel = - new SidePanelWidget(&m_context.screenshot); - connect(sidePanel, &SidePanelWidget::colorChanged, - this, &CaptureWidget::setDrawColor); - connect(sidePanel, &SidePanelWidget::thicknessChanged, - this, &CaptureWidget::setDrawThickness); - connect(this, &CaptureWidget::colorChanged, - sidePanel, &SidePanelWidget::updateColor); - connect(this, &CaptureWidget::thicknessChanged, - sidePanel, &SidePanelWidget::updateThickness); - connect(sidePanel, &SidePanelWidget::togglePanel, - m_panel, &UtilityPanel::toggle); + SidePanelWidget* sidePanel = new SidePanelWidget(&m_context.screenshot); + connect(sidePanel, + &SidePanelWidget::colorChanged, + this, + &CaptureWidget::setDrawColor); + connect(sidePanel, + &SidePanelWidget::thicknessChanged, + this, + &CaptureWidget::setDrawThickness); + connect(this, + &CaptureWidget::colorChanged, + sidePanel, + &SidePanelWidget::updateColor); + connect(this, + &CaptureWidget::thicknessChanged, + sidePanel, + &SidePanelWidget::updateThickness); + connect( + sidePanel, &SidePanelWidget::togglePanel, m_panel, &UtilityPanel::toggle); sidePanel->colorChanged(m_context.color); sidePanel->thicknessChanged(m_context.thickness); m_panel->pushWidget(sidePanel); m_panel->pushWidget(new QUndoView(&m_undoStack, this)); } -void CaptureWidget::initSelection() { +void CaptureWidget::initSelection() +{ m_selection = new SelectionWidget(m_uiColor, this); - connect(m_selection, &SelectionWidget::animationEnded, this, [this](){ + connect(m_selection, &SelectionWidget::animationEnded, this, [this]() { this->m_buttonHandler->updatePosition(this->m_selection->geometry()); }); m_selection->setVisible(false); m_selection->setGeometry(QRect()); } -void CaptureWidget::setState(CaptureButton *b) { +void CaptureWidget::setState(CaptureButton* b) +{ if (!b) { return; } @@ -654,7 +715,7 @@ void CaptureWidget::setState(CaptureButton *b) { if (b->tool()->isSelectable()) { if (m_activeButton != b) { - QWidget *confW = b->tool()->configurationWidget(); + QWidget* confW = b->tool()->configurationWidget(); m_panel->addToolWidget(confW); if (m_activeButton) { m_activeButton->setColor(m_uiColor); @@ -671,7 +732,8 @@ void CaptureWidget::setState(CaptureButton *b) { } } -void CaptureWidget::processTool(CaptureTool *t) { +void CaptureWidget::processTool(CaptureTool* t) +{ auto backup = m_activeTool; // The tool is active during the pressed(). m_activeTool = t; @@ -679,102 +741,108 @@ void CaptureWidget::processTool(CaptureTool *t) { m_activeTool = backup; } -void CaptureWidget::handleButtonSignal(CaptureTool::Request r) { +void CaptureWidget::handleButtonSignal(CaptureTool::Request r) +{ switch (r) { - case CaptureTool::REQ_CLEAR_MODIFICATIONS: - m_undoStack.setIndex(0); - update(); - break; - case CaptureTool::REQ_CLOSE_GUI: - close(); - break; - case CaptureTool::REQ_HIDE_GUI: - hide(); - break; - case CaptureTool::REQ_HIDE_SELECTION: - m_newSelection = true; - m_selection->setVisible(false); - updateCursor(); - break; - case CaptureTool::REQ_SELECT_ALL: - m_selection->setGeometryAnimated(rect()); - break; - case CaptureTool::REQ_UNDO_MODIFICATION: - m_undoStack.undo(); - break; - case CaptureTool::REQ_REDO_MODIFICATION: - m_undoStack.redo(); - break; - case CaptureTool::REQ_REDRAW: - update(); - break; - case CaptureTool::REQ_TOGGLE_SIDEBAR: - m_panel->toggle(); - break; - case CaptureTool::REQ_SHOW_COLOR_PICKER: - break; - case CaptureTool::REQ_MOVE_MODE: - setState(m_activeButton); // Disable the actual button - break; - case CaptureTool::REQ_CAPTURE_DONE_OK: - m_captureDone = true; - break; - case CaptureTool::REQ_ADD_CHILD_WIDGET: - if (!m_activeTool) { + case CaptureTool::REQ_CLEAR_MODIFICATIONS: + m_undoStack.setIndex(0); + update(); break; - } - if (m_toolWidget) { - m_toolWidget->deleteLater(); - } - m_toolWidget = m_activeTool->widget(); - if (m_toolWidget) { - makeChild(m_toolWidget); - m_toolWidget->move(m_context.mousePos); - m_toolWidget->show(); - m_toolWidget->setFocus(); - } - break; - case CaptureTool::REQ_ADD_CHILD_WINDOW: - if (!m_activeTool) { + case CaptureTool::REQ_CLOSE_GUI: + close(); break; - } else { - QWidget *w = m_activeTool->widget(); - connect(this, &CaptureWidget::destroyed, w, &QWidget::deleteLater); - w->show(); - } - break; - case CaptureTool::REQ_ADD_EXTERNAL_WIDGETS: - if (!m_activeTool) { + case CaptureTool::REQ_HIDE_GUI: + hide(); + break; + case CaptureTool::REQ_HIDE_SELECTION: + m_newSelection = true; + m_selection->setVisible(false); + updateCursor(); + break; + case CaptureTool::REQ_SELECT_ALL: + m_selection->setGeometryAnimated(rect()); + break; + case CaptureTool::REQ_UNDO_MODIFICATION: + m_undoStack.undo(); + break; + case CaptureTool::REQ_REDO_MODIFICATION: + m_undoStack.redo(); + break; + case CaptureTool::REQ_REDRAW: + update(); + break; + case CaptureTool::REQ_TOGGLE_SIDEBAR: + m_panel->toggle(); + break; + case CaptureTool::REQ_SHOW_COLOR_PICKER: + break; + case CaptureTool::REQ_MOVE_MODE: + setState(m_activeButton); // Disable the actual button + break; + case CaptureTool::REQ_CAPTURE_DONE_OK: + m_captureDone = true; + break; + case CaptureTool::REQ_ADD_CHILD_WIDGET: + if (!m_activeTool) { + break; + } + if (m_toolWidget) { + m_toolWidget->deleteLater(); + } + m_toolWidget = m_activeTool->widget(); + if (m_toolWidget) { + makeChild(m_toolWidget); + m_toolWidget->move(m_context.mousePos); + m_toolWidget->show(); + m_toolWidget->setFocus(); + } + break; + case CaptureTool::REQ_ADD_CHILD_WINDOW: + if (!m_activeTool) { + break; + } else { + QWidget* w = m_activeTool->widget(); + connect( + this, &CaptureWidget::destroyed, w, &QWidget::deleteLater); + w->show(); + } + break; + case CaptureTool::REQ_ADD_EXTERNAL_WIDGETS: + if (!m_activeTool) { + break; + } else { + QWidget* w = m_activeTool->widget(); + w->setAttribute(Qt::WA_DeleteOnClose); + w->show(); + } + break; + default: break; - } else { - QWidget *w = m_activeTool->widget(); - w->setAttribute(Qt::WA_DeleteOnClose); - w->show(); - } - break; - default: - break; } } -void CaptureWidget::setDrawColor(const QColor &c) { +void CaptureWidget::setDrawColor(const QColor& c) +{ m_context.color = c; - if(m_context.color.isValid()) { + if (m_context.color.isValid()) { ConfigHandler().setDrawColor(m_context.color); emit colorChanged(c); } } -void CaptureWidget::setDrawThickness(const int &t) +void CaptureWidget::setDrawThickness(const int& t) { m_context.thickness = qBound(0, t, 100); ConfigHandler().setdrawThickness(m_context.thickness); emit thicknessChanged(m_context.thickness); } -void CaptureWidget::leftResize() { - if (m_selection->isVisible() && m_selection->geometry().right() > m_selection->geometry().left()) { - m_selection->setGeometry(m_selection->geometry() + QMargins(0, 0, -1, 0)); +void CaptureWidget::leftResize() +{ + if (m_selection->isVisible() && + m_selection->geometry().right() > m_selection->geometry().left()) { + m_selection->setGeometry(m_selection->geometry() + + QMargins(0, 0, -1, 0)); QRect newGeometry = m_selection->geometry().intersected(rect()); m_context.selection = extendedRect(&newGeometry); m_buttonHandler->updatePosition(m_selection->geometry()); @@ -783,9 +851,12 @@ void CaptureWidget::leftResize() { } } -void CaptureWidget::rightResize() { - if (m_selection->isVisible() && m_selection->geometry().right() < rect().right()) { - m_selection->setGeometry(m_selection->geometry() + QMargins(0, 0, 1, 0)); +void CaptureWidget::rightResize() +{ + if (m_selection->isVisible() && + m_selection->geometry().right() < rect().right()) { + m_selection->setGeometry(m_selection->geometry() + + QMargins(0, 0, 1, 0)); QRect newGeometry = m_selection->geometry().intersected(rect()); m_context.selection = extendedRect(&newGeometry); m_buttonHandler->updatePosition(m_selection->geometry()); @@ -794,9 +865,12 @@ void CaptureWidget::rightResize() { } } -void CaptureWidget::upResize() { - if (m_selection->isVisible() && m_selection->geometry().bottom() > m_selection->geometry().top()) { - m_selection->setGeometry(m_selection->geometry() + QMargins(0, 0, 0, -1)); +void CaptureWidget::upResize() +{ + if (m_selection->isVisible() && + m_selection->geometry().bottom() > m_selection->geometry().top()) { + m_selection->setGeometry(m_selection->geometry() + + QMargins(0, 0, 0, -1)); QRect newGeometry = m_selection->geometry().intersected(rect()); m_context.selection = extendedRect(&newGeometry); m_buttonHandler->updatePosition(m_selection->geometry()); @@ -805,9 +879,12 @@ void CaptureWidget::upResize() { } } -void CaptureWidget::downResize() { - if (m_selection->isVisible() && m_selection->geometry().bottom() < rect().bottom()) { - m_selection->setGeometry(m_selection->geometry() + QMargins(0, 0, 0, 1)); +void CaptureWidget::downResize() +{ + if (m_selection->isVisible() && + m_selection->geometry().bottom() < rect().bottom()) { + m_selection->setGeometry(m_selection->geometry() + + QMargins(0, 0, 0, 1)); QRect newGeometry = m_selection->geometry().intersected(rect()); m_context.selection = extendedRect(&newGeometry); m_buttonHandler->updatePosition(m_selection->geometry()); @@ -816,77 +893,108 @@ void CaptureWidget::downResize() { } } -void CaptureWidget::initShortcuts() { - QString shortcut = ConfigHandler().shortcut(QVariant::fromValue(CaptureButton::ButtonType::TYPE_EXIT).toString()); +void CaptureWidget::initShortcuts() +{ + QString shortcut = ConfigHandler().shortcut( + QVariant::fromValue(CaptureButton::ButtonType::TYPE_EXIT).toString()); new QShortcut(QKeySequence(shortcut), this, SLOT(close())); - shortcut = ConfigHandler().shortcut(QVariant::fromValue(CaptureButton::ButtonType::TYPE_SAVE).toString()); + shortcut = ConfigHandler().shortcut( + QVariant::fromValue(CaptureButton::ButtonType::TYPE_SAVE).toString()); new QShortcut(QKeySequence(shortcut), this, SLOT(saveScreenshot())); - shortcut = ConfigHandler().shortcut(QVariant::fromValue(CaptureButton::ButtonType::TYPE_COPY).toString()); + shortcut = ConfigHandler().shortcut( + QVariant::fromValue(CaptureButton::ButtonType::TYPE_COPY).toString()); new QShortcut(QKeySequence(shortcut), this, SLOT(copyScreenshot())); - shortcut = ConfigHandler().shortcut(QVariant::fromValue(CaptureButton::ButtonType::TYPE_UNDO).toString()); + shortcut = ConfigHandler().shortcut( + QVariant::fromValue(CaptureButton::ButtonType::TYPE_UNDO).toString()); new QShortcut(QKeySequence(shortcut), this, SLOT(undo())); - shortcut = ConfigHandler().shortcut(QVariant::fromValue(CaptureButton::ButtonType::TYPE_REDO).toString()); + shortcut = ConfigHandler().shortcut( + QVariant::fromValue(CaptureButton::ButtonType::TYPE_REDO).toString()); new QShortcut(QKeySequence(shortcut), this, SLOT(redo())); - shortcut = ConfigHandler().shortcut(QVariant::fromValue(CaptureButton::ButtonType::TYPE_IMAGEUPLOADER).toString()); + shortcut = ConfigHandler().shortcut( + QVariant::fromValue(CaptureButton::ButtonType::TYPE_IMAGEUPLOADER) + .toString()); new QShortcut(shortcut, this, SLOT(uploadScreenshot())); - new QShortcut(QKeySequence(ConfigHandler().shortcut("TYPE_TOGGLE_PANEL")), this, SLOT(togglePanel())); + new QShortcut(QKeySequence(ConfigHandler().shortcut("TYPE_TOGGLE_PANEL")), + this, + SLOT(togglePanel())); - new QShortcut(QKeySequence(ConfigHandler().shortcut("TYPE_RESIZE_LEFT")), this, SLOT(leftResize())); - new QShortcut(QKeySequence(ConfigHandler().shortcut("TYPE_RESIZE_RIGHT")), this, SLOT(rightResize())); - new QShortcut(QKeySequence(ConfigHandler().shortcut("TYPE_RESIZE_UP")), this, SLOT(upResize())); - new QShortcut(QKeySequence(ConfigHandler().shortcut("TYPE_RESIZE_DOWN")), this, SLOT(downResize())); + new QShortcut(QKeySequence(ConfigHandler().shortcut("TYPE_RESIZE_LEFT")), + this, + SLOT(leftResize())); + new QShortcut(QKeySequence(ConfigHandler().shortcut("TYPE_RESIZE_RIGHT")), + this, + SLOT(rightResize())); + new QShortcut(QKeySequence(ConfigHandler().shortcut("TYPE_RESIZE_UP")), + this, + SLOT(upResize())); + new QShortcut(QKeySequence(ConfigHandler().shortcut("TYPE_RESIZE_DOWN")), + this, + SLOT(downResize())); - new QShortcut(QKeySequence(ConfigHandler().shortcut("TYPE_MOVE_LEFT")), this, SLOT(leftMove())); - new QShortcut(QKeySequence(ConfigHandler().shortcut("TYPE_MOVE_RIGHT")), this, SLOT(rightMove())); - new QShortcut(QKeySequence(ConfigHandler().shortcut("TYPE_MOVE_UP")), this, SLOT(upMove())); - new QShortcut(QKeySequence(ConfigHandler().shortcut("TYPE_MOVE_DOWN")), this, SLOT(downMove())); + new QShortcut(QKeySequence(ConfigHandler().shortcut("TYPE_MOVE_LEFT")), + this, + SLOT(leftMove())); + new QShortcut(QKeySequence(ConfigHandler().shortcut("TYPE_MOVE_RIGHT")), + this, + SLOT(rightMove())); + new QShortcut(QKeySequence(ConfigHandler().shortcut("TYPE_MOVE_UP")), + this, + SLOT(upMove())); + new QShortcut(QKeySequence(ConfigHandler().shortcut("TYPE_MOVE_DOWN")), + this, + SLOT(downMove())); new QShortcut(Qt::Key_Escape, this, SLOT(deleteToolwidgetOrClose())); } -void CaptureWidget::updateSizeIndicator() { - if (m_sizeIndButton){ - const QRect &selection = extendedSelection(); +void CaptureWidget::updateSizeIndicator() +{ + if (m_sizeIndButton) { + const QRect& selection = extendedSelection(); m_sizeIndButton->setText(QStringLiteral("%1\n%2") - .arg(selection.width()) - .arg(selection.height())); + .arg(selection.width()) + .arg(selection.height())); } } -void CaptureWidget::updateCursor() { +void CaptureWidget::updateCursor() +{ if (m_rightClick) { setCursor(Qt::ArrowCursor); } else if (m_grabbing) { setCursor(Qt::ClosedHandCursor); } else if (!m_activeButton) { using sw = SelectionWidget; - if (m_mouseOverHandle != sw::NO_SIDE){ + if (m_mouseOverHandle != sw::NO_SIDE) { // cursor on the handlers switch (m_mouseOverHandle) { - case sw::TOPLEFT_SIDE: case sw::BOTTONRIGHT_SIDE: - setCursor(Qt::SizeFDiagCursor); - break; - case sw::TOPRIGHT_SIDE: case sw::BOTTONLEFT_SIDE: - setCursor(Qt::SizeBDiagCursor); - break; - case sw::LEFT_SIDE: case sw::RIGHT_SIDE: - setCursor(Qt::SizeHorCursor); - break; - case sw::TOP_SIDE: case sw::BOTTON_SIDE: - setCursor(Qt::SizeVerCursor); - break; - default: - break; + case sw::TOPLEFT_SIDE: + case sw::BOTTONRIGHT_SIDE: + setCursor(Qt::SizeFDiagCursor); + break; + case sw::TOPRIGHT_SIDE: + case sw::BOTTONLEFT_SIDE: + setCursor(Qt::SizeBDiagCursor); + break; + case sw::LEFT_SIDE: + case sw::RIGHT_SIDE: + setCursor(Qt::SizeHorCursor); + break; + case sw::TOP_SIDE: + case sw::BOTTON_SIDE: + setCursor(Qt::SizeVerCursor); + break; + default: + break; } } else if (m_selection->isVisible() && - m_selection->geometry().contains(m_context.mousePos)) - { + m_selection->geometry().contains(m_context.mousePos)) { setCursor(Qt::OpenHandCursor); } else { setCursor(Qt::CrossCursor); @@ -896,13 +1004,17 @@ void CaptureWidget::updateCursor() { } } -void CaptureWidget::pushToolToStack() { - auto mod = new ModificationCommand( - &m_context.screenshot, m_activeTool); - disconnect(this, &CaptureWidget::colorChanged, - m_activeTool, &CaptureTool::colorChanged); - disconnect(this, &CaptureWidget::thicknessChanged, - m_activeTool, &CaptureTool::thicknessChanged); +void CaptureWidget::pushToolToStack() +{ + auto mod = new ModificationCommand(&m_context.screenshot, m_activeTool); + disconnect(this, + &CaptureWidget::colorChanged, + m_activeTool, + &CaptureTool::colorChanged); + disconnect(this, + &CaptureWidget::thicknessChanged, + m_activeTool, + &CaptureTool::thicknessChanged); if (m_panel->toolWidget()) { disconnect(m_panel->toolWidget(), nullptr, m_activeTool, nullptr); } @@ -910,39 +1022,48 @@ void CaptureWidget::pushToolToStack() { m_activeTool = nullptr; } -void CaptureWidget::makeChild(QWidget *w) { +void CaptureWidget::makeChild(QWidget* w) +{ w->setParent(this); w->installEventFilter(m_eventFilter); } -void CaptureWidget::togglePanel() { +void CaptureWidget::togglePanel() +{ m_panel->toggle(); } -void CaptureWidget::childEnter() { +void CaptureWidget::childEnter() +{ m_previewEnabled = false; update(); } -void CaptureWidget::childLeave() { +void CaptureWidget::childLeave() +{ m_previewEnabled = true; update(); } -void CaptureWidget::uploadScreenshot() { - m_activeTool = new ImgS3UploaderTool(); +void CaptureWidget::uploadScreenshot() +{ + StorageManager storageManager; + m_activeTool = + storageManager.imgUploaderTool(ConfigHandler().uploadStorage()); m_activeTool->setCapture(pixmap()); handleButtonSignal(CaptureTool::REQ_ADD_EXTERNAL_WIDGETS); close(); } -void CaptureWidget::copyScreenshot() { +void CaptureWidget::copyScreenshot() +{ m_captureDone = true; ScreenshotSaver().saveToClipboard(pixmap()); close(); } -void CaptureWidget::saveScreenshot() { +void CaptureWidget::saveScreenshot() +{ m_captureDone = true; hide(); if (m_context.savePath.isEmpty()) { @@ -953,25 +1074,29 @@ void CaptureWidget::saveScreenshot() { close(); } -void CaptureWidget::undo() { +void CaptureWidget::undo() +{ m_undoStack.undo(); } -void CaptureWidget::redo() { +void CaptureWidget::redo() +{ m_undoStack.redo(); } -QRect CaptureWidget::extendedSelection() const { +QRect CaptureWidget::extendedSelection() const +{ if (!m_selection->isVisible()) return QRect(); QRect r = m_selection->geometry(); return extendedRect(&r); } -QRect CaptureWidget::extendedRect(QRect *r) const { +QRect CaptureWidget::extendedRect(QRect* r) const +{ auto devicePixelRatio = m_context.screenshot.devicePixelRatio(); - return QRect(r->left() * devicePixelRatio, - r->top() * devicePixelRatio, - r->width() * devicePixelRatio, + return QRect(r->left() * devicePixelRatio, + r->top() * devicePixelRatio, + r->width() * devicePixelRatio, r->height() * devicePixelRatio); } diff --git a/src/widgets/historywidget.cpp b/src/widgets/historywidget.cpp index f313b543..85048111 100644 --- a/src/widgets/historywidget.cpp +++ b/src/widgets/historywidget.cpp @@ -1,26 +1,30 @@ #include "historywidget.h" +#include "src/tools/storage/storagemanager.h" +#include "src/tools/storage/imguploader.h" +#include "src/tools/storage/s3/imgs3uploader.h" #include "src/utils/history.h" #include "src/widgets/notificationwidget.h" -#include "src/tools/imgs3/imgs3uploader.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include -#include #include -#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include -HistoryWidget::HistoryWidget(QWidget *parent) : QDialog(parent) +HistoryWidget::HistoryWidget(QWidget* parent) + : QDialog(parent) { setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowTitle(tr("Latest Uploads")); @@ -30,114 +34,128 @@ HistoryWidget::HistoryWidget(QWidget *parent) : QDialog(parent) m_pVBox = new QVBoxLayout(this); m_pVBox->setAlignment(Qt::AlignTop); - QScrollArea *scrollArea = new QScrollArea( this ); - scrollArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn ); - scrollArea->setWidgetResizable( true ); - scrollArea->setGeometry( this->frameGeometry() ); + QScrollArea* scrollArea = new QScrollArea(this); + scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); + scrollArea->setWidgetResizable(true); + scrollArea->setGeometry(this->frameGeometry()); - QWidget *widget = new QWidget(); - scrollArea->setWidget( widget ); - widget->setLayout( m_pVBox ); + QWidget* widget = new QWidget(); + scrollArea->setWidget(widget); + widget->setLayout(m_pVBox); loadHistory(); } -void HistoryWidget::loadHistory() { +void HistoryWidget::loadHistory() +{ // read history files History history = History(); QList historyFiles = history.history(); - if(historyFiles.isEmpty()) { + if (historyFiles.isEmpty()) { setEmptyMessage(); - } - else { + } else { // generate history list - foreach(QString fileName, historyFiles) { + foreach (QString fileName, historyFiles) { addLine(history.path(), fileName); } } } -void HistoryWidget::setEmptyMessage() { - QPushButton *buttonEmpty = new QPushButton; +void HistoryWidget::setEmptyMessage() +{ + QPushButton* buttonEmpty = new QPushButton; buttonEmpty->setText(tr("Screenshots history is empty")); buttonEmpty->setMinimumSize(1, HISTORYPIXMAP_MAX_PREVIEW_HEIGHT); - connect(buttonEmpty, &QPushButton::clicked, this, [=](){ - this->close(); - }); + connect(buttonEmpty, &QPushButton::clicked, this, [=]() { this->close(); }); m_pVBox->addWidget(buttonEmpty); } -void HistoryWidget::addLine(const QString &path, const QString& fileName) { - QHBoxLayout *phbl = new QHBoxLayout(); +void HistoryWidget::addLine(const QString& path, const QString& fileName) +{ + QHBoxLayout* phbl = new QHBoxLayout(); QString fullFileName = path + fileName; History history; HISTORY_FILE_NAME unpackFileName = history.unpackFileName(fileName); - QString url = m_s3Settings.url() + unpackFileName.file; + QString url; + + StorageManager storageManager; + url = storageManager.storageUrl(unpackFileName.type) + unpackFileName.file; // load pixmap QPixmap pixmap; - pixmap.load( fullFileName, "png" ); + pixmap.load(fullFileName, "png"); - if (pixmap.height() / HISTORYPIXMAP_MAX_PREVIEW_HEIGHT >= pixmap.width() / HISTORYPIXMAP_MAX_PREVIEW_WIDTH) { + if (pixmap.height() / HISTORYPIXMAP_MAX_PREVIEW_HEIGHT >= + pixmap.width() / HISTORYPIXMAP_MAX_PREVIEW_WIDTH) { pixmap = pixmap.scaledToHeight(HISTORYPIXMAP_MAX_PREVIEW_HEIGHT); } else { pixmap = pixmap.scaledToWidth(HISTORYPIXMAP_MAX_PREVIEW_WIDTH); } // get file info - QFileInfo *pFileInfo = new QFileInfo(fullFileName); - QString lastModified = pFileInfo->lastModified().toString(" yyyy-MM-dd\nhh:mm:ss"); + QFileInfo* pFileInfo = new QFileInfo(fullFileName); + QString lastModified = + pFileInfo->lastModified().toString(" yyyy-MM-dd\nhh:mm:ss"); // screenshot preview - QLabel *pScreenshot = new QLabel(); + QLabel* pScreenshot = new QLabel(); pScreenshot->setStyleSheet("padding: 5px;"); pScreenshot->setMinimumHeight(HISTORYPIXMAP_MAX_PREVIEW_HEIGHT); pScreenshot->setPixmap(pixmap); // screenshot datetime - QLabel *pScreenshotText = new QLabel(); + QLabel* pScreenshotText = new QLabel(); pScreenshotText->setStyleSheet("padding: 5px;"); pScreenshotText->setMinimumHeight(HISTORYPIXMAP_MAX_PREVIEW_HEIGHT); pScreenshotText->setAlignment(Qt::AlignCenter); pScreenshotText->setText(lastModified); // copy url - QPushButton *buttonCopyUrl = new QPushButton; + QPushButton* buttonCopyUrl = new QPushButton; buttonCopyUrl->setText(tr("Copy URL")); buttonCopyUrl->setMinimumHeight(HISTORYPIXMAP_MAX_PREVIEW_HEIGHT); - connect(buttonCopyUrl, &QPushButton::clicked, this, [=](){ + connect(buttonCopyUrl, &QPushButton::clicked, this, [=]() { QApplication::clipboard()->setText(url); m_notification->showMessage(tr("URL copied to clipboard.")); this->close(); }); // open in browser - QPushButton *buttonOpen = new QPushButton; + QPushButton* buttonOpen = new QPushButton; buttonOpen->setText(tr("Open in browser")); buttonOpen->setMinimumHeight(HISTORYPIXMAP_MAX_PREVIEW_HEIGHT); - connect(buttonOpen, &QPushButton::clicked, this, [=](){ + connect(buttonOpen, &QPushButton::clicked, this, [=]() { QDesktopServices::openUrl(QUrl(url)); this->close(); }); // delete - QPushButton *buttonDelete = new QPushButton; + QPushButton* buttonDelete = new QPushButton; buttonDelete->setIcon(QIcon(":/img/material/black/delete.svg")); buttonDelete->setMinimumHeight(HISTORYPIXMAP_MAX_PREVIEW_HEIGHT); - connect(buttonDelete, &QPushButton::clicked, this, [=](){ - if (unpackFileName.token.length() > 0) { - removeItem(phbl, unpackFileName.file, unpackFileName.token); - } - else { - // for compatibility with previous versions and to be able to remove previous screenshots - QFile file(fullFileName); - if (file.exists()) { - file.remove(); + connect(buttonDelete, &QPushButton::clicked, this, [=]() { + // TODO - remove dependency injection (s3 & imgur) + if (unpackFileName.type.compare(SCREENSHOT_STORAGE_TYPE_S3) == 0) { + if (unpackFileName.token.length() > 0) { + ImgS3Uploader* uploader = new ImgS3Uploader(); + removeItem( + uploader, phbl, unpackFileName.file, unpackFileName.token); + } else { + // for compatibility with previous versions and to be able to + // remove previous screenshots + removeCacheFile(fullFileName); + removeLayoutItem(phbl); } - removeLocalItem(phbl); + } else if (unpackFileName.type.compare(SCREENSHOT_STORAGE_TYPE_IMGUR) == + 0) { + QDesktopServices::openUrl( + QUrl(QStringLiteral("https://imgur.com/delete/%1") + .arg(unpackFileName.token))); + removeCacheFile(fullFileName); + removeLayoutItem(phbl); } }); @@ -158,23 +176,27 @@ void HistoryWidget::addLine(const QString &path, const QString& fileName) { m_pVBox->addLayout(phbl); } -void HistoryWidget::removeItem(QLayout *pl, const QString& s3FileName, const QString& deleteToken) { - ImgS3Uploader *uploader = new ImgS3Uploader(); +void HistoryWidget::removeItem(ImgUploader* imgUploader, + QLayout* pl, + const QString& fileName, + const QString& deleteToken) +{ hide(); - uploader->show(); - uploader->deleteResource(s3FileName, deleteToken); - connect(uploader, &QWidget::destroyed, this, [=](){ - if(uploader->success()) { - removeLocalItem(pl); + imgUploader->show(); + imgUploader->deleteResource(fileName, deleteToken); + connect(imgUploader, &QWidget::destroyed, this, [=]() { + if (imgUploader->resultStatus) { + removeLayoutItem(pl); } show(); }); } -void HistoryWidget::removeLocalItem(QLayout *pl) { +void HistoryWidget::removeLayoutItem(QLayout* pl) +{ // remove current row or refresh list - while(pl->count() > 0) { - QLayoutItem *item = pl->takeAt(0); + while (pl->count() > 0) { + QLayoutItem* item = pl->takeAt(0); delete item->widget(); delete item; } @@ -182,7 +204,16 @@ void HistoryWidget::removeLocalItem(QLayout *pl) { delete pl; // set "empty" message if no items left - if(m_pVBox->count() == 0) { + if (m_pVBox->count() == 0) { setEmptyMessage(); } } + +void HistoryWidget::removeCacheFile(const QString& fullFileName) +{ + // premove history preview + QFile file(fullFileName); + if (file.exists()) { + file.remove(); + } +} diff --git a/src/widgets/historywidget.h b/src/widgets/historywidget.h index b29cb000..0d88098a 100644 --- a/src/widgets/historywidget.h +++ b/src/widgets/historywidget.h @@ -4,35 +4,38 @@ #define HISTORYPIXMAP_MAX_PREVIEW_WIDTH 160 #define HISTORYPIXMAP_MAX_PREVIEW_HEIGHT 90 -#include -#include #include +#include #include -#include "src/tools/imgs3/imgs3settings.h" +#include class QLayout; class QVBoxLayout; class NotificationWidget; +class ImgUploader; class HistoryWidget : public QDialog { Q_OBJECT public: - explicit HistoryWidget(QWidget *parent = nullptr); + explicit HistoryWidget(QWidget* parent = nullptr); signals: private: void loadHistory(); - void addLine(const QString &, const QString &); - void removeItem(QLayout *pl, const QString& s3FileName, const QString& deleteToken); - void removeLocalItem(QLayout *pl); + void addLine(const QString&, const QString&); void setEmptyMessage(); + void removeItem(ImgUploader* imgUploader, + QLayout* pl, + const QString& s3FileName, + const QString& deleteToken); + void removeLayoutItem(QLayout* pl); + void removeCacheFile(const QString& fullFileName); private: - ImgS3Settings m_s3Settings; - QVBoxLayout *m_pVBox; - NotificationWidget *m_notification; + QVBoxLayout* m_pVBox; + NotificationWidget* m_notification; }; #endif // HISTORYWIDGET_H diff --git a/translations/Internationalization_ca.ts b/translations/Internationalization_ca.ts index 3b7fbcaa..adcebf6b 100644 --- a/translations/Internationalization_ca.ts +++ b/translations/Internationalization_ca.ts @@ -125,13 +125,13 @@ CaptureWidget - + Unable to capture screen Impossible capturar la pantalla Imposible capturar la pantalla - + Select an area with the mouse, or press Esc to exit. Press Enter to capture the screen. Press Right Click to show the color picker. @@ -156,32 +156,27 @@ Press Space to open the side panel. ConfigWindow - + Configuration Configuració - + Interface Interfície - + Filename Editor Editor de noms - + Shortcuts - - Path Default - - - - + General General @@ -332,152 +327,167 @@ Press Space to open the side panel. GeneneralConf - + Show help message Mostra el missatge d'ajuda - + Show the help message at the beginning in the capture mode. Mostra el missatge d'ajuda en iniciar el mode de captura. - - + + Show desktop notifications Mostra les notificacions d'escriptori - + Show tray icon Mostra la icona en la barra de tasques - + Show the systemtray icon Mostra la icona en la barra de tasques - - + + Import Importar - - - + + + Error Error - + Unable to read file. Impossible llegir el fitxer. - - + + Unable to write file. Impossible escriure al fitxer. - + Save File Guardar Arxiu - + Confirm Reset Confirmar Reset - + Are you sure you want to reset the configuration? Esteu segur que voleu reiniciar la configuració? - + Configuration File Fitxer de Configuració - + Export Exportar - + Reset Reset - + Launch at startup Llançament a l'inici - - + + Launch Flameshot - + Show welcome message on launch - + Close application after capture - + Close after taking a screenshot - + Copy URL after upload - + Copy URL and close window after upload - - + + Copy file path after save + + + Upload storage + + + + + Imgur storage + + + + + S3 storage (require config.ini file with s3 credentials) + + HistoryWidget - + Latest Uploads - + Screenshots history is empty - + Copy URL Copia l'URL - + URL copied to clipboard. L'URL s'ha copiat al porta-retalls. - + Open in browser @@ -485,164 +495,199 @@ Press Space to open the side panel. ImgS3Uploader - + Uploading Image S'està pujant la imatge - + Upload image to S3 - + Delete image from S3 - + Unable to remove screenshot from the remote storage. - + Network error - + Possibly it doesn't exist anymore - + Do you want to remove screenshot from local history anyway? - + S3 Creds URL is not found in your configuration file - Copy URL - Copia l'URL + Copia l'URL - Open URL - Obri l'URL + Obri l'URL - - Delete image - - - - Image to Clipboard. - Imatge al porta-retalls. + Imatge al porta-retalls. - Unable to open the URL. - No es pot obrir l'URL. + No es pot obrir l'URL. - - + URL copied to clipboard. L'URL s'ha copiat al porta-retalls. - - + Deleting image... - + Remove screenshot from history? - Screenshot copied to clipboard. - La captura s'ha copiat al porta-retalls. + La captura s'ha copiat al porta-retalls. ImgS3UploaderTool - + Image Uploader Puja la imatge - + Upload the selection to S3 bucket + + ImgUploader + + + Upload image to S3 + + + + + + Uploading Image + S'està pujant la imatge + + + + Upload image + + + + + Unable to open the URL. + No es pot obrir l'URL. + + + + URL copied to clipboard. + L'URL s'ha copiat al porta-retalls. + + + + Screenshot copied to clipboard. + La captura s'ha copiat al porta-retalls. + + + + Deleting image... + + + + + Copy URL + Copia l'URL + + + + Open URL + Obri l'URL + + + + Delete image + + + + + Image to Clipboard. + Imatge al porta-retalls. + + ImgurUploader - + Upload to Imgur Puja a Imgur - Uploading Image - S'està pujant la imatge + S'està pujant la imatge - Copy URL - Copia l'URL + Copia l'URL - Open URL - Obri l'URL + Obri l'URL - Image to Clipboard. - Imatge al porta-retalls. + Imatge al porta-retalls. - - + Unable to open the URL. No es pot obrir l'URL. - URL copied to clipboard. - L'URL s'ha copiat al porta-retalls. + L'URL s'ha copiat al porta-retalls. - Screenshot copied to clipboard. - La captura s'ha copiat al porta-retalls. - - - - Delete image - + La captura s'ha copiat al porta-retalls. ImgurUploaderTool - + Image Uploader Puja la imatge - + Upload the selection to Imgur Puja la selecció a Imgur @@ -840,7 +885,7 @@ Press Space to open the side panel. - + URL copied to clipboard. L'URL s'ha copiat al porta-retalls. diff --git a/translations/Internationalization_de_DE.ts b/translations/Internationalization_de_DE.ts index 33be19a9..34518205 100644 --- a/translations/Internationalization_de_DE.ts +++ b/translations/Internationalization_de_DE.ts @@ -125,12 +125,12 @@ CaptureWidget - + Unable to capture screen Bereich kann nicht erfasst werden - + Select an area with the mouse, or press Esc to exit. Press Enter to capture the screen. Press Right Click to show the color picker. @@ -159,32 +159,27 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. ConfigWindow - + Configuration Einstellungen - + Interface Benutzeroberfläche - + Filename Editor Dateinamen Editor - + Shortcuts - - Path Default - - - - + General Allgemein @@ -335,152 +330,167 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. GeneneralConf - - + + Import Importieren - - - + + + Error Fehler - + Unable to read file. Datei kann nicht gelesen werden. - - + + Unable to write file. Datei kann nicht geschrieben werden. - + Save File Datei speichern - + Confirm Reset Zurücksetzen bestätigen - + Are you sure you want to reset the configuration? Sind Sie sicher, dass sie die Konfiguration zurücksetzen wollen? - + Show help message Hilfetext anzeigen - + Show the help message at the beginning in the capture mode. Hilfetext am Start der Auswahl anzeigen. - - + + Show desktop notifications Zeige Desktopbenachrichtigungen - + Show tray icon Zeige Taskleistensymbol - + Show the systemtray icon Zeigt das Taskleistensymbol - + Configuration File Konfigurationsdatei - + Export Exportieren - + Reset Zurücksetzen - + Launch at startup Automatisch starten - - + + Launch Flameshot Starte Flameshot - + Show welcome message on launch - + Close application after capture - + Close after taking a screenshot - + Copy URL after upload - + Copy URL and close window after upload - - + + Copy file path after save + + + Upload storage + + + + + Imgur storage + + + + + S3 storage (require config.ini file with s3 credentials) + + HistoryWidget - + Latest Uploads - + Screenshots history is empty - + Copy URL URL kopieren - + URL copied to clipboard. URL kopiert. - + Open in browser @@ -488,164 +498,207 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. ImgS3Uploader - + Uploading Image Bild hochladen - + Upload image to S3 - + Delete image from S3 - + Unable to remove screenshot from the remote storage. - + Network error - + Possibly it doesn't exist anymore - + Do you want to remove screenshot from local history anyway? - + S3 Creds URL is not found in your configuration file - Copy URL - URL kopieren + URL kopieren - Open URL - URL öffnen + URL öffnen - Delete image - Bild löschen + Bild löschen - Image to Clipboard. - Bild in Zwischenablage. + Bild in Zwischenablage. - Unable to open the URL. - Kann URL nicht öffnen. + Kann URL nicht öffnen. - - + URL copied to clipboard. URL kopiert. - - + Deleting image... - + Remove screenshot from history? - Screenshot copied to clipboard. - Bildschirmaufnahme in Zwischenablage kopiert. + Bildschirmaufnahme in Zwischenablage kopiert. ImgS3UploaderTool - + Image Uploader Bild hochladen - + Upload the selection to S3 bucket + + ImgUploader + + + Upload image to S3 + + + + + + Uploading Image + Bild hochladen + + + + Upload image + + + + + Unable to open the URL. + Kann URL nicht öffnen. + + + + URL copied to clipboard. + URL kopiert. + + + + Screenshot copied to clipboard. + Bildschirmaufnahme in Zwischenablage kopiert. + + + + Deleting image... + + + + + Copy URL + URL kopieren + + + + Open URL + URL öffnen + + + + Delete image + Bild löschen + + + + Image to Clipboard. + Bild in Zwischenablage. + + ImgurUploader - + Upload to Imgur Zu Imgur hochladen - Uploading Image - Bild hochladen + Bild hochladen - Copy URL - URL kopieren + URL kopieren - Open URL - URL öffnen + URL öffnen - Delete image - Bild löschen + Bild löschen - Image to Clipboard. - Bild in Zwischenablage. + Bild in Zwischenablage. - - + Unable to open the URL. Kann URL nicht öffnen. - URL copied to clipboard. - URL kopiert. + URL kopiert. - Screenshot copied to clipboard. - Bildschirmaufnahme in Zwischenablage kopiert. + Bildschirmaufnahme in Zwischenablage kopiert. ImgurUploaderTool - + Image Uploader Bild hochladen - + Upload the selection to Imgur Auswahl zu Imgur hochladen @@ -851,7 +904,7 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. Kein Schreibzugriff auf - + URL copied to clipboard. URL kopiert. diff --git a/translations/Internationalization_es.ts b/translations/Internationalization_es.ts index 77ebce9d..76d981fa 100644 --- a/translations/Internationalization_es.ts +++ b/translations/Internationalization_es.ts @@ -125,12 +125,12 @@ CaptureWidget - + Unable to capture screen Imposible capturar la pantalla - + Select an area with the mouse, or press Esc to exit. Press Enter to capture the screen. Press Right Click to show the color picker. @@ -159,32 +159,27 @@ Presiona Espacio para abrir el panel lateral. ConfigWindow - + Configuration Configuración - + Interface Interfaz - + Filename Editor Editor de Nombre - + Shortcuts - - Path Default - - - - + General General @@ -335,152 +330,167 @@ Presiona Espacio para abrir el panel lateral. GeneneralConf - - + + Import Importar - - - + + + Error Error - + Unable to read file. Imposible leer el archivo. - - + + Unable to write file. Imposible escribir el archivo. - + Save File Guardar Archivo - + Confirm Reset Confirmar Reset - + Are you sure you want to reset the configuration? ¿Estás seguro de que quieres reiniciar la configuración? - + Show help message Mostrar mensaje de ayuda - + Show the help message at the beginning in the capture mode. Muestra el mensaje de ayuda al iniciar el modo de captura. - - + + Show desktop notifications Mostrar notificaciones del escritorio - + Show tray icon Mostrar icono en la barra de tareas - + Show the systemtray icon Mostrar el icono en la barra de tareas - + Configuration File Archivo de Configuración - + Export Exportar - + Reset Reset - + Launch at startup Lanzar en el arranque - - + + Launch Flameshot Lanzar Flameshot - + Show welcome message on launch - + Close application after capture - + Close after taking a screenshot - + Copy URL after upload - + Copy URL and close window after upload - - + + Copy file path after save + + + Upload storage + + + + + Imgur storage + + + + + S3 storage (require config.ini file with s3 credentials) + + HistoryWidget - + Latest Uploads - + Screenshots history is empty - + Copy URL Copiar URL - + URL copied to clipboard. URL copiada al portapapeles. - + Open in browser @@ -488,164 +498,207 @@ Presiona Espacio para abrir el panel lateral. ImgS3Uploader - + Uploading Image Subiendo Imagen - + Upload image to S3 - + Delete image from S3 - + Unable to remove screenshot from the remote storage. - + Network error - + Possibly it doesn't exist anymore - + Do you want to remove screenshot from local history anyway? - + S3 Creds URL is not found in your configuration file - Copy URL - Copiar URL + Copiar URL - Open URL - Abrir URL + Abrir URL - Delete image - Borrar imagen + Borrar imagen - Image to Clipboard. - Imagen al Portapapeles. + Imagen al Portapapeles. - Unable to open the URL. - No puede abrir la URL. + No puede abrir la URL. - - + URL copied to clipboard. URL copiada al portapapeles. - - + Deleting image... - + Remove screenshot from history? - Screenshot copied to clipboard. - Captura copiada al portapapeles. + Captura copiada al portapapeles. ImgS3UploaderTool - + Image Uploader Subir Imagen - + Upload the selection to S3 bucket + + ImgUploader + + + Upload image to S3 + + + + + + Uploading Image + Subiendo Imagen + + + + Upload image + + + + + Unable to open the URL. + No puede abrir la URL. + + + + URL copied to clipboard. + URL copiada al portapapeles. + + + + Screenshot copied to clipboard. + Captura copiada al portapapeles. + + + + Deleting image... + + + + + Copy URL + Copiar URL + + + + Open URL + Abrir URL + + + + Delete image + Borrar imagen + + + + Image to Clipboard. + Imagen al Portapapeles. + + ImgurUploader - + Upload to Imgur Subir a Imgur - Uploading Image - Subiendo Imagen + Subiendo Imagen - Copy URL - Copiar URL + Copiar URL - Open URL - Abrir URL + Abrir URL - Delete image - Borrar imagen + Borrar imagen - Image to Clipboard. - Imagen al Portapapeles. + Imagen al Portapapeles. - - + Unable to open the URL. No puede abrir la URL. - URL copied to clipboard. - URL copiada al portapapeles. + URL copiada al portapapeles. - Screenshot copied to clipboard. - Captura copiada al portapapeles. + Captura copiada al portapapeles. ImgurUploaderTool - + Image Uploader Subir Imagen - + Upload the selection to Imgur Sube la selección a Imgur @@ -847,7 +900,7 @@ Presiona Espacio para abrir el panel lateral. Imposible escribir en - + URL copied to clipboard. URL copiada al portapapeles. diff --git a/translations/Internationalization_fr.ts b/translations/Internationalization_fr.ts index ad86d1a1..ede9c812 100644 --- a/translations/Internationalization_fr.ts +++ b/translations/Internationalization_fr.ts @@ -125,12 +125,12 @@ CaptureWidget - + Unable to capture screen Imposible de capturer l'écran - + Select an area with the mouse, or press Esc to exit. Press Enter to capture the screen. Press Right Click to show the color picker. @@ -159,32 +159,27 @@ Appuyer sur Espace pour ouvrir le panneau latéral. ConfigWindow - + Configuration Configuration - + Interface Interface - + Filename Editor Editeur de Noms - + Shortcuts - - Path Default - - - - + General Général @@ -335,152 +330,167 @@ Appuyer sur Espace pour ouvrir le panneau latéral. GeneneralConf - - + + Import Importer - - - + + + Error Erreur - + Unable to read file. Impossible de lire le fichier. - - + + Unable to write file. Impossible d'écrire le fichier. - + Save File Sauvegarder le fichier - + Confirm Reset Confirmer la Réinitialisation - + Are you sure you want to reset the configuration? Êtes-vous sûr de vouloir réinitialiser la configuration ? - + Show help message Montrer le message d'aide - + Show the help message at the beginning in the capture mode. Afficher ce message au lancement du mode capture. - - + + Show desktop notifications Afficher les notifications du bureau - + Show tray icon Afficher les icones de la barre d'état - + Show the systemtray icon Afficher l'icône dans la barre de tâches - + Configuration File Fichier de Configuration - + Export Exporter - + Reset Réinitialiser - + Launch at startup Lancer au démarrage - - + + Launch Flameshot Démarrer Flameshot - + Show welcome message on launch - + Close application after capture Fermer après une capture - + Close after taking a screenshot Fermer l'application après une capture d'écran - + Copy URL after upload - + Copy URL and close window after upload - - + + Copy file path after save + + + Upload storage + + + + + Imgur storage + + + + + S3 storage (require config.ini file with s3 credentials) + + HistoryWidget - + Latest Uploads - + Screenshots history is empty - + Copy URL Copier l'URL - + URL copied to clipboard. URL copiée dans le Presse-papier. - + Open in browser @@ -488,164 +498,199 @@ Appuyer sur Espace pour ouvrir le panneau latéral. ImgS3Uploader - + Uploading Image Mise en ligne de l'image - + Upload image to S3 - + Delete image from S3 - + Unable to remove screenshot from the remote storage. - + Network error - + Possibly it doesn't exist anymore - + Do you want to remove screenshot from local history anyway? - + S3 Creds URL is not found in your configuration file - Copy URL - Copier l'URL + Copier l'URL - Open URL - Ouvrir l'URL + Ouvrir l'URL - - Delete image - - - - Image to Clipboard. - Image dans le Presse-papier. + Image dans le Presse-papier. - Unable to open the URL. - Impossible d'ouvrir l'URL. + Impossible d'ouvrir l'URL. - - + URL copied to clipboard. URL copiée dans le Presse-papier. - - + Deleting image... - + Remove screenshot from history? - Screenshot copied to clipboard. - Capture d'écran copiée dans le Presse-papier. + Capture d'écran copiée dans le Presse-papier. ImgS3UploaderTool - + Image Uploader Mise en ligne d'images - + Upload the selection to S3 bucket - ImgurUploader + ImgUploader - - Upload to Imgur - Mettre en ligne vers Imgur + + Upload image to S3 + - + + Uploading Image - Mise en ligne de l'image + Mise en ligne de l'image - + + Upload image + + + + + Unable to open the URL. + Impossible d'ouvrir l'URL. + + + + URL copied to clipboard. + URL copiée dans le Presse-papier. + + + + Screenshot copied to clipboard. + Capture d'écran copiée dans le Presse-papier. + + + + Deleting image... + + + + Copy URL - Copier l'URL + Copier l'URL - + Open URL - Ouvrir l'URL + Ouvrir l'URL - + Delete image - + Image to Clipboard. - Image dans le Presse-papier. + Image dans le Presse-papier. + + + + ImgurUploader + + + Upload to Imgur + Mettre en ligne vers Imgur - - + Uploading Image + Mise en ligne de l'image + + + Copy URL + Copier l'URL + + + Open URL + Ouvrir l'URL + + + Image to Clipboard. + Image dans le Presse-papier. + + + Unable to open the URL. Impossible d'ouvrir l'URL. - URL copied to clipboard. - URL copiée dans le Presse-papier. + URL copiée dans le Presse-papier. - Screenshot copied to clipboard. - Capture d'écran copiée dans le Presse-papier. + Capture d'écran copiée dans le Presse-papier. ImgurUploaderTool - + Image Uploader Mise en ligne d'images - + Upload the selection to Imgur Mettre en ligne la sélection vers Imgur @@ -843,7 +888,7 @@ Appuyer sur Espace pour ouvrir le panneau latéral. Imposible d'écrire par dessus - + URL copied to clipboard. URL copiée dans le Presse-papier. diff --git a/translations/Internationalization_hu.ts b/translations/Internationalization_hu.ts index c4fa8b2f..054c02d7 100644 --- a/translations/Internationalization_hu.ts +++ b/translations/Internationalization_hu.ts @@ -154,10 +154,6 @@ Press Space to open the side panel. General Általános - - Path Default - - Shortcuts @@ -393,6 +389,18 @@ Press Space to open the side panel. Copy file path after save + + Upload storage + + + + Imgur storage + + + + S3 storage (require config.ini file with s3 credentials) + + HistoryWidget @@ -425,19 +433,19 @@ Press Space to open the side panel. Copy URL - URL másolása + URL másolása Open URL - URL megnyitása + URL megnyitása Image to Clipboard. - Kép a vágolapra. + Kép a vágolapra. Unable to open the URL. - Nem lehet az URL-t megnyitni. + Nem lehet az URL-t megnyitni. URL copied to clipboard. @@ -445,7 +453,7 @@ Press Space to open the side panel. Screenshot copied to clipboard. - Képernyőmentés másolva a vágólapra. + Képernyőmentés másolva a vágólapra. Upload image to S3 @@ -455,10 +463,6 @@ Press Space to open the side panel. Delete image from S3 - - Delete image - - S3 Creds URL is not found in your configuration file @@ -499,6 +503,53 @@ Press Space to open the side panel. + + ImgUploader + + Upload image to S3 + + + + Uploading Image + Kép felötlése + + + Upload image + + + + Unable to open the URL. + Nem lehet az URL-t megnyitni. + + + URL copied to clipboard. + URL másolva a vágólapra. + + + Screenshot copied to clipboard. + Képernyőmentés másolva a vágólapra. + + + Deleting image... + + + + Copy URL + URL másolása + + + Open URL + URL megnyitása + + + Delete image + + + + Image to Clipboard. + Kép a vágolapra. + + ImgurUploader @@ -507,19 +558,19 @@ Press Space to open the side panel. Uploading Image - Kép felötlése + Kép felötlése Copy URL - URL másolása + URL másolása Open URL - URL megnyitása + URL megnyitása Image to Clipboard. - Kép a vágolapra. + Kép a vágolapra. Unable to open the URL. @@ -527,15 +578,11 @@ Press Space to open the side panel. URL copied to clipboard. - URL másolva a vágólapra. + URL másolva a vágólapra. Screenshot copied to clipboard. - Képernyőmentés másolva a vágólapra. - - - Delete image - + Képernyőmentés másolva a vágólapra. diff --git a/translations/Internationalization_ja.ts b/translations/Internationalization_ja.ts index 2f295ffe..96698057 100644 --- a/translations/Internationalization_ja.ts +++ b/translations/Internationalization_ja.ts @@ -125,12 +125,12 @@ CaptureWidget - + Unable to capture screen 画面をキャプチャーできません - + Select an area with the mouse, or press Esc to exit. Press Enter to capture the screen. Press Right Click to show the color picker. @@ -159,32 +159,27 @@ Enter を押すと画面をキャプチャー。 ConfigWindow - + Configuration 設定 - + Interface インターフェース - + Filename Editor ファイル名エディター - + Shortcuts - - Path Default - - - - + General 全般 @@ -335,152 +330,167 @@ Enter を押すと画面をキャプチャー。 GeneneralConf - + Show help message ヘルプメッセージを表示する - + Show the help message at the beginning in the capture mode. キャプチャーモード開始時にヘルプメッセージを表示する。 - - + + Show desktop notifications デスクトップの通知を表示する - + Show tray icon トレイアイコンを表示する - + Show the systemtray icon システムトレイアイコンを表示する - - + + Import インポート - - - + + + Error エラー - + Unable to read file. ファイルを読み込めません。 - - + + Unable to write file. ファイルに書き込めません。 - + Save File ファイルを保存 - + Confirm Reset リセットの確認 - + Are you sure you want to reset the configuration? 設定をリセットしてもよろしいですか? - + Configuration File 設定ファイル - + Export エクスポート - + Reset リセット - + Launch at startup スタートアップ時に起動する - - + + Launch Flameshot Flameshot を起動する - + Show welcome message on launch - + Close application after capture - + Close after taking a screenshot - + Copy URL after upload - + Copy URL and close window after upload - - + + Copy file path after save + + + Upload storage + + + + + Imgur storage + + + + + S3 storage (require config.ini file with s3 credentials) + + HistoryWidget - + Latest Uploads - + Screenshots history is empty - + Copy URL URL をコピー - + URL copied to clipboard. URL をクリップボードにコピーしました。 - + Open in browser @@ -488,164 +498,207 @@ Enter を押すと画面をキャプチャー。 ImgS3Uploader - + Uploading Image 画像をアップロード中 - + Upload image to S3 - + Delete image from S3 - + Unable to remove screenshot from the remote storage. - + Network error - + Possibly it doesn't exist anymore - + Do you want to remove screenshot from local history anyway? - + S3 Creds URL is not found in your configuration file - Copy URL - URL をコピー + URL をコピー - Open URL - URL を開く + URL を開く - Delete image - 画像を削除 + 画像を削除 - Image to Clipboard. - 画像をクリップボードへ。 + 画像をクリップボードへ。 - Unable to open the URL. - URL を開けません。 + URL を開けません。 - - + URL copied to clipboard. URL をクリップボードにコピーしました。 - - + Deleting image... - + Remove screenshot from history? - Screenshot copied to clipboard. - スクリーンショットをクリップボードにコピーしました。 + スクリーンショットをクリップボードにコピーしました。 ImgS3UploaderTool - + Image Uploader 画像アップローダー - + Upload the selection to S3 bucket + + ImgUploader + + + Upload image to S3 + + + + + + Uploading Image + 画像をアップロード中 + + + + Upload image + + + + + Unable to open the URL. + URL を開けません。 + + + + URL copied to clipboard. + URL をクリップボードにコピーしました。 + + + + Screenshot copied to clipboard. + スクリーンショットをクリップボードにコピーしました。 + + + + Deleting image... + + + + + Copy URL + URL をコピー + + + + Open URL + URL を開く + + + + Delete image + 画像を削除 + + + + Image to Clipboard. + 画像をクリップボードへ。 + + ImgurUploader - + Upload to Imgur Imgur にアップロード - Uploading Image - 画像をアップロード中 + 画像をアップロード中 - Copy URL - URL をコピー + URL をコピー - Open URL - URL を開く + URL を開く - Delete image - 画像を削除 + 画像を削除 - Image to Clipboard. - 画像をクリップボードへ。 + 画像をクリップボードへ。 - - + Unable to open the URL. URL を開けません。 - URL copied to clipboard. - URL をクリップボードにコピーしました。 + URL をクリップボードにコピーしました。 - Screenshot copied to clipboard. - スクリーンショットをクリップボードにコピーしました。 + スクリーンショットをクリップボードにコピーしました。 ImgurUploaderTool - + Image Uploader 画像アップローダー - + Upload the selection to Imgur Imgur に選択範囲をアップロードする @@ -843,7 +896,7 @@ Enter を押すと画面をキャプチャー。 書き込めません: - + URL copied to clipboard. URL をクリップボードにコピーしました。 diff --git a/translations/Internationalization_ka.ts b/translations/Internationalization_ka.ts index e84f9153..f3dfd655 100644 --- a/translations/Internationalization_ka.ts +++ b/translations/Internationalization_ka.ts @@ -125,12 +125,12 @@ CaptureWidget - + Unable to capture screen ეკრანის გადაღება ვერ მოხერხდა - + Select an area with the mouse, or press Esc to exit. Press Enter to capture the screen. Press Right Click to show the color picker. @@ -155,32 +155,27 @@ Press Space to open the side panel. ConfigWindow - + Configuration პარამეტრები - + Interface ინტერფეისი - + Filename Editor ფაილის სახელის რედაქტორი - + Shortcuts - - Path Default - - - - + General ზოგადი @@ -331,152 +326,167 @@ Press Space to open the side panel. GeneneralConf - - + + Import იმპორტირება - - - + + + Error შეცდომა - + Unable to read file. ფაილის წაკითხვა ვერ მოხერხდა. - - + + Unable to write file. ფაილის ჩაწერა ვერ მოხერხდა. - + Save File ფაილის შენახვა - + Confirm Reset განულების დადასტურება - + Are you sure you want to reset the configuration? დარწმუნებული ხართ, რომ გსურთ პარამეტრების განულება? - + Show help message დახმარების შეტყობინების ნახვა - + Show the help message at the beginning in the capture mode. დახმარების შეტყობინების ნახვა გადაღების რეჟიმის დაწყებისას. - - + + Show desktop notifications ცნობების ჩვენება სამუშაო მაგიდაზე - + Show tray icon ხატულის ჩვენება სისტემურ პანელზე - + Show the systemtray icon ხატულის ჩვენება სისტემურ პანელზე - + Configuration File პარამეტრების ფაილი - + Export ექსპორტირება - + Reset განულება - + Launch at startup გაშვება სისტემის ჩატვირთვისას - - + + Launch Flameshot - + Show welcome message on launch - + Close application after capture - + Close after taking a screenshot - + Copy URL after upload - + Copy URL and close window after upload - - + + Copy file path after save + + + Upload storage + + + + + Imgur storage + + + + + S3 storage (require config.ini file with s3 credentials) + + HistoryWidget - + Latest Uploads - + Screenshots history is empty - + Copy URL URL-ის კოპირება - + URL copied to clipboard. URL დაკოპირდა გაცვლის ბუფერში. - + Open in browser @@ -484,164 +494,199 @@ Press Space to open the side panel. ImgS3Uploader - + Uploading Image სურათის ატვირთვა - + Upload image to S3 - + Delete image from S3 - + Unable to remove screenshot from the remote storage. - + Network error - + Possibly it doesn't exist anymore - + Do you want to remove screenshot from local history anyway? - + S3 Creds URL is not found in your configuration file - Copy URL - URL-ის კოპირება + URL-ის კოპირება - Open URL - URL-ის გახსნა + URL-ის გახსნა - - Delete image - - - - Image to Clipboard. - სურათის გაცვლის ბუფერში გაგზავნა + სურათის გაცვლის ბუფერში გაგზავნა - Unable to open the URL. - URL-ის გახსნა ვერ მოხერხდა. + URL-ის გახსნა ვერ მოხერხდა. - - + URL copied to clipboard. URL დაკოპირდა გაცვლის ბუფერში. - - + Deleting image... - + Remove screenshot from history? - Screenshot copied to clipboard. - სურათი დაკოპირდა გაცვლის ბუფერში. + სურათი დაკოპირდა გაცვლის ბუფერში. ImgS3UploaderTool - + Image Uploader სურათის ამტვირთველი - + Upload the selection to S3 bucket - ImgurUploader + ImgUploader - - Upload to Imgur - Imgur-ზე ატვირთვა + + Upload image to S3 + - + + Uploading Image - სურათის ატვირთვა + სურათის ატვირთვა - + + Upload image + + + + + Unable to open the URL. + URL-ის გახსნა ვერ მოხერხდა. + + + + URL copied to clipboard. + URL დაკოპირდა გაცვლის ბუფერში. + + + + Screenshot copied to clipboard. + სურათი დაკოპირდა გაცვლის ბუფერში. + + + + Deleting image... + + + + Copy URL - URL-ის კოპირება + URL-ის კოპირება - + Open URL - URL-ის გახსნა + URL-ის გახსნა - + Delete image - + Image to Clipboard. - სურათის გაცვლის ბუფერში გაგზავნა + სურათის გაცვლის ბუფერში გაგზავნა + + + + ImgurUploader + + + Upload to Imgur + Imgur-ზე ატვირთვა - - + Uploading Image + სურათის ატვირთვა + + + Copy URL + URL-ის კოპირება + + + Open URL + URL-ის გახსნა + + + Image to Clipboard. + სურათის გაცვლის ბუფერში გაგზავნა + + + Unable to open the URL. URL-ის გახსნა ვერ მოხერხდა. - URL copied to clipboard. - URL დაკოპირდა გაცვლის ბუფერში. + URL დაკოპირდა გაცვლის ბუფერში. - Screenshot copied to clipboard. - სურათი დაკოპირდა გაცვლის ბუფერში. + სურათი დაკოპირდა გაცვლის ბუფერში. ImgurUploaderTool - + Image Uploader სურათის ამტვირთველი - + Upload the selection to Imgur შერჩეულის Imgur-ზე ატვირთვა @@ -839,7 +884,7 @@ Press Space to open the side panel. შემდეგ მისამართზე ჩაწერა ვერ მოხერხდა: - + URL copied to clipboard. URL დაკოპირდა გაცვლის ბუფერში. diff --git a/translations/Internationalization_nl.ts b/translations/Internationalization_nl.ts index 38e5842c..284e7f70 100644 --- a/translations/Internationalization_nl.ts +++ b/translations/Internationalization_nl.ts @@ -125,12 +125,12 @@ CaptureWidget - + Unable to capture screen Kan scherm niet vastleggen - + Select an area with the mouse, or press Esc to exit. Press Enter to capture the screen. Press Right Click to show the color picker. @@ -159,32 +159,27 @@ Druk op spatie om het zijpaneel te openen. ConfigWindow - + Configuration Configuratie - + Interface Uiterlijk - + Filename Editor Bestandsnaambewerker - + Shortcuts - - Path Default - - - - + General Algemeen @@ -335,152 +330,167 @@ Druk op spatie om het zijpaneel te openen. GeneneralConf - - + + Import Importeren - - - + + + Error Fout - + Unable to read file. Kan bestand niet uitlezen. - - + + Unable to write file. Kan bestand niet wegschrijven. - + Save File Bestand opslaan - + Confirm Reset Herstellen bevestigen - + Are you sure you want to reset the configuration? Weet je zeker dat je de standwaardwaarden van de configuratie wilt herstellen? - + Show help message Uitleg tonen - + Show the help message at the beginning in the capture mode. Toont een bericht met uitleg bij het openen van de vastlegmodus. - - + + Show desktop notifications Bureaubladmeldingen tonen - + Show tray icon Systeemvakpictogram tonen - + Show the systemtray icon Toont het systeemvakpictogram - + Configuration File Configuratiebestand - + Export Exporteren - + Reset Standaardwaarden - + Launch at startup Automatisch opstarten - - + + Launch Flameshot Flameshot openen - + Show welcome message on launch - + Close application after capture - + Close after taking a screenshot - + Copy URL after upload - + Copy URL and close window after upload - - + + Copy file path after save + + + Upload storage + + + + + Imgur storage + + + + + S3 storage (require config.ini file with s3 credentials) + + HistoryWidget - + Latest Uploads - + Screenshots history is empty - + Copy URL URL kopiëren - + URL copied to clipboard. URL gekopieerd naar klembord. - + Open in browser @@ -488,164 +498,207 @@ Druk op spatie om het zijpaneel te openen. ImgS3Uploader - + Uploading Image Bezig met uploaden van afbeelding... - + Upload image to S3 - + Delete image from S3 - + Unable to remove screenshot from the remote storage. - + Network error - + Possibly it doesn't exist anymore - + Do you want to remove screenshot from local history anyway? - + S3 Creds URL is not found in your configuration file - Copy URL - URL kopiëren + URL kopiëren - Open URL - URL openen + URL openen - Delete image - Afbeelding verwijderen + Afbeelding verwijderen - Image to Clipboard. - Afbeelding naar klembord. + Afbeelding naar klembord. - Unable to open the URL. - Kan URL niet openen. + Kan URL niet openen. - - + URL copied to clipboard. URL gekopieerd naar klembord. - - + Deleting image... - + Remove screenshot from history? - Screenshot copied to clipboard. - Schermafdruk gekopieerd naar klembord. + Schermafdruk gekopieerd naar klembord. ImgS3UploaderTool - + Image Uploader Afbeeldingsuploader - + Upload the selection to S3 bucket + + ImgUploader + + + Upload image to S3 + + + + + + Uploading Image + Bezig met uploaden van afbeelding... + + + + Upload image + + + + + Unable to open the URL. + Kan URL niet openen. + + + + URL copied to clipboard. + URL gekopieerd naar klembord. + + + + Screenshot copied to clipboard. + Schermafdruk gekopieerd naar klembord. + + + + Deleting image... + + + + + Copy URL + URL kopiëren + + + + Open URL + URL openen + + + + Delete image + Afbeelding verwijderen + + + + Image to Clipboard. + Afbeelding naar klembord. + + ImgurUploader - + Upload to Imgur Uploaden naar Imgur - Uploading Image - Bezig met uploaden van afbeelding... + Bezig met uploaden van afbeelding... - Copy URL - URL kopiëren + URL kopiëren - Open URL - URL openen + URL openen - Delete image - Afbeelding verwijderen + Afbeelding verwijderen - Image to Clipboard. - Afbeelding naar klembord. + Afbeelding naar klembord. - - + Unable to open the URL. Kan URL niet openen. - URL copied to clipboard. - URL gekopieerd naar klembord. + URL gekopieerd naar klembord. - Screenshot copied to clipboard. - Schermafdruk gekopieerd naar klembord. + Schermafdruk gekopieerd naar klembord. ImgurUploaderTool - + Image Uploader Afbeeldingsuploader - + Upload the selection to Imgur Upload de selectie naar Imgur @@ -847,7 +900,7 @@ Druk op spatie om het zijpaneel te openen. Kan niet wegschrijven naar - + URL copied to clipboard. URL gekopieerd naar klembord. diff --git a/translations/Internationalization_pl.ts b/translations/Internationalization_pl.ts index aa0f8841..d7bd9fd4 100644 --- a/translations/Internationalization_pl.ts +++ b/translations/Internationalization_pl.ts @@ -125,12 +125,12 @@ CaptureWidget - + Unable to capture screen Nie można przechwycić ekranu - + Select an area with the mouse, or press Esc to exit. Press Enter to capture the screen. Press Right Click to show the color picker. @@ -158,32 +158,27 @@ Spacja, aby pokazać panel boczny. ConfigWindow - + Configuration Konfiguracja - + Interface Interfejs - + Filename Editor Edytor nazw plików - + Shortcuts - - Path Default - - - - + General Ogólne @@ -334,152 +329,167 @@ Spacja, aby pokazać panel boczny. GeneneralConf - - + + Import Import - - - + + + Error Błąd - + Unable to read file. Nie można odczytać pliku. - - + + Unable to write file. Nie można zapisać pliku. - + Save File Zapisz plik - + Confirm Reset Potwierdź Reset - + Are you sure you want to reset the configuration? Czy na pewno chcesz zresetować konfigurację? - + Show help message Pokaż podpowiedzi - + Show the help message at the beginning in the capture mode. Pokaż podpowiedzi na początku trybu przechwytywania. - - + + Show desktop notifications Pokaż powiadomienia ekranowe - + Show tray icon Pokaż ikonę w trayu - + Show the systemtray icon Pokaż ikonę w zasobniku systemowym - + Configuration File Plik konfiguracyjny - + Export Export - + Reset Reset - + Launch at startup Uruchom podczas startu - - + + Launch Flameshot Uruchom Flameshot - + Show welcome message on launch - + Close application after capture - + Close after taking a screenshot - + Copy URL after upload - + Copy URL and close window after upload - - + + Copy file path after save + + + Upload storage + + + + + Imgur storage + + + + + S3 storage (require config.ini file with s3 credentials) + + HistoryWidget - + Latest Uploads - + Screenshots history is empty - + Copy URL Kopiuj URL - + URL copied to clipboard. URL skopiowany do schowka. - + Open in browser @@ -487,164 +497,207 @@ Spacja, aby pokazać panel boczny. ImgS3Uploader - + Uploading Image Wysyłanie obrazka - + Upload image to S3 - + Delete image from S3 - + Unable to remove screenshot from the remote storage. - + Network error - + Possibly it doesn't exist anymore - + Do you want to remove screenshot from local history anyway? - + S3 Creds URL is not found in your configuration file - Copy URL - Kopiuj URL + Kopiuj URL - Open URL - Otwórz URL + Otwórz URL - Delete image - Usuń obrazek + Usuń obrazek - Image to Clipboard. - Obrazek do schowka. + Obrazek do schowka. - Unable to open the URL. - Nie można otworzyć adresu URL. + Nie można otworzyć adresu URL. - - + URL copied to clipboard. URL skopiowany do schowka. - - + Deleting image... - + Remove screenshot from history? - Screenshot copied to clipboard. - Zrzut ekranu skopiowany do schowka. + Zrzut ekranu skopiowany do schowka. ImgS3UploaderTool - + Image Uploader Uploader obrazów - + Upload the selection to S3 bucket + + ImgUploader + + + Upload image to S3 + + + + + + Uploading Image + Wysyłanie obrazka + + + + Upload image + + + + + Unable to open the URL. + Nie można otworzyć adresu URL. + + + + URL copied to clipboard. + URL skopiowany do schowka. + + + + Screenshot copied to clipboard. + Zrzut ekranu skopiowany do schowka. + + + + Deleting image... + + + + + Copy URL + Kopiuj URL + + + + Open URL + Otwórz URL + + + + Delete image + Usuń obrazek + + + + Image to Clipboard. + Obrazek do schowka. + + ImgurUploader - + Upload to Imgur Wyślij do Imgur - Uploading Image - Wysyłanie obrazka + Wysyłanie obrazka - Copy URL - Kopiuj URL + Kopiuj URL - Open URL - Otwórz URL + Otwórz URL - Delete image - Usuń obrazek + Usuń obrazek - Image to Clipboard. - Obrazek do schowka. + Obrazek do schowka. - - + Unable to open the URL. Nie można otworzyć adresu URL. - URL copied to clipboard. - URL skopiowany do schowka. + URL skopiowany do schowka. - Screenshot copied to clipboard. - Zrzut ekranu skopiowany do schowka. + Zrzut ekranu skopiowany do schowka. ImgurUploaderTool - + Image Uploader Uploader obrazów - + Upload the selection to Imgur Wyślij zaznaczenie do Imgur @@ -842,7 +895,7 @@ Spacja, aby pokazać panel boczny. Nie można zapisać w - + URL copied to clipboard. URL skopiowany do schowka. diff --git a/translations/Internationalization_pt_br.ts b/translations/Internationalization_pt_br.ts index b52272e8..5e7cac62 100644 --- a/translations/Internationalization_pt_br.ts +++ b/translations/Internationalization_pt_br.ts @@ -125,12 +125,12 @@ CaptureWidget - + Unable to capture screen Não foi possível capturar a tela - + Select an area with the mouse, or press Esc to exit. Press Enter to capture the screen. Press Right Click to show the color picker. @@ -159,32 +159,27 @@ Pressione espaço abrir o painel lateral. ConfigWindow - + Configuration Configuração - + Interface Interface - + Filename Editor Editor de nome de arquivo - + Shortcuts - - Path Default - - - - + General Geral @@ -335,152 +330,167 @@ Pressione espaço abrir o painel lateral. GeneneralConf - - + + Import Importar - - - + + + Error Erro - + Unable to read file. Não foi possível ler o arquivo. - - + + Unable to write file. Não foi possível escrever no arquivo. - + Save File Salvar Arquivo - + Confirm Reset Confirmar Reset - + Are you sure you want to reset the configuration? Tem certeza que deseja resetar a configuração? - + Show help message Mostrar mensagem de ajuda - + Show the help message at the beginning in the capture mode. Mostrar mensagem de ajuda no início do modo de captura. - - + + Show desktop notifications Mostrar notificações de Desktop - + Show tray icon Mostrar ícone de tray - + Show the systemtray icon Mosrar ícone na barra de aplicações - + Configuration File Arquivo de Configurações - + Export Exportar - + Reset Reset - + Launch at startup Iniciar junto com o sistema - - + + Launch Flameshot Iniciar Flameshot - + Show welcome message on launch - + Close application after capture - + Close after taking a screenshot - + Copy URL after upload - + Copy URL and close window after upload - - + + Copy file path after save + + + Upload storage + + + + + Imgur storage + + + + + S3 storage (require config.ini file with s3 credentials) + + HistoryWidget - + Latest Uploads - + Screenshots history is empty - + Copy URL Copiar URL - + URL copied to clipboard. URL copiada para o clipboard. - + Open in browser @@ -488,164 +498,207 @@ Pressione espaço abrir o painel lateral. ImgS3Uploader - + Uploading Image Upando Imagem - + Upload image to S3 - + Delete image from S3 - + Unable to remove screenshot from the remote storage. - + Network error - + Possibly it doesn't exist anymore - + Do you want to remove screenshot from local history anyway? - + S3 Creds URL is not found in your configuration file - Copy URL - Copiar URL + Copiar URL - Open URL - Abrir URL + Abrir URL - Delete image - Deletar imagem + Deletar imagem - Image to Clipboard. - Imagem no Clipboard. + Imagem no Clipboard. - Unable to open the URL. - Não foi possível abrir a URL. + Não foi possível abrir a URL. - - + URL copied to clipboard. URL copiada para o clipboard. - - + Deleting image... - + Remove screenshot from history? - Screenshot copied to clipboard. - Screenshot copiada para o clipboard. + Screenshot copiada para o clipboard. ImgS3UploaderTool - + Image Uploader Uploader de imagens - + Upload the selection to S3 bucket + + ImgUploader + + + Upload image to S3 + + + + + + Uploading Image + Upando Imagem + + + + Upload image + + + + + Unable to open the URL. + Não foi possível abrir a URL. + + + + URL copied to clipboard. + URL copiada para o clipboard. + + + + Screenshot copied to clipboard. + Screenshot copiada para o clipboard. + + + + Deleting image... + + + + + Copy URL + Copiar URL + + + + Open URL + Abrir URL + + + + Delete image + Deletar imagem + + + + Image to Clipboard. + Imagem no Clipboard. + + ImgurUploader - + Upload to Imgur Upload no Imgur - Uploading Image - Upando Imagem + Upando Imagem - Copy URL - Copiar URL + Copiar URL - Open URL - Abrir URL + Abrir URL - Delete image - Deletar imagem + Deletar imagem - Image to Clipboard. - Imagem no Clipboard. + Imagem no Clipboard. - - + Unable to open the URL. Não foi possível abrir a URL. - URL copied to clipboard. - URL copiada para o clipboard. + URL copiada para o clipboard. - Screenshot copied to clipboard. - Screenshot copiada para o clipboard. + Screenshot copiada para o clipboard. ImgurUploaderTool - + Image Uploader Uploader de imagens - + Upload the selection to Imgur Upa a seleção no Imgur @@ -843,7 +896,7 @@ Pressione espaço abrir o painel lateral. Não foi possível escrever em - + URL copied to clipboard. URL copiada para o clipboard. diff --git a/translations/Internationalization_ru.ts b/translations/Internationalization_ru.ts index 0200c6d7..fba7380c 100644 --- a/translations/Internationalization_ru.ts +++ b/translations/Internationalization_ru.ts @@ -125,12 +125,12 @@ CaptureWidget - + Unable to capture screen Не удалось захватить экран - + Select an area with the mouse, or press Esc to exit. Press Enter to capture the screen. Press Right Click to show the color picker. @@ -159,32 +159,31 @@ Press Space to open the side panel. ConfigWindow - + Configuration Настройка - + Interface Интерфейс - + Filename Editor Редактор имен файлов - + Shortcuts Горячие клавиши - Path Default - Путь + Путь - + General Общие @@ -343,127 +342,142 @@ Press Space to open the side panel. GeneneralConf - - + + Import Импорт - - - + + + Error Ошибка - + Unable to read file. Не удалось прочитать файл. - - + + Unable to write file. Не удалось записать файл. - + Save File Сохранить файл - + Confirm Reset Подтвердить сброс - + Are you sure you want to reset the configuration? Вы действительно хотите сбросить настройки? - + Show help message Показывать справочное сообщение - + Show the help message at the beginning in the capture mode. Показывать справочное сообщение перед началом захвата экрана. - - + + Show desktop notifications Показывать уведомления - + Show tray icon Показывать значок в трее - + Show the systemtray icon Показать значок в системном трее - + Configuration File Файл конфигурации - + Export Экспорт - + Reset Сброс - + Launch at startup Запускать при старте системы - - + + Launch Flameshot Запустить Flameshot - + Show welcome message on launch Показывать приветствие при запуске - + Close application after capture Закрыть приложение после захвата - + Close after taking a screenshot Закрыть после получения скриншота - + Copy URL after upload Скопировать URL после загрузки - + Copy URL and close window after upload Скопировать URL после загрузки и закрыть окно - - + + Copy file path after save Копировать путь к сохраненному файлу + + + Upload storage + Хранилище скриншотов + + + + Imgur storage + Хранилище Imgur + + + + S3 storage (require config.ini file with s3 credentials) + Хранилище S3 (необходим файл config.ini с параметрами доступа) + HistoryWidget @@ -476,27 +490,27 @@ Press Space to open the side panel. История скриншотов пустая - + Latest Uploads Последние загрузки - + Screenshots history is empty История скриншотов пуста - + Copy URL Скопировать URL - + URL copied to clipboard. URL скопирован в буфер обмена. - + Open in browser Открыть в браузере @@ -508,17 +522,17 @@ Press Space to open the side panel. Загрузить на S3 - + Uploading Image Загрузка изображения - + Upload image to S3 Загрузить на S3 - + Delete image from S3 Удалить скриншот с S3 @@ -527,87 +541,79 @@ Press Space to open the side panel. Удалить скриншот - + Remove screenshot from history? Удалить скриншот из истории? - + S3 Creds URL is not found in your configuration file Параметры доступов к S3 не найдены в конфигурационном файле - Copy URL - Скопировать URL + Скопировать URL - Open URL - Открыть URL + Открыть URL - Delete image - Удалить изображение + Удалить изображение - Image to Clipboard. - Изображение в буфер обмена. + Изображение в буфер обмена. - Unable to open the URL. - Не удалось открыть URL. + Не удалось открыть URL. - - + URL copied to clipboard. URL скопирован в буфер обмена. - - + Deleting image... Удаление скриншота... - + Unable to remove screenshot from the remote storage. Невозможно удалить снимок экрана из удаленного хранилища. - + Network error Ошибка сети - + Possibly it doesn't exist anymore Возможно, его больше не существует - + Do you want to remove screenshot from local history anyway? Вы все равно хотите удалить скриншот из локальной истории? - Screenshot copied to clipboard. - Снимок скопирован в буфер обмена. + Снимок скопирован в буфер обмена. ImgS3UploaderTool - + Image Uploader Отправка изображений - + Upload the selection to S3 bucket Загрузить выделение на S3 @@ -617,63 +623,114 @@ Press Space to open the side panel. - ImgurUploader + ImgUploader - - Upload to Imgur - Загрузить в Imgur + + Upload image to S3 + Загрузить на S3 - + + Uploading Image Загрузка изображения - - Copy URL - Скопировать URL + + Upload image + Загрузить изображение - - Open URL - Открыть URL - - - - Delete image - Удалить изображение - - - - Image to Clipboard. - Изображение в буфер обмена. - - - - + Unable to open the URL. Не удалось открыть URL. - + URL copied to clipboard. URL скопирован в буфер обмена. - + Screenshot copied to clipboard. Снимок скопирован в буфер обмена. + + + Deleting image... + Удаление скриншота... + + + + Copy URL + Скопировать URL + + + + Open URL + Открыть URL + + + + Delete image + Удалить изображение + + + + Image to Clipboard. + Изображение в буфер обмена. + + + + ImgurUploader + + + Upload to Imgur + Загрузить в Imgur + + + Uploading Image + Загрузка изображения + + + Copy URL + Скопировать URL + + + Open URL + Открыть URL + + + Delete image + Удалить изображение + + + Image to Clipboard. + Изображение в буфер обмена. + + + + Unable to open the URL. + Не удалось открыть URL. + + + URL copied to clipboard. + URL скопирован в буфер обмена. + + + Screenshot copied to clipboard. + Снимок скопирован в буфер обмена. + ImgurUploaderTool - + Image Uploader Отправка изображений - + Upload the selection to Imgur Загрузить выделение на Imgur @@ -887,7 +944,7 @@ Press Space to open the side panel. Не удалось сохранить - + URL copied to clipboard. URL скопирован в буфер обмена. diff --git a/translations/Internationalization_sk.ts b/translations/Internationalization_sk.ts index f235432f..3004419f 100644 --- a/translations/Internationalization_sk.ts +++ b/translations/Internationalization_sk.ts @@ -125,12 +125,12 @@ CaptureWidget - + Unable to capture screen Nepodarilo sa zachytiť obrazovku - + Select an area with the mouse, or press Esc to exit. Press Enter to capture the screen. Press Right Click to show the color picker. @@ -159,32 +159,27 @@ Stlačte medzerník pre otvorenie postranného panelu. ConfigWindow - + Configuration Konfigurácia - + Interface Interfejs - + Filename Editor Editor názvov súborov - + Shortcuts - - Path Default - - - - + General Všeobecné @@ -335,152 +330,167 @@ Stlačte medzerník pre otvorenie postranného panelu. GeneneralConf - - + + Import Importovať - - - + + + Error Chyba - + Unable to read file. Zlyhalo čítanie súboru. - - + + Unable to write file. Zlyhal zápis do súboru. - + Save File Uložiť súbor - + Confirm Reset Potvrdiť Reset - + Are you sure you want to reset the configuration? Naozaj si želáte resetovať aktuálnu konfiguráciu? - + Show help message Zobraziť nápovedu - + Show the help message at the beginning in the capture mode. Zobraziť nápovedu na začiatku počas režimu zachytávania obrazovky. - - + + Show desktop notifications Zobraziť systémové upozornenia - + Show tray icon Zobraziť stavovú ikonu - + Show the systemtray icon Zobraziť ikonu v stavovej oblasti - + Configuration File Súbor s konfiguráciou - + Export Exportovať - + Reset Resetovať - + Launch at startup Spúšťať pri štarte - - + + Launch Flameshot Spustiť Flameshot - + Show welcome message on launch - + Close application after capture Zavrieť po vytvorení snímky - + Close after taking a screenshot Zatvoriť po vytvorení snímky obrazovky - + Copy URL after upload - + Copy URL and close window after upload - - + + Copy file path after save + + + Upload storage + + + + + Imgur storage + + + + + S3 storage (require config.ini file with s3 credentials) + + HistoryWidget - + Latest Uploads - + Screenshots history is empty - + Copy URL Kopírovať URL - + URL copied to clipboard. URL skopírovaná do schránky. - + Open in browser @@ -488,164 +498,207 @@ Stlačte medzerník pre otvorenie postranného panelu. ImgS3Uploader - + Uploading Image Nahrávam obrázok - + Upload image to S3 - + Delete image from S3 - + Unable to remove screenshot from the remote storage. - + Network error - + Possibly it doesn't exist anymore - + Do you want to remove screenshot from local history anyway? - + S3 Creds URL is not found in your configuration file - Copy URL - Kopírovať URL + Kopírovať URL - Open URL - Otvoriť URL + Otvoriť URL - Delete image - Vymazať obrázok + Vymazať obrázok - Image to Clipboard. - Obrázok do schránky. + Obrázok do schránky. - Unable to open the URL. - Nepodarilo sa otvoriť URL. + Nepodarilo sa otvoriť URL. - - + URL copied to clipboard. URL skopírovaná do schránky. - - + Deleting image... - + Remove screenshot from history? - Screenshot copied to clipboard. - Snímka obrazovky bola skopírovaná do schránky. + Snímka obrazovky bola skopírovaná do schránky. ImgS3UploaderTool - + Image Uploader Uploader obrázkov - + Upload the selection to S3 bucket + + ImgUploader + + + Upload image to S3 + + + + + + Uploading Image + Nahrávam obrázok + + + + Upload image + + + + + Unable to open the URL. + Nepodarilo sa otvoriť URL. + + + + URL copied to clipboard. + URL skopírovaná do schránky. + + + + Screenshot copied to clipboard. + Snímka obrazovky bola skopírovaná do schránky. + + + + Deleting image... + + + + + Copy URL + Kopírovať URL + + + + Open URL + Otvoriť URL + + + + Delete image + Vymazať obrázok + + + + Image to Clipboard. + Obrázok do schránky. + + ImgurUploader - + Upload to Imgur Nahrať na Imgur - Uploading Image - Nahrávam obrázok + Nahrávam obrázok - Copy URL - Kopírovať URL + Kopírovať URL - Open URL - Otvoriť URL + Otvoriť URL - Delete image - Vymazať obrázok + Vymazať obrázok - Image to Clipboard. - Obrázok do schránky. + Obrázok do schránky. - - + Unable to open the URL. Nepodarilo sa otvoriť URL. - URL copied to clipboard. - URL skopírovaná do schránky. + URL skopírovaná do schránky. - Screenshot copied to clipboard. - Snímka obrazovky bola skopírovaná do schránky. + Snímka obrazovky bola skopírovaná do schránky. ImgurUploaderTool - + Image Uploader Uploader obrázkov - + Upload the selection to Imgur Nahrať výber na Imgur @@ -851,7 +904,7 @@ Stlačte medzerník pre otvorenie postranného panelu. Chyba pri ukladaní - + URL copied to clipboard. URL skopírovaná do schránky. diff --git a/translations/Internationalization_sr.ts b/translations/Internationalization_sr.ts index 4dc05af2..b243f85f 100644 --- a/translations/Internationalization_sr.ts +++ b/translations/Internationalization_sr.ts @@ -125,12 +125,12 @@ CaptureWidget - + Unable to capture screen Нисам успео да снимим екран - + Select an area with the mouse, or press Esc to exit. Press Enter to capture the screen. Press Right Click to show the color picker. @@ -159,32 +159,27 @@ Press Space to open the side panel. ConfigWindow - + Configuration Подешавања - + Interface Изглед - + Filename Editor Избор имена датотеке - + Shortcuts - - Path Default - - - - + General Опште @@ -335,152 +330,167 @@ Press Space to open the side panel. GeneneralConf - - + + Import Увоз - - - + + + Error Грешка - + Unable to read file. Нисам успео да прочитам датотеку. - - + + Unable to write file. Нисам успео да сачувам датотеку. - + Save File Сачувај датотеку - + Confirm Reset Потврда поништавања - + Are you sure you want to reset the configuration? Да ли сте сигурни да желите да поништите сва прилагођена подешавања? - + Show help message Приказуј поруку са упутством - + Show the help message at the beginning in the capture mode. Приказуј поруку са кратким упутством на почетку снимања екрана. - - + + Show desktop notifications Користи системска обавештења - + Show tray icon Иконица на системској полици - + Show the systemtray icon Приказуј иконицу на системској полици - + Configuration File Датотека са подешавањима - + Export Извоз - + Reset Поништи - + Launch at startup Покрени на почетку - - + + Launch Flameshot Покрени Flameshot - + Show welcome message on launch - + Close application after capture - + Close after taking a screenshot - + Copy URL after upload - + Copy URL and close window after upload - - + + Copy file path after save + + + Upload storage + + + + + Imgur storage + + + + + S3 storage (require config.ini file with s3 credentials) + + HistoryWidget - + Latest Uploads - + Screenshots history is empty - + Copy URL Запамти интернет адресу - + URL copied to clipboard. Интернет адреса је сачувана у привременој меморији. - + Open in browser @@ -488,164 +498,207 @@ Press Space to open the side panel. ImgS3Uploader - + Uploading Image Објављујем слику - + Upload image to S3 - + Delete image from S3 - + Unable to remove screenshot from the remote storage. - + Network error - + Possibly it doesn't exist anymore - + Do you want to remove screenshot from local history anyway? - + S3 Creds URL is not found in your configuration file - Copy URL - Запамти интернет адресу + Запамти интернет адресу - Open URL - Посети интернет адресу + Посети интернет адресу - Delete image - Избриши слику + Избриши слику - Image to Clipboard. - Сачувај у привремену меморију. + Сачувај у привремену меморију. - Unable to open the URL. - Нисам успео да посетим интернет адресу. + Нисам успео да посетим интернет адресу. - - + URL copied to clipboard. Интернет адреса је сачувана у привременој меморији. - - + Deleting image... - + Remove screenshot from history? - Screenshot copied to clipboard. - Слика је сачувана у привременој меморији. + Слика је сачувана у привременој меморији. ImgS3UploaderTool - + Image Uploader Објављивање слике - + Upload the selection to S3 bucket + + ImgUploader + + + Upload image to S3 + + + + + + Uploading Image + Објављујем слику + + + + Upload image + + + + + Unable to open the URL. + Нисам успео да посетим интернет адресу. + + + + URL copied to clipboard. + Интернет адреса је сачувана у привременој меморији. + + + + Screenshot copied to clipboard. + Слика је сачувана у привременој меморији. + + + + Deleting image... + + + + + Copy URL + Запамти интернет адресу + + + + Open URL + Посети интернет адресу + + + + Delete image + Избриши слику + + + + Image to Clipboard. + Сачувај у привремену меморију. + + ImgurUploader - + Upload to Imgur Објави на Imgur - Uploading Image - Објављујем слику + Објављујем слику - Copy URL - Запамти интернет адресу + Запамти интернет адресу - Open URL - Посети интернет адресу + Посети интернет адресу - Delete image - Избриши слику + Избриши слику - Image to Clipboard. - Сачувај у привремену меморију. + Сачувај у привремену меморију. - - + Unable to open the URL. Нисам успео да посетим интернет адресу. - URL copied to clipboard. - Интернет адреса је сачувана у привременој меморији. + Интернет адреса је сачувана у привременој меморији. - Screenshot copied to clipboard. - Слика је сачувана у привременој меморији. + Слика је сачувана у привременој меморији. ImgurUploaderTool - + Image Uploader Објављивање слике - + Upload the selection to Imgur Објави избор на Imgur сајту @@ -843,7 +896,7 @@ Press Space to open the side panel. Нисам успео са сачувам - + URL copied to clipboard. Интернет адреса је сачувана у привременој меморији. diff --git a/translations/Internationalization_tr.ts b/translations/Internationalization_tr.ts index 1160935c..07dbd013 100644 --- a/translations/Internationalization_tr.ts +++ b/translations/Internationalization_tr.ts @@ -125,12 +125,12 @@ CaptureWidget - + Unable to capture screen Ekran resmi alınamadı - + Select an area with the mouse, or press Esc to exit. Press Enter to capture the screen. Press Right Click to show the color picker. @@ -159,32 +159,27 @@ Yan paneli açmak için Boşluk tuşuna basın. ConfigWindow - + Configuration Ayarlar - + Interface Arayüz - + Filename Editor Dosya Adı Düzenleyici - + Shortcuts - - Path Default - - - - + General Genel @@ -335,152 +330,167 @@ Yan paneli açmak için Boşluk tuşuna basın. GeneneralConf - - + + Import Dışa aktar - - - + + + Error Hata - + Unable to read file. Dosya okunamıyor. - - + + Unable to write file. Dosya yazılamıyor. - + Save File Dosyayı Kaydet - + Confirm Reset Sıfırlamayı Onayla - + Are you sure you want to reset the configuration? Ayarları sıfırlamak istediğinizden emin misiniz? - + Show help message Yardım mesajını göster - + Show the help message at the beginning in the capture mode. Yakalama modunda başında yardım mesajını gösterin. - - + + Show desktop notifications Masaüstü bildirimlerini göster - + Show tray icon Tepsi simgesini göster - + Show the systemtray icon Sistem tepsisi simgesini göster - + Configuration File Yapılandırma Dosyası - + Export Dışa aktar - + Reset Sıfırla - + Launch at startup Başlangıçta başlatın - - + + Launch Flameshot Flameshot'ı başlat - + Show welcome message on launch - + Close application after capture - + Close after taking a screenshot - + Copy URL after upload - + Copy URL and close window after upload - - + + Copy file path after save + + + Upload storage + + + + + Imgur storage + + + + + S3 storage (require config.ini file with s3 credentials) + + HistoryWidget - + Latest Uploads - + Screenshots history is empty - + Copy URL URL Kopyala - + URL copied to clipboard. URL panoya kopyalandı. - + Open in browser @@ -488,164 +498,207 @@ Yan paneli açmak için Boşluk tuşuna basın. ImgS3Uploader - + Uploading Image Resim Yükleniyor - + Upload image to S3 - + Delete image from S3 - + Unable to remove screenshot from the remote storage. - + Network error - + Possibly it doesn't exist anymore - + Do you want to remove screenshot from local history anyway? - + S3 Creds URL is not found in your configuration file - Copy URL - URL Kopyala + URL Kopyala - Open URL - URL Aç + URL Aç - Delete image - Resmi sil + Resmi sil - Image to Clipboard. - Resim Pano'ya. + Resim Pano'ya. - Unable to open the URL. - URL açılamıyor. + URL açılamıyor. - - + URL copied to clipboard. URL panoya kopyalandı. - - + Deleting image... - + Remove screenshot from history? - Screenshot copied to clipboard. - Ekran görüntüsü panoya kopyalandı. + Ekran görüntüsü panoya kopyalandı. ImgS3UploaderTool - + Image Uploader Resim Yükleme Aracı - + Upload the selection to S3 bucket + + ImgUploader + + + Upload image to S3 + + + + + + Uploading Image + Resim Yükleniyor + + + + Upload image + + + + + Unable to open the URL. + URL açılamıyor. + + + + URL copied to clipboard. + URL panoya kopyalandı. + + + + Screenshot copied to clipboard. + Ekran görüntüsü panoya kopyalandı. + + + + Deleting image... + + + + + Copy URL + URL Kopyala + + + + Open URL + URL Aç + + + + Delete image + Resmi sil + + + + Image to Clipboard. + Resim Pano'ya. + + ImgurUploader - + Upload to Imgur Imgur'a yükle - Uploading Image - Resim Yükleniyor + Resim Yükleniyor - Copy URL - URL Kopyala + URL Kopyala - Open URL - URL Aç + URL Aç - Delete image - Resmi sil + Resmi sil - Image to Clipboard. - Resim Pano'ya. + Resim Pano'ya. - - + Unable to open the URL. URL açılamıyor. - URL copied to clipboard. - URL panoya kopyalandı. + URL panoya kopyalandı. - Screenshot copied to clipboard. - Ekran görüntüsü panoya kopyalandı. + Ekran görüntüsü panoya kopyalandı. ImgurUploaderTool - + Image Uploader Resim Yükleme Aracı - + Upload the selection to Imgur Seçimi Imgur'a yükler @@ -843,7 +896,7 @@ Yan paneli açmak için Boşluk tuşuna basın. Yazma mümkün değil - + URL copied to clipboard. URL panoya kopyalandı. diff --git a/translations/Internationalization_uk.ts b/translations/Internationalization_uk.ts index 179c3c3d..761adb7a 100644 --- a/translations/Internationalization_uk.ts +++ b/translations/Internationalization_uk.ts @@ -125,12 +125,12 @@ CaptureWidget - + Unable to capture screen Не вдалось захопити екран - + Select an area with the mouse, or press Esc to exit. Press Enter to capture the screen. Press Right Click to show the color picker. @@ -159,32 +159,31 @@ Press Space to open the side panel. ConfigWindow - + Configuration Налаштування - + Interface Інтерфейс - + Filename Editor Редактор імені файлів - + Shortcuts Гарячі клавіші - Path Default - Шлях + Шлях - + General Загальне @@ -343,127 +342,142 @@ Press Space to open the side panel. GeneneralConf - - + + Import Імпорт - - - + + + Error Помилка - + Unable to read file. Не вдалось прочитати файл. - - + + Unable to write file. Не вдалось записати файл. - + Save File Зберегти файл - + Confirm Reset Підтвердити скидання - + Are you sure you want to reset the configuration? Ви дійсно хочете скинути налаштування? - + Show help message Показувати повідомлення довідки - + Show the help message at the beginning in the capture mode. Показувати повідомлення довідки на початку режиму захоплення. - - + + Show desktop notifications Показувати повідомлення - + Show tray icon Показувати значок на панелі - + Show the systemtray icon Показувати значок на панелі повідомленнь - + Configuration File Файл налаштувань - + Export Експорт - + Reset Скинути - + Launch at startup Запускати при старті системи - - + + Launch Flameshot Запускати Flameshot - + Show welcome message on launch Показувати привітання при запуску - + Close application after capture Закрити прогрму після захвату - + Close after taking a screenshot Закрити програму після отримання скріншоту - + Copy URL after upload Копіювати URL після завантаження - + Copy URL and close window after upload Копіювати URL та закрити вікно після завантаження - - + + Copy file path after save Копіювати шлях до збереженного файлу + + + Upload storage + Cховище скріншотів + + + + Imgur storage + Сховище Imgur + + + + S3 storage (require config.ini file with s3 credentials) + Сховище S3 (потрібен файл config.ini із параметрами доступу) + HistoryWidget @@ -476,27 +490,27 @@ Press Space to open the side panel. Історія скріншотів пуста - + Latest Uploads Останні завантаження - + Screenshots history is empty Історія скріншотів пуста - + Copy URL Скопіювати URL - + URL copied to clipboard. URL скопійовано до буферу обміну. - + Open in browser Відкрити у браузері @@ -508,17 +522,17 @@ Press Space to open the side panel. Вивантажити на S3 - + Uploading Image Вивантаження зображення - + Upload image to S3 Завантажити на S3 - + Delete image from S3 Видалити скріншот з S3 @@ -527,87 +541,79 @@ Press Space to open the side panel. Видалити скіншот - + Remove screenshot from history? Видалити скріншот із історії? - + S3 Creds URL is not found in your configuration file Параметри доступів до S3 не знайдені у конфігураціонному файлі - Copy URL - Скопіювати URL + Скопіювати URL - Open URL - Відкрити URL + Відкрити URL - Delete image - Видалити зображення + Видалити зображення - Image to Clipboard. - Зображення до буферу обміну. + Зображення до буферу обміну. - Unable to open the URL. - Не вдалось відкрити URL. + Не вдалось відкрити URL. - - + URL copied to clipboard. URL скопійовано до буферу обміну. - - + Deleting image... Видалення скріншоту... - + Unable to remove screenshot from the remote storage. Не вдалося видалити скріншот із віддаленого сховища. - + Network error Помилка мережі - + Possibly it doesn't exist anymore Можливо, його більше не існує - + Do you want to remove screenshot from local history anyway? Ви все одно хочете видалити скріншот із локальної історії? - Screenshot copied to clipboard. - Знімок скопійовано до буферу обміну. + Знімок скопійовано до буферу обміну. ImgS3UploaderTool - + Image Uploader Вивантаження зображень - + Upload the selection to S3 bucket Вивантажити виділення на S3 @@ -617,63 +623,114 @@ Press Space to open the side panel. - ImgurUploader + ImgUploader - - Upload to Imgur - Вивантажити до Imgur + + Upload image to S3 + Завантажити на S3 - + + Uploading Image Вивантаження зображення - - Copy URL - Скопіювати URL + + Upload image + Вивантажити зображення - - Open URL - Відкрити URL - - - - Delete image - Видалити зображення - - - - Image to Clipboard. - Зображення до буферу обміну. - - - - + Unable to open the URL. Не вдалось відкрити URL. - + URL copied to clipboard. URL скопійовано до буферу обміну. - + Screenshot copied to clipboard. Знімок скопійовано до буферу обміну. + + + Deleting image... + Видалення скріншоту... + + + + Copy URL + Скопіювати URL + + + + Open URL + Відкрити URL + + + + Delete image + Видалити зображення + + + + Image to Clipboard. + Зображення до буферу обміну. + + + + ImgurUploader + + + Upload to Imgur + Вивантажити до Imgur + + + Uploading Image + Вивантаження зображення + + + Copy URL + Скопіювати URL + + + Open URL + Відкрити URL + + + Delete image + Видалити зображення + + + Image to Clipboard. + Зображення до буферу обміну. + + + + Unable to open the URL. + Не вдалось відкрити URL. + + + URL copied to clipboard. + URL скопійовано до буферу обміну. + + + Screenshot copied to clipboard. + Знімок скопійовано до буферу обміну. + ImgurUploaderTool - + Image Uploader Вивантаження зображень - + Upload the selection to Imgur Вивантажити вибране до Imgur @@ -887,7 +944,7 @@ Press Space to open the side panel. Не вдалось зберегти - + URL copied to clipboard. URL скопійовано до буферу обміну. diff --git a/translations/Internationalization_zh_CN.ts b/translations/Internationalization_zh_CN.ts index 710d93ca..1916eaa7 100644 --- a/translations/Internationalization_zh_CN.ts +++ b/translations/Internationalization_zh_CN.ts @@ -125,13 +125,13 @@ CaptureWidget - + Unable to capture screen 无法捕获屏幕 无法捕获屏幕 - + Select an area with the mouse, or press Esc to exit. Press Enter to capture the screen. Press Right Click to show the color picker. @@ -160,32 +160,27 @@ Press Space to open the side panel. ConfigWindow - + Configuration 配置 - + Interface 界面 - + Filename Editor 文件名编辑器 - + Shortcuts - - Path Default - - - - + General 常规 @@ -336,152 +331,167 @@ Press Space to open the side panel. GeneneralConf - + Show help message 显示帮助文档 - + Show the help message at the beginning in the capture mode. 在捕获之前显示帮助信息。 - - + + Show desktop notifications 显示桌面通知 - + Show tray icon 显示托盘图标 - + Show the systemtray icon 显示任务栏图标 - - + + Import 导入 - - - + + + Error 错误 - + Unable to read file. 无法读取文件。 - - + + Unable to write file. 无法写入文件。 - + Save File 保存到文件 - + Confirm Reset 确定重置 - + Are you sure you want to reset the configuration? 你确定你想要重置配置? - + Configuration File 配置文件 - + Export 导出 - + Reset 重置 - + Launch at startup 开机时启动 - - + + Launch Flameshot 启动 Flameshot - + Show welcome message on launch - + Close application after capture 捕获后关闭 - + Close after taking a screenshot 获取屏幕截图后关闭 - + Copy URL after upload - + Copy URL and close window after upload - - + + Copy file path after save + + + Upload storage + + + + + Imgur storage + + + + + S3 storage (require config.ini file with s3 credentials) + + HistoryWidget - + Latest Uploads - + Screenshots history is empty - + Copy URL 复制链接 - + URL copied to clipboard. 复制链接到剪贴板。 - + Open in browser @@ -489,164 +499,207 @@ Press Space to open the side panel. ImgS3Uploader - + Uploading Image 正在上传 - + Upload image to S3 - + Delete image from S3 - + Unable to remove screenshot from the remote storage. - + Network error - + Possibly it doesn't exist anymore - + Do you want to remove screenshot from local history anyway? - + S3 Creds URL is not found in your configuration file - Copy URL - 复制链接 + 复制链接 - Open URL - 打开链接 + 打开链接 - Delete image - 删除图像 + 删除图像 - Image to Clipboard. - 保存文件到剪贴板。 + 保存文件到剪贴板。 - Unable to open the URL. - 无法打开此链接。 + 无法打开此链接。 - - + URL copied to clipboard. 复制链接到剪贴板。 - - + Deleting image... - + Remove screenshot from history? - Screenshot copied to clipboard. - 截图复制到剪贴板。 + 截图复制到剪贴板。 ImgS3UploaderTool - + Image Uploader 上传图片 - + Upload the selection to S3 bucket + + ImgUploader + + + Upload image to S3 + + + + + + Uploading Image + 正在上传 + + + + Upload image + + + + + Unable to open the URL. + 无法打开此链接。 + + + + URL copied to clipboard. + 复制链接到剪贴板。 + + + + Screenshot copied to clipboard. + 截图复制到剪贴板。 + + + + Deleting image... + + + + + Copy URL + 复制链接 + + + + Open URL + 打开链接 + + + + Delete image + 删除图像 + + + + Image to Clipboard. + 保存文件到剪贴板。 + + ImgurUploader - + Upload to Imgur 上传到Imgur - Uploading Image - 正在上传 + 正在上传 - Copy URL - 复制链接 + 复制链接 - Open URL - 打开链接 + 打开链接 - Delete image - 删除图像 + 删除图像 - Image to Clipboard. - 保存文件到剪贴板。 + 保存文件到剪贴板。 - - + Unable to open the URL. 无法打开此链接。 - URL copied to clipboard. - 复制链接到剪贴板。 + 复制链接到剪贴板。 - Screenshot copied to clipboard. - 截图复制到剪贴板。 + 截图复制到剪贴板。 ImgurUploaderTool - + Image Uploader 上传图片 - + Upload the selection to Imgur 上传选择到 Imgur @@ -852,7 +905,7 @@ Press Space to open the side panel. 无法写入 - + URL copied to clipboard. 复制链接到剪贴板。 diff --git a/translations/Internationalization_zh_TW.ts b/translations/Internationalization_zh_TW.ts index 6194cfb4..96cd338a 100644 --- a/translations/Internationalization_zh_TW.ts +++ b/translations/Internationalization_zh_TW.ts @@ -125,12 +125,12 @@ CaptureWidget - + Unable to capture screen 無法擷取螢幕 - + Select an area with the mouse, or press Esc to exit. Press Enter to capture the screen. Press Right Click to show the color picker. @@ -155,32 +155,27 @@ Press Space to open the side panel. ConfigWindow - + Configuration 設定 - + Interface 介面 - + Filename Editor 檔案名稱編輯器 - + Shortcuts - - Path Default - - - - + General 一般 @@ -331,152 +326,167 @@ Press Space to open the side panel. GeneneralConf - + Show help message 顯示説明資訊 - + Show the help message at the beginning in the capture mode. 在擷取之前顯示説明資訊 - - + + Show desktop notifications 顯示桌面通知 - + Show tray icon 顯示託盤圖示 - + Show the systemtray icon 顯示工作列圖示 - - + + Import 匯入 - - - + + + Error 錯誤 - + Unable to read file. 無法讀取檔案 - - + + Unable to write file. 無法寫入檔案 - + Save File 存檔 - + Confirm Reset 確認重設 - + Are you sure you want to reset the configuration? 你確定你想要重設? - + Configuration File 設定檔 - + Export 匯出 - + Reset 重設 - + Launch at startup 自動啟動 - - + + Launch Flameshot - + Show welcome message on launch - + Close application after capture - + Close after taking a screenshot - + Copy URL after upload - + Copy URL and close window after upload - - + + Copy file path after save + + + Upload storage + + + + + Imgur storage + + + + + S3 storage (require config.ini file with s3 credentials) + + HistoryWidget - + Latest Uploads - + Screenshots history is empty - + Copy URL 複製連結 - + URL copied to clipboard. 連結已複製到剪貼簿 - + Open in browser @@ -484,164 +494,199 @@ Press Space to open the side panel. ImgS3Uploader - + Uploading Image 正在上傳 - + Upload image to S3 - + Delete image from S3 - + Unable to remove screenshot from the remote storage. - + Network error - + Possibly it doesn't exist anymore - + Do you want to remove screenshot from local history anyway? - + S3 Creds URL is not found in your configuration file - Copy URL - 複製連結 + 複製連結 - Open URL - 打開連結 + 打開連結 - - Delete image - - - - Image to Clipboard. - 將檔案複製到剪貼簿 + 將檔案複製到剪貼簿 - Unable to open the URL. - 無法打開此連結 + 無法打開此連結 - - + URL copied to clipboard. 連結已複製到剪貼簿 - - + Deleting image... - + Remove screenshot from history? - Screenshot copied to clipboard. - 截圖已複製到剪貼簿 + 截圖已複製到剪貼簿 ImgS3UploaderTool - + Image Uploader 上傳圖片 - + Upload the selection to S3 bucket - ImgurUploader + ImgUploader - - Upload to Imgur - 上傳到 Imgur + + Upload image to S3 + - + + Uploading Image - 正在上傳 + 正在上傳 - + + Upload image + + + + + Unable to open the URL. + 無法打開此連結 + + + + URL copied to clipboard. + 連結已複製到剪貼簿 + + + + Screenshot copied to clipboard. + 截圖已複製到剪貼簿 + + + + Deleting image... + + + + Copy URL - 複製連結 + 複製連結 - + Open URL - 打開連結 + 打開連結 - + Delete image - + Image to Clipboard. - 將檔案複製到剪貼簿 + 將檔案複製到剪貼簿 + + + + ImgurUploader + + + Upload to Imgur + 上傳到 Imgur - - + Uploading Image + 正在上傳 + + + Copy URL + 複製連結 + + + Open URL + 打開連結 + + + Image to Clipboard. + 將檔案複製到剪貼簿 + + + Unable to open the URL. 無法打開此連結 - URL copied to clipboard. - 連結已複製到剪貼簿 + 連結已複製到剪貼簿 - Screenshot copied to clipboard. - 截圖已複製到剪貼簿 + 截圖已複製到剪貼簿 ImgurUploaderTool - + Image Uploader 上傳圖片 - + Upload the selection to Imgur 上傳到 Imgur @@ -839,7 +884,7 @@ Press Space to open the side panel. 無法寫入 - + URL copied to clipboard. 連結已複製到剪貼簿