diff options
Diffstat (limited to 'kdeprint/kjobviewer')
-rw-r--r-- | kdeprint/kjobviewer/Makefile.am | 24 | ||||
-rw-r--r-- | kdeprint/kjobviewer/hi128-app-kjobviewer.png | bin | 0 -> 8472 bytes | |||
-rw-r--r-- | kdeprint/kjobviewer/hi16-app-kjobviewer.png | bin | 0 -> 684 bytes | |||
-rw-r--r-- | kdeprint/kjobviewer/hi22-app-kjobviewer.png | bin | 0 -> 1003 bytes | |||
-rw-r--r-- | kdeprint/kjobviewer/hi32-app-kjobviewer.png | bin | 0 -> 1633 bytes | |||
-rw-r--r-- | kdeprint/kjobviewer/hi48-app-kjobviewer.png | bin | 0 -> 2588 bytes | |||
-rw-r--r-- | kdeprint/kjobviewer/hi64-app-kjobviewer.png | bin | 0 -> 3720 bytes | |||
-rw-r--r-- | kdeprint/kjobviewer/hisc-app-kjobviewer.svgz | bin | 0 -> 17679 bytes | |||
-rw-r--r-- | kdeprint/kjobviewer/kjobviewer.cpp | 233 | ||||
-rw-r--r-- | kdeprint/kjobviewer/kjobviewer.desktop | 92 | ||||
-rw-r--r-- | kdeprint/kjobviewer/kjobviewer.h | 57 | ||||
-rw-r--r-- | kdeprint/kjobviewer/kjobviewerui.rc | 35 | ||||
-rw-r--r-- | kdeprint/kjobviewer/main.cpp | 49 |
13 files changed, 490 insertions, 0 deletions
diff --git a/kdeprint/kjobviewer/Makefile.am b/kdeprint/kjobviewer/Makefile.am new file mode 100644 index 000000000..56be89334 --- /dev/null +++ b/kdeprint/kjobviewer/Makefile.am @@ -0,0 +1,24 @@ +AM_CPPFLAGS = -D_KDEPRINT_COMPILE + +INCLUDES = $(all_includes) + +bin_PROGRAMS= +lib_LTLIBRARIES= +kdeinit_LTLIBRARIES = kjobviewer.la + +kjobviewer_la_SOURCES = kjobviewer.cpp main.cpp +kjobviewer_la_METASOURCES = AUTO +kjobviewer_la_LIBADD = -lkdeprint_management $(LIB_KDEUI) +kjobviewer_la_LDFLAGS = -module -avoid-version $(all_libraries) $(KDE_RPATH) + +noinst_HEADERS = kjobviewer.h + +KDE_ICON = kjobviewer + +rc_DATA = kjobviewerui.rc +rcdir = $(kde_datadir)/kjobviewer + +xdg_apps_DATA = kjobviewer.desktop + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/kjobviewer.pot diff --git a/kdeprint/kjobviewer/hi128-app-kjobviewer.png b/kdeprint/kjobviewer/hi128-app-kjobviewer.png Binary files differnew file mode 100644 index 000000000..7db5f56b1 --- /dev/null +++ b/kdeprint/kjobviewer/hi128-app-kjobviewer.png diff --git a/kdeprint/kjobviewer/hi16-app-kjobviewer.png b/kdeprint/kjobviewer/hi16-app-kjobviewer.png Binary files differnew file mode 100644 index 000000000..d6defce21 --- /dev/null +++ b/kdeprint/kjobviewer/hi16-app-kjobviewer.png diff --git a/kdeprint/kjobviewer/hi22-app-kjobviewer.png b/kdeprint/kjobviewer/hi22-app-kjobviewer.png Binary files differnew file mode 100644 index 000000000..a71ee2817 --- /dev/null +++ b/kdeprint/kjobviewer/hi22-app-kjobviewer.png diff --git a/kdeprint/kjobviewer/hi32-app-kjobviewer.png b/kdeprint/kjobviewer/hi32-app-kjobviewer.png Binary files differnew file mode 100644 index 000000000..d554b554f --- /dev/null +++ b/kdeprint/kjobviewer/hi32-app-kjobviewer.png diff --git a/kdeprint/kjobviewer/hi48-app-kjobviewer.png b/kdeprint/kjobviewer/hi48-app-kjobviewer.png Binary files differnew file mode 100644 index 000000000..13adbd006 --- /dev/null +++ b/kdeprint/kjobviewer/hi48-app-kjobviewer.png diff --git a/kdeprint/kjobviewer/hi64-app-kjobviewer.png b/kdeprint/kjobviewer/hi64-app-kjobviewer.png Binary files differnew file mode 100644 index 000000000..5d22d215e --- /dev/null +++ b/kdeprint/kjobviewer/hi64-app-kjobviewer.png diff --git a/kdeprint/kjobviewer/hisc-app-kjobviewer.svgz b/kdeprint/kjobviewer/hisc-app-kjobviewer.svgz Binary files differnew file mode 100644 index 000000000..f40b4bdfa --- /dev/null +++ b/kdeprint/kjobviewer/hisc-app-kjobviewer.svgz diff --git a/kdeprint/kjobviewer/kjobviewer.cpp b/kdeprint/kjobviewer/kjobviewer.cpp new file mode 100644 index 000000000..12a7aef1a --- /dev/null +++ b/kdeprint/kjobviewer/kjobviewer.cpp @@ -0,0 +1,233 @@ +/* + * This file is part of the KDE libraries + * Copyright (c) 2001 Michael Goffioul <[email protected]> + * + * 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 "kjobviewer.h" +#include <kdeprint/kmjobviewer.h> +#include <kdeprint/kmtimer.h> +#include <kdeprint/kmmanager.h> + +#include <stdlib.h> +#include <qpixmap.h> +#include <kcmdlineargs.h> +#include <kaboutdata.h> +#include <kmessagebox.h> +#include <klocale.h> +#include <ksystemtray.h> +#include <kdebug.h> +#include <kiconloader.h> +#include <kpopupmenu.h> +#include <kwin.h> +#include <kstartupinfo.h> + +class JobTray : public KSystemTray +{ +public: + JobTray(KJobViewerApp *parent, const char *name = 0) + : KSystemTray(0, name), m_app(parent) { connect( this, SIGNAL( quitSelected() ), kapp, SLOT( quit() ) ); } +protected: + void mousePressEvent(QMouseEvent*); +private: + KJobViewerApp *m_app; +}; + +void JobTray::mousePressEvent(QMouseEvent *e) +{ + if (e->button() == Qt::RightButton) + KSystemTray::mousePressEvent(e); + else if (m_app->m_views.count() > 0) + { + KPopupMenu menu; + QDictIterator<KMJobViewer> it(m_app->m_views); + QPtrList<KMJobViewer> list; + list.setAutoDelete(false); + for (; it.current(); ++it) + { + menu.insertItem(KWin::icon(it.current()->winId(), 16, 16), it.currentKey(), list.count()); + if (it.current()->isVisible()) + menu.setItemChecked(list.count(), true); + list.append(it.current()); + } + + if (list.count() == 1) + { + // special case, old behavior + if (list.first()->isVisible()) + list.first()->hide(); + else + list.first()->show(); + } + else + { + int choice = menu.exec(mapToGlobal(e->pos())); + if (choice != -1) + { + KMJobViewer *view = list.at(choice); + if (view->isVisible()) + KWin::activateWindow(view->winId()); + else + view->show(); + } + } + } +} + +//------------------------------------------------------------- + +KJobViewerApp::KJobViewerApp() : KUniqueApplication() +{ + m_views.setAutoDelete(true); + m_tray = 0; + m_timer = 0; +} + +KJobViewerApp::~KJobViewerApp() +{ +} + +int KJobViewerApp::newInstance() +{ + initialize(); + return 0; +} + +void KJobViewerApp::initialize() +{ + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + bool showIt = args->isSet("show"); + bool all = args->isSet("all"); + QString prname = args->getOption("d"); + KMJobViewer *view(0); + + if (!m_timer) + { + m_timer = KMTimer::self(); + connect(m_timer,SIGNAL(timeout()),SLOT(slotTimer())); + } + + if (prname.isEmpty() && all) + prname = i18n("All Printers"); + + if (prname.isEmpty()) { + KMPrinter *prt = KMManager::self()->defaultPrinter(); + if (prt) + prname = prt->printerName(); + else { + KMessageBox::error(0, i18n("There is no default printer. Start with --all to see all printers."), i18n("Print Error")); + exit(1); + return; + } + } + + if (!m_tray) + { + m_tray = new JobTray(this); + m_tray->setPixmap(m_tray->loadIcon("fileprint")); + + } + + view = m_views.find(prname); + if (!view) + { + kdDebug() << "creating new view: " << prname << endl; + view = new KMJobViewer(); + connect(view, SIGNAL(jobsShown(KMJobViewer*,bool)), SLOT(slotJobsShown(KMJobViewer*,bool))); + connect(view, SIGNAL(printerChanged(KMJobViewer*,const QString&)), SLOT(slotPrinterChanged(KMJobViewer*,const QString&))); + connect(view, SIGNAL(refreshClicked()), SLOT(slotTimer())); + connect(view, SIGNAL(viewerDestroyed(KMJobViewer*)), SLOT(slotViewerDestroyed(KMJobViewer*))); + m_views.insert(prname, view); + } + + if (showIt) + { + view->show(); + m_tray->show(); + } + view->setPrinter(prname); + + //m_timer->release(true); + m_timer->delay(10); +} + +void KJobViewerApp::slotJobsShown(KMJobViewer *view, bool hasJobs) +{ + if (!hasJobs && !view->isVisible() && !view->isSticky()) + { + kdDebug() << "removing view: " << view->printer() << endl; + // the window is hidden and doesn't have any job shown -> destroy it + // closing won't have any effect as the KMJobViewer overload closeEvent() + m_views.remove(view->printer()); + } + + if (m_views.count() > 0) + { + if (!m_tray->isVisible()) + m_tray->show(); + } + else { + KStartupInfo::appStarted(); + kapp->quit(); + } +} + +void KJobViewerApp::slotTimer() +{ + // Update printer list + KMManager::self()->printerList(true); + + // Refresh views. The first time, job list is reloaded, + // other views will simply use reloaded job list + bool trigger(true); + QDictIterator<KMJobViewer> it(m_views); + for (; it.current(); ++it, trigger=false) + it.current()->refresh(trigger); +} + +void KJobViewerApp::slotPrinterChanged(KMJobViewer *view, const QString& prname) +{ + KMJobViewer *other = m_views.find(prname); + if (other) + { + if (other->isVisible()) + KWin::activateWindow(other->winId()); + else + other->show(); + } + else + { + m_views.take(view->printer()); + m_views.insert(prname, view); + view->setPrinter(prname); + } +} + +void KJobViewerApp::reload() +{ + // trigger delayed refresh in all views + m_timer->delay(10); +} + +void KJobViewerApp::slotViewerDestroyed(KMJobViewer *view) +{ + if (view) + m_views.take(view->printer()); + if (m_views.count() == 0) + kapp->quit(); +} + +#include "kjobviewer.moc" diff --git a/kdeprint/kjobviewer/kjobviewer.desktop b/kdeprint/kjobviewer/kjobviewer.desktop new file mode 100644 index 000000000..965ed49bf --- /dev/null +++ b/kdeprint/kjobviewer/kjobviewer.desktop @@ -0,0 +1,92 @@ +[Desktop Entry] +Exec=kjobviewer --all --show %i %m +Icon=kjobviewer +Terminal=false +Type=Application +X-KDE-StartupNotify=true + +Name=KJobViewer +Name[bn]=কে-জব-ভিউয়ার +Name[csb]=Przezérnik pòlétów drëkera +Name[cy]=KGwelyddSwyddi +Name[ja]=K ジョブビューア +Name[nds]=Opgavenkieker +Name[ne]=KJob दर्शक +Name[pl]=Przeglądarka zadań drukowania +Name[pt_BR]=Trabalhos de Impressão +Name[ro]=Vizualizor lucrări de tipărit +Name[rw]=K-IkigaragazaUmurimo +Name[sk]=Prehliadač úloh +Name[sv]=K-jobbvisare +Name[ta]=கேபணி காட்சியாளன் +Name[tg]=Намоишгари корҳо +Name[vi]=Trình theo dõi Tác vụ In ấn +GenericName=Print Jobs +GenericName[af]=Drukker Werke +GenericName[be]=Заданні друку +GenericName[bg]=Задания за печат +GenericName[bn]=মুদ্রণ তালিকা +GenericName[bs]=Zadaci štampe +GenericName[ca]=Treballs d'impressió +GenericName[cs]=Tiskové úlohy +GenericName[csb]=Pòlétë drëkera +GenericName[cy]=Swyddi Argraffu +GenericName[da]=Udskriv job +GenericName[de]=Druckaufträge +GenericName[el]=Εργασίες εκτύπωσης +GenericName[eo]=Printtaskoj +GenericName[es]=Trabajos de impresión +GenericName[et]=Printeri tööd +GenericName[eu]=Inprimaketa lanak +GenericName[fa]=چاپ کارها +GenericName[fi]=Tulostustyöt +GenericName[fr]=Tâches d'impressions +GenericName[fy]=printtaken +GenericName[ga]=Jabanna Priontála +GenericName[gl]=Traballos de Impresión +GenericName[he]=עבודות הדפסה +GenericName[hr]=Zadaci ispisivanja +GenericName[hu]=Nyomtatási feladatok +GenericName[is]=Prentverk +GenericName[it]=Lavori di stampa +GenericName[ja]=印刷ジョブ +GenericName[ka]=ბეჭდვის დავალება +GenericName[kk]=Басып шығару тапсырмалары +GenericName[km]=ការងារបោះពុម្ព +GenericName[lt]=Spausdinimo užduotys +GenericName[mk]=Задачи за печатење +GenericName[ms]=Cetak Kerja +GenericName[nb]=Utskriftsjobber +GenericName[nds]=Druckopgaven +GenericName[ne]=मुद्रण कार्य +GenericName[nl]=Afdruktaken +GenericName[nn]=Utskriftsjobbar +GenericName[pa]=ਛਪਾਈ ਕੰਮ +GenericName[pl]=Zadania drukowania +GenericName[pt]=Tarefas de Impressão +GenericName[pt_BR]=Tarefas de Impressão +GenericName[ro]=Lucrări de tipărit +GenericName[ru]=Задания печати +GenericName[rw]=Gucapa Imirimo +GenericName[se]=Čálihanbarggut +GenericName[sk]=Tlačové úlohy +GenericName[sl]=Tiskalniška opravila +GenericName[sr]=Послови штампе +GenericName[sr@Latn]=Poslovi štampe +GenericName[sv]=Skrivarjobb +GenericName[ta]=அச்சுப் பணிகள் +GenericName[te]=ప్రచురణ పనులు +GenericName[tg]=Корҳои чопгар +GenericName[th]=งานพิมพ์ +GenericName[tr]=Yazdırma Görevleri +GenericName[tt]=Bastıru Eşläre +GenericName[uk]=Задачі друку +GenericName[uz]=Bosib chiqarish vazifalari +GenericName[uz@cyrillic]=Босиб чиқариш вазифалари +GenericName[vi]=Tác vụ In ấn +GenericName[wa]=Bouyes d' imprimaedje +GenericName[zh_CN]=打印任务 +GenericName[zh_TW]=列印工作 + +X-DCOP-ServiceType=Unique +Categories=Qt;KDE;Utility;X-KDE-Utilities-Peripherals; diff --git a/kdeprint/kjobviewer/kjobviewer.h b/kdeprint/kjobviewer/kjobviewer.h new file mode 100644 index 000000000..389f160a4 --- /dev/null +++ b/kdeprint/kjobviewer/kjobviewer.h @@ -0,0 +1,57 @@ +/* + * This file is part of the KDE libraries + * Copyright (c) 2001 Michael Goffioul <[email protected]> + * + * 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 KJOBVIEWER_H +#define KJOBVIEWER_H + +#include <kuniqueapplication.h> +#include <kdeprint/kpreloadobject.h> +#include <qdict.h> + +class KMJobViewer; +class KMTimer; +class JobTray; + +class KJobViewerApp : public KUniqueApplication, public KPReloadObject +{ + Q_OBJECT + friend class JobTray; +public: + KJobViewerApp(); + virtual ~KJobViewerApp(); + + virtual int newInstance(); + +protected: + void initialize(); + void reload(); + +protected slots: + void slotJobsShown(KMJobViewer*, bool); + void slotTimer(); + void slotPrinterChanged(KMJobViewer*, const QString&); + void slotViewerDestroyed(KMJobViewer*); + +private: + QDict<KMJobViewer> m_views; + JobTray *m_tray; + KMTimer *m_timer; +}; + +#endif diff --git a/kdeprint/kjobviewer/kjobviewerui.rc b/kdeprint/kjobviewer/kjobviewerui.rc new file mode 100644 index 000000000..83592dfc6 --- /dev/null +++ b/kdeprint/kjobviewer/kjobviewerui.rc @@ -0,0 +1,35 @@ +<!DOCTYPE kpartgui> +<kpartgui name="kjobviewer"> +<MenuBar> + <Menu name="jobs"><text>&Jobs</text> + <Action name="job_hold" /> + <Action name="job_resume" /> + <Separator /> + <Action name="job_remove" /> + <Action name="job_move" /> + <Separator /> + <Action name="job_restart" /> + </Menu> + <Menu name="filter"><text>F&ilter</text> + <Action name="filter_modify" /> + <Action name="view_completed" /> + <Action name="view_user_jobs" /> + </Menu> +</MenuBar> +<ToolBar name="mainToolBar"> + <Action name="job_hold" /> + <Action name="job_resume" /> + <Separator /> + <Action name="job_remove" /> + <Action name="job_move" /> + <Separator /> + <Action name="job_restart" /> + <Separator /> + <Action name="filter_modify" /> + <Action name="view_completed" /> + <Action name="view_user_jobs" /> + <Action name="view_username" /> + <Separator /> + <Action name="refresh" /> +</ToolBar> +</kpartgui> diff --git a/kdeprint/kjobviewer/main.cpp b/kdeprint/kjobviewer/main.cpp new file mode 100644 index 000000000..47176d743 --- /dev/null +++ b/kdeprint/kjobviewer/main.cpp @@ -0,0 +1,49 @@ +/* + * This file is part of the KDE libraries + * Copyright (c) 2001 Michael Goffioul <[email protected]> + * + * 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 <kapplication.h> +#include <kcmdlineargs.h> +#include <kaboutdata.h> + +#include "kjobviewer.h" +#include <klocale.h> +#include <stdlib.h> + +static KCmdLineOptions options[] = { + { "d <printer-name>", I18N_NOOP("The printer for which jobs are requested"), 0 }, + { "noshow", I18N_NOOP("Show job viewer at startup"), 0}, + { "all", I18N_NOOP("Show jobs for all printers"), 0}, + KCmdLineLastOption +}; + + +extern "C" int KDE_EXPORT kdemain(int argc, char *argv[]) +{ + KAboutData aboutData("kjobviewer",I18N_NOOP("KJobViewer"),"0.1",I18N_NOOP("A print job viewer"),KAboutData::License_GPL,"(c) 2001, Michael Goffioul", 0, "http://printing.kde.org"); + aboutData.addAuthor("Michael Goffioul",0,"[email protected]"); + KCmdLineArgs::init(argc,argv,&aboutData); + KCmdLineArgs::addCmdLineOptions(options); + KJobViewerApp::addCmdLineOptions(); + + if (!KJobViewerApp::start()) + exit(0); + + KJobViewerApp a; + return a.exec(); +} |