summaryrefslogtreecommitdiffstats
path: root/korn/kornshell.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch)
tree67208f7c145782a7e90b123b982ca78d88cc2c87 /korn/kornshell.cpp
downloadtdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz
tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'korn/kornshell.cpp')
-rw-r--r--korn/kornshell.cpp155
1 files changed, 155 insertions, 0 deletions
diff --git a/korn/kornshell.cpp b/korn/kornshell.cpp
new file mode 100644
index 000000000..3e87ba42f
--- /dev/null
+++ b/korn/kornshell.cpp
@@ -0,0 +1,155 @@
+/*
+ * Copyright (C) 2004-2006, Mart Kelder (mart@kelder31.nl)
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "kornshell.h"
+
+#include "boxcontainer.h"
+#include "dockedcontainer.h"
+#include "korncfgimpl.h"
+#include "hvcontainer.h"
+#include "password.h"
+
+#include <kapplication.h>
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kdialogbase.h>
+#include <klocale.h>
+
+#include <qtimer.h>
+
+KornShell::KornShell( QWidget * parent, const char * name )
+ : QWidget( parent, name ),
+ _config( new KConfig( "kornrc" ) ),
+ _box( 0 ),
+ _configDialog( 0 ),
+ _show( false )
+{
+ _config->checkUpdate( "korn_kde_3_4_config_change", "korn-3-4-config_change.upd" );
+ if( kapp->isRestored() )
+ {
+ _config->setGroup( "korn" );
+ QTimer::singleShot( _config->readNumEntry( "session_startup_delay", 2000 ), this, SLOT(readConfig()) );
+ kdDebug() << "startup delayed" << endl;
+ }
+ else
+ {
+ kdDebug() << "Startup not delayed" << endl;
+ readConfig();
+ }
+
+}
+
+KornShell::~KornShell()
+{
+ if( _box )
+ _box->writeConfig( _config );
+ delete _config;
+ delete _box;
+}
+
+void KornShell::show()
+{
+ if( _box )
+ _box->showBox();
+ else
+ _show = true;
+}
+
+void KornShell::optionDlg()
+{
+ if( _configDialog )
+ {
+ _configDialog->show();
+ return;
+ }
+
+ _configDialog = new KDialogBase( 0, "Configuration Dialog", false, i18n( "Korn Configuration" ),
+ KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Apply, KDialogBase::Ok, true );
+
+ KornCfgImpl *widget = new KornCfgImpl( _configDialog, "Configuration widget" );
+ _configDialog->setMainWidget( widget );
+
+ connect( _configDialog, SIGNAL( finished() ), this, SLOT( slotDialogClosed() ) );
+ connect( _configDialog, SIGNAL( applyClicked() ), this, SLOT( slotApply() ) );
+
+ _configDialog->show();
+}
+
+void KornShell::readConfig()
+{
+ static bool shownConfig = false;
+
+ _config->setGroup( "korn" );
+ QChar layout = _config->readEntry( "layout", "Docked" )[0].upper();
+ KOrnPassword::setUseWallet( _config->readBoolEntry( "usewallet", false ) );
+
+ if( layout == 'H' )
+ _box = new HVContainer( Qt::Horizontal, this, "horizontal container" );
+ else if( layout == 'V' )
+ _box = new HVContainer( Qt::Vertical, this, "vertical container" );
+ else
+ _box = new DockedContainer( this, "docked container" );
+
+ connect( _box, SIGNAL( showConfiguration() ), this, SLOT( optionDlg() ) );
+
+ _box->readConfig( _config );
+
+ //Show configuration dialog of no boxes are configurated
+ if( !_config->hasGroup( "korn-0" ) )
+ //If user pressed cancel, or did not add a box, close KOrn
+ if( !shownConfig )
+ {
+ shownConfig = true;
+ optionDlg();
+ }
+ else
+ {
+ kapp->quit();
+ }
+
+ if( _show )
+ {
+ // Show is called, but _box wasn't available at that time
+ show();
+ _show = false;
+ }
+}
+
+void KornShell::slotDialogClosed()
+{
+ _configDialog->deleteLater(); _configDialog = 0;
+
+ //At this time, just delete all widgets and make a new one.
+ //Maybe, this should replaces later by a better variant.
+ slotApply();
+}
+
+void KornShell::slotApply()
+{
+ //At this time, just delete all widgets and make a new one.
+ //Maybe, this should replaces later by a better variant.
+
+ delete _box; _box = 0;
+
+ _config->reparseConfiguration();
+
+ readConfig();
+ _box->showBox();
+}
+
+#include "kornshell.moc"