knotes Library API Documentation

knoteconfigdlg.cpp

00001 /******************************************************************* 00002 KNotes -- Notes for the KDE project 00003 00004 Copyright (c) 1997-2004, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00019 *******************************************************************/ 00020 00021 #include <qlabel.h> 00022 #include <qlayout.h> 00023 #include <qcheckbox.h> 00024 #include <qhgroupbox.h> 00025 #include <qtabwidget.h> 00026 00027 #include <kapplication.h> 00028 #include <kconfig.h> 00029 #include <klocale.h> 00030 #include <kiconloader.h> 00031 #include <kcolorbutton.h> 00032 #include <knuminput.h> 00033 #include <klineedit.h> 00034 #include <kfontrequester.h> 00035 #include <kwin.h> 00036 00037 #include "knote.h" 00038 #include "knoteconfigdlg.h" 00039 #include "knotesglobalconfig.h" 00040 #include "version.h" 00041 00042 00043 KNoteConfigDlg::KNoteConfigDlg( KNoteConfig *config, const QString& title, 00044 QWidget *parent, const char *name ) 00045 : KConfigDialog( parent, name, config ? config : KNotesGlobalConfig::self(), IconList, 00046 config ? Default|Ok|Apply|Cancel : Default|Ok|Cancel, Ok ) 00047 { 00048 setCaption( title ); 00049 KWin::setIcons( winId(), kapp->icon(), kapp->miniIcon() ); 00050 00051 setIconListAllVisible( true ); 00052 enableButtonSeparator( true ); 00053 00054 if ( config ) 00055 { 00056 addPage( makeDisplayPage( false ), i18n("Display"), "knotes", 00057 i18n("Display Settings") ); 00058 addPage( makeEditorPage( false ), i18n("Editor"), "edit", 00059 i18n("Editor Settings") ); 00060 } 00061 else 00062 { 00063 config = KNotesGlobalConfig::self(); 00064 addPage( makeDefaultsPage(), i18n("Defaults"), "knotes", 00065 i18n("Default Settings for New Notes") ); 00066 addPage( makeActionsPage(), i18n("Actions"), "misc", 00067 i18n("Action Settings") ); 00068 addPage( makeNetworkPage(), i18n("Network"), "network", 00069 i18n("Network Settings") ); 00070 } 00071 00072 config->setVersion( KNOTES_VERSION ); 00073 } 00074 00075 KNoteConfigDlg::~KNoteConfigDlg() 00076 { 00077 } 00078 00079 void KNoteConfigDlg::slotUpdateCaption() 00080 { 00081 KNote *note = ::qt_cast<KNote *>(sender()); 00082 if ( note ) 00083 setCaption( note->name() ); 00084 } 00085 00086 QWidget *KNoteConfigDlg::makeDisplayPage( bool defaults ) 00087 { 00088 QWidget *displayPage = new QWidget(); 00089 QGridLayout *layout = new QGridLayout( displayPage, 2, 2, 00090 defaults ? marginHint() : 0, spacingHint() ); 00091 00092 QLabel *label_FgColor = new QLabel( i18n("&Text color:"), displayPage, "label_FgColor" ); 00093 layout->addWidget( label_FgColor, 0, 0 ); 00094 00095 KColorButton *kcfg_FgColor = new KColorButton( displayPage, "kcfg_FgColor" ); 00096 label_FgColor->setBuddy( kcfg_FgColor ); 00097 layout->addWidget( kcfg_FgColor, 0, 1 ); 00098 00099 QLabel *label_BgColor = new QLabel( i18n("&Background color:"), displayPage, "label_BgColor" ); 00100 layout->addWidget( label_BgColor, 1, 0 ); 00101 00102 KColorButton *kcfg_BgColor = new KColorButton( displayPage, "kcfg_BgColor" ); 00103 label_BgColor->setBuddy( kcfg_BgColor ); 00104 layout->addWidget( kcfg_BgColor, 1, 1 ); 00105 00106 QCheckBox *kcfg_ShowInTaskbar = new QCheckBox( i18n("&Show note in taskbar"), 00107 displayPage, "kcfg_ShowInTaskbar" ); 00108 00109 if ( defaults ) 00110 { 00111 QLabel *label_Width = new QLabel( i18n("Default &width:"), displayPage, "label_Width" ); 00112 layout->addWidget( label_Width, 2, 0 ); 00113 00114 KIntNumInput *kcfg_Width = new KIntNumInput( displayPage, "kcfg_Width" ); 00115 label_Width->setBuddy( kcfg_Width ); 00116 kcfg_Width->setRange( 100, 2000, 10, false ); 00117 layout->addWidget( kcfg_Width, 2, 1 ); 00118 00119 QLabel *label_Height = new QLabel( i18n("Default &height:"), displayPage, "label_Height" ); 00120 layout->addWidget( label_Height, 3, 0 ); 00121 00122 KIntNumInput *kcfg_Height = new KIntNumInput( displayPage, "kcfg_Height" ); 00123 kcfg_Height->setRange( 100, 2000, 10, false ); 00124 label_Height->setBuddy( kcfg_Height ); 00125 layout->addWidget( kcfg_Height, 3, 1 ); 00126 00127 layout->addWidget( kcfg_ShowInTaskbar, 4, 0 ); 00128 } 00129 else 00130 layout->addWidget( kcfg_ShowInTaskbar, 2, 0 ); 00131 00132 return displayPage; 00133 } 00134 00135 QWidget *KNoteConfigDlg::makeEditorPage( bool defaults ) 00136 { 00137 QWidget *editorPage = new QWidget(); 00138 QGridLayout *layout = new QGridLayout( editorPage, 4, 3, 00139 defaults ? marginHint() : 0, spacingHint() ); 00140 00141 QLabel *label_TabSize = new QLabel( i18n( "&Tab size:" ), editorPage, "label_TabSize" ); 00142 layout->addMultiCellWidget( label_TabSize, 0, 0, 0, 1 ); 00143 00144 KIntNumInput *kcfg_TabSize = new KIntNumInput( editorPage, "kcfg_TabSize" ); 00145 kcfg_TabSize->setRange( 0, 40, 1, false ); 00146 label_TabSize->setBuddy( kcfg_TabSize ); 00147 layout->addWidget( kcfg_TabSize, 0, 2 ); 00148 00149 QCheckBox *kcfg_AutoIndent = new QCheckBox( i18n("Auto &indent"), editorPage, "kcfg_AutoIndent" ); 00150 layout->addMultiCellWidget( kcfg_AutoIndent, 1, 1, 0, 1 ); 00151 00152 QCheckBox *kcfg_RichText = new QCheckBox( i18n("&Rich text"), editorPage, "kcfg_RichText" ); 00153 layout->addWidget( kcfg_RichText, 1, 2 ); 00154 00155 QLabel *label_Font = new QLabel( i18n("Text font:"), editorPage, "label_Font" ); 00156 layout->addWidget( label_Font, 3, 0 ); 00157 00158 KFontRequester *kcfg_Font = new KFontRequester( editorPage, "kcfg_Font" ); 00159 kcfg_Font->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ) ); 00160 layout->addMultiCellWidget( kcfg_Font, 3, 3, 1, 2 ); 00161 00162 QLabel *label_TitleFont = new QLabel( i18n("Title font:"), editorPage, "label_TitleFont" ); 00163 layout->addWidget( label_TitleFont, 2, 0 ); 00164 00165 KFontRequester *kcfg_TitleFont = new KFontRequester( editorPage, "kcfg_TitleFont" ); 00166 kcfg_TitleFont->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ) ); 00167 layout->addMultiCellWidget( kcfg_TitleFont, 2, 2, 1, 2 ); 00168 00169 return editorPage; 00170 } 00171 00172 QWidget *KNoteConfigDlg::makeDefaultsPage() 00173 { 00174 QTabWidget *defaultsPage = new QTabWidget(); 00175 defaultsPage->addTab( makeDisplayPage( true ), SmallIconSet( "knotes" ), i18n("Displa&y") ); 00176 defaultsPage->addTab( makeEditorPage( true ), SmallIconSet( "edit" ), i18n("&Editor") ); 00177 00178 return defaultsPage; 00179 } 00180 00181 QWidget *KNoteConfigDlg::makeActionsPage() 00182 { 00183 QWidget *actionsPage = new QWidget(); 00184 QGridLayout *layout = new QGridLayout( actionsPage, 2, 2, 0, spacingHint() ); 00185 00186 QLabel *label_MailAction = new QLabel( i18n("&Mail action:"), actionsPage, "label_MailAction" ); 00187 layout->addWidget( label_MailAction, 0, 0 ); 00188 00189 KLineEdit *kcfg_MailAction = new KLineEdit( actionsPage, "kcfg_MailAction" ); 00190 label_MailAction->setBuddy( kcfg_MailAction ); 00191 layout->addWidget( kcfg_MailAction, 0, 1 ); 00192 00193 return actionsPage; 00194 } 00195 00196 QWidget *KNoteConfigDlg::makeNetworkPage() 00197 { 00198 QWidget *networkPage = new QWidget(); 00199 QGridLayout *layout = new QGridLayout( networkPage, 4, 2, 0, spacingHint() ); 00200 00201 QGroupBox *incoming = new QHGroupBox( i18n("Incoming Notes"), networkPage ); 00202 layout->addMultiCellWidget( incoming, 0, 0, 0, 1 ); 00203 00204 new QCheckBox( i18n("Accept incoming notes"), incoming, "kcfg_ReceiveNotes" ); 00205 00206 QGroupBox *outgoing = new QHGroupBox( i18n("Outgoing Notes"), networkPage ); 00207 layout->addMultiCellWidget( outgoing, 1, 1, 0, 1 ); 00208 00209 QLabel *label_SenderID = new QLabel( i18n("&Sender ID:"), outgoing, "label_SenderID" ); 00210 KLineEdit *kcfg_SenderID = new KLineEdit( outgoing, "kcfg_SenderID" ); 00211 label_SenderID->setBuddy( kcfg_SenderID ); 00212 00213 QLabel *label_Port = new QLabel( i18n("&Port:"), networkPage, "label_Port" ); 00214 layout->addWidget( label_Port, 2, 0 ); 00215 00216 KIntNumInput *kcfg_Port = new KIntNumInput( networkPage, "kcfg_Port" ); 00217 kcfg_Port->setRange( 0, 65535, 1, false ); 00218 label_Port->setBuddy( kcfg_Port ); 00219 layout->addWidget( kcfg_Port, 2, 1 ); 00220 00221 return networkPage; 00222 } 00223 00224 00225 #include "knoteconfigdlg.moc"
KDE Logo
This file is part of the documentation for knotes Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 27 12:50:14 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003