Hello

What really annoyed me, was that kopete always connected with status online 
after starting it. (yes of course when autoconnect was enabled, but I wanted 
that) 

So I wrote this small patch to let the user choose that inital status. 
Actually it would be nice if kopete would use that as well when failing to 
restore a connection on a connection loss. (Sometimes it happens that a 
protocol is just online)

The code in the switch statement should be made cleaner, but I somehow fail at 
that.


Cyrill Helg
diff -Naur kdenetwork/kopete/kopete/config/behavior/behaviorconfig_general.ui kdenetwork.new/kopete/kopete/config/behavior/behaviorconfig_general.ui
--- kdenetwork/kopete/kopete/config/behavior/behaviorconfig_general.ui	2008-06-08 15:15:02.000000000 +0200
+++ kdenetwork.new/kopete/kopete/config/behavior/behaviorconfig_general.ui	2008-06-08 10:58:10.000000000 +0200
@@ -158,9 +158,65 @@
         </property>
        </widget>
       </item>
+
+<item>
+    <widget class="QGroupBox" name="initialStatusGroup" >
+     <property name="title" >
+      <string>Initial status</string>
+     </property>
+     <layout class="QVBoxLayout" >
+      <property name="spacing" >
+       <number>6</number>
+      </property>
+      <property name="leftMargin" >
+       <number>9</number>
+      </property>
+      <property name="topMargin" >
+       <number>9</number>
+      </property>
+      <property name="rightMargin" >
+       <number>9</number>
+      </property>
+      <property name="bottomMargin" >
+       <number>9</number>
+      </property>
+      <item>
+       <widget class="QComboBox" name="kcfg_initialStatus" >
+        <property name="whatsThis" >
+         <string>Set the initial status</string>
+        </property>
+        <item>
+         <property name="text" >
+          <string>Online</string>
+         </property>
+        </item>
+        <item>
+         <property name="text" >
+          <string>Away</string>
+         </property>
+        </item>
+        <item>
+         <property name="text" >
+          <string>Busy</string>
+         </property>
+        </item>
+        <item>
+         <property name="text" >
+          <string>Invisible</string>
+         </property>
+        </item>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+
+
      </layout>
     </widget>
    </item>
+
+
    <item>
     <spacer>
      <property name="orientation" >
@@ -186,6 +242,7 @@
   <tabstop>kcfg_startDocked</tabstop>
   <tabstop>kcfg_useMessageQueue</tabstop>
   <tabstop>kcfg_autoConnect</tabstop>
+  <tabstop>kcfg_initialStatus</tabstop>
  </tabstops>
  <resources/>
  <connections/>
diff -Naur kdenetwork/kopete/kopete/kopeteapplication.cpp kdenetwork.new/kopete/kopete/kopeteapplication.cpp
--- kdenetwork/kopete/kopete/kopeteapplication.cpp	2008-06-08 15:15:02.000000000 +0200
+++ kdenetwork.new/kopete/kopete/kopeteapplication.cpp	2008-06-08 10:52:12.000000000 +0200
@@ -218,8 +218,26 @@
 	// --noconnect not specified?
 	if ( args->isSet( "connect" )  && Kopete::BehaviorSettings::self()->autoConnect() &&
 			( Solid::Networking::status() == Solid::Networking::Unknown ||
-			  Solid::Networking::status() == Solid::Networking::Connected ) )
-		Kopete::AccountManager::self()->setOnlineStatus( Kopete::OnlineStatusManager::Online, QString(), Kopete::AccountManager::ConnectIfOffline );
+			  Solid::Networking::status() == Solid::Networking::Connected ) ){
+
+		switch( Kopete::BehaviorSettings::self()->initialStatus() )
+		{
+		  case Kopete::BehaviorSettings::EnumInitialStatus::Online:
+			Kopete::AccountManager::self()->setOnlineStatus( Kopete::OnlineStatusManager::Online, QString(), Kopete::AccountManager::ConnectIfOffline );
+		  break;
+		  case Kopete::BehaviorSettings::EnumInitialStatus::Away:
+			Kopete::AccountManager::self()->setOnlineStatus( Kopete::OnlineStatusManager::Away, QString(), Kopete::AccountManager::ConnectIfOffline );
+		  break;
+		  case Kopete::BehaviorSettings::EnumInitialStatus::Busy:
+			Kopete::AccountManager::self()->setOnlineStatus( Kopete::OnlineStatusManager::Busy, QString(), Kopete::AccountManager::ConnectIfOffline );
+		  break;
+		  case Kopete::BehaviorSettings::EnumInitialStatus::Invisible:
+			Kopete::AccountManager::self()->setOnlineStatus( Kopete::OnlineStatusManager::Invisible, QString(), Kopete::AccountManager::ConnectIfOffline );
+		  break;
+		}
+	 }
+
+	kDebug(999)<< "initial status set in config: " <<Kopete::BehaviorSettings::self()->initialStatus();

 	QStringList connectArgs = args->getOptionList( "autoconnect" );
 	for ( QStringList::ConstIterator i = connectArgs.begin(); i != connectArgs.end(); ++i )

diff -Naur kdenetwork/kopete/libkopete/kopetebehaviorsettings.kcfg kdenetwork.new/kopete/libkopete/kopetebehaviorsettings.kcfg
--- kdenetwork/kopete/libkopete/kopetebehaviorsettings.kcfg	2008-06-08 15:15:02.000000000 +0200
+++ kdenetwork.new/kopete/libkopete/kopetebehaviorsettings.kcfg	2008-06-08 10:16:01.000000000 +0200
@@ -40,6 +40,16 @@
 			<label>Auto connect on Kopete load.</label>
 			<default>false</default>
 		</entry>
+		<entry key="initialStatus" type="Enum">
+			<label>Initial Status</label>
+			<choices>
+				<choice name="Online" />
+				<choice name="Away" />
+				<choice name="Busy" />
+				<choice name="Invisible" />
+			</choices>
+			<default>Online</default>
+		</entry>
 		<!-- Event Behavior -->
 		<entry key="raiseMessageWindow" type="Bool">
 			<label>Raise message view on new messages.</label>

_______________________________________________
kopete-devel mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/kopete-devel

Reply via email to