20 #include "kmconfiggeneral.h"
23 #include <tqgroupbox.h>
24 #include <tqcheckbox.h>
26 #include <tqwhatsthis.h>
28 #include <kpushbutton.h>
29 #include <tdelocale.h>
30 #include <kurlrequester.h>
32 #include <kmimemagic.h>
33 #include <tdeconfig.h>
34 #include <knuminput.h>
35 #include <tdemessagebox.h>
37 #include <klineedit.h>
41 KMConfigGeneral::KMConfigGeneral(TQWidget *parent)
42 : KMConfigPage(parent,
"ConfigTimer")
44 setPageName(i18n(
"General"));
45 setPageHeader(i18n(
"General Settings"));
46 setPagePixmap(
"document-print");
48 TQGroupBox *m_timerbox =
new TQGroupBox(0, TQt::Vertical, i18n(
"Refresh Interval"),
this);
49 m_timer =
new KIntNumInput(m_timerbox,
"Timer");
50 m_timer->setRange(0,30);
51 m_timer->setSuffix( i18n(
" sec" ) );
52 m_timer->setSpecialValueText(i18n(
"Disabled"));
53 TQWhatsThis::add(m_timer, i18n(
"This time setting controls the refresh rate of various "
54 "<b>TDE Print</b> components like the print manager "
55 "and the job viewer."));
57 TQGroupBox *m_testpagebox =
new TQGroupBox(0, TQt::Vertical, i18n(
"Test Page"),
this);
58 m_defaulttestpage =
new TQCheckBox(i18n(
"&Specify personal test page"), m_testpagebox,
"TestPageCheck");
59 m_testpage =
new KURLRequester(m_testpagebox,
"TestPage");
60 m_preview =
new KPushButton(KGuiItem(i18n(
"Preview..."),
"filefind"), m_testpagebox);
61 connect(m_defaulttestpage,TQ_SIGNAL(toggled(
bool)),m_testpage,TQ_SLOT(setEnabled(
bool)));
62 connect(m_defaulttestpage,TQ_SIGNAL(toggled(
bool)),
this,TQ_SLOT(setEnabledPreviewButton(
bool)));
63 connect(m_preview,TQ_SIGNAL(clicked()),TQ_SLOT(slotTestPagePreview()));
64 connect(m_testpage->lineEdit(),TQ_SIGNAL(textChanged (
const TQString & )),
this,TQ_SLOT(testPageChanged(
const TQString & )));
65 m_testpage->setDisabled(
true);
66 m_preview->setDisabled(
true);
67 m_defaulttestpage->setCursor(KCursor::handCursor());
69 TQGroupBox *m_statusbox =
new TQGroupBox(0, TQt::Vertical, i18n(
"Miscellaneous"),
this);
70 m_statusmsg =
new TQCheckBox(i18n(
"Sho&w printing status message box"), m_statusbox);
71 m_uselast =
new TQCheckBox(i18n(
"De&faults to the last printer used in the application"), m_statusbox);
74 TQVBoxLayout *lay0 =
new TQVBoxLayout(
this, 0, KDialog::spacingHint());
75 lay0->addWidget(m_timerbox);
76 lay0->addWidget(m_testpagebox);
77 lay0->addWidget(m_statusbox);
79 TQVBoxLayout *lay1 =
new TQVBoxLayout(m_timerbox->layout(),
80 KDialog::spacingHint());
81 lay1->addWidget(m_timer);
82 TQVBoxLayout *lay2 =
new TQVBoxLayout(m_testpagebox->layout(),
83 KDialog::spacingHint());
84 TQHBoxLayout *lay3 =
new TQHBoxLayout(0, 0, 0);
85 lay2->addWidget(m_defaulttestpage);
86 lay2->addWidget(m_testpage);
87 lay2->addLayout(lay3);
89 lay3->addWidget(m_preview);
90 TQVBoxLayout *lay4 =
new TQVBoxLayout(m_statusbox->layout(),
91 KDialog::spacingHint());
92 lay4->addWidget(m_statusmsg);
93 lay4->addWidget(m_uselast);
94 m_preview->setEnabled( !m_testpage->url().isEmpty());
97 void KMConfigGeneral::testPageChanged(
const TQString &test )
99 m_preview->setEnabled( !test.isEmpty());
102 void KMConfigGeneral::setEnabledPreviewButton(
bool b)
104 m_preview->setEnabled(!m_testpage->url().isEmpty() && b);
107 void KMConfigGeneral::loadConfig(TDEConfig *conf)
109 conf->setGroup(
"General");
110 m_timer->setValue(conf->readNumEntry(
"TimerDelay",5));
111 TQString tpage = conf->readPathEntry(
"TestPage");
112 if (!tpage.isEmpty())
114 m_defaulttestpage->setChecked(
true);
115 m_testpage->setURL(tpage);
117 m_statusmsg->setChecked(conf->readBoolEntry(
"ShowStatusMsg",
true));
118 m_uselast->setChecked(conf->readBoolEntry(
"UseLast",
true));
121 void KMConfigGeneral::saveConfig(TDEConfig *conf)
123 conf->setGroup(
"General");
124 conf->writeEntry(
"TimerDelay",m_timer->value());
125 conf->writePathEntry(
"TestPage",(m_defaulttestpage->isChecked() ? m_testpage->url() : TQString::null));
126 if (m_defaulttestpage->isChecked() && KMimeMagic::self()->findFileType(m_testpage->url())->mimeType() !=
"application/postscript")
127 KMessageBox::sorry(
this, i18n(
"The selected test page is not a PostScript file. You may not "
128 "be able to test your printer anymore."));
129 conf->writeEntry(
"ShowStatusMsg", m_statusmsg->isChecked());
130 conf->writeEntry(
"UseLast", m_uselast->isChecked());
133 void KMConfigGeneral::slotTestPagePreview()
135 TQString tpage = m_testpage->url();
137 KMessageBox::error(
this, i18n(
"Empty file name."));
139 KRun::runURL(KURL( tpage ), KMimeMagic::self()->findFileType(tpage)->mimeType());
142 #include "kmconfiggeneral.moc"