Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 0d5433ed authored by Kurt Hindenburg's avatar Kurt Hindenburg

Split method to add/remove shortcut actions into separate methods

parent 7889cbb3
......@@ -128,38 +128,51 @@ void ProfileList::syncWidgetActions(QWidget* widget, bool sync)
widget->addActions(_group->actions());
}
void ProfileList::favoriteChanged(Profile::Ptr profile, bool isFavorite)
void ProfileList::addShortcutAction(Profile::Ptr profile)
{
ProfileManager* manager = ProfileManager::instance();
if (isFavorite) {
auto action = new QAction(_group);
action->setData(QVariant::fromValue(profile));
auto action = new QAction(_group);
action->setData(QVariant::fromValue(profile));
if (_addShortcuts) {
action->setShortcut(manager->shortcut(profile));
}
if (_addShortcuts) {
action->setShortcut(manager->shortcut(profile));
}
updateAction(action, profile);
updateAction(action, profile);
foreach(QWidget * widget, _registeredWidgets) {
widget->addAction(action);
}
emit actionsChanged(_group->actions());
updateEmptyAction();
}
void ProfileList::removeShortcutAction(Profile::Ptr profile)
{
QAction* action = actionForProfile(profile);
if (action != nullptr) {
_group->removeAction(action);
foreach(QWidget * widget, _registeredWidgets) {
widget->addAction(action);
widget->removeAction(action);
}
emit actionsChanged(_group->actions());
} else {
QAction* action = actionForProfile(profile);
if (action != nullptr) {
_group->removeAction(action);
foreach(QWidget * widget, _registeredWidgets) {
widget->removeAction(action);
}
emit actionsChanged(_group->actions());
}
}
updateEmptyAction();
}
void ProfileList::favoriteChanged(Profile::Ptr profile, bool isFavorite)
{
if (isFavorite) {
addShortcutAction(profile);
} else {
removeShortcutAction(profile);
}
}
void ProfileList::triggered(QAction* action)
{
emit profileSelected(action->data().value<Profile::Ptr>());
......
......@@ -86,6 +86,8 @@ private Q_SLOTS:
void favoriteChanged(Profile::Ptr profile, bool isFavorite);
void profileChanged(Profile::Ptr profile);
void shortcutChanged(Profile::Ptr profile, const QKeySequence &sequence);
void addShortcutAction(Profile::Ptr profile);
void removeShortcutAction(Profile::Ptr profile);
private:
Q_DISABLE_COPY(ProfileList)
......
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