kplato

kptconfigdialog.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 2004 Dag Andersen <danders@get2net.dk>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; 
00007    version 2 of the License.
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 "kptconfigdialog.h"
00021 
00022 #include "kpttaskdefaultpanel.h"
00023 //#include "kptconfigbehaviorpanel.h"
00024 
00025 #include "kptconfig.h"
00026 #include "kptproject.h"
00027 #include "kpttask.h"
00028 #include "kptcalendar.h"
00029 
00030 #include <kiconloader.h>
00031 #include <klocale.h>
00032 #include <kcommand.h>
00033 
00034 #include <qvbox.h>
00035 
00036 #include <kdebug.h>
00037 
00038 namespace KPlato
00039 {
00040 
00041 // little helper stolen from kmail/kword
00042 static inline QPixmap loadIcon( const char * name ) {
00043   return KGlobal::instance()->iconLoader()
00044     ->loadIcon( QString::fromLatin1(name), KIcon::NoGroup, KIcon::SizeMedium );
00045 }
00046 
00047 
00048 ConfigDialog::ConfigDialog(Config &config, Project &project, QWidget *parent, const char *)
00049     : KDialogBase(KDialogBase::IconList, i18n("Configure KPlato"),
00050                   KDialogBase::Ok | KDialogBase::Apply | KDialogBase::Cancel| KDialogBase::Default,
00051                   KDialogBase::Ok, parent),
00052       m_config(config)
00053 {
00054 
00055 /*    QVBox *page = addVBoxPage(i18n("Behavior"), i18n("Behavior"), loadIcon("misc"));
00056     m_behaviorPage = new ConfigBehaviorPanel(config.behavior(), page);*/
00057     
00058     QVBox *page = addVBoxPage(i18n("Task Defaults"), i18n("Task Defaults"), loadIcon("misc"));
00059     m_taskDefaultPage = new TaskDefaultPanel(config.taskDefaults(), project.standardWorktime(), page);
00060     
00061     enableButtonOK(false);
00062     enableButtonApply(false);
00063     
00064 //    connect(m_behaviorPage, SIGNAL(changed()), SLOT(slotChanged()));
00065     connect(m_taskDefaultPage, SIGNAL(changed()), SLOT(slotChanged()));
00066 }
00067 
00068 
00069 void ConfigDialog::slotApply() {
00070     if (!m_taskDefaultPage->ok())
00071         return;
00072 /*    if (!m_behaviorPage->ok())
00073         return;*/
00074     KCommand *cmd = m_taskDefaultPage->buildCommand(0);
00075     if (cmd)
00076         cmd->execute();
00077 
00078 //    m_behaviorPage->apply();
00079 }
00080 
00081 void ConfigDialog::slotOk() {
00082     slotApply();
00083     accept();
00084 }
00085 
00086 void ConfigDialog::slotDefault() {
00087     kdDebug()<<k_funcinfo<<endl;
00088     m_taskDefaultPage->setStartValues(m_config.taskDefaults());
00089 //    m_behaviorPage->setStartValues();
00090     
00091     enableButtonOK(false);
00092     enableButtonApply(false);
00093 }
00094 
00095 void ConfigDialog::slotChanged() {
00096     enableButtonOK(true);
00097     enableButtonApply(true);
00098 }
00099 
00100 }  //KPlato namespace
00101 
00102 #include "kptconfigdialog.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys