knotes

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