fredag den 25. Juli 2008 01:48:47 skrev Jakob Lund:
> Hi
>
> This patch makes small improvements to the effects selection widget:
> * improved text formatting (long lines no longer truncated in 'name'
> and 'maker' fields)
> * list items now react first time they are clicked
> * expandable items expand when clicked
> * adding a "recently used effects" group that remembers effects across
> sessions by saving to preferences file.
>
> The last bit is technically a violation to the feature freeze (since the
> user will see it) but it's a quite small change, so please try it out. If
> you like I can easily remove that part from the patch.
>
> - Jakob.

OK that patch was wrooong... This is the right one here. Dont' use the other 
one.

Cheers
- J.L.
Index: gui/src/LadspaFXSelector.cpp
===================================================================
--- gui/src/LadspaFXSelector.cpp	(revision 255)
+++ gui/src/LadspaFXSelector.cpp	(working copy)
@@ -25,6 +25,7 @@
 #include <hydrogen/hydrogen.h>
 #include "Skin.h"
 #include <hydrogen/Song.h>
+#include <hydrogen/Preferences.h>
 
 #include <hydrogen/fx/Effects.h>
 
@@ -105,7 +106,7 @@
 	pRootItem->setText( 0, trUtf8("Groups") );
 	m_pGroupsListView->addTopLevelItem( pRootItem );
 	m_pGroupsListView->setItemExpanded( pRootItem, true );
-
+	
 	H2Core::LadspaFXGroup* pFXGroup = Effects::getInstance()->getLadspaFXGroup();
 	for (uint i = 0; i < pFXGroup->getChildList().size(); i++) {
 		H2Core::LadspaFXGroup *pNewGroup = ( pFXGroup->getChildList() )[ i ];
@@ -126,6 +127,9 @@
 	else if (sGroupName == QString("Categorized(LRDF)")) {
 		sGroupName = trUtf8("Categorized (LRDF)");
 	}
+	else if (sGroupName == QString("Recently Used")) {
+		sGroupName = trUtf8("Recently Used");
+	}
 	QTreeWidgetItem* pNewItem = new QTreeWidgetItem( pItem );
 	pNewItem->setText( 0, sGroupName );
 
@@ -153,7 +157,6 @@
 }
 
 
-
 void LadspaFXSelector::pluginSelected()
 {
 #ifdef LADSPA_SUPPORT
@@ -213,13 +216,17 @@
 	m_pCopyrightLbl->setText( QString("") );
 
 	// nothing was selected
-	if ( m_pGroupsListView->selectedItems().size() == 0 ) {
+	if ( currentItem == NULL ) {
 		return;
 	}
+	
+	if ( currentItem->childCount() ) {
+		currentItem->setExpanded( true );
+	}
 
 	QString itemText = currentItem->text( 0 );
 
-	//m_pPluginsListBox->clear();
+	//m_pPluginsListBox->clear(); // ... Why not anyway ? Jakob Lund
 
 	while( m_pPluginsListBox->count() != 0) {
 		m_pPluginsListBox->takeItem( 0 );
Index: gui/src/LadspaFXProperties.cpp
===================================================================
--- gui/src/LadspaFXProperties.cpp	(revision 255)
+++ gui/src/LadspaFXProperties.cpp	(working copy)
@@ -24,6 +24,7 @@
 #include <hydrogen/audio_engine.h>
 #include <hydrogen/Song.h>
 #include <hydrogen/fx/Effects.h>
+#include <hydrogen/Preferences.h>
 #include <hydrogen/IO/AudioOutput.h>
 using namespace H2Core;
 
Index: gui/src/UI/LadspaFXSelector_UI.ui
===================================================================
--- gui/src/UI/LadspaFXSelector_UI.ui	(revision 255)
+++ gui/src/UI/LadspaFXSelector_UI.ui	(working copy)
@@ -31,18 +31,9 @@
     <property name="spacing" >
      <number>6</number>
     </property>
-    <property name="leftMargin" >
+    <property name="margin" >
      <number>0</number>
     </property>
-    <property name="topMargin" >
-     <number>0</number>
-    </property>
-    <property name="rightMargin" >
-     <number>0</number>
-    </property>
-    <property name="bottomMargin" >
-     <number>0</number>
-    </property>
     <item>
      <spacer>
       <property name="orientation" >
@@ -51,7 +42,7 @@
       <property name="sizeType" >
        <enum>QSizePolicy::Expanding</enum>
       </property>
-      <property name="sizeHint" >
+      <property name="sizeHint" stdset="0" >
        <size>
         <width>20</width>
         <height>0</height>
@@ -117,7 +108,7 @@
       <property name="sizeType" >
        <enum>QSizePolicy::Expanding</enum>
       </property>
-      <property name="sizeHint" >
+      <property name="sizeHint" stdset="0" >
        <size>
         <width>20</width>
         <height>0</height>
@@ -216,7 +207,11 @@
      </font>
     </property>
     <property name="text" >
-     <string>Name:</string>
+     <string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd";>
+&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
+p, li { white-space: pre-wrap; }
+&lt;/style>&lt;/head>&lt;body style=" font-family:'DejaVu Sans'; font-size:12pt; font-weight:400; font-style:normal;">
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-weight:600;">Name:&lt;/span>&lt;/p>&lt;/body>&lt;/html></string>
     </property>
    </widget>
    <widget class="QLabel" name="m_nameLbl" >
@@ -225,23 +220,27 @@
       <x>10</x>
       <y>40</y>
       <width>180</width>
-      <height>20</height>
+      <height>41</height>
      </rect>
     </property>
     <property name="text" >
-     <string>### fx name</string>
+     <string>### fx name
+1</string>
     </property>
     <property name="alignment" >
      <set>Qt::AlignTop</set>
     </property>
+    <property name="wordWrap" >
+     <bool>true</bool>
+    </property>
    </widget>
    <widget class="QLabel" name="textLabel2" >
     <property name="geometry" >
      <rect>
       <x>10</x>
-      <y>60</y>
+      <y>81</y>
       <width>180</width>
-      <height>20</height>
+      <height>19</height>
      </rect>
     </property>
     <property name="font" >
@@ -255,14 +254,18 @@
      </font>
     </property>
     <property name="text" >
-     <string>Label:</string>
+     <string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd";>
+&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
+p, li { white-space: pre-wrap; }
+&lt;/style>&lt;/head>&lt;body style=" font-family:'DejaVu Sans'; font-size:12pt; font-weight:400; font-style:normal;">
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-weight:600;">Label:&lt;/span>&lt;/p>&lt;/body>&lt;/html></string>
     </property>
    </widget>
    <widget class="QLabel" name="m_labelLbl" >
     <property name="geometry" >
      <rect>
       <x>10</x>
-      <y>80</y>
+      <y>101</y>
       <width>180</width>
       <height>20</height>
      </rect>
@@ -273,12 +276,15 @@
     <property name="alignment" >
      <set>Qt::AlignTop</set>
     </property>
+    <property name="wordWrap" >
+     <bool>false</bool>
+    </property>
    </widget>
    <widget class="QLabel" name="textLabel3" >
     <property name="geometry" >
      <rect>
       <x>10</x>
-      <y>100</y>
+      <y>126</y>
       <width>80</width>
       <height>20</height>
      </rect>
@@ -294,14 +300,18 @@
      </font>
     </property>
     <property name="text" >
-     <string>Type:</string>
+     <string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd";>
+&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
+p, li { white-space: pre-wrap; }
+&lt;/style>&lt;/head>&lt;body style=" font-family:'DejaVu Sans'; font-size:12pt; font-weight:400; font-style:normal;">
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-weight:600;">Type:&lt;/span>&lt;/p>&lt;/body>&lt;/html></string>
     </property>
    </widget>
    <widget class="QLabel" name="textLabel1_2" >
     <property name="geometry" >
      <rect>
       <x>100</x>
-      <y>100</y>
+      <y>126</y>
       <width>90</width>
       <height>20</height>
      </rect>
@@ -317,14 +327,18 @@
      </font>
     </property>
     <property name="text" >
-     <string>ID:</string>
+     <string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd";>
+&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
+p, li { white-space: pre-wrap; }
+&lt;/style>&lt;/head>&lt;body style=" font-family:'DejaVu Sans'; font-size:12pt; font-weight:400; font-style:normal;">
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-weight:600;">ID:&lt;/span>&lt;/p>&lt;/body>&lt;/html></string>
     </property>
    </widget>
    <widget class="QLabel" name="m_typeLbl" >
     <property name="geometry" >
      <rect>
       <x>10</x>
-      <y>120</y>
+      <y>146</y>
       <width>80</width>
       <height>20</height>
      </rect>
@@ -340,7 +354,7 @@
     <property name="geometry" >
      <rect>
       <x>100</x>
-      <y>120</y>
+      <y>146</y>
       <width>90</width>
       <height>20</height>
      </rect>
@@ -356,7 +370,7 @@
     <property name="geometry" >
      <rect>
       <x>10</x>
-      <y>140</y>
+      <y>169</y>
       <width>180</width>
       <height>20</height>
      </rect>
@@ -372,34 +386,39 @@
      </font>
     </property>
     <property name="text" >
-     <string>Maker:</string>
+     <string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd";>
+&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
+p, li { white-space: pre-wrap; }
+&lt;/style>&lt;/head>&lt;body style=" font-family:'DejaVu Sans'; font-size:12pt; font-weight:400; font-style:normal;">
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-weight:600;">Maker:&lt;/span>&lt;/p>&lt;/body>&lt;/html></string>
     </property>
    </widget>
    <widget class="QLabel" name="m_pMakerLbl" >
     <property name="geometry" >
      <rect>
       <x>10</x>
-      <y>160</y>
+      <y>189</y>
       <width>180</width>
-      <height>80</height>
+      <height>61</height>
      </rect>
     </property>
     <property name="text" >
      <string>### FX maker
 1
-2
-3
-4</string>
+2</string>
     </property>
     <property name="alignment" >
      <set>Qt::AlignTop</set>
     </property>
+    <property name="wordWrap" >
+     <bool>true</bool>
+    </property>
    </widget>
    <widget class="QLabel" name="textLabel5" >
     <property name="geometry" >
      <rect>
       <x>10</x>
-      <y>240</y>
+      <y>250</y>
       <width>180</width>
       <height>20</height>
      </rect>
@@ -415,33 +434,38 @@
      </font>
     </property>
     <property name="text" >
-     <string>Copyright:</string>
+     <string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd";>
+&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
+p, li { white-space: pre-wrap; }
+&lt;/style>&lt;/head>&lt;body style=" font-family:'DejaVu Sans'; font-size:12pt; font-weight:400; font-style:normal;">
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-weight:600;">Copyright:&lt;/span>&lt;/p>&lt;/body>&lt;/html></string>
     </property>
    </widget>
    <widget class="QLabel" name="m_pCopyrightLbl" >
     <property name="geometry" >
      <rect>
       <x>10</x>
-      <y>260</y>
+      <y>270</y>
       <width>180</width>
-      <height>80</height>
+      <height>71</height>
      </rect>
     </property>
     <property name="text" >
      <string>### copyright
 1
 2
-3
-4</string>
+3</string>
     </property>
     <property name="alignment" >
      <set>Qt::AlignTop</set>
     </property>
+    <property name="wordWrap" >
+     <bool>true</bool>
+    </property>
    </widget>
   </widget>
  </widget>
  <layoutdefault spacing="6" margin="11" />
- <includes/>
  <resources/>
  <connections>
   <connection>
Index: hydrogen.kdevelop
===================================================================
--- hydrogen.kdevelop	(revision 255)
+++ hydrogen.kdevelop	(working copy)
@@ -11,12 +11,12 @@
     </keywords>
     <projectdirectory>.</projectdirectory>
     <absoluteprojectpath>false</absoluteprojectpath>
-    <description/>
+    <description></description>
     <ignoreparts/>
     <secondaryLanguages/>
     <versioncontrol/>
     <projectname>hydrogen</projectname>
-    <defaultencoding/>
+    <defaultencoding></defaultencoding>
   </general>
   <kdevfileview>
     <groups>
@@ -73,12 +73,12 @@
   </kdevdoctreeview>
   <kdevdebugger>
     <general>
-      <dbgshell/>
+      <dbgshell></dbgshell>
       <programargs>-n -V</programargs>
-      <gdbpath/>
-      <configGdbScript/>
-      <runShellScript/>
-      <runGdbScript/>
+      <gdbpath></gdbpath>
+      <configGdbScript></configGdbScript>
+      <runShellScript></runShellScript>
+      <runGdbScript></runGdbScript>
       <breakonloadinglibs>true</breakonloadinglibs>
       <separatetty>true</separatetty>
       <floatingtoolbar>false</floatingtoolbar>
@@ -105,13 +105,13 @@
     <run>
       <directoryradio>executable</directoryradio>
       <customdirectory>/</customdirectory>
-      <mainprogram>/home/comix/hydrogen_svn/trunk_qstring_ovunque</mainprogram>
+      <mainprogram>/home/jakob/hydrogen_svn_245/hydrogen/hydrogengui</mainprogram>
       <programargs>-n -V</programargs>
       <terminal>true</terminal>
       <autocompile>true</autocompile>
       <envvars/>
-      <globaldebugarguments/>
-      <globalcwd>/home/comix/hydrogen_svn/trunk_qstring_ovunque</globalcwd>
+      <globaldebugarguments></globaldebugarguments>
+      <globalcwd>/home/jakob/hydrogen_svn_245/hydrogen</globalcwd>
       <useglobalprogram>true</useglobalprogram>
       <autoinstall>false</autoinstall>
       <autokdesu>false</autokdesu>
@@ -120,7 +120,7 @@
       <abortonerror>true</abortonerror>
       <numberofjobs>1</numberofjobs>
       <dontact>false</dontact>
-      <makebin>make</makebin>
+      <makebin>scons</makebin>
       <prio>0</prio>
       <envvars/>
       <runmultiplejobs>false</runmultiplejobs>
@@ -136,8 +136,7 @@
   </kdevtrollproject>
   <kdevcppsupport>
     <references>
-      <pcs>Qt4</pcs>
-      <pcs>automatic_%2Fhome%2Fcomix%2Fprogetti%2Fhydrogen_svn%2Ftrunk</pcs>
+      <pcs>automatic_%2Fhome%2Fjakob%2Fhydrogen_svn_245%2Fhydrogen</pcs>
     </references>
     <codecompletion>
       <includeGlobalFunctions>true</includeGlobalFunctions>
Index: libs/hydrogen/include/hydrogen/Preferences.h
===================================================================
--- libs/hydrogen/include/hydrogen/Preferences.h	(revision 255)
+++ libs/hydrogen/include/hydrogen/Preferences.h	(working copy)
@@ -264,6 +264,11 @@
 	}
 	void setRecentFiles( std::vector<QString> recentFiles );
 
+	QStringList getRecentFX() {
+		return m_recentFX;
+	}
+	void setMostRecentFX( QString );
+
 	std::vector<QString> getLadspaPath() {
 		return m_ladspaPathVect;
 	}
@@ -438,6 +443,7 @@
 	QString lastSongFilename;	///< Last song used
 	bool hearNewNotes;
 	std::vector<QString> m_recentFiles;
+	QStringList m_recentFX;
 	std::vector<QString> m_ladspaPathVect;
 	bool quantizeEvents;
 	bool recordEvents;
Index: libs/hydrogen/include/hydrogen/fx/Effects.h
===================================================================
--- libs/hydrogen/include/hydrogen/fx/Effects.h	(revision 255)
+++ libs/hydrogen/include/hydrogen/fx/Effects.h	(working copy)
@@ -54,6 +54,9 @@
 	static Effects* m_pInstance;
 	std::vector<LadspaFXInfo*> m_pluginList;
 	LadspaFXGroup* m_pRootGroup;
+	LadspaFXGroup* m_pRecentGroup;
+	
+	void updateRecentGroup();
 
 	LadspaFX* m_FXList[ MAX_FX ];
 
Index: libs/hydrogen/include/hydrogen/fx/LadspaFX.h
===================================================================
--- libs/hydrogen/include/hydrogen/fx/LadspaFX.h	(revision 255)
+++ libs/hydrogen/include/hydrogen/fx/LadspaFX.h	(working copy)
@@ -73,6 +73,11 @@
 	std::vector<LadspaFXGroup*> getChildList() {
 		return m_childGroups;
 	}
+	
+	void clear() {
+		m_childGroups.clear();
+		m_ladspaList.clear();
+	}
 
 private:
 	QString m_sName;
Index: libs/hydrogen/src/preferences.cpp
===================================================================
--- libs/hydrogen/src/preferences.cpp	(revision 255)
+++ libs/hydrogen/src/preferences.cpp	(working copy)
@@ -240,6 +240,17 @@
 				WARNINGLOG( "recentUsedSongs node not found" );
 			}
 
+			TiXmlNode* pRecentFXNode = rootNode->FirstChild( "recentlyUsedEffects" );
+			if ( pRecentFXNode ) {
+				TiXmlNode* pFXNode = 0;
+				for ( pFXNode = pRecentFXNode->FirstChild( "FX" ); pFXNode; pFXNode = pFXNode->NextSibling( "FX" ) ) {
+					QString sFXName = pFXNode->FirstChild()->Value();
+					m_recentFX.push_back( sFXName );
+				}
+			} else {
+				WARNINGLOG( "recentlyUsedEffects node not found" );
+			}
+
 			sServerList.clear();
 			TiXmlNode* pServerListNode = rootNode->FirstChild( "serverList" );
 			if ( pServerListNode ) {
@@ -545,6 +556,17 @@
 		}
 	}
 	rootNode.InsertEndChild( recentUsedSongsNode );
+	
+	TiXmlElement recentFXNode( "recentlyUsedEffects" );
+	{
+		int nFX = 0;
+		QString FXname;
+		foreach( FXname, m_recentFX ) {
+			LocalFileMng::writeXmlString( &recentFXNode, "FX", FXname );
+			if ( ++nFX > 10 ) break;
+		}
+	}
+	rootNode.InsertEndChild( recentFXNode );
 
 
 	std::list<QString>::const_iterator cur_Server;
@@ -827,8 +849,16 @@
 }
 
 
+void Preferences::setMostRecentFX( QString FX_name )
+{
+	int pos = m_recentFX.indexOf( FX_name );
+	
+	if ( pos != -1 )
+		m_recentFX.removeAt( pos );
+	
+	m_recentFX.push_front( FX_name );
+}
 
-
 void Preferences::setRecentFiles( std::vector<QString> recentFiles )
 {
 	// find single filenames. (skip duplicates)
Index: libs/hydrogen/src/fx/effects.cpp
===================================================================
--- libs/hydrogen/src/fx/effects.cpp	(revision 255)
+++ libs/hydrogen/src/fx/effects.cpp	(working copy)
@@ -48,6 +48,7 @@
 Effects::Effects()
 		: Object( "Effects" )
 		, m_pRootGroup( NULL )
+		, m_pRecentGroup( NULL )
 {
 	//INFOLOG( "INIT" );
 
@@ -74,8 +75,8 @@
 Effects::~Effects()
 {
 	//INFOLOG( "DESTROY" );
-	delete getLadspaFXGroup();
-
+	if ( m_pRootGroup != NULL ) delete m_pRootGroup;
+	
 	//INFOLOG( "destroying " + to_string( m_pluginList.size() ) + " LADSPA plugins" );
 	for ( unsigned i = 0; i < m_pluginList.size(); i++ ) {
 		delete m_pluginList[i];
@@ -111,7 +112,13 @@
 	}
 
 	m_FXList[ nFX ] = pFX;
+	
+	if ( pFX != NULL ) {
+		Preferences::getInstance()->setMostRecentFX( pFX->getPluginName() );
+		updateRecentGroup();
+	}
 
+
 	AudioEngine::get_instance()->unlock();
 }
 
@@ -231,6 +238,11 @@
 	}
 
 	m_pRootGroup = new LadspaFXGroup( "Root" );
+	
+	// Adding recent FX.
+	m_pRecentGroup = new LadspaFXGroup( "Recently Used" );
+	m_pRootGroup->addChild( m_pRecentGroup );
+	updateRecentGroup();
 
 	LadspaFXGroup *pUncategorizedGroup = new LadspaFXGroup( "Uncategorized" );
 	m_pRootGroup->addChild( pUncategorizedGroup );
@@ -273,7 +285,25 @@
 	return m_pRootGroup;
 }
 
+void Effects::updateRecentGroup()
+{
+	if ( m_pRecentGroup == NULL )
+		return;  // Too early :s
+	
+	m_pRecentGroup->clear();
+	
 
+	QString sRecent; // The recent fx names sit in the preferences object
+	foreach ( sRecent, Preferences::getInstance()->getRecentFX() ) {
+		for ( std::vector<LadspaFXInfo*>::iterator i = m_pluginList.begin(); i < m_pluginList.end(); i++ ) {
+			if ( sRecent == (*i)->m_sName ) {
+				m_pRecentGroup->addLadspaInfo( *i );
+				break;
+			}
+		}
+	}
+}
+
 #ifdef LRDF_SUPPORT
 
 
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Hydrogen-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hydrogen-devel

Reply via email to