mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +00:00
plasma: use taskmanager library directly in switchwindow containment actions
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
cfecf4def5
commit
4eb64ca003
16 changed files with 19 additions and 1028 deletions
|
@ -8,7 +8,7 @@ set(switchwindow_SRCS
|
|||
kde4_add_plugin(plasma_containmentactions_switchwindow ${switchwindow_SRCS})
|
||||
target_link_libraries(plasma_containmentactions_switchwindow
|
||||
KDE4::plasma
|
||||
KDE4::kio
|
||||
taskmanager
|
||||
)
|
||||
|
||||
install(
|
||||
|
|
|
@ -19,16 +19,10 @@
|
|||
|
||||
#include "switch.h"
|
||||
|
||||
#include <QtGui/qgraphicssceneevent.h>
|
||||
#include <QtGui/qgraphicssceneevent.h>
|
||||
#include <QTimer>
|
||||
|
||||
#include <KDebug>
|
||||
#include <KMenu>
|
||||
#include <KWindowSystem>
|
||||
|
||||
#include <Plasma/DataEngine>
|
||||
#include <Plasma/Service>
|
||||
#include <taskmanager/taskmanager.h>
|
||||
|
||||
SwitchWindow::SwitchWindow(QObject *parent, const QVariantList &args)
|
||||
: Plasma::ContainmentActions(parent, args),
|
||||
|
@ -105,31 +99,21 @@ void SwitchWindow::contextEvent(QEvent *event)
|
|||
void SwitchWindow::makeMenu()
|
||||
{
|
||||
m_menu->clear();
|
||||
Plasma::DataEngine *tasks = dataEngine("tasks");
|
||||
if (!tasks->isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QMultiHash<int, QAction*> desktops;
|
||||
|
||||
//make all the window actions
|
||||
foreach (const QString &source, tasks->sources()) {
|
||||
Plasma::DataEngine::Data window = tasks->query(source);
|
||||
if (window.value("startup").toBool()) {
|
||||
//kDebug() << "skipped fake task" << source;
|
||||
continue;
|
||||
}
|
||||
|
||||
QString name = window.value("visibleNameWithState").toString();
|
||||
// make all the window actions
|
||||
foreach (TaskManager::Task *task, TaskManager::TaskManager::self()->tasks()) {
|
||||
QString name = task->visibleNameWithState();
|
||||
if (name.isEmpty()) {
|
||||
kDebug() << "failed source" << source;
|
||||
kDebug() << "skipping task with empty name";
|
||||
continue;
|
||||
}
|
||||
|
||||
QAction *action = new QAction(name, m_menu);
|
||||
action->setIcon(window.value("icon").value<QIcon>());
|
||||
action->setData(source);
|
||||
desktops.insert(window.value("desktop").toInt(), action);
|
||||
action->setIcon(task->icon());
|
||||
action->setData(qlonglong(task->window()));
|
||||
desktops.insert(task->desktop(), action);
|
||||
}
|
||||
|
||||
//sort into menu
|
||||
|
@ -192,12 +176,15 @@ QList<QAction*> SwitchWindow::contextualActions()
|
|||
|
||||
void SwitchWindow::switchTo(QAction *action)
|
||||
{
|
||||
QString source = action->data().toString();
|
||||
kDebug() << source;
|
||||
Plasma::Service *service = dataEngine("tasks")->serviceForSource(source);
|
||||
if (service) {
|
||||
service->startOperationCall("activateRaiseOrIconify", service->operationParameters("activateRaiseOrIconify"));
|
||||
qlonglong taskwindow = action->data().toLongLong();
|
||||
kDebug() << "task window" << taskwindow;
|
||||
foreach (TaskManager::Task *task, TaskManager::TaskManager::self()->tasks()) {
|
||||
if (qlonglong(task->window()) == taskwindow) {
|
||||
task->activateRaiseOrIconify();
|
||||
return;
|
||||
}
|
||||
}
|
||||
kWarning() << "could not find the task window";
|
||||
}
|
||||
|
||||
void SwitchWindow::clearWindowsOrder()
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#include <QAction>
|
||||
#include <QTimer>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
|
||||
class KMenu;
|
||||
|
||||
class SwitchWindow : public Plasma::ContainmentActions
|
||||
|
|
|
@ -6,5 +6,4 @@ add_subdirectory(soliddevice)
|
|||
add_subdirectory(time)
|
||||
add_subdirectory(statusnotifieritem)
|
||||
add_subdirectory(systemmonitor)
|
||||
add_subdirectory(tasks)
|
||||
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
include_directories(
|
||||
# for taskmanager_export.h
|
||||
${CMAKE_BINARY_DIR}/libs
|
||||
${CMAKE_BINARY_DIR}/libs/taskmanager
|
||||
)
|
||||
|
||||
set(tasks_engine_SRCS
|
||||
tasksengine.cpp
|
||||
tasksource.cpp
|
||||
taskservice.cpp
|
||||
taskjob.cpp
|
||||
virtualdesktopssource.cpp
|
||||
)
|
||||
|
||||
kde4_add_plugin(plasma_engine_tasks ${tasks_engine_SRCS})
|
||||
target_link_libraries(plasma_engine_tasks
|
||||
KDE4::kdeui
|
||||
KDE4::plasma
|
||||
taskmanager
|
||||
)
|
||||
|
||||
install(TARGETS plasma_engine_tasks DESTINATION ${KDE4_PLUGIN_INSTALL_DIR})
|
||||
install(FILES plasma-dataengine-tasks.desktop DESTINATION ${KDE4_SERVICES_INSTALL_DIR})
|
|
@ -1,156 +0,0 @@
|
|||
[Desktop Entry]
|
||||
Name=Window Information
|
||||
Name[ar]=معلومات النافذة
|
||||
Name[ast]=Información de ventana
|
||||
Name[be@latin]=Źviestki z akna
|
||||
Name[bg]=Данни за прозорци
|
||||
Name[bn]=উইণ্ডো তথ্য
|
||||
Name[bn_IN]=উইন্ডো সংক্রান্ড তথ্য
|
||||
Name[bs]=podaci o prozorima
|
||||
Name[ca]=Informació de les finestres
|
||||
Name[ca@valencia]=Informació de les finestres
|
||||
Name[cs]=Informace o okně
|
||||
Name[csb]=Wëdowiédzô òknów
|
||||
Name[da]=Vinduesinformation
|
||||
Name[de]=Fensterinformationen
|
||||
Name[el]=Πληροφορίες παραθύρου
|
||||
Name[en_GB]=Window Information
|
||||
Name[eo]=Fenestra Informo
|
||||
Name[es]=Información de ventana
|
||||
Name[et]=Akende teave
|
||||
Name[eu]=Leihoari buruzko informazioa
|
||||
Name[fi]=Ikkunatiedot
|
||||
Name[fr]=Informations sur la fenêtre
|
||||
Name[fy]=Finster ynformaasje
|
||||
Name[ga]=Eolas Faoin Fhuinneog
|
||||
Name[gl]=Información de xanelas
|
||||
Name[gu]=વિન્ડો માહિતી
|
||||
Name[he]=מידע על חלון
|
||||
Name[hi]=विंडो जानकारी
|
||||
Name[hne]=विंडो जानकारी
|
||||
Name[hr]=Podaci o prozorima
|
||||
Name[hu]=Ablakjellemzők
|
||||
Name[ia]=Information de fenestra
|
||||
Name[id]=Informasi Jendela
|
||||
Name[is]=Gluggaupplýsingar
|
||||
Name[it]=Informazioni sulle finestre
|
||||
Name[ja]=ウィンドウの情報
|
||||
Name[kk]=Терезенің мәліметі
|
||||
Name[km]=ព័ត៌មានបង្អួច
|
||||
Name[kn]=ಕಿಟಕಿ ಮಾಹಿತಿ
|
||||
Name[ko]=창 정보
|
||||
Name[ku]=Agahiya Paceyê
|
||||
Name[lt]=Lango informacija
|
||||
Name[lv]=Logu informācija
|
||||
Name[mk]=Информации за прозорец
|
||||
Name[ml]=വിന്ഡോ വിവരം
|
||||
Name[mr]=चौकट माहिती
|
||||
Name[nb]=Vindusinformasjon
|
||||
Name[nds]=Finster-Informatschonen
|
||||
Name[nl]=Vensterinformatie
|
||||
Name[nn]=Vindaugsinformasjon
|
||||
Name[or]=ୱିଣ୍ଡୋ ସୂଚନା
|
||||
Name[pa]=ਵਿੰਡੋ ਜਾਣਕਾਰੀ
|
||||
Name[pl]=Informacje o oknie
|
||||
Name[pt]=Informação das Janelas
|
||||
Name[pt_BR]=Informações da janela
|
||||
Name[ro]=Informații fereastră
|
||||
Name[ru]=Сведения об окне
|
||||
Name[si]=කවුළු තොරතුරු
|
||||
Name[sk]=Informácie o oknách
|
||||
Name[sl]=Podatki o oknih
|
||||
Name[sr]=подаци о прозорима
|
||||
Name[sr@ijekavian]=подаци о прозорима
|
||||
Name[sr@ijekavianlatin]=podaci o prozorima
|
||||
Name[sr@latin]=podaci o prozorima
|
||||
Name[sv]=Fönsterinformation
|
||||
Name[ta]=Window Information
|
||||
Name[tg]=Сведения об окне
|
||||
Name[th]=ข้อมูลของหน้าต่าง
|
||||
Name[tr]=Pencere Bilgileri
|
||||
Name[ug]=كۆزنەك ئۇچۇرى
|
||||
Name[uk]=Інформація про вікна
|
||||
Name[wa]=Informåcions sol finiesse
|
||||
Name[x-test]=xxWindow Informationxx
|
||||
Name[zh_CN]=窗口信息
|
||||
Name[zh_TW]=視窗資訊
|
||||
Comment=Information and management services for all available windows.
|
||||
Comment[ar]=معلومات و خدمات الإدارة لجميع النوافذ المتاحة.
|
||||
Comment[ast]=Información y servicios de xestión pa toles ventanes disponibles.
|
||||
Comment[bg]=Данни и услуги за управление на всички налични прозорци.
|
||||
Comment[bs]=Servisi za podatke i upravljanje svim dostupnim prozorima.
|
||||
Comment[ca]=Serveis d'informació i gestió de totes les finestres disponibles.
|
||||
Comment[ca@valencia]=Serveis d'informació i gestió de totes les finestres disponibles.
|
||||
Comment[cs]=Informace a správa služeb pro všechna dostupná okna.
|
||||
Comment[da]=Information og håndteringstjenester for alle tilgængelige vinduer.
|
||||
Comment[de]=Informationen und Verwaltungsdienste für alle verfügbaren Fenster.
|
||||
Comment[el]=Πληροφορίες υπηρεσιών διαχείρισης για όλα τα διαθέσιμα παράθυρα.
|
||||
Comment[en_GB]=Information and management services for all available windows.
|
||||
Comment[eo]=Informado kaj servmastrumado por ĉiuj disponeblaj fenestroj.
|
||||
Comment[es]=Información y servicios de gestión para todas las ventanas disponibles.
|
||||
Comment[et]=Teave kõikide akende kohta ja vastavad haldamisteenused.
|
||||
Comment[eu]=Informazioa eta kudeaketa-zerbitzuak leiho erabilgarri guztientzat.
|
||||
Comment[fi]=Tieto- ja hallintapalveluja kaikkille käytettävissä oleville ikkunoille.
|
||||
Comment[fr]=Services d'informations et de gestion pour toutes les fenêtres disponibles.
|
||||
Comment[fy]=Ynformaasje en behear tsjinsten foar alle beskikbere finsters.
|
||||
Comment[gl]=Servizos de información e xestión de todas as xanelas dispoñíbeis.
|
||||
Comment[he]=שירותי מידע וניהול עבור כל החלונות הזמינים.
|
||||
Comment[hr]=Usluge informiranja i upravljanja za sve dostupne prozore
|
||||
Comment[hu]=Jellemzők és kezelő szolgáltatások az összes elérhető ablakhoz.
|
||||
Comment[ia]=Servicios de gestion e information pro omne fenestras disponibile.
|
||||
Comment[id]=Layanan informasi dan manajemen untuk semua jendela yang tersedia.
|
||||
Comment[is]=Upplýsinga- og stýringaþjónusta fyrir alla tiltæka glugga.
|
||||
Comment[it]=Servizi di informazioni e gestione per tutte le finestre disponibili.
|
||||
Comment[ja]=すべての利用可能なウィンドウ用の情報・管理サービスです。
|
||||
Comment[kk]=Бүкіл бар терезелерінің мәліметі мен басқару қызметтері.
|
||||
Comment[km]=ព័ត៌មានអំពីសេវា និងការគ្រប់គ្រងសម្រាប់វីនដូដែលអាចប្រើបានទាំងអស់ ។
|
||||
Comment[kn]=ಲಭ್ಯವಿರುವ ಎಲ್ಲಾ ವಿಂಡೋಗಳಿಗಾಗಿನ ಮಾಹಿತಿ ಹಾಗು ನಿರ್ವಹಣಾ ಸೇವೆಗಳು.
|
||||
Comment[ko]=사용 가능한 창에 대한 정보 및 관리 서비스입니다.
|
||||
Comment[lt]=Informacija ir tvarkymo tarnybos visiems prieinamiems langams.
|
||||
Comment[lv]=Informācija un pārvaldības servisi visiem pieejamajiem logiem.
|
||||
Comment[mk]=Информации и менаџирање сервиси за сите достапни прозорци.
|
||||
Comment[ml]=ലഭ്യമായ ജാലകങ്ങള്ക്കുള്ള വിവരണങ്ങളും നേതൃത്വ സേവനങ്ങളും.
|
||||
Comment[mr]=सर्व उपलब्ध चौकटींकरिता माहिती व व्यवस्थापन सेवा
|
||||
Comment[nb]=Informasjon og styringstjenester for alle tilgjengelige vinduer.
|
||||
Comment[nds]=Informatschonen un Pleegdeensten för all verföögbor Finstern
|
||||
Comment[nl]=Informatie- en beheerservices voor alle beschikbare vensters.
|
||||
Comment[nn]=Informasjon om og handteringstenester for alle tilgjengelege vindauge.
|
||||
Comment[pa]=ਸਭ ਉਪਲੱਬਧ ਵਿੰਡੋਜ਼ ਲਈ ਜਾਣਕਾਰੀ ਅਤੇ ਪਰਬੰਧ ਸਰਵਿਸਾਂ
|
||||
Comment[pl]=Informacje i usługi zarządzania dla wszystkich dostępnych okien.
|
||||
Comment[pt]=Serviços de informação e gestão dos serviços para todas as janelas disponíveis.
|
||||
Comment[pt_BR]=Informação e gerenciamento de serviços para todas as janelas disponíveis.
|
||||
Comment[ro]=Servicii de informare și gestiune pentru toate ferestrele disponibile.
|
||||
Comment[ru]=Информация и управление всеми доступными окнами.
|
||||
Comment[si]=පවතින සියළු කවුළු සඳහා තොරතුරු හා පරිපාලන සේවා
|
||||
Comment[sk]=Informačné a riadiace služby pre všetky dostupné okná.
|
||||
Comment[sl]=Podatki o vseh razpoložljivih oknih in storitve za upravljanje oken.
|
||||
Comment[sr]=Сервиси за податке и управљање свим доступним прозорима.
|
||||
Comment[sr@ijekavian]=Сервиси за податке и управљање свим доступним прозорима.
|
||||
Comment[sr@ijekavianlatin]=Servisi za podatke i upravljanje svim dostupnim prozorima.
|
||||
Comment[sr@latin]=Servisi za podatke i upravljanje svim dostupnim prozorima.
|
||||
Comment[sv]=Information om och hanteringstjänster för alla tillgängliga fönster.
|
||||
Comment[tg]=Иттилоот ва идоракунии хизматҳо барои ҳамаи тирезаҳои дастрас.
|
||||
Comment[th]=ข้อมูลรายละเอียดและบริการการจัดการต่าง ๆ สำหรับหน้าต่างที่มีใช้งานทั้งหมด
|
||||
Comment[tr]=Kullanılabilir tüm pencereler için bilgi ve yönetim servisleri.
|
||||
Comment[ug]=ئىشلەتكىلى بولىدىغان ھەممە كۆزنەكلەرنىڭ ئۇچۇرى ۋە باشقۇرۇش مۇلازىمەتلىرى
|
||||
Comment[uk]=Відомості щодо служб і керування ними для всіх доступних вікон.
|
||||
Comment[vi]=Thông tin và các dịch vụ quản lý cho tất cả các cửa sổ hiện hữu.
|
||||
Comment[wa]=Informåcions eyet siervices di manaedjmint po tos les purneas k' i gn a.
|
||||
Comment[x-test]=xxInformation and management services for all available windows.xx
|
||||
Comment[zh_CN]=全部可用窗口的信息和管理服务
|
||||
Comment[zh_TW]=所有可用的視窗的資訊與管理服務。
|
||||
Type=Service
|
||||
Icon=user-desktop
|
||||
|
||||
X-KDE-ServiceTypes=Plasma/DataEngine
|
||||
X-KDE-Library=plasma_engine_tasks
|
||||
|
||||
X-KDE-PluginInfo-Author=Robert Knight
|
||||
X-KDE-PluginInfo-Email=robertknight@gmail.com
|
||||
X-KDE-PluginInfo-Name=tasks
|
||||
X-KDE-PluginInfo-Version=0.1
|
||||
X-KDE-PluginInfo-Website=
|
||||
X-KDE-PluginInfo-Category=Windows and Tasks
|
||||
X-KDE-PluginInfo-Depends=
|
||||
X-KDE-PluginInfo-License=LGPL
|
||||
X-KDE-PluginInfo-EnabledByDefault=true
|
|
@ -1,136 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Alain Boyer <alainboyer@gmail.com>
|
||||
*
|
||||
* This program 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 program 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 General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "taskjob.h"
|
||||
|
||||
TaskJob::TaskJob(TaskSource *source, const QString &operation, const QMap<QString, QVariant> ¶meters, QObject *parent) :
|
||||
ServiceJob(source->objectName(), operation, parameters, parent),
|
||||
m_source(source)
|
||||
{
|
||||
}
|
||||
|
||||
TaskJob::~TaskJob()
|
||||
{
|
||||
}
|
||||
|
||||
void TaskJob::start()
|
||||
{
|
||||
if (!m_source->task()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// only a subset of task operations are exported
|
||||
const QString operation = operationName();
|
||||
if (operation == "setMaximized") {
|
||||
m_source->task()->setMaximized(parameters().value("maximized").toBool());
|
||||
setResult(true);
|
||||
return;
|
||||
} else if (operation == "setMinimized") {
|
||||
m_source->task()->setIconified(parameters().value("minimized").toBool());
|
||||
setResult(true);
|
||||
return;
|
||||
} else if (operation == "setShaded") {
|
||||
m_source->task()->setShaded(parameters().value("shaded").toBool());
|
||||
setResult(true);
|
||||
return;
|
||||
} else if (operation == "setFullScreen") {
|
||||
m_source->task()->setFullScreen(parameters().value("fullScreen").toBool());
|
||||
setResult(true);
|
||||
return;
|
||||
} else if (operation == "setAlwaysOnTop") {
|
||||
m_source->task()->setAlwaysOnTop(parameters().value("alwaysOnTop").toBool());
|
||||
setResult(true);
|
||||
return;
|
||||
} else if (operation == "setKeptBelowOthers") {
|
||||
m_source->task()->setKeptBelowOthers(parameters().value("keptBelowOthers").toBool());
|
||||
setResult(true);
|
||||
return;
|
||||
} else if (operation == "toggleMaximized") {
|
||||
m_source->task()->toggleMaximized();
|
||||
setResult(true);
|
||||
return;
|
||||
} else if (operation == "toggleMinimized") {
|
||||
m_source->task()->toggleIconified();
|
||||
setResult(true);
|
||||
return;
|
||||
} else if (operation == "toggleShaded") {
|
||||
m_source->task()->toggleShaded();
|
||||
setResult(true);
|
||||
return;
|
||||
} else if (operation == "toggleFullScreen") {
|
||||
m_source->task()->toggleFullScreen();
|
||||
setResult(true);
|
||||
return;
|
||||
} else if (operation == "toggleAlwaysOnTop") {
|
||||
m_source->task()->toggleAlwaysOnTop();
|
||||
setResult(true);
|
||||
return;
|
||||
} else if (operation == "toggleKeptBelowOthers") {
|
||||
m_source->task()->toggleKeptBelowOthers();
|
||||
setResult(true);
|
||||
return;
|
||||
} else if (operation == "restore") {
|
||||
m_source->task()->restore();
|
||||
setResult(true);
|
||||
return;
|
||||
} else if (operation == "resize") {
|
||||
m_source->task()->resize();
|
||||
setResult(true);
|
||||
return;
|
||||
} else if (operation == "move") {
|
||||
m_source->task()->move();
|
||||
setResult(true);
|
||||
return;
|
||||
} else if (operation == "raise") {
|
||||
m_source->task()->raise();
|
||||
setResult(true);
|
||||
return;
|
||||
} else if (operation == "lower") {
|
||||
m_source->task()->lower();
|
||||
setResult(true);
|
||||
return;
|
||||
} else if (operation == "activate") {
|
||||
m_source->task()->activate();
|
||||
setResult(true);
|
||||
return;
|
||||
} else if (operation == "activateRaiseOrIconify") {
|
||||
m_source->task()->activateRaiseOrIconify();
|
||||
setResult(true);
|
||||
return;
|
||||
} else if (operation == "close") {
|
||||
m_source->task()->close();
|
||||
setResult(true);
|
||||
return;
|
||||
} else if (operation == "toDesktop") {
|
||||
m_source->task()->toDesktop(parameters().value("desktop").toInt());
|
||||
setResult(true);
|
||||
return;
|
||||
} else if (operation == "toCurrentDesktop") {
|
||||
m_source->task()->toCurrentDesktop();
|
||||
setResult(true);
|
||||
return;
|
||||
} else if (operation == "publishIconGeometry") {
|
||||
m_source->task()->publishIconGeometry(parameters().value("geometry").toRect());
|
||||
setResult(true);
|
||||
return;
|
||||
}
|
||||
|
||||
setResult(false);
|
||||
}
|
||||
|
||||
#include "moc_taskjob.cpp"
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Alain Boyer <alainboyer@gmail.com>
|
||||
*
|
||||
* This program 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 program 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 General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef TASKJOB_H
|
||||
#define TASKJOB_H
|
||||
|
||||
// plasma
|
||||
#include <Plasma/ServiceJob>
|
||||
|
||||
// own
|
||||
#include "tasksource.h"
|
||||
|
||||
/**
|
||||
* Task Job
|
||||
*/
|
||||
class TaskJob : public Plasma::ServiceJob
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskJob(TaskSource *source, const QString &operation, const QMap<QString, QVariant> ¶meters, QObject *parent = NULL);
|
||||
~TaskJob();
|
||||
|
||||
protected:
|
||||
void start();
|
||||
|
||||
private:
|
||||
TaskSource *m_source;
|
||||
|
||||
};
|
||||
|
||||
#endif // TASKJOB_H
|
|
@ -1,128 +0,0 @@
|
|||
/*
|
||||
* Copyright 2007 Robert Knight <robertknight@gmail.com>
|
||||
*
|
||||
* This program 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 program 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 General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "tasksengine.h"
|
||||
#include "virtualdesktopssource.h"
|
||||
|
||||
// own
|
||||
#include "tasksource.h"
|
||||
|
||||
TasksEngine::TasksEngine(QObject *parent, const QVariantList &args) :
|
||||
Plasma::DataEngine(parent, args)
|
||||
{
|
||||
Q_UNUSED(args);
|
||||
}
|
||||
|
||||
TasksEngine::~TasksEngine()
|
||||
{
|
||||
}
|
||||
|
||||
Plasma::Service *TasksEngine::serviceForSource(const QString &name)
|
||||
{
|
||||
TaskSource *source = qobject_cast<TaskSource*>(containerForSource(name));
|
||||
// if source does not exist or it represents a startup task, return a null service
|
||||
if (!source || !source->task()) {
|
||||
return Plasma::DataEngine::serviceForSource(name);
|
||||
}
|
||||
|
||||
// if source represent a proper task, return task service
|
||||
Plasma::Service *service = source->createService();
|
||||
service->setParent(this);
|
||||
return service;
|
||||
}
|
||||
|
||||
const QString TasksEngine::getStartupName(::TaskManager::Startup *startup)
|
||||
{
|
||||
return startup->id().id();
|
||||
}
|
||||
|
||||
const QString TasksEngine::getTaskName(::TaskManager::Task *task)
|
||||
{
|
||||
return QString::number(task->window());
|
||||
}
|
||||
|
||||
void TasksEngine::init()
|
||||
{
|
||||
foreach (TaskManager::Task *task, TaskManager::TaskManager::self()->tasks()) {
|
||||
Q_ASSERT(task);
|
||||
taskAdded(task);
|
||||
}
|
||||
|
||||
TaskManager::TaskManager *manager = TaskManager::TaskManager::self();
|
||||
connect(manager, SIGNAL(startupAdded(::TaskManager::Startup*)), this, SLOT(startupAdded(::TaskManager::Startup*)));
|
||||
connect(manager, SIGNAL(startupRemoved(::TaskManager::Startup*)), this, SLOT(startupRemoved(::TaskManager::Startup*)));
|
||||
connect(manager, SIGNAL(taskAdded(::TaskManager::Task*)), this, SLOT(taskAdded(::TaskManager::Task*)));
|
||||
connect(manager, SIGNAL(taskRemoved(::TaskManager::Task*)), this, SLOT(taskRemoved(::TaskManager::Task*)));
|
||||
}
|
||||
|
||||
void TasksEngine::startupRemoved(::TaskManager::Startup *startup)
|
||||
{
|
||||
Q_ASSERT(startup);
|
||||
// there is an event loop ref counting bug in Qt that prevents deleteLater() from working
|
||||
// properly, so we need to remove the source our selves with a single shot
|
||||
//removeSource(getStartupName(startup));
|
||||
if (Plasma::DataContainer *container = containerForSource(getStartupName(startup))) {
|
||||
QTimer::singleShot(0, container, SLOT(deleteLater()));
|
||||
}
|
||||
}
|
||||
|
||||
void TasksEngine::taskRemoved(::TaskManager::Task *task)
|
||||
{
|
||||
Q_ASSERT(task);
|
||||
// there is an event loop ref counting bug in Qt that prevents deleteLater() from working
|
||||
// properly, so we need to remove the source our selves with a single shot
|
||||
//removeSource(getTaskName(task));
|
||||
if (Plasma::DataContainer *container = containerForSource(getTaskName(task))) {
|
||||
QTimer::singleShot(0, container, SLOT(deleteLater()));
|
||||
}
|
||||
}
|
||||
|
||||
void TasksEngine::startupAdded(::TaskManager::Startup *startup)
|
||||
{
|
||||
Q_ASSERT(startup);
|
||||
if (!containerForSource(getStartupName(startup))) {
|
||||
TaskSource *taskSource = new TaskSource(startup, this);
|
||||
connect(startup, SIGNAL(changed(::TaskManager::TaskChanges)), taskSource, SLOT(updateStartup(::TaskManager::TaskChanges)));
|
||||
addSource(taskSource);
|
||||
}
|
||||
}
|
||||
|
||||
void TasksEngine::taskAdded(::TaskManager::Task *task)
|
||||
{
|
||||
Q_ASSERT(task);
|
||||
if (!containerForSource(getTaskName(task))) {
|
||||
TaskSource *taskSource = new TaskSource(task, this);
|
||||
connect(task, SIGNAL(changed(::TaskManager::TaskChanges)), taskSource, SLOT(updateTask(::TaskManager::TaskChanges)));
|
||||
connect(TaskManager::TaskManager::self(), SIGNAL(desktopChanged(int)), taskSource, SLOT(updateDesktop()));
|
||||
addSource(taskSource);
|
||||
}
|
||||
}
|
||||
|
||||
bool TasksEngine::sourceRequestEvent(const QString &source)
|
||||
{
|
||||
if (source == "virtualDesktops") {
|
||||
addSource(new VirtualDesktopsSource);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
K_EXPORT_PLASMA_DATAENGINE(tasks, TasksEngine)
|
||||
|
||||
#include "moc_tasksengine.cpp"
|
|
@ -1,75 +0,0 @@
|
|||
/*
|
||||
* Copyright 2007 Robert Knight <robertknight@gmail.com>
|
||||
*
|
||||
* This program 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 program 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 General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef TASKSENGINE_H
|
||||
#define TASKSENGINE_H
|
||||
|
||||
// plasma
|
||||
#include <Plasma/DataEngine>
|
||||
#include <Plasma/Service>
|
||||
|
||||
// libtaskmanager
|
||||
#include <taskmanager/taskmanager.h>
|
||||
|
||||
namespace TaskManager
|
||||
{
|
||||
class Startup;
|
||||
class Task;
|
||||
} // namespace TaskManager
|
||||
|
||||
/**
|
||||
* Tasks Data Engine
|
||||
*
|
||||
* This engine provides information regarding tasks (windows that are currently open)
|
||||
* as well as startup tasks (windows that are about to open).
|
||||
* Each task and startup is represented by a unique source. Sources are added and removed
|
||||
* as windows are opened and closed. You cannot request a customized source.
|
||||
*
|
||||
* A service is also provided for each task. It exposes some operations that can be
|
||||
* performed on the windows (ex: maximize, minimize, activate).
|
||||
*
|
||||
* The data and operations are provided and handled by the taskmanager library.
|
||||
* It should be noted that only a subset of data and operations are exposed.
|
||||
*/
|
||||
class TasksEngine : public Plasma::DataEngine
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TasksEngine(QObject *parent, const QVariantList &args);
|
||||
~TasksEngine();
|
||||
Plasma::Service *serviceForSource(const QString &name);
|
||||
|
||||
protected:
|
||||
static const QString getStartupName(::TaskManager::Startup *startup);
|
||||
static const QString getTaskName(::TaskManager::Task *task);
|
||||
virtual void init();
|
||||
bool sourceRequestEvent(const QString &source);
|
||||
|
||||
private slots:
|
||||
void startupAdded(::TaskManager::Startup *startup);
|
||||
void startupRemoved(::TaskManager::Startup *startup);
|
||||
void taskAdded(::TaskManager::Task *task);
|
||||
void taskRemoved(::TaskManager::Task *task);
|
||||
|
||||
private:
|
||||
friend class TaskSource;
|
||||
};
|
||||
|
||||
#endif // TASKSENGINE_H
|
|
@ -1,66 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Alain Boyer <alainboyer@gmail.com>
|
||||
*
|
||||
* This program 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 program 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 General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "taskservice.h"
|
||||
|
||||
// own
|
||||
#include "taskjob.h"
|
||||
|
||||
TaskService::TaskService(TaskSource *source) :
|
||||
Plasma::Service(source),
|
||||
m_source(source)
|
||||
{
|
||||
setName("tasks");
|
||||
setOperationNames(
|
||||
QStringList()
|
||||
<< "setMaximized"
|
||||
<< "setMinimized"
|
||||
<< "setShaded"
|
||||
<< "setFullScreen"
|
||||
<< "setAlwaysOnTop"
|
||||
<< "setKeptBelowOthers"
|
||||
<< "toggleMaximized"
|
||||
<< "toggleMinimized"
|
||||
<< "toggleShaded"
|
||||
<< "toggleFullScreen"
|
||||
<< "toggleAlwaysOnTop"
|
||||
<< "toggleKeptBelowOthers"
|
||||
<< "restore"
|
||||
<< "resize"
|
||||
<< "move"
|
||||
<< "raise"
|
||||
<< "lower"
|
||||
<< "activate"
|
||||
<< "activateRaiseOrIconify"
|
||||
<< "close"
|
||||
<< "toDesktop"
|
||||
<< "toCurrentDesktop"
|
||||
<< "publishIconGeometry"
|
||||
);
|
||||
}
|
||||
|
||||
TaskService::~TaskService()
|
||||
{
|
||||
}
|
||||
|
||||
Plasma::ServiceJob *TaskService::createJob(const QString &operation, const QMap<QString, QVariant> ¶meters)
|
||||
{
|
||||
return new TaskJob(m_source, operation, parameters, this);
|
||||
}
|
||||
|
||||
#include "moc_taskservice.cpp"
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Alain Boyer <alainboyer@gmail.com>
|
||||
*
|
||||
* This program 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 program 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 General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef TASKSERVICE_H
|
||||
#define TASKSERVICE_H
|
||||
|
||||
// plasma
|
||||
#include <Plasma/Service>
|
||||
#include <Plasma/ServiceJob>
|
||||
|
||||
// own
|
||||
#include "tasksource.h"
|
||||
|
||||
/**
|
||||
* Task Service
|
||||
*/
|
||||
class TaskService : public Plasma::Service
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskService(TaskSource *source);
|
||||
~TaskService();
|
||||
|
||||
protected:
|
||||
Plasma::ServiceJob *createJob(const QString &operation, const QMap<QString, QVariant> ¶meters);
|
||||
|
||||
private:
|
||||
TaskSource *m_source;
|
||||
};
|
||||
|
||||
#endif // TASKSERVICE_H
|
|
@ -1,165 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Alain Boyer <alainboyer@gmail.com>
|
||||
*
|
||||
* This program 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 program 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 General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "tasksource.h"
|
||||
|
||||
// own
|
||||
#include "tasksengine.h"
|
||||
#include "taskservice.h"
|
||||
|
||||
TaskSource::TaskSource(::TaskManager::Startup *startup, QObject *parent)
|
||||
: Plasma::DataContainer(parent),
|
||||
m_startup(startup)
|
||||
{
|
||||
setObjectName(TasksEngine::getStartupName(startup));
|
||||
setData("startup", true);
|
||||
setData("task", false);
|
||||
updateStartup(TaskManager::TaskUnchanged);
|
||||
}
|
||||
|
||||
TaskSource::TaskSource(::TaskManager::Task *task, QObject *parent)
|
||||
: Plasma::DataContainer(parent),
|
||||
m_task(task)
|
||||
{
|
||||
setObjectName(TasksEngine::getTaskName(task));
|
||||
setData("startup", false);
|
||||
setData("task", true);
|
||||
setData("className", task->className());
|
||||
setData("classClass", task->classClass());
|
||||
updateTask(TaskManager::EverythingChanged);
|
||||
}
|
||||
|
||||
TaskSource::~TaskSource()
|
||||
{
|
||||
}
|
||||
|
||||
Plasma::Service *TaskSource::createService()
|
||||
{
|
||||
return new TaskService(this);
|
||||
}
|
||||
|
||||
::TaskManager::Task *TaskSource::task()
|
||||
{
|
||||
return m_task.data();
|
||||
}
|
||||
|
||||
void TaskSource::updateStartup(::TaskManager::TaskChanges startupChanges)
|
||||
{
|
||||
::TaskManager::Startup *startup = m_startup.data();
|
||||
if (!startup) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (startupChanges) {
|
||||
case TaskManager::TaskUnchanged:
|
||||
setData("text", startup->text());
|
||||
setData("bin", startup->bin());
|
||||
setData("icon", startup->icon());
|
||||
}
|
||||
checkForUpdate();
|
||||
}
|
||||
|
||||
void TaskSource::updateTask(::TaskManager::TaskChanges taskChanges)
|
||||
{
|
||||
::TaskManager::Task *taskPtr = m_task.data();
|
||||
if (!taskPtr) {
|
||||
return;
|
||||
}
|
||||
|
||||
// only a subset of task information is exported
|
||||
switch (taskChanges) {
|
||||
case TaskManager::EverythingChanged:
|
||||
setData("name", taskPtr->name());
|
||||
setData("visibleName", taskPtr->visibleName());
|
||||
setData("visibleNameWithState", taskPtr->visibleNameWithState());
|
||||
setData("maximized", taskPtr->isMaximized());
|
||||
setData("minimized", taskPtr->isMinimized());
|
||||
setData("shaded", taskPtr->isShaded());
|
||||
setData("fullScreen", taskPtr->isFullScreen());
|
||||
setData("alwaysOnTop", taskPtr->isAlwaysOnTop());
|
||||
setData("keptBelowOthers", taskPtr->isKeptBelowOthers());
|
||||
setData("active", taskPtr->isActive());
|
||||
setData("onTop", taskPtr->isOnTop());
|
||||
setData("onCurrentDesktop", taskPtr->isOnCurrentDesktop());
|
||||
setData("onAllDesktops", taskPtr->isOnAllDesktops());
|
||||
setData("desktop", taskPtr->desktop());
|
||||
setData("icon", taskPtr->icon());
|
||||
setData("actionMinimize", taskPtr->info().actionSupported(NET::ActionMinimize));
|
||||
setData("actionMaximize", taskPtr->info().actionSupported(NET::ActionMax));
|
||||
setData("actionShade", taskPtr->info().actionSupported(NET::ActionShade));
|
||||
setData("actionResize", taskPtr->info().actionSupported(NET::ActionResize));
|
||||
setData("actionMove", taskPtr->info().actionSupported(NET::ActionMove));
|
||||
setData("actionClose", taskPtr->info().actionSupported(NET::ActionClose));
|
||||
setData("actionChangeDesktop", taskPtr->info().actionSupported(NET::ActionChangeDesktop));
|
||||
setData("actionFullScreen", taskPtr->info().actionSupported(NET::ActionFullScreen));
|
||||
break;
|
||||
case TaskManager::IconChanged:
|
||||
setData("icon", taskPtr->icon());
|
||||
break;
|
||||
case TaskManager::NameChanged:
|
||||
setData("name", taskPtr->name());
|
||||
setData("visibleName", taskPtr->visibleName());
|
||||
setData("visibleNameWithState", taskPtr->visibleNameWithState());
|
||||
break;
|
||||
case TaskManager::StateChanged:
|
||||
setData("maximized", taskPtr->isMaximized());
|
||||
setData("minimized", taskPtr->isMinimized());
|
||||
setData("shaded", taskPtr->isShaded());
|
||||
setData("fullScreen", taskPtr->isFullScreen());
|
||||
setData("alwaysOnTop", taskPtr->isAlwaysOnTop());
|
||||
setData("keptBelowOthers", taskPtr->isKeptBelowOthers());
|
||||
setData("active", taskPtr->isActive());
|
||||
setData("onTop", taskPtr->isOnTop());
|
||||
setData("visibleNameWithState", taskPtr->visibleNameWithState());
|
||||
break;
|
||||
case TaskManager::DesktopChanged:
|
||||
setData("onCurrentDesktop", taskPtr->isOnCurrentDesktop());
|
||||
setData("onAllDesktops", taskPtr->isOnAllDesktops());
|
||||
setData("desktop", taskPtr->desktop());
|
||||
break;
|
||||
case TaskManager::ActionsChanged:
|
||||
setData("actionMinimize", taskPtr->info().actionSupported(NET::ActionMinimize));
|
||||
setData("actionMaximize", taskPtr->info().actionSupported(NET::ActionMax));
|
||||
setData("actionShade", taskPtr->info().actionSupported(NET::ActionShade));
|
||||
setData("actionResize", taskPtr->info().actionSupported(NET::ActionResize));
|
||||
setData("actionMove", taskPtr->info().actionSupported(NET::ActionMove));
|
||||
setData("actionClose", taskPtr->info().actionSupported(NET::ActionClose));
|
||||
setData("actionChangeDesktop", taskPtr->info().actionSupported(NET::ActionChangeDesktop));
|
||||
setData("actionFullScreen", taskPtr->info().actionSupported(NET::ActionFullScreen));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
checkForUpdate();
|
||||
}
|
||||
|
||||
void TaskSource::updateDesktop()
|
||||
{
|
||||
if (!m_task) {
|
||||
return;
|
||||
}
|
||||
|
||||
const bool onCurrentDesktop = m_task.data()->isOnCurrentDesktop();
|
||||
if (data()["onCurrentDesktop"].toBool() != onCurrentDesktop) {
|
||||
setData("onCurrentDesktop", onCurrentDesktop);
|
||||
checkForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#include "moc_tasksource.cpp"
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Alain Boyer <alainboyer@gmail.com>
|
||||
*
|
||||
* This program 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 program 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 General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef TASKSOURCE_H
|
||||
#define TASKSOURCE_H
|
||||
|
||||
// plasma
|
||||
#include <Plasma/DataContainer>
|
||||
|
||||
// libtaskmanager
|
||||
#include <taskmanager/taskmanager.h>
|
||||
|
||||
/**
|
||||
* Task Source
|
||||
*
|
||||
* This custom DataContainer represents a task or startup task as a unique source.
|
||||
* It holds a shared pointer to the task or startup task and is responsible for setting
|
||||
* and updating the data exposed by the source.
|
||||
*/
|
||||
class TaskSource : public Plasma::DataContainer
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskSource(::TaskManager::Startup *startup, QObject *parent);
|
||||
TaskSource(::TaskManager::Task *task, QObject *parent);
|
||||
~TaskSource();
|
||||
|
||||
Plasma::Service *createService();
|
||||
::TaskManager::Task *task();
|
||||
|
||||
private slots:
|
||||
void updateStartup(::TaskManager::TaskChanges startupChanges);
|
||||
void updateTask(::TaskManager::TaskChanges taskChanges);
|
||||
void updateDesktop();
|
||||
|
||||
private:
|
||||
QWeakPointer< ::TaskManager::Startup > m_startup;
|
||||
QWeakPointer< ::TaskManager::Task > m_task;
|
||||
};
|
||||
|
||||
#endif // TASKSOURCE_H
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010 Matthieu Gallien <matthieu_gallien@yahoo.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "virtualdesktopssource.h"
|
||||
|
||||
#include <KWindowSystem>
|
||||
|
||||
VirtualDesktopsSource::VirtualDesktopsSource() : Plasma::DataContainer()
|
||||
{
|
||||
setObjectName( QLatin1String("virtualDesktops" ));
|
||||
connect(KWindowSystem::self(), SIGNAL(numberOfDesktopsChanged(int)), this, SLOT(updateDesktopNumber(int)));
|
||||
connect(KWindowSystem::self(), SIGNAL(desktopNamesChanged()), this, SLOT(updateDesktopNames()));
|
||||
updateDesktopNumber(KWindowSystem::self()->numberOfDesktops());
|
||||
updateDesktopNames();
|
||||
}
|
||||
|
||||
VirtualDesktopsSource::~VirtualDesktopsSource()
|
||||
{
|
||||
disconnect(KWindowSystem::self(), SIGNAL(numberOfDesktopsChanged(int)), this, SLOT(updateDesktopNumber(int)));
|
||||
}
|
||||
|
||||
void VirtualDesktopsSource::updateDesktopNumber(int desktop)
|
||||
{
|
||||
setData("number", desktop);
|
||||
checkForUpdate();
|
||||
}
|
||||
|
||||
void VirtualDesktopsSource::updateDesktopNames()
|
||||
{
|
||||
QList<QVariant> desktopNames;
|
||||
for (int i = 0; i < KWindowSystem::self()->numberOfDesktops(); i++) {
|
||||
desktopNames.append(KWindowSystem::self()->desktopName(i + 1));
|
||||
}
|
||||
setData("names", desktopNames);
|
||||
checkForUpdate();
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010 Matthieu Gallien <matthieu_gallien@yahoo.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef VIRTUALDESKTOPSSOURCE_H
|
||||
#define VIRTUALDESKTOPSSOURCE_H
|
||||
|
||||
// plasma
|
||||
#include <Plasma/DataContainer>
|
||||
|
||||
class VirtualDesktopsSource : public Plasma::DataContainer
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
VirtualDesktopsSource();
|
||||
|
||||
~VirtualDesktopsSource();
|
||||
|
||||
private slots:
|
||||
|
||||
void updateDesktopNumber(int desktop);
|
||||
|
||||
void updateDesktopNames();
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Add table
Reference in a new issue