Skip to content

Commit

Permalink
Added preview to date naming window, removed WEBP option (terribly slow)
Browse files Browse the repository at this point in the history
  • Loading branch information
ckaiser committed May 1, 2021
1 parent 6858918 commit 090f54a
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##Lightscreen
## Lightscreen
[![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)

A screenshot tool.
Expand Down
24 changes: 24 additions & 0 deletions dialogs/namingdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <tools/os.h>
#include <tools/screenshotmanager.h>

#include <QDateTime>
#include <QDesktopServices>
#include <QKeyEvent>
#include <QSettings>
Expand Down Expand Up @@ -48,13 +49,16 @@ NamingDialog::NamingDialog(Screenshot::Naming naming, QWidget *parent) :
ui.dateFormatComboBox->setCurrentIndex(ui.dateFormatComboBox->count() - 1);
}

updateDatePreview();

ui.leadingZerosSpinBox->setValue(settings->value("options/naming/leadingZeros", 0).toInt());

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

// Stack & window size adjustments
ui.stack->setCurrentIndex((int)naming);
Expand All @@ -68,15 +72,35 @@ bool NamingDialog::eventFilter(QObject *object, QEvent *event)
if (event->type() == QEvent::KeyPress
&& object == ui.dateFormatComboBox) {
QKeyEvent *keyEvent = (QKeyEvent *)(event);
#ifdef Q_OS_WIN
if (QRegExp("[?:\\\\/*\"<>|]").exactMatch(keyEvent->text())) {
event->ignore();
return true;
}
#endif

#ifdef Q_OS_MACOS
if (keyEvent->text().contains(":")) {
event->ignore();
return true;
}
#endif

#ifdef Q_OS_UNIX
if (keyEvent->text().contains("/")) {
event->ignore();
return true;
}
#endif
}

return QDialog::eventFilter(object, event);
}

void NamingDialog::updateDatePreview() {
ui.datePreviewLabel->setText(tr("<u>Preview</u>: ") + QDateTime::currentDateTime().toString(ui.dateFormatComboBox->currentText()));
}

void NamingDialog::saveSettings() {
auto settings = ScreenshotManager::instance()->settings();
settings->setValue("options/flip" , ui.flipNamingCheckBox->isChecked());
Expand Down
1 change: 1 addition & 0 deletions dialogs/namingdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class NamingDialog : public QDialog

public slots:
void saveSettings();
void updateDatePreview();

private:
Ui::NamingDialog ui;
Expand Down
51 changes: 34 additions & 17 deletions dialogs/namingdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,21 @@
<property name="horizontalSpacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="dateFormatLabel">
<item row="1" column="2">
<widget class="QLabel" name="dateHelpLabel">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">margin-left: 4px</string>
</property>
<property name="text">
<string>Date Format:</string>
<string notr="true"> &lt;a href=&quot;https://lightscreen.com.ar/help#date&quot;&gt;[?]&lt;/a&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
Expand All @@ -150,21 +161,10 @@
</property>
</spacer>
</item>
<item row="1" column="2">
<widget class="QLabel" name="dateHelpLabel">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">margin-left: 4px</string>
</property>
<item row="0" column="0">
<widget class="QLabel" name="dateFormatLabel">
<property name="text">
<string notr="true"> &lt;a href=&quot;https://lightscreen.com.ar/help#date&quot;&gt;[?]&lt;/a&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<string>Date Format:</string>
</property>
</widget>
</item>
Expand All @@ -183,6 +183,23 @@
<string notr="true">yyyy-MM-dd HH.mm.ss</string>
</property>
</item>
<item>
<property name="text">
<string>ddd MMMM d yy</string>
</property>
</item>
<item>
<property name="text">
<string>dddd d of MMMM</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="datePreviewLabel">
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
</layout>
Expand Down
5 changes: 0 additions & 5 deletions dialogs/optionsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,6 @@
<string notr="true">BMP</string>
</property>
</item>
<item>
<property name="text">
<string>WEBP</string>
</property>
</item>
</widget>
</item>
<item row="4" column="0">
Expand Down

0 comments on commit 090f54a

Please sign in to comment.