diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -68,6 +68,8 @@
${SPECTACLE_SRCS_ALL}
)
+ki18n_wrap_ui(spectacle Gui/SettingsDialog/GeneralOptions.ui Gui/SettingsDialog/SaveOptions.ui)
+
# link libraries
target_link_libraries(
diff --git a/src/Gui/SettingsDialog/GeneralOptions.ui b/src/Gui/SettingsDialog/GeneralOptions.ui
new file mode 100644
--- /dev/null
+++ b/src/Gui/SettingsDialog/GeneralOptions.ui
@@ -0,0 +1,202 @@
+
+
+ GeneralOptions
+
+
+
+ 0
+ 0
+ 463
+ 442
+
+
+
+ -
+
+
+ When Spectacle is Running
+
+
+
+ -
+
+
+ Press screenshot key to:
+
+
+
+ -
+
+
+ Take a new Screenshot
+
+
+ true
+
+
+ printKeyActionGroup
+
+
+
+ -
+
+
+ Open a new Spectacle window
+
+
+ printKeyActionGroup
+
+
+
+ -
+
+
+ Return focus to Spectacle
+
+
+ printKeyActionGroup
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+ QSizePolicy::Fixed
+
+
+
+ 0
+ 18
+
+
+
+
+ -
+
+
+ After taking a screenshot:
+
+
+
+ -
+
+
+ Copy image to clipboard
+
+
+
+ -
+
+
+ Autosave the image to the default location
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+ QSizePolicy::Fixed
+
+
+
+ 0
+ 18
+
+
+
+
+ -
+
+
+ Rectangular Region
+
+
+
+ -
+
+
+ General:
+
+
+
+ -
+
+
+ Use light background
+
+
+
+ -
+
+
+ Show magnifier
+
+
+
+ -
+
+
+ Accept on click-and-release
+
+
+
+ -
+
+
+ Remember selected area:
+
+
+
+ -
+
+
+ Never
+
+
+ true
+
+
+
+ -
+
+
+ Always
+
+
+
+ -
+
+
+ Until Spectacle is closed
+
+
+
+
+
+
+ true
+
+
+ false
+
+
+
+
+
+ KTitleWidget
+ QWidget
+
+
+
+
+
+
+
+
+
diff --git a/src/Gui/SettingsDialog/GeneralOptionsPage.h b/src/Gui/SettingsDialog/GeneralOptionsPage.h
--- a/src/Gui/SettingsDialog/GeneralOptionsPage.h
+++ b/src/Gui/SettingsDialog/GeneralOptionsPage.h
@@ -22,13 +22,20 @@
#include
+class Ui_GeneralOptions;
+
class GeneralOptionsPage : public QWidget
{
Q_OBJECT
public:
explicit GeneralOptionsPage(QWidget *parent = nullptr);
+ ~GeneralOptionsPage() override;
+
+ private:
+
+ Ui_GeneralOptions *m_ui;
};
#endif // GENERALOPTIONSPAGE_H
diff --git a/src/Gui/SettingsDialog/GeneralOptionsPage.cpp b/src/Gui/SettingsDialog/GeneralOptionsPage.cpp
--- a/src/Gui/SettingsDialog/GeneralOptionsPage.cpp
+++ b/src/Gui/SettingsDialog/GeneralOptionsPage.cpp
@@ -20,6 +20,9 @@
#include "GeneralOptionsPage.h"
+#include "settings.h"
+#include "ui_GeneralOptions.h"
+
#include
#include
#include
@@ -32,103 +35,43 @@
#include
#include
-GeneralOptionsPage::GeneralOptionsPage(QWidget *parent) :
- QWidget{parent}
+GeneralOptionsPage::GeneralOptionsPage(QWidget *parent)
+ : QWidget(parent)
+ , m_ui(new Ui_GeneralOptions)
{
- QFormLayout *mainLayout = new QFormLayout(this);
- setLayout(mainLayout);
+ m_ui->setupUi(this);
+
+ m_ui->runningTitle->setLevel(2);
+ m_ui->regionTitle->setLevel(2);
+
+ m_ui->printKeyActionGroup->setId(m_ui->newScreenshotButton, Settings::TakeNewScreenshot);
+ m_ui->printKeyActionGroup->setId(m_ui->newWindowButton, Settings::StartNewInstance);
+ m_ui->printKeyActionGroup->setId(m_ui->activateWindowButton, Settings::FocusWindow);
- // When spectacle is running settings
- KTitleWidget* runningTitle = new KTitleWidget(this);
- runningTitle->setText(i18n("When Spectacle is Running"));
- runningTitle->setLevel(2);
- mainLayout->addRow(runningTitle);
- QRadioButton* takeNew = new QRadioButton(i18n("Take a new screenshot"), this);
- QRadioButton* startNewInstance = new QRadioButton(i18n("Open a new Spectacle window"), this);
- QButtonGroup* printKeyActionGroup = new QButtonGroup(this);
- printKeyActionGroup->setExclusive(true);
- printKeyActionGroup->addButton(takeNew,0);// SpectacleConfig::PrintKeyActionRunning::TakeNewScreenshot);
- printKeyActionGroup->addButton(startNewInstance,1);// SpectacleConfig::PrintKeyActionRunning::StartNewInstance);
- mainLayout->addRow(i18n("Press screenshot key to:"), takeNew);
- mainLayout->addRow(QString(), startNewInstance);
//On Wayland we can't programmatically raise and focus the window so we have to hide the option
- if (!(KWindowSystem::isPlatformWayland() || qstrcmp(qgetenv("XDG_SESSION_TYPE"), "wayland") == 0)) {
- QRadioButton* focusWindow = new QRadioButton(i18n("Return focus to Spectacle"), this);
- printKeyActionGroup->addButton( focusWindow,2);// SpectacleConfig::PrintKeyActionRunning::FocusWindow);
- mainLayout->addRow(QString(), focusWindow);
+ if (KWindowSystem::isPlatformWayland() || qstrcmp(qgetenv("XDG_SESSION_TYPE"), "wayland") == 0) {
+ m_ui->formLayout->removeRow(m_ui->activateWindowButton);
}
-
- //Workaround because KConfigWidgets doesn't support QButtonGroup (Bug 409037)
- auto workaroundLabel = new QLineEdit(this);
- workaroundLabel->setHidden(true);
- workaroundLabel->setObjectName(QStringLiteral("kcfg_printKeyActionRunning"));
- // Need to check default Button because we get no change event for that
- takeNew->setChecked(true);
- connect(workaroundLabel, &QLineEdit::textChanged,
- printKeyActionGroup, [printKeyActionGroup, takeNew](const QString& text){
- auto button = printKeyActionGroup->button(text.toInt());
- // We are missing a button on Wayland
- button ? button->setChecked(true) : takeNew->setChecked(true);
+ //Workaround because KConfigDialogManager doesn't support QButtonGroup (Bug 409037)
+ auto workaroundLabel = m_ui->kcfg_printKeyActionRunning;
+ connect(workaroundLabel, &QLineEdit::textChanged, this, [this](const QString& text){
+ auto button = m_ui->printKeyActionGroup->button(text.toInt());
+ // We are missing a button on Wayland
+ button ? button->setChecked(true) : m_ui->newScreenshotButton->setChecked(true);
});
- connect(printKeyActionGroup, qOverload(&QButtonGroup::buttonToggled),
- workaroundLabel, [workaroundLabel, printKeyActionGroup] (QAbstractButton *button, bool checked) {
+ connect(m_ui->printKeyActionGroup, qOverload(&QButtonGroup::buttonToggled),
+ workaroundLabel, [workaroundLabel, this] (QAbstractButton *button, bool checked) {
if (checked) {
- const int value = printKeyActionGroup->id(button);
+ const int value = m_ui->printKeyActionGroup->id(button);
workaroundLabel->setText(QString::number(value));
}
});
// /Workaround
- mainLayout->addItem(new QSpacerItem(0, 18, QSizePolicy::Fixed, QSizePolicy::Fixed));
-
- // actions to take after taking a screenshot
- auto copyImageToClipboard = new QCheckBox(i18n("Copy image to clipboard"), this);
- copyImageToClipboard->setObjectName(QStringLiteral("kcfg_copyImageToClipboard"));
- mainLayout->addRow(i18n("After taking a screenshot:"), copyImageToClipboard);
-
- auto autoSaveImage = new QCheckBox(i18n("Autosave the image to the default location"), this);
- autoSaveImage->setObjectName(QStringLiteral("kcfg_autoSaveImage"));
- mainLayout->addRow(QString(), autoSaveImage);
-
- mainLayout->addItem(new QSpacerItem(0, 18, QSizePolicy::Fixed, QSizePolicy::Fixed));
-
- // Rectangular Region settings
- KTitleWidget *titleWidget = new KTitleWidget(this);
- titleWidget->setText(i18n("Rectangular Region"));
- titleWidget->setLevel(2);
- mainLayout->addRow(titleWidget);
-
- // use light background
- QCheckBox* kcfg_useLightMaskColour = new QCheckBox(i18n("Use light background"), this);
- kcfg_useLightMaskColour->setObjectName(QStringLiteral("kcfg_useLightMaskColour"));
- mainLayout->addRow(i18n("General:"), kcfg_useLightMaskColour);
-
- // show magnifier
- auto showMagnifier = new QCheckBox(i18n("Show magnifier"), this);
- showMagnifier->setObjectName(QStringLiteral("kcfg_showMagnifier"));
- mainLayout->addRow(QString(), showMagnifier);
-
- // release mouse-button to capture
- auto releaseToCapture = new QCheckBox(i18n("Accept on click-and-release"), this);
- releaseToCapture->setObjectName(QStringLiteral("kcfg_useReleaseToCapture"));
- mainLayout->addRow(QString(), releaseToCapture);
-
- mainLayout->addItem(new QSpacerItem(0, 18, QSizePolicy::Fixed, QSizePolicy::Fixed));
-
- // remember Rectangular Region box
- QButtonGroup* rememberGroup = new QButtonGroup(this);
- rememberGroup->setExclusive(true);
- QRadioButton* neverButton = new QRadioButton(i18n("Never"), this);
- auto rememberAlways = new QRadioButton(i18n("Always"), this);
- rememberAlways->setObjectName(QStringLiteral("kcfg_alwaysRememberRegion"));
- auto rememberUntilClosed = new QRadioButton(i18n("Until Spectacle is closed"), this);
- rememberUntilClosed->setObjectName(QStringLiteral("kcfg_rememberLastRectangularRegion"));
- rememberGroup->addButton(neverButton);
- rememberGroup->addButton(rememberAlways);
- rememberGroup->addButton(rememberUntilClosed);
- neverButton->setChecked(true);
- mainLayout->addRow(i18n("Remember selected area:"), neverButton);
+}
- mainLayout->addRow(QString(), rememberAlways);
- mainLayout->addRow(QString(), rememberUntilClosed);
+GeneralOptionsPage::~GeneralOptionsPage()
+{
+ delete m_ui;
}
+
diff --git a/src/Gui/SettingsDialog/SaveOptions.ui b/src/Gui/SettingsDialog/SaveOptions.ui
new file mode 100644
--- /dev/null
+++ b/src/Gui/SettingsDialog/SaveOptions.ui
@@ -0,0 +1,188 @@
+
+
+ SaveOptions
+
+
+
+ 0
+ 0
+ 598
+ 286
+
+
+
+ -
+
+
+ Save Location:
+
+
+ kcfg_defaultSaveLocation
+
+
+
+ -
+
+
+ KFile::Directory|KFile::LocalOnly
+
+
+
+ -
+
+
+ Copy file location to clipboard after saving
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+ QSizePolicy::Fixed
+
+
+
+ 0
+ 18
+
+
+
+
+ -
+
+
+ Compression Quality:
+
+
+ qualitySpinner
+
+
+
+ -
+
+
-
+
+
-
+
+
+ Qt::Horizontal
+
+
+
+ -
+
+
+ %
+
+
+ 100
+
+
+
+
+
+ -
+
+
+ Choose the image quality when saving with lossy image formats like JPEG
+
+
+
+
+
+ -
+
+
+ Filename:
+
+
+ kcfg_saveFilenameFormat
+
+
+
+ -
+
+
-
+
+
+ %d
+
+
+
+ -
+
+
+ currentText
+
+
+
+
+
+ -
+
+
+ Preview:
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+
+
+
+ true
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+ QSizePolicy::Fixed
+
+
+
+ 0
+ 18
+
+
+
+
+
+
+
+
+ KUrlRequester
+ QWidget
+
+
+
+
+
+
+ kcfg_compressionQuality
+ valueChanged(int)
+ qualitySpinner
+ setValue(int)
+
+
+ qualitySpinner
+ valueChanged(int)
+ kcfg_compressionQuality
+ setValue(int)
+
+
+
diff --git a/src/Gui/SettingsDialog/SaveOptionsPage.h b/src/Gui/SettingsDialog/SaveOptionsPage.h
--- a/src/Gui/SettingsDialog/SaveOptionsPage.h
+++ b/src/Gui/SettingsDialog/SaveOptionsPage.h
@@ -22,24 +22,21 @@
#include
-class QComboBox;
-class QLabel;
-class QLineEdit;
+class Ui_SaveOptions;
class SaveOptionsPage : public QWidget
{
Q_OBJECT
public:
explicit SaveOptionsPage(QWidget *parent = nullptr);
-
+ ~SaveOptionsPage() override;
+
private:
-
- QLineEdit* mSaveNameFormat;
- QLabel* mPreviewLabel;
- QComboBox* mSaveImageFormat;
-
+
+ Ui_SaveOptions *m_ui;
+
void updateFilenamePreview();
};
diff --git a/src/Gui/SettingsDialog/SaveOptionsPage.cpp b/src/Gui/SettingsDialog/SaveOptionsPage.cpp
--- a/src/Gui/SettingsDialog/SaveOptionsPage.cpp
+++ b/src/Gui/SettingsDialog/SaveOptionsPage.cpp
@@ -22,6 +22,7 @@
#include "SpectacleCommon.h"
#include "ExportManager.h"
+#include "ui_SaveOptions.h"
#include
#include
@@ -35,116 +36,57 @@
#include
#include
-SaveOptionsPage::SaveOptionsPage(QWidget *parent) : QWidget(parent)
+SaveOptionsPage::SaveOptionsPage(QWidget *parent)
+ : QWidget(parent)
+ , m_ui(new Ui_SaveOptions)
{
- QFormLayout *mainLayout = new QFormLayout;
- setLayout(mainLayout);
+ m_ui->setupUi(this);
- // Save location
- auto urlRequester = new KUrlRequester(this);
- urlRequester->setObjectName(QStringLiteral("kcfg_defaultSaveLocation"));
- urlRequester->setMode(KFile::Directory);
- mainLayout->addRow(i18n("Save Location:"), urlRequester);
-
- // copy file location to clipboard after saving
- auto copyPathToClipboard = new QCheckBox(i18n("Copy file location to clipboard after saving"), this);
- copyPathToClipboard->setObjectName(QStringLiteral("kcfg_copySaveLocation"));
- mainLayout->addRow(QString(), copyPathToClipboard);
-
- mainLayout->addItem(new QSpacerItem(0, 18, QSizePolicy::Fixed, QSizePolicy::Fixed));
-
- // Compression quality slider and current value display
- QHBoxLayout *sliderHorizLayout = new QHBoxLayout(this);
- QVBoxLayout *sliderVertLayout = new QVBoxLayout(this);
-
- // Current value
- auto qualitySpinner = new QSpinBox(this);
- qualitySpinner->setSuffix(QString::fromUtf8("%"));
- qualitySpinner->setRange(0, 100);
- qualitySpinner->setObjectName(QStringLiteral("kcfg_compressionQuality"));
-
- // Slider
- auto qualitySlider = new QSlider(Qt::Horizontal, this);
- qualitySlider->setRange(0, 100);
- qualitySlider->setSliderPosition(qualitySpinner->value());
- qualitySlider->setTracking(true);
- connect(qualitySlider, &QSlider::valueChanged, this, [=](int value) {
- qualitySpinner->setValue(value);
- });
- connect(qualitySpinner, QOverload::of(&QSpinBox::valueChanged), this, [=] (int value) {qualitySlider->setValue(value);});
- sliderHorizLayout->addWidget(qualitySlider);
- sliderHorizLayout->addWidget(qualitySpinner);
-
- sliderVertLayout->addLayout(sliderHorizLayout);
-
- QLabel *qualitySliderDescription = new QLabel(this);
- qualitySliderDescription->setText(i18n("Choose the image quality when saving with lossy image formats like JPEG"));
-
- sliderVertLayout->addWidget(qualitySliderDescription);
-
- mainLayout->addRow(i18n("Compression Quality:"), sliderVertLayout);
-
- mainLayout->addItem(new QSpacerItem(0, 18, QSizePolicy::Fixed, QSizePolicy::Fixed));
-
- // filename chooser text field
- QHBoxLayout *saveFieldLayout = new QHBoxLayout(this);
- mSaveNameFormat = new QLineEdit(this);
- mSaveNameFormat->setObjectName(QStringLiteral("kcfg_saveFilenameFormat"));
-
- connect(mSaveNameFormat, &QLineEdit::textEdited, this, [&](const QString &newText) {
+ connect(m_ui->kcfg_saveFilenameFormat, &QLineEdit::textEdited, this, [&](const QString &newText) {
QString fmt;
const auto imageFormats = QImageWriter::supportedImageFormats();
for (const auto &item : imageFormats) {
fmt = QString::fromLocal8Bit(item);
if (newText.endsWith(QLatin1Char('.') + fmt, Qt::CaseInsensitive)) {
QString txtCopy = newText;
txtCopy.chop(fmt.length() + 1);
- mSaveNameFormat->setText(txtCopy);
- mSaveImageFormat->setCurrentIndex(mSaveImageFormat->findText(fmt.toUpper()));
+ m_ui->kcfg_saveFilenameFormat->setText(txtCopy);
+ m_ui->kcfg_defaultSaveImageFormat->setCurrentIndex(m_ui->kcfg_defaultSaveImageFormat->findText(fmt.toUpper()));
}
}
});
- connect(mSaveNameFormat, &QLineEdit::textChanged,this, &SaveOptionsPage::updateFilenamePreview);
- mSaveNameFormat->setPlaceholderText(QStringLiteral("%d"));
- saveFieldLayout->addWidget(mSaveNameFormat);
+ connect(m_ui->kcfg_saveFilenameFormat, &QLineEdit::textChanged,this, &SaveOptionsPage::updateFilenamePreview);
- mSaveImageFormat = new QComboBox(this);
- mSaveImageFormat->setObjectName(QStringLiteral("kcfg_defaultSaveImageFormat"));
- mSaveImageFormat->setProperty("kcfg_property", QByteArray("currentText"));
- mSaveImageFormat->addItems([&](){
+ m_ui->kcfg_defaultSaveImageFormat->addItems([&](){
QStringList items;
const auto formats = QImageWriter::supportedImageFormats();
for (const auto &fmt : formats) {
items.append(QString::fromLocal8Bit(fmt).toUpper());
}
return items;
}());
- connect(mSaveImageFormat, &QComboBox::currentTextChanged, this, &SaveOptionsPage::updateFilenamePreview);
- saveFieldLayout->addWidget(mSaveImageFormat);
- mainLayout->addRow(i18n("Filename:"), saveFieldLayout);
+ connect( m_ui->kcfg_defaultSaveImageFormat, &QComboBox::currentTextChanged, this, &SaveOptionsPage::updateFilenamePreview);
- mPreviewLabel = new QLabel(this);
- mainLayout->addRow(i18nc("Preview of the user configured filename", "Preview:"), mPreviewLabel);
- // now the save filename format layout
QString helpText = i18n(
"You can use the following placeholders in the filename, which will be replaced "
"with actual text when the file is saved:"
);
for (auto option = ExportManager::filenamePlaceholders.cbegin();
- option != ExportManager::filenamePlaceholders.cend(); ++option) {
+ option != ExportManager::filenamePlaceholders.cend(); ++option) {
helpText += QStringLiteral("%1: %2
").arg(option.key(),
option.value().toString());
}
helpText += QLatin1String("/: ") + i18n("To save to a sub-folder");
helpText += QStringLiteral("
");
- QLabel *fmtHelpText = new QLabel(helpText, this);
- fmtHelpText->setWordWrap(true);
- fmtHelpText->setTextFormat(Qt::RichText);
- fmtHelpText->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
- connect(fmtHelpText, &QLabel::linkActivated, this, [this](const QString& placeholder) {
- mSaveNameFormat->insert(placeholder);
+ m_ui->helpTextLabel->setText(helpText);
+ connect(m_ui->helpTextLabel, &QLabel::linkActivated, this, [this](const QString& placeholder) {
+ m_ui->kcfg_saveFilenameFormat->insert(placeholder);
});
- mainLayout->addWidget(fmtHelpText);
+}
+
+SaveOptionsPage::~SaveOptionsPage()
+{
+ delete m_ui;
}
void SaveOptionsPage::updateFilenamePreview()
@@ -161,8 +103,9 @@
if (lSwitchGrabMode) {
lExportManager->setCaptureMode(Spectacle::CaptureMode::ActiveWindow);
}
- const QString lFileName = lExportManager->formatFilename(mSaveNameFormat->text());
- mPreviewLabel->setText(xi18nc("@info", "%1.%2", lFileName, mSaveImageFormat->currentText().toLower()));
+ const QString lFileName = lExportManager->formatFilename(m_ui->kcfg_saveFilenameFormat->text());
+ m_ui->preview->setText(xi18nc("@info", "%1.%2",
+ lFileName, m_ui->kcfg_defaultSaveImageFormat->currentText().toLower()));
if (lSwitchGrabMode) {
lExportManager->setCaptureMode(lOldMode);
}