1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
/***************************************************************************
kxeconfiguration.cpp
--------------------
begin : Tue Dec 02 2003
copyright : (C) 2003 by The KXMLEditor Team
email : hartig@users.sourceforge.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "kxeconfiguration.h"
#include "kxetreeviewsettings.h"
#include "kxetextviewsettings.h"
#include "kxenewfilesettings.h"
#include "kxeprintsettings.h"
#include "kxearchiveextssettings.h"
#include <kglobal.h>
#include <klocale.h>
#include <kdialogbase.h>
#include <kiconloader.h>
#include <tqlayout.h>
KXEConfiguration::KXEConfiguration()
: TQObject( 0, "KXMLEditor's configuration (KXEConfiguration)" ),
m_pDialog( 0 )
{
// initialize all setting group objects
m_pTreeView = new KXETreeViewSettings( this, "tree view config. settings" );
m_pTextView = new KXETextViewSettings( this, "text view config. settings" );
m_pNewFile = new KXENewFileSettings( this, "new file config. settings" );
m_pPrint = new KXEPrintSettings( this, "printing config. settings" );
m_pArcExts = new KXEArchiveExtsSettings( this, "archive extension config. settings" );
// restore the settings from our config file
restore();
}
KXEConfiguration::~KXEConfiguration()
{
if ( m_pDialog )
delete m_pDialog;
}
void KXEConfiguration::store( KConfig * pConfig ) const
{
if ( ! pConfig )
pConfig = KGlobal::config();
m_pTreeView->store( pConfig );
m_pTextView->store( pConfig );
m_pNewFile->store( pConfig );
m_pPrint->store( pConfig );
m_pArcExts->store( pConfig );
}
void KXEConfiguration::restore( KConfig * pConfig )
{
if ( ! pConfig )
pConfig = KGlobal::config();
m_pTreeView->restore( pConfig );
m_pTextView->restore( pConfig );
m_pNewFile->restore( pConfig );
m_pPrint->restore( pConfig );
m_pArcExts->restore( pConfig );
}
void KXEConfiguration::showDialog()
{
if ( ! m_pDialog ) // if there is no dialog yet,
{
// create one
m_pDialog = new KDialogBase( KDialogBase::IconList, // dialog face
i18n("Configure KXMLEditor"), // caption
KDialogBase::Apply | KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Help, // buttons
KDialogBase::Ok, // default button
0, // parent
"configuration dialog", // name
false, // not modal
true ); // show separator
connect( m_pDialog, SIGNAL(applyClicked()), this, SLOT(slotDlgApplied()) );
connect( m_pDialog, SIGNAL(okClicked()), this, SLOT(slotDlgApplied()) );
// and add the pages
TQFrame * pFrame;
TQWidget * pPage;
TQVBoxLayout * pLayout;
// - tree view properties page
pFrame = m_pDialog->addPage( m_pTreeView->dialogPageName(),
m_pTreeView->dialogPageHeader(),
KGlobal::instance()->iconLoader()->loadIcon( m_pTreeView->dialogPageIcon(), KIcon::NoGroup, KIcon::SizeMedium ) );
pLayout = new TQVBoxLayout( pFrame );
pPage = m_pTreeView->dialogPage( pFrame );
pLayout->addWidget( pPage );
connect( m_pTreeView, SIGNAL(sigDialogPageChanged()), this, SLOT(slotDlgChanged()) );
// - text view properties page
pFrame = m_pDialog->addPage( m_pTextView->dialogPageName(),
m_pTextView->dialogPageHeader(),
KGlobal::instance()->iconLoader()->loadIcon( m_pTextView->dialogPageIcon(), KIcon::NoGroup, KIcon::SizeMedium ) );
pLayout = new TQVBoxLayout( pFrame );
pPage = m_pTextView->dialogPage( pFrame );
pLayout->addWidget( pPage );
connect( m_pTextView, SIGNAL(sigDialogPageChanged()), this, SLOT(slotDlgChanged()) );
// - new file settings page
pFrame = m_pDialog->addPage( m_pNewFile->dialogPageName(),
m_pNewFile->dialogPageHeader(),
KGlobal::instance()->iconLoader()->loadIcon( m_pNewFile->dialogPageIcon(), KIcon::NoGroup, KIcon::SizeMedium ) );
pLayout = new TQVBoxLayout( pFrame );
pPage = m_pNewFile->dialogPage( pFrame );
pLayout->addWidget( pPage );
connect( m_pNewFile, SIGNAL(sigDialogPageChanged()), this, SLOT(slotDlgChanged()) );
// - printing's settings page
pFrame = m_pDialog->addPage( m_pPrint->dialogPageName(),
m_pPrint->dialogPageHeader(),
KGlobal::instance()->iconLoader()->loadIcon( m_pPrint->dialogPageIcon(), KIcon::NoGroup, KIcon::SizeMedium ) );
pLayout = new TQVBoxLayout( pFrame );
pPage = m_pPrint->dialogPage( pFrame );
pLayout->addWidget( pPage );
connect( m_pPrint, SIGNAL(sigDialogPageChanged()), this, SLOT(slotDlgChanged()) );
// - archive extensions page
pFrame = m_pDialog->addPage( m_pArcExts->dialogPageName(),
m_pArcExts->dialogPageHeader(),
KGlobal::instance()->iconLoader()->loadIcon( m_pArcExts->dialogPageIcon(), KIcon::NoGroup, KIcon::SizeMedium ) );
pLayout = new TQVBoxLayout( pFrame );
pPage = m_pArcExts->dialogPage( pFrame );
pLayout->addWidget( pPage );
connect( m_pArcExts, SIGNAL(sigDialogPageChanged()), this, SLOT(slotDlgChanged()) );
}
if ( m_pDialog->isVisible() ) // If the dialog is visible (probably opened by
{ // another part), it has to be hidden to make
m_pDialog->hide(); // it appear on the current desktop by the later
} // call of show.
else // If the dialog is not visible, it's
{ // Apply- and Ok-buttons have to be
m_pDialog->enableButtonApply( false ); // disabled (until something is changed
m_pDialog->enableButtonOK( false ); // within the dialog).
}
m_pDialog->show(); // show our configuration dialog
}
void KXEConfiguration::slotDlgApplied()
{
// reset configuration dialog
m_pDialog->enableButtonApply( false );
m_pDialog->enableButtonOK( false );
// apply the page's data to the corresponding setting groups
m_pTreeView->apply();
m_pTextView->apply();
m_pNewFile->apply();
m_pPrint->apply();
m_pArcExts->apply();
// store the applied data to our config file
store();
}
void KXEConfiguration::slotDlgChanged()
{
m_pDialog->enableButtonApply( true );
m_pDialog->enableButtonOK( true );
}
#include "kxeconfiguration.moc"
|