Skip to content

Commit

Permalink
Disabled PNG quality, now defaults to fastest compressed
Browse files Browse the repository at this point in the history
also SSL detection runs in a thread to avoid locking the options UI
  • Loading branch information
ckaiser committed Feb 19, 2017
1 parent 9fddf7e commit 4e9691a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
20 changes: 17 additions & 3 deletions dialogs/optionsdialog.cpp
Expand Up @@ -33,6 +33,9 @@
#include <QMenu>
#include <QAction>

#include <QFutureWatcher>
#include <QtConcurrent>

#ifdef Q_OS_WIN
#include <windows.h>
#endif
Expand Down Expand Up @@ -74,6 +77,7 @@ OptionsDialog::OptionsDialog(QWidget *parent) :
}
#endif

setEnabled(false); // We disable the widgets to prevent any user interaction until the settings have loaded.
QMetaObject::invokeMethod(this, "init" , Qt::QueuedConnection);
QMetaObject::invokeMethod(this, "loadSettings", Qt::QueuedConnection);
}
Expand Down Expand Up @@ -207,7 +211,7 @@ void OptionsDialog::loadSettings()
// Advanced
ui.clipboardCheckBox->setChecked(settings()->value("clipboard", true).toBool());
ui.urlClipboardCheckBox->setChecked(settings()->value("urlClipboard", false).toBool());
ui.optiPngCheckBox->setChecked(settings()->value("optipng", true).toBool());
ui.optiPngCheckBox->setChecked(settings()->value("optipng", false).toBool());
ui.closeHideCheckBox->setChecked(settings()->value("closeHide", true).toBool());
ui.currentMonitorCheckBox->setChecked(settings()->value("currentMonitor", false).toBool());
ui.replaceCheckBox->setChecked(settings()->value("replace", false).toBool());
Expand Down Expand Up @@ -433,6 +437,9 @@ void OptionsDialog::updatePreview()
}

ui.previewLabel->setText(preview);

ui.qualitySlider->setEnabled(ui.formatComboBox->currentText() != "PNG");
ui.qualityLabel->setEnabled(ui.qualitySlider->isEnabled());
}

void OptionsDialog::viewHistory()
Expand Down Expand Up @@ -600,9 +607,16 @@ void OptionsDialog::init()
// Version
ui.versionLabel->setText(tr("Version %1").arg(qApp->applicationVersion()));

ui.uploadSslWarningLabel->setVisible(!QSslSocket::supportsSsl());
ui.uploadSslWarningLabel->setVisible(false);

setEnabled(false); // We disable the widgets to prevent any user interaction until the settings have loaded.
// Run the SSL check in another thread (slows down dialog startup considerably).
auto futureWatcher = new QFutureWatcher<bool>(this);
connect(futureWatcher, &QFutureWatcher<bool>::finished, futureWatcher, &QFutureWatcher<bool>::deleteLater);
connect(futureWatcher, &QFutureWatcher<bool>::finished, this, [&, futureWatcher] {
ui.uploadSslWarningLabel->setVisible(!futureWatcher->future().result());
});

futureWatcher->setFuture(QtConcurrent::run([]() -> bool { return QSslSocket::supportsSsl(); }));

//
// Connections
Expand Down
2 changes: 1 addition & 1 deletion lightscreen.pro
Expand Up @@ -53,7 +53,7 @@ FORMS += dialogs/historydialog.ui \
RESOURCES += lightscreen.qrc
CODECFORSRC = UTF-8

QT += core gui widgets network sql multimedia
QT += core gui widgets network sql multimedia concurrent

include($$PWD/tools/SingleApplication/singleapplication.pri)
include($$PWD/tools/UGlobalHotkey/uglobalhotkey.pri)
Expand Down
4 changes: 3 additions & 1 deletion tools/screenshot.cpp
Expand Up @@ -53,7 +53,9 @@ Screenshot::Screenshot(QObject *parent, Screenshot::Options options):
mUnloaded(false),
mUnloadFilename()
{
// Here be crickets
if (mOptions.format == Screenshot::PNG) {
mOptions.quality = 80;
}
}

Screenshot::~Screenshot()
Expand Down

0 comments on commit 4e9691a

Please sign in to comment.