mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
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:
parent
88ef5ea9b7
commit
854742efcc
10 changed files with 159 additions and 177 deletions
|
|
@ -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();
|
||||
|
|
@ -65,7 +64,7 @@ void ApplicationListModel::loadSettings()
|
|||
++i;
|
||||
}
|
||||
|
||||
//loadApplications();
|
||||
// loadApplications();
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> ApplicationListModel::roleNames() const
|
||||
|
|
@ -112,39 +111,36 @@ void ApplicationListModel::initWayland()
|
|||
}
|
||||
auto *registry = new Registry(this);
|
||||
registry->create(connection);
|
||||
connect(registry, &Registry::plasmaWindowManagementAnnounced, this,
|
||||
[this, registry] (quint32 name, quint32 version) {
|
||||
m_windowManagement = registry->createPlasmaWindowManagement(name, version, this);
|
||||
qRegisterMetaType<QVector<int> >("QVector<int>");
|
||||
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) {
|
||||
if (window->appId() == QStringLiteral("org.kde.plasmashell")) {
|
||||
return;
|
||||
}
|
||||
int idx = 0;
|
||||
for (auto i = m_applicationList.begin(); i != m_applicationList.end(); i++) {
|
||||
if ((*i).storageId == window->appId() + QStringLiteral(".desktop")) {
|
||||
(*i).window = window;
|
||||
emit dataChanged(index(idx, 0), index(idx, 0));
|
||||
connect(window, &KWayland::Client::PlasmaWindow::unmapped, this, [this, window] () {
|
||||
int idx = 0;
|
||||
for (auto i = m_applicationList.begin(); i != m_applicationList.end(); i++) {
|
||||
if ((*i).storageId == window->appId() + QStringLiteral(".desktop")) {
|
||||
(*i).window = nullptr;
|
||||
emit dataChanged(index(idx, 0), index(idx, 0));
|
||||
break;
|
||||
}
|
||||
idx++;
|
||||
connect(m_windowManagement, &KWayland::Client::PlasmaWindowManagement::windowCreated, this, [this](KWayland::Client::PlasmaWindow *window) {
|
||||
if (window->appId() == QStringLiteral("org.kde.plasmashell")) {
|
||||
return;
|
||||
}
|
||||
int idx = 0;
|
||||
for (auto i = m_applicationList.begin(); i != m_applicationList.end(); i++) {
|
||||
if ((*i).storageId == window->appId() + QStringLiteral(".desktop")) {
|
||||
(*i).window = window;
|
||||
emit dataChanged(index(idx, 0), index(idx, 0));
|
||||
connect(window, &KWayland::Client::PlasmaWindow::unmapped, this, [this, window]() {
|
||||
int idx = 0;
|
||||
for (auto i = m_applicationList.begin(); i != m_applicationList.end(); i++) {
|
||||
if ((*i).storageId == window->appId() + QStringLiteral(".desktop")) {
|
||||
(*i).window = nullptr;
|
||||
emit dataChanged(index(idx, 0), index(idx, 0));
|
||||
break;
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
idx++;
|
||||
idx++;
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
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;
|
||||
|
|
@ -180,7 +177,7 @@ void ApplicationListModel::loadApplications()
|
|||
if (!serviceGroup->noDisplay()) {
|
||||
KServiceGroup::List entryGroupList = serviceGroup->entries(true);
|
||||
|
||||
for(KServiceGroup::List::ConstIterator it = entryGroupList.constBegin(); it != entryGroupList.constEnd(); it++) {
|
||||
for (KServiceGroup::List::ConstIterator it = entryGroupList.constBegin(); it != entryGroupList.constEnd(); it++) {
|
||||
KSycocaEntry::Ptr entry = (*it);
|
||||
|
||||
if (entry->isType(KST_KServiceGroup)) {
|
||||
|
|
@ -283,7 +280,7 @@ Qt::ItemFlags ApplicationListModel::flags(const QModelIndex &index) const
|
|||
{
|
||||
if (!index.isValid())
|
||||
return {};
|
||||
return Qt::ItemIsDragEnabled|QAbstractListModel::flags(index);
|
||||
return Qt::ItemIsDragEnabled | QAbstractListModel::flags(index);
|
||||
}
|
||||
|
||||
int ApplicationListModel::rowCount(const QModelIndex &parent) const
|
||||
|
|
@ -295,7 +292,7 @@ int ApplicationListModel::rowCount(const QModelIndex &parent) const
|
|||
return m_applicationList.count();
|
||||
}
|
||||
|
||||
void ApplicationListModel::moveRow(const QModelIndex& /* sourceParent */, int sourceRow, const QModelIndex& /* destinationParent */, int destinationChild)
|
||||
void ApplicationListModel::moveRow(const QModelIndex & /* sourceParent */, int sourceRow, const QModelIndex & /* destinationParent */, int destinationChild)
|
||||
{
|
||||
moveItem(sourceRow, destinationChild);
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
@ -326,8 +322,8 @@ void ApplicationListModel::setLocation(int row, LauncherLocation location)
|
|||
}
|
||||
emit favoriteCountChanged();
|
||||
|
||||
// Out of favorites
|
||||
} else if (data.location == Favorites) {
|
||||
// Out of favorites
|
||||
} else if (data.location == Favorites) {
|
||||
m_favorites.removeAll(data.uniqueId);
|
||||
if (m_applet) {
|
||||
m_applet->config().writeEntry("Favorites", m_favorites);
|
||||
|
|
@ -342,8 +338,8 @@ void ApplicationListModel::setLocation(int row, LauncherLocation location)
|
|||
m_applet->config().writeEntry("DesktopItems", m_desktopItems.values());
|
||||
}
|
||||
|
||||
// Out of Desktop
|
||||
} else if (data.location == Desktop) {
|
||||
// Out of Desktop
|
||||
} else if (data.location == Desktop) {
|
||||
m_desktopItems.remove(data.uniqueId);
|
||||
if (m_applet) {
|
||||
m_applet->config().writeEntry(QStringLiteral("DesktopItems"), m_desktopItems.values());
|
||||
|
|
@ -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;
|
||||
|
|
@ -483,7 +477,7 @@ void ApplicationListModel::setMinimizedDelegate(int row, QQuickItem *delegate)
|
|||
return;
|
||||
}
|
||||
|
||||
QRect rect = delegate->mapRectToScene(QRectF(0,0, delegate->width(), delegate->height())).toRect();
|
||||
QRect rect = delegate->mapRectToScene(QRectF(0, 0, delegate->width(), delegate->height())).toRect();
|
||||
|
||||
window->setMinimizedGeometry(surface, rect);
|
||||
}
|
||||
|
|
@ -516,4 +510,3 @@ void ApplicationListModel::unsetMinimizedDelegate(int row, QQuickItem *delegate)
|
|||
}
|
||||
|
||||
#include "moc_applicationlistmodel.cpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
@ -102,7 +109,7 @@ public:
|
|||
Q_INVOKABLE void unsetMinimizedDelegate(int row, QQuickItem *delegate);
|
||||
|
||||
public Q_SLOTS:
|
||||
void sycocaDbChanged(const QStringList &change);
|
||||
void sycocaDbChanged(const QStringList &change);
|
||||
|
||||
Q_SIGNALS:
|
||||
void countChanged();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
@ -95,7 +91,7 @@ void FavoritesModel::loadApplications()
|
|||
}
|
||||
m_desktopItems.remove(uniqueId);
|
||||
}
|
||||
|
||||
|
||||
endResetModel();
|
||||
emit countChanged();
|
||||
|
||||
|
|
@ -183,4 +179,3 @@ void FavoritesModel::removeFavorite(int row)
|
|||
}
|
||||
|
||||
#include "moc_favoritesmodel.cpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
#ifndef HOMESCREEN_H
|
||||
#define HOMESCREEN_H
|
||||
|
||||
|
||||
#include <Plasma/Containment>
|
||||
|
||||
class QQuickItem;
|
||||
|
|
@ -20,7 +19,7 @@ class HomeScreen : public Plasma::Containment
|
|||
Q_PROPERTY(ApplicationListModel *applicationListModel READ applicationListModel CONSTANT)
|
||||
|
||||
public:
|
||||
HomeScreen( QObject *parent, const QVariantList &args );
|
||||
HomeScreen(QObject *parent, const QVariantList &args);
|
||||
~HomeScreen() override;
|
||||
|
||||
void configChanged() override;
|
||||
|
|
@ -31,7 +30,7 @@ public:
|
|||
Q_INVOKABLE void stackAfter(QQuickItem *item1, QQuickItem *item2);
|
||||
|
||||
protected:
|
||||
// void configChanged() override;
|
||||
// void configChanged() override;
|
||||
|
||||
private:
|
||||
ApplicationListModel *m_applicationListModel = nullptr;
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
||||
|
|
@ -33,8 +33,8 @@ constexpr int SCREENSHOT_DELAY = 200;
|
|||
static int readData(int theFile, QByteArray &theDataOut)
|
||||
{
|
||||
// implementation based on QtWayland file qwaylanddataoffer.cpp
|
||||
char lBuffer[4096];
|
||||
int lRetryCount = 0;
|
||||
char lBuffer[4096];
|
||||
int lRetryCount = 0;
|
||||
ssize_t lBytesRead = 0;
|
||||
|
||||
do {
|
||||
|
|
@ -73,22 +73,21 @@ static QImage readImage(int thePipeFd)
|
|||
PhonePanel::PhonePanel(QObject *parent, const QVariantList &args)
|
||||
: Plasma::Containment(parent, args)
|
||||
{
|
||||
//setHasConfigurationInterface(true);
|
||||
// setHasConfigurationInterface(true);
|
||||
m_kscreenInterface = new org::kde::KScreen(QStringLiteral("org.kde.kded5"), QStringLiteral("/modules/kscreen"), QDBusConnection::sessionBus(), this);
|
||||
m_screenshotInterface = new org::kde::kwin::Screenshot(QStringLiteral("org.kde.KWin"), QStringLiteral("/Screenshot"), QDBusConnection::sessionBus(), this);
|
||||
|
||||
|
||||
m_localeConfig = KSharedConfig::openConfig(QStringLiteral("kdeglobals"), KConfig::SimpleConfig);
|
||||
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 {
|
||||
if (group.name() == "Locale") {
|
||||
// we have to reparse for new changes (from system settings)
|
||||
m_localeConfig->reparseConfiguration();
|
||||
Q_EMIT isSystem24HourFormatChanged();
|
||||
}
|
||||
});
|
||||
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();
|
||||
Q_EMIT isSystem24HourFormatChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
PhonePanel::~PhonePanel() = default;
|
||||
|
|
@ -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")));
|
||||
|
|
@ -162,14 +159,14 @@ void PhonePanel::takeScreenshot()
|
|||
// wait ~200 ms to wait for rest of animations
|
||||
QTimer::singleShot(SCREENSHOT_DELAY, [=]() {
|
||||
int lPipeFds[2];
|
||||
if (pipe2(lPipeFds, O_CLOEXEC|O_NONBLOCK) != 0) {
|
||||
if (pipe2(lPipeFds, O_CLOEXEC | O_NONBLOCK) != 0) {
|
||||
qWarning() << "Could not take screenshot";
|
||||
return;
|
||||
}
|
||||
// Take fullscreen screenshot, and no pointer
|
||||
QDBusPendingCall pcall = m_screenshotInterface->screenshotFullscreen(QDBusUnixFileDescriptor(lPipeFds[1]), false, true);
|
||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall, this);
|
||||
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [](QDBusPendingCallWatcher* watcher) {
|
||||
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [](QDBusPendingCallWatcher *watcher) {
|
||||
if (watcher->isError()) {
|
||||
const auto error = watcher->error();
|
||||
qWarning() << "Error calling KWin DBus interface:" << error.name() << error.message();
|
||||
|
|
@ -177,23 +174,21 @@ void PhonePanel::takeScreenshot()
|
|||
watcher->deleteLater();
|
||||
});
|
||||
const auto lWatcher = new QFutureWatcher<QImage>(this);
|
||||
QObject::connect(lWatcher, &QFutureWatcher<QImage>::finished, this,
|
||||
[lWatcher, filePath] () {
|
||||
lWatcher->deleteLater();
|
||||
const QImage lImage = lWatcher->result();
|
||||
qDebug() << lImage;
|
||||
if(!lImage.save(filePath, "PNG")) {
|
||||
qWarning() << "Failed to save screenshot to" << filePath;
|
||||
} else {
|
||||
KNotification *notif = new KNotification("captured");
|
||||
notif->setComponentName(QStringLiteral("plasma_phone_components"));
|
||||
notif->setTitle(i18n("New Screenshot"));
|
||||
notif->setUrls({filePath});
|
||||
notif->setText(i18n("New screenshot saved to %1", filePath));
|
||||
notif->sendEvent();
|
||||
}
|
||||
QObject::connect(lWatcher, &QFutureWatcher<QImage>::finished, this, [lWatcher, filePath]() {
|
||||
lWatcher->deleteLater();
|
||||
const QImage lImage = lWatcher->result();
|
||||
qDebug() << lImage;
|
||||
if (!lImage.save(filePath, "PNG")) {
|
||||
qWarning() << "Failed to save screenshot to" << filePath;
|
||||
} else {
|
||||
KNotification *notif = new KNotification("captured");
|
||||
notif->setComponentName(QStringLiteral("plasma_phone_components"));
|
||||
notif->setTitle(i18n("New Screenshot"));
|
||||
notif->setUrls({filePath});
|
||||
notif->setText(i18n("New screenshot saved to %1", filePath));
|
||||
notif->sendEvent();
|
||||
}
|
||||
);
|
||||
});
|
||||
lWatcher->setFuture(QtConcurrent::run(readImage, lPipeFds[0]));
|
||||
close(lPipeFds[1]);
|
||||
});
|
||||
|
|
@ -202,7 +197,7 @@ void PhonePanel::takeScreenshot()
|
|||
bool PhonePanel::isSystem24HourFormat()
|
||||
{
|
||||
KConfigGroup localeSettings = KConfigGroup(m_localeConfig, "Locale");
|
||||
|
||||
|
||||
QString timeFormat = localeSettings.readEntry("TimeFormat", QStringLiteral(FORMAT24H));
|
||||
return timeFormat == QStringLiteral(FORMAT24H);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,8 +21,9 @@ 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(QObject *parent, const QVariantList &args);
|
||||
~PhonePanel() override;
|
||||
|
||||
public Q_SLOTS:
|
||||
|
|
@ -33,9 +33,9 @@ public Q_SLOTS:
|
|||
|
||||
bool autoRotate();
|
||||
void setAutoRotate(bool value);
|
||||
|
||||
|
||||
bool torchEnabled() const;
|
||||
|
||||
|
||||
bool isSystem24HourFormat();
|
||||
|
||||
signals:
|
||||
|
|
@ -45,7 +45,7 @@ signals:
|
|||
|
||||
private:
|
||||
bool m_running = false;
|
||||
|
||||
|
||||
KConfigWatcher::Ptr m_localeConfigWatcher;
|
||||
KSharedConfig::Ptr m_localeConfig;
|
||||
|
||||
|
|
|
|||
|
|
@ -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,9 +49,13 @@ 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 * {
|
||||
return new KwinVirtualKeyboardInterface;
|
||||
});
|
||||
qmlRegisterSingletonType<OrgKdeKwinVirtualKeyboardInterface>("org.kde.plasma.phone.taskpanel",
|
||||
1,
|
||||
0,
|
||||
"KWinVirtualKeyboard",
|
||||
[](QQmlEngine *, QJSEngine *) -> QObject * {
|
||||
return new KwinVirtualKeyboardInterface;
|
||||
});
|
||||
}
|
||||
|
||||
TaskPanel::~TaskPanel() = default;
|
||||
|
|
@ -76,44 +81,36 @@ void TaskPanel::initWayland()
|
|||
}
|
||||
auto *registry = new Registry(this);
|
||||
registry->create(connection);
|
||||
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) {
|
||||
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));
|
||||
|
||||
m_activeTimer->start();
|
||||
}
|
||||
);
|
||||
connect(registry, &Registry::plasmaShellAnnounced, this,
|
||||
[this, registry] (quint32 name, quint32 version) {
|
||||
|
||||
m_shellInterface = registry->createPlasmaShell(name, version, this);
|
||||
|
||||
if (!m_panel) {
|
||||
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) {
|
||||
if (showing == m_showingDesktop) {
|
||||
return;
|
||||
}
|
||||
Surface *s = Surface::fromWindow(m_panel);
|
||||
if (!s) {
|
||||
return;
|
||||
}
|
||||
m_shellSurface = m_shellInterface->createSurface(s, this);
|
||||
m_shellSurface->setSkipTaskbar(true);
|
||||
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));
|
||||
|
||||
m_activeTimer->start();
|
||||
});
|
||||
connect(registry, &Registry::plasmaShellAnnounced, this, [this, registry](quint32 name, quint32 version) {
|
||||
m_shellInterface = registry->createPlasmaShell(name, version, this);
|
||||
|
||||
if (!m_panel) {
|
||||
return;
|
||||
}
|
||||
);
|
||||
Surface *s = Surface::fromWindow(m_panel);
|
||||
if (!s) {
|
||||
return;
|
||||
}
|
||||
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,18 +194,17 @@ 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();
|
||||
emit hasCloseableActiveWindowChanged();
|
||||
}
|
||||
|
||||
void TaskPanel::closeActiveWindow()
|
||||
{
|
||||
if (m_activeWindow) {
|
||||
m_activeWindow->requestClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
K_EXPORT_PLASMA_APPLET_WITH_JSON(taskpanel, TaskPanel, "metadata.json")
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class TaskPanel : public Plasma::Containment
|
|||
Q_PROPERTY(QWindow *panel READ panel WRITE setPanel NOTIFY panelChanged)
|
||||
|
||||
public:
|
||||
TaskPanel( QObject *parent, const QVariantList &args );
|
||||
TaskPanel(QObject *parent, const QVariantList &args);
|
||||
~TaskPanel() override;
|
||||
|
||||
QWindow *panel();
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue