knoteconfigdlg.cpp
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 <tqlabel.h> 00022 #include <tqlayout.h> 00023 #include <tqcheckbox.h> 00024 #include <tqcombobox.h> 00025 #include <tqhgroupbox.h> 00026 #include <tqtabwidget.h> 00027 00028 #include <tdeapplication.h> 00029 #include <tdeconfig.h> 00030 #include <tdelocale.h> 00031 #include <kiconloader.h> 00032 #include <kcolorbutton.h> 00033 #include <knuminput.h> 00034 #include <klineedit.h> 00035 #include <tdefontrequester.h> 00036 #include <twin.h> 00037 00038 #include "knote.h" 00039 #include "knoteconfigdlg.h" 00040 #include "knotesglobalconfig.h" 00041 #include "version.h" 00042 00043 00044 KNoteConfigDlg::KNoteConfigDlg( KNoteConfig *config, const TQString& title, 00045 TQWidget *parent, const char *name ) 00046 : TDEConfigDialog( parent, name, config ? config : KNotesGlobalConfig::self(), IconList, 00047 config ? Default|Ok|Apply|Cancel : Default|Ok|Cancel, Ok ) 00048 { 00049 setCaption( title ); 00050 KWin::setIcons( winId(), kapp->icon(), kapp->miniIcon() ); 00051 00052 setIconListAllVisible( true ); 00053 enableButtonSeparator( true ); 00054 00055 if ( config ) 00056 { 00057 addPage( makeDisplayPage( false ), i18n("Display"), "knotes", 00058 i18n("Display Settings") ); 00059 addPage( makeEditorPage( false ), i18n("Editor"), "edit", 00060 i18n("Editor Settings") ); 00061 } 00062 else 00063 { 00064 config = KNotesGlobalConfig::self(); 00065 addPage( makeDefaultsPage(), i18n("Defaults"), "knotes", 00066 i18n("Default Settings for New Notes") ); 00067 addPage( makeActionsPage(), i18n("Actions"), "misc", 00068 i18n("Action Settings") ); 00069 addPage( makeNetworkPage(), i18n("Network"), "network", 00070 i18n("Network Settings") ); 00071 addPage( makeStylePage(), i18n("Style"), "style", 00072 i18n("Style Settings") ); 00073 } 00074 00075 config->setVersion( KNOTES_VERSION ); 00076 } 00077 00078 KNoteConfigDlg::~KNoteConfigDlg() 00079 { 00080 } 00081 00082 void KNoteConfigDlg::slotUpdateCaption() 00083 { 00084 KNote *note = ::tqqt_cast<KNote *>(sender()); 00085 if ( note ) 00086 setCaption( note->name() ); 00087 } 00088 00089 TQWidget *KNoteConfigDlg::makeDisplayPage( bool defaults ) 00090 { 00091 TQWidget *displayPage = new TQWidget(); 00092 TQGridLayout *layout = new TQGridLayout( displayPage, 2, 2, 00093 defaults ? marginHint() : 0, spacingHint() ); 00094 00095 TQLabel *label_FgColor = new TQLabel( i18n("&Text color:"), displayPage, "label_FgColor" ); 00096 layout->addWidget( label_FgColor, 0, 0 ); 00097 00098 KColorButton *kcfg_FgColor = new KColorButton( displayPage, "kcfg_FgColor" ); 00099 label_FgColor->setBuddy( kcfg_FgColor ); 00100 layout->addWidget( kcfg_FgColor, 0, 1 ); 00101 00102 TQLabel *label_BgColor = new TQLabel( i18n("&Background color:"), displayPage, "label_BgColor" ); 00103 layout->addWidget( label_BgColor, 1, 0 ); 00104 00105 KColorButton *kcfg_BgColor = new KColorButton( displayPage, "kcfg_BgColor" ); 00106 label_BgColor->setBuddy( kcfg_BgColor ); 00107 layout->addWidget( kcfg_BgColor, 1, 1 ); 00108 00109 TQCheckBox *kcfg_ShowInTaskbar = new TQCheckBox( i18n("&Show note in taskbar"), 00110 displayPage, "kcfg_ShowInTaskbar" ); 00111 00112 if ( defaults ) 00113 { 00114 TQLabel *label_Width = new TQLabel( i18n("Default &width:"), displayPage, "label_Width" ); 00115 layout->addWidget( label_Width, 2, 0 ); 00116 00117 KIntNumInput *kcfg_Width = new KIntNumInput( displayPage, "kcfg_Width" ); 00118 label_Width->setBuddy( kcfg_Width ); 00119 kcfg_Width->setRange( 50, 2000, 10, false ); 00120 layout->addWidget( kcfg_Width, 2, 1 ); 00121 00122 TQLabel *label_Height = new TQLabel( i18n("Default &height:"), displayPage, "label_Height" ); 00123 layout->addWidget( label_Height, 3, 0 ); 00124 00125 KIntNumInput *kcfg_Height = new KIntNumInput( displayPage, "kcfg_Height" ); 00126 kcfg_Height->setRange( 50, 2000, 10, false ); 00127 label_Height->setBuddy( kcfg_Height ); 00128 layout->addWidget( kcfg_Height, 3, 1 ); 00129 00130 layout->addWidget( kcfg_ShowInTaskbar, 4, 0 ); 00131 } 00132 else 00133 layout->addWidget( kcfg_ShowInTaskbar, 2, 0 ); 00134 00135 return displayPage; 00136 } 00137 00138 TQWidget *KNoteConfigDlg::makeEditorPage( bool defaults ) 00139 { 00140 TQWidget *editorPage = new TQWidget(); 00141 TQGridLayout *layout = new TQGridLayout( editorPage, 4, 3, 00142 defaults ? marginHint() : 0, spacingHint() ); 00143 00144 TQLabel *label_TabSize = new TQLabel( i18n( "&Tab size:" ), editorPage, "label_TabSize" ); 00145 layout->addMultiCellWidget( label_TabSize, 0, 0, 0, 1 ); 00146 00147 KIntNumInput *kcfg_TabSize = new KIntNumInput( editorPage, "kcfg_TabSize" ); 00148 kcfg_TabSize->setRange( 0, 40, 1, false ); 00149 label_TabSize->setBuddy( kcfg_TabSize ); 00150 layout->addWidget( kcfg_TabSize, 0, 2 ); 00151 00152 TQCheckBox *kcfg_AutoIndent = new TQCheckBox( i18n("Auto &indent"), editorPage, "kcfg_AutoIndent" ); 00153 layout->addMultiCellWidget( kcfg_AutoIndent, 1, 1, 0, 1 ); 00154 00155 TQCheckBox *kcfg_RichText = new TQCheckBox( i18n("&Rich text"), editorPage, "kcfg_RichText" ); 00156 layout->addWidget( kcfg_RichText, 1, 2 ); 00157 00158 TQLabel *label_Font = new TQLabel( i18n("Text font:"), editorPage, "label_Font" ); 00159 layout->addWidget( label_Font, 3, 0 ); 00160 00161 TDEFontRequester *kcfg_Font = new TDEFontRequester( editorPage, "kcfg_Font" ); 00162 kcfg_Font->setSizePolicy( TQSizePolicy( TQSizePolicy::Minimum, TQSizePolicy::Fixed ) ); 00163 layout->addMultiCellWidget( kcfg_Font, 3, 3, 1, 2 ); 00164 00165 TQLabel *label_TitleFont = new TQLabel( i18n("Title font:"), editorPage, "label_TitleFont" ); 00166 layout->addWidget( label_TitleFont, 2, 0 ); 00167 00168 TDEFontRequester *kcfg_TitleFont = new TDEFontRequester( editorPage, "kcfg_TitleFont" ); 00169 kcfg_TitleFont->setSizePolicy( TQSizePolicy( TQSizePolicy::Minimum, TQSizePolicy::Fixed ) ); 00170 layout->addMultiCellWidget( kcfg_TitleFont, 2, 2, 1, 2 ); 00171 00172 return editorPage; 00173 } 00174 00175 TQWidget *KNoteConfigDlg::makeDefaultsPage() 00176 { 00177 TQTabWidget *defaultsPage = new TQTabWidget(); 00178 defaultsPage->addTab( makeDisplayPage( true ), SmallIconSet( "knotes" ), i18n("Displa&y") ); 00179 defaultsPage->addTab( makeEditorPage( true ), SmallIconSet( "edit" ), i18n("&Editor") ); 00180 00181 return defaultsPage; 00182 } 00183 00184 TQWidget *KNoteConfigDlg::makeActionsPage() 00185 { 00186 TQWidget *actionsPage = new TQWidget(); 00187 TQGridLayout *layout = new TQGridLayout( actionsPage, 2, 2, 0, spacingHint() ); 00188 00189 TQLabel *label_MailAction = new TQLabel( i18n("&Mail action:"), actionsPage, "label_MailAction" ); 00190 layout->addWidget( label_MailAction, 0, 0 ); 00191 00192 KLineEdit *kcfg_MailAction = new KLineEdit( actionsPage, "kcfg_MailAction" ); 00193 label_MailAction->setBuddy( kcfg_MailAction ); 00194 layout->addWidget( kcfg_MailAction, 0, 1 ); 00195 00196 return actionsPage; 00197 } 00198 00199 TQWidget *KNoteConfigDlg::makeNetworkPage() 00200 { 00201 TQWidget *networkPage = new TQWidget(); 00202 TQGridLayout *layout = new TQGridLayout( networkPage, 4, 2, 0, spacingHint() ); 00203 00204 TQGroupBox *incoming = new TQHGroupBox( i18n("Incoming Notes"), networkPage ); 00205 layout->addMultiCellWidget( incoming, 0, 0, 0, 1 ); 00206 00207 new TQCheckBox( i18n("Accept incoming notes"), incoming, "kcfg_ReceiveNotes" ); 00208 00209 TQGroupBox *outgoing = new TQHGroupBox( i18n("Outgoing Notes"), networkPage ); 00210 layout->addMultiCellWidget( outgoing, 1, 1, 0, 1 ); 00211 00212 TQLabel *label_SenderID = new TQLabel( i18n("&Sender ID:"), outgoing, "label_SenderID" ); 00213 KLineEdit *kcfg_SenderID = new KLineEdit( outgoing, "kcfg_SenderID" ); 00214 label_SenderID->setBuddy( kcfg_SenderID ); 00215 00216 TQLabel *label_Port = new TQLabel( i18n("&Port:"), networkPage, "label_Port" ); 00217 layout->addWidget( label_Port, 2, 0 ); 00218 00219 KIntNumInput *kcfg_Port = new KIntNumInput( networkPage, "kcfg_Port" ); 00220 kcfg_Port->setRange( 0, 65535, 1, false ); 00221 label_Port->setBuddy( kcfg_Port ); 00222 layout->addWidget( kcfg_Port, 2, 1 ); 00223 00224 return networkPage; 00225 } 00226 00227 TQWidget *KNoteConfigDlg::makeStylePage() 00228 { 00229 TQWidget *stylePage = new TQWidget(); 00230 TQGridLayout *layout = new TQGridLayout( stylePage, 2, 2, 0, spacingHint() ); 00231 00232 TQLabel *label_Style = new TQLabel( i18n("&Style:"), stylePage, "label_Style" ); 00233 layout->addWidget( label_Style, 0, 0 ); 00234 00235 TQComboBox *kcfg_Style = new TQComboBox( stylePage, "kcfg_Style" ); 00236 TQStringList list; 00237 list << "Plain" << "Fancy"; 00238 kcfg_Style->insertStringList( list ); 00239 label_Style->setBuddy( kcfg_Style ); 00240 layout->addWidget( kcfg_Style, 0, 1 ); 00241 00242 return stylePage; 00243 } 00244 00245 #include "knoteconfigdlg.moc"