00001
00002
00003
00004 #include "kopetebehaviorsettings.h"
00005
00006 #include <kglobal.h>
00007 #include <QtCore/QFile>
00008
00009 using namespace Kopete;
00010
00011 namespace Kopete {
00012 class BehaviorSettingsHelper
00013 {
00014 public:
00015 BehaviorSettingsHelper() : q(0) {}
00016 ~BehaviorSettingsHelper() { delete q; }
00017 BehaviorSettings *q;
00018 };
00019 }
00020 K_GLOBAL_STATIC(BehaviorSettingsHelper, s_globalBehaviorSettings)
00021 BehaviorSettings *BehaviorSettings::self()
00022 {
00023 if (!s_globalBehaviorSettings->q) {
00024 new BehaviorSettings;
00025 s_globalBehaviorSettings->q->readConfig();
00026 }
00027
00028 return s_globalBehaviorSettings->q;
00029 }
00030
00031 BehaviorSettings::BehaviorSettings( )
00032 : KConfigSkeleton( QLatin1String( "kopeterc" ) )
00033 {
00034 Q_ASSERT(!s_globalBehaviorSettings->q);
00035 s_globalBehaviorSettings->q = this;
00036 setCurrentGroup( QLatin1String( "Behavior" ) );
00037
00038 mStartDockedItem = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "startDocked" ), mStartDocked, false );
00039 addItem( mStartDockedItem, QLatin1String( "startDocked" ) );
00040 mShowSystemTrayItem = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "showSystemTray" ), mShowSystemTray, true );
00041 addItem( mShowSystemTrayItem, QLatin1String( "showSystemTray" ) );
00042 mUseMessageStackItem = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "useMessageStack" ), mUseMessageStack, false );
00043 addItem( mUseMessageStackItem, QLatin1String( "useMessageStack" ) );
00044 mUseMessageQueueItem = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "useMessageQueue" ), mUseMessageQueue, true );
00045 addItem( mUseMessageQueueItem, QLatin1String( "useMessageQueue" ) );
00046 mQueueUnreadMessagesItem = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "queueUnreadMessages" ), mQueueUnreadMessages, false );
00047 addItem( mQueueUnreadMessagesItem, QLatin1String( "queueUnreadMessages" ) );
00048 mContactListMouseNavigationItem = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "contactListMouseNavigation" ), mContactListMouseNavigation, false );
00049 addItem( mContactListMouseNavigationItem, QLatin1String( "contactListMouseNavigation" ) );
00050 mReconnectOnDisconnectItem = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "reconnectOnDisconnect" ), mReconnectOnDisconnect, true );
00051 addItem( mReconnectOnDisconnectItem, QLatin1String( "reconnectOnDisconnect" ) );
00052 mAutoConnectItem = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "autoConnect" ), mAutoConnect, false );
00053 addItem( mAutoConnectItem, QLatin1String( "autoConnect" ) );
00054 mRaiseMessageWindowItem = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "raiseMessageWindow" ), mRaiseMessageWindow, false );
00055 addItem( mRaiseMessageWindowItem, QLatin1String( "raiseMessageWindow" ) );
00056 mShowEventsItem = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "showEvents" ), mShowEvents, true );
00057 addItem( mShowEventsItem, QLatin1String( "showEvents" ) );
00058 mQueueOnlyHighlightedMessagesInGroupChatsItem = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "queueOnlyHighlightedMessagesInGroupChats" ), mQueueOnlyHighlightedMessagesInGroupChats, false );
00059 addItem( mQueueOnlyHighlightedMessagesInGroupChatsItem, QLatin1String( "queueOnlyHighlightedMessagesInGroupChats" ) );
00060 mQueueOnlyMessagesOnAnotherDesktopItem = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "queueOnlyMessagesOnAnotherDesktop" ), mQueueOnlyMessagesOnAnotherDesktop, false );
00061 addItem( mQueueOnlyMessagesOnAnotherDesktopItem, QLatin1String( "queueOnlyMessagesOnAnotherDesktop" ) );
00062 mBalloonNotifyIgnoreClosesChatViewItem = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "balloonNotifyIgnoreClosesChatView" ), mBalloonNotifyIgnoreClosesChatView, false );
00063 addItem( mBalloonNotifyIgnoreClosesChatViewItem, QLatin1String( "balloonNotifyIgnoreClosesChatView" ) );
00064 mTrayflashNotifyItem = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "trayflashNotify" ), mTrayflashNotify, true );
00065 addItem( mTrayflashNotifyItem, QLatin1String( "trayflashNotify" ) );
00066 mTrayflashNotifyLeftClickOpensMessageItem = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "trayflashNotifyLeftClickOpensMessage" ), mTrayflashNotifyLeftClickOpensMessage, true );
00067 addItem( mTrayflashNotifyLeftClickOpensMessageItem, QLatin1String( "trayflashNotifyLeftClickOpensMessage" ) );
00068 mTrayflashNotifySetCurrentDesktopToChatViewItem = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "trayflashNotifySetCurrentDesktopToChatView" ), mTrayflashNotifySetCurrentDesktopToChatView, false );
00069 addItem( mTrayflashNotifySetCurrentDesktopToChatViewItem, QLatin1String( "trayflashNotifySetCurrentDesktopToChatView" ) );
00070 mEnableEventsWhileAwayItem = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "enableEventsWhileAway" ), mEnableEventsWhileAway, true );
00071 addItem( mEnableEventsWhileAwayItem, QLatin1String( "enableEventsWhileAway" ) );
00072 QList<KConfigSkeleton::ItemEnum::Choice> valueschatWindowGroupPolicy;
00073 {
00074 KConfigSkeleton::ItemEnum::Choice choice;
00075 choice.name = QLatin1String( "OpenNewWindow" );
00076 valueschatWindowGroupPolicy.append( choice );
00077 }
00078 {
00079 KConfigSkeleton::ItemEnum::Choice choice;
00080 choice.name = QLatin1String( "GroupByAccount" );
00081 valueschatWindowGroupPolicy.append( choice );
00082 }
00083 {
00084 KConfigSkeleton::ItemEnum::Choice choice;
00085 choice.name = QLatin1String( "GroupAll" );
00086 valueschatWindowGroupPolicy.append( choice );
00087 }
00088 {
00089 KConfigSkeleton::ItemEnum::Choice choice;
00090 choice.name = QLatin1String( "GroupByGroup" );
00091 valueschatWindowGroupPolicy.append( choice );
00092 }
00093 {
00094 KConfigSkeleton::ItemEnum::Choice choice;
00095 choice.name = QLatin1String( "GroupByMetaContact" );
00096 valueschatWindowGroupPolicy.append( choice );
00097 }
00098 mChatWindowGroupPolicyItem = new KConfigSkeleton::ItemEnum( currentGroup(), QLatin1String( "chatWindowGroupPolicy" ), mChatWindowGroupPolicy, valueschatWindowGroupPolicy, EnumChatWindowGroupPolicy::OpenNewWindow );
00099 addItem( mChatWindowGroupPolicyItem, QLatin1String( "chatWindowGroupPolicy" ) );
00100 mSpellCheckItem = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "spellCheck" ), mSpellCheck, true );
00101 addItem( mSpellCheckItem, QLatin1String( "spellCheck" ) );
00102 mChatWindowShowSendButtonItem = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "chatWindowShowSendButton" ), mChatWindowShowSendButton, true );
00103 addItem( mChatWindowShowSendButtonItem, QLatin1String( "chatWindowShowSendButton" ) );
00104 mShowDatesItem = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "showDates" ), mShowDates, false );
00105 addItem( mShowDatesItem, QLatin1String( "showDates" ) );
00106 mTruncateContactNameItem = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "truncateContactName" ), mTruncateContactName, false );
00107 addItem( mTruncateContactNameItem, QLatin1String( "truncateContactName" ) );
00108 mTruncateContactNameLengthItem = new KConfigSkeleton::ItemInt( currentGroup(), QLatin1String( "truncateContactNameLength" ), mTruncateContactNameLength, 20 );
00109 addItem( mTruncateContactNameLengthItem, QLatin1String( "truncateContactNameLength" ) );
00110 mChatWindowBufferViewSizeItem = new KConfigSkeleton::ItemInt( currentGroup(), QLatin1String( "chatWindowBufferViewSize" ), mChatWindowBufferViewSize, 250 );
00111 addItem( mChatWindowBufferViewSizeItem, QLatin1String( "chatWindowBufferViewSize" ) );
00112 mHighlightEnabledItem = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "highlightEnabled" ), mHighlightEnabled, true );
00113 addItem( mHighlightEnabledItem, QLatin1String( "highlightEnabled" ) );
00114 mViewPluginItem = new KConfigSkeleton::ItemString( currentGroup(), QLatin1String( "viewPlugin" ), mViewPlugin, QLatin1String( "kopete_chatwindow" ) );
00115 addItem( mViewPluginItem, QLatin1String( "viewPlugin" ) );
00116
00117 setCurrentGroup( QLatin1String( "AutoAway" ) );
00118
00119 mUseAutoAwayItem = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "useAutoAway" ), mUseAutoAway, true );
00120 addItem( mUseAutoAwayItem, QLatin1String( "useAutoAway" ) );
00121 mAutoAwayTimeoutItem = new KConfigSkeleton::ItemInt( currentGroup(), QLatin1String( "autoAwayTimeout" ), mAutoAwayTimeout, 600 );
00122 addItem( mAutoAwayTimeoutItem, QLatin1String( "autoAwayTimeout" ) );
00123 mAutoAwayGoAvailableItem = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "autoAwayGoAvailable" ), mAutoAwayGoAvailable, true );
00124 addItem( mAutoAwayGoAvailableItem, QLatin1String( "autoAwayGoAvailable" ) );
00125 mUseLastAwayMessageItem = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "useLastAwayMessage" ), mUseLastAwayMessage, true );
00126 addItem( mUseLastAwayMessageItem, QLatin1String( "useLastAwayMessage" ) );
00127 mUseCustomAwayMessageItem = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "useCustomAwayMessage" ), mUseCustomAwayMessage, false );
00128 addItem( mUseCustomAwayMessageItem, QLatin1String( "useCustomAwayMessage" ) );
00129 mAutoAwayCustomTitleItem = new KConfigSkeleton::ItemString( currentGroup(), QLatin1String( "autoAwayCustomTitle" ), mAutoAwayCustomTitle, i18n("Away") );
00130 addItem( mAutoAwayCustomTitleItem, QLatin1String( "autoAwayCustomTitle" ) );
00131 mAutoAwayCustomMessageItem = new KConfigSkeleton::ItemString( currentGroup(), QLatin1String( "autoAwayCustomMessage" ), mAutoAwayCustomMessage, i18n("I am gone right now, but I will be back later") );
00132 addItem( mAutoAwayCustomMessageItem, QLatin1String( "autoAwayCustomMessage" ) );
00133
00134 setCurrentGroup( QLatin1String( "ContactList" ) );
00135
00136 mSmoothScrollingItem = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "smoothScrolling" ), mSmoothScrolling, true );
00137 addItem( mSmoothScrollingItem, QLatin1String( "smoothScrolling" ) );
00138
00139 setCurrentGroup( QLatin1String( "ChatWindowSettings" ) );
00140
00141 mAlwaysShowTabsItem = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "AlwaysShowTabs" ), mAlwaysShowTabs, false );
00142 addItem( mAlwaysShowTabsItem, QLatin1String( "AlwaysShowTabs" ) );
00143 }
00144
00145 BehaviorSettings::~BehaviorSettings()
00146 {
00147 }
00148