From 65f5e7cb4d09977affa95100ef20ddbfa4620a34 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Fri, 1 Feb 2013 23:11:34 -0600 Subject: Rename many classes and header files to avoid conflicts with KDE4 --- kiosktool/profilePropsPage.cpp | 234 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 234 insertions(+) create mode 100644 kiosktool/profilePropsPage.cpp (limited to 'kiosktool/profilePropsPage.cpp') diff --git a/kiosktool/profilePropsPage.cpp b/kiosktool/profilePropsPage.cpp new file mode 100644 index 0000000..d90d131 --- /dev/null +++ b/kiosktool/profilePropsPage.cpp @@ -0,0 +1,234 @@ +/* + * profilePropsPage.cpp + * + * Copyright (C) 2004 Waldo Bastian + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 "profilePropsPage.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "kioskrun.h" +#include "kiosksync.h" + +static TQStringList userList() +{ + KUser thisUser; + TQStringList result; + result << thisUser.loginName(); + result << "root"; + + TDEConfig *config = kapp->config(); + config->setGroup("General"); + result += config->readListEntry("PreviousUsers"); + result.sort(); + + // Remove dupes + TQStringList::Iterator nextIt = result.begin(); + for(TQStringList::Iterator it = result.begin(); + it != result.end(); it = nextIt) + { + nextIt = it; + nextIt++; + + if ((nextIt != result.end()) && ((*it) == (*nextIt))) + result.remove(it); + } + + return result; +} + + +ProfilePropsPage::ProfilePropsPage(TQWidget *parent, const TQString &profile) + : ProfilePropsPageUI(parent), PageWidget(this), m_profile(profile) +{ +} + +ProfilePropsPage::~ProfilePropsPage() +{ +} + +void ProfilePropsPage::slotProfileNameChanged() +{ + TQString profile = editProfileName->text(); + if (m_fixedProfileDir) + { + TQString profilePrefix = KioskRun::self()->getProfilePrefix(); + TQString installDir = profilePrefix+profile+"/"; + labelInstallDir->setText(installDir); + } +// TODO: enableButtonOK(!profile.isEmpty()); +} + +void ProfilePropsPage::load() +{ + bool bNewProfile = false; + if (m_profile.isEmpty()) + { + m_profile = KioskRun::self()->newProfile(); + bNewProfile = true; + } + + TQString profilePrefix = KioskRun::self()->getProfilePrefix(); + m_fixedProfileDir = !profilePrefix.isEmpty(); + connect(editProfileName, TQT_SIGNAL(textChanged(const TQString&)), + this, TQT_SLOT(slotProfileNameChanged())); + +#if 0 + connect(kurlInstallDir, TQT_SIGNAL(textChanged(const TQString&)), + this, TQT_SLOT(updateButtons())); +#endif + + comboUser->setEditable(true); + comboUser->insertStringList(userList()); + + TQRegExp rx( "[^/ :]*" ); + TQValidator* validator = new TQRegExpValidator( rx, this ); + + editProfileName->setValidator(validator); + editProfileName->setFocus(); + + TQString description; + TQString installDir; + TQString installUser; + + KioskRun::self()->getProfileInfo(m_profile, description, installDir, installUser); + + if (!bNewProfile) + { + m_origProfile = m_profile; + m_origInstallDir = installDir; + } + + editProfileName->setText(m_profile); + editDescription->setText(description); + if (m_fixedProfileDir) + { + delete kurlInstallDir; + labelInstallDir->setReadOnly(true); + labelInstallDir->setText(installDir); + setTabOrder(editDescription, comboUser); + setTabOrder(comboUser, labelInstallDir); + } + else + { + delete labelInstallDir; + kurlInstallDir->setMode(KFile::Directory); + kurlInstallDir->setURL(installDir); + setTabOrder(editDescription, comboUser); + setTabOrder(comboUser, kurlInstallDir); + } + comboUser->setCurrentText(installUser); +} + +bool ProfilePropsPage::save() +{ + TQString user = comboUser->currentText(); + KUser userInfo(user); + if (!userInfo.isValid()) + { + KMessageBox::sorry(this, + i18n("The user %1 is not an existing user.").arg(user)); + comboUser->setFocus(); + return false; + } + + m_profile = editProfileName->text(); + TQString description = editDescription->text(); + TQString installDir; + if (m_fixedProfileDir) + { + installDir = labelInstallDir->text(); + } + else + { + installDir = kurlInstallDir->url(); + } + + if (!installDir.endsWith("/")) + installDir.append("/"); + + if (!m_origInstallDir.isEmpty() && (installDir != m_origInstallDir)) + { + KioskSync origInstallDir; + origInstallDir.addDir(m_origInstallDir, KURL()); + TQStringList fileList = origInstallDir.listFiles(); + fileList.remove(".kdeprofile"); + if (!fileList.isEmpty()) + { + int msgResult = KMessageBox::warningContinueCancelList(this, + i18n("The directory for this profile has changed " + "from %1 to %2.

" + "The following files under %3 will be moved to %4") + .arg(m_origInstallDir, installDir, m_origInstallDir, installDir), + fileList, + i18n("Profile Directory Changed")); + if (msgResult != KMessageBox::Continue) + return false; + } + KioskRun::self()->setUser(user); + if (!KioskRun::self()->move(m_origInstallDir, installDir, fileList)) + return false; + if (TQDir(m_origInstallDir).exists()) + { + if (!KioskRun::self()->remove(m_origInstallDir)) + return false; + } + } + + TQString installUser = user; + + bool result = KioskRun::self()->setProfileInfo( m_profile, description, installDir, installUser); + + if (result && !m_origProfile.isEmpty() && (m_origProfile != m_profile)) + { + result = KioskRun::self()->deleteProfile( m_origProfile, false ); + } + + // Store this user for easy access later + TDEConfig *config = kapp->config(); + config->setGroup("General"); + TQStringList previousUsers= config->readListEntry("PreviousUsers"); + if (!previousUsers.contains(user)) + { + previousUsers << user; + config->writeEntry("PreviousUsers", previousUsers); + config->sync(); + } + + return result; +} + +void ProfilePropsPage::setFocus() +{ + editProfileName->setFocus(); +} + +TQString ProfilePropsPage::subCaption() +{ + return TQString(); +} + +#include "profilePropsPage.moc" -- cgit v1.2.3