Commit 6855de6b authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

Move to modern connect syntax

parent 28ce1c5e
......@@ -90,8 +90,12 @@ void TopLevel::registerGameboard(const QString &menuText, const QString &board,
{
KToggleAction *t = new KToggleAction(menuText, this);
actionCollection()->addAction(board, t);
t->setData(board);
connect(t, SIGNAL(toggled(bool)), SLOT(changeGameboard()));
connect(t, &KToggleAction::toggled, this, [this, t, board] {
if (t->isChecked())
{
changeGameboard(board);
}
});
playgroundsGroup->addAction(t);
QList<QAction*> actionList = playgroundsGroup->actions();
std::sort(actionList.begin(), actionList.end(), actionSorterByName);
......@@ -108,9 +112,10 @@ void TopLevel::registerLanguage(const QString &code, const QString &soundFile, b
KToggleAction *t = new KToggleAction(KLanguageName::nameForCode(code), this);
t->setEnabled(enabled);
actionCollection()->addAction(soundFile, t);
t->setData(soundFile);
sounds.insert(code, soundFile);
connect(t, SIGNAL(toggled(bool)), SLOT(changeLanguage()));
connect(t, &KToggleAction::toggled, this, [this, soundFile] {
changeLanguage(soundFile);
});
languagesGroup->addAction(t);
QList<QAction*> actionList = languagesGroup->actions();
actionList.removeAll(actionCollection()->action(QStringLiteral( "speech_no_sound" )));
......@@ -126,17 +131,6 @@ void TopLevel::changeGameboardFromCombo(int index)
changeGameboard(newBoard);
}
void TopLevel::changeGameboard()
{
QAction *action = qobject_cast<QAction*>(sender());
// ignore toggling of "nonchecked" actions
if (action->isChecked())
{
QString newGameBoard = action->data().toString();
changeGameboard(newGameBoard);
}
}
void TopLevel::changeGameboard(const QString &newGameBoard)
{
if (newGameBoard == playGround->currentGameboard()) return;
......@@ -176,13 +170,6 @@ void TopLevel::changeGameboard(const QString &newGameBoard)
}
}
void TopLevel::changeLanguage()
{
QAction *action = qobject_cast<QAction*>(sender());
QString soundFile = action->data().toString();
changeLanguage(soundFile);
}
// Switch to another language
void TopLevel::changeLanguage(const QString &soundFile)
{
......@@ -289,7 +276,7 @@ void TopLevel::setupKAction()
connect(action, &QAction::triggered, this, &TopLevel::filePicture);
//Edit
action = KStandardAction::copy(this, SLOT(editCopy()), actionCollection());
action = KStandardAction::copy(this, &TopLevel::editCopy, actionCollection());
actionCollection()->addAction(action->objectName(), action);
action = KStandardAction::undo(0, 0, actionCollection());
......@@ -303,7 +290,7 @@ void TopLevel::setupKAction()
connect(t, &QAction::triggered, this, &TopLevel::soundOff);
languagesGroup->addAction(t);
KStandardAction::fullScreen(this, SLOT(toggleFullScreen()), this, actionCollection());
KStandardAction::fullScreen(this, &TopLevel::toggleFullScreen, this, actionCollection());
t = new KToggleAction(i18n("&Lock Aspect Ratio"), this);
actionCollection()->addAction( QStringLiteral( "lock_aspect_ratio" ), t);
......@@ -318,7 +305,7 @@ void TopLevel::setupKAction()
PlaygroundDelegate *playgroundDelegate = new PlaygroundDelegate(playgroundCombo->view());
playgroundCombo->setItemDelegate(playgroundDelegate);
connect(playgroundCombo, SIGNAL(currentIndexChanged(int)),this,SLOT(changeGameboardFromCombo(int)));
connect(playgroundCombo, QOverload<int>::of(&KComboBox::currentIndexChanged), this, &TopLevel::changeGameboardFromCombo);
QWidgetAction *widgetAction = new QWidgetAction(this);
widgetAction->setDefaultWidget(playgroundCombo);
......
......@@ -57,8 +57,6 @@ private slots:
void editCopy();
void soundOff();
void changeGameboardFromCombo(int index);
void changeGameboard();
void changeLanguage();
void toggleFullScreen();
void lockAspectRatio(bool lock);
......
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