Author: tgoettlicher
Date: Wed Feb 6 12:17:34 2008
New Revision: 44182
URL: http://svn.opensuse.org/viewcvs/yast?rev=44182&view=rev
Log:
fix build
Added:
branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/
branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/CMakeLists.txt
branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/
branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/CMakeLists.txt
branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/FindLibXKlavier.cmake
branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/FindPAM.cmake
branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/FindRAW1394.cmake
branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/FindSensors.cmake
branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/UnixAuth.cmake
branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/kcmultiwidget.cpp
Added: branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/CMakeLists.txt?rev=44182&view=auto
==============================================================================
--- branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/CMakeLists.txt (added)
+++ branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/CMakeLists.txt Wed Feb 6 12:17:34 2008
@@ -0,0 +1,3 @@
+
+add_subdirectory(modules)
+
Added: branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/CMakeLists.txt?rev=44182&view=auto
==============================================================================
--- branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/CMakeLists.txt (added)
+++ branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/CMakeLists.txt Wed Feb 6 12:17:34 2008
@@ -0,0 +1,8 @@
+# install the cmake files
+
+file(GLOB cmakeFiles "${CMAKE_CURRENT_SOURCE_DIR}/*.cmake")
+
+set(module_install_dir ${DATA_INSTALL_DIR}/cmake/modules )
+
+install( FILES ${cmakeFiles} DESTINATION ${module_install_dir} )
+
Added: branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/FindLibXKlavier.cmake
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/FindLibXKlavier.cmake?rev=44182&view=auto
==============================================================================
--- branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/FindLibXKlavier.cmake (added)
+++ branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/FindLibXKlavier.cmake Wed Feb 6 12:17:34 2008
@@ -0,0 +1,50 @@
+# - Try to find LibXKlavier
+# Once done this will define
+#
+# LIBXKLAVIER_FOUND - system has LibXKlavier
+# LIBXKLAVIER_LIBRARIES - the libraries needed to use LibXKlavier
+# LIBXKLAVIER_DEFINITIONS - Compiler switches required for using LibXKlavier
+
+if (LIBXKLAVIER_DEFINITIONS AND LIBXKLAVIER_LIBRARIES)
+
+ # in cache already
+ SET(LIBXKLAVIER_FOUND TRUE)
+
+else (LIBXKLAVIER_DEFINITIONS AND LIBXKLAVIER_LIBRARIES)
+
+ IF (NOT WIN32)
+ # use pkg-config to get the directories and then use these values
+ # in the FIND_PATH() and FIND_LIBRARY() calls
+ INCLUDE(UsePkgConfig)
+ PKGCONFIG(libxklavier _LibXKlavierIncDir _LibXKlavierLinkDir _LibXKlavierLinkFlags _LibXKlavierCflags)
+
+ if(_LibXKlavierLinkFlags)
+ # find again pkg-config, to query it about libxklavier version
+ FIND_PROGRAM(PKGCONFIG_EXECUTABLE NAMES pkg-config )
+
+ # query pkg-config asking for a libxklavier >= 3.0
+ EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS --atleast-version=3.0 libxklavier RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _pkgconfigDevNull )
+ if(_return_VALUE STREQUAL "0")
+ set(LIBXKLAVIER_DEFINITIONS ${_LibXKlavierCflags})
+ endif(_return_VALUE STREQUAL "0")
+ endif(_LibXKlavierLinkFlags)
+
+ ENDIF (NOT WIN32)
+
+# FIND_PATH(LIBXKLAVIER_INCLUDE_DIR libxklavier/xklavier.h
+# PATHS
+# ${_LibXKlavierIncDir}
+# PATH_SUFFIXES libxklavier
+# )
+
+ FIND_LIBRARY(LIBXKLAVIER_LIBRARIES NAMES xklavier libxklavier
+ PATHS
+ ${_LibXKlavierLinkDir}
+ )
+
+ include(FindPackageHandleStandardArgs)
+ FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXKlavier DEFAULT_MSG LIBXKLAVIER_DEFINITIONS LIBXKLAVIER_LIBRARIES )
+
+ MARK_AS_ADVANCED(LIBXKLAVIER_DEFINITIONS LIBXKLAVIER_LIBRARIES)
+
+endif (LIBXKLAVIER_DEFINITIONS AND LIBXKLAVIER_LIBRARIES)
Added: branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/FindPAM.cmake
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/FindPAM.cmake?rev=44182&view=auto
==============================================================================
--- branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/FindPAM.cmake (added)
+++ branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/FindPAM.cmake Wed Feb 6 12:17:34 2008
@@ -0,0 +1,74 @@
+# - Try to find the PAM libraries
+# Once done this will define
+#
+# PAM_FOUND - system has pam
+# PAM_INCLUDE_DIR - the pam include directory
+# PAM_LIBRARIES - libpam library
+
+if (PAM_INCLUDE_DIR AND PAM_LIBRARY)
+ # Already in cache, be silent
+ set(PAM_FIND_QUIETLY TRUE)
+endif (PAM_INCLUDE_DIR AND PAM_LIBRARY)
+
+find_path(PAM_INCLUDE_DIR NAMES security/pam_appl.h pam/pam_appl.h)
+find_library(PAM_LIBRARY pam)
+find_library(DL_LIBRARY dl)
+
+if (PAM_INCLUDE_DIR AND PAM_LIBRARY)
+ set(PAM_FOUND TRUE)
+ if (DL_LIBRARY)
+ set(PAM_LIBRARIES ${PAM_LIBRARY} ${DL_LIBRARY})
+ else (DL_LIBRARY)
+ set(PAM_LIBRARIES ${PAM_LIBRARY})
+ endif (DL_LIBRARY)
+
+ if (EXISTS ${PAM_INCLUDE_DIR}/pam/pam_appl.h)
+ # darwin claims to be something special
+ set(HAVE_PAM_PAM_APPL_H 1)
+ endif (EXISTS ${PAM_INCLUDE_DIR}/pam/pam_appl.h)
+
+ if (NOT DEFINED PAM_MESSAGE_CONST)
+ include(CheckCXXSourceCompiles)
+ # XXX does this work with plain c?
+ check_cxx_source_compiles("
+#if ${HAVE_PAM_PAM_APPL_H}+0
+# include
+#else
+# include
+#endif
+
+static int PAM_conv(
+ int num_msg,
+ const struct pam_message **msg, /* this is the culprit */
+ struct pam_response **resp,
+ void *ctx)
+{
+ return 0;
+}
+
+int main(void)
+{
+ struct pam_conv PAM_conversation = {
+ &PAM_conv, /* this bombs out if the above does not match */
+ 0
+ };
+
+ return 0;
+}
+" PAM_MESSAGE_CONST)
+ endif (NOT DEFINED PAM_MESSAGE_CONST)
+ set(PAM_MESSAGE_CONST ${PAM_MESSAGE_CONST} CACHE BOOL "PAM expects a conversation function with const pam_message")
+
+endif (PAM_INCLUDE_DIR AND PAM_LIBRARY)
+
+if (PAM_FOUND)
+ if (NOT PAM_FIND_QUIETLY)
+ message(STATUS "Found PAM: ${PAM_LIBRARIES}")
+ endif (NOT PAM_FIND_QUIETLY)
+else (PAM_FOUND)
+ if (PAM_FIND_REQUIRED)
+ message(FATAL_ERROR "PAM was not found")
+ endif(PAM_FIND_REQUIRED)
+endif (PAM_FOUND)
+
+mark_as_advanced(PAM_INCLUDE_DIR PAM_LIBRARY DL_LIBRARY PAM_MESSAGE_CONST)
Added: branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/FindRAW1394.cmake
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/FindRAW1394.cmake?rev=44182&view=auto
==============================================================================
--- branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/FindRAW1394.cmake (added)
+++ branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/FindRAW1394.cmake Wed Feb 6 12:17:34 2008
@@ -0,0 +1,20 @@
+# - Try to find the raw1394 directory library
+# Once done this will define
+#
+# RAW1394_FOUND - system has RAW1394
+# RAW1394_INCLUDE_DIR - the RAW1394 include directory
+# RAW1394_LIBRARIES - The libraries needed to use FAM
+
+if(RAW1394_INCLUDE_DIR AND RAW1394_LIBRARIES)
+ set(RAW1394_FIND_QUIETLY TRUE)
+endif(RAW1394_INCLUDE_DIR AND RAW1394_LIBRARIES)
+
+FIND_PATH(RAW1394_INCLUDE_DIR libraw1394/raw1394.h)
+
+FIND_LIBRARY(RAW1394_LIBRARIES NAMES raw1394 )
+
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(RAW1394 DEFAULT_MSG RAW1394_LIBRARIES RAW1394_INCLUDE_DIR)
+
+MARK_AS_ADVANCED(RAW1394_INCLUDE_DIR RAW1394_LIBRARIES)
+
Added: branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/FindSensors.cmake
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/FindSensors.cmake?rev=44182&view=auto
==============================================================================
--- branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/FindSensors.cmake (added)
+++ branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/FindSensors.cmake Wed Feb 6 12:17:34 2008
@@ -0,0 +1,17 @@
+# - Try to find the sensors directory library
+# Once done this will define
+#
+# SENSORS_FOUND - system has SENSORS
+# SENSORS_INCLUDE_DIR - the SENSORS include directory
+# SENSORS_LIBRARIES - The libraries needed to use SENSORS
+
+FIND_PATH(SENSORS_INCLUDE_DIR sensors/sensors.h)
+
+FIND_LIBRARY(SENSORS_LIBRARIES NAMES sensors)
+
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(Sensors DEFAULT_MSG SENSORS_INCLUDE_DIR SENSORS_LIBRARIES )
+MACRO_LOG_FEATURE(SENSORS_FOUND "lm-sensors" "Sensors support for ksysguard" "http://www.lm-sensors.org" FALSE)
+
+MARK_AS_ADVANCED(SENSORS_INCLUDE_DIR SENSORS_LIBRARIES)
+
Added: branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/UnixAuth.cmake
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/UnixAuth.cmake?rev=44182&view=auto
==============================================================================
--- branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/UnixAuth.cmake (added)
+++ branches/tmp/tgoettlicher/yast2_2nd_rewrite/cmake/modules/UnixAuth.cmake Wed Feb 6 12:17:34 2008
@@ -0,0 +1,51 @@
+find_package(PAM)
+
+set(UNIXAUTH_LIBRARIES)
+set(UNIXAUTH_INCLUDE_DIRS)
+
+set(SHADOW_LIBRARIES)
+check_function_exists(getspnam found_getspnam)
+if (found_getspnam)
+ set(HAVE_GETSPNAM 1)
+else (found_getspnam)
+ macro_push_required_vars()
+ set(CMAKE_REQUIRED_LIBRARIES -lshadow)
+ check_function_exists(getspnam found_getspnam_shadow)
+ if (found_getspnam_shadow)
+ set(HAVE_GETSPNAM 1)
+ set(SHADOW_LIBRARIES shadow)
+ check_function_exists(pw_encrypt HAVE_PW_ENCRYPT) # ancient Linux shadow
+ else (found_getspnam_shadow)
+ set(CMAKE_REQUIRED_LIBRARIES -lgen) # UnixWare
+ check_function_exists(getspnam found_getspnam_gen)
+ if (found_getspnam_gen)
+ set(HAVE_GETSPNAM 1)
+ set(SHADOW_LIBRARIES gen)
+ endif (found_getspnam_gen)
+ endif (found_getspnam_shadow)
+ macro_pop_required_vars()
+endif (found_getspnam)
+
+set(CRYPT_LIBRARIES)
+check_library_exists(crypt crypt "" HAVE_CRYPT)
+if (HAVE_CRYPT)
+ set(CRYPT_LIBRARIES crypt)
+ check_include_files(crypt.h HAVE_CRYPT_H)
+endif (HAVE_CRYPT)
+
+if (PAM_FOUND)
+
+ set(HAVE_PAM 1)
+ set(UNIXAUTH_LIBRARIES ${PAM_LIBRARIES})
+ set(UNIXAUTH_INCLUDE_DIRS ${PAM_INCLUDE_DIR})
+
+else (PAM_FOUND)
+
+ if (HAVE_GETSPNAM)
+ set(UNIXAUTH_LIBRARIES ${SHADOW_LIBRARIES})
+ endif (HAVE_GETSPNAM)
+ if (NOT HAVE_PW_ENCRYPT)
+ set(UNIXAUTH_LIBRARIES ${UNIXAUTH_LIBRARIES} ${CRYPT_LIBRARIES})
+ endif (NOT HAVE_PW_ENCRYPT)
+
+endif (PAM_FOUND)
Added: branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/kcmultiwidget.cpp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/kcmultiwidget.cpp?rev=44182&view=auto
==============================================================================
--- branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/kcmultiwidget.cpp (added)
+++ branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/kcmultiwidget.cpp Wed Feb 6 12:17:34 2008
@@ -0,0 +1,392 @@
+/*
+ Copyright (c) 2000 Matthias Elter
+ Copyright (c) 2003 Daniel Molkentin
+ Copyright (c) 2003 Matthias Kretz
+ Copyright (c) 2004 Frans Englich
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+*/
+
+#include "kcmultiwidget.h"
+
+#include
+#include <QProcess>
+#include <QScrollArea>
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "kcmoduleloader.h"
+#include "kcmoduleproxy.h"
+
+/*
+Button usage:
+
+ User1 => Close
+ User2 => Admin (dead in KDE 4)
+*/
+
+class KCMultiWidget::KCMultiWidgetPrivate
+{
+ public:
+ KCMultiWidgetPrivate()
+ : hasRootKCM( false )
+ {}
+
+ bool hasRootKCM;
+};
+
+KCMultiWidget::KCMultiWidget(QWidget *parent, Qt::WindowModality modality)
+ : KPageDialog( parent ),
+ d( new KCMultiWidgetPrivate )
+{
+ InitKIconDialog(i18n("Configure"), modality);
+ init();
+}
+
+// Maybe move into init()?
+void KCMultiWidget::InitKIconDialog(const QString& caption,
+ Qt::WindowModality modality)
+{
+ setCaption(caption);
+ setButtons(KDialog::Help |
+ KDialog::Default |
+ KDialog::Cancel |
+ KDialog::Apply |
+ KDialog::Ok |
+ KDialog::Reset |
+ KDialog::User1);
+ setDefaultButton(KDialog::Ok);
+ setButtonGuiItem(KDialog::User1, KStandardGuiItem::close());
+
+ setWindowModality(modality);
+}
+
+inline void KCMultiWidget::init()
+{
+ // A bit hackish: KCMultiWidget inherits from KPageDialog, but it really is
+ // a widget...
+ setWindowFlags(Qt::Widget);
+
+ connect( this, SIGNAL( finished()), SLOT( dialogClosed()));
+ showButton( Ok, false );
+ showButton( Cancel, false );
+ showButton( Reset, true ); // Reset button
+ showButton( User1, false ); // Close button.
+
+ enableButton(Apply, false);
+ enableButton(Reset, false);
+ enableButton(Default, false);
+ enableButton(Help, false);
+
+ connect( this, SIGNAL(currentPageChanged(KPageWidgetItem*, KPageWidgetItem*)), this, SLOT(slotAboutToShow(KPageWidgetItem*, KPageWidgetItem* )) );
+ setInitialSize(QSize(640,480));
+ setFaceType( Auto );
+ connect( this, SIGNAL(helpClicked()), this, SLOT(slotHelp()) );
+ connect( this, SIGNAL(defaultClicked()), this, SLOT(slotDefault()) );
+ connect( this, SIGNAL(applyClicked()), this, SLOT(slotApply()) );
+ connect( this, SIGNAL(resetClicked()), this, SLOT(slotReset()) );
+ connect( this, SIGNAL(user1Clicked()), this, SLOT(slotClose()) );
+}
+
+KCMultiWidget::~KCMultiWidget()
+{
+ qDeleteAll( m_orphanModules );
+ delete d;
+}
+
+void KCMultiWidget::slotDefault()
+{
+ currentModule()->defaults();
+ clientChanged( true );
+ return;
+}
+
+void KCMultiWidget::slotReset()
+{
+ ModuleList::Iterator end = m_modules.end();
+ currentModule()->load();
+ clientChanged( false );
+}
+
+void KCMultiWidget::apply()
+{
+ QStringList updatedModules;
+ foreach( const CreatedModule &it, m_modules )
+ {
+ KCModuleProxy * m = it.kcm;
+ if( m && m->changed() )
+ {
+ m->save();
+ QStringList names = moduleParentComponents[ m ];
+
+ foreach ( const QString &name , names )
+ {
+ if ( updatedModules.indexOf(name) == -1 )
+ updatedModules.append(name);
+ }
+ }
+ }
+ foreach( const QString &it, updatedModules )
+ {
+ kDebug() << it << " " << ( it );
+ emit configCommitted( it.toLatin1() );
+ }
+ emit configCommitted();
+}
+
+void KCMultiWidget::slotApply()
+{
+ apply();
+}
+
+void KCMultiWidget::slotOk()
+{
+ emit okClicked();
+ apply();
+ accept();
+}
+
+void KCMultiWidget::slotHelp()
+{
+ QString docPath = currentModule()->moduleInfo().docPath();
+
+ KUrl url( KUrl("help:/"), docPath );
+
+ if (url.protocol() == "help" || url.protocol() == "man" || url.protocol() == "info") {
+ QProcess::startDetached("khelpcenter", QStringList() << url.url());
+ } else {
+ KToolInvocation::invokeBrowser( url.url() );
+ }
+}
+
+// Close button
+void KCMultiWidget::slotClose() {
+ emit close();
+}
+
+void KCMultiWidget::clientChanged(bool state)
+{
+ kDebug( 710 ) << state;
+ foreach( const CreatedModule &it, m_modules )
+ if( it.kcm->changed() ) {
+ enableButton( Apply, true );
+ enableButton( Reset, true);
+ return;
+ }
+ enableButton( Apply, false );
+ enableButton( Reset, false);
+}
+
+void KCMultiWidget::addModule(const KCModuleInfo& moduleinfo)
+{
+ if( !moduleinfo.service() ) {
+ kWarning() << "ModuleInfo has no associated KService" ;
+ return;
+ }
+
+ if ( !KAuthorized::authorizeControlModule( moduleinfo.service()->menuId() )) {
+ kWarning() << "Not authorised to load module" ;
+ return;
+ }
+
+ if(moduleinfo.service()->noDisplay()) {
+ return;
+ }
+ KCModuleProxy * module;
+ QScrollArea * moduleScrollArea;
+ if( m_orphanModules.contains( moduleinfo.service() ) )
+ {
+ // the KCModule already exists - it was removed from the dialog in
+ // removeAllModules
+ module = m_orphanModules[ moduleinfo.service() ];
+ m_orphanModules.remove( moduleinfo.service() );
+ kDebug( 710 ) << "Use KCModule from the list of orphans for " <<
+ moduleinfo.moduleName() << ": " << module << endl;
+
+ if( module->changed() ) {
+ clientChanged( true );
+ }
+
+ moduleScrollArea = static_cast( module->parentWidget() );
+ }
+ else
+ {
+ moduleScrollArea = new QScrollArea( this );
+ module = new KCModuleProxy( moduleinfo, moduleScrollArea );
+ moduleScrollArea->setWidget( module );
+ moduleScrollArea->setWidgetResizable( true );
+ moduleScrollArea->setFrameStyle( QFrame::NoFrame );
+ moduleScrollArea->viewport()->setAutoFillBackground(false);
+ module->setAutoFillBackground(false);
+ QStringList parentComponents = moduleinfo.service()->property(
+ "X-KDE-System-Settings-Parent-Category" ).toStringList();
+ moduleParentComponents.insert( module,
+ parentComponents );
+
+ connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool)));
+ }
+
+ CreatedModule cm;
+ cm.kcm = module;
+ cm.service = moduleinfo.service();
+ cm.adminmode = false;
+ cm.buttons = module->buttons();
+ // "root KCMs are gone" says KControl
+ // if ( moduleinfo.needsRootPrivileges() && !d->hasRootKCM &&
+ // !KUser().isSuperUser() ) {/* If we're embedded, it's true */
+ // d->hasRootKCM = true;
+ // cm.adminmode = true;
+ // m_modules.append( cm );
+ // if( dialogface==Plain ) {
+ // slotAboutToShow( page ); // Won't be called otherwise, necessary for adminMode button
+ // }
+ // } else {
+ // m_modules.append( cm );
+ // }
+
+ m_modules.append( cm );
+ if( m_modules.count() == 1 ) {
+ slotAboutToShow( module );
+ }
+ KPageWidgetItem* page = addPage(moduleScrollArea, moduleinfo.moduleName());
+ page->setIcon( KIcon(moduleinfo.icon()) );
+ page->setHeader(moduleinfo.comment());
+}
+
+KCModuleProxy* KCMultiWidget::currentModule()
+{
+ KPageWidgetItem *pageWidget = currentPage();
+ if ( pageWidget == 0 )
+ return 0;
+
+ QScrollArea *scrollArea = qobject_cast( pageWidget->widget() );
+ KCModuleProxy *module = qobject_cast( scrollArea->widget() );
+
+ return module;
+}
+
+void KCMultiWidget::applyOrRevert(KCModuleProxy * module)
+{
+ if( !module || !module->changed() )
+ return;
+
+ int res = KMessageBox::warningYesNo(this,
+ i18n("There are unsaved changes in the active module.\n"
+ "Do you want to apply the changes or discard them?"),
+ i18n("Unsaved Changes"),
+ KStandardGuiItem::apply(),
+ KStandardGuiItem::discard());
+ if (res == KMessageBox::Yes) {
+ slotApply();
+ } else {
+ module->load();
+ clientChanged( false );
+ }
+}
+
+void KCMultiWidget::slotAboutToShow(KPageWidgetItem* current, KPageWidgetItem* before)
+ {
+ if( before != 0 ) {
+ QScrollArea *scrollArea = qobject_cast( before->widget() );
+ KCModuleProxy *module = qobject_cast( scrollArea->widget() );
+ applyOrRevert( module );
+ }
+
+ QWidget* sendingWidget = current->widget();
+ slotAboutToShow(sendingWidget);
+}
+
+void KCMultiWidget::slotAboutToShow(QWidget *page)
+{
+ QList objects = page->findChildren();
+
+ // add fall back
+ objects.append( qobject_cast(page) );
+
+ KCModuleProxy *module = objects.first();
+ if( ! module ) {
+ return;
+ }
+
+ emit ( aboutToShow( module ) );
+
+ int buttons = 0;
+ bool found = false;
+ foreach( const CreatedModule &it, m_modules ) {
+ if( it.kcm==module) {
+ showButton(User2, it.adminmode);
+ buttons = it.buttons;
+ found = true;
+ }
+ }
+ if (!found) {
+ buttons = module->buttons();
+ }
+ //Q_ASSERT(found);
+
+ showButton(Apply, buttons & KCModule::Apply);
+ showButton(Reset, buttons & KCModule::Apply);
+
+ // Close button. No Apply button implies a Close button.
+ showButton(User1, (buttons & KCModule::Apply)==0);
+
+ enableButton( KDialog::Help, buttons & KCModule::Help );
+ enableButton( KDialog::Default, buttons & KCModule::Default );
+
+ disconnect( this, SIGNAL(user3Clicked()), 0, 0 );
+
+ // if (module->moduleInfo().needsRootPrivileges() &&
+ // !module->rootMode() )
+ // { /* Enable the Admin Mode button */
+ // enableButton( User2, true );
+ // connect( this, SIGNAL(user3Clicked()), module, SLOT( runAsRoot() ));
+ // connect( this, SIGNAL(user3Clicked()), SLOT( disableRModeButton() ));
+ // } else {
+ // enableButton( User2, false );
+ // }
+}
+
+void KCMultiWidget::rootExit()
+{
+ enableButton( User2, true);
+}
+
+void KCMultiWidget::disableRModeButton()
+{
+ enableButton( User2, false );
+ connect ( currentModule(), SIGNAL( childClosed() ), SLOT( rootExit() ) );
+}
+
+void KCMultiWidget::slotCancel() {
+ dialogClosed();
+}
+
+void KCMultiWidget::dialogClosed()
+{
+ applyOrRevert( currentModule() );
+}
+
+#include "kcmultiwidget.moc"
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org