Add default path configration for screenshots
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "src/widgets/capture/capturebutton.h"
|
||||
#include "src/config/geneneralconf.h"
|
||||
#include "src/config/filenameeditor.h"
|
||||
#include "src/config/filepathconfiguration.h"
|
||||
#include "src/config/strftimechooserwidget.h"
|
||||
#include "src/config/visualseditor.h"
|
||||
#include "src/utils/globalvalues.h"
|
||||
@@ -35,8 +36,7 @@
|
||||
|
||||
ConfigWindow::ConfigWindow(QWidget *parent) : QTabWidget(parent) {
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
const int size = GlobalValues::buttonBaseSize() * 12;
|
||||
setMinimumSize(size, size);
|
||||
setMinimumSize(GlobalValues::buttonBaseSize() * 14, GlobalValues::buttonBaseSize() * 12);
|
||||
setWindowIcon(QIcon(":img/app/flameshot.svg"));
|
||||
setWindowTitle(tr("Configuration"));
|
||||
|
||||
@@ -67,6 +67,11 @@ ConfigWindow::ConfigWindow(QWidget *parent) : QTabWidget(parent) {
|
||||
addTab(m_filenameEditor, QIcon(modifier + "name_edition.svg"),
|
||||
tr("Filename Editor"));
|
||||
|
||||
// filepath
|
||||
m_filePathConfiguration = new FilePathConfiguration();
|
||||
addTab(m_filePathConfiguration, QIcon(modifier + "name_edition.svg"),
|
||||
tr("Path Default"));
|
||||
|
||||
// general
|
||||
m_generalConfig = new GeneneralConf();
|
||||
addTab(m_generalConfig, QIcon(modifier + "config.svg"),
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <QTabWidget>
|
||||
|
||||
class FileNameEditor;
|
||||
class FilePathConfiguration;
|
||||
class GeneneralConf;
|
||||
class QFileSystemWatcher;
|
||||
class VisualsEditor;
|
||||
@@ -37,6 +38,7 @@ protected:
|
||||
|
||||
private:
|
||||
FileNameEditor *m_filenameEditor;
|
||||
FilePathConfiguration *m_filePathConfiguration;
|
||||
GeneneralConf *m_generalConfig;
|
||||
VisualsEditor *m_visuals;
|
||||
QFileSystemWatcher *m_configWatcher;
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
FileNameEditor::FileNameEditor(QWidget *parent) : QWidget(parent) {
|
||||
initWidgets();
|
||||
initLayout();
|
||||
initLayout();
|
||||
}
|
||||
|
||||
void FileNameEditor::initLayout() {
|
||||
|
||||
77
src/config/filepathconfiguration.cpp
Normal file
77
src/config/filepathconfiguration.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
#include "filepathconfiguration.h"
|
||||
#include "src/utils/filenamehandler.h"
|
||||
#include "src/config/strftimechooserwidget.h"
|
||||
#include "src/utils/confighandler.h"
|
||||
#include <QCheckBox>
|
||||
#include <QFileDialog>
|
||||
#include <QDir>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLineEdit>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include "src/utils/confighandler.h"
|
||||
|
||||
|
||||
FilePathConfiguration::FilePathConfiguration(QWidget *parent) : QWidget(parent) {
|
||||
initWidgets();
|
||||
initLayout();
|
||||
}
|
||||
|
||||
void FilePathConfiguration::initLayout() {
|
||||
m_layout = new QVBoxLayout(this);
|
||||
|
||||
m_layout->addWidget(new QLabel(tr("Screenshot path default:")));
|
||||
m_layout->addWidget(m_screenshotPathFixed);
|
||||
m_layout->addWidget(m_screenshotPathFixedDefault);
|
||||
m_layout->addStretch();
|
||||
QHBoxLayout *horizScreenshotButtonsLayout = new QHBoxLayout();
|
||||
horizScreenshotButtonsLayout->addStretch();
|
||||
horizScreenshotButtonsLayout->addWidget(m_screenshotPathFixedClear);
|
||||
horizScreenshotButtonsLayout->addWidget(m_screenshotPathFixedBrowse);
|
||||
m_layout->addLayout(horizScreenshotButtonsLayout);
|
||||
}
|
||||
|
||||
void FilePathConfiguration::initWidgets() {
|
||||
ConfigHandler config;
|
||||
|
||||
// Screenshot path default
|
||||
m_screenshotPathFixed = new QCheckBox(tr("Use fixed path for screenshots to save"), this);
|
||||
m_screenshotPathFixed->setChecked(!config.savePathFixed().isEmpty());
|
||||
connect(m_screenshotPathFixed, SIGNAL(toggled(bool)), this, SLOT(sreenshotPathFixed()));
|
||||
m_screenshotPathFixedDefault = new QLineEdit(this);
|
||||
m_screenshotPathFixedDefault->setText(config.savePathFixed());
|
||||
m_screenshotPathFixedDefault->setDisabled(config.savePathFixed().isEmpty());
|
||||
m_screenshotPathFixedBrowse = new QPushButton(tr("Browse"), this);
|
||||
m_screenshotPathFixedBrowse->setDisabled(config.savePathFixed().isEmpty());
|
||||
connect(m_screenshotPathFixedBrowse, SIGNAL(released()),this, SLOT (screenshotPathFixedSet()));
|
||||
m_screenshotPathFixedClear = new QPushButton(tr("Clear"), this);
|
||||
m_screenshotPathFixedClear->setDisabled(config.savePathFixed().isEmpty());
|
||||
connect(m_screenshotPathFixedClear, SIGNAL(released()),this, SLOT (screenshotPathFixedClear()));
|
||||
}
|
||||
|
||||
void FilePathConfiguration::sreenshotPathFixed() {
|
||||
bool status = m_screenshotPathFixedDefault->isEnabled();
|
||||
m_screenshotPathFixedDefault->setEnabled(!status);
|
||||
m_screenshotPathFixedBrowse->setEnabled(!status);
|
||||
m_screenshotPathFixedClear->setEnabled(!status);
|
||||
screenshotPathFixedClear();
|
||||
}
|
||||
|
||||
void FilePathConfiguration::screenshotPathFixedSet() {
|
||||
QFileDialog *dirDialog = new QFileDialog(this, tr("Select default path for Screenshots"));
|
||||
dirDialog->setFileMode(QFileDialog::DirectoryOnly);
|
||||
dirDialog->setOption(QFileDialog::ShowDirsOnly, true);
|
||||
QString filePath = dirDialog->getOpenFileName();
|
||||
QDir d = QFileInfo(filePath).absoluteDir();
|
||||
QString absolutePath = d.absolutePath();
|
||||
m_screenshotPathFixedDefault->setText(absolutePath);
|
||||
ConfigHandler config;
|
||||
config.setSavePathFixed(absolutePath);
|
||||
}
|
||||
|
||||
void FilePathConfiguration::screenshotPathFixedClear() {
|
||||
ConfigHandler config;
|
||||
m_screenshotPathFixedDefault->setText("");
|
||||
config.setSavePathFixed(m_screenshotPathFixedDefault->text());
|
||||
}
|
||||
33
src/config/filepathconfiguration.h
Normal file
33
src/config/filepathconfiguration.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
//#include <QPointer>
|
||||
|
||||
class QVBoxLayout;
|
||||
class QLineEdit;
|
||||
class QCheckBox;
|
||||
class FileNameHandler;
|
||||
class QPushButton;
|
||||
|
||||
class FilePathConfiguration : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FilePathConfiguration(QWidget *parent = nullptr);
|
||||
|
||||
private:
|
||||
QVBoxLayout *m_layout;
|
||||
QCheckBox *m_screenshotPathFixed;
|
||||
QLineEdit *m_screenshotPathFixedDefault;
|
||||
QPushButton *m_screenshotPathFixedBrowse;
|
||||
QPushButton *m_screenshotPathFixedClear;
|
||||
|
||||
void initLayout();
|
||||
void initWidgets();
|
||||
|
||||
public slots:
|
||||
|
||||
private slots:
|
||||
void sreenshotPathFixed();
|
||||
void screenshotPathFixedSet();
|
||||
void screenshotPathFixedClear();
|
||||
};
|
||||
@@ -118,11 +118,26 @@ void ConfigHandler::setUserColors(const QVector<QColor> &l) {
|
||||
}
|
||||
|
||||
QString ConfigHandler::savePathValue() {
|
||||
return m_settings.value(QStringLiteral("savePath")).toString();
|
||||
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) {
|
||||
m_settings.setValue(QStringLiteral("savePath"), savePath);
|
||||
QString savePathFixed = m_settings.value(QStringLiteral("savePathFixed")).toString();
|
||||
if( savePathFixed.isEmpty() ) {
|
||||
m_settings.setValue(QStringLiteral("savePath"), savePath);
|
||||
}
|
||||
}
|
||||
|
||||
QString ConfigHandler::savePathFixed() {
|
||||
return m_settings.value(QStringLiteral("savePathFixed")).toString();
|
||||
}
|
||||
|
||||
void ConfigHandler::setSavePathFixed(const QString &savePathFixed) {
|
||||
m_settings.setValue(QStringLiteral("savePathFixed"), savePathFixed);
|
||||
}
|
||||
|
||||
QColor ConfigHandler::uiMainColorValue() {
|
||||
|
||||
@@ -33,6 +33,8 @@ public:
|
||||
|
||||
QString savePathValue();
|
||||
void setSavePath(const QString &);
|
||||
QString savePathFixed();
|
||||
void setSavePathFixed(const QString &);
|
||||
|
||||
QColor uiMainColorValue();
|
||||
void setUIMainColor(const QColor &);
|
||||
|
||||
Reference in New Issue
Block a user