Version: (using KDE KDE 3.5.1) Installed from: Debian testing/unstable Packages OS: Linux It would be very superb if the "Manage Files" "Organize" screen would have capabilities of presets. If you use different schemes for different directories or a another scheme in a subfolder this would allow much better organization. for example: i have /music/artist/album [bitrate]/trackno - trackname but also /music/Audiobooks/language/author/... with defined presets of values this would be very handy if something is wrong :) ui suggestion: +-Organize Collection Files -+ | [ preset list ] [+] [-] | | | | [collection ] | | .... | If you press the [+] button a dialog for a name pops up, asking for the presets name and all values in the current dialog are saved under this name. [-] button asks for remove of this preset.
*** Bug 124733 has been marked as a duplicate of this bug. ***
*** This bug has been confirmed by popular vote. ***
That is true, and still there for 2.X
(In reply to comment #3) > That is true, and still there for 2.X What do you mean by "this is true"?
I meant we still don't have any preset available in the organize file dialog in 2-2svn Simon
Because the organize files dialog needs a lot of work :) Simon, check with Teo who has done quite some work on it already.
Oooh, I like this idea. Can't believe I haven't seen it before. Coming right up!
commit df0c6c8494aeca663e67a87c59efc3f819b3c382 Author: Casey Link <unnamedrambler@gmail.com> Date: Sat May 29 17:57:01 2010 -0500 Add the ability to save format presets to the Organize Files dialog. This feature was requested four years ago! BUG: 122672 diff --git a/src/amarokconfig.kcfg b/src/amarokconfig.kcfg index b18b371..4185963 100644 --- a/src/amarokconfig.kcfg +++ b/src/amarokconfig.kcfg @@ -191,6 +191,11 @@ <whatsthis>In basic mode graphical drag/droppable tokens are used to create a filename scheme, in advanced mode the images are replaced with text.</whatsthis> <default>Basic</default> </entry> + <entry key="Format Presets" type="StringList"> + <label>Format Presets</label> + <whatsthis>A list of preset formats (token schemas).</whatsthis> + <default>Default#DELIM#%artist/%album/%track_-_%title#DELIM#selected</default> + </entry> </group> <group name="Playback"> diff --git a/src/dialogs/FilenameLayoutDialog.cpp b/src/dialogs/FilenameLayoutDialog.cpp index 37e92d6..f3a9918 100644 --- a/src/dialogs/FilenameLayoutDialog.cpp +++ b/src/dialogs/FilenameLayoutDialog.cpp @@ -337,6 +337,13 @@ FilenameLayoutDialog::setFileName( QString FileName ) updatePreview(); } +// attempts to set the scheme +void FilenameLayoutDialog::setScheme(const QString& scheme) +{ + inferScheme( scheme ); +} + + //Updates the Filename Preview void FilenameLayoutDialog::updatePreview() //SLOT diff --git a/src/dialogs/FilenameLayoutDialog.h b/src/dialogs/FilenameLayoutDialog.h index 2cc4267..2e20c77 100644 --- a/src/dialogs/FilenameLayoutDialog.h +++ b/src/dialogs/FilenameLayoutDialog.h @@ -91,6 +91,8 @@ class FilenameLayoutDialog */ void setFileName( QString FileName ); + AMAROK_EXPORT void setScheme( const QString &scheme ); + public slots: void onAccept(); diff --git a/src/dialogs/OrganizeCollectionDialog.cpp b/src/dialogs/OrganizeCollectionDialog.cpp index 329f348..bae6ae7 100644 --- a/src/dialogs/OrganizeCollectionDialog.cpp +++ b/src/dialogs/OrganizeCollectionDialog.cpp @@ -29,6 +29,7 @@ #include "ui_OrganizeCollectionDialogBase.h" #include <kcolorscheme.h> +#include <KInputDialog> #include <QDir> @@ -100,6 +101,8 @@ OrganizeCollectionDialog::OrganizeCollectionDialog( const Meta::TrackList &track this, SLOT( slotUpdatePreview() ) ); connect( ui->folderCombo, SIGNAL( currentIndexChanged( const QString & ) ), this, SLOT( slotEnableOk( const QString & ) ) ); + connect( ui->addPresetButton, SIGNAL( clicked( bool ) ), this, SLOT( slotAddFormat() ) ); + connect( ui->removePresetButton, SIGNAL( clicked( bool ) ), this, SLOT( slotRemoveFormat() ) ); slotEnableOk( ui->folderCombo->currentText() ); @@ -372,9 +375,57 @@ OrganizeCollectionDialog::update( const QString & dummy ) void OrganizeCollectionDialog::init() { + populateFormatList(); slotUpdatePreview(); } +void OrganizeCollectionDialog::populateFormatList() +{ + // items are stored in the config list in the following format: + // Label#DELIM#format string#DELIM#selected + // the last item to have the third parameter is the default selected preset + // the third param isnis optional + QStringList presets_raw; + int selected_index = -1; + ui->presetCombo->clear(); + presets_raw = AmarokConfig::formatPresets(); + foreach( QString str, presets_raw ) + { + QStringList items; + items = str.split( "#DELIM#", QString::SkipEmptyParts ); + if( items.size() < 2 ) + continue; + ui->presetCombo->addItem( items.at( 0 ), items.at( 1 ) ); // Label, format string + if( items.size() == 3 ) + selected_index = ui->presetCombo->findData( items.at( 1 ) ); + } + if( selected_index > 0 ) + ui->presetCombo->setCurrentIndex( selected_index ); + slotFormatPresetSelected( selected_index ); + connect( ui->presetCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( slotFormatPresetSelected( int ) ) ); +} + +void OrganizeCollectionDialog::saveFormatList() +{ + QStringList presets; + int n = ui->presetCombo->count(); + int current_idx = ui->presetCombo->currentIndex(); + for( int i = 0; i < n; ++i ) + { + QString item; + if( i == current_idx ) + item = "%1#DELIM#%2#DELIM#selected"; + else + item = "%1#DELIM#%2"; + QString scheme = ui->presetCombo->itemData( i ).toString(); + QString label = ui->presetCombo->itemText( i ); + item = item.arg( label, scheme ); + presets.append( item ); + } + AmarokConfig::setFormatPresets( presets ); +} + + void OrganizeCollectionDialog::slotUpdatePreview() { @@ -384,6 +435,7 @@ OrganizeCollectionDialog::slotUpdatePreview() void OrganizeCollectionDialog::slotDialogAccepted() { + saveFormatList(); AmarokConfig::setOrganizeDirectory( ui->folderCombo->currentText() ); AmarokConfig::setIgnoreThe( ui->ignoreTheCheck->isChecked() ); AmarokConfig::setReplaceSpace( ui->spaceCheck->isChecked() ); @@ -402,4 +454,29 @@ OrganizeCollectionDialog::slotEnableOk( const QString & currentCollectionRoot ) else enableButtonOk( true ); } + +void OrganizeCollectionDialog::slotFormatPresetSelected( int index ) +{ + QString scheme = ui->presetCombo->itemData( index ).toString(); + m_filenameLayoutDialog->setScheme( scheme ); +} + +void OrganizeCollectionDialog::slotAddFormat() +{ + bool ok = false; + QString name = KInputDialog::getText( i18n( "New Format Preset" ), i18n( "Preset Name" ), i18n( "New Preset" ), &ok, this ); + if( !ok ) + return; // user canceled. + QString format = m_filenameLayoutDialog->getParsableScheme(); + ui->presetCombo->insertItem(0, name, format); + ui->presetCombo->setCurrentIndex( 0 ); +} + +void OrganizeCollectionDialog::slotRemoveFormat() +{ + int idx = ui->presetCombo->currentIndex(); + ui->presetCombo->removeItem( idx ); +} + + #endif //AMAROK_ORGANIZECOLLECTIONDIALOG_UI_H diff --git a/src/dialogs/OrganizeCollectionDialog.h b/src/dialogs/OrganizeCollectionDialog.h index 75df8c7..443f4eb 100644 --- a/src/dialogs/OrganizeCollectionDialog.h +++ b/src/dialogs/OrganizeCollectionDialog.h @@ -54,6 +54,10 @@ class AMAROK_EXPORT OrganizeCollectionDialog : public KDialog public slots: void slotUpdatePreview(); void slotDialogAccepted(); + private slots: + void slotFormatPresetSelected( int ); + void slotAddFormat(); + void slotRemoveFormat(); private: QString buildDestination( const QString &format, const Meta::TrackPtr &track ) const; @@ -66,6 +70,8 @@ class AMAROK_EXPORT OrganizeCollectionDialog : public KDialog void update( int dummy ); void update( const QString & dummy ); void init(); + void populateFormatList(); + void saveFormatList(); Ui::OrganizeCollectionDialogBase *ui; FilenameLayoutDialog *m_filenameLayoutDialog; diff --git a/src/dialogs/OrganizeCollectionDialogBase.ui b/src/dialogs/OrganizeCollectionDialogBase.ui index 105f723..b55afa9 100644 --- a/src/dialogs/OrganizeCollectionDialogBase.ui +++ b/src/dialogs/OrganizeCollectionDialogBase.ui @@ -7,8 +7,8 @@ <rect> <x>0</x> <y>0</y> - <width>791</width> - <height>523</height> + <width>700</width> + <height>481</height> </rect> </property> <property name="sizePolicy"> @@ -67,6 +67,87 @@ </layout> </item> <item> + <layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0,0"> + <property name="topMargin"> + <number>0</number> + </property> + <item> + <widget class="QLabel" name="label"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Format Presets:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="presetCombo"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>150</width> + <height>0</height> + </size> + </property> + <property name="toolTip"> + <string/> + </property> + <property name="whatsThis"> + <string>A list of selectable filename scheme/format presets.</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="removePresetButton"> + <property name="toolTip"> + <string>Removes the currently selected format reset</string> + </property> + <property name="text"> + <string>Remove Preset</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="addPresetButton"> + <property name="toolTip"> + <string>Saves the current scheme/format above as a preset.</string> + </property> + <property name="text"> + <string>Save Preset</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>1</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> <widget class="QGroupBox" name="groupBox_2"> <property name="sizePolicy"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> @@ -79,7 +160,7 @@ </property> <layout class="QGridLayout" name="gridLayout"> <property name="sizeConstraint"> - <enum>QLayout::SetFixedSize</enum> + <enum>QLayout::SetDefaultConstraint</enum> </property> <item row="0" column="0"> <widget class="QCheckBox" name="spaceCheck"> @@ -268,6 +349,12 @@ Most people can leave this option enabled as it ensures copying to media devices </item> <item> <widget class="QLabel" name="conflictLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <property name="text"> <string/> </property>