Commit 8ce0d2df authored by Harald Sitter's avatar Harald Sitter 🏳️‍🌈
Browse files

use chrono literals where possible

improves readability substantially
parent 02fc8757
......@@ -9,6 +9,8 @@
#include "reportassistantpages_bugzilla.h"
#include <chrono>
#include <QAction>
#include <QCheckBox>
#include <QCursor>
......@@ -43,6 +45,8 @@
#include "statuswidget.h"
#include "systeminformation.h"
using namespace std::chrono_literals;
static const char kWalletEntryName[] = "drkonqi_bugzilla";
static const char kWalletEntryUsername[] = "username";
static const char kWalletEntryPassword[] = "password";
......@@ -152,7 +156,7 @@ void BugzillaLoginPage::aboutToShow()
bugzillaManager()->getUsername()));
} else {
// Try to show wallet dialog once this dialog is shown
QTimer::singleShot(100, this, &BugzillaLoginPage::walletLogin);
QTimer::singleShot(100ms, this, &BugzillaLoginPage::walletLogin);
// ...also reset focus. walletLogin may be fully no-op and not set focus
// if it failed to do anything which leaves the focus elsewhere
ui.m_userEdit->setFocus(Qt::OtherFocusReason);
......
......@@ -6,11 +6,14 @@
#include "detachedprocessmonitor.h"
#include "drkonqi_debug.h"
#include <chrono>
#include <errno.h>
#include <signal.h>
#include <QTimerEvent>
using namespace std::chrono_literals;
DetachedProcessMonitor::DetachedProcessMonitor(QObject *parent)
: QObject(parent)
, m_pid(0)
......@@ -20,7 +23,7 @@ DetachedProcessMonitor::DetachedProcessMonitor(QObject *parent)
void DetachedProcessMonitor::startMonitoring(int pid)
{
m_pid = pid;
startTimer(10);
startTimer(10ms);
}
void DetachedProcessMonitor::timerEvent(QTimerEvent *event)
......
......@@ -7,6 +7,8 @@
#include "drkonqi.h"
#include "drkonqi_debug.h"
#include <chrono>
#include <QFileDialog>
#include <QPointer>
#include <QTemporaryFile>
......@@ -26,6 +28,8 @@
#include "drkonqibackends.h"
#include "systeminformation.h"
using namespace std::chrono_literals;
DrKonqi::DrKonqi()
: m_systemInformation(new SystemInformation())
, m_backend(new KCrashBackend())
......@@ -58,7 +62,7 @@ class EnableCrashCatchingDelayed : public QObject
public:
EnableCrashCatchingDelayed()
{
startTimer(10000); // 10 s
startTimer(10s);
}
protected:
......
......@@ -6,6 +6,7 @@
#include "drkonqibackends.h"
#include <cerrno>
#include <chrono>
#include <cstdlib>
#include <signal.h>
#include <sys/types.h>
......@@ -31,6 +32,8 @@
#include <AvailabilityMacros.h>
#endif
using namespace std::chrono_literals;
AbstractDrKonqiBackend::~AbstractDrKonqiBackend() = default;
bool AbstractDrKonqiBackend::init()
......@@ -91,7 +94,7 @@ bool KCrashBackend::init()
// to reach the alarm(0); call in kdeui/util/kcrash.cpp line 406 or else
// if we stop it before this call, pending alarm signals will kill the
// process when we try to continue it.
QTimer::singleShot(2000, this, &KCrashBackend::stopAttachedProcess);
QTimer::singleShot(2s, this, &KCrashBackend::stopAttachedProcess);
}
#endif
......
......@@ -6,6 +6,8 @@
#include "statusnotifier.h"
#include <chrono>
#include <QAction>
#include <QDBusConnectionInterface>
#include <QDBusServiceWatcher>
......@@ -21,6 +23,8 @@
#include "crashedapplication.h"
#include "drkonqi.h"
using namespace std::chrono_literals;
StatusNotifier::StatusNotifier(QObject *parent)
: QObject(parent)
, m_autoCloseTimer(new QTimer(this))
......@@ -50,7 +54,7 @@ void StatusNotifier::show()
// if nobody bothered to look at the crash after 1 minute, just close
m_autoCloseTimer->setSingleShot(true);
m_autoCloseTimer->setInterval(60000);
m_autoCloseTimer->setInterval(1min);
m_autoCloseTimer->start();
connect(m_autoCloseTimer, &QTimer::timeout, this, &StatusNotifier::expired);
connect(this, &StatusNotifier::activated, this, &StatusNotifier::deleteLater);
......@@ -94,7 +98,7 @@ void StatusNotifier::show()
// We are tracking the related Notifications service here, because actually
// tracking the Host interface is fairly involved with no tangible advantage.
auto activateTimer = new QTimer(this);
activateTimer->setInterval(10000);
activateTimer->setInterval(10s);
connect(activateTimer, &QTimer::timeout, this, &StatusNotifier::activated);
auto watcher =
......@@ -103,7 +107,7 @@ void StatusNotifier::show()
connect(watcher, &QDBusServiceWatcher::serviceRegistered, activateTimer, &QTimer::stop);
// make sure the user doesn't miss the SNI by stopping the auto hide timer when the session becomes idle
int idleId = KIdleTime::instance()->addIdleTimeout(30000);
int idleId = KIdleTime::instance()->addIdleTimeout(int(std::chrono::milliseconds(30s).count()));
connect(KIdleTime::instance(), static_cast<void (KIdleTime::*)(int, int)>(&KIdleTime::timeoutReached), this, [this, idleId](int id) {
if (idleId == id) {
m_autoCloseTimer->stop();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment