Commit c751d247 authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

Use more modern signal/slot connects

parent 20e7aa32
......@@ -70,7 +70,8 @@ KGameRenderer::KGameRenderer(KgThemeProvider* provider, unsigned cacheSize)
{
provider->setParent(this);
}
connect(provider, SIGNAL(currentThemeChanged(const KgTheme*)), SLOT(_k_setTheme(const KgTheme*)));
connect(provider, &KgThemeProvider::currentThemeChanged,
this, [this](const KgTheme *theme) { d->_k_setTheme(theme); });
}
static KgThemeProvider* providerForSingleTheme(KgTheme* theme, QObject* parent)
......
......@@ -223,7 +223,6 @@ class KDEGAMES_EXPORT KGameRenderer : public QObject
friend class KGameRendererClient;
friend class KGameRendererClientPrivate;
KGameRendererPrivate* const d;
Q_PRIVATE_SLOT(d, void _k_setTheme(const KgTheme*));
};
Q_DECLARE_OPERATORS_FOR_FLAGS(KGameRenderer::Strategies)
......
......@@ -380,7 +380,7 @@ void KgDifficultyGUI::init(KXmlGuiWindow* window, KgDifficulty* difficulty)
//create selector (resides in status bar)
KgDifficultyGUI::Selector* selector = new KgDifficultyGUI::Selector(difficulty, window);
selector->setToolTip(i18nc("Game difficulty level", "Difficulty"));
QObject::connect(selector, SIGNAL(activated(int)), selector, SLOT(slotActivated(int)));
QObject::connect(selector, QOverload<int>::of(&QComboBox::activated), selector, &Selector::slotActivated);
QObject::connect(difficulty, &KgDifficulty::editableChanged, selector, &QWidget::setEnabled);
QObject::connect(difficulty, &KgDifficulty::selectedLevelChanged,
selector, &Selector::slotSelected);
......@@ -391,7 +391,7 @@ void KgDifficultyGUI::init(KXmlGuiWindow* window, KgDifficulty* difficulty)
KSelectAction* menu = new KgDifficultyGUI::Menu(icon, i18nc("Game difficulty level", "Difficulty"), window);
menu->setToolTip(i18n("Set the difficulty level"));
menu->setWhatsThis(i18n("Set the difficulty level of the game."));
QObject::connect(menu, SIGNAL(triggered(int)), selector, SLOT(slotActivated(int)));
QObject::connect(menu, QOverload<int>::of(&KSelectAction::triggered), selector, &Selector::slotActivated);
QObject::connect(difficulty, &KgDifficulty::editableChanged, menu, &QAction::setEnabled);
QObject::connect(selector, &Selector::signalSelected, menu, &KSelectAction::setCurrentItem);
......
......@@ -60,7 +60,7 @@ KgThemeProvider::KgThemeProvider(const QByteArray& configKey, QObject* parent)
{
qRegisterMetaType<const KgTheme*>();
qRegisterMetaType<KgThemeProvider*>();
connect(this, SIGNAL(currentThemeChanged(const KgTheme*)), this, SLOT(updateThemeName()));
connect(this, &KgThemeProvider::currentThemeChanged, this, [this]() { d->updateThemeName(); });
}
KgThemeProvider::~KgThemeProvider()
......
......@@ -143,7 +143,6 @@ class KDEGAMES_EXPORT KgThemeProvider : public QObject
private:
class Private;
Private* const d;
Q_PRIVATE_SLOT(d, void updateThemeName());
};
Q_DECLARE_METATYPE(KgThemeProvider*)
......
......@@ -77,10 +77,10 @@ KgThemeSelector::KgThemeSelector(KgThemeProvider* provider, Options options, QWi
const QSize scrollBarSizeHint = d->m_list->verticalScrollBar()->sizeHint();
d->m_list->setMinimumSize(itemSizeHint.width() + 2 * scrollBarSizeHint.width(), 4.1 * itemSizeHint.height());
//monitor change selection in both directions
connect(d->m_provider, SIGNAL(currentThemeChanged(const KgTheme*)),
SLOT(_k_updateListSelection(const KgTheme*)));
connect(d->m_list, SIGNAL(itemSelectionChanged()),
SLOT(_k_updateProviderSelection()));
connect(d->m_provider, &KgThemeProvider::currentThemeChanged,
this, [this](const KgTheme* theme) { d->_k_updateListSelection(theme); });
connect(d->m_list, &QListWidget::itemSelectionChanged,
this, [this]() { d->_k_updateProviderSelection(); });
//setup main layout
QVBoxLayout* layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
......@@ -91,7 +91,8 @@ KgThemeSelector::KgThemeSelector(KgThemeProvider* provider, Options options, QWi
d->m_knsButton = new QPushButton(QIcon::fromTheme(QStringLiteral("get-hot-new-stuff")),
i18n("Get New Themes..."), this);
layout->addWidget(d->m_knsButton);
connect(d->m_knsButton, SIGNAL(clicked()), SLOT(_k_showNewStuffDialog()));
connect(d->m_knsButton, &QAbstractButton::clicked,
this, [this]() { d->_k_showNewStuffDialog(); });
}
}
......
......@@ -66,10 +66,6 @@ class KDEGAMES_EXPORT KgThemeSelector : public QWidget
class Dialog;
class Private;
Private* const d;
Q_PRIVATE_SLOT(d, void _k_updateListSelection(const KgTheme*));
Q_PRIVATE_SLOT(d, void _k_updateProviderSelection());
Q_PRIVATE_SLOT(d, void _k_showNewStuffDialog());
};
Q_DECLARE_OPERATORS_FOR_FLAGS(KgThemeSelector::Options)
......
......@@ -115,7 +115,8 @@ void KGameDifficultyPrivate::init(KXmlGuiWindow* window, const QObject* recvr, c
m_menu = new KSelectAction(QIcon::fromTheme( QStringLiteral( "games-difficult") ), i18nc("Game difficulty level", "Difficulty" ), window);
m_menu->setToolTip(i18n("Set the difficulty level"));
m_menu->setWhatsThis(i18n("Set the difficulty level of the game."));
QObject::connect(m_menu, SIGNAL(triggered(int)), this, SLOT(changeSelection(int)));
connect(m_menu, QOverload<int>::of(&KSelectAction::triggered),
this, &KGameDifficultyPrivate::changeSelection);
m_menu->setObjectName( QStringLiteral("options_game_difficulty" ));
window->actionCollection()->addAction(m_menu->objectName(), m_menu);
......@@ -123,7 +124,8 @@ void KGameDifficultyPrivate::init(KXmlGuiWindow* window, const QObject* recvr, c
m_comboBox = new KComboBox(window);
m_comboBox->setToolTip(i18n("Difficulty"));
QObject::connect(m_comboBox, SIGNAL(activated(int)), this, SLOT(changeSelection(int)));
connect(m_comboBox, QOverload<int>::of(&QComboBox::activated),
this, &KGameDifficultyPrivate::changeSelection);
window->statusBar()->addPermanentWidget(m_comboBox);
KGameDifficulty::setRestartOnChange(KGameDifficulty::RestartOnChange);
......
......@@ -76,7 +76,7 @@ void KGameThemeSelector::KGameThemeSelectorPrivate::setupData(KConfigSkeleton *
//The lineEdit widget holds our theme path for automatic connection via KConfigXT.
//But the user should not manipulate it directly, so we hide it.
ui.kcfg_Theme->hide();
connect(ui.kcfg_Theme, SIGNAL(textChanged(QString)), q, SLOT(_k_updateThemeList(QString)));
connect(ui.kcfg_Theme, &QLineEdit::textChanged, q, [this](const QString &text) { _k_updateThemeList(text); });
//Disable KNS button?
if (knsflags==KGameThemeSelector::NewStuffDisableDownload) {
......@@ -91,7 +91,7 @@ void KGameThemeSelector::KGameThemeSelectorPrivate::setupData(KConfigSkeleton *
findThemes(lastUsedTheme);
connect(ui.getNewButton, SIGNAL(clicked()), q, SLOT(_k_openKNewStuffDialog()));
connect(ui.getNewButton, &QAbstractButton::clicked, q, [this]() { _k_openKNewStuffDialog(); });
}
void KGameThemeSelector::KGameThemeSelectorPrivate::findThemes(const QString &initialSelection)
......@@ -160,7 +160,7 @@ void KGameThemeSelector::KGameThemeSelectorPrivate::findThemes(const QString &in
}
//Reconnect the themeList
connect(ui.themeList, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), q, SLOT(_k_updatePreview()));
connect(ui.themeList, &QListWidget::currentItemChanged, q, [this]() { _k_updatePreview(); });
}
void KGameThemeSelector::KGameThemeSelectorPrivate::_k_updatePreview()
......
......@@ -74,10 +74,6 @@ class KDEGAMESPRIVATE_EXPORT KGameThemeSelector : public QWidget
KGameThemeSelectorPrivate* const d;
Q_DISABLE_COPY(KGameThemeSelector)
Q_PRIVATE_SLOT(d, void _k_updatePreview())
Q_PRIVATE_SLOT(d, void _k_updateThemeList(const QString&))
Q_PRIVATE_SLOT(d, void _k_openKNewStuffDialog())
};
#endif
......
......@@ -38,7 +38,7 @@ KGpiMainWindow::KGpiMainWindow()
connect(m_popupItem, &KGamePopupItem::linkActivated, this, &KGpiMainWindow::onLinkClicked);
m_textItem = new QGraphicsSimpleTextItem;
actionCollection()->addAction( KStandardAction::Quit, this, SLOT(close()) );
KStandardAction::quit(this, &KGpiMainWindow::close, actionCollection());
m_scene = new QGraphicsScene;
m_scene->setSceneRect( -1000, -1000, 2000, 2000 );
......@@ -128,7 +128,7 @@ void KGpiMainWindow::onLinkClicked(const QString& link)
m_textItem->setPos( visibleRect.left()+visibleRect.width()/2-m_textItem->boundingRect().width()/2,
visibleRect.top()+visibleRect.height()/2 );
m_textItem->show();
QTimer::singleShot(2000, this, SLOT(hideTextItem()));
QTimer::singleShot(2000, this, &KGpiMainWindow::hideTextItem);
}
void KGpiMainWindow::hideTextItem()
......
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