TDE personal information management applications
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

246 lines
8.9 KiB

  1. /*******************************************************************
  2. KNotes -- Notes for the KDE project
  3. Copyright (c) 1997-2005, The KNotes Developers
  4. This program is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU General Public License
  6. as published by the Free Software Foundation; either version 2
  7. of the License, or (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  15. *******************************************************************/
  16. #include <tqlabel.h>
  17. #include <tqlayout.h>
  18. #include <tqcheckbox.h>
  19. #include <tqcombobox.h>
  20. #include <tqhgroupbox.h>
  21. #include <tqtabwidget.h>
  22. #include <tdeapplication.h>
  23. #include <tdeconfig.h>
  24. #include <tdelocale.h>
  25. #include <kiconloader.h>
  26. #include <kcolorbutton.h>
  27. #include <knuminput.h>
  28. #include <klineedit.h>
  29. #include <tdefontrequester.h>
  30. #include <twin.h>
  31. #include "knote.h"
  32. #include "knoteconfigdlg.h"
  33. #include "knotesglobalconfig.h"
  34. #include "version.h"
  35. KNoteConfigDlg::KNoteConfigDlg( KNoteConfig *config, const TQString& title,
  36. TQWidget *parent, const char *name )
  37. : TDEConfigDialog( parent, name, config ? config : KNotesGlobalConfig::self(), IconList,
  38. config ? Default|Ok|Apply|Cancel : Default|Ok|Cancel, Ok )
  39. {
  40. setCaption( title );
  41. KWin::setIcons( winId(), kapp->icon(), kapp->miniIcon() );
  42. setIconListAllVisible( true );
  43. enableButtonSeparator( true );
  44. if ( config )
  45. {
  46. addPage( makeDisplayPage( false ), i18n("Display"), "knotes",
  47. i18n("Display Settings") );
  48. addPage( makeEditorPage( false ), i18n("Editor"), "edit",
  49. i18n("Editor Settings") );
  50. }
  51. else
  52. {
  53. config = KNotesGlobalConfig::self();
  54. addPage( makeDefaultsPage(), i18n("Defaults"), "knotes",
  55. i18n("Default Settings for New Notes") );
  56. addPage( makeActionsPage(), i18n("Actions"), "misc",
  57. i18n("Action Settings") );
  58. addPage( makeNetworkPage(), i18n("Network"), "network",
  59. i18n("Network Settings") );
  60. addPage( makeStylePage(), i18n("Style"), "style",
  61. i18n("Style Settings") );
  62. }
  63. config->setVersion( KNOTES_VERSION );
  64. }
  65. KNoteConfigDlg::~KNoteConfigDlg()
  66. {
  67. }
  68. void KNoteConfigDlg::slotUpdateCaption()
  69. {
  70. KNote *note = ::tqqt_cast<KNote *>(sender());
  71. if ( note )
  72. setCaption( note->name() );
  73. }
  74. TQWidget *KNoteConfigDlg::makeDisplayPage( bool defaults )
  75. {
  76. TQWidget *displayPage = new TQWidget();
  77. TQGridLayout *layout = new TQGridLayout( displayPage, 2, 2,
  78. defaults ? marginHint() : 0, spacingHint() );
  79. TQLabel *label_FgColor = new TQLabel( i18n("&Text color:"), displayPage, "label_FgColor" );
  80. layout->addWidget( label_FgColor, 0, 0 );
  81. KColorButton *kcfg_FgColor = new KColorButton( displayPage, "kcfg_FgColor" );
  82. label_FgColor->setBuddy( kcfg_FgColor );
  83. layout->addWidget( kcfg_FgColor, 0, 1 );
  84. TQLabel *label_BgColor = new TQLabel( i18n("&Background color:"), displayPage, "label_BgColor" );
  85. layout->addWidget( label_BgColor, 1, 0 );
  86. KColorButton *kcfg_BgColor = new KColorButton( displayPage, "kcfg_BgColor" );
  87. label_BgColor->setBuddy( kcfg_BgColor );
  88. layout->addWidget( kcfg_BgColor, 1, 1 );
  89. TQCheckBox *kcfg_ShowInTaskbar = new TQCheckBox( i18n("&Show note in taskbar"),
  90. displayPage, "kcfg_ShowInTaskbar" );
  91. if ( defaults )
  92. {
  93. TQLabel *label_Width = new TQLabel( i18n("Default &width:"), displayPage, "label_Width" );
  94. layout->addWidget( label_Width, 2, 0 );
  95. KIntNumInput *kcfg_Width = new KIntNumInput( displayPage, "kcfg_Width" );
  96. label_Width->setBuddy( kcfg_Width );
  97. kcfg_Width->setRange( 50, 2000, 10, false );
  98. layout->addWidget( kcfg_Width, 2, 1 );
  99. TQLabel *label_Height = new TQLabel( i18n("Default &height:"), displayPage, "label_Height" );
  100. layout->addWidget( label_Height, 3, 0 );
  101. KIntNumInput *kcfg_Height = new KIntNumInput( displayPage, "kcfg_Height" );
  102. kcfg_Height->setRange( 50, 2000, 10, false );
  103. label_Height->setBuddy( kcfg_Height );
  104. layout->addWidget( kcfg_Height, 3, 1 );
  105. layout->addWidget( kcfg_ShowInTaskbar, 4, 0 );
  106. }
  107. else
  108. layout->addWidget( kcfg_ShowInTaskbar, 2, 0 );
  109. return displayPage;
  110. }
  111. TQWidget *KNoteConfigDlg::makeEditorPage( bool defaults )
  112. {
  113. TQWidget *editorPage = new TQWidget();
  114. TQGridLayout *layout = new TQGridLayout( editorPage, 4, 3,
  115. defaults ? marginHint() : 0, spacingHint() );
  116. TQLabel *label_TabSize = new TQLabel( i18n( "&Tab size:" ), editorPage, "label_TabSize" );
  117. layout->addMultiCellWidget( label_TabSize, 0, 0, 0, 1 );
  118. KIntNumInput *kcfg_TabSize = new KIntNumInput( editorPage, "kcfg_TabSize" );
  119. kcfg_TabSize->setRange( 0, 40, 1, false );
  120. label_TabSize->setBuddy( kcfg_TabSize );
  121. layout->addWidget( kcfg_TabSize, 0, 2 );
  122. TQCheckBox *kcfg_AutoIndent = new TQCheckBox( i18n("Auto &indent"), editorPage, "kcfg_AutoIndent" );
  123. layout->addMultiCellWidget( kcfg_AutoIndent, 1, 1, 0, 1 );
  124. TQCheckBox *kcfg_RichText = new TQCheckBox( i18n("&Rich text"), editorPage, "kcfg_RichText" );
  125. layout->addWidget( kcfg_RichText, 1, 2 );
  126. TQLabel *label_Font = new TQLabel( i18n("Text font:"), editorPage, "label_Font" );
  127. layout->addWidget( label_Font, 3, 0 );
  128. TDEFontRequester *kcfg_Font = new TDEFontRequester( editorPage, "kcfg_Font" );
  129. kcfg_Font->setSizePolicy( TQSizePolicy( TQSizePolicy::Minimum, TQSizePolicy::Fixed ) );
  130. layout->addMultiCellWidget( kcfg_Font, 3, 3, 1, 2 );
  131. TQLabel *label_TitleFont = new TQLabel( i18n("Title font:"), editorPage, "label_TitleFont" );
  132. layout->addWidget( label_TitleFont, 2, 0 );
  133. TDEFontRequester *kcfg_TitleFont = new TDEFontRequester( editorPage, "kcfg_TitleFont" );
  134. kcfg_TitleFont->setSizePolicy( TQSizePolicy( TQSizePolicy::Minimum, TQSizePolicy::Fixed ) );
  135. layout->addMultiCellWidget( kcfg_TitleFont, 2, 2, 1, 2 );
  136. return editorPage;
  137. }
  138. TQWidget *KNoteConfigDlg::makeDefaultsPage()
  139. {
  140. TQTabWidget *defaultsPage = new TQTabWidget();
  141. defaultsPage->addTab( makeDisplayPage( true ), SmallIconSet( "knotes" ), i18n("Displa&y") );
  142. defaultsPage->addTab( makeEditorPage( true ), SmallIconSet( "edit" ), i18n("&Editor") );
  143. return defaultsPage;
  144. }
  145. TQWidget *KNoteConfigDlg::makeActionsPage()
  146. {
  147. TQWidget *actionsPage = new TQWidget();
  148. TQGridLayout *layout = new TQGridLayout( actionsPage, 2, 2, 0, spacingHint() );
  149. TQLabel *label_MailAction = new TQLabel( i18n("&Mail action:"), actionsPage, "label_MailAction" );
  150. layout->addWidget( label_MailAction, 0, 0 );
  151. KLineEdit *kcfg_MailAction = new KLineEdit( actionsPage, "kcfg_MailAction" );
  152. label_MailAction->setBuddy( kcfg_MailAction );
  153. layout->addWidget( kcfg_MailAction, 0, 1 );
  154. return actionsPage;
  155. }
  156. TQWidget *KNoteConfigDlg::makeNetworkPage()
  157. {
  158. TQWidget *networkPage = new TQWidget();
  159. TQGridLayout *layout = new TQGridLayout( networkPage, 4, 2, 0, spacingHint() );
  160. TQGroupBox *incoming = new TQHGroupBox( i18n("Incoming Notes"), networkPage );
  161. layout->addMultiCellWidget( incoming, 0, 0, 0, 1 );
  162. new TQCheckBox( i18n("Accept incoming notes"), incoming, "kcfg_ReceiveNotes" );
  163. TQGroupBox *outgoing = new TQHGroupBox( i18n("Outgoing Notes"), networkPage );
  164. layout->addMultiCellWidget( outgoing, 1, 1, 0, 1 );
  165. TQLabel *label_SenderID = new TQLabel( i18n("&Sender ID:"), outgoing, "label_SenderID" );
  166. KLineEdit *kcfg_SenderID = new KLineEdit( outgoing, "kcfg_SenderID" );
  167. label_SenderID->setBuddy( kcfg_SenderID );
  168. TQLabel *label_Port = new TQLabel( i18n("&Port:"), networkPage, "label_Port" );
  169. layout->addWidget( label_Port, 2, 0 );
  170. KIntNumInput *kcfg_Port = new KIntNumInput( networkPage, "kcfg_Port" );
  171. kcfg_Port->setRange( 0, 65535, 1, false );
  172. label_Port->setBuddy( kcfg_Port );
  173. layout->addWidget( kcfg_Port, 2, 1 );
  174. return networkPage;
  175. }
  176. TQWidget *KNoteConfigDlg::makeStylePage()
  177. {
  178. TQWidget *stylePage = new TQWidget();
  179. TQGridLayout *layout = new TQGridLayout( stylePage, 2, 2, 0, spacingHint() );
  180. TQLabel *label_Style = new TQLabel( i18n("&Style:"), stylePage, "label_Style" );
  181. layout->addWidget( label_Style, 0, 0 );
  182. TQComboBox *kcfg_Style = new TQComboBox( stylePage, "kcfg_Style" );
  183. TQStringList list;
  184. list << "Plain" << "Fancy";
  185. kcfg_Style->insertStringList( list );
  186. label_Style->setBuddy( kcfg_Style );
  187. layout->addWidget( kcfg_Style, 0, 1 );
  188. return stylePage;
  189. }
  190. #include "knoteconfigdlg.moc"