Commit ccab81e8 authored by David Jarvie's avatar David Jarvie

clazy fixes; use member function syntax for Preferences::connect()

parent 540ded8e
Pipeline #34534 passed with stage
in 15 minutes and 15 seconds
......@@ -152,13 +152,13 @@ void KAlarmApp::initialise()
Preferences::setAutoStart(true);
Preferences::self()->save();
}
Preferences::connect(SIGNAL(startOfDayChanged(QTime)), this, SLOT(changeStartOfDay()));
Preferences::connect(SIGNAL(workTimeChanged(QTime,QTime,QBitArray)), this, SLOT(slotWorkTimeChanged(QTime,QTime,QBitArray)));
Preferences::connect(SIGNAL(holidaysChanged(KHolidays::HolidayRegion)), this, SLOT(slotHolidaysChanged(KHolidays::HolidayRegion)));
Preferences::connect(SIGNAL(feb29TypeChanged(Feb29Type)), this, SLOT(slotFeb29TypeChanged(Feb29Type)));
Preferences::connect(SIGNAL(showInSystemTrayChanged(bool)), this, SLOT(slotShowInSystemTrayChanged()));
Preferences::connect(SIGNAL(archivedKeepDaysChanged(int)), this, SLOT(setArchivePurgeDays()));
Preferences::connect(SIGNAL(messageFontChanged(QFont)), this, SLOT(slotMessageFontChanged(QFont)));
Preferences::connect(&Preferences::startOfDayChanged, this, &KAlarmApp::changeStartOfDay);
Preferences::connect(&Preferences::workTimeChanged, this, &KAlarmApp::slotWorkTimeChanged);
Preferences::connect(&Preferences::holidaysChanged, this, &KAlarmApp::slotHolidaysChanged);
Preferences::connect(&Preferences::feb29TypeChanged, this, &KAlarmApp::slotFeb29TypeChanged);
Preferences::connect(&Preferences::showInSystemTrayChanged, this, &KAlarmApp::slotShowInSystemTrayChanged);
Preferences::connect(&Preferences::archivedKeepDaysChanged, this, &KAlarmApp::setArchivePurgeDays);
Preferences::connect(&Preferences::messageFontChanged, this, &KAlarmApp::slotMessageFontChanged);
slotFeb29TypeChanged(Preferences::defaultFeb29Type());
KAEvent::setStartOfDay(Preferences::startOfDay());
......
......@@ -132,7 +132,7 @@ DailyTimer::~DailyTimer()
DailyTimer* DailyTimer::fixedInstance(const QTime& timeOfDay, bool create)
{
for (DailyTimer* timer : mFixedTimers)
for (DailyTimer* timer : qAsConst(mFixedTimers))
if (timer->mTime == timeOfDay)
return timer;
return create ? new DailyTimer(timeOfDay, true) : nullptr;
......
......@@ -560,8 +560,8 @@ void MainWindow::initActions()
connect(mActionRedo->menu(), &QMenu::triggered, this, &MainWindow::slotRedoItem);
connect(Undo::instance(), &Undo::changed, this, &MainWindow::slotUndoStatus);
connect(mListView, &AlarmListView::findActive, this, &MainWindow::slotFindActive);
Preferences::connect(SIGNAL(archivedKeepDaysChanged(int)), this, SLOT(updateKeepArchived(int)));
Preferences::connect(SIGNAL(showInSystemTrayChanged(bool)), this, SLOT(updateTrayIconAction()));
Preferences::connect(&Preferences::archivedKeepDaysChanged, this, &MainWindow::updateKeepArchived);
Preferences::connect(&Preferences::showInSystemTrayChanged, this, &MainWindow::updateTrayIconAction);
connect(theApp(), &KAlarmApp::trayIconToggled, this, &MainWindow::updateTrayIconAction);
// Set menu item states
......
/*
* preferences.h - program preference settings
* Program: kalarm
* SPDX-FileCopyrightText: 2001-2018 David Jarvie <djarvie@kde.org>
* SPDX-FileCopyrightText: 2001-2020 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
......@@ -25,93 +25,100 @@ namespace KHolidays { class HolidayRegion; }
// Settings configured in the Preferences dialog
class Preferences : public PreferencesBase
{
Q_OBJECT
public:
enum MailFrom { MAIL_FROM_KMAIL, MAIL_FROM_SYS_SETTINGS, MAIL_FROM_ADDR };
static Preferences* self();
static void connect(const char* signal, const QObject* receiver, const char* member);
static int autoHideSystemTray();
static void setAutoHideSystemTray(int timeout);
static bool autoStartChangedByUser() { return mAutoStartChangedByUser; }
static void setAutoStartChangedByUser(bool c){ mAutoStartChangedByUser = c; }
// Access to settings
static QString previousVersion() { return mPreviousVersion; }
static Backend previousBackend() { return mPreviousBackend; }
static void setAskAutoStart(bool yes);
static bool noAutoStart() { return self()->base_NoAutoStart(); }
static void setNoAutoStart(bool yes);
static KADateTime::Spec timeSpec();
static QTimeZone timeSpecAsZone();
static void setTimeSpec(const KADateTime::Spec&);
static const KHolidays::HolidayRegion& holidays();
static void setHolidayRegion(const QString& regionCode);
static QTime startOfDay() { return self()->mBase_StartOfDay.time(); }
static void setStartOfDay(const QTime&);
static QTime workDayStart() { return self()->mBase_WorkDayStart.time(); }
static QTime workDayEnd() { return self()->mBase_WorkDayEnd.time(); }
static QBitArray workDays();
static void setWorkDayStart(const QTime& t) { self()->setBase_WorkDayStart(QDateTime(QDate(1900,1,1), t)); }
static void setWorkDayEnd(const QTime& t) { self()->setBase_WorkDayEnd(QDateTime(QDate(1900,1,1), t)); }
static void setWorkDays(const QBitArray&);
static bool quitWarn() { return mUsingDefaults ? self()->base_QuitWarn() : notifying(QUIT_WARN); }
static void setQuitWarn(bool yes) { setNotify(QUIT_WARN, yes); }
static bool confirmAlarmDeletion() { return mUsingDefaults ? self()->base_ConfirmAlarmDeletion() : notifying(CONFIRM_ALARM_DELETION); }
static void setConfirmAlarmDeletion(bool yes){ setNotify(CONFIRM_ALARM_DELETION, yes); }
static bool emailCopyToKMail() { return self()->mBase_EmailCopyToKMail && self()->mEmailClient == sendmail; }
static void setEmailCopyToKMail(bool yes) { self()->setBase_EmailCopyToKMail(yes); }
static bool emailQueuedNotify() { return mUsingDefaults ? self()->base_EmailQueuedNotify() : notifying(EMAIL_QUEUED_NOTIFY); }
static void setEmailQueuedNotify(bool yes) { setNotify(EMAIL_QUEUED_NOTIFY, yes); }
static MailFrom emailFrom();
static QString emailAddress();
static void setEmailAddress(MailFrom, const QString& address);
static MailFrom emailBccFrom();
static QString emailBccAddress();
static void setEmailBccAddress(bool useSystemSettings, const QString& address);
static bool emailBccUseSystemSettings();
static QString cmdXTermCommand();
static void setCmdXTermCommand(const QString& cmd);
static float defaultSoundVolume() { int vol = self()->mBase_DefaultSoundVolume; return (vol < 0) ? -1 : static_cast<float>(vol) / 100; }
static void setDefaultSoundVolume(float v) { self()->setBase_DefaultSoundVolume(v < 0 ? -1 : static_cast<int>(v * 100)); }
// Config file entry names for notification messages
static const QLatin1String QUIT_WARN;
static const QLatin1String ASK_AUTO_START;
static const QLatin1String CONFIRM_ALARM_DELETION;
static const QLatin1String EMAIL_QUEUED_NOTIFY;
bool useDefaults(bool def) override { mUsingDefaults = def; return PreferencesBase::useDefaults(def); }
Q_SIGNALS:
void timeZoneChanged(const KADateTime::Spec& newTz);
void holidaysChanged(const KHolidays::HolidayRegion& newHolidays);
void startOfDayChanged(const QTime& newStartOfDay);
void workTimeChanged(const QTime& startTime, const QTime& endTime, const QBitArray& workDays);
private Q_SLOTS:
void timeZoneChange(const QString&);
void holidaysChange(const QString& regionCode);
void startDayChange(const QDateTime&);
void workTimeChange(const QDateTime&, const QDateTime&, int days);
private:
Preferences(); // only one instance allowed
static int startOfDayCheck(const QTime&);
static void setNotify(const QString& messageID, bool notify);
static bool notifying(const QString& messageID);
static Preferences* mInstance;
static bool mUsingDefaults;
static KHolidays::HolidayRegion* mHolidays;
static QString mPreviousVersion; // last KAlarm version which wrote the config file
static Backend mPreviousBackend; // backend used by last used version of KAlarm
// All the following members are accessed by the Preferences dialog classes
static int mMessageButtonDelay; // 0 = scatter; -1 = no delay, no scatter; >0 = delay, no scatter
// Change tracking
static bool mAutoStartChangedByUser; // AutoStart has been changed by the user
Q_OBJECT
public:
enum MailFrom { MAIL_FROM_KMAIL, MAIL_FROM_SYS_SETTINGS, MAIL_FROM_ADDR };
static Preferences* self();
static void connect(const char* signal, const QObject* receiver, const char* member);
template<class Signal, class Receiver, class Func,
class = typename std::enable_if<!std::is_convertible<Signal, const char*>::value>::type,
class = typename std::enable_if<!std::is_convertible<Func, const char*>::value>::type>
static void connect(Signal signal, const Receiver* receiver, Func member)
{
QObject::connect(self(), signal, receiver, member);
}
static int autoHideSystemTray();
static void setAutoHideSystemTray(int timeout);
static bool autoStartChangedByUser() { return mAutoStartChangedByUser; }
static void setAutoStartChangedByUser(bool c){ mAutoStartChangedByUser = c; }
// Access to settings
static QString previousVersion() { return mPreviousVersion; }
static Backend previousBackend() { return mPreviousBackend; }
static void setAskAutoStart(bool yes);
static bool noAutoStart() { return self()->base_NoAutoStart(); }
static void setNoAutoStart(bool yes);
static KADateTime::Spec timeSpec();
static QTimeZone timeSpecAsZone();
static void setTimeSpec(const KADateTime::Spec&);
static const KHolidays::HolidayRegion& holidays();
static void setHolidayRegion(const QString& regionCode);
static QTime startOfDay() { return self()->mBase_StartOfDay.time(); }
static void setStartOfDay(const QTime&);
static QTime workDayStart() { return self()->mBase_WorkDayStart.time(); }
static QTime workDayEnd() { return self()->mBase_WorkDayEnd.time(); }
static QBitArray workDays();
static void setWorkDayStart(const QTime& t) { self()->setBase_WorkDayStart(QDateTime(QDate(1900,1,1), t)); }
static void setWorkDayEnd(const QTime& t) { self()->setBase_WorkDayEnd(QDateTime(QDate(1900,1,1), t)); }
static void setWorkDays(const QBitArray&);
static bool quitWarn() { return mUsingDefaults ? self()->base_QuitWarn() : notifying(QUIT_WARN); }
static void setQuitWarn(bool yes) { setNotify(QUIT_WARN, yes); }
static bool confirmAlarmDeletion() { return mUsingDefaults ? self()->base_ConfirmAlarmDeletion() : notifying(CONFIRM_ALARM_DELETION); }
static void setConfirmAlarmDeletion(bool yes){ setNotify(CONFIRM_ALARM_DELETION, yes); }
static bool emailCopyToKMail() { return self()->mBase_EmailCopyToKMail && self()->mEmailClient == sendmail; }
static void setEmailCopyToKMail(bool yes) { self()->setBase_EmailCopyToKMail(yes); }
static bool emailQueuedNotify() { return mUsingDefaults ? self()->base_EmailQueuedNotify() : notifying(EMAIL_QUEUED_NOTIFY); }
static void setEmailQueuedNotify(bool yes) { setNotify(EMAIL_QUEUED_NOTIFY, yes); }
static MailFrom emailFrom();
static QString emailAddress();
static void setEmailAddress(MailFrom, const QString& address);
static MailFrom emailBccFrom();
static QString emailBccAddress();
static void setEmailBccAddress(bool useSystemSettings, const QString& address);
static bool emailBccUseSystemSettings();
static QString cmdXTermCommand();
static void setCmdXTermCommand(const QString& cmd);
static float defaultSoundVolume() { int vol = self()->mBase_DefaultSoundVolume; return (vol < 0) ? -1 : static_cast<float>(vol) / 100; }
static void setDefaultSoundVolume(float v) { self()->setBase_DefaultSoundVolume(v < 0 ? -1 : static_cast<int>(v * 100)); }
// Config file entry names for notification messages
static const QLatin1String QUIT_WARN;
static const QLatin1String ASK_AUTO_START;
static const QLatin1String CONFIRM_ALARM_DELETION;
static const QLatin1String EMAIL_QUEUED_NOTIFY;
bool useDefaults(bool def) override { mUsingDefaults = def; return PreferencesBase::useDefaults(def); }
Q_SIGNALS:
void timeZoneChanged(const KADateTime::Spec& newTz);
void holidaysChanged(const KHolidays::HolidayRegion& newHolidays);
void startOfDayChanged(const QTime& newStartOfDay);
void workTimeChanged(const QTime& startTime, const QTime& endTime, const QBitArray& workDays);
private Q_SLOTS:
void timeZoneChange(const QString&);
void holidaysChange(const QString& regionCode);
void startDayChange(const QDateTime&);
void workTimeChange(const QDateTime&, const QDateTime&, int days);
private:
Preferences(); // only one instance allowed
static int startOfDayCheck(const QTime&);
static void setNotify(const QString& messageID, bool notify);
static bool notifying(const QString& messageID);
static Preferences* mInstance;
static bool mUsingDefaults;
static KHolidays::HolidayRegion* mHolidays;
static QString mPreviousVersion; // last KAlarm version which wrote the config file
static Backend mPreviousBackend; // backend used by last used version of KAlarm
// All the following members are accessed by the Preferences dialog classes
static int mMessageButtonDelay; // 0 = scatter; -1 = no delay, no scatter; >0 = delay, no scatter
// Change tracking
static bool mAutoStartChangedByUser; // AutoStart has been changed by the user
};
#endif // PREFERENCES_H
......
......@@ -112,10 +112,10 @@ FileResourceDataModel::FileResourceDataModel(QObject* parent)
}
MinuteTimer::connect(this, SLOT(slotUpdateTimeTo()));
Preferences::connect(SIGNAL(archivedColourChanged(QColor)), this, SLOT(slotUpdateArchivedColour(QColor)));
Preferences::connect(SIGNAL(disabledColourChanged(QColor)), this, SLOT(slotUpdateDisabledColour(QColor)));
Preferences::connect(SIGNAL(holidaysChanged(KHolidays::HolidayRegion)), this, SLOT(slotUpdateHolidays()));
Preferences::connect(SIGNAL(workTimeChanged(QTime,QTime,QBitArray)), this, SLOT(slotUpdateWorkingHours()));
Preferences::connect(&Preferences::archivedColourChanged, this, &FileResourceDataModel::slotUpdateArchivedColour);
Preferences::connect(&Preferences::disabledColourChanged, this, &FileResourceDataModel::slotUpdateDisabledColour);
Preferences::connect(&Preferences::holidaysChanged, this, &FileResourceDataModel::slotUpdateHolidays);
Preferences::connect(&Preferences::workTimeChanged, this, &FileResourceDataModel::slotUpdateWorkingHours);
}
/******************************************************************************
......
......@@ -181,8 +181,8 @@ void Resources::setStandard(Resource& resource, CalEvent::Type type, bool standa
return;
Resources* manager = instance();
auto it = manager->mResources.find(resource.id());
if (it == manager->mResources.end())
auto it = manager->mResources.constFind(resource.id());
if (it == manager->mResources.constEnd())
return;
resource = it.value(); // just in case it's a different object!
if (standard == resource.configIsStandard(type))
......@@ -211,8 +211,8 @@ void Resources::setStandard(Resource& resource, CalEvent::Types types)
types &= resource.enabledTypes();
Resources* manager = instance();
auto it = manager->mResources.find(resource.id());
if (it == manager->mResources.end())
auto it = manager->mResources.constFind(resource.id());
if (it == manager->mResources.constEnd())
return;
resource = it.value(); // just in case it's a different object!
if (types != resource.configStandardTypes()
......
......@@ -93,7 +93,7 @@ ResourceSelector::ResourceSelector(QWidget* parent)
connect(mAlarmType, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, &ResourceSelector::alarmTypeSelected);
QTimer::singleShot(0, this, &ResourceSelector::alarmTypeSelected);
Preferences::connect(SIGNAL(archivedKeepDaysChanged(int)), this, SLOT(archiveDaysChanged(int)));
Preferences::connect(&Preferences::archivedKeepDaysChanged, this, &ResourceSelector::archiveDaysChanged);
}
/******************************************************************************
......
......@@ -277,7 +277,7 @@ void SoundPicker::slotPickFile()
// Remove mRevertType, setLastType(), #include QTimer
// But wait a moment until setting the radio button, or it won't work.
mRevertType = true; // prevent sound dialog popping up twice
QTimer::singleShot(0, this, SLOT(setLastType()));
QTimer::singleShot(0, this, &SoundPicker::setLastType);
#else
mTypeCombo->setCurrentIndex(indexes[mLastType]);
#endif
......
/*
* startdaytimer.cpp - timer triggered at the user-defined start-of-day time
* Program: kalarm
* SPDX-FileCopyrightText: 2004, 2005, 2009 David Jarvie <djarvie@kde.org>
* SPDX-FileCopyrightText: 2004-2020 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
......@@ -16,7 +16,7 @@ StartOfDayTimer* StartOfDayTimer::mInstance = nullptr;
StartOfDayTimer::StartOfDayTimer()
: DailyTimer(Preferences::startOfDay(), false)
{
Preferences::connect(SIGNAL(startOfDayChanged(QTime)), this, SLOT(startOfDayChanged()));
Preferences::connect(&Preferences::startOfDayChanged, this, &StartOfDayTimer::startOfDayChanged);
}
StartOfDayTimer* StartOfDayTimer::instance()
......
......@@ -127,11 +127,11 @@ TrayWindow::TrayWindow(MainWindow* parent)
mStatusUpdateTimer->setSingleShot(true);
connect(mStatusUpdateTimer, &QTimer::timeout, this, &TrayWindow::updateStatus);
connect(ResourcesCalendar::instance(), &ResourcesCalendar::earliestAlarmChanged, this, &TrayWindow::updateStatus);
Preferences::connect(SIGNAL(autoHideSystemTrayChanged(int)), this, SLOT(updateStatus()));
Preferences::connect(&Preferences::autoHideSystemTrayChanged, this, &TrayWindow::updateStatus);
updateStatus();
// Update when tooltip preferences are modified
Preferences::connect(SIGNAL(tooltipPreferencesChanged()), mToolTipUpdateTimer, SLOT(start()));
Preferences::connect(&Preferences::tooltipPreferencesChanged, mToolTipUpdateTimer, QOverload<>::of(&QTimer::start));
}
TrayWindow::~TrayWindow()
......
Markdown is supported
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