[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/multimedia/amarok/src
From:       Mark Kretschmann <markey () web ! de>
Date:       2006-01-22 17:20:59
Message-ID: 1137950459.895437.26538.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 501345 by markey:

* Remove the option "Restart running scripts on next app start". It was fairly \
pointless the way it worked. Scripts are now always being restarted. Perhaps it would \
make sense to introduce a per script "autorun" setting, I'm not sure. Gimmick or \
                useful?
* Remove some code duplication wrt script termination.



 M  +24 -30    scriptmanager.cpp  
 M  +3 -0      scriptmanager.h  
 M  +2 -32     scriptmanagerbase.ui  


--- trunk/extragear/multimedia/amarok/src/scriptmanager.cpp #501344:501345
@@ -180,9 +180,7 @@
     ScriptMap::Iterator end( m_scripts.end() );
     for( it = m_scripts.begin(); it != end; ++it ) {
         if( it.data().process ) {
-            it.data().process->kill(); // Sends SIGTERM
-            it.data().process->detach();
-            delete it.data().process;
+            terminateProcess( &it.data().process );
             runningScripts << it.key();
         }
     }
@@ -190,7 +188,6 @@
     // Save config
     KConfig* const config = amaroK::config( "ScriptManager" );
     config->writeEntry( "Running Scripts", runningScripts );
-    config->writeEntry( "Auto Run", m_gui->checkBox_autoRun->isChecked() );
 
     s_instance = 0;
 }
@@ -280,20 +277,14 @@
     // Handle auto-run:
 
     KConfig* const config = amaroK::config( "ScriptManager" );
-    const bool autoRun = config->readBoolEntry( "Auto Run", false );
-    m_gui->checkBox_autoRun->setChecked( autoRun );
+    const QStringList runningScripts = config->readListEntry( "Running Scripts" );
 
-    if( autoRun ) {
-        const QStringList runningScripts = config->readListEntry( "Running Scripts" \
                );
-
-        QStringList::ConstIterator it;
-        QStringList::ConstIterator end( runningScripts.end() );
-        for( it = runningScripts.begin(); it != end; ++it ) {
-            if( m_scripts.contains( *it ) ) {
-                debug() << "Auto-running script: " << *it << endl;
-                m_gui->listView->setCurrentItem( m_scripts[*it].li );
-                slotRunScript();
-            }
+    end = runningScripts.end();
+    for( it = runningScripts.begin(); it != end; ++it ) {
+        if( m_scripts.contains( *it ) ) {
+            debug() << "Auto-running script: " << *it << endl;
+            m_gui->listView->setCurrentItem( m_scripts[*it].li );
+            slotRunScript();
         }
     }
 
@@ -456,16 +447,11 @@
         if( it.data().url.directory() == directory )
             keys << it.key();
 
-    // Kill script processes, remove entries from script list
+    // Terminate script processes, remove entries from script list
     QStringList::Iterator itKeys;
     for( itKeys = keys.begin(); itKeys != keys.end(); ++itKeys ) {
         delete m_scripts[*itKeys].li;
-        if( m_scripts[*itKeys].process ) {
-            // Terminate script process (with SIGTERM)
-            m_scripts[*itKeys].process->kill();
-            m_scripts[*itKeys].process->detach();
-            delete m_scripts[*itKeys].process;
-        }
+        terminateProcess( &m_scripts[*itKeys].process );
         m_scripts.erase( *itKeys );
     }
 }
@@ -519,12 +505,7 @@
     if( m_scripts.find( name ) == m_scripts.end() )
         return;
 
-    // Terminate script process (with SIGTERM)
-    m_scripts[name].process->kill();
-    m_scripts[name].process->detach();
-
-    delete m_scripts[name].process;
-    m_scripts[name].process = 0;
+    terminateProcess( &m_scripts[name].process );
     m_scripts[name].log = QString::null;
     slotCurrentChanged( m_gui->listView->currentItem() );
 
@@ -681,6 +662,19 @@
 ////////////////////////////////////////////////////////////////////////////////
 
 void
+ScriptManager::terminateProcess( KProcIO** proc )
+{
+    if( *proc ) {
+        (*proc)->kill(); // Sends SIGTERM
+        (*proc)->detach();
+
+        delete *proc;
+        *proc = 0;
+    }
+}
+
+
+void
 ScriptManager::notifyScripts( const QString& message )
 {
     DEBUG_BLOCK
--- trunk/extragear/multimedia/amarok/src/scriptmanager.h #501344:501345
@@ -117,6 +117,9 @@
         void scriptFinished( KProcess* process );
 
     private:
+        /** Terminates a process with SIGTERM and deletes the KProcIO object */
+        void terminateProcess( KProcIO** proc );
+
         /** Sends a string message to all running scripts */
         void notifyScripts( const QString& message );
 
--- trunk/extragear/multimedia/amarok/src/scriptmanagerbase.ui #501344:501345
@@ -8,8 +8,8 @@
         <rect>
             <x>0</x>
             <y>0</y>
-            <width>366</width>
-            <height>292</height>
+            <width>367</width>
+            <height>237</height>
         </rect>
     </property>
     <property name="caption">
@@ -19,20 +19,6 @@
         <property name="name">
             <cstring>unnamed</cstring>
         </property>
-        <widget class="Line" row="9" column="0" rowspan="1" colspan="2">
-            <property name="name">
-                <cstring>line2</cstring>
-            </property>
-            <property name="frameShape">
-                <enum>HLine</enum>
-            </property>
-            <property name="frameShadow">
-                <enum>Sunken</enum>
-            </property>
-            <property name="orientation">
-                <enum>Horizontal</enum>
-            </property>
-        </widget>
         <widget class="KListView" row="0" column="0" rowspan="9" colspan="1">
             <column>
                 <property name="text">
@@ -139,27 +125,11 @@
                 <string>&amp;Uninstall</string>
             </property>
         </widget>
-        <widget class="QCheckBox" row="10" column="0" rowspan="1" colspan="2">
-            <property name="name">
-                <cstring>checkBox_autoRun</cstring>
-            </property>
-            <property name="text">
-                <string>R&amp;estart running scripts on application startup</string>
-            </property>
-            <property name="toolTip" stdset="0">
-                <string>If enabled, amaroK will automatically restart scripts that \
                were running when you exited the application.</string>
-            </property>
-        </widget>
     </grid>
 </widget>
-<customwidgets>
-</customwidgets>
 <includes>
     <include location="global" impldecl="in implementation">kdialog.h</include>
 </includes>
 <layoutdefaults spacing="6" margin="0"/>
 <layoutfunctions spacing="KDialog::spacingHint"/>
-<includehints>
-    <includehint>klistview.h</includehint>
-</includehints>
 </UI>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic