Changeset View
Changeset View
Standalone View
Standalone View
src/Gui/SettingsDialog/SaveOptionsPage.cpp
Show All 30 Lines | |||||
31 | #include <QHBoxLayout> | 31 | #include <QHBoxLayout> | ||
32 | #include <QComboBox> | 32 | #include <QComboBox> | ||
33 | #include <QImageWriter> | 33 | #include <QImageWriter> | ||
34 | #include <QCheckBox> | 34 | #include <QCheckBox> | ||
35 | 35 | | |||
36 | SaveOptionsPage::SaveOptionsPage(QWidget *parent) : | 36 | SaveOptionsPage::SaveOptionsPage(QWidget *parent) : | ||
37 | SettingsPage(parent) | 37 | SettingsPage(parent) | ||
38 | { | 38 | { | ||
39 | QFormLayout *mainLayout = new QFormLayout; | 39 | QFormLayout *mainLayout = new QFormLayout; | ||
davidre: You have added an empty line here. | |||||
40 | setLayout(mainLayout); | 40 | setLayout(mainLayout); | ||
41 | 41 | | |||
42 | // Save location | 42 | // Save location | ||
43 | mUrlRequester = new KUrlRequester; | 43 | mUrlRequester = new KUrlRequester; | ||
44 | mUrlRequester->setMode(KFile::Directory); | 44 | mUrlRequester->setMode(KFile::Directory); | ||
45 | connect(mUrlRequester, &KUrlRequester::textChanged, this, &SaveOptionsPage::markDirty); | 45 | connect(mUrlRequester, &KUrlRequester::textChanged, this, &SaveOptionsPage::markDirty); | ||
46 | mainLayout->addRow(i18n("Save Location:"), mUrlRequester); | 46 | mainLayout->addRow(i18n("Save Location:"), mUrlRequester); | ||
47 | 47 | | |||
48 | // copy file location to clipboard after saving | 48 | // copy file location to clipboard after saving | ||
49 | mCopyPathToClipboard = new QCheckBox(i18n("Copy file location to clipboard after saving"), this); | 49 | mCopyPathToClipboard = new QCheckBox(i18n("Copy file location to clipboard after saving"), this); | ||
50 | connect(mCopyPathToClipboard, &QCheckBox::toggled, this, &SaveOptionsPage::markDirty); | 50 | connect(mCopyPathToClipboard, &QCheckBox::toggled, this, &SaveOptionsPage::markDirty); | ||
51 | mainLayout->addRow(QString(), mCopyPathToClipboard); | 51 | mainLayout->addRow(QString(), mCopyPathToClipboard); | ||
52 | 52 | | |||
53 | 53 | | |||
54 | mainLayout->addItem(new QSpacerItem(0, 18, QSizePolicy::Fixed, QSizePolicy::Fixed)); | 54 | mainLayout->addItem(new QSpacerItem(0, 18, QSizePolicy::Fixed, QSizePolicy::Fixed)); | ||
55 | 55 | | |||
56 | // Compression quality slider and current value display | ||||
57 | QHBoxLayout *sliderHorizLayout = new QHBoxLayout(); | ||||
58 | QVBoxLayout *sliderVertLayout = new QVBoxLayout(); | ||||
59 | | ||||
60 | // Current value | ||||
61 | QLabel *qualityValue = new QLabel(); | ||||
62 | qualityValue->setNum(SpectacleConfig::instance()->compressionQuality()); | ||||
63 | qualityValue->setMinimumWidth(qualityValue->fontInfo().pointSize()*3); | ||||
64 | | ||||
65 | // Slider | ||||
66 | mQualitySlider = new QSlider(Qt::Horizontal); | ||||
67 | mQualitySlider->setRange(0, 100); | ||||
68 | mQualitySlider->setTickInterval(5); | ||||
69 | mQualitySlider->setSliderPosition(SpectacleConfig::instance()->compressionQuality()); | ||||
70 | mQualitySlider->setTickPosition(QSlider::TicksBelow); | ||||
71 | mQualitySlider->setTracking(true); | ||||
72 | connect(mQualitySlider, &QSlider::valueChanged, [=](int value) { | ||||
73 | qualityValue->setNum(value); | ||||
Put the Brace on the same line as the parameter list - this style is already used in this file davidre: Put the Brace on the same line as the parameter list - this style is already used in this file | |||||
74 | markDirty(); | ||||
75 | }); | ||||
76 | | ||||
77 | sliderHorizLayout->addWidget(mQualitySlider); | ||||
78 | sliderHorizLayout->addWidget(qualityValue); | ||||
79 | | ||||
80 | sliderVertLayout->addLayout(sliderHorizLayout); | ||||
81 | | ||||
82 | QLabel *qualitySliderDescription = new QLabel(); | ||||
83 | qualitySliderDescription->setText(i18n("Choose the image quality when saving with lossy image formats like JPEG")); | ||||
84 | | ||||
85 | sliderVertLayout->addWidget(qualitySliderDescription); | ||||
86 | | ||||
87 | mainLayout->addRow(i18n("Compression Quality:"), sliderVertLayout); | ||||
88 | | ||||
89 | mainLayout->addItem(new QSpacerItem(0, 18, QSizePolicy::Fixed, QSizePolicy::Fixed)); | ||||
56 | 90 | | |||
57 | // filename chooser and instructional text | 91 | // filename chooser and instructional text | ||
58 | QVBoxLayout *saveNameLayout = new QVBoxLayout; | 92 | QVBoxLayout *saveNameLayout = new QVBoxLayout; | ||
59 | 93 | | |||
60 | // filename chooser text field | 94 | // filename chooser text field | ||
61 | QHBoxLayout *saveFieldLayout = new QHBoxLayout; | 95 | QHBoxLayout *saveFieldLayout = new QHBoxLayout; | ||
62 | mSaveNameFormat = new QLineEdit; | 96 | mSaveNameFormat = new QLineEdit; | ||
63 | connect(mSaveNameFormat, &QLineEdit::textEdited, this, &SaveOptionsPage::markDirty); | 97 | connect(mSaveNameFormat, &QLineEdit::textEdited, this, &SaveOptionsPage::markDirty); | ||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Line(s) | 168 | { | |||
137 | SpectacleConfig *cfgManager = SpectacleConfig::instance(); | 171 | SpectacleConfig *cfgManager = SpectacleConfig::instance(); | ||
138 | 172 | | |||
139 | // save the data | 173 | // save the data | ||
140 | 174 | | |||
141 | cfgManager->setDefaultSaveLocation(mUrlRequester->url().toDisplayString(QUrl::PreferLocalFile)); | 175 | cfgManager->setDefaultSaveLocation(mUrlRequester->url().toDisplayString(QUrl::PreferLocalFile)); | ||
142 | cfgManager->setAutoSaveFilenameFormat(mSaveNameFormat->text()); | 176 | cfgManager->setAutoSaveFilenameFormat(mSaveNameFormat->text()); | ||
143 | cfgManager->setSaveImageFormat(mSaveImageFormat->currentText().toLower()); | 177 | cfgManager->setSaveImageFormat(mSaveImageFormat->currentText().toLower()); | ||
144 | cfgManager->setCopySaveLocationToClipboard(mCopyPathToClipboard->checkState() == Qt::Checked); | 178 | cfgManager->setCopySaveLocationToClipboard(mCopyPathToClipboard->checkState() == Qt::Checked); | ||
179 | cfgManager->setCompressionQuality(mQualitySlider->value()); | ||||
145 | 180 | | |||
146 | // done | 181 | // done | ||
147 | 182 | | |||
148 | mChangesMade = false; | 183 | mChangesMade = false; | ||
149 | } | 184 | } | ||
150 | 185 | | |||
151 | void SaveOptionsPage::resetChanges() | 186 | void SaveOptionsPage::resetChanges() | ||
152 | { | 187 | { | ||
153 | // bring up the configuration reader | 188 | // bring up the configuration reader | ||
154 | 189 | | |||
155 | SpectacleConfig *cfgManager = SpectacleConfig::instance(); | 190 | SpectacleConfig *cfgManager = SpectacleConfig::instance(); | ||
156 | 191 | | |||
157 | // read in the data | 192 | // read in the data | ||
158 | 193 | | |||
159 | mSaveNameFormat->setText(cfgManager->autoSaveFilenameFormat()); | 194 | mSaveNameFormat->setText(cfgManager->autoSaveFilenameFormat()); | ||
160 | mUrlRequester->setUrl(QUrl::fromUserInput(cfgManager->defaultSaveLocation())); | 195 | mUrlRequester->setUrl(QUrl::fromUserInput(cfgManager->defaultSaveLocation())); | ||
161 | mCopyPathToClipboard->setChecked(cfgManager->copySaveLocationToClipboard()); | 196 | mCopyPathToClipboard->setChecked(cfgManager->copySaveLocationToClipboard()); | ||
197 | mQualitySlider->setSliderPosition(cfgManager->compressionQuality()); | ||||
162 | 198 | | |||
163 | // read in the save image format and calculate its index | 199 | // read in the save image format and calculate its index | ||
164 | 200 | | |||
165 | { | 201 | { | ||
166 | int index = mSaveImageFormat->findText(cfgManager->saveImageFormat().toUpper()); | 202 | int index = mSaveImageFormat->findText(cfgManager->saveImageFormat().toUpper()); | ||
167 | if (index >= 0) { | 203 | if (index >= 0) { | ||
168 | mSaveImageFormat->setCurrentIndex(index); | 204 | mSaveImageFormat->setCurrentIndex(index); | ||
169 | } | 205 | } | ||
170 | } | 206 | } | ||
171 | 207 | | |||
172 | // done | 208 | // done | ||
173 | 209 | | |||
174 | mChangesMade = false; | 210 | mChangesMade = false; | ||
175 | } | 211 | } |
You have added an empty line here.