Delay code cleanup
This commit is contained in:
parent
9a90814891
commit
3877799895
@ -5,6 +5,7 @@
|
||||
#include <QAction>
|
||||
#include <QCloseEvent>
|
||||
#include <QCoreApplication>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QListWidgetItem>
|
||||
#include <QMenu>
|
||||
#include <QStatusBar>
|
||||
@ -55,6 +56,12 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
||||
statusBar()->showMessage(errors.at(0).what());
|
||||
else
|
||||
statusBar()->showMessage(QString("Errors visible in console (if present). Count: " + QString::number(errors.size())));
|
||||
|
||||
// Set delay
|
||||
if ((settings::settings().contains("delay")))
|
||||
ui->delay->setValue(settings::settings().value("delay").toDouble());
|
||||
else
|
||||
ui->delay->setValue(0.25);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
@ -67,6 +74,11 @@ void MainWindow::setScheme(QString scheme)
|
||||
ui->nameScheme->setText(scheme);
|
||||
}
|
||||
|
||||
QDoubleSpinBox *MainWindow::delay()
|
||||
{
|
||||
return ui->delay;
|
||||
}
|
||||
|
||||
MainWindow *MainWindow::inst()
|
||||
{
|
||||
return instance;
|
||||
@ -103,12 +115,12 @@ void MainWindow::on_actionQuit_triggered()
|
||||
|
||||
void MainWindow::on_actionFullscreen_triggered()
|
||||
{
|
||||
QTimer::singleShot(0, &screenshotter::fullscreen);
|
||||
screenshotter::fullscreenDelayed();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionArea_triggered()
|
||||
{
|
||||
QTimer::singleShot(0, &screenshotter::area);
|
||||
screenshotter::areaDelayed();
|
||||
}
|
||||
|
||||
void MainWindow::on_uploaderList_clicked(const QModelIndex &)
|
||||
@ -124,3 +136,8 @@ void MainWindow::on_nameScheme_textEdited(const QString &arg1)
|
||||
{
|
||||
settings::settings().setValue("fileFormat", arg1);
|
||||
}
|
||||
|
||||
void MainWindow::on_delay_valueChanged(double arg1)
|
||||
{
|
||||
settings::settings().setValue("delay", arg1);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef MAINWINDOW_HPP
|
||||
#define MAINWINDOW_HPP
|
||||
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QMainWindow>
|
||||
#include <QSystemTrayIcon>
|
||||
|
||||
@ -25,12 +26,15 @@ class MainWindow : public QMainWindow
|
||||
void on_uploaderList_clicked(const QModelIndex &);
|
||||
void on_nameScheme_textEdited(const QString &arg1);
|
||||
|
||||
void on_delay_valueChanged(double arg1);
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
QSystemTrayIcon *tray;
|
||||
void setScheme(QString scheme);
|
||||
QDoubleSpinBox *delay();
|
||||
|
||||
static MainWindow *inst();
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>470</width>
|
||||
<width>471</width>
|
||||
<height>315</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -24,25 +24,49 @@
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Uploader selection:</string>
|
||||
<string>Delay before taking a screenshot</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="uploaderList"/>
|
||||
</item>
|
||||
<item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>File name scheme:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QDoubleSpinBox" name="delay">
|
||||
<property name="toolTip">
|
||||
<string>In seconds</string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>A delay before taking a screenshot, in seconds</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Uploader selection:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>s</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QListWidget" name="uploaderList"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLineEdit" name="nameScheme">
|
||||
<property name="toolTip">
|
||||
<string>http://doc.qt.io/qt-5/qdatetime.html#toString</string>
|
||||
@ -59,7 +83,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>470</width>
|
||||
<width>471</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -1,7 +1,10 @@
|
||||
#include "screenshotter.hpp"
|
||||
#include "cropeditor/cropeditor.hpp"
|
||||
#include "mainwindow.hpp"
|
||||
#include "screenshotutil.hpp"
|
||||
#include "uploaders/uploadersingleton.hpp"
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QTimer>
|
||||
|
||||
void screenshotter::area()
|
||||
{
|
||||
@ -13,3 +16,13 @@ void screenshotter::fullscreen()
|
||||
{
|
||||
UploaderSingleton::inst().upload(screenshotutil::fullscreen());
|
||||
}
|
||||
|
||||
void screenshotter::areaDelayed()
|
||||
{
|
||||
QTimer::singleShot(MainWindow::inst()->delay()->value() * 1000, &screenshotter::area);
|
||||
}
|
||||
|
||||
void screenshotter::fullscreenDelayed()
|
||||
{
|
||||
QTimer::singleShot(MainWindow::inst()->delay()->value() * 1000, &screenshotter::fullscreen);
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ namespace screenshotter
|
||||
{
|
||||
void fullscreen();
|
||||
void area();
|
||||
void fullscreenDelayed();
|
||||
void areaDelayed();
|
||||
}
|
||||
|
||||
#endif // SCREENSHOTTER_HPP
|
||||
|
Loading…
Reference in New Issue
Block a user