videodownloader/gui/setrangedialog.cpp

50 lines
1.5 KiB
C++
Raw Normal View History

2015-09-08 17:05:59 +02:00
#include "./setrangedialog.h"
2015-04-22 19:32:04 +02:00
2015-09-08 17:05:59 +02:00
#include "../network/downloadrange.h"
2015-12-05 22:56:32 +01:00
#include "ui_setrangedialog.h"
2015-04-22 19:32:04 +02:00
#include <qtutilities/misc/dialogutils.h>
2015-04-22 19:32:04 +02:00
#include <QMessageBox>
2019-06-10 22:50:15 +02:00
using namespace QtUtilities;
2015-04-22 19:32:04 +02:00
using namespace Network;
namespace QtGui {
2017-05-01 03:22:50 +02:00
SetRangeDialog::SetRangeDialog(DownloadRange &range, QWidget *parent)
: QDialog(parent)
, m_ui(new Ui::SetRangeDialog)
, m_range(range)
2015-04-22 19:32:04 +02:00
{
m_ui->setupUi(this);
#ifdef Q_OS_WIN32
setStyleSheet(dialogStyle());
2015-04-22 19:32:04 +02:00
#endif
m_ui->fromSpinBox->setValue(range.startOffset());
m_ui->toSpinBox->setValue(range.endOffset());
m_ui->currentPosSpinBox->setValue(range.currentOffset());
connect(m_ui->abortPushButton, &QPushButton::clicked, this, &SetRangeDialog::reject);
connect(m_ui->confirmPushButton, &QPushButton::clicked, this, &SetRangeDialog::confirm);
}
SetRangeDialog::~SetRangeDialog()
2017-05-01 03:22:50 +02:00
{
}
2015-04-22 19:32:04 +02:00
void SetRangeDialog::confirm()
{
2017-05-01 03:22:50 +02:00
if ((m_ui->fromSpinBox->value() < m_ui->toSpinBox->value() || m_ui->toSpinBox->value() < 0)
&& (m_ui->fromSpinBox->value() <= m_ui->currentPosSpinBox->value())
&& (m_ui->toSpinBox->value() > m_ui->currentPosSpinBox->value() || m_ui->toSpinBox->value() < 0)) {
2015-04-22 19:32:04 +02:00
m_range.setStartOffset(m_ui->fromSpinBox->value());
m_range.setEndOffset(m_ui->toSpinBox->value());
m_range.setCurrentOffset(m_ui->currentPosSpinBox->value());
accept();
} else {
QMessageBox::warning(this, this->windowTitle(), tr("Values are invalid."));
}
}
2019-07-20 20:20:58 +02:00
} // namespace QtGui