diff --git a/IdealIRC/IRC.cpp b/IdealIRC/IRC.cpp index 4487fe9..dbd49ca 100644 --- a/IdealIRC/IRC.cpp +++ b/IdealIRC/IRC.cpp @@ -23,6 +23,7 @@ #include "config.h" #include <fmt/format.h> #include <QDateTime> +#include <QTimer> IRC::IRC(IWinStatus& status) : m_status(status) @@ -152,8 +153,13 @@ void IRC::onDisconnected() else { auto& conf = ConfigMgr::instance(); bool reconnect = conf.common("Reconnect").toInt(); - if (reconnect && !m_expectDisconnect) - tryConnect(); + if (reconnect && !m_expectDisconnect) { + auto delayReconnectSecs = conf.common("ReconnectDelay").toInt(); + QTimer::singleShot(delayReconnectSecs * 1000, [this] { + if (!m_expectDisconnect) // Note: This flag might be changed during the timer. If reconnection is aborted, it'll change. + tryConnect(); + }); + } } m_expectDisconnect = false; }