Merge branch 'master' of https://github.com/lupoDharkael/flameshot into save
This commit is contained in:
@@ -40,6 +40,7 @@ GeneneralConf::GeneneralConf(QWidget *parent) : QWidget(parent) {
|
||||
initShowTrayIcon();
|
||||
initAutostart();
|
||||
initCloseAfterCapture();
|
||||
initCopyAndCloseAfterUpload();
|
||||
initSaveAfterCopy();
|
||||
|
||||
// this has to be at the end
|
||||
@@ -53,6 +54,7 @@ void GeneneralConf::updateComponents() {
|
||||
m_sysNotifications->setChecked(config.desktopNotificationValue());
|
||||
m_autostart->setChecked(config.startupLaunchValue());
|
||||
m_closeAfterCapture->setChecked(config.closeAfterScreenshotValue());
|
||||
m_copyAndCloseAfterUpload->setChecked(config.copyAndCloseAfterUploadEnabled());
|
||||
m_saveAfterCopy->setChecked(config.saveAfterCopyValue());
|
||||
|
||||
if (!config.saveAfterCopyPathValue().isEmpty()) {
|
||||
@@ -235,11 +237,24 @@ void GeneneralConf::initCloseAfterCapture() {
|
||||
&GeneneralConf::closeAfterCaptureChanged);
|
||||
}
|
||||
|
||||
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_layout->addWidget(m_copyAndCloseAfterUpload);
|
||||
|
||||
connect(m_copyAndCloseAfterUpload, &QCheckBox::clicked, [](bool checked) {
|
||||
ConfigHandler().setCopyAndCloseAfterUploadEnabled(checked);
|
||||
});
|
||||
}
|
||||
|
||||
void GeneneralConf::initSaveAfterCopy() {
|
||||
m_saveAfterCopy = new QCheckBox(tr("Save image after copy"), this);
|
||||
m_saveAfterCopy->setToolTip(tr("Save image file after copying it"));
|
||||
m_layout->addWidget(m_saveAfterCopy);
|
||||
connect(m_saveAfterCopy, &QCheckBox::clicked, this,
|
||||
connect(m_saveAfterCopy, &QCheckBox::clicked, this,
|
||||
&GeneneralConf::saveAfterCopyChanged);
|
||||
|
||||
QHBoxLayout *pathLayout = new QHBoxLayout();
|
||||
@@ -250,7 +265,7 @@ void GeneneralConf::initSaveAfterCopy() {
|
||||
m_layout->addWidget(box);
|
||||
|
||||
m_savePath = new QLineEdit(
|
||||
QStandardPaths::writableLocation(QStandardPaths::PicturesLocation),
|
||||
QStandardPaths::writableLocation(QStandardPaths::PicturesLocation),
|
||||
this);
|
||||
m_savePath->setDisabled(true);
|
||||
QString foreground = this->palette().foreground().color().name();
|
||||
@@ -259,7 +274,7 @@ void GeneneralConf::initSaveAfterCopy() {
|
||||
|
||||
m_changeSaveButton = new QPushButton(tr("Change..."), this);
|
||||
pathLayout->addWidget(m_changeSaveButton);
|
||||
connect(m_changeSaveButton, &QPushButton::clicked, this,
|
||||
connect(m_changeSaveButton, &QPushButton::clicked, this,
|
||||
&GeneneralConf::changeSavePath);
|
||||
}
|
||||
|
||||
@@ -277,7 +292,7 @@ void GeneneralConf::changeSavePath() {
|
||||
return;
|
||||
}
|
||||
if (!QFileInfo(path).isWritable()) {
|
||||
QMessageBox::about(this, tr("Error"),
|
||||
QMessageBox::about(this, tr("Error"),
|
||||
tr("Unable to write to directory."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ private:
|
||||
QCheckBox *m_helpMessage;
|
||||
QCheckBox *m_autostart;
|
||||
QCheckBox *m_closeAfterCapture;
|
||||
QCheckBox *m_copyAndCloseAfterUpload;
|
||||
QPushButton *m_importButton;
|
||||
QPushButton *m_exportButton;
|
||||
QPushButton *m_resetButton;
|
||||
@@ -65,5 +66,6 @@ private:
|
||||
void initConfingButtons();
|
||||
void initAutostart();
|
||||
void initCloseAfterCapture();
|
||||
void initCopyAndCloseAfterUpload();
|
||||
void initSaveAfterCopy();
|
||||
};
|
||||
|
||||
@@ -201,7 +201,7 @@ int main(int argc, char *argv[]) {
|
||||
auto helpOption = parser.addHelpOption();
|
||||
auto versionOption = parser.addVersionOption();
|
||||
parser.AddOptions({ pathOption, delayOption, rawImageOption }, guiArgument);
|
||||
parser.AddOptions({ screenNumberOption, clipboardOption,pathOption,
|
||||
parser.AddOptions({ screenNumberOption, clipboardOption, pathOption,
|
||||
delayOption, rawImageOption },
|
||||
screenArgument);
|
||||
parser.AddOptions({ pathOption, clipboardOption, delayOption, rawImageOption },
|
||||
|
||||
@@ -45,6 +45,7 @@ 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());
|
||||
@@ -76,7 +77,13 @@ void ImgurUploader::handleReply(QNetworkReply *reply) {
|
||||
m_imageURL.setUrl(data[QStringLiteral("link")].toString());
|
||||
m_deleteImageURL.setUrl(QStringLiteral("https://imgur.com/delete/%1").arg(
|
||||
data[QStringLiteral("deletehash")].toString()));
|
||||
onUploadOk();
|
||||
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());
|
||||
}
|
||||
|
||||
@@ -325,6 +325,14 @@ void ConfigHandler::setCloseAfterScreenshot(const bool close) {
|
||||
m_settings.setValue(QStringLiteral("closeAfterScreenshot"), close);
|
||||
}
|
||||
|
||||
bool ConfigHandler::copyAndCloseAfterUploadEnabled() {
|
||||
return m_settings.value(QStringLiteral("copyAndCloseAfterUpload")).toBool();
|
||||
}
|
||||
|
||||
void ConfigHandler::setCopyAndCloseAfterUploadEnabled(const bool value) {
|
||||
m_settings.setValue(QStringLiteral("copyAndCloseAfterUpload"), value);
|
||||
}
|
||||
|
||||
bool ConfigHandler::saveAfterCopyValue() {
|
||||
return m_settings.value(QStringLiteral("saveAfterCopy")).toBool();
|
||||
}
|
||||
|
||||
@@ -71,6 +71,9 @@ public:
|
||||
bool closeAfterScreenshotValue();
|
||||
void setCloseAfterScreenshot(const bool);
|
||||
|
||||
bool copyAndCloseAfterUploadEnabled();
|
||||
void setCopyAndCloseAfterUploadEnabled(const bool);
|
||||
|
||||
bool saveAfterCopyValue();
|
||||
void setSaveAfterCopy(const bool);
|
||||
|
||||
|
||||
@@ -15,10 +15,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Flameshot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#define pragma once
|
||||
|
||||
#include <QVector>
|
||||
#include "src/widgets/capture/capturebutton.h"
|
||||
#pragma once
|
||||
|
||||
namespace GlobalValues {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user