Run clang-format

If you want git blame to ignore formatting revisions run:
git config blame.ignoreRevsFile .git-blame-ignore-revs
This commit is contained in:
Alexander Lohnau 2021-03-19 08:52:22 +01:00
parent 88ef5ea9b7
commit 854742efcc
No known key found for this signature in database
GPG key ID: 6C45BA731AA2ED36
10 changed files with 159 additions and 177 deletions

View file

@ -9,9 +9,9 @@
// Qt
#include <QByteArray>
#include <QDebug>
#include <QModelIndex>
#include <QProcess>
#include <QDebug>
#include <QQuickItem>
#include <QQuickWindow>
@ -32,11 +32,10 @@
constexpr int MAX_FAVOURITES = 5;
ApplicationListModel::ApplicationListModel(HomeScreen *parent)
: QAbstractListModel(parent),
m_applet(parent)
: QAbstractListModel(parent)
, m_applet(parent)
{
connect(KSycoca::self(), qOverload<const QStringList &>(&KSycoca::databaseChanged),
this, &ApplicationListModel::sycocaDbChanged);
connect(KSycoca::self(), qOverload<const QStringList &>(&KSycoca::databaseChanged), this, &ApplicationListModel::sycocaDbChanged);
loadSettings();
initWayland();
@ -112,13 +111,11 @@ void ApplicationListModel::initWayland()
}
auto *registry = new Registry(this);
registry->create(connection);
connect(registry, &Registry::plasmaWindowManagementAnnounced, this,
[this, registry] (quint32 name, quint32 version) {
connect(registry, &Registry::plasmaWindowManagementAnnounced, this, [this, registry](quint32 name, quint32 version) {
m_windowManagement = registry->createPlasmaWindowManagement(name, version, this);
qRegisterMetaType<QVector<int>>("QVector<int>");
connect(m_windowManagement, &KWayland::Client::PlasmaWindowManagement::windowCreated,
this, [this] (KWayland::Client::PlasmaWindow *window) {
connect(m_windowManagement, &KWayland::Client::PlasmaWindowManagement::windowCreated, this, [this](KWayland::Client::PlasmaWindow *window) {
if (window->appId() == QStringLiteral("org.kde.plasmashell")) {
return;
}
@ -143,8 +140,7 @@ void ApplicationListModel::initWayland()
idx++;
}
});
}
);
});
registry->setup();
connection->roundtrip();
@ -162,7 +158,8 @@ void ApplicationListModel::loadApplications()
m_applicationList.clear();
KServiceGroup::Ptr group = KServiceGroup::root();
if (!group || !group->isValid()) return;
if (!group || !group->isValid())
return;
KServiceGroup::List subGroupList = group->entries(true);
QMap<int, ApplicationData> orderedList;
@ -314,8 +311,7 @@ void ApplicationListModel::setLocation(int row, LauncherLocation location)
if (location == Favorites) {
qWarning() << "favoriting" << row << data.name;
// Deny favorites when full
if (row >= m_maxFavoriteCount || m_favorites.count() >= m_maxFavoriteCount ||
m_favorites.contains(data.uniqueId)) {
if (row >= m_maxFavoriteCount || m_favorites.count() >= m_maxFavoriteCount || m_favorites.contains(data.uniqueId)) {
return;
}
@ -359,8 +355,7 @@ void ApplicationListModel::setLocation(int row, LauncherLocation location)
void ApplicationListModel::moveItem(int row, int destination)
{
if (row < 0 || destination < 0 || row >= m_applicationList.length() ||
destination >= m_applicationList.length() || row == destination) {
if (row < 0 || destination < 0 || row >= m_applicationList.length() || destination >= m_applicationList.length() || row == destination) {
return;
}
if (destination > row) {
@ -378,7 +373,6 @@ void ApplicationListModel::moveItem(int row, int destination)
m_applicationList.insert(destination, data);
}
m_appOrder.clear();
m_appPositions.clear();
int i = 0;
@ -516,4 +510,3 @@ void ApplicationListModel::unsetMinimizedDelegate(int row, QQuickItem *delegate)
}
#include "moc_applicationlistmodel.cpp"

View file

@ -8,9 +8,9 @@
#define APPLICATIONLISTMODEL_H
// Qt
#include <QObject>
#include <QAbstractListModel>
#include <QList>
#include <QObject>
#include <QSet>
#include "homescreen.h"
@ -28,7 +28,8 @@ class PlasmaWindow;
class ApplicationListModel;
class ApplicationListModel : public QAbstractListModel {
class ApplicationListModel : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(int count READ count NOTIFY countChanged)
@ -75,8 +76,14 @@ public:
void moveRow(const QModelIndex &sourceParent, int sourceRow, const QModelIndex &destinationParent, int destinationChild);
int count() const { return m_applicationList.count(); }
int favoriteCount() const { return m_favorites.count();}
int count() const
{
return m_applicationList.count();
}
int favoriteCount() const
{
return m_favorites.count();
}
int maxFavoriteCount() const;
void setMaxFavoriteCount(int count);

View file

@ -9,14 +9,13 @@
// Qt
#include <QByteArray>
#include <QModelIndex>
#include <QDebug>
#include <QModelIndex>
// KDE
#include <KService>
#include <KSharedConfig>
constexpr int MAX_FAVOURITES = 5;
FavoritesModel::FavoritesModel(HomeScreen *parent)
@ -26,7 +25,6 @@ FavoritesModel::FavoritesModel(HomeScreen *parent)
FavoritesModel::~FavoritesModel() = default;
QString FavoritesModel::storageToUniqueId(const QString &storageId) const
{
if (storageId.isEmpty()) {
@ -52,10 +50,8 @@ QString FavoritesModel::uniqueToStorageId(const QString &uniqueId) const
return uniqueId.split(QLatin1Char('-')).first();
}
void FavoritesModel::loadApplications()
{
beginResetModel();
m_applicationList.clear();
@ -183,4 +179,3 @@ void FavoritesModel::removeFavorite(int row)
}
#include "moc_favoritesmodel.cpp"

View file

@ -7,13 +7,13 @@
#pragma once
// Qt
#include <QObject>
#include <QAbstractListModel>
#include <QList>
#include <QObject>
#include <QSet>
#include "homescreen.h"
#include "applicationlistmodel.h"
#include "homescreen.h"
class QString;
@ -28,14 +28,14 @@ class PlasmaWindow;
class FavoritesModel;
class FavoritesModel : public ApplicationListModel {
class FavoritesModel : public ApplicationListModel
{
Q_OBJECT
public:
FavoritesModel(HomeScreen *parent = nullptr);
~FavoritesModel() override;
QString storageToUniqueId(const QString &storageId) const;
QString uniqueToStorageId(const QString &uniqueId) const;
@ -43,7 +43,4 @@ public:
Q_INVOKABLE void removeFavorite(int row);
Q_INVOKABLE void loadApplications() override;
};

View file

@ -7,9 +7,9 @@
#include "applicationlistmodel.h"
#include "favoritesmodel.h"
#include <QtQml>
#include <QDebug>
#include <QQuickItem>
#include <QtQml>
HomeScreen::HomeScreen(QObject *parent, const QVariantList &args)
: Plasma::Containment(parent, args)

View file

@ -7,7 +7,6 @@
#ifndef HOMESCREEN_H
#define HOMESCREEN_H
#include <Plasma/Containment>
class QQuickItem;

View file

@ -7,22 +7,22 @@
#include "phonepanel.h"
#include <qplatformdefs.h>
#include <fcntl.h>
#include <qplatformdefs.h>
#include <unistd.h>
#include <KNotification>
#include <KLocalizedString>
#include <KConfigGroup>
#include <KLocalizedString>
#include <KNotification>
#include <QDateTime>
#include <QDBusPendingReply>
#include <QFile>
#include <QDateTime>
#include <QDebug>
#include <QStandardPaths>
#include <QFile>
#include <QProcess>
#include <QtConcurrent/QtConcurrent>
#include <QScreen>
#include <QStandardPaths>
#include <QtConcurrent/QtConcurrent>
#define FORMAT24H "HH:mm:ss"
@ -81,8 +81,7 @@ PhonePanel::PhonePanel(QObject *parent, const QVariantList &args)
m_localeConfigWatcher = KConfigWatcher::create(m_localeConfig);
// watch for changes to locale config, to update 12/24 hour time
connect(m_localeConfigWatcher.data(), &KConfigWatcher::configChanged,
this, [this](const KConfigGroup &group, const QByteArrayList &names) -> void {
connect(m_localeConfigWatcher.data(), &KConfigWatcher::configChanged, this, [this](const KConfigGroup &group, const QByteArrayList &names) -> void {
if (group.name() == "Locale") {
// we have to reparse for new changes (from system settings)
m_localeConfig->reparseConfiguration();
@ -152,9 +151,7 @@ void PhonePanel::takeScreenshot()
}
QDir picturesDir(filePath);
if (!picturesDir.mkpath(QStringLiteral("Screenshots"))) {
qWarning() << "Couldn't create folder at"
<< picturesDir.path() + QStringLiteral("/Screenshots")
<< "to take screenshot.";
qWarning() << "Couldn't create folder at" << picturesDir.path() + QStringLiteral("/Screenshots") << "to take screenshot.";
return;
}
filePath += QStringLiteral("/Screenshots/Screenshot_%1.png").arg(QDateTime::currentDateTime().toString(QStringLiteral("yyyyMMdd_hhmmss")));
@ -177,8 +174,7 @@ void PhonePanel::takeScreenshot()
watcher->deleteLater();
});
const auto lWatcher = new QFutureWatcher<QImage>(this);
QObject::connect(lWatcher, &QFutureWatcher<QImage>::finished, this,
[lWatcher, filePath] () {
QObject::connect(lWatcher, &QFutureWatcher<QImage>::finished, this, [lWatcher, filePath]() {
lWatcher->deleteLater();
const QImage lImage = lWatcher->result();
qDebug() << lImage;
@ -192,8 +188,7 @@ void PhonePanel::takeScreenshot()
notif->setText(i18n("New screenshot saved to %1", filePath));
notif->sendEvent();
}
}
);
});
lWatcher->setFuture(QtConcurrent::run(readImage, lPipeFds[0]));
close(lPipeFds[1]);
});

View file

@ -7,11 +7,10 @@
#ifndef PHONEPANEL_H
#define PHONEPANEL_H
#include <Plasma/Containment>
#include <KSharedConfig>
#include <KConfigWatcher>
#include <KSharedConfig>
#include "kscreeninterface.h"
#include "screenshotinterface.h"
@ -22,6 +21,7 @@ class PhonePanel : public Plasma::Containment
Q_PROPERTY(bool autoRotateEnabled READ autoRotate WRITE setAutoRotate NOTIFY autoRotateChanged);
Q_PROPERTY(bool torchEnabled READ torchEnabled NOTIFY torchChanged);
Q_PROPERTY(bool isSystem24HourFormat READ isSystem24HourFormat NOTIFY isSystem24HourFormatChanged);
public:
PhonePanel(QObject *parent, const QVariantList &args);
~PhonePanel() override;

View file

@ -6,18 +6,18 @@
#include "taskpanel.h"
#include <QtQml>
#include <QDebug>
#include <QQuickItem>
#include <QQuickWindow>
#include <QtQml>
#include <Plasma/Package>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/plasmashell.h>
#include <KWayland/Client/plasmawindowmanagement.h>
#include <KWayland/Client/plasmawindowmodel.h>
#include <KWayland/Client/plasmashell.h>
#include <KWayland/Client/registry.h>
#include <KWayland/Client/surface.h>
#include <Plasma/Package>
#include <virtualkeyboardinterface.h>
@ -31,9 +31,10 @@ class KwinVirtualKeyboardInterface : public OrgKdeKwinVirtualKeyboardInterface
Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
public:
KwinVirtualKeyboardInterface() :
OrgKdeKwinVirtualKeyboardInterface(QStringLiteral("org.kde.KWin"), QStringLiteral("/VirtualKeyboard"), QDBusConnection::sessionBus())
{}
KwinVirtualKeyboardInterface()
: OrgKdeKwinVirtualKeyboardInterface(QStringLiteral("org.kde.KWin"), QStringLiteral("/VirtualKeyboard"), QDBusConnection::sessionBus())
{
}
};
TaskPanel::TaskPanel(QObject *parent, const QVariantList &args)
@ -48,7 +49,11 @@ TaskPanel::TaskPanel(QObject *parent, const QVariantList &args)
connect(m_activeTimer, &QTimer::timeout, this, &TaskPanel::updateActiveWindow);
initWayland();
qmlRegisterSingletonType<OrgKdeKwinVirtualKeyboardInterface>("org.kde.plasma.phone.taskpanel", 1, 0, "KWinVirtualKeyboard", [](QQmlEngine *, QJSEngine *) -> QObject * {
qmlRegisterSingletonType<OrgKdeKwinVirtualKeyboardInterface>("org.kde.plasma.phone.taskpanel",
1,
0,
"KWinVirtualKeyboard",
[](QQmlEngine *, QJSEngine *) -> QObject * {
return new KwinVirtualKeyboardInterface;
});
}
@ -76,31 +81,24 @@ void TaskPanel::initWayland()
}
auto *registry = new Registry(this);
registry->create(connection);
connect(registry, &Registry::plasmaWindowManagementAnnounced, this,
[this, registry] (quint32 name, quint32 version) {
connect(registry, &Registry::plasmaWindowManagementAnnounced, this, [this, registry](quint32 name, quint32 version) {
m_windowManagement = registry->createPlasmaWindowManagement(name, version, this);
qRegisterMetaType<QVector<int>>("QVector<int>");
connect(m_windowManagement, &PlasmaWindowManagement::showingDesktopChanged, this,
[this] (bool showing) {
connect(m_windowManagement, &PlasmaWindowManagement::showingDesktopChanged, this, [this](bool showing) {
if (showing == m_showingDesktop) {
return;
}
m_showingDesktop = showing;
emit showingDesktopChanged(m_showingDesktop);
}
);
});
// FIXME
// connect(m_windowManagement, &PlasmaWindowManagement::activeWindowChanged, this, &TaskPanel::updateActiveWindow, Qt::QueuedConnection);
connect(m_windowManagement, &KWayland::Client::PlasmaWindowManagement::activeWindowChanged,
m_activeTimer, qOverload<>(&QTimer::start));
connect(m_windowManagement, &KWayland::Client::PlasmaWindowManagement::activeWindowChanged, m_activeTimer, qOverload<>(&QTimer::start));
m_activeTimer->start();
}
);
connect(registry, &Registry::plasmaShellAnnounced, this,
[this, registry] (quint32 name, quint32 version) {
});
connect(registry, &Registry::plasmaShellAnnounced, this, [this, registry](quint32 name, quint32 version) {
m_shellInterface = registry->createPlasmaShell(name, version, this);
if (!m_panel) {
@ -112,8 +110,7 @@ void TaskPanel::initWayland()
}
m_shellSurface = m_shellInterface->createSurface(s, this);
m_shellSurface->setSkipTaskbar(true);
}
);
});
registry->setup();
connection->roundtrip();
}
@ -164,15 +161,13 @@ void TaskPanel::updateActiveWindow()
}
if (m_activeWindow) {
disconnect(m_activeWindow.data(), &KWayland::Client::PlasmaWindow::closeableChanged, this, &TaskPanel::hasCloseableActiveWindowChanged);
disconnect(m_activeWindow.data(), &KWayland::Client::PlasmaWindow::unmapped,
this, &TaskPanel::forgetActiveWindow);
disconnect(m_activeWindow.data(), &KWayland::Client::PlasmaWindow::unmapped, this, &TaskPanel::forgetActiveWindow);
}
m_activeWindow = m_windowManagement->activeWindow();
if (m_activeWindow) {
connect(m_activeWindow.data(), &KWayland::Client::PlasmaWindow::closeableChanged, this, &TaskPanel::hasCloseableActiveWindowChanged);
connect(m_activeWindow.data(), &KWayland::Client::PlasmaWindow::unmapped,
this, &TaskPanel::forgetActiveWindow);
connect(m_activeWindow.data(), &KWayland::Client::PlasmaWindow::unmapped, this, &TaskPanel::forgetActiveWindow);
}
bool newAllMinimized = true;
@ -199,8 +194,7 @@ void TaskPanel::forgetActiveWindow()
{
if (m_activeWindow) {
disconnect(m_activeWindow.data(), &KWayland::Client::PlasmaWindow::closeableChanged, this, &TaskPanel::hasCloseableActiveWindowChanged);
disconnect(m_activeWindow.data(), &KWayland::Client::PlasmaWindow::unmapped,
this, &TaskPanel::forgetActiveWindow);
disconnect(m_activeWindow.data(), &KWayland::Client::PlasmaWindow::unmapped, this, &TaskPanel::forgetActiveWindow);
}
m_activeWindow.clear();
emit hasCloseableActiveWindowChanged();

View file

@ -41,12 +41,14 @@ public:
Q_INVOKABLE void closeActiveWindow();
bool isShowingDesktop() const {
bool isShowingDesktop() const
{
return m_showingDesktop;
}
void requestShowingDesktop(bool showingDesktop);
bool allMinimized() const {
bool allMinimized() const
{
return m_allMinimized;
}
bool hasCloseableActiveWindow() const;