Summary: it was the only remaining user of that dialog helper. the connection between the two was fairly meh. the engine would invoke the kded module over dbus, the module would then process the request, find that only one desktop entry is specified, resulting in one action being found and then running that action on behalf of the engine. this is overly complicated for no additional gain. the engine is the sole user of this functionality AND it already had knowledge of the service system, so soliduiserver in this case doesn't actually add anything. it's just a more involved call chain. the useful code of soliduiserver is now in the hotplug dataengine directly and the soliduiserver no longer supports the actions dialog. hotplug is now the sole authority for hotplugging. soliduiserver: - include cleanup - all classes no longer in use have been removed - kdelibs4support is no longer a link target - new link targets i18n + widgetsaddons (previously pulled in by kdelibs4support) hotplug: - hotplugjob now directly executes service actions using classes imported from soliduiserver - no longer links qtdbus - new translation domain plasma_engine_hotplug (for i18n call in imported service classes) - new link against ki18n for that reason Test Plan: running an action works same as before, internally it no longer relies on dbus/kded Reviewers: broulik Reviewed By: broulik Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D21761wilder-5.17
parent
8c3838eda4
commit
f67d61b391
15 changed files with 61 additions and 468 deletions
@ -0,0 +1,2 @@ |
||||
#! /usr/bin/env bash |
||||
$XGETTEXT *.cpp -o $podir/plasma_engine_hotplug.pot |
||||
@ -1,125 +0,0 @@ |
||||
/* This file is part of the KDE Project
|
||||
Copyright (c) 2005 Jean-Remy Falleri <jr.falleri@laposte.net> |
||||
Copyright (c) 2005-2007 Kevin Ottens <ervin@kde.org> |
||||
|
||||
This library is free software; you can redistribute it and/or |
||||
modify it under the terms of the GNU Library General Public |
||||
License version 2 as published by the Free Software Foundation. |
||||
|
||||
This library is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||
Library General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU Library General Public License |
||||
along with this library; see the file COPYING.LIB. If not, write to |
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
||||
Boston, MA 02110-1301, USA. |
||||
*/ |
||||
|
||||
#include "deviceactionsdialog.h" |
||||
|
||||
#include <QIcon> |
||||
#include <QCheckBox> |
||||
#include <QDebug> |
||||
|
||||
#include "deviceaction.h" |
||||
#include "ui_deviceactionsdialogview.h" |
||||
|
||||
DeviceActionsDialog::DeviceActionsDialog(QWidget *parent) |
||||
: KDialog(parent) |
||||
{ |
||||
qDebug() << Q_FUNC_INFO; |
||||
|
||||
setModal(false); |
||||
setButtons(Ok|Cancel); |
||||
setDefaultButton(Ok); |
||||
|
||||
QWidget *page = new QWidget(this); |
||||
m_view.setupUi(page); |
||||
setMainWidget(page); |
||||
updateActionsListBox(); |
||||
|
||||
resize(QSize(400,400).expandedTo(minimumSizeHint())); |
||||
|
||||
connect(this, &DeviceActionsDialog::okClicked, this, &DeviceActionsDialog::slotOk); |
||||
connect(m_view.actionsList, &QListWidget::doubleClicked, this, &DeviceActionsDialog::slotOk); |
||||
|
||||
connect(this, &DeviceActionsDialog::finished, this, &DeviceActionsDialog::delayedDestruct); |
||||
} |
||||
|
||||
DeviceActionsDialog::~DeviceActionsDialog() |
||||
{ |
||||
} |
||||
|
||||
void DeviceActionsDialog::setDevice(const Solid::Device &device) |
||||
{ |
||||
m_device = device; |
||||
|
||||
QString label = device.vendor(); |
||||
if (!label.isEmpty()) label+=' '; |
||||
label+= device.product(); |
||||
|
||||
setWindowTitle(label);
|
||||
|
||||
m_view.iconLabel->setPixmap(QIcon::fromTheme(device.icon()).pixmap(64)); |
||||
m_view.descriptionLabel->setText(device.vendor()+' '+device.product()); |
||||
setWindowIcon(QIcon::fromTheme(device.icon())); |
||||
} |
||||
|
||||
Solid::Device DeviceActionsDialog::device() const |
||||
{ |
||||
return m_device; |
||||
} |
||||
|
||||
void DeviceActionsDialog::setActions(const QList<DeviceAction*> &actions) |
||||
{ |
||||
qDeleteAll(m_actions); |
||||
m_actions.clear(); |
||||
|
||||
m_actions = actions; |
||||
|
||||
updateActionsListBox(); |
||||
} |
||||
|
||||
QList<DeviceAction*> DeviceActionsDialog::actions() const |
||||
{ |
||||
return m_actions; |
||||
} |
||||
|
||||
void DeviceActionsDialog::updateActionsListBox() |
||||
{ |
||||
m_view.actionsList->clear(); |
||||
|
||||
foreach (DeviceAction *action, m_actions) { |
||||
QListWidgetItem *item = new QListWidgetItem(QIcon::fromTheme(action->iconName()), |
||||
action->label()); |
||||
item->setData(Qt::UserRole, action->id()); |
||||
m_view.actionsList->addItem(item); |
||||
} |
||||
|
||||
if (m_view.actionsList->count()>0) |
||||
m_view.actionsList->item(0)->setSelected(true); |
||||
} |
||||
|
||||
void DeviceActionsDialog::slotOk() |
||||
{ |
||||
QListWidgetItem *item = m_view.actionsList->selectedItems().value(0); |
||||
|
||||
if (item) { |
||||
const QString id = item->data(Qt::UserRole).toString(); |
||||
|
||||
foreach (DeviceAction *action, m_actions) { |
||||
if (action->id()==id) { |
||||
launchAction(action); |
||||
return; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
void DeviceActionsDialog::launchAction(DeviceAction *action) |
||||
{ |
||||
action->execute(m_device); |
||||
accept(); |
||||
} |
||||
@ -1,57 +0,0 @@ |
||||
/* This file is part of the KDE Project
|
||||
Copyright (c) 2005 Jean-Remy Falleri <jr.falleri@laposte.net> |
||||
Copyright (c) 2005-2007 Kevin Ottens <ervin@kde.org> |
||||
|
||||
This library is free software; you can redistribute it and/or |
||||
modify it under the terms of the GNU Library General Public |
||||
License version 2 as published by the Free Software Foundation. |
||||
|
||||
This library is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||
Library General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU Library General Public License |
||||
along with this library; see the file COPYING.LIB. If not, write to |
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
||||
Boston, MA 02110-1301, USA. |
||||
*/ |
||||
|
||||
#ifndef DEVICEACTIONSDIALOG_H |
||||
#define DEVICEACTIONSDIALOG_H |
||||
|
||||
#include <kdialog.h> |
||||
#include <solid/device.h> |
||||
|
||||
#include "ui_deviceactionsdialogview.h" |
||||
|
||||
class DeviceAction; |
||||
|
||||
class DeviceActionsDialog : public KDialog |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit DeviceActionsDialog(QWidget *parent=nullptr); |
||||
~DeviceActionsDialog() override; |
||||
|
||||
void setDevice(const Solid::Device &device); |
||||
Solid::Device device() const; |
||||
|
||||
void setActions(const QList<DeviceAction*> &actions); |
||||
QList<DeviceAction*> actions() const; |
||||
|
||||
private Q_SLOTS: |
||||
void slotOk(); |
||||
|
||||
private: |
||||
void launchAction(DeviceAction *action); |
||||
void updateActionsListBox(); |
||||
|
||||
Ui::DeviceActionsDialogView m_view; |
||||
|
||||
Solid::Device m_device; |
||||
QList<DeviceAction*> m_actions; |
||||
}; |
||||
|
||||
#endif |
||||
@ -1,94 +0,0 @@ |
||||
<ui version="4.0" > |
||||
<class>DeviceActionsDialogView</class> |
||||
<widget class="QWidget" name="DeviceActionsDialogView" > |
||||
<property name="geometry" > |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>508</width> |
||||
<height>480</height> |
||||
</rect> |
||||
</property> |
||||
<layout class="QVBoxLayout" > |
||||
<property name="spacing" > |
||||
<number>15</number> |
||||
</property> |
||||
<item> |
||||
<layout class="QHBoxLayout" > |
||||
<property name="spacing" > |
||||
<number>20</number> |
||||
</property> |
||||
<item> |
||||
<widget class="QLabel" name="iconLabel" > |
||||
<property name="sizePolicy" > |
||||
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" > |
||||
<horstretch>0</horstretch> |
||||
<verstretch>0</verstretch> |
||||
</sizepolicy> |
||||
</property> |
||||
<property name="minimumSize" > |
||||
<size> |
||||
<width>64</width> |
||||
<height>64</height> |
||||
</size> |
||||
</property> |
||||
<property name="maximumSize" > |
||||
<size> |
||||
<width>64</width> |
||||
<height>64</height> |
||||
</size> |
||||
</property> |
||||
<property name="scaledContents" > |
||||
<bool>true</bool> |
||||
</property> |
||||
<property name="wordWrap" > |
||||
<bool>false</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QLabel" name="textLabel1" > |
||||
<property name="text" > |
||||
<string>A new device has been detected.<br><b>What do you want to do?</b></string> |
||||
</property> |
||||
<property name="textFormat" > |
||||
<enum>Qt::RichText</enum> |
||||
</property> |
||||
<property name="wordWrap" > |
||||
<bool>false</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
<item> |
||||
<widget class="QLabel" name="descriptionLabel" > |
||||
<property name="sizePolicy" > |
||||
<sizepolicy vsizetype="Minimum" hsizetype="Preferred" > |
||||
<horstretch>0</horstretch> |
||||
<verstretch>0</verstretch> |
||||
</sizepolicy> |
||||
</property> |
||||
<property name="text" > |
||||
<string>...</string> |
||||
</property> |
||||
<property name="wordWrap" > |
||||
<bool>false</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QListWidget" name="actionsList" > |
||||
<property name="iconSize" > |
||||
<size> |
||||
<width>48</width> |
||||
<height>48</height> |
||||
</size> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
<resources/> |
||||
<connections/> |
||||
</ui> |
||||
@ -1,38 +0,0 @@ |
||||
/* This file is part of the KDE Project
|
||||
Copyright (c) 2005 Jean-Remy Falleri <jr.falleri@laposte.net> |
||||
Copyright (c) 2005-2007 Kevin Ottens <ervin@kde.org> |
||||
|
||||
This library is free software; you can redistribute it and/or |
||||
modify it under the terms of the GNU Library General Public |
||||
License version 2 as published by the Free Software Foundation. |
||||
|
||||
This library is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||
Library General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU Library General Public License |
||||
along with this library; see the file COPYING.LIB. If not, write to |
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
||||
Boston, MA 02110-1301, USA. |
||||
*/ |
||||
|
||||
#include "devicenothingaction.h" |
||||
|
||||
#include <KLocalizedString> |
||||
|
||||
DeviceNothingAction::DeviceNothingAction() |
||||
: DeviceAction() |
||||
{ |
||||
setIconName(QStringLiteral("dialog-cancel")); |
||||
setLabel(i18n("Do nothing")); |
||||
} |
||||
|
||||
QString DeviceNothingAction::id() const |
||||
{ |
||||
return QStringLiteral("#NothingAction"); |
||||
} |
||||
|
||||
void DeviceNothingAction::execute(Solid::Device &/*device*/) |
||||
{ |
||||
} |
||||
@ -1,34 +0,0 @@ |
||||
/* This file is part of the KDE Project
|
||||
Copyright (c) 2005 Jean-Remy Falleri <jr.falleri@laposte.net> |
||||
Copyright (c) 2005-2007 Kevin Ottens <ervin@kde.org> |
||||
|
||||
This library is free software; you can redistribute it and/or |
||||
modify it under the terms of the GNU Library General Public |
||||
License version 2 as published by the Free Software Foundation. |
||||
|
||||
This library is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||
Library General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU Library General Public License |
||||
along with this library; see the file COPYING.LIB. If not, write to |
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
||||
Boston, MA 02110-1301, USA. |
||||
*/ |
||||
|
||||
#ifndef DEVICENOTHINGACTION_H |
||||
#define DEVICENOTHINGACTION_H |
||||
|
||||
#include "deviceaction.h" |
||||
|
||||
class DeviceNothingAction : public DeviceAction |
||||
{ |
||||
public: |
||||
DeviceNothingAction(); |
||||
QString id() const override; |
||||
void execute(Solid::Device &device) override; |
||||
}; |
||||
|
||||
#endif |
||||
|
||||
Loading…
Reference in new issue