Commit 2ae72675 authored by Nicolas Fella's avatar Nicolas Fella
Browse files

Avoid manual casting of signals/slots

In one case by renaming a slot so it isn't overloaded any more.
In other cases by using QOverload
parent bd8e8bdd
...@@ -121,8 +121,8 @@ SettingsDialog::SettingsDialog(TopLevel *toplevel, const QList<Tea> &teas) ...@@ -121,8 +121,8 @@ SettingsDialog::SettingsDialog(TopLevel *toplevel, const QList<Tea> &teas)
connect(ui->downButton, &QToolButton::clicked, this, &SettingsDialog::downButtonClicked); connect(ui->downButton, &QToolButton::clicked, this, &SettingsDialog::downButtonClicked);
connect(ui->teaNameEdit, &QLineEdit::textChanged, this, &SettingsDialog::nameValueChanged); connect(ui->teaNameEdit, &QLineEdit::textChanged, this, &SettingsDialog::nameValueChanged);
connect(ui->minutesSpin, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &SettingsDialog::timeValueChanged); connect(ui->minutesSpin, QOverload<int>::of(&QSpinBox::valueChanged), this, &SettingsDialog::timeValueChanged);
connect(ui->secondsSpin, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &SettingsDialog::timeValueChanged); connect(ui->secondsSpin, QOverload<int>::of(&QSpinBox::valueChanged), this, &SettingsDialog::timeValueChanged);
} }
SettingsDialog::~SettingsDialog() SettingsDialog::~SettingsDialog()
......
...@@ -82,8 +82,8 @@ TimeEditDialog::TimeEditDialog(TopLevel *toplevel) ...@@ -82,8 +82,8 @@ TimeEditDialog::TimeEditDialog(TopLevel *toplevel)
x = qMin( qMax( 0, y ), desktopSize.height() - height() ); x = qMin( qMax( 0, y ), desktopSize.height() - height() );
move( QPoint( x, y ) ); move( QPoint( x, y ) );
connect(ui->minutes, static_cast<void (KPluralHandlingSpinBox::*)(int)>(&KPluralHandlingSpinBox::valueChanged), this, &TimeEditDialog::checkOkButtonState); connect(ui->minutes, QOverload<int>::of(&KPluralHandlingSpinBox::valueChanged), this, &TimeEditDialog::checkOkButtonState);
connect(ui->seconds, static_cast<void (KPluralHandlingSpinBox::*)(int)>(&KPluralHandlingSpinBox::valueChanged), this, &TimeEditDialog::checkOkButtonState); connect(ui->seconds, QOverload<int>::of(&KPluralHandlingSpinBox::valueChanged), this, &TimeEditDialog::checkOkButtonState);
connect(buttonBox, &QDialogButtonBox::accepted, this, &TimeEditDialog::accept); connect(buttonBox, &QDialogButtonBox::accepted, this, &TimeEditDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &TimeEditDialog::reject); connect(buttonBox, &QDialogButtonBox::rejected, this, &TimeEditDialog::reject);
......
...@@ -130,7 +130,7 @@ TopLevel::TopLevel(const KAboutData *aboutData, const QString &icon, QWidget *pa ...@@ -130,7 +130,7 @@ TopLevel::TopLevel(const KAboutData *aboutData, const QString &icon, QWidget *pa
m_timer = new QTimer( this ); m_timer = new QTimer( this );
connect(m_timer, &QTimer::timeout, this, &TopLevel::teaTimeEvent); connect(m_timer, &QTimer::timeout, this, &TopLevel::teaTimeEvent);
connect(contextMenu(), static_cast<void (QMenu::*)(QAction*)>(&QMenu::triggered), this, static_cast<void (TopLevel::*)(QAction*)>(&TopLevel::runTea)); connect(contextMenu(), &QMenu::triggered, this, &TopLevel::slotRunTea);
connect(this, &TopLevel::activated, this, &TopLevel::showPopup); connect(this, &TopLevel::activated, this, &TopLevel::showPopup);
loadConfig(); loadConfig();
...@@ -204,7 +204,7 @@ void TopLevel::setTeaList(const QList<Tea> &tealist) { ...@@ -204,7 +204,7 @@ void TopLevel::setTeaList(const QList<Tea> &tealist) {
contextMenu()->addSeparator(); contextMenu()->addSeparator();
contextMenu()->addAction( m_actionCollection->action(QLatin1String(KStandardAction::name(KStandardAction::Quit))) ); contextMenu()->addAction( m_actionCollection->action(QLatin1String(KStandardAction::name(KStandardAction::Quit))) );
connect(contextMenu(), static_cast<void (QMenu::*)(QAction*)>(&QMenu::triggered), this, static_cast<void (TopLevel::*)(QAction*)>(&TopLevel::runTea)); connect(contextMenu(), &QMenu::triggered, this, &TopLevel::slotRunTea);
loadConfig(); loadConfig();
} }
...@@ -237,7 +237,7 @@ void TopLevel::showTimeEditDialog() ...@@ -237,7 +237,7 @@ void TopLevel::showTimeEditDialog()
} }
void TopLevel::runTea(QAction *a) void TopLevel::slotRunTea(QAction *a)
{ {
int index = a->data().toInt(); int index = a->data().toInt();
if( index <= 0 ) { if( index <= 0 ) {
......
...@@ -47,7 +47,7 @@ class TopLevel : public QSystemTrayIcon ...@@ -47,7 +47,7 @@ class TopLevel : public QSystemTrayIcon
void runTea(const Tea &tea); void runTea(const Tea &tea);
private: private:
void runTea(QAction *a); void slotRunTea(QAction *a);
void showSettingsDialog(); void showSettingsDialog();
void showTimeEditDialog(); void showTimeEditDialog();
void teaTimeEvent(); void teaTimeEvent();
......
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