<RCC>
<qresource prefix="/icons">
- <file>white/add.png</file>
- <file>white/artists.png</file>
- <file>white/back.png</file>
- <file>white/delete.png</file>
- <file>white/deselect_all.png</file>
- <file>white/dynamic.png</file>
- <file>white/fav.png</file>
- <file>white/forward.png</file>
- <file>white/fullscreen.png</file>
- <file>white/library.png</file>
- <file>white/next.png</file>
- <file>white/pause.png</file>
- <file>white/play.png</file>
- <file>white/playback.png</file>
- <file>white/player.png</file>
- <file>white/playlist.png</file>
- <file>white/playlists.png</file>
- <file>white/prev.png</file>
- <file>white/random_active.png</file>
- <file>white/random_inactive.png</file>
- <file>white/repeat_active.png</file>
- <file>white/repeat_inactive.png</file>
- <file>white/search.png</file>
- <file>white/select_all.png</file>
- <file>white/stop.png</file>
- <file>white/use.png</file>
- <file>white/volume.png</file>
- <file>white/window.png</file>
- <file>white/more.png</file>
- <file>white/unmore.png</file>
- <file>white/more_l.png</file>
- <file>white/unmore_l.png</file>
<file>black/add.png</file>
<file>black/artists.png</file>
<file>black/back.png</file>
<file>black/playlist.png</file>
<file>black/playlists.png</file>
<file>black/prev.png</file>
- <file>black/random_active.png</file>
- <file>black/random_inactive.png</file>
- <file>black/repeat_active.png</file>
- <file>black/repeat_inactive.png</file>
+ <file>black/random_off.png</file>
+ <file>black/random_on.png</file>
+ <file>black/repeat_all.png</file>
+ <file>black/repeat_off.png</file>
+ <file>black/repeat_one.png</file>
<file>black/search.png</file>
<file>black/select_all.png</file>
<file>black/stop.png</file>
<file>black/use.png</file>
<file>black/volume.png</file>
<file>black/window.png</file>
+ <file>white/add.png</file>
+ <file>white/artists.png</file>
+ <file>white/back.png</file>
+ <file>white/delete.png</file>
+ <file>white/deselect_all.png</file>
+ <file>white/dynamic.png</file>
+ <file>white/fav.png</file>
+ <file>white/forward.png</file>
+ <file>white/fullscreen.png</file>
+ <file>white/library.png</file>
+ <file>white/more_l.png</file>
+ <file>white/more.png</file>
+ <file>white/next.png</file>
+ <file>white/pause.png</file>
+ <file>white/play.png</file>
+ <file>white/playback.png</file>
+ <file>white/player.png</file>
+ <file>white/playlist.png</file>
+ <file>white/playlists.png</file>
+ <file>white/prev.png</file>
+ <file>white/random_off.png</file>
+ <file>white/random_on.png</file>
+ <file>white/repeat_all.png</file>
+ <file>white/repeat_off.png</file>
+ <file>white/repeat_one.png</file>
+ <file>white/search.png</file>
+ <file>white/select_all.png</file>
+ <file>white/stop.png</file>
+ <file>white/unmore_l.png</file>
+ <file>white/unmore.png</file>
+ <file>white/use.png</file>
+ <file>white/volume.png</file>
+ <file>white/window.png</file>
</qresource>
</RCC>
connect(ui->playlistsButton, SIGNAL(clicked()), this, SLOT(_playlists_button()));
connect(ui->dynamicButton, SIGNAL(clicked()), this, SLOT(_dynamic_button()));
connect(ui->listView, SIGNAL(clicked(QModelIndex)), this, SLOT(_process_list_click(QModelIndex)));
+ connect(ui->listView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(_process_dblclick(QModelIndex)));
connect(ui->listView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this, SLOT(_process_selection(QItemSelection,QItemSelection)));
connect(ui->addButton, SIGNAL(clicked()), this, SLOT(_add_button()));
ui->listView->setColumnWidth(0, 70);
ui->listView->scrollToTop();
_state = STATE_PLAYLIST_TRACK;
+ _is_dynamic = true;
ui->backButton->setEnabled(true);
ui->useButton->setEnabled(true);
ui->useButton->setIcon(QIcon(":/icons/"+_icons_theme+"/use.png"));
ui->listLabel->setText(QString("Albums by \"%1\"").arg(_current_artist));
break;
case STATE_PLAYLIST_TRACK:
- _playlists_button();
+ if (_is_dynamic) {
+ _dynamic_button();
+ _is_dynamic = false;
+ } else {
+ _playlists_button();
+ }
ui->listView->scrollToTop();
default:
return;
} else {
ui->selectAllButton->setIcon(QIcon(":/icons/"+_icons_theme+"/select_all.png"));
}
+ refresh();
}
void LibraryForm::checkGradient() {
ui->listView->selectionModel()->select(id, QItemSelectionModel::Deselect);
}
}
+
+void LibraryForm::_process_dblclick(QModelIndex id) {
+ if (id.column() == 0)
+ return;
+ if (_state == STATE_TRACK || _state == STATE_PLAYLIST_TRACK) {
+ qWarning() << "double clicked";
+ Playlist cur = _lib->getCurrentPlaylist();
+ Track track = _current_tracks.at(id.row());
+ cur.addTrack(track);
+ _lib->saveCurrentPlaylist(cur);
+ _current_playlist_changed = true;
+ emit addAndPlay(track);
+ ui->listView->clearSelection();
+ }
+}
+
void busy(QString);
void done();
void fullscreen(bool);
+ void addAndPlay(Track);
public slots:
void search(QString);
void nextItem();
void _back_button();
void _use_button();
void _process_list_click(QModelIndex);
+ void _process_dblclick(QModelIndex);
void _process_selection(QItemSelection, QItemSelection);
void _more_button();
Library *_lib;
QStandardItemModel *_model;
LibraryFormListState _state;
+ bool _is_dynamic; // workaround
QString _current_artist;
QString _current_album;
Playlist _current_playlist;
connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(_orientation_changed()));
connect(_player_form, SIGNAL(fullscreen(bool)), this, SLOT(_fullscreen(bool)));
connect(_library_form, SIGNAL(fullscreen(bool)), this, SLOT(_fullscreen(bool)));
+ connect(_library_form, SIGNAL(addAndPlay(Track)), _player_form, SLOT(play(Track)));
_player_form->reload(true);
library();
QString mode = config.getValue("ui/orientation").toString();
int seed = QTime::currentTime().msec();
qsrand(seed);
_random = _config.getValue("playback/random").toBool();
- _repeat = _config.getValue("playback/repeat").toBool();
+ _repeat = (RepeatRule) _config.getValue("playback/repeat").toInt();
_current = -1;
}
stop(); // empty playlist
return;
}
+ if (_repeat == REPEAT_ONE) {
+ _set_source();
+ play();
+ return;
+ }
_history.push(_current % count);
if (!_queue.isEmpty()) {
_current = _queue.dequeue();
_current = _current + 1;
}
}
- if (_random && _history.count() >= count && !_repeat ||
- !_repeat && _current >= count) {
+ if (_random && _history.count() >= count && _repeat == REPEAT_NO||
+ _repeat == REPEAT_NO && _current >= count) {
_history.clear();
stop();
} else {
}
void Player::toggleRepeat() {
- _repeat = !_repeat;
+ if (_repeat == REPEAT_NO) {
+ _repeat = REPEAT_ALL;
+ } else if (_repeat == REPEAT_ALL) {
+ _repeat = REPEAT_ONE;
+ } else if (_repeat == REPEAT_ONE) {
+ _repeat = REPEAT_NO;
+ }
_config.setValue("playback/repeat", _repeat);
}
namespace Playback {
enum PlayerState { PLAYER_STOPPED, PLAYER_PLAYING, PLAYER_PAUSED, PLAYER_LOADING, PLAYER_DONE, PLAYER_ERROR };
+ enum RepeatRule {REPEAT_NO, REPEAT_ALL, REPEAT_ONE};
class Randomizer {
public:
explicit Player(QObject *parent = 0);
bool random() {return _random;}
- bool repeat() {return _repeat;}
+ RepeatRule repeat() {return _repeat;}
int volume() {return (int)(_output->volume()*100 + 0.5);}
Phonon::MediaObject* mediaObject() {return _player;}
bool equalizerEnabled() {return _equalizer_enabled;}
int _current;
Track _track; // current track (workaround)
bool _random;
- bool _repeat;
+ RepeatRule _repeat;
bool _equalizer_enabled;
QStack<int> _history;
QQueue<int> _queue;
_time = new QTime();
ui->setupUi(this);
if (_player->random()) {
- ui->randomButton->setIcon(QIcon(":/icons/"+_icons_theme+"/random_active.png"));
+ ui->randomButton->setIcon(QIcon(":/icons/"+_icons_theme+"/random_on.png"));
} else {
- ui->randomButton->setIcon(QIcon(":/icons/"+_icons_theme+"/random_inactive.png"));
+ ui->randomButton->setIcon(QIcon(":/icons/"+_icons_theme+"/random_off.png"));
}
- if (_player->repeat()) {
- ui->repeatButton->setIcon(QIcon(":/icons/"+_icons_theme+"/repeat_active.png"));
+ if (_player->repeat() == REPEAT_ALL) {
+ ui->repeatButton->setIcon(QIcon(":/icons/"+_icons_theme+"/repeat_all.png"));
+ } else if (_player->repeat() == REPEAT_NO){
+ ui->repeatButton->setIcon(QIcon(":/icons/"+_icons_theme+"/repeat_off.png"));
} else {
- ui->repeatButton->setIcon(QIcon(":/icons/"+_icons_theme+"/repeat_inactive.png"));
+ ui->repeatButton->setIcon(QIcon(":/icons/"+_icons_theme+"/repeat_one.png"));
}
ui->volumeSlider->setMinimum(0);
ui->volumeSlider->setMaximum(100);
void PlayerForm::_toggle_random() {
_player->toggleRandom();
if (_player->random()) {
- ui->randomButton->setIcon(QIcon(":/icons/"+_icons_theme+"/random_active.png"));
+ ui->randomButton->setIcon(QIcon(":/icons/"+_icons_theme+"/random_on.png"));
} else {
- ui->randomButton->setIcon(QIcon(":/icons/"+_icons_theme+"/random_inactive.png"));
+ ui->randomButton->setIcon(QIcon(":/icons/"+_icons_theme+"/random_off.png"));
}
}
void PlayerForm::_toggle_repeat() {
_player->toggleRepeat();
- if (_player->repeat()) {
- ui->repeatButton->setIcon(QIcon(":/icons/"+_icons_theme+"/repeat_active.png"));
+ if (_player->repeat() == REPEAT_ALL) {
+ ui->repeatButton->setIcon(QIcon(":/icons/"+_icons_theme+"/repeat_all.png"));
+ } else if (_player->repeat() == REPEAT_NO){
+ ui->repeatButton->setIcon(QIcon(":/icons/"+_icons_theme+"/repeat_off.png"));
} else {
- ui->repeatButton->setIcon(QIcon(":/icons/"+_icons_theme+"/repeat_inactive.png"));
+ ui->repeatButton->setIcon(QIcon(":/icons/"+_icons_theme+"/repeat_one.png"));
}
}
} else {
ui->viewButton->setIcon(QIcon(":/icons/"+_icons_theme+"/playback.png"));
}
- if (_player->repeat()) {
- ui->repeatButton->setIcon(QIcon(":/icons/"+_icons_theme+"/repeat_active.png"));
+ if (_player->repeat() == REPEAT_ALL) {
+ ui->repeatButton->setIcon(QIcon(":/icons/"+_icons_theme+"/repeat_all.png"));
+ } else if (_player->repeat() == REPEAT_NO){
+ ui->repeatButton->setIcon(QIcon(":/icons/"+_icons_theme+"/repeat_off.png"));
} else {
- ui->repeatButton->setIcon(QIcon(":/icons/"+_icons_theme+"/repeat_inactive.png"));
+ ui->repeatButton->setIcon(QIcon(":/icons/"+_icons_theme+"/repeat_one.png"));
}
if (_player->random()) {
- ui->randomButton->setIcon(QIcon(":/icons/"+_icons_theme+"/random_active.png"));
+ ui->randomButton->setIcon(QIcon(":/icons/"+_icons_theme+"/random_on.png"));
} else {
- ui->randomButton->setIcon(QIcon(":/icons/"+_icons_theme+"/random_inactive.png"));
+ ui->randomButton->setIcon(QIcon(":/icons/"+_icons_theme+"/random_off.png"));
}
}
ui->bottomWidget->setStyleSheet("");
}
}
+
+void PlayerForm::play(Track track) {
+ reload(true);
+ int id = _current_playlist.tracks().indexOf(track);
+ if (id > 0) {
+ _player->setTrackId(id);
+ _player->play();
+ }
+}
void landscapeMode();
void updateIcons();
void checkGradient();
+ void play(Track);
private slots:
void _library();
</property>
</widget>
</item>
- <item>
- <widget class="QSlider" name="volumeSlider">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="invertedAppearance">
- <bool>false</bool>
- </property>
- <property name="invertedControls">
- <bool>false</bool>
- </property>
- </widget>
- </item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
</widget>
</widget>
</item>
+ <item>
+ <widget class="QSlider" name="volumeSlider">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="invertedAppearance">
+ <bool>false</bool>
+ </property>
+ <property name="invertedControls">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
</layout>
</item>
<item>
</property>
<property name="icon">
<iconset resource="../../resources/resources.qrc">
- <normaloff>:/icons/white/repeat_inactive.png</normaloff>:/icons/white/repeat_inactive.png</iconset>
+ <normaloff>:/icons/white/repeat_off.png</normaloff>:/icons/white/repeat_off.png</iconset>
</property>
<property name="iconSize">
<size>
</property>
<property name="icon">
<iconset resource="../../resources/resources.qrc">
- <normaloff>:/icons/white/random_inactive.png</normaloff>:/icons/white/random_inactive.png</iconset>
+ <normaloff>:/icons/white/random_off.png</normaloff>:/icons/white/random_off.png</iconset>
</property>
<property name="iconSize">
<size>