Refactoring.

Switch to using std::chrono.
This commit is contained in:
Roman Telezhynskyi 2024-04-16 11:47:13 +03:00
parent 5b92408fee
commit f46197740d
7 changed files with 11 additions and 10 deletions

View File

@ -214,7 +214,8 @@ auto PreferencesConfigurationPage::Apply() -> QStringList
QTimer *autoSaveTimer = VApplication::VApp()->getAutoSaveTimer();
SCASSERT(autoSaveTimer)
ui->autoSaveCheck->isChecked() ? autoSaveTimer->start(ui->autoTime->value() * 60000) : autoSaveTimer->stop();
ui->autoSaveCheck->isChecked() ? autoSaveTimer->start(std::chrono::minutes{ui->autoTime->value()})
: autoSaveTimer->stop();
settings->SetOsSeparator(ui->osOptionCheck->isChecked());
settings->SetToolBarStyle(ui->toolBarStyleCheck->isChecked());

View File

@ -38,7 +38,6 @@
#include <QMenu>
#include <QTimer>
#include <QUndoStack>
#include <chrono>
using namespace std::chrono_literals;

View File

@ -6256,7 +6256,7 @@ void MainWindow::InitAutoSave()
if (VAbstractValApplication::VApp()->ValentinaSettings()->GetAutosaveState())
{
const qint32 autoTime = VAbstractValApplication::VApp()->ValentinaSettings()->GetAutosaveTime();
m_autoSaveTimer->start(autoTime * 60000);
m_autoSaveTimer->start(std::chrono::minutes{autoTime});
qCDebug(vMainWindow, "Autosaving each %d minutes.", autoTime);
}
VApplication::VApp()->setAutoSaveTimer(m_autoSaveTimer);

View File

@ -76,6 +76,7 @@
#include <QWinTaskbarProgress>
#endif
using namespace std::chrono_literals;
using namespace Qt::Literals::StringLiterals;
QT_WARNING_PUSH
@ -234,7 +235,7 @@ auto MainWindowsNoGUI::GenerateLayout(VLayoutGenerator &lGenerator) -> bool
progressTimer->deleteLater();
}
});
progressTimer->start(1000);
progressTimer->start(1s);
}
LayoutErrors nestingState = LayoutErrors::NoError;

View File

@ -301,9 +301,8 @@ void VGAnalytics::SendAppCloseEvent(qint64 engagementTimeMsec)
if (QNetworkReply *reply = d->SendAnalytics())
{
QTimer timer;
const int timeoutSeconds = 3; // Wait for 3 seconds
timer.setSingleShot(true);
timer.start(timeoutSeconds * 1000);
timer.start(3s);
QEventLoop loop;
connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);

View File

@ -31,6 +31,7 @@
#include <QSharedPointer>
#include <QString>
#include <QtGlobal>
#include <chrono>
#include "../vgeometry/vgeometrydef.h"
#include "../vmisc/typedef.h"
@ -50,7 +51,7 @@ class QListWidget;
class VPieceNode;
class QDialogButtonBox;
constexpr int formulaTimerTimeout = 300;
constexpr std::chrono::milliseconds formulaTimerTimeout = std::chrono::milliseconds(300);
extern const QColor errorColor;

View File

@ -257,9 +257,9 @@ void DialogPlaceLabel::ChosenObject(quint32 id, const SceneObject &type)
CheckPoint();
prepare = true;
timerWidth->setSingleShot(formulaTimerTimeout);
timerHeight->setSingleShot(formulaTimerTimeout);
timerAngle->setSingleShot(formulaTimerTimeout);
timerWidth->setSingleShot(formulaTimerTimeout.count());
timerHeight->setSingleShot(formulaTimerTimeout.count());
timerAngle->setSingleShot(formulaTimerTimeout.count());
this->setModal(true);
this->show();