_check_directory_query = new QSqlQuery(db);
_check_directory_query->prepare("SELECT id from directories WHERE path = :path");
+ _check_favorite_query = new QSqlQuery(db);
+ _check_favorite_query->prepare("SELECT 'yes' from favorites WHERE track_id in (SELECT id from tracks WHERE source = :source)");
+
_insert_artist_query = new QSqlQuery(db);
_insert_artist_query->prepare("INSERT INTO artist (name, uname) values (:name, :uname)");
query->bindValue(":source", track.source());
query->exec();
}
+
+bool DbStorage::isFavorite(Track track) {
+ QSqlQuery *query = _check_favorite_query;
+ query->bindValue(":source", track.source());
+ query->exec();
+ if (query->next()) {
+ QString ans = query->value(0).toString();
+ return ans == "yes";
+ }
+ return false;
+}
void deleteTracksFrom(QString path);
void checkTracksFrom(QString path);
+ bool isFavorite(Track);
+
private:
QSqlDatabase db;
void _create_database_structure();
QSqlQuery *_check_artist_query;
QSqlQuery *_check_album_query;
QSqlQuery *_check_directory_query;
+ QSqlQuery *_check_favorite_query;
QSqlQuery *_insert_artist_query;
QSqlQuery *_insert_album_query;
if (msec > _DBUS_ACTION_TIMEOUT_) {
if (event == "ButtonPressed") {
if (state == "next-song") {
- QMetaObject::invokeMethod(parent(), "next");
+ next();
} else if (state == "previous-song") {
- QMetaObject::invokeMethod(parent(), "prev");
+ prev();
} else if (state == "play-cd" || state == "pause-cd") {
- QMetaObject::invokeMethod(parent(), "toggle");
+ toggle();
}
}
}
_time = t;
}
-
connect(ui->enableToggleButton, SIGNAL(clicked()), this, SLOT(_state_changed()));
connect(ui->saveButton, SIGNAL(clicked()), this, SLOT(_save_preset()));
connect(ui->presetComboBox, SIGNAL(activated(QString)), this, SLOT(_load_preset(QString)));
+
+ Config config;
+ if (config.equalizerEnabled()) {
+ setEqualizerEnabled(true);
+ _load_preset("");
+ }
}
EqualizerDialog::~EqualizerDialog()
void Library::removeFromFavorites(Track track) {
_library_storage->removeFromFavorites(track);
}
+
+bool Library::isFavorite(Track track) {
+ return _library_storage->isFavorite(track);
+}
void updateAll();
void deleteDirectories(QList<QString> directories);
+ bool isFavorite(Track);
+
signals:
void started();
void done();
QString hp = h < 10 ? QString("0%1").arg(h) : QString("%1").arg(h);
QString mp = m < 10 ? QString("0%1").arg(m) : QString("%1").arg(m);
QString sp = s < 10 ? QString("0%1").arg(s) : QString("%1").arg(s);
- _player_form->showCountdown(hp+":"+mp+":"+sp);
+ _player_form->showCountdown(tr("Music off: ")+hp+":"+mp+":"+sp);
}
}
void MainWindow::settings() {
_settings_form->show();
-
-// Config config;
-// _library_form->refresh();
-// _player_form->updateIcons();
-// _library_form->updateIcons();
-// _manage_library_form->updateIcons();
-// _player_form->checkGradient();
-// _library_form->checkGradient();
-// _directory_form->updateIcons();
-// _directory_form->updateGradient();
-// updateTranslations();
}
void MainWindow::_change_orientation() {
return "";
return _playlist.tracks().at(_current).metadata().title();
}
+
+Track Player::current() {
+ if (_current >= 0) {
+ return _playlist.tracks().at(_current);
+ } else {
+ return Track();
+ }
+}
bool equalizerEnabled() {return _equalizer_enabled;}
bool equalizerAvailable() {return _equalizer != NULL;}
PlayerState state() {return _state;}
+ Track current();
signals:
void stateChanged (PlayerState);
ui->seekSlider->setMaximum(track.metadata().length());
_tick(0, track.metadata().length());
_coverfinder->find(track);
+ ui->cfavButton->setChecked(_lib->isFavorite(track));
}
void PlayerForm::_tick(int done, int all) {
if (idx.isEmpty())
return;
int id = idx.first().row();
- _lib->addToFavorites(_current_playlist.tracks().at(id));
+ if (ui->cfavButton->isChecked()) {
+ _lib->addToFavorites(_current_playlist.tracks().at(id));
+ } else {
+ _lib->removeFromFavorites(_current_playlist.tracks().at(id));
+ }
+ ui->cfavButton->setChecked(_lib->isFavorite(_current_playlist.tracks().at(id)));
}
void PlayerForm::_state_changed(PlayerState state) {
ui->caddButton->setEnabled(true);
ui->cdeleteButton->setEnabled(true);
ui->cfavButton->setEnabled(true);
+ ui->cfavButton->setChecked(_lib->isFavorite(_player->current()));
ui->ctagButton->setEnabled(true);
ui->caddButton->setIcon(QIcon(":/icons/"+_icons_theme+"/add.png"));
ui->cdeleteButton->setIcon(QIcon(":/icons/"+_icons_theme+"/delete.png"));
<number>0</number>
</property>
<item>
- <widget class="QLabel" name="label">
+ <widget class="QLabel" name="timeLabel">
<property name="text">
- <string>Music off:</string>
+ <string>Music off: 00:00:00</string>
</property>
<property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="timeLabel">
- <property name="text">
- <string>00:00:00</string>
+ <set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<iconset resource="../../resources/resources.qrc">
<normaloff>:/icons/white/fav.png</normaloff>:/icons/white/fav.png</iconset>
</property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
<property name="flat">
<bool>true</bool>
</property>