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+
80104void NamingDialog::saveSettings () {
81105 auto settings = ScreenshotManager::instance ()->settings ();
82106 settings->setValue (" options/flip" , ui.flipNamingCheckBox ->isChecked ());
0 commit comments