Skip to content

Commit 090f54a

Browse files
committed
Added preview to date naming window, removed WEBP option (terribly slow)
1 parent 6858918 commit 090f54a

File tree

5 files changed

+60
-23
lines changed

5 files changed

+60
-23
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
##Lightscreen
1+
## Lightscreen
22
[![Build status](https://ci.appveyor.com/api/projects/status/26q7pg1q5u4ukxbg?svg=true)](https://ci.appveyor.com/project/ckaiser/lightscreen) [![Coverity status](https://scan.coverity.com/projects/6066/badge.svg)](https://scan.coverity.com/projects/ckaiser-lightscreen)
33

44
A screenshot tool.

dialogs/namingdialog.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <tools/os.h>
2222
#include <tools/screenshotmanager.h>
2323

24+
#include <QDateTime>
2425
#include <QDesktopServices>
2526
#include <QKeyEvent>
2627
#include <QSettings>
@@ -48,13 +49,16 @@ NamingDialog::NamingDialog(Screenshot::Naming naming, QWidget *parent) :
4849
ui.dateFormatComboBox->setCurrentIndex(ui.dateFormatComboBox->count() - 1);
4950
}
5051

52+
updateDatePreview();
53+
5154
ui.leadingZerosSpinBox->setValue(settings->value("options/naming/leadingZeros", 0).toInt());
5255

5356
// Signals/Slots
5457
connect(ui.buttonBox , &QDialogButtonBox::accepted, this, &NamingDialog::saveSettings);
5558
connect(ui.dateHelpLabel, &QLabel::linkActivated, this, [](const QUrl &url) {
5659
QDesktopServices::openUrl(QUrl(url));
5760
});
61+
connect(ui.dateFormatComboBox, &QComboBox::currentTextChanged, this, &NamingDialog::updateDatePreview);
5862

5963
// Stack & window size adjustments
6064
ui.stack->setCurrentIndex((int)naming);
@@ -68,15 +72,35 @@ bool NamingDialog::eventFilter(QObject *object, QEvent *event)
6872
if (event->type() == QEvent::KeyPress
6973
&& object == ui.dateFormatComboBox) {
7074
QKeyEvent *keyEvent = (QKeyEvent *)(event);
75+
#ifdef Q_OS_WIN
7176
if (QRegExp("[?:\\\\/*\"<>|]").exactMatch(keyEvent->text())) {
7277
event->ignore();
7378
return true;
7479
}
80+
#endif
81+
82+
#ifdef Q_OS_MACOS
83+
if (keyEvent->text().contains(":")) {
84+
event->ignore();
85+
return true;
86+
}
87+
#endif
88+
89+
#ifdef Q_OS_UNIX
90+
if (keyEvent->text().contains("/")) {
91+
event->ignore();
92+
return true;
93+
}
94+
#endif
7595
}
7696

7797
return QDialog::eventFilter(object, event);
7898
}
7999

100+
void NamingDialog::updateDatePreview() {
101+
ui.datePreviewLabel->setText(tr("<u>Preview</u>: ") + QDateTime::currentDateTime().toString(ui.dateFormatComboBox->currentText()));
102+
}
103+
80104
void NamingDialog::saveSettings() {
81105
auto settings = ScreenshotManager::instance()->settings();
82106
settings->setValue("options/flip" , ui.flipNamingCheckBox->isChecked());

dialogs/namingdialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class NamingDialog : public QDialog
3636

3737
public slots:
3838
void saveSettings();
39+
void updateDatePreview();
3940

4041
private:
4142
Ui::NamingDialog ui;

dialogs/namingdialog.ui

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,21 @@
130130
<property name="horizontalSpacing">
131131
<number>0</number>
132132
</property>
133-
<item row="0" column="0">
134-
<widget class="QLabel" name="dateFormatLabel">
133+
<item row="1" column="2">
134+
<widget class="QLabel" name="dateHelpLabel">
135+
<property name="font">
136+
<font>
137+
<pointsize>10</pointsize>
138+
</font>
139+
</property>
140+
<property name="styleSheet">
141+
<string notr="true">margin-left: 4px</string>
142+
</property>
135143
<property name="text">
136-
<string>Date Format:</string>
144+
<string notr="true"> &lt;a href=&quot;https://lightscreen.com.ar/help#date&quot;&gt;[?]&lt;/a&gt;</string>
145+
</property>
146+
<property name="alignment">
147+
<set>Qt::AlignCenter</set>
137148
</property>
138149
</widget>
139150
</item>
@@ -150,21 +161,10 @@
150161
</property>
151162
</spacer>
152163
</item>
153-
<item row="1" column="2">
154-
<widget class="QLabel" name="dateHelpLabel">
155-
<property name="font">
156-
<font>
157-
<pointsize>10</pointsize>
158-
</font>
159-
</property>
160-
<property name="styleSheet">
161-
<string notr="true">margin-left: 4px</string>
162-
</property>
164+
<item row="0" column="0">
165+
<widget class="QLabel" name="dateFormatLabel">
163166
<property name="text">
164-
<string notr="true"> &lt;a href=&quot;https://lightscreen.com.ar/help#date&quot;&gt;[?]&lt;/a&gt;</string>
165-
</property>
166-
<property name="alignment">
167-
<set>Qt::AlignCenter</set>
167+
<string>Date Format:</string>
168168
</property>
169169
</widget>
170170
</item>
@@ -183,6 +183,23 @@
183183
<string notr="true">yyyy-MM-dd HH.mm.ss</string>
184184
</property>
185185
</item>
186+
<item>
187+
<property name="text">
188+
<string>ddd MMMM d yy</string>
189+
</property>
190+
</item>
191+
<item>
192+
<property name="text">
193+
<string>dddd d of MMMM</string>
194+
</property>
195+
</item>
196+
</widget>
197+
</item>
198+
<item row="2" column="0">
199+
<widget class="QLabel" name="datePreviewLabel">
200+
<property name="text">
201+
<string notr="true"/>
202+
</property>
186203
</widget>
187204
</item>
188205
</layout>

dialogs/optionsdialog.ui

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,6 @@
198198
<string notr="true">BMP</string>
199199
</property>
200200
</item>
201-
<item>
202-
<property name="text">
203-
<string>WEBP</string>
204-
</property>
205-
</item>
206201
</widget>
207202
</item>
208203
<item row="4" column="0">

0 commit comments

Comments
 (0)