diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-05-18 03:12:25 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-05-18 03:12:25 -0500 |
commit | fd4d12151ca6b034307f8eba345fbef97a3cbfaf (patch) | |
tree | 2fd264d0d0500192dc1f2c649e76fc379d0bbd59 /src/bondwizard.cpp | |
parent | 8fdae616e94a37d5abf2d8a02fcff8a93d2f2ed1 (diff) | |
download | kcmldap-fd4d12151ca6b034307f8eba345fbef97a3cbfaf.tar.gz kcmldap-fd4d12151ca6b034307f8eba345fbef97a3cbfaf.zip |
Add skeleton wizards and dialogs
Diffstat (limited to 'src/bondwizard.cpp')
-rw-r--r-- | src/bondwizard.cpp | 156 |
1 files changed, 156 insertions, 0 deletions
diff --git a/src/bondwizard.cpp b/src/bondwizard.cpp new file mode 100644 index 0000000..b0fe2b7 --- /dev/null +++ b/src/bondwizard.cpp @@ -0,0 +1,156 @@ +/*************************************************************************** + * Copyright (C) 2012 by Timothy Pearson * + * kb9vqf@pearsoncomputing.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. * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include <unistd.h> + +#include <tqpushbutton.h> +#include <tqlabel.h> +#include <tqstring.h> +#include <tqstringlist.h> +#include <tqfile.h> +#include <tqtimer.h> +#include <tqcursor.h> + +#include <ksimpleconfig.h> +#include <kglobal.h> +#include <kglobalsettings.h> +#include <kstandarddirs.h> +#include <klocale.h> +#include <kapplication.h> +#include <klistview.h> +#include <krun.h> +#include <kmessagebox.h> +#include <kconfig.h> + +#include <stdlib.h> + +#include <kdebug.h> + +#include "bondrealmpage.h" +#include "bondfinishpage.h" + +#include "bondwizard.h" +#include "bondwizard.moc" + +BondWizard::BondWizard(TQWidget *parent, const char *name) + : KWizard(parent, name, true) { + + realmpage= new BondRealmPage(this); + addPage( realmpage, i18n( "Step 1: Introduction" ) ); + setHelpEnabled(TQWizard::page(0), false); + + finishpage= new BondFinishPage(this); + addPage(finishpage, i18n( "Step 2: I want it my Way..." ) ); + setHelpEnabled(TQWizard::page(1), false); + + setFinishEnabled(TQWizard::page(1), true); + + setPosition(); +} + +BondWizard::~BondWizard() { +} + + +void BondWizard::next() { + if(currentPage()==realmpage) { + realm_dirty=true; // set the dirty flag, changes done that need reverting + // realmpage->save(); + TQWizard::next(); + } + if(currentPage()==finishpage) { + finishButton()->setFocus(); + } +} + +void BondWizard::slotNext() { + TQWizard::next(); +} + +void BondWizard::back() { + TQWizard::back(); +} + +bool BondWizard::askClose(){ + TQString text; + if (currentPage()==realmpage) { + text = i18n("<p>Are you sure you want to quit the LDAP Bonding Wizard?</p>" + "<p>If yes, click <b>Quit</b> and all changes will be lost." + "<br>If not, click <b>Cancel</b> to return and finish your setup.</p>"); + } else { + text = i18n("<p>Are you sure you want to quit the LDAP Bonding Wizard?</p>" + "<p>If not, click <b>Cancel</b> to return and finish bonding.</p>"); + } + int status = KMessageBox::warningContinueCancel(this, text, i18n("All Changes Will Be Lost"), KStdGuiItem::quit()); + if(status==KMessageBox::Continue){ + setDefaults(); + return true; + } else { + return false; + } +} + +/** the cancel button is connected to the reject() slot of TQDialog, + * so we have to reimplement this here to add a dialogbox to ask if we + * really want to quit the wizard. + */ +void BondWizard::reject(){ + if (askClose()){ + exit(0); + } +} + +void BondWizard::closeEvent(TQCloseEvent* e){ + if ( askClose() ) + exit(0); + else + e->ignore(); +} + +/** maybe call a dialog that the wizard has finished. */ +void BondWizard::accept(){ + exit(0); +} + +/** calls all save functions after resetting all features/ OS/ theme selections to Trinity default */ +void BondWizard::setDefaults(){ +// if(realm_dirty) +// realmpage->save(false); +} + +/** there seems to be a bug in TQWizard, that makes this evil hack necessary */ +void BondWizard::setPosition() { + TQSize hint = realmpage->sizeHint(); + TQSize finish_size = finishpage->sizeHint(); + + // get the width of the broadest child-widget + if ( hint.width() < finish_size.width() ) + hint.setWidth(finish_size.width()); + + // get the height of the highest child-widget + if ( hint.height() < finish_size.height() ) + hint.setHeight(finish_size.height()); + + // set the position + TQRect rect = KGlobalSettings::desktopGeometry(TQCursor::pos()); + int w = rect.x() + (rect.width() - hint.width())/2 - 9; + int h = rect.y() + (rect.height() - hint.height())/2; + move(w, h); +} |