kmuimanager.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <config.h>
00021
00022 #include "kmuimanager.h"
00023 #include "kprintdialog.h"
00024 #include "kprintdialogpage.h"
00025 #include "kpcopiespage.h"
00026 #include "kprinter.h"
00027 #include "kprinterpropertydialog.h"
00028 #include "kmfactory.h"
00029 #include "kmmanager.h"
00030 #include "kmprinter.h"
00031 #include "kpdriverpage.h"
00032 #include "kpmarginpage.h"
00033 #include "kpqtpage.h"
00034 #include "kpfilterpage.h"
00035 #include "kpfileselectpage.h"
00036 #include "kxmlcommand.h"
00037 #include "kpposterpage.h"
00038
00039 #include <klocale.h>
00040 #include <kdebug.h>
00041
00042 KMUiManager::KMUiManager(QObject *parent, const char *name)
00043 : QObject(parent,name)
00044 {
00045 m_printdialogflags = KMUiManager::PrintDialogAll;
00046 m_printdialogpages.setAutoDelete(false);
00047 }
00048
00049 KMUiManager::~KMUiManager()
00050 {
00051 }
00052
00053 void KMUiManager::setupPropertyPages(KMPropertyPage*)
00054 {
00055 }
00056
00057 void KMUiManager::setupWizard(KMWizard*)
00058 {
00059 }
00060
00061 void KMUiManager::setupConfigDialog(KMConfigDialog*)
00062 {
00063 }
00064
00065 int KMUiManager::copyFlags(KPrinter *pr, bool usePlugin)
00066 {
00067 int fl(0), pcap(pluginPageCap());
00068 if (KMFactory::self()->settings()->pageSelection == KPrinter::ApplicationSide)
00069 {
00070 if (pr)
00071 {
00072 if (pr->currentPage() > 0) fl |= Current;
00073 if (pr->minPage() > 0 && pr->maxPage() > 0)
00074 fl |= (Range|PageSet|Order);
00075 }
00076
00077 if (usePlugin)
00078 fl |= (pcap & (Collate|NoAutoCollate));
00079 else
00080 fl |= NoAutoCollate;
00081 }
00082 else if (usePlugin)
00083
00084
00085 fl = pageCap();
00086 else
00087
00088
00089
00090 fl = systemPageCap() | NoAutoCollate;
00091 return fl;
00092 }
00093
00094 int KMUiManager::dialogFlags()
00095 {
00096 int f = m_printdialogflags;
00097 int appf = KMFactory::self()->settings()->application;
00098 if (appf != KPrinter::Dialog)
00099 {
00100 f &= ~(KMUiManager::Preview);
00101 if ( appf == KPrinter::StandAlonePersistent)
00102 f |= KMUiManager::Persistent;
00103 }
00104 return f;
00105 }
00106
00107 void KMUiManager::setupPrintDialog(KPrintDialog *dlg)
00108 {
00109
00110 int f = dialogFlags();
00111 dlg->setFlags(f);
00112
00113
00114 int stdpages = KMFactory::self()->settings()->standardDialogPages;
00115 if (stdpages & KPrinter::CopiesPage)
00116 m_printdialogpages.prepend(new KPCopiesPage(dlg->printer(), 0, "CopiesPage"));
00117 if (stdpages & KPrinter::FilesPage)
00118 m_printdialogpages.prepend(new KPFileSelectPage(0, "FileSelectPage"));
00119
00120
00121 setupPrintDialogPages(&m_printdialogpages);
00122
00123 dlg->setDialogPages(&m_printdialogpages);
00124 }
00125
00126 void KMUiManager::setupPropertyDialog(KPrinterPropertyDialog *dlg)
00127 {
00128 if (dlg->printer())
00129 {
00130 DrMain *driver = KMManager::self()->loadDriver(dlg->printer(), false);
00131 dlg->setDriver(driver);
00132
00133 if (dlg->printer()->isSpecial())
00134 {
00135 dlg->addPage(new KPQtPage(dlg,"QtPage"));
00136
00137 }
00138 else
00139 {
00140
00141 setupPrinterPropertyDialog(dlg);
00142 }
00143
00144
00145 KPrinter *prt(0);
00146 if (dlg->parent() && dlg->parent()->isA("KPrintDialog"))
00147 prt = static_cast<KPrintDialog*>(dlg->parent())->printer();
00148
00149
00150 if ( ( prt && !prt->fullPage() && prt->applicationType() == KPrinter::Dialog )
00151 || prt->applicationType() < 0 )
00152 dlg->addPage(new KPMarginPage(prt, driver, dlg, "MarginPage"));
00153
00154
00155 if (driver)
00156 dlg->addPage(new KPDriverPage(dlg->printer(),driver,dlg,"DriverPage"));
00157
00158 dlg->setCaption(i18n("Configuration of %1").arg(dlg->printer()->name()));
00159 if ( KXmlCommandManager::self()->checkCommand( "poster", KXmlCommandManager::None, KXmlCommandManager::None ) )
00160 dlg->addPage( new KPPosterPage( dlg, "PosterPage" ) );
00161 dlg->addPage(new KPFilterPage(dlg,"FilterPage"));
00162 dlg->resize(100,100);
00163 }
00164 }
00165
00166 void KMUiManager::setupPrinterPropertyDialog(KPrinterPropertyDialog *dlg)
00167 {
00168 if (KMFactory::self()->settings()->application == KPrinter::Dialog
00169 || KMFactory::self()->settings()->application < 0 )
00170 dlg->addPage(new KPQtPage(dlg,"QtPage"));
00171 }
00172
00173 int KMUiManager::pageCap()
00174 {
00175 int val = systemPageCap();
00176 val |= pluginPageCap();
00177 return val;
00178 }
00179
00180 int KMUiManager::systemPageCap()
00181 {
00182 int val(0);
00183 if (KXmlCommandManager::self()->checkCommand("psselect"))
00184 val |= KMUiManager::PSSelect;
00185 return val;
00186 }
00187
00188 int KMUiManager::pluginPageCap()
00189 {
00190 return 0;
00191 }
00192
00193 void KMUiManager::setupPrintDialogPages(QPtrList<KPrintDialogPage>*)
00194 {
00195 }
00196
00197 void KMUiManager::setupJobViewer(QListView*)
00198 {
00199 }
00200
00201 #include "kmuimanager.moc"
|