00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "kmconfiggeneral.h"
00021
00022 #include <tqlayout.h>
00023 #include <tqgroupbox.h>
00024 #include <tqcheckbox.h>
00025 #include <tqlabel.h>
00026 #include <tqwhatsthis.h>
00027
00028 #include <kpushbutton.h>
00029 #include <tdelocale.h>
00030 #include <kurlrequester.h>
00031 #include <krun.h>
00032 #include <kmimemagic.h>
00033 #include <tdeconfig.h>
00034 #include <knuminput.h>
00035 #include <tdemessagebox.h>
00036 #include <kcursor.h>
00037 #include <klineedit.h>
00038 #include <kguiitem.h>
00039 #include <kdialog.h>
00040
00041 KMConfigGeneral::KMConfigGeneral(TQWidget *parent)
00042 : KMConfigPage(parent,"ConfigTimer")
00043 {
00044 setPageName(i18n("General"));
00045 setPageHeader(i18n("General Settings"));
00046 setPagePixmap("document-print");
00047
00048 TQGroupBox *m_timerbox = new TQGroupBox(0, Qt::Vertical, i18n("Refresh Interval"), this);
00049 m_timer = new KIntNumInput(m_timerbox,"Timer");
00050 m_timer->setRange(0,30);
00051 m_timer->setSuffix( i18n( " sec" ) );
00052 m_timer->setSpecialValueText(i18n("Disabled"));
00053 TQWhatsThis::add(m_timer, i18n("This time setting controls the refresh rate of various "
00054 "<b>TDE Print</b> components like the print manager "
00055 "and the job viewer."));
00056
00057 TQGroupBox *m_testpagebox = new TQGroupBox(0, Qt::Vertical, i18n("Test Page"), this);
00058 m_defaulttestpage = new TQCheckBox(i18n("&Specify personal test page"), m_testpagebox, "TestPageCheck");
00059 m_testpage = new KURLRequester(m_testpagebox,"TestPage");
00060 m_preview = new KPushButton(KGuiItem(i18n("Preview..."), "filefind"), m_testpagebox);
00061 connect(m_defaulttestpage,TQT_SIGNAL(toggled(bool)),m_testpage,TQT_SLOT(setEnabled(bool)));
00062 connect(m_defaulttestpage,TQT_SIGNAL(toggled(bool)),this,TQT_SLOT(setEnabledPreviewButton(bool)));
00063 connect(m_preview,TQT_SIGNAL(clicked()),TQT_SLOT(slotTestPagePreview()));
00064 connect(m_testpage->lineEdit(),TQT_SIGNAL(textChanged ( const TQString & )),this,TQT_SLOT(testPageChanged(const TQString & )));
00065 m_testpage->setDisabled(true);
00066 m_preview->setDisabled(true);
00067 m_defaulttestpage->setCursor(KCursor::handCursor());
00068
00069 TQGroupBox *m_statusbox = new TQGroupBox(0, Qt::Vertical, i18n("Miscellaneous"), this);
00070 m_statusmsg = new TQCheckBox(i18n("Sho&w printing status message box"), m_statusbox);
00071 m_uselast = new TQCheckBox(i18n("De&faults to the last printer used in the application"), m_statusbox);
00072
00073
00074 TQVBoxLayout *lay0 = new TQVBoxLayout(this, 0, KDialog::spacingHint());
00075 lay0->addWidget(m_timerbox);
00076 lay0->addWidget(m_testpagebox);
00077 lay0->addWidget(m_statusbox);
00078 lay0->addStretch(1);
00079 TQVBoxLayout *lay1 = new TQVBoxLayout(TQT_TQLAYOUT(m_timerbox->layout()),
00080 KDialog::spacingHint());
00081 lay1->addWidget(m_timer);
00082 TQVBoxLayout *lay2 = new TQVBoxLayout(TQT_TQLAYOUT(m_testpagebox->layout()),
00083 KDialog::spacingHint());
00084 TQHBoxLayout *lay3 = new TQHBoxLayout(0, 0, 0);
00085 lay2->addWidget(m_defaulttestpage);
00086 lay2->addWidget(m_testpage);
00087 lay2->addLayout(lay3);
00088 lay3->addStretch(1);
00089 lay3->addWidget(m_preview);
00090 TQVBoxLayout *lay4 = new TQVBoxLayout(TQT_TQLAYOUT(m_statusbox->layout()),
00091 KDialog::spacingHint());
00092 lay4->addWidget(m_statusmsg);
00093 lay4->addWidget(m_uselast);
00094 m_preview->setEnabled( !m_testpage->url().isEmpty());
00095 }
00096
00097 void KMConfigGeneral::testPageChanged(const TQString &test )
00098 {
00099 m_preview->setEnabled( !test.isEmpty());
00100 }
00101
00102 void KMConfigGeneral::setEnabledPreviewButton(bool b)
00103 {
00104 m_preview->setEnabled(!m_testpage->url().isEmpty() && b);
00105 }
00106
00107 void KMConfigGeneral::loadConfig(TDEConfig *conf)
00108 {
00109 conf->setGroup("General");
00110 m_timer->setValue(conf->readNumEntry("TimerDelay",5));
00111 TQString tpage = conf->readPathEntry("TestPage");
00112 if (!tpage.isEmpty())
00113 {
00114 m_defaulttestpage->setChecked(true);
00115 m_testpage->setURL(tpage);
00116 }
00117 m_statusmsg->setChecked(conf->readBoolEntry("ShowStatusMsg", true));
00118 m_uselast->setChecked(conf->readBoolEntry("UseLast", true));
00119 }
00120
00121 void KMConfigGeneral::saveConfig(TDEConfig *conf)
00122 {
00123 conf->setGroup("General");
00124 conf->writeEntry("TimerDelay",m_timer->value());
00125 conf->writePathEntry("TestPage",(m_defaulttestpage->isChecked() ? m_testpage->url() : TQString::null));
00126 if (m_defaulttestpage->isChecked() && KMimeMagic::self()->findFileType(m_testpage->url())->mimeType() != "application/postscript")
00127 KMessageBox::sorry(this, i18n("The selected test page is not a PostScript file. You may not "
00128 "be able to test your printer anymore."));
00129 conf->writeEntry("ShowStatusMsg", m_statusmsg->isChecked());
00130 conf->writeEntry("UseLast", m_uselast->isChecked());
00131 }
00132
00133 void KMConfigGeneral::slotTestPagePreview()
00134 {
00135 TQString tpage = m_testpage->url();
00136 if (tpage.isEmpty())
00137 KMessageBox::error(this, i18n("Empty file name."));
00138 else
00139 KRun::runURL(KURL( tpage ), KMimeMagic::self()->findFileType(tpage)->mimeType());
00140 }
00141
00142 #include "kmconfiggeneral.moc"