From d09854cbc0b593fa1596e39048f51320e245ae24 Mon Sep 17 00:00:00 2001 From: Laurent Montel Date: Fri, 18 Mar 2022 08:18:32 +0100 Subject: [PATCH] Use directly std::chrono_literals --- components/containmentlayoutmanager/appletslayout.cpp | 7 +++++-- components/containmentlayoutmanager/configoverlay.cpp | 5 ++++- components/containmentlayoutmanager/itemcontainer.cpp | 5 ++++- gmenu-dbusmenu-proxy/menuproxy.cpp | 5 ++++- klipper/klipper.cpp | 9 ++++++--- libnotificationmanager/abstractnotificationsmodel.cpp | 5 ++++- libtaskmanager/launchertasksmodel.cpp | 5 ++++- libtaskmanager/xwindowtasksmodel.cpp | 5 ++++- shell/panelconfigview.cpp | 6 +++++- shell/panelview.cpp | 6 ++++-- shell/screenpool.cpp | 6 +++++- shell/scripting/configgroup.cpp | 5 ++++- shell/shellcontainmentconfig.cpp | 10 ++++++---- shell/shellcorona.cpp | 6 ++++-- 14 files changed, 63 insertions(+), 22 deletions(-) diff --git a/components/containmentlayoutmanager/appletslayout.cpp b/components/containmentlayoutmanager/appletslayout.cpp index 6e0328cda..4ae05b8f8 100644 --- a/components/containmentlayoutmanager/appletslayout.cpp +++ b/components/containmentlayoutmanager/appletslayout.cpp @@ -18,6 +18,9 @@ #include #include #include +#include + +using namespace std::chrono_literals; AppletsLayout::AppletsLayout(QQuickItem *parent) : QQuickItem(parent) @@ -29,7 +32,7 @@ AppletsLayout::AppletsLayout(QQuickItem *parent) m_saveLayoutTimer = new QTimer(this); m_saveLayoutTimer->setSingleShot(true); - m_saveLayoutTimer->setInterval(100); + m_saveLayoutTimer->setInterval(100ms); connect(m_layoutManager, &AbstractLayoutManager::layoutNeedsSaving, m_saveLayoutTimer, QOverload<>::of(&QTimer::start)); connect(m_saveLayoutTimer, &QTimer::timeout, this, [this]() { // We can't assume m_containment to be valid: if we load in a plasmoid that can run also @@ -53,7 +56,7 @@ AppletsLayout::AppletsLayout(QQuickItem *parent) m_layoutChangeTimer = new QTimer(this); m_layoutChangeTimer->setSingleShot(true); - m_layoutChangeTimer->setInterval(100); + m_layoutChangeTimer->setInterval(100ms); connect(m_layoutChangeTimer, &QTimer::timeout, this, [this]() { // We can't assume m_containment to be valid: if we load in a plasmoid that can run also // in "applet" mode, m_containment will never be valid diff --git a/components/containmentlayoutmanager/configoverlay.cpp b/components/containmentlayoutmanager/configoverlay.cpp index 0fb755a0f..d3249c2b1 100644 --- a/components/containmentlayoutmanager/configoverlay.cpp +++ b/components/containmentlayoutmanager/configoverlay.cpp @@ -6,14 +6,17 @@ #include "configoverlay.h" +#include #include +using namespace std::chrono_literals; + ConfigOverlay::ConfigOverlay(QQuickItem *parent) : QQuickItem(parent) { m_hideTimer = new QTimer(this); m_hideTimer->setSingleShot(true); - m_hideTimer->setInterval(600); + m_hideTimer->setInterval(600ms); connect(m_hideTimer, &QTimer::timeout, this, [this]() { setVisible(false); }); diff --git a/components/containmentlayoutmanager/itemcontainer.cpp b/components/containmentlayoutmanager/itemcontainer.cpp index d76fcd949..436cf78bd 100644 --- a/components/containmentlayoutmanager/itemcontainer.cpp +++ b/components/containmentlayoutmanager/itemcontainer.cpp @@ -17,6 +17,9 @@ #include #include +#include + +using namespace std::chrono_literals; ItemContainer::ItemContainer(QQuickItem *parent) : QQuickItem(parent) @@ -656,7 +659,7 @@ void ItemContainer::hoverLeaveEvent(QHoverEvent *event) if (!m_closeEditModeTimer) { m_closeEditModeTimer = new QTimer(this); m_closeEditModeTimer->setSingleShot(true); - m_closeEditModeTimer->setInterval(500); + m_closeEditModeTimer->setInterval(500ms); connect(m_closeEditModeTimer, &QTimer::timeout, this, [this]() { setEditMode(false); }); diff --git a/gmenu-dbusmenu-proxy/menuproxy.cpp b/gmenu-dbusmenu-proxy/menuproxy.cpp index 5fb2faffb..df64bca00 100644 --- a/gmenu-dbusmenu-proxy/menuproxy.cpp +++ b/gmenu-dbusmenu-proxy/menuproxy.cpp @@ -32,6 +32,9 @@ #include #include "window.h" +#include + +using namespace std::chrono_literals; static const QString s_ourServiceName = QStringLiteral("org.kde.plasma.gmenu_dbusmenu_proxy"); @@ -87,7 +90,7 @@ MenuProxy::MenuProxy() // kde-gtk-config just deletes and re-creates the gtkrc-2.0, watch this and add our config to it again m_writeGtk2SettingsTimer->setSingleShot(true); - m_writeGtk2SettingsTimer->setInterval(1000); + m_writeGtk2SettingsTimer->setInterval(1s); connect(m_writeGtk2SettingsTimer, &QTimer::timeout, this, &MenuProxy::writeGtk2Settings); auto startGtk2SettingsTimer = [this] { diff --git a/klipper/klipper.cpp b/klipper/klipper.cpp index 360c430c3..96f469cce 100644 --- a/klipper/klipper.cpp +++ b/klipper/klipper.cpp @@ -47,7 +47,10 @@ #else #include #endif +#include #include + +using namespace std::chrono_literals; #endif namespace @@ -351,7 +354,7 @@ void Klipper::loadSettings() if (m_bKeepContents && !m_saveFileTimer) { m_saveFileTimer = new QTimer(this); m_saveFileTimer->setSingleShot(true); - m_saveFileTimer->setInterval(5000); + m_saveFileTimer->setInterval(5s); connect(m_saveFileTimer, &QTimer::timeout, this, [this] { #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QtConcurrent::run(this, &Klipper::saveHistory, false); @@ -682,12 +685,12 @@ bool Klipper::blockFetchingNewData() if (((queryPointer->mask & (XCB_KEY_BUT_MASK_SHIFT | XCB_KEY_BUT_MASK_BUTTON_1)) == XCB_KEY_BUT_MASK_SHIFT) // BUG: 85198 || ((queryPointer->mask & XCB_KEY_BUT_MASK_BUTTON_1) == XCB_KEY_BUT_MASK_BUTTON_1)) { // BUG: 80302 m_pendingContentsCheck = true; - m_pendingCheckTimer.start(100); + m_pendingCheckTimer.start(100ms); return true; } m_pendingContentsCheck = false; if (m_overflowCounter == 0) - m_overflowClearTimer.start(1000); + m_overflowClearTimer.start(1s); if (++m_overflowCounter > MAX_CLIPBOARD_CHANGES) return true; #endif diff --git a/libnotificationmanager/abstractnotificationsmodel.cpp b/libnotificationmanager/abstractnotificationsmodel.cpp index b730d34d2..2ae4790ff 100644 --- a/libnotificationmanager/abstractnotificationsmodel.cpp +++ b/libnotificationmanager/abstractnotificationsmodel.cpp @@ -18,8 +18,11 @@ #include #include +#include #include +using namespace std::chrono_literals; + static const int s_notificationsLimit = 1000; using namespace NotificationManager; @@ -29,7 +32,7 @@ AbstractNotificationsModel::Private::Private(AbstractNotificationsModel *q) , lastRead(QDateTime::currentDateTimeUtc()) { pendingRemovalTimer.setSingleShot(true); - pendingRemovalTimer.setInterval(50); + pendingRemovalTimer.setInterval(50ms); connect(&pendingRemovalTimer, &QTimer::timeout, q, [this, q] { QVector rowsToBeRemoved; rowsToBeRemoved.reserve(pendingRemovals.count()); diff --git a/libtaskmanager/launchertasksmodel.cpp b/libtaskmanager/launchertasksmodel.cpp index ec7666717..c04f5886c 100644 --- a/libtaskmanager/launchertasksmodel.cpp +++ b/libtaskmanager/launchertasksmodel.cpp @@ -35,6 +35,9 @@ #endif #include "launchertasksmodel_p.h" +#include + +using namespace std::chrono_literals; namespace TaskManager { @@ -86,7 +89,7 @@ LauncherTasksModel::Private::Private(LauncherTasksModel *q) void LauncherTasksModel::Private::init() { sycocaChangeTimer.setSingleShot(true); - sycocaChangeTimer.setInterval(100); + sycocaChangeTimer.setInterval(100ms); QObject::connect(&sycocaChangeTimer, &QTimer::timeout, q, [this]() { if (!launchersOrder.count()) { diff --git a/libtaskmanager/xwindowtasksmodel.cpp b/libtaskmanager/xwindowtasksmodel.cpp index 679ca36de..4130400dc 100644 --- a/libtaskmanager/xwindowtasksmodel.cpp +++ b/libtaskmanager/xwindowtasksmodel.cpp @@ -30,6 +30,9 @@ #include #else #include +#include + +using namespace std::chrono_literals; #endif namespace TaskManager @@ -122,7 +125,7 @@ void XWindowTasksModel::Private::init() cachedStackingOrder = KWindowSystem::stackingOrder(); sycocaChangeTimer.setSingleShot(true); - sycocaChangeTimer.setInterval(100); + sycocaChangeTimer.setInterval(100ms); QObject::connect(&sycocaChangeTimer, &QTimer::timeout, q, clearCacheAndRefresh); diff --git a/shell/panelconfigview.cpp b/shell/panelconfigview.cpp index 34ff82a4a..536541b5d 100644 --- a/shell/panelconfigview.cpp +++ b/shell/panelconfigview.cpp @@ -27,6 +27,10 @@ #include #include +#include + +using namespace std::chrono_literals; + //////////////////////////////PanelConfigView PanelConfigView::PanelConfigView(Plasma::Containment *containment, PanelView *panelView, QWindow *parent) : ConfigView(containment, parent) @@ -39,7 +43,7 @@ PanelConfigView::PanelConfigView(Plasma::Containment *containment, PanelView *pa connect(panelView, &QWindow::screenChanged, &m_screenSyncTimer, QOverload<>::of(&QTimer::start)); m_screenSyncTimer.setSingleShot(true); - m_screenSyncTimer.setInterval(150); + m_screenSyncTimer.setInterval(150ms); connect(&m_screenSyncTimer, &QTimer::timeout, [=]() { setScreen(panelView->screen()); KWindowSystem::setType(winId(), NET::Dock); diff --git a/shell/panelview.cpp b/shell/panelview.cpp index 283133913..66bf140d8 100644 --- a/shell/panelview.cpp +++ b/shell/panelview.cpp @@ -43,7 +43,9 @@ #endif #include #endif +#include +using namespace std::chrono_literals; static const int MINSIZE = 10; PanelView::PanelView(ShellCorona *corona, QScreen *targetScreen, QWindow *parent) @@ -85,7 +87,7 @@ PanelView::PanelView(ShellCorona *corona, QScreen *targetScreen, QWindow *parent connect(&m_positionPaneltimer, &QTimer::timeout, this, &PanelView::restore); m_unhideTimer.setSingleShot(true); - m_unhideTimer.setInterval(500); + m_unhideTimer.setInterval(500ms); connect(&m_unhideTimer, &QTimer::timeout, this, &PanelView::restoreAutoHide); m_lastScreen = targetScreen; @@ -1355,7 +1357,7 @@ void PanelView::showTemporarily() QTimer *t = new QTimer(this); t->setSingleShot(true); - t->setInterval(3000); + t->setInterval(3s); connect(t, &QTimer::timeout, this, &PanelView::restoreAutoHide); connect(t, &QTimer::timeout, t, &QObject::deleteLater); t->start(); diff --git a/shell/screenpool.cpp b/shell/screenpool.cpp index 40734c8e8..7be4cea54 100644 --- a/shell/screenpool.cpp +++ b/shell/screenpool.cpp @@ -19,6 +19,10 @@ #define CHECK_SCREEN_INVARIANTS #endif +#include + +using namespace std::chrono_literals; + ScreenPool::ScreenPool(const KSharedConfig::Ptr &config, QObject *parent) : QObject(parent) , m_configGroup(KConfigGroup(config, QStringLiteral("ScreenConnectors"))) @@ -29,7 +33,7 @@ ScreenPool::ScreenPool(const KSharedConfig::Ptr &config, QObject *parent) connect(m_primaryWatcher, &PrimaryOutputWatcher::primaryOutputNameChanged, this, &ScreenPool::handlePrimaryOutputNameChanged); m_reconsiderOutputsTimer.setSingleShot(true); - m_reconsiderOutputsTimer.setInterval(250); + m_reconsiderOutputsTimer.setInterval(250ms); connect(&m_reconsiderOutputsTimer, &QTimer::timeout, this, &ScreenPool::reconsiderOutputs); m_configSaveTimer.setSingleShot(true); diff --git a/shell/scripting/configgroup.cpp b/shell/scripting/configgroup.cpp index 2f445a20b..e9df838de 100644 --- a/shell/scripting/configgroup.cpp +++ b/shell/scripting/configgroup.cpp @@ -10,10 +10,13 @@ #include #include +#include #include #include #include +using namespace std::chrono_literals; + class ConfigGroupPrivate { public: @@ -44,7 +47,7 @@ ConfigGroup::ConfigGroup(QObject *parent) // Delay and compress everything within 5 seconds into one sync d->synchTimer = new QTimer(this); d->synchTimer->setSingleShot(true); - d->synchTimer->setInterval(1500); + d->synchTimer->setInterval(1500ms); connect(d->synchTimer, &QTimer::timeout, this, &ConfigGroup::sync); } diff --git a/shell/shellcontainmentconfig.cpp b/shell/shellcontainmentconfig.cpp index a9e9c7cb7..10e2fca53 100644 --- a/shell/shellcontainmentconfig.cpp +++ b/shell/shellcontainmentconfig.cpp @@ -17,10 +17,12 @@ #include #include -#include "shellcorona.h" -#include "screenpool.h" #include "panelview.h" +#include "screenpool.h" +#include "shellcorona.h" +#include +using namespace std::chrono_literals; ScreenPoolModel::ScreenPoolModel(ShellCorona *corona, QObject *parent) : QAbstractListModel(parent) @@ -28,7 +30,7 @@ ScreenPoolModel::ScreenPoolModel(ShellCorona *corona, QObject *parent) { m_reloadTimer = new QTimer(this); m_reloadTimer->setSingleShot(true); - m_reloadTimer->setInterval(200); + m_reloadTimer->setInterval(200ms); connect(m_reloadTimer, &QTimer::timeout, this, &ScreenPoolModel::load); @@ -148,7 +150,7 @@ ShellContainmentModel::ShellContainmentModel(ShellCorona *corona, int screenId, { m_reloadTimer = new QTimer(this); m_reloadTimer->setSingleShot(true); - m_reloadTimer->setInterval(200); + m_reloadTimer->setInterval(200ms); connect(m_reloadTimer, &QTimer::timeout, this, &ShellContainmentModel::load); diff --git a/shell/shellcorona.cpp b/shell/shellcorona.cpp index aa47964f4..97e8cca6c 100644 --- a/shell/shellcorona.cpp +++ b/shell/shellcorona.cpp @@ -77,7 +77,9 @@ #endif #include #endif +#include +using namespace std::chrono_literals; static const int s_configSyncDelay = 10000; // 10 seconds ShellCorona::ShellCorona(QObject *parent) @@ -117,12 +119,12 @@ void ShellCorona::init() connect(this, &Corona::configSynced, this, &ShellCorona::syncAppConfig); m_waitingPanelsTimer.setSingleShot(true); - m_waitingPanelsTimer.setInterval(250); + m_waitingPanelsTimer.setInterval(250ms); connect(&m_waitingPanelsTimer, &QTimer::timeout, this, &ShellCorona::createWaitingPanels); #ifndef NDEBUG m_invariantsTimer.setSingleShot(true); - m_invariantsTimer.setInterval(250); + m_invariantsTimer.setInterval(250ms); connect(&m_invariantsTimer, &QTimer::timeout, this, &ShellCorona::screenInvariants); #endif