summaryrefslogtreecommitdiffstats
path: root/part/kxeconfiguration.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'part/kxeconfiguration.cpp')
-rw-r--r--part/kxeconfiguration.cpp181
1 files changed, 181 insertions, 0 deletions
diff --git a/part/kxeconfiguration.cpp b/part/kxeconfiguration.cpp
new file mode 100644
index 0000000..d780add
--- /dev/null
+++ b/part/kxeconfiguration.cpp
@@ -0,0 +1,181 @@
+/***************************************************************************
+ 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 <qlayout.h>
+
+
+KXEConfiguration::KXEConfiguration()
+ : QObject( 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
+ QFrame * pFrame;
+ QWidget * pPage;
+ QVBoxLayout * 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 QVBoxLayout( 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 QVBoxLayout( 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 QVBoxLayout( 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 QVBoxLayout( 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 QVBoxLayout( 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 );
+}