22 #include "tdeconfigwizard.h"
24 #include <tdelocale.h>
26 #include <tdeconfigskeleton.h>
27 #include <tdemessagebox.h>
28 #include <tdeapplication.h>
30 #include <tqlistview.h>
35 char *name,
bool modal )
36 : KDialogBase( TreeList, i18n(
"Configuration Wizard"), Ok|Cancel, Ok, parent,
38 mPropagator( 0 ), mChangesPage( 0 )
44 char *name,
bool modal )
45 : KDialogBase( TreeList, i18n(
"Configuration Wizard"), Ok|Cancel, Ok, parent,
47 mPropagator( propagator ), mChangesPage( 0 )
57 void TDEConfigWizard::init()
59 connect(
this, TQ_SIGNAL( aboutToShowPage( TQWidget * ) ),
60 TQ_SLOT( slotAboutToShowPage( TQWidget * ) ) );
62 TQTimer::singleShot( 0,
this, TQ_SLOT( readConfig() ) );
70 void TDEConfigWizard::slotAboutToShowPage( TQWidget *page )
72 if ( page == mChangesPage ) {
79 return addPage( title );
82 void TDEConfigWizard::setupRulesPage()
84 TQFrame *topFrame = addPage( i18n(
"Rules") );
85 TQVBoxLayout *topLayout =
new TQVBoxLayout( topFrame );
87 mRuleView =
new TQListView( topFrame );
88 topLayout->addWidget( mRuleView );
90 mRuleView->addColumn( i18n(
"Source") );
91 mRuleView->addColumn( i18n(
"Target") );
92 mRuleView->addColumn( i18n(
"Condition") );
97 void TDEConfigWizard::updateRules()
100 kdError() <<
"TDEConfigWizard: No TDEConfigPropagator set." << endl;
106 TDEConfigPropagator::Rule::List rules = mPropagator->rules();
107 TDEConfigPropagator::Rule::List::ConstIterator it;
108 for( it = rules.begin(); it != rules.end(); ++it ) {
109 TDEConfigPropagator::Rule r = *it;
110 TQString source = r.sourceFile +
"/" + r.sourceGroup +
"/" +
112 TQString target = r.targetFile +
"/" + r.targetGroup +
"/" +
115 TDEConfigPropagator::Condition c = r.condition;
117 condition = c.file +
"/" + c.group +
"/" + c.key +
" = " + c.value;
119 new TQListViewItem( mRuleView, source, target, condition );
123 void TDEConfigWizard::setupChangesPage()
125 TQFrame *topFrame = addPage( i18n(
"Changes") );
126 TQVBoxLayout *topLayout =
new TQVBoxLayout( topFrame );
128 mChangeView =
new TQListView( topFrame );
129 topLayout->addWidget( mChangeView );
131 mChangeView->addColumn( i18n(
"Action") );
132 mChangeView->addColumn( i18n(
"Option") );
133 mChangeView->addColumn( i18n(
"Value") );
134 mChangeView->setSorting( -1 );
136 mChangesPage = topFrame;
139 void TDEConfigWizard::updateChanges()
141 kdDebug() <<
"TDEConfigWizard::updateChanges()" << endl;
143 if ( !mPropagator ) {
144 kdError() <<
"TDEConfigWizard: No TDEConfigPropagator set." << endl;
150 mPropagator->updateChanges();
152 mChangeView->clear();
154 TDEConfigPropagator::Change::List changes = mPropagator->changes();
155 TDEConfigPropagator::Change *c;
156 for( c = changes.first(); c; c = changes.next() ) {
157 new TQListViewItem( mChangeView, mChangeView->lastItem(), c->title(), c->arg1(), c->arg2() );
161 void TDEConfigWizard::readConfig()
163 kdDebug() <<
"TDEConfigWizard::readConfig()" << endl;
165 int result = KMessageBox::warningContinueCancel(
this,
166 i18n(
"Please make sure that the programs which are "
167 "configured by the wizard do not run in parallel to the wizard; "
168 "otherwise, changes done by the wizard could be lost."),
169 i18n(
"Warning"), i18n(
"Run Wizard Now"),
"warning_running_instances" );
170 if ( result != KMessageBox::Continue ) kapp->quit();
175 void TDEConfigWizard::slotOk()
178 if ( error.isNull() ) {
181 if ( !mPropagator ) {
182 kdError() <<
"TDEConfigWizard: No TDEConfigPropagator set." << endl;
185 if ( mPropagator->skeleton() ) {
186 mPropagator->skeleton()->writeConfig();
188 mPropagator->commit();
193 KMessageBox::sorry(
this, error );
197 #include "tdeconfigwizard.moc"
virtual TQString validate()
Validates the supplied data.
virtual ~TDEConfigWizard()
Destructor.
TDEConfigWizard(TQWidget *parent=0, char *name=0, bool modal=false)
Create wizard.
virtual void usrReadConfig()=0
Use this function to read the configuration from the TDEConfigSkeleton object to the GUI.
void setPropagator(TDEConfigPropagator *)
Set propagator the wizard operates on.
virtual void usrWriteConfig()=0
This function is called when the wizard is finished.
TQFrame * createWizardPage(const TQString &title)
Create wizard page with given title.