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

tdeprint

kmconfiggeneral.cpp

00001 /*
00002  *  This file is part of the KDE libraries
00003  *  Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
00004  *
00005  *  This library is free software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Library General Public
00007  *  License version 2 as published by the Free Software Foundation.
00008  *
00009  *  This library is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  *  Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Library General Public License
00015  *  along with this library; see the file COPYING.LIB.  If not, write to
00016  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  *  Boston, MA 02110-1301, USA.
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     //layout
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"

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.7.1
This website is maintained by Timothy Pearson.