diff options
author | Anton Khirnov <wyskas@gmail.com> | 2009-03-27 07:50:41 +0100 |
---|---|---|
committer | Anton Khirnov <wyskas@gmail.com> | 2009-03-27 07:50:41 +0100 |
commit | b35c85322b0551eb4536d1d03ec19c388e7f6309 (patch) | |
tree | 1ab4fb173a30e63f72e11a709dfc1532503fa1dd /nephilim/plugins/Library.py | |
parent | d839a1becf09c92206d5c7a299e3fc20a60a6f92 (diff) |
Library: better handling of modes.
Diffstat (limited to 'nephilim/plugins/Library.py')
-rw-r--r-- | nephilim/plugins/Library.py | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/nephilim/plugins/Library.py b/nephilim/plugins/Library.py index e1fe94f..06e2a41 100644 --- a/nephilim/plugins/Library.py +++ b/nephilim/plugins/Library.py @@ -1,3 +1,20 @@ +# +# Copyright (C) 2009 Anton Khirnov <wyskas@gmail.com> +# +# Nephilim is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Nephilim is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Nephilim. If not, see <http://www.gnu.org/licenses/>. +# + from PyQt4 import QtGui, QtCore from PyQt4.QtCore import QVariant @@ -5,12 +22,12 @@ from ..plugin import Plugin class Library(Plugin): o=None - DEFAULTS = {'modes' : 'artist\n'\ - 'artist/album\n'\ - 'artist/date/album\n'\ - 'genre\n'\ - 'genre/artist\n'\ - 'genre/artist/album\n'} + DEFAULTS = {'modes' : ['artist', + 'artist/album', + 'artist/date/album', + 'genre', + 'genre/artist', + 'genre/artist/album']} def _load(self): self.o = LibraryWidget(self) @@ -34,12 +51,19 @@ class Library(Plugin): Plugin.SettingsWidget.__init__(self, plugin) self.setLayout(QtGui.QVBoxLayout()) - self.modes = QtGui.QTextEdit() - self.modes.insertPlainText(self.settings().value(self.plugin.name() + '/modes').toString()) - self.layout().addWidget(self.modes) + self.modes = QtGui.QComboBox() + self.modes.setEditable(True) + for mode in self.settings().value(self.plugin.name() + '/modes').toStringList(): + self.modes.addItem(mode) + self._add_widget(self.modes, 'Modes', 'How should the songs in library be grouped.\n' + 'Should be written in form tag1/tag2/...,\n' + 'using tags supported by MPD.') def save_settings(self): - self.settings().setValue(self.plugin.name() + '/modes', QVariant(self.modes.toPlainText())) + modes = [] + for i in range(0, self.modes.count()): + modes.append(self.modes.itemText(i)) + self.settings().setValue(self.plugin.name() + '/modes', QVariant(modes)) self.plugin.o.refresh_modes() def get_settings_widget(self): @@ -136,7 +160,7 @@ class LibraryWidget(QtGui.QWidget): def refresh_modes(self): self.modes.clear() - for mode in self.settings.value('/modes').toString().split('\n'): + for mode in self.settings.value('/modes').toStringList(): self.modes.addItem(mode) self.modes.setCurrentIndex(self.settings.value('current_mode').toInt()[0]) |