1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-02-03 12:47:31 +01:00

Actually fix formatting

This commit is contained in:
Luis Caceres 2019-12-07 19:30:10 +00:00
parent 0b6519bad4
commit a3531d749a
3 changed files with 75 additions and 83 deletions

View File

@ -43,7 +43,8 @@ GlobalShortcuts::GlobalShortcuts(QWidget* parent)
gnome_backend_(nullptr), gnome_backend_(nullptr),
system_backend_(nullptr), system_backend_(nullptr),
use_gnome_(false), use_gnome_(false),
have_kglobalaccel_(KGlobalAccelShortcutBackend::isKGlobalAccelAvailable()) { have_kglobalaccel_(
KGlobalAccelShortcutBackend::isKGlobalAccelAvailable()) {
settings_.beginGroup(kSettingsGroup); settings_.beginGroup(kSettingsGroup);
// Create actions // Create actions

View File

@ -1,5 +1,5 @@
#include "kglobalaccelglobalshortcutbackend.h"
#include "core/logging.h" #include "core/logging.h"
#include "kglobalaccelglobalshortcutbackend.h"
#include <QAction> #include <QAction>
#include <QGuiApplication> #include <QGuiApplication>
@ -47,7 +47,9 @@ bool isCorrectMediaKeyShortcut(const GlobalShortcuts::Shortcut &shortcut) {
KGlobalAccelShortcutBackend::KGlobalAccelShortcutBackend( KGlobalAccelShortcutBackend::KGlobalAccelShortcutBackend(
GlobalShortcuts* parent) GlobalShortcuts* parent)
: GlobalShortcutBackend(parent), iface_(nullptr), component_(nullptr), : GlobalShortcutBackend(parent),
iface_(nullptr),
component_(nullptr),
nameToAction_() {} nameToAction_() {}
#else // HAVE_DBUS #else // HAVE_DBUS
@ -69,21 +71,17 @@ bool KGlobalAccelShortcutBackend::DoRegister() {
#ifdef HAVE_DBUS #ifdef HAVE_DBUS
qLog(Debug) << "Registering shortcuts"; qLog(Debug) << "Registering shortcuts";
if (!acquireInterface()) if (!acquireInterface()) return false;
return false;
bool complete = true; bool complete = true;
for (const GlobalShortcuts::Shortcut& shortcut : for (const GlobalShortcuts::Shortcut& shortcut :
manager_->shortcuts().values()) { manager_->shortcuts().values()) {
if (shortcut.action->shortcut().isEmpty()) if (shortcut.action->shortcut().isEmpty()) continue;
continue;
if (!registerShortcut(shortcut)) if (!registerShortcut(shortcut)) complete = false;
complete = false;
} }
if (!acquireComponent()) if (!acquireComponent()) return false;
return false;
QObject::connect(component_, QObject::connect(component_,
&OrgKdeKglobalaccelComponentInterface::globalShortcutPressed, &OrgKdeKglobalaccelComponentInterface::globalShortcutPressed,
@ -98,11 +96,9 @@ bool KGlobalAccelShortcutBackend::DoRegister() {
void KGlobalAccelShortcutBackend::DoUnregister() { void KGlobalAccelShortcutBackend::DoUnregister() {
#ifdef HAVE_DBUS #ifdef HAVE_DBUS
if (!acquireInterface()) if (!acquireInterface()) return;
return;
if (!acquireComponent()) if (!acquireComponent()) return;
return;
for (const GlobalShortcuts::Shortcut& shortcut : manager_->shortcuts()) for (const GlobalShortcuts::Shortcut& shortcut : manager_->shortcuts())
unregisterAction(shortcut.id, shortcut.action); unregisterAction(shortcut.id, shortcut.action);
@ -143,16 +139,14 @@ bool KGlobalAccelShortcutBackend::acquireComponent() {
} }
bool KGlobalAccelShortcutBackend::acquireInterface() { bool KGlobalAccelShortcutBackend::acquireInterface() {
if (iface_ && iface_->isValid()) if (iface_ && iface_->isValid()) return true;
return true;
if (isKGlobalAccelAvailable()) { if (isKGlobalAccelAvailable()) {
iface_ = new OrgKdeKGlobalAccelInterface( iface_ = new OrgKdeKGlobalAccelInterface(
Service, Path, QDBusConnection::sessionBus(), this); Service, Path, QDBusConnection::sessionBus(), this);
} }
if (iface_ && iface_->isValid()) if (iface_ && iface_->isValid()) return true;
return true;
if (!iface_) if (!iface_)
qLog(Warning) << "KGlobalAccel daemon not registered"; qLog(Warning) << "KGlobalAccel daemon not registered";
@ -170,13 +164,12 @@ QStringList KGlobalAccelShortcutBackend::id(const QString &name,
ret << name; ret << name;
ret << compDisplayName(); ret << compDisplayName();
ret << action->text().replace(QLatin1Char('&'), QStringLiteral("")); ret << action->text().replace(QLatin1Char('&'), QStringLiteral(""));
if (ret.back().isEmpty()) if (ret.back().isEmpty()) ret.back() = name;
ret.back() = name;
return ret; return ret;
} }
QList<int> QList<int> KGlobalAccelShortcutBackend::intList(
KGlobalAccelShortcutBackend::intList(const QList<QKeySequence> &seq) { const QList<QKeySequence>& seq) {
QList<int> ret; QList<int> ret;
for (const QKeySequence& sequence : seq) { for (const QKeySequence& sequence : seq) {
ret.append(sequence[0]); ret.append(sequence[0]);
@ -209,8 +202,7 @@ bool KGlobalAccelShortcutBackend::registerAction(const QString &name,
bool KGlobalAccelShortcutBackend::registerShortcut( bool KGlobalAccelShortcutBackend::registerShortcut(
const GlobalShortcuts::Shortcut& shortcut) { const GlobalShortcuts::Shortcut& shortcut) {
QStringList actionId; QStringList actionId;
if (!registerAction(shortcut.id, shortcut.action, actionId)) if (!registerAction(shortcut.id, shortcut.action, actionId)) return false;
return false;
QList<QKeySequence> activeShortcut; QList<QKeySequence> activeShortcut;
activeShortcut << shortcut.action->shortcut(); activeShortcut << shortcut.action->shortcut();
@ -239,8 +231,8 @@ bool KGlobalAccelShortcutBackend::registerShortcut(
return true; return true;
} }
QList<QKeySequence> QList<QKeySequence> KGlobalAccelShortcutBackend::shortcutList(
KGlobalAccelShortcutBackend::shortcutList(const QList<int> &seq) { const QList<int>& seq) {
QList<QKeySequence> ret; QList<QKeySequence> ret;
for (int i : seq) { for (int i : seq) {
ret.append(i); ret.append(i);
@ -268,8 +260,7 @@ void KGlobalAccelShortcutBackend::onShortcutPressed(
} }
} }
if (action && action->isEnabled()) if (action && action->isEnabled()) action->trigger();
action->trigger();
} }
#endif // HAVE_DBUS #endif // HAVE_DBUS