mirror of
https://github.com/fergalmoran/flameshot.git
synced 2026-02-11 21:14:01 +00:00
Merge pull request #51 from namecheap/bugfix/RND-655-flameshot-join-two-similar-options-save-path-and-save-default-path-for-screenshots
Join two similar options 'Save path' and 'Save default path for scree…
This commit is contained in:
@@ -44,7 +44,6 @@ GeneneralConf::GeneneralConf(QWidget* parent)
|
||||
initCopyAndCloseAfterUpload();
|
||||
initCopyPathAfterSave();
|
||||
initSaveAfterCopy();
|
||||
initFilePathConfiguration();
|
||||
|
||||
// this has to be at the end
|
||||
initConfingButtons();
|
||||
@@ -330,12 +329,15 @@ void GeneneralConf::initSaveAfterCopy()
|
||||
this,
|
||||
&GeneneralConf::saveAfterCopyChanged);
|
||||
|
||||
QHBoxLayout* pathLayout = new QHBoxLayout();
|
||||
m_layout->addStretch();
|
||||
QGroupBox* box = new QGroupBox(tr("Save Path"));
|
||||
box->setFlat(true);
|
||||
box->setLayout(pathLayout);
|
||||
m_layout->addWidget(box);
|
||||
m_layout->addStretch();
|
||||
|
||||
QVBoxLayout* vboxLayout = new QVBoxLayout();
|
||||
box->setLayout(vboxLayout);
|
||||
|
||||
QHBoxLayout* pathLayout = new QHBoxLayout();
|
||||
|
||||
m_savePath = new QLineEdit(
|
||||
QStandardPaths::writableLocation(QStandardPaths::PicturesLocation), this);
|
||||
@@ -350,6 +352,17 @@ void GeneneralConf::initSaveAfterCopy()
|
||||
&QPushButton::clicked,
|
||||
this,
|
||||
&GeneneralConf::changeSavePath);
|
||||
|
||||
m_screenshotPathFixedCheck =
|
||||
new QCheckBox(tr("Use fixed path for screenshots to save"), this);
|
||||
m_screenshotPathFixedCheck->setChecked(ConfigHandler().savePathFixed());
|
||||
connect(m_screenshotPathFixedCheck,
|
||||
SIGNAL(toggled(bool)),
|
||||
this,
|
||||
SLOT(togglePathFixed()));
|
||||
|
||||
vboxLayout->addLayout(pathLayout);
|
||||
vboxLayout->addWidget(m_screenshotPathFixedCheck);
|
||||
}
|
||||
|
||||
void GeneneralConf::saveAfterCopyChanged(bool checked)
|
||||
@@ -379,50 +392,6 @@ void GeneneralConf::initCopyPathAfterSave()
|
||||
});
|
||||
}
|
||||
|
||||
void GeneneralConf::initFilePathConfiguration()
|
||||
{
|
||||
QGroupBox* box = new QGroupBox(tr("Select default path for Screenshots"));
|
||||
box->setFlat(true);
|
||||
|
||||
QVBoxLayout* boxLayout = new QVBoxLayout();
|
||||
box->setLayout(boxLayout);
|
||||
|
||||
QHBoxLayout* pathBrowseLayout = new QHBoxLayout();
|
||||
|
||||
m_screenshotPathFixedCheck =
|
||||
new QCheckBox(tr("Use fixed path for screenshots to save"), this);
|
||||
m_screenshotPathFixedCheck->setChecked(
|
||||
!ConfigHandler().savePathFixed().isEmpty());
|
||||
connect(m_screenshotPathFixedCheck,
|
||||
SIGNAL(toggled(bool)),
|
||||
this,
|
||||
SLOT(pathFixed()));
|
||||
|
||||
m_screenshotPathFixedText =
|
||||
new QLineEdit(ConfigHandler().savePathFixed(), this);
|
||||
m_screenshotPathFixedText->setDisabled(true);
|
||||
QString foreground = this->palette().foreground().color().name();
|
||||
m_screenshotPathFixedText->setStyleSheet(
|
||||
QStringLiteral("color: %1").arg(foreground));
|
||||
|
||||
m_screenshotPathFixedBrowse = new QPushButton(tr("Change..."), this);
|
||||
m_screenshotPathFixedBrowse->setEnabled(
|
||||
m_screenshotPathFixedCheck->isChecked());
|
||||
connect(m_screenshotPathFixedBrowse,
|
||||
&QPushButton::clicked,
|
||||
this,
|
||||
&GeneneralConf::setPathFixed);
|
||||
|
||||
pathBrowseLayout->addWidget(m_screenshotPathFixedText);
|
||||
pathBrowseLayout->addWidget(m_screenshotPathFixedBrowse);
|
||||
|
||||
boxLayout->addWidget(m_screenshotPathFixedCheck);
|
||||
boxLayout->addLayout(pathBrowseLayout);
|
||||
|
||||
m_layout->addStretch();
|
||||
m_layout->addWidget(box);
|
||||
}
|
||||
|
||||
const QString GeneneralConf::chooseFolder(const QString pathDefault)
|
||||
{
|
||||
QString path;
|
||||
@@ -448,25 +417,7 @@ const QString GeneneralConf::chooseFolder(const QString pathDefault)
|
||||
return path;
|
||||
}
|
||||
|
||||
void GeneneralConf::setPathFixed()
|
||||
void GeneneralConf::togglePathFixed()
|
||||
{
|
||||
QString pathDefault = m_screenshotPathFixedText->text();
|
||||
QString path = chooseFolder(pathDefault);
|
||||
if (path.isNull()) {
|
||||
return;
|
||||
}
|
||||
m_screenshotPathFixedText->setText(path);
|
||||
ConfigHandler().setSavePathFixed(path);
|
||||
}
|
||||
|
||||
void GeneneralConf::pathFixed()
|
||||
{
|
||||
bool status = m_screenshotPathFixedCheck->isChecked();
|
||||
m_screenshotPathFixedBrowse->setEnabled(status);
|
||||
if (!status) {
|
||||
m_screenshotPathFixedText->setText("");
|
||||
ConfigHandler().setSavePathFixed(m_screenshotPathFixedText->text());
|
||||
} else {
|
||||
emit setPathFixed();
|
||||
}
|
||||
ConfigHandler().setSavePathFixed(m_screenshotPathFixedCheck->isChecked());
|
||||
}
|
||||
|
||||
@@ -46,8 +46,7 @@ private slots:
|
||||
void importConfiguration();
|
||||
void exportFileConfiguration();
|
||||
void resetConfiguration();
|
||||
void setPathFixed();
|
||||
void pathFixed();
|
||||
void togglePathFixed();
|
||||
|
||||
private:
|
||||
const QString chooseFolder(const QString currentPath = "");
|
||||
@@ -63,7 +62,6 @@ private:
|
||||
void initCopyAndCloseAfterUpload();
|
||||
void initSaveAfterCopy();
|
||||
void initCopyPathAfterSave();
|
||||
void initFilePathConfiguration();
|
||||
|
||||
// class members
|
||||
QVBoxLayout* m_layout;
|
||||
@@ -82,7 +80,5 @@ private:
|
||||
QCheckBox* m_saveAfterCopy;
|
||||
QLineEdit* m_savePath;
|
||||
QPushButton* m_changeSaveButton;
|
||||
QLineEdit* m_screenshotPathFixedText;
|
||||
QCheckBox* m_screenshotPathFixedCheck;
|
||||
QPushButton* m_screenshotPathFixedBrowse;
|
||||
};
|
||||
|
||||
@@ -124,31 +124,25 @@ void ConfigHandler::setUserColors(const QVector<QColor>& l)
|
||||
QVariant::fromValue(hexColors));
|
||||
}
|
||||
|
||||
QString ConfigHandler::savePathValue()
|
||||
QString ConfigHandler::savePath()
|
||||
{
|
||||
QString savePath =
|
||||
m_settings.value(QStringLiteral("savePathFixed")).toString();
|
||||
if (savePath.isEmpty()) {
|
||||
savePath = m_settings.value(QStringLiteral("savePath")).toString();
|
||||
}
|
||||
return savePath;
|
||||
return m_settings.value(QStringLiteral("savePath")).toString();
|
||||
}
|
||||
|
||||
void ConfigHandler::setSavePath(const QString& savePath)
|
||||
{
|
||||
QString savePathFixed =
|
||||
m_settings.value(QStringLiteral("savePathFixed")).toString();
|
||||
if (savePathFixed.isEmpty()) {
|
||||
m_settings.setValue(QStringLiteral("savePath"), savePath);
|
||||
}
|
||||
m_settings.setValue(QStringLiteral("savePath"), savePath);
|
||||
}
|
||||
|
||||
QString ConfigHandler::savePathFixed()
|
||||
bool ConfigHandler::savePathFixed()
|
||||
{
|
||||
return m_settings.value(QStringLiteral("savePathFixed")).toString();
|
||||
if (!m_settings.contains(QStringLiteral("savePathFixed"))) {
|
||||
m_settings.setValue(QStringLiteral("savePathFixed"), false);
|
||||
}
|
||||
return m_settings.value(QStringLiteral("savePathFixed")).toBool();
|
||||
}
|
||||
|
||||
void ConfigHandler::setSavePathFixed(const QString& savePathFixed)
|
||||
void ConfigHandler::setSavePathFixed(bool savePathFixed)
|
||||
{
|
||||
m_settings.setValue(QStringLiteral("savePathFixed"), savePathFixed);
|
||||
}
|
||||
|
||||
@@ -33,10 +33,11 @@ public:
|
||||
QVector<QColor> getUserColors();
|
||||
void setUserColors(const QVector<QColor>&);
|
||||
|
||||
QString savePathValue();
|
||||
QString savePath();
|
||||
void setSavePath(const QString&);
|
||||
QString savePathFixed();
|
||||
void setSavePathFixed(const QString&);
|
||||
|
||||
bool savePathFixed();
|
||||
void setSavePathFixed(bool);
|
||||
|
||||
QColor uiMainColorValue();
|
||||
void setUIMainColor(const QColor&);
|
||||
|
||||
@@ -73,7 +73,7 @@ void FileNameHandler::setPattern(const QString& pattern)
|
||||
QString FileNameHandler::absoluteSavePath(QString& directory, QString& filename)
|
||||
{
|
||||
ConfigHandler config;
|
||||
directory = config.savePathValue();
|
||||
directory = config.savePath();
|
||||
if (directory.isEmpty() || !QDir(directory).exists() ||
|
||||
!QFileInfo(directory).isWritable()) {
|
||||
directory =
|
||||
|
||||
@@ -79,7 +79,7 @@ bool ScreenshotSaver::saveToFilesystemGUI(const QPixmap& capture)
|
||||
while (!ok) {
|
||||
ConfigHandler config;
|
||||
QString savePath = FileNameHandler().absoluteSavePath();
|
||||
if (config.savePathFixed().size() == 0) {
|
||||
if (!config.savePathFixed()) {
|
||||
savePath = QFileDialog::getSaveFileName(
|
||||
nullptr,
|
||||
QObject::tr("Save screenshot"),
|
||||
@@ -95,7 +95,6 @@ bool ScreenshotSaver::saveToFilesystemGUI(const QPixmap& capture)
|
||||
if (!savePath.endsWith(QLatin1String(".png"), Qt::CaseInsensitive) &&
|
||||
!savePath.endsWith(QLatin1String(".bmp"), Qt::CaseInsensitive) &&
|
||||
!savePath.endsWith(QLatin1String(".jpg"), Qt::CaseInsensitive)) {
|
||||
|
||||
savePath += QLatin1String(".png");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user