kitchensync
actionmanager.cpp00001
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 "prefs.h"
00029
00030 #include "actionmanager.h"
00031
00032 using namespace KSync;
00033
00034 ActionManager::ActionManager( KActionCollection *actionCollection )
00035 : mActionCollection( actionCollection ), mView( 0 )
00036 {
00037 }
00038
00039 ActionManager::~ActionManager()
00040 {
00041 writeConfig();
00042 }
00043
00044 void ActionManager::setView( KitchenSync *view )
00045 {
00046 mView = view;
00047 }
00048
00049 void ActionManager::initActions()
00050 {
00051 if ( !mView ) {
00052 kdError() << "Call KSync::ActionManager::setView() before "
00053 << "KSync::ActionManager::initActions()." << endl;
00054 return;
00055 }
00056
00057 new KAction( i18n("Synchronize" ), "reload", 0, mView, SLOT( slotSync() ),
00058 mActionCollection, "sync" );
00059
00060 new KAction( i18n("Configure Profiles..."), "configure", 0,
00061 mView, SLOT( configureProfiles() ),
00062 mActionCollection, "config_profile" );
00063
00064 new KAction( i18n("Configure Current Profile..."), "configure", 0,
00065 mView, SLOT( configureCurrentProfile() ),
00066 mActionCollection, "config_current" );
00067
00068 m_profAct = new KSelectAction( i18n("Profile"), KShortcut(), mView,
00069 SLOT( activateProfile() ),
00070 mActionCollection, "select_prof");
00071
00072 KStdAction::preferences( mView, SLOT( slotPreferences() ),
00073 mActionCollection );
00074 }
00075
00076 int ActionManager::currentProfile()
00077 {
00078 return m_profAct->currentItem();
00079 }
00080
00081 void ActionManager::setProfiles( const QStringList &profiles )
00082 {
00083 m_profAct->setItems( profiles );
00084 }
00085
00086 void ActionManager::readConfig()
00087 {
00088 m_profAct->setCurrentItem( Prefs::instance()->currentProfile() );
00089 }
00090
00091 void ActionManager::writeConfig()
00092 {
00093 Prefs::instance()->setCurrentProfile( m_profAct->currentItem() );
00094 Prefs::instance()->writeConfig();
00095 }
|