• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

knotes

knoteconfigdlg.cpp

Go to the documentation of this file.
00001 /*******************************************************************
00002  KNotes -- Notes for the KDE project
00003 
00004  Copyright (c) 1997-2005, The KNotes Developers
00005 
00006  This program is free software; you can redistribute it and/or
00007  modify it under the terms of the GNU General Public License
00008  as published by the Free Software Foundation; either version 2
00009  of the License, or (at your option) any later version.
00010 
00011  This program is distributed in the hope that it will be useful,
00012  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  GNU General Public License for more details.
00015 
00016  You should have received a copy of the GNU General Public License
00017  along with this program; if not, write to the Free Software
00018  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019 *******************************************************************/
00020 
00021 #include <QCheckBox>
00022 #include <QComboBox>
00023 #include <QGridLayout>
00024 #include <QGroupBox>
00025 #include <QHBoxLayout>
00026 #include <QLabel>
00027 #include <QTabWidget>
00028 #include <QVBoxLayout>
00029 
00030 #include <kapplication.h>
00031 #include <kcolorbutton.h>
00032 #include <kconfig.h>
00033 #include <kfontrequester.h>
00034 #include <kiconloader.h>
00035 #include <klineedit.h>
00036 #include <klocale.h>
00037 #include <knuminput.h>
00038 #include <kwindowsystem.h>
00039 
00040 #include "knote.h"
00041 #include "knoteconfigdlg.h"
00042 #include "knotesglobalconfig.h"
00043 #include "version.h"
00044 
00045 
00046 KNoteConfigDlg::KNoteConfigDlg( KNoteConfig *config, const QString &title,
00047                                 QWidget *parent, const QString &name )
00048   : KConfigDialog( parent, name, config ? config : KNotesGlobalConfig::self() )
00049 {
00050   setFaceType( KPageDialog::List );
00051   setButtons( config ? Default | Ok | Apply | Cancel : Default | Ok | Cancel );
00052   setDefaultButton( Ok );
00053   
00054   setCaption( title );
00055 #ifdef Q_WS_X11
00056   KWindowSystem::setIcons( winId(),
00057                            qApp->windowIcon().pixmap(
00058                              IconSize( KIconLoader::Desktop ),
00059                              IconSize( KIconLoader::Desktop ) ),
00060                            qApp->windowIcon().pixmap(
00061                              IconSize( KIconLoader::Small ),
00062                              IconSize( KIconLoader::Small ) ) );
00063 #endif
00064   //setIconListAllVisible( true );
00065   showButtonSeparator( true );
00066   
00067   if ( config ) {
00068     addPage( makeDisplayPage( false ), i18n( "Display" ), "knotes",
00069              i18n( "Display Settings" ) );
00070     addPage( makeEditorPage( false ), i18n( "Editor" ), "accessories-text-editor",
00071              i18n( "Editor Settings" ) );
00072   } else {
00073     config = KNotesGlobalConfig::self();
00074     addPage( makeDefaultsPage(), i18n( "Defaults" ), "knotes",
00075              i18n( "Default Settings for New Notes" ) );
00076     addPage( makeActionsPage(), i18n( "Actions" ), "preferences-other",
00077              i18n( "Action Settings" ) );
00078     addPage( makeNetworkPage(), i18n( "Network" ), "network-wired",
00079              i18n( "Network Settings" ) );
00080     addPage( makeStylePage(), i18n( "Style" ), "preferences-desktop-theme",
00081              i18n( "Style Settings" ) );
00082   }
00083   
00084   config->setVersion( KNOTES_VERSION );
00085 }
00086 
00087 KNoteConfigDlg::~KNoteConfigDlg()
00088 {
00089 }
00090 
00091 void KNoteConfigDlg::slotUpdateCaption()
00092 {
00093   KNote *note = ::qobject_cast<KNote *>( sender() );
00094   if ( note ) {
00095     setCaption( note->name() );
00096   }
00097 }
00098 
00099 QWidget *KNoteConfigDlg::makeDisplayPage( bool defaults )
00100 {
00101   QWidget *displayPage = new QWidget();
00102   QGridLayout *layout = new QGridLayout( displayPage );
00103   layout->setSpacing( spacingHint() );
00104   layout->setMargin( defaults ? marginHint() : 0 );
00105   
00106   QLabel *label_FgColor = new QLabel( i18n( "&Text color:" ), displayPage );
00107   label_FgColor->setObjectName( "label_FgColor" );
00108   layout->addWidget( label_FgColor, 0, 0 );
00109   
00110   KColorButton *kcfg_FgColor = new KColorButton( displayPage );
00111   kcfg_FgColor->setObjectName( "kcfg_FgColor" );
00112   label_FgColor->setBuddy( kcfg_FgColor );
00113   layout->addWidget( kcfg_FgColor, 0, 1 );
00114   
00115   QLabel *label_BgColor = new QLabel( i18n( "&Background color:" ),
00116                                       displayPage );
00117   label_BgColor->setObjectName( "label_BgColor" );
00118   layout->addWidget( label_BgColor, 1, 0 );
00119   
00120   KColorButton *kcfg_BgColor = new KColorButton( displayPage );
00121   kcfg_BgColor->setObjectName( "kcfg_BgColor" );
00122   label_BgColor->setBuddy( kcfg_BgColor );
00123   layout->addWidget( kcfg_BgColor, 1, 1 );
00124   
00125   QCheckBox *kcfg_ShowInTaskbar = 
00126       new QCheckBox( i18n( "&Show note in taskbar" ), displayPage );
00127   kcfg_ShowInTaskbar->setObjectName( "kcfg_ShowInTaskbar" );
00128   
00129   QCheckBox *kcfg_RememberDesktop = 
00130       new QCheckBox( i18n( "&Remember desktop" ), displayPage );
00131   kcfg_RememberDesktop->setObjectName( "kcfg_RememberDesktop" );
00132   
00133   if ( defaults ) {
00134     QLabel *label_Width = new QLabel( i18n( "Default &width:" ), displayPage );
00135   
00136     label_Width->setObjectName( "label_Width" );
00137     layout->addWidget( label_Width, 2, 0 );
00138     
00139     KIntNumInput *kcfg_Width = new KIntNumInput( displayPage );
00140     kcfg_Width->setObjectName( "kcfg_Width" );
00141     label_Width->setBuddy( kcfg_Width );
00142     kcfg_Width->setRange( 50, 2000, 10 );
00143     kcfg_Width->setSliderEnabled( false );
00144     layout->addWidget( kcfg_Width, 2, 1 );
00145     
00146     QLabel *label_Height = new QLabel( i18n( "Default &height:" ),
00147                                        displayPage );
00148     label_Height->setObjectName( "label_Height" );
00149     layout->addWidget( label_Height, 3, 0 );
00150     
00151     KIntNumInput *kcfg_Height = new KIntNumInput( displayPage );
00152     kcfg_Height->setObjectName( "kcfg_Height" );
00153     kcfg_Height->setRange( 50, 2000, 10 );
00154     kcfg_Height->setSliderEnabled( false );
00155     label_Height->setBuddy( kcfg_Height );
00156     layout->addWidget( kcfg_Height, 3, 1 );
00157     
00158     layout->addWidget( kcfg_ShowInTaskbar, 4, 0 );
00159     layout->addWidget( kcfg_RememberDesktop, 5, 0 );
00160   } else {
00161     layout->addWidget( kcfg_ShowInTaskbar, 2, 0 );
00162     layout->addWidget( kcfg_RememberDesktop, 3, 0 );
00163   }
00164   return displayPage;
00165 }
00166 
00167 QWidget *KNoteConfigDlg::makeEditorPage( bool defaults )
00168 {
00169   QWidget *editorPage = new QWidget();
00170   QGridLayout *layout = new QGridLayout( editorPage );
00171   layout->setSpacing( spacingHint() );
00172   layout->setMargin( defaults ? marginHint() : 0 );
00173   
00174   QLabel *label_TabSize = new QLabel( i18n( "&Tab size:" ), editorPage );
00175   label_TabSize->setObjectName( "label_TabSize" );
00176   layout->addWidget( label_TabSize, 0, 0, 1, 2 );
00177   
00178   KIntNumInput *kcfg_TabSize = new KIntNumInput( editorPage );
00179   kcfg_TabSize->setObjectName( "kcfg_TabSize" );
00180   kcfg_TabSize->setRange( 0, 40 );
00181   kcfg_TabSize->setSliderEnabled( false );
00182   label_TabSize->setBuddy( kcfg_TabSize );
00183   layout->addWidget( kcfg_TabSize, 0, 2 );
00184   
00185   QCheckBox *kcfg_AutoIndent = new QCheckBox( i18n( "Auto &indent" ),
00186                                               editorPage );
00187   kcfg_AutoIndent->setObjectName( "kcfg_AutoIndent" );
00188   layout->addWidget( kcfg_AutoIndent, 1, 0, 1, 2 );
00189   
00190   QCheckBox *kcfg_RichText = new QCheckBox( i18n( "&Rich text" ), editorPage );
00191   kcfg_RichText->setObjectName( "kcfg_RichText" );
00192   layout->addWidget( kcfg_RichText, 1, 2 );
00193   
00194   QLabel *label_Font = new QLabel( i18n( "Text font:" ), editorPage );
00195   label_Font->setObjectName( "label_Font" );
00196   layout->addWidget( label_Font, 3, 0 );
00197   
00198   KFontRequester *kcfg_Font = new KFontRequester( editorPage );
00199   kcfg_Font->setObjectName( "kcfg_Font" );
00200   kcfg_Font->setSizePolicy( QSizePolicy( QSizePolicy::Minimum,
00201                                          QSizePolicy::Fixed ) );
00202   layout->addWidget( kcfg_Font, 3, 1, 1, 2 );
00203   
00204   QLabel *label_TitleFont = new QLabel( i18n( "Title font:" ), editorPage );
00205   label_TitleFont->setObjectName( "label_TitleFont" );
00206   layout->addWidget( label_TitleFont, 2, 0 );
00207   
00208   KFontRequester *kcfg_TitleFont = new KFontRequester( editorPage );
00209   kcfg_TitleFont->setObjectName( "kcfg_TitleFont" );
00210   kcfg_TitleFont->setSizePolicy( QSizePolicy( QSizePolicy::Minimum,
00211                                  QSizePolicy::Fixed ) );
00212   layout->addWidget( kcfg_TitleFont, 2, 1, 1, 2 );
00213   
00214   return editorPage;
00215 }
00216 
00217 QWidget *KNoteConfigDlg::makeDefaultsPage()
00218 {
00219   QTabWidget *defaultsPage = new QTabWidget();
00220   defaultsPage->addTab( makeDisplayPage( true ), KIcon( "knotes" ),
00221                         i18n( "Displa&y" ) );
00222   defaultsPage->addTab( makeEditorPage( true ), KIcon( "document-properties" ),
00223                         i18n( "&Editor" ) );
00224   
00225   return defaultsPage;
00226 }
00227 
00228 QWidget *KNoteConfigDlg::makeActionsPage()
00229 {
00230   QWidget *actionsPage = new QWidget();
00231   QGridLayout *layout = new QGridLayout( actionsPage );
00232   layout->setSpacing( spacingHint() );
00233   layout->setMargin( 0 );
00234   
00235   QLabel *label_MailAction = new QLabel( i18n( "&Mail action:" ), actionsPage );
00236   label_MailAction->setObjectName( "label_MailAction" );
00237   layout->addWidget( label_MailAction, 0, 0 );
00238   
00239   KLineEdit *kcfg_MailAction = new KLineEdit( actionsPage );
00240   kcfg_MailAction->setObjectName( "kcfg_MailAction" );
00241   label_MailAction->setBuddy( kcfg_MailAction );
00242   layout->addWidget( kcfg_MailAction, 0, 1 );
00243   
00244   return actionsPage;
00245 }
00246 
00247 QWidget *KNoteConfigDlg::makeNetworkPage()
00248 {
00249   QWidget *networkPage = new QWidget();
00250   QVBoxLayout *layout = new QVBoxLayout;
00251   layout->setSpacing( spacingHint() );
00252   layout->setMargin( 0 );
00253   
00254   QGroupBox *incoming = new QGroupBox( i18n( "Incoming Notes" ) );
00255   QHBoxLayout *tmpLayout = new QHBoxLayout;
00256   
00257   QCheckBox *tmpChkB=new QCheckBox( i18n( "Accept incoming notes" ) );
00258   tmpChkB->setObjectName( "kcfg_ReceiveNotes" );
00259   tmpLayout->addWidget( tmpChkB );
00260   incoming->setLayout( tmpLayout );
00261   layout->addWidget( incoming );
00262   
00263   QGroupBox *outgoing = new QGroupBox( i18n( "Outgoing Notes" ) );
00264   tmpLayout = new QHBoxLayout;
00265   
00266   QLabel *label_SenderID = new QLabel( i18n( "&Sender ID:" ) );
00267   label_SenderID->setObjectName( "label_SenderID" );
00268   KLineEdit *kcfg_SenderID = new KLineEdit;
00269   kcfg_SenderID->setObjectName( "kcfg_SenderID" );
00270   label_SenderID->setBuddy( kcfg_SenderID );
00271   tmpLayout->addWidget( label_SenderID );
00272   tmpLayout->addWidget( kcfg_SenderID );
00273   outgoing->setLayout( tmpLayout );
00274   layout->addWidget( outgoing );
00275   
00276   tmpLayout = new QHBoxLayout;
00277   
00278   QLabel *label_Port = new QLabel( i18n( "&Port:" ) );
00279   label_Port->setObjectName( "label_Port" );
00280   
00281   tmpLayout->addWidget( label_Port );
00282   
00283   KIntNumInput *kcfg_Port = new KIntNumInput;
00284   kcfg_Port->setObjectName( "kcfg_Port" );
00285   kcfg_Port->setRange( 0, 65535 );
00286   kcfg_Port->setSliderEnabled( false );
00287   label_Port->setBuddy( kcfg_Port );
00288   tmpLayout->addWidget( kcfg_Port );
00289   layout->addLayout( tmpLayout );
00290   
00291   networkPage->setLayout( layout );
00292   return networkPage;
00293 }
00294 
00295 QWidget *KNoteConfigDlg::makeStylePage()
00296 {
00297   QWidget *stylePage = new QWidget();
00298   QGridLayout *layout = new QGridLayout( stylePage );
00299   layout->setSpacing( spacingHint() );
00300   layout->setMargin( 0 );
00301   
00302   QLabel *label_Style = new QLabel( i18n( "&Style:" ), stylePage );
00303   label_Style->setObjectName( "label_Style" );
00304   layout->addWidget( label_Style, 0, 0 );
00305   
00306   QComboBox *kcfg_Style = new QComboBox( stylePage );
00307   kcfg_Style->setObjectName( "kcfg_Style" );
00308   QStringList list;
00309   list << "Plain";
00310   kcfg_Style->addItems( list );
00311   label_Style->setBuddy( kcfg_Style );
00312   layout->addWidget( kcfg_Style, 0, 1 );
00313   
00314   return stylePage;
00315 }
00316 
00317 #include "knoteconfigdlg.moc"

knotes

Skip menu "knotes"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal