• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeprint
 

tdeprint

  • tdeprint
kprintaction.cpp
1/*
2 * This file is part of the KDE libraries
3 * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License version 2 as published by the Free Software Foundation.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 **/
19
20#include "kprintaction.h"
21
22#include <kprinter.h>
23#include <tdeprint/kmmanager.h>
24#include <kiconloader.h>
25#include <tdepopupmenu.h>
26#include <tdelocale.h>
27
28class KPrintAction::KPrintActionPrivate
29{
30public:
31 KPrintActionPrivate()
32 {
33 type = All;
34 parentWidget = 0;
35 }
36
37 PrinterType type;
38 TQStringList printers;
39 TQWidget *parentWidget;
40};
41
42KPrintAction::KPrintAction(const TQString& text, PrinterType type, TQWidget *parentWidget, TQObject *parent, const char *name)
43: TDEActionMenu(text, parent, name)
44{
45 d = new KPrintActionPrivate();
46 initialize(type, parentWidget);
47}
48
49KPrintAction::KPrintAction(const TQString& text, const TQIconSet& icon, PrinterType type, TQWidget *parentWidget, TQObject *parent, const char *name)
50: TDEActionMenu(text, icon, parent, name)
51{
52 d = new KPrintActionPrivate();
53 initialize(type, parentWidget);
54}
55
56KPrintAction::KPrintAction(const TQString& text, const TQString& icon, PrinterType type, TQWidget *parentWidget, TQObject *parent, const char *name)
57: TDEActionMenu(text, icon, parent, name)
58{
59 d = new KPrintActionPrivate();
60 initialize(type, parentWidget);
61}
62
63KPrintAction::~KPrintAction()
64{
65 delete d;
66}
67
68void KPrintAction::initialize(PrinterType type, TQWidget *parentWidget)
69{
70 connect(popupMenu(), TQ_SIGNAL(aboutToShow()), TQ_SLOT(slotAboutToShow()));
71 connect(popupMenu(), TQ_SIGNAL(activated(int)), TQ_SLOT(slotActivated(int)));
72
73 d->type = type;
74 d->parentWidget = parentWidget;
75}
76
77void KPrintAction::slotAboutToShow()
78{
79 popupMenu()->clear();
80 d->printers.clear();
81 TQPtrList<KMPrinter> *prts = KMManager::self()->printerList();
82 if (prts && !prts->isEmpty())
83 {
84 TQPtrListIterator<KMPrinter> it(*prts);
85 bool first(false);
86 int ID(0);
87 for (; it.current(); ++it)
88 {
89 if (d->type == All || (d->type == Specials && it.current()->isSpecial()) || (d->type == Regular && !it.current()->isSpecial()))
90 {
91 if (d->type == All && !first && it.current()->isSpecial())
92 {
93 if (popupMenu()->count() > 0)
94 popupMenu()->insertSeparator();
95 first = true;
96 }
97 popupMenu()->insertItem(SmallIconSet(it.current()->pixmap()), it.current()->name(), ID++);
98 d->printers.append(it.current()->name());
99 }
100 }
101 }
102}
103
104void KPrintAction::slotActivated(int ID)
105{
106 KPrinter printer(false);
107 KMPrinter *mprt = KMManager::self()->findPrinter(d->printers[ID]);
108 if (mprt && mprt->autoConfigure(&printer, d->parentWidget))
109 {
110 // emit the signal
111 emit print(&printer);
112 }
113}
114
115KPrintAction* KPrintAction::exportAll(TQWidget *parentWidget, TQObject *parent, const char *name)
116{
117 return new KPrintAction(i18n("&Export..."), All, parentWidget, parent, (name ? name : "export_all"));
118}
119
120KPrintAction* KPrintAction::exportRegular(TQWidget *parentWidget, TQObject *parent, const char *name)
121{
122 return new KPrintAction(i18n("&Export..."), Regular, parentWidget, parent, (name ? name : "export_regular"));
123}
124
125KPrintAction* KPrintAction::exportSpecial(TQWidget *parentWidget, TQObject *parent, const char *name)
126{
127 return new KPrintAction(i18n("&Export..."), Specials, parentWidget, parent, (name ? name : "export_special"));
128}
129
130#include "kprintaction.moc"
KPrinter
This class is the main interface to access the TDE print framework.
Definition: kprinter.h:89

tdeprint

Skip menu "tdeprint"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

tdeprint

Skip menu "tdeprint"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeprint by doxygen 1.9.4
This website is maintained by Timothy Pearson.