mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-06-11 08:57:21 +00:00
Show a trash icon to the left of the Overview button in convergence
mode. The icon toggles between user-trash and user-trash-full by
watching ~/.local/share/Trash/files via FolderListModel.
Left-click opens the trash in the default file manager via
Qt.openUrlExternally("trash:/"), making the feature file-manager-
agnostic. Right-click offers "Open Trash" and "Empty Trash"; the
latter shows a confirmation dialog before invoking KIO.Trash via
D-Bus.
The right wing of the virtual-desktop pager shifts left to make
room for the trash button.
120 lines
3.4 KiB
C++
120 lines
3.4 KiB
C++
// SPDX-FileCopyrightText: 2015 Marco Martin <mart@kde.org>
|
|
// SPDX-FileCopyrightText: 2022-2023 Devin Lin <devin@kde.org>
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#include "homescreen.h"
|
|
|
|
#include <virtualdesktopinfo.h>
|
|
|
|
#include <KWindowSystem>
|
|
|
|
#include <QDBusConnection>
|
|
#include <QDBusMessage>
|
|
#include <QDebug>
|
|
#include <QQmlEngine>
|
|
#include <QQmlExtensionPlugin>
|
|
#include <QQuickItem>
|
|
|
|
K_PLUGIN_CLASS_WITH_JSON(HomeScreen, "metadata.json")
|
|
|
|
HomeScreen::HomeScreen(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
|
|
: Plasma::Containment{parent, data, args}
|
|
, m_folioSettings{new FolioSettings{this}}
|
|
, m_homeScreenState{new HomeScreenState{this}}
|
|
, m_widgetsManager{new WidgetsManager{this}}
|
|
, m_applicationListModel{new ApplicationListModel{this}}
|
|
, m_applicationListSearchModel{new ApplicationListSearchModel{this, m_applicationListModel}}
|
|
, m_favouritesModel{new FavouritesModel{this}}
|
|
, m_pageListModel{new PageListModel{this}}
|
|
{
|
|
// HomeScreenState init() has dependencies on other objects
|
|
m_homeScreenState->init();
|
|
|
|
setHasConfigurationInterface(true);
|
|
|
|
connect(KWindowSystem::self(), &KWindowSystem::showingDesktopChanged, this, &HomeScreen::showingDesktopChanged);
|
|
|
|
connect(this, &Plasma::Containment::appletAdded, this, &HomeScreen::onAppletAdded);
|
|
connect(this, &Plasma::Containment::appletAboutToBeRemoved, this, &HomeScreen::onAppletAboutToBeRemoved);
|
|
}
|
|
|
|
HomeScreen::~HomeScreen() = default;
|
|
|
|
void HomeScreen::configChanged()
|
|
{
|
|
Plasma::Containment::configChanged();
|
|
}
|
|
|
|
void HomeScreen::onAppletAdded(Plasma::Applet *applet, const QRectF &geometryHint)
|
|
{
|
|
Q_UNUSED(geometryHint)
|
|
widgetsManager()->addWidget(applet);
|
|
}
|
|
|
|
void HomeScreen::onAppletAboutToBeRemoved(Plasma::Applet *applet)
|
|
{
|
|
widgetsManager()->removeWidget(applet);
|
|
}
|
|
|
|
FolioSettings *HomeScreen::folioSettings()
|
|
{
|
|
return m_folioSettings;
|
|
}
|
|
|
|
HomeScreenState *HomeScreen::homeScreenState()
|
|
{
|
|
return m_homeScreenState;
|
|
}
|
|
|
|
WidgetsManager *HomeScreen::widgetsManager()
|
|
{
|
|
return m_widgetsManager;
|
|
}
|
|
|
|
ApplicationListModel *HomeScreen::applicationListModel()
|
|
{
|
|
return m_applicationListModel;
|
|
}
|
|
|
|
ApplicationListSearchModel *HomeScreen::applicationListSearchModel()
|
|
{
|
|
return m_applicationListSearchModel;
|
|
}
|
|
|
|
FavouritesModel *HomeScreen::favouritesModel()
|
|
{
|
|
return m_favouritesModel;
|
|
}
|
|
|
|
PageListModel *HomeScreen::pageListModel()
|
|
{
|
|
return m_pageListModel;
|
|
}
|
|
|
|
void HomeScreen::triggerOverview() const
|
|
{
|
|
QDBusMessage message = QDBusMessage::createMethodCall("org.kde.kglobalaccel", "/component/kwin", "org.kde.kglobalaccel.Component", "invokeShortcut");
|
|
message.setArguments({QStringLiteral("Overview")});
|
|
QDBusConnection::sessionBus().send(message);
|
|
}
|
|
|
|
void HomeScreen::activateVirtualDesktop(const QVariant &desktop) const
|
|
{
|
|
if (!desktop.isValid() || desktop.toString().isEmpty()) {
|
|
return;
|
|
}
|
|
|
|
TaskManager::VirtualDesktopInfo virtualDesktopInfo;
|
|
virtualDesktopInfo.requestActivate(desktop);
|
|
}
|
|
|
|
void HomeScreen::emptyTrash() const
|
|
{
|
|
QDBusMessage message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kio.trash"),
|
|
QStringLiteral("/trash"),
|
|
QStringLiteral("org.kde.KIO.Trash"),
|
|
QStringLiteral("emptyTrash"));
|
|
QDBusConnection::sessionBus().send(message);
|
|
}
|
|
|
|
#include "homescreen.moc"
|