actionmanager.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <klocale.h>
00023 #include <kstatusbar.h>
00024 #include <kdebug.h>
00025 #include <kglobal.h>
00026 #include <kconfig.h>
00027
00028 #include "actionmanager.h"
00029
00030 using namespace KSync;
00031
00032 ActionManager::ActionManager( KActionCollection *actionCollection )
00033 : mActionCollection( actionCollection ), mView( 0 )
00034 {
00035 }
00036
00037 ActionManager::~ActionManager()
00038 {
00039 writeConfig();
00040 }
00041
00042 void ActionManager::setView( KitchenSync *view )
00043 {
00044 mView = view;
00045 }
00046
00047 void ActionManager::initActions()
00048 {
00049 if ( !mView ) {
00050 kdError() << "Call KSync::ActionManager::setView() before "
00051 << "KSync::ActionManager::initActions()." << endl;
00052 return;
00053 }
00054
00055 new KAction( i18n("Synchronize" ), "reload", 0, mView, SLOT( slotSync() ),
00056 mActionCollection, "sync" );
00057
00058 new KAction( i18n("Configure Profiles..."), "configure", 0,
00059 mView, SLOT( configureProfiles() ),
00060 mActionCollection, "config_profile" );
00061
00062 new KAction( i18n("Configure Current Profile..."), "configure", 0,
00063 mView, SLOT( configureCurrentProfile() ),
00064 mActionCollection, "config_current" );
00065
00066 m_profAct = new KSelectAction( i18n("Profile"), KShortcut(), mView,
00067 SLOT( activateProfile() ),
00068 mActionCollection, "select_prof");
00069
00070 KStdAction::preferences( mView, SLOT( slotPreferences() ),
00071 mActionCollection );
00072 }
00073
00074 int ActionManager::currentProfile()
00075 {
00076 return m_profAct->currentItem();
00077 }
00078
00079 void ActionManager::setProfiles( const QStringList &profiles )
00080 {
00081 m_profAct->setItems( profiles );
00082 }
00083
00084 void ActionManager::readConfig()
00085 {
00086 KConfig *cfg = KGlobal::config();
00087 cfg->setGroup( "Profiles" );
00088 int currentProfile = cfg->readNumEntry( "CurrentProfile", 0 );
00089 m_profAct->setCurrentItem( currentProfile );
00090 }
00091
00092 void ActionManager::writeConfig()
00093 {
00094 KConfig *cfg = KGlobal::config();
00095 cfg->setGroup( "Profiles" );
00096 int currentProfile = m_profAct->currentItem();
00097 cfg->writeEntry( "CurrentProfile", currentProfile );
00098 cfg->sync();
00099 }
This file is part of the documentation for kitchensync Library Version 3.3.2.