mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 10:22:48 +00:00
kded: drop unused window registration feature
no point in passing around windows to kded4 or its modules, job UI delegate windows are different thing tho Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
fc408ce6b3
commit
302a470d3b
9 changed files with 47 additions and 276 deletions
|
@ -19,19 +19,18 @@
|
|||
Boston, MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
#ifndef __KDEDMODULE_H__
|
||||
#define __KDEDMODULE_H__
|
||||
#ifndef KDEDMODULE_H
|
||||
#define KDEDMODULE_H
|
||||
|
||||
#include <kdecore_export.h>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QDBusObjectPath>
|
||||
|
||||
class KDEDModulePrivate;
|
||||
class Kded;
|
||||
|
||||
#include <QDBusObjectPath>
|
||||
|
||||
/**
|
||||
* \class KDEDModule kdedmodule.h <KDEDModule>
|
||||
*
|
||||
|
@ -51,12 +50,7 @@ class KDECORE_EXPORT KDEDModule: public QObject
|
|||
|
||||
friend class Kded;
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
explicit KDEDModule(QObject* parent = 0);
|
||||
|
||||
explicit KDEDModule(QObject *parent = nullptr);
|
||||
virtual ~KDEDModule();
|
||||
|
||||
/**
|
||||
|
@ -74,16 +68,6 @@ Q_SIGNALS:
|
|||
*/
|
||||
void moduleDeleted(KDEDModule *);
|
||||
|
||||
/**
|
||||
* Emitted when a mainwindow registers itself.
|
||||
*/
|
||||
void windowRegistered(qlonglong windowId);
|
||||
|
||||
/**
|
||||
* Emitted when a mainwindow unregisters itself.
|
||||
*/
|
||||
void windowUnregistered(qlonglong windowId);
|
||||
|
||||
/**
|
||||
* Emitted after the module is registered successfully with D-Bus
|
||||
*
|
||||
|
@ -95,4 +79,4 @@ private:
|
|||
KDEDModulePrivate* const d;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // KDEDMODULE_H
|
||||
|
|
|
@ -88,17 +88,10 @@ Kded::Kded(QObject *parent)
|
|||
: QObject(parent),
|
||||
m_pDirWatch(nullptr),
|
||||
m_pTimer(nullptr),
|
||||
m_hTimer(nullptr),
|
||||
m_serviceWatcher(nullptr)
|
||||
m_hTimer(nullptr)
|
||||
{
|
||||
_self = this;
|
||||
|
||||
m_serviceWatcher = new QDBusServiceWatcher(this);
|
||||
m_serviceWatcher->setConnection(QDBusConnection::sessionBus());
|
||||
m_serviceWatcher->setWatchMode(QDBusServiceWatcher::WatchForUnregistration);
|
||||
connect(m_serviceWatcher, SIGNAL(serviceUnregistered(QString)),
|
||||
this, SLOT(slotApplicationRemoved(QString)));
|
||||
|
||||
new KBuildsycocaAdaptor(this);
|
||||
new KdedAdaptor(this);
|
||||
|
||||
|
@ -442,24 +435,6 @@ void Kded::slotKDEDModuleRemoved(KDEDModule *module)
|
|||
// }
|
||||
}
|
||||
|
||||
void Kded::slotApplicationRemoved(const QString &name)
|
||||
{
|
||||
#if 0 // see kdedmodule.cpp (KDED_OBJECTS)
|
||||
foreach (KDEDModule* module, m_modules) {
|
||||
module->removeAll(appId);
|
||||
}
|
||||
#endif
|
||||
m_serviceWatcher->removeWatchedService(name);
|
||||
const QList<qlonglong> windowIds = m_windowIdList.value(name);
|
||||
foreach(const qlonglong windowId, windowIds) {
|
||||
m_globalWindowIdList.remove(windowId);
|
||||
foreach(KDEDModule* module, m_modules) {
|
||||
emit module->windowUnregistered(windowId);
|
||||
}
|
||||
}
|
||||
m_windowIdList.remove(name);
|
||||
}
|
||||
|
||||
void Kded::updateDirWatch()
|
||||
{
|
||||
if (!bCheckSycoca) {
|
||||
|
@ -524,50 +499,6 @@ void Kded::checkHostname()
|
|||
m_hostname = newHostname;
|
||||
}
|
||||
|
||||
#if 0
|
||||
bool Kded::isWindowRegistered(long windowId) const
|
||||
{
|
||||
return m_globalWindowIdList.contains(windowId);
|
||||
}
|
||||
#endif
|
||||
|
||||
void Kded::registerWindowId(qlonglong windowId, const QString &sender)
|
||||
{
|
||||
if (!m_windowIdList.contains(sender)) {
|
||||
m_serviceWatcher->addWatchedService(sender);
|
||||
}
|
||||
|
||||
m_globalWindowIdList.insert(windowId);
|
||||
QList<qlonglong> windowIds = m_windowIdList.value(sender);
|
||||
windowIds.append(windowId);
|
||||
m_windowIdList.insert(sender, windowIds);
|
||||
|
||||
foreach (KDEDModule* module, m_modules) {
|
||||
// kDebug() << module->moduleName();
|
||||
emit module->windowRegistered(windowId);
|
||||
}
|
||||
}
|
||||
|
||||
void Kded::unregisterWindowId(qlonglong windowId, const QString &sender)
|
||||
{
|
||||
m_globalWindowIdList.remove(windowId);
|
||||
QList<qlonglong> windowIds = m_windowIdList.value(sender);
|
||||
if (!windowIds.isEmpty()) {
|
||||
windowIds.removeAll(windowId);
|
||||
if (windowIds.isEmpty()) {
|
||||
m_serviceWatcher->removeWatchedService(sender);
|
||||
m_windowIdList.remove(sender);
|
||||
} else {
|
||||
m_windowIdList.insert(sender, windowIds);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (KDEDModule* module, m_modules) {
|
||||
// kDebug() << module->moduleName();
|
||||
emit module->windowUnregistered(windowId);
|
||||
}
|
||||
}
|
||||
|
||||
KBuildsycocaAdaptor::KBuildsycocaAdaptor(QObject *parent)
|
||||
: QDBusAbstractAdaptor(parent)
|
||||
{
|
||||
|
|
41
kded/kded.h
41
kded/kded.h
|
@ -20,22 +20,18 @@
|
|||
#ifndef KDED_H
|
||||
#define KDED_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QSet>
|
||||
#include <QtDBus/QDBusMessage>
|
||||
#include <QtDBus/QDBusAbstractAdaptor>
|
||||
#include <QtDBus/QDBusServiceWatcher>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QTimer>
|
||||
#include <QHash>
|
||||
#include <QDBusMessage>
|
||||
#include <QDBusAbstractAdaptor>
|
||||
|
||||
#include <ksycoca.h>
|
||||
#include <ksycocatype.h>
|
||||
#include <kdedmodule.h>
|
||||
#include <kservice.h>
|
||||
|
||||
#include <QDBusServiceWatcher>
|
||||
|
||||
class KDirWatch;
|
||||
|
||||
// Apps get read-only access
|
||||
|
@ -55,20 +51,7 @@ public:
|
|||
KDEDModule *loadModule(const KService::Ptr& service, bool onDemand);
|
||||
QStringList loadedModules();
|
||||
bool unloadModule(const QString &obj);
|
||||
//bool isWindowRegistered(qlonglong windowId) const;
|
||||
/**
|
||||
* Applications can register/unregister their windows with kded modules.
|
||||
*/
|
||||
//@{
|
||||
/**
|
||||
* Register a window with KDED
|
||||
*/
|
||||
void registerWindowId(qlonglong windowId, const QString &sender);
|
||||
/**
|
||||
* Unregister a window previously registered with KDED
|
||||
*/
|
||||
void unregisterWindowId(qlonglong windowId, const QString &sender);
|
||||
//@}
|
||||
|
||||
void loadSecondPhase();
|
||||
|
||||
//@{
|
||||
|
@ -142,11 +125,6 @@ public Q_SLOTS:
|
|||
*/
|
||||
void updateResourceList();
|
||||
|
||||
/**
|
||||
* An application unregistered itself from DBus
|
||||
*/
|
||||
void slotApplicationRemoved(const QString&);
|
||||
|
||||
/**
|
||||
* A KDEDModule is about to get destroyed.
|
||||
*/
|
||||
|
@ -191,11 +169,6 @@ private:
|
|||
//QHash<QString,QLibrary *> m_libs;
|
||||
QHash<QString,QObject *> m_dontLoad;
|
||||
|
||||
//window id tracking, with a QDBusServiceWatcher to remove them as needed
|
||||
QDBusServiceWatcher *m_serviceWatcher;
|
||||
QHash<QString,QList<qlonglong> > m_windowIdList;
|
||||
QSet<long> m_globalWindowIdList;
|
||||
|
||||
QStringList m_allResourceDirs;
|
||||
|
||||
static Kded *_self;
|
||||
|
|
|
@ -49,19 +49,10 @@ bool KdedAdaptor::unloadModule(const QString &module)
|
|||
return Kded::self()->unloadModule(module);
|
||||
}
|
||||
|
||||
void KdedAdaptor::registerWindowId(qlonglong windowId, const QDBusMessage &msg)
|
||||
{
|
||||
Kded::self()->registerWindowId(windowId, msg.service());
|
||||
}
|
||||
|
||||
void KdedAdaptor::setModuleAutoloading(const QString &module, bool autoload)
|
||||
{
|
||||
return Kded::self()->setModuleAutoloading(module, autoload);
|
||||
}
|
||||
void KdedAdaptor::unregisterWindowId(qlonglong windowId, const QDBusMessage &msg)
|
||||
{
|
||||
Kded::self()->unregisterWindowId(windowId, msg.service());
|
||||
}
|
||||
|
||||
QStringList KdedAdaptor::loadedModules()
|
||||
{
|
||||
|
|
|
@ -35,9 +35,6 @@ public Q_SLOTS:
|
|||
bool loadModule(const QString &obj);
|
||||
QStringList loadedModules();
|
||||
bool unloadModule(const QString &obj);
|
||||
//bool isWindowRegistered(qlonglong windowId) const;
|
||||
void registerWindowId(qlonglong windowId, const QDBusMessage&);
|
||||
void unregisterWindowId(qlonglong windowId, const QDBusMessage&);
|
||||
void reconfigure();
|
||||
void loadSecondPhase();
|
||||
void quit();
|
||||
|
@ -58,4 +55,4 @@ public Q_SLOTS:
|
|||
void setModuleAutoloading(const QString &module, bool autoload);
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // KDED_KDEDADAPTOR_H
|
||||
|
|
|
@ -21,25 +21,17 @@
|
|||
*/
|
||||
|
||||
#include "jobuidelegate.h"
|
||||
|
||||
#include <kdebug.h>
|
||||
#include <kjob.h>
|
||||
#include <klocale.h>
|
||||
#include <kmessagebox.h>
|
||||
#include <ksharedconfig.h>
|
||||
#include <kmessage.h>
|
||||
#include "kio/job.h"
|
||||
#include "kjob.h"
|
||||
#include "klocale.h"
|
||||
#include "kmessagebox.h"
|
||||
#include "ksharedconfig.h"
|
||||
#include "kmessage.h"
|
||||
#include "kdebug.h"
|
||||
|
||||
#include <QPointer>
|
||||
#include <QWidget>
|
||||
|
||||
#include "kio/scheduler.h"
|
||||
|
||||
void KIO::JobUiDelegate::setWindow(QWidget *window)
|
||||
{
|
||||
KDialogJobUiDelegate::setWindow(window);
|
||||
KIO::Scheduler::registerWindow(window);
|
||||
}
|
||||
|
||||
KIO::RenameDialog_Result KIO::JobUiDelegate::askFileRename(KJob * job,
|
||||
const QString & caption,
|
||||
const QString& src,
|
||||
|
|
|
@ -41,13 +41,6 @@ class KIO_EXPORT JobUiDelegate : public KDialogJobUiDelegate
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/**
|
||||
* Associate this job with a window given by @p window.
|
||||
* @param window the window to associate to
|
||||
* @see window()
|
||||
*/
|
||||
virtual void setWindow(QWidget *window);
|
||||
|
||||
/**
|
||||
* \relates KIO::RenameDialog
|
||||
* Construct a modal, parent-less "rename" dialog, and return
|
||||
|
|
|
@ -560,13 +560,11 @@ public:
|
|||
bool m_ignoreConfigReparse;
|
||||
|
||||
SessionData sessionData;
|
||||
QMap<QObject *,WId> m_windowList;
|
||||
|
||||
void doJob(SimpleJob *job);
|
||||
void setJobPriority(SimpleJob *job, int priority);
|
||||
void cancelJob(SimpleJob *job);
|
||||
void jobFinished(KIO::SimpleJob *job, KIO::SlaveInterface *slave);
|
||||
void registerWindow(QWidget *wid);
|
||||
|
||||
void setupSlave(KIO::SlaveInterface *slave, const KUrl &url, const QString &protocol, bool newSlave);
|
||||
|
||||
|
@ -574,8 +572,6 @@ public:
|
|||
|
||||
void slotReparseSlaveConfiguration(const QString &, const QDBusMessage&);
|
||||
|
||||
void slotUnregisterWindow(QObject *);
|
||||
|
||||
ProtoQueue *protoQ(const QString& protocol, const QString& host)
|
||||
{
|
||||
ProtoQueue *pq = m_protocols.value(protocol, 0);
|
||||
|
@ -661,16 +657,6 @@ void Scheduler::jobFinished(KIO::SimpleJob *job, KIO::SlaveInterface *slave)
|
|||
schedulerPrivate->jobFinished(job, slave);
|
||||
}
|
||||
|
||||
void Scheduler::registerWindow(QWidget *wid)
|
||||
{
|
||||
schedulerPrivate->registerWindow(wid);
|
||||
}
|
||||
|
||||
void Scheduler::unregisterWindow(QObject *wid)
|
||||
{
|
||||
schedulerPrivate->slotUnregisterWindow(wid);
|
||||
}
|
||||
|
||||
void Scheduler::emitReparseSlaveConfiguration()
|
||||
{
|
||||
// Do it immediately in this process, otherwise we might send a request before reparsing
|
||||
|
@ -816,65 +802,5 @@ void SchedulerPrivate::slotSlaveDied(KIO::SlaveInterface *slave)
|
|||
slave->deref(); // Delete slave
|
||||
}
|
||||
|
||||
/*
|
||||
Returns the top most window associated with widget.
|
||||
|
||||
Unlike QWidget::window(), this function does its best to find and return the
|
||||
main application window associated with the given widget.
|
||||
|
||||
If widget itself is a dialog or its parent is a dialog, and that dialog has a
|
||||
parent widget then this function will iterate through all those widgets to
|
||||
find the top most window, which most of the time is the main window of the
|
||||
application. By contrast, QWidget::window() would simply return the first
|
||||
file dialog it encountered since it is the "next ancestor widget that has (or
|
||||
could have) a window-system frame".
|
||||
*/
|
||||
static QWidget* topLevelWindow(QWidget* widget)
|
||||
{
|
||||
QWidget* w = widget;
|
||||
while (w && w->parentWidget()) {
|
||||
w = w->parentWidget();
|
||||
}
|
||||
return (w ? w->window() : 0);
|
||||
}
|
||||
|
||||
void SchedulerPrivate::registerWindow(QWidget *wid)
|
||||
{
|
||||
if (!wid)
|
||||
return;
|
||||
|
||||
QWidget* window = topLevelWindow(wid);
|
||||
QObject *obj = static_cast<QObject *>(window);
|
||||
|
||||
if (!m_windowList.contains(obj))
|
||||
{
|
||||
// We must store the window Id because by the time
|
||||
// the destroyed signal is emitted we can no longer
|
||||
// access QWidget::winId() (already destructed)
|
||||
WId windowId = window->winId();
|
||||
m_windowList.insert(obj, windowId);
|
||||
q->connect(window, SIGNAL(destroyed(QObject*)),
|
||||
SLOT(slotUnregisterWindow(QObject*)));
|
||||
QDBusInterface("org.kde.kded", "/kded", "org.kde.kded").
|
||||
call(QDBus::NoBlock, "registerWindowId", qlonglong(windowId));
|
||||
}
|
||||
}
|
||||
|
||||
void SchedulerPrivate::slotUnregisterWindow(QObject *obj)
|
||||
{
|
||||
if (!obj)
|
||||
return;
|
||||
|
||||
QMap<QObject *, WId>::Iterator it = m_windowList.find(obj);
|
||||
if (it == m_windowList.end())
|
||||
return;
|
||||
WId windowId = it.value();
|
||||
q->disconnect(it.key(), SIGNAL(destroyed(QObject*)),
|
||||
q, SLOT(slotUnregisterWindow(QObject*)));
|
||||
m_windowList.erase( it );
|
||||
QDBusInterface("org.kde.kded", "/kded", "org.kde.kded").
|
||||
call(QDBus::NoBlock, "unregisterWindowId", qlonglong(windowId));
|
||||
}
|
||||
|
||||
#include "moc_scheduler.cpp"
|
||||
#include "moc_scheduler_p.cpp"
|
||||
|
|
|
@ -120,20 +120,6 @@ namespace KIO {
|
|||
*/
|
||||
static void jobFinished(KIO::SimpleJob *job, KIO::SlaveInterface *slave);
|
||||
|
||||
/**
|
||||
* Register the mainwindow @p wid with the KIO subsystem
|
||||
* Do not call this, it is called automatically from
|
||||
* void KIO::Job::setWindow(QWidget*).
|
||||
* @param wid the window to register
|
||||
*/
|
||||
static void registerWindow(QWidget *wid);
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* Unregisters the window registered by registerWindow().
|
||||
*/
|
||||
static void unregisterWindow(QObject *wid);
|
||||
|
||||
static void emitReparseSlaveConfiguration();
|
||||
|
||||
static Scheduler *self();
|
||||
|
@ -151,8 +137,6 @@ namespace KIO {
|
|||
|
||||
// connected to D-Bus signal:
|
||||
Q_PRIVATE_SLOT(d_func(), void slotReparseSlaveConfiguration(const QString &, const QDBusMessage&))
|
||||
|
||||
Q_PRIVATE_SLOT(d_func(), void slotUnregisterWindow(QObject *))
|
||||
private:
|
||||
friend class SchedulerPrivate;
|
||||
SchedulerPrivate *d_func();
|
||||
|
|
Loading…
Add table
Reference in a new issue