A lot of changes (animations, initial library manager)
authorNikolay Tischenko <niktischenko@gmail.com>
Tue, 19 Oct 2010 19:07:48 +0000 (02:07 +0700)
committerNikolay Tischenko <niktischenko@gmail.com>
Tue, 19 Oct 2010 19:07:48 +0000 (02:07 +0700)
19 files changed:
resources/someplayer_pkg.png [new file with mode: 0644]
someplayer.pro
src/dbstorage.cpp
src/dbstorage.h
src/filestorage.cpp
src/libraryform.cpp
src/libraryform.h
src/mainwindow.cpp
src/mainwindow.h
src/managelibraryform.cpp [new file with mode: 0644]
src/managelibraryform.h [new file with mode: 0644]
src/playerform.cpp
src/playerform.h
src/toolswidget.cpp
src/toolswidget.h
src/ui/libraryform.ui
src/ui/mainwindow.ui
src/ui/managelibraryform.ui [new file with mode: 0644]
src/ui/playerform.ui

diff --git a/resources/someplayer_pkg.png b/resources/someplayer_pkg.png
new file mode 100644 (file)
index 0000000..b3d5654
Binary files /dev/null and b/resources/someplayer_pkg.png differ
index edadcf2..f46e990 100644 (file)
@@ -122,7 +122,8 @@ SOURCES += src/main.cpp\
     src/saveplaylistdialog.cpp \
     src/settingsdialog.cpp \
     src/dbusadaptor.cpp \
-    src/toolswidget.cpp
+    src/toolswidget.cpp \
+    src/managelibraryform.cpp
 
 HEADERS  += src/mainwindow.h \
                src/player/player.h \
@@ -223,7 +224,8 @@ HEADERS  += src/mainwindow.h \
     src/settingsdialog.h \
     src/abstractitemrenderer.h \
     src/dbusadaptor.h \
-    src/toolswidget.h
+    src/toolswidget.h \
+    src/managelibraryform.h
 
 FORMS    += src/ui/mainwindow.ui \
     src/ui/playerform.ui \
@@ -235,7 +237,8 @@ FORMS    += src/ui/mainwindow.ui \
     src/ui/equalizerdialog.ui \
     src/ui/saveplaylistdialog.ui \
     src/ui/settingsdialog.ui \
-    src/ui/toolswidget.ui
+    src/ui/toolswidget.ui \
+    src/ui/managelibraryform.ui
 
 CONFIG += mobility
 MOBILITY = 
index 078c21f..485a59d 100644 (file)
 #include <QSqlQuery>
 #include <QSqlResult>
 #include <QDebug>
+#include <QFileInfo>
 
 using namespace SomePlayer::Storage;
 using namespace SomePlayer::DataObjects;
 
 DbStorage::DbStorage(QString path) {
-       QString dbname = path+_DATABASE_NAME_;
+       QString dbname = path + _DATABASE_NAME_;
        db = QSqlDatabase::addDatabase("QSQLITE");
        db.setDatabaseName(dbname);
        if (!db.open()) {
@@ -95,12 +96,18 @@ void DbStorage::_prepare_queries() {
        _get_track_id_by_source_query = new QSqlQuery(db);
        _get_track_id_by_source_query->prepare("SELECT id FROM tracks WHERE source = :source");
 
+       _get_directories_query = new QSqlQuery(db);
+       _get_directories_query->prepare("SELECT id, path FROM directories");
+
        _check_artist_query = new QSqlQuery(db);
        _check_artist_query->prepare("SELECT id FROM artist WHERE uname = :uname");
 
        _check_album_query = new QSqlQuery(db);
        _check_album_query->prepare("SELECT id FROM album WHERE uname = :uname AND artist_id = :artist_id");
 
+       _check_directory_query = new QSqlQuery(db);
+       _check_directory_query->prepare("SELECT id from directories WHERE path = :path");
+
        _insert_artist_query = new QSqlQuery(db);
        _insert_artist_query->prepare("INSERT INTO artist (name, uname) values (:name, :uname)");
 
@@ -108,7 +115,7 @@ void DbStorage::_prepare_queries() {
        _insert_album_query->prepare("INSERT INTO album (name, uname, artist_id, year) values (:name, :uname, :artist_id, :year)");
 
        _insert_track_query = new QSqlQuery(db);
-       _insert_track_query->prepare("INSERT INTO tracks (title, utitle, artist_id, album_id, source, length) values (:title, :utitle, :artist_id, :album_id, :source, :length)");
+       _insert_track_query->prepare("INSERT INTO tracks (title, utitle, artist_id, album_id, source, directory, length) values (:title, :utitle, :artist_id, :album_id, :source, :directory_id, :length)");
 
        _insert_date_query = new QSqlQuery(db);
        _insert_date_query->prepare("INSERT INTO adding_date (track_id, date) values (:track_id, strftime('%s', 'now'))");
@@ -116,6 +123,9 @@ void DbStorage::_prepare_queries() {
        _insert_favorites_query = new QSqlQuery(db);
        _insert_favorites_query->prepare("INSERT INTO favorites (track_id) values (:track_id)");
 
+       _insert_directory_query = new QSqlQuery(db);
+       _insert_directory_query->prepare("INSERT INTO directories (path) values (:path)");
+
        _update_track_count_query = new QSqlQuery(db);
        _update_track_count_query->prepare("UPDATE tracks SET count = :count where id = :id");
 
@@ -156,6 +166,7 @@ void DbStorage::_create_database_structure() {
                                                                "title text, "
                                                                "utitle text, "
                                                                "source text, "
+                                                               "directory integer, "
                                                                "count integer default 0, "
                                                                "length integer default 0, "
                                                                "foreign key(artist_id) references artist(id), "
@@ -183,6 +194,8 @@ void DbStorage::_create_database_structure() {
                                        "on album.artist_id = artist.id) "
                                "on aartist_id = tracks.artist_id "
                                "and aalbum_id = tracks.album_id");
+
+       query->exec("create table directories (id integer primary key, path text)");
 }
 
 DbStorage::~DbStorage() {
@@ -195,14 +208,17 @@ DbStorage::~DbStorage() {
        delete _get_recently_added_query;
        delete _get_tracks_for_album_query;
        delete _get_tracks_by_pattern_query;
+       delete _get_directories_query;
        delete _check_album_query;
        delete _check_artist_query;
+       delete _check_directory_query;
        delete _get_track_id_by_source_query;
        delete _insert_album_query;
        delete _insert_artist_query;
        delete _insert_date_query;
        delete _insert_track_query;
        delete _insert_favorites_query;
+       delete _insert_directory_query;
        delete _update_track_count_query;
        delete _remove_track_query;
        db.close();
@@ -366,6 +382,8 @@ void DbStorage::addTrack(Track track) {
        QString artist = track.metadata().artist();
        QString album = track.metadata().album();
        QString source = track.source();
+       QFileInfo info(source);
+       QString path = info.canonicalPath();
        int year = track.metadata().year();
        int artist_id = _check_add_artist(artist);
        int album_id = _check_add_album(album, artist_id, year);
@@ -386,6 +404,7 @@ void DbStorage::addTrack(Track track) {
        query->bindValue(":artist_id", artist_id);
        query->bindValue(":album_id", album_id);
        query->bindValue(":source", source);
+       query->bindValue(":directory", _check_add_directory(path));
        query->bindValue(":length", track.metadata().length());
        if (query->exec()) {
                //ok
@@ -527,3 +546,27 @@ void DbStorage::_cleanup() {
        _remove_empty_albums_query->exec();
        _remove_empty_artists_query->exec();
 }
+
+int DbStorage::_check_add_directory(QString path) {
+       QSqlQuery *query = _check_directory_query;
+       query->bindValue(":path", path);
+       query->exec();
+       if (query->next()) {
+               return query->value(0).toInt();
+       } else {
+               query = _insert_directory_query;
+               query->bindValue(":path", path);
+               query->exec();
+               return _check_add_directory(path);
+       }
+}
+
+QList<QString> DbStorage::getDirectories() {
+       QSqlQuery *query = _get_directories_query;
+       query->exec();
+       QList<QString> directories;
+       while (query->next()) {
+               directories.append(query->value(1).toString());
+       }
+       return directories;
+}
index 1e1fb8c..cc10880 100644 (file)
@@ -42,6 +42,7 @@ namespace SomePlayer {
                public:
                        DbStorage(QString path);
                        ~DbStorage();
+                       QList<QString> getDirectories();
                        QList<QString> getArtists();
                        QMap<QString, int> getAlbumsForArtist(QString artist);
                        QList<Track> getTracksForAlbum(QString album, QString artist); // hm...
@@ -67,6 +68,7 @@ namespace SomePlayer {
 
                        int _check_add_artist(QString artist);
                        int _check_add_album(QString album, int artist_id, int year);
+                       int _check_add_directory(QString path);
 
                        void _cleanup();
 
@@ -82,15 +84,18 @@ namespace SomePlayer {
                        QSqlQuery *_get_track_count;
                        QSqlQuery *_get_tracks_by_pattern_query;
                        QSqlQuery *_get_track_id_by_source_query;
+                       QSqlQuery *_get_directories_query;
 
                        QSqlQuery *_check_artist_query;
                        QSqlQuery *_check_album_query;
+                       QSqlQuery *_check_directory_query;
 
                        QSqlQuery *_insert_artist_query;
                        QSqlQuery *_insert_album_query;
                        QSqlQuery *_insert_track_query;
                        QSqlQuery *_insert_date_query;
                        QSqlQuery *_insert_favorites_query;
+                       QSqlQuery *_insert_directory_query;
 
                        QSqlQuery *_update_track_count_query;
 
index dea1e68..1ddb878 100644 (file)
@@ -48,7 +48,7 @@ QList<Playlist> FileStorage::getPlaylists() {
 Playlist FileStorage::getPlaylist(QString name) {
        if (name == _CURRENT_PLAYLIST_SUBST_)
                name = _CURRENT_PLAYLIST_NAME_;
-       QFile playlistFile (_path_prefix+"/"+name+"."+_PLAYLIST_FILE_EXTENSION_OLD_); // remove OLD_ in next version
+       QFile playlistFile (_path_prefix + "/" + name + "." + _PLAYLIST_FILE_EXTENSION_OLD_); // remove OLD_ in next version
        Playlist playlist;
        playlist.setName(PLAYLIST_BAD_NAME);
        // legacy _start_
@@ -85,7 +85,7 @@ Playlist FileStorage::getPlaylist(QString name) {
                playlistFile.close();
                playlistFile.remove();
        } else {
-               playlistFile.setFileName(_path_prefix+"/"+name+"."+_PLAYLIST_FILE_EXTENSION_);
+               playlistFile.setFileName(_path_prefix + "/" + name + "." + _PLAYLIST_FILE_EXTENSION_);
        // legacy _end_
                if (playlistFile.exists()) {
                        playlist.setName(name);
@@ -160,7 +160,7 @@ void FileStorage::savePlaylist(Playlist playlist) {
        QString name = playlist.name();
        if (playlist.name() == _CURRENT_PLAYLIST_SUBST_)
                name = _CURRENT_PLAYLIST_NAME_;
-       QString filename = _path_prefix + "/" +name+"."_PLAYLIST_FILE_EXTENSION_;
+       QString filename = _path_prefix + "/" + name + "."_PLAYLIST_FILE_EXTENSION_;
        QFile playlistFile(filename);
        if (playlistFile.exists()) {
                playlistFile.remove();
index 2b8c092..3f9f9ea 100644 (file)
@@ -123,8 +123,8 @@ LibraryForm::LibraryForm(Library *lib, QWidget *parent) :
        ui->listView->setModel(_model);
        ui->listView->setColumnWidth(0, 70);
        ui->toolsLayout->addWidget(_tools_widget);
+       _tools_widget->hideFSButton();
        _tools_widget->hide();
-       connect(ui->playerButton, SIGNAL(clicked()), this, SLOT(_player()));
        connect(ui->viewButton, SIGNAL(clicked()), this, SLOT(_view_button()));
        connect(ui->playlistsButton, SIGNAL(clicked()), this, SLOT(_playlists_button()));
        connect(ui->dynamicButton, SIGNAL(clicked()), this, SLOT(_dynamic_button()));
@@ -140,11 +140,10 @@ LibraryForm::LibraryForm(Library *lib, QWidget *parent) :
        connect(_tools_widget, SIGNAL(search(QString)), this, SLOT(search(QString)));
        connect(_tools_widget, SIGNAL(nextSearch()), this, SLOT(nextItem()));
        connect(_tools_widget, SIGNAL(prevSearch()), this, SLOT(prevItem()));
-       connect(_tools_widget, SIGNAL(toggleFullscreen(bool)), this, SIGNAL(fullscreen(bool)));
        connect(ui->moreButton, SIGNAL(clicked()), this, SLOT(_more_button()));
        connect(search_in_library, SIGNAL(toggled(bool)), this, SLOT(_search_button(bool)));
+       connect(ui->playerButton, SIGNAL(clicked()), this, SLOT(hide()));
        _view_button();
-       _current_playlist_changed = true;
        _top_gradient = ui->topWidget->styleSheet();
        _bottom_gradient = ui->bottomWidget->styleSheet();
        _is_dynamic = false;
@@ -152,16 +151,9 @@ LibraryForm::LibraryForm(Library *lib, QWidget *parent) :
 
 LibraryForm::~LibraryForm()
 {
-       _lib->saveCurrentPlaylist(_lib->getCurrentPlaylist()); // wtf?
-       _current_playlist_changed = true;
        delete ui;
 }
 
-void LibraryForm::_player() {
-       emit player(_current_playlist_changed);
-       _current_playlist_changed = false;
-}
-
 void LibraryForm::_view_button() {
        QList<QString> artitst = _lib->getArtists();
        __fill_model(_model, artitst, _icons_theme);
@@ -285,7 +277,6 @@ void LibraryForm::_add_button() {
        if (_state == STATE_NONE) return;
        QModelIndexList selected = ui->listView->selectionModel()->selectedIndexes();
        ui->listView->selectionModel()->clearSelection();
-       emit busy(QString("<H1>Adding... Please wait</H1>"));
        Playlist cur = _lib->getCurrentPlaylist();
        QRegExp regexp("\\[\\d+\\]\\ (.*)");
        switch (_state) {
@@ -294,7 +285,7 @@ void LibraryForm::_add_button() {
                        _add_artist(&cur, id.data().toString());
                }
                _lib->saveCurrentPlaylist(cur);
-               _current_playlist_changed = true;
+               emit refreshPlayer();
                break;
        case STATE_ALBUM:
                foreach (QModelIndex id, selected) {
@@ -303,41 +294,39 @@ void LibraryForm::_add_button() {
                        }
                }
                _lib->saveCurrentPlaylist(cur);
-               _current_playlist_changed = true;
+               emit refreshPlayer();
                break;
        case STATE_TRACK:
                foreach (QModelIndex id, selected) {
                        _add_track(&cur, _current_tracks.at(id.row()));
                }
                _lib->saveCurrentPlaylist(cur);
-               _current_playlist_changed = true;
+               emit refreshPlayer();
                break;
        case STATE_PLAYLIST:
                foreach (QModelIndex id, selected) {
                        _add_playlist(&cur, id.data().toString());
                }
                _lib->saveCurrentPlaylist(cur);
-               _current_playlist_changed = true;
+               emit refreshPlayer();
                break;
        case STATE_PLAYLIST_TRACK:
                foreach (QModelIndex id, selected) {
                        _add_track(&cur, _current_tracks.at(id.row()));
                }
                _lib->saveCurrentPlaylist(cur);
-               _current_playlist_changed = true;
+               emit refreshPlayer();
                break;
        case STATE_SEARCH:
                foreach (QModelIndex id, selected) {
                        _add_track(&cur, _current_tracks.at(id.row()));
                }
                _lib->saveCurrentPlaylist(cur);
-               _current_playlist_changed = true;
+               emit refreshPlayer();
                break;
        default:
-               emit done();
                return;
        }
-       emit done();
 }
 
 
@@ -424,7 +413,7 @@ void LibraryForm::_delete_button() {
                }
                _current_tracks = _current_playlist.tracks();
                _lib->savePlaylist(_current_playlist);
-               _current_playlist_changed = true;
+               emit refreshPlayer();
                __fill_model_tracks(_model, _current_tracks, _icons_theme);
                ui->listView->setColumnWidth(0, 70);
        } else if (_state == STATE_PLAYLIST) {
@@ -450,12 +439,12 @@ void LibraryForm::_delete_track(Track track) {
        Playlist current = _lib->getCurrentPlaylist();
        current.removeTrack(track);
        _lib->saveCurrentPlaylist(current);
-       _current_playlist_changed = true;
+       emit refreshPlayer();
 }
 
 void LibraryForm::_use_button() {
        _lib->saveCurrentPlaylist(_current_playlist);
-       _current_playlist_changed = true;
+       emit refreshPlayer();
        _current_playlist = _lib->getCurrentPlaylist();
 }
 
@@ -665,11 +654,10 @@ void LibraryForm::updateIcons() {
        } else {
                ui->moreButton->setIcon(QIcon(landscape ? ":/icons/"+_icons_theme+"/unmore_l.png" : ":/icons/"+_icons_theme+"/more.png"));
        }
-       ui->playerButton->setIcon(QIcon(":/icons/"+_icons_theme+"/player.png"));
        ui->playlistsButton->setIcon(QIcon(":/icons/"+_icons_theme+"/playlists.png"));
        ui->viewButton->setIcon(QIcon(":/icons/"+_icons_theme+"/artists.png"));
        if (ui->listView->selectionModel()->selectedRows().count() == _model->rowCount()) {
-               ui->selectAllButton->setIcon(QIcon(":/icons/"+_icons_theme+"/unselect_all.png"));
+               ui->selectAllButton->setIcon(QIcon(":/icons/"+_icons_theme+"/deselect_all.png"));
        } else {
                ui->selectAllButton->setIcon(QIcon(":/icons/"+_icons_theme+"/select_all.png"));
        }
@@ -710,7 +698,7 @@ void LibraryForm::_process_dblclick(QModelIndex id) {
                Track track = _current_tracks.at(id.row());
                cur.addTrack(track);
                _lib->saveCurrentPlaylist(cur);
-               _current_playlist_changed = true;
+               emit refreshPlayer();
                emit addAndPlay(track);
                ui->listView->clearSelection();
        }
index 59bb9a0..b4d87bc 100644 (file)
@@ -47,12 +47,9 @@ class LibraryForm : public QWidget
 
 public:
        explicit LibraryForm(Library *lib, QWidget *parent = 0);
-    ~LibraryForm();
+       ~LibraryForm();
 signals:
-       void player(bool);
-       void busy(QString);
-       void done();
-       void fullscreen(bool);
+       void refreshPlayer();
        void addAndPlay(Track);
 public slots:
        void search(QString);
@@ -65,7 +62,6 @@ public slots:
        void updateIcons();
        void checkGradient();
 private slots:
-       void _player();
        void _view_button();
        void _dynamic_button();
        void _playlists_button();
@@ -93,7 +89,6 @@ private:
        QList<Track> _current_tracks;
        QString _search_pattern;
        int _search_current_id;
-       bool _current_playlist_changed;
        ToolsWidget *_tools_widget;
        bool landscape;
        QString _icons_theme;
index 1fbec1d..40c5304 100644 (file)
@@ -46,44 +46,39 @@ MainWindow::MainWindow(QWidget *parent) :
        connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about()));
        connect(ui->actionSettings, SIGNAL(triggered()), this, SLOT(settings()));
        setAnimated(true);
-       _player_form = new PlayerForm(_library, ui->stackedWidget);
-       _library_form = new LibraryForm(_library, ui->stackedWidget);
-       _busy_widget = new BusyWidget(ui->stackedWidget);
+       setAttribute(Qt::WA_Maemo5StackedWindow);
+       _player_form = new PlayerForm(_library, this);
+       ui->centralWidget->layout()->addWidget(_player_form);
+       _library_form = new LibraryForm(_library, this);
+       _library_form->setAttribute(Qt::WA_Maemo5StackedWindow);
+       _library_form->setWindowFlags(_library_form->windowFlags() | Qt::Window);
+       _busy_widget = new BusyWidget(this);
+       ui->centralWidget->layout()->addWidget(_busy_widget);
+       _busy_widget->hide();
        _timer = new QTimer(this);
        _equalizer_dialog = new EqualizerDialog(this);
-       ui->stackedWidget->insertWidget(0, _player_form);
-       ui->stackedWidget->insertWidget(1, _library_form);
-       ui->stackedWidget->insertWidget(2, _busy_widget);
-       QAction *add_directory = ui->menuLibrary->addAction("Add directory");
-       QAction *save_playlist = ui->menuLibrary->addAction("Save playlist");
-       QAction *clear_playlist = ui->menuLibrary->addAction("Clear current playlist");
-       QAction *add_files = ui->menuLibrary->addAction("Add file to current playlist");
-       QAction *set_timer = ui->menuBar->addAction("Set timer");
-       QAction *equalizer = ui->menuBar->addAction("Equalizer");
+       _manage_library_form = new ManageLibraryForm(_library, this);
+       _manage_library_form->setAttribute(Qt::WA_Maemo5StackedWindow);
+       _manage_library_form->setWindowFlags(Qt::Window | _manage_library_form->windowFlags());
        connect(_player_form, SIGNAL(library()), this, SLOT(library()));
-       connect(_library_form, SIGNAL(player(bool)), this, SLOT(player(bool)));
-       connect(add_directory, SIGNAL(triggered()), this, SLOT(_add_directory()));
-       connect(save_playlist, SIGNAL(triggered()), this, SLOT(_save_playlist()));
-       connect(clear_playlist, SIGNAL(triggered()), this, SLOT(_clear_current_playlist()));
-       connect(add_files, SIGNAL(triggered()), this, SLOT(_add_files()));
-       connect(set_timer, SIGNAL(triggered()), this, SLOT(_set_timer()));
-       connect(equalizer, SIGNAL(triggered()), this, SLOT(_equalizer()));
+       connect(_library_form, SIGNAL(refreshPlayer()), this, SLOT(player()));
+       connect(ui->actionManageLibrary, SIGNAL(triggered()), this, SLOT(_manage_library()));
+       connect(ui->actionSavePlaylist, SIGNAL(triggered()), this, SLOT(_save_playlist()));
+       connect(_player_form, SIGNAL(clearPlaylist()), this, SLOT(_clear_current_playlist()));
+       connect(ui->actionSetTimer, SIGNAL(triggered()), this, SLOT(_set_timer()));
+       connect(ui->actionEqualizer, SIGNAL(triggered()), this, SLOT(_equalizer()));
        connect(_library, SIGNAL(done()), this, SLOT(library()));
        connect(_library, SIGNAL(done()), _library_form, SLOT(refresh()));
        connect(_library, SIGNAL(addingTracks(int)), _busy_widget, SLOT(setMax(int)));
        connect(_library, SIGNAL(trackAdded()), _busy_widget, SLOT(tick()));
-       connect(_library_form, SIGNAL(done()), this, SLOT(library()));
-       connect(_library_form, SIGNAL(busy(QString)), this, SLOT(showBusyWidget(QString)));
        connect(_timer, SIGNAL(timeout()), this, SLOT(_timeout()));
        connect(_equalizer_dialog, SIGNAL(valueChanged(int,int)), this, SLOT(_equalizer_value_changed(int, int)));
        connect(_equalizer_dialog, SIGNAL(equalizerEnabled()), _player_form, SLOT(enableEqualizer()));
        connect(_equalizer_dialog, SIGNAL(equalizerDisabled()), _player_form, SLOT(disableEqualizer()));
        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();
        if (mode == "landscape") {
                setAttribute(Qt::WA_Maemo5LandscapeOrientation);
@@ -105,6 +100,7 @@ MainWindow::MainWindow(QWidget *parent) :
        _player_form->updateIcons();
        _player_form->checkGradient();
        _library_form->checkGradient();
+       setWindowTitle("SomePlayer");
 }
 
 MainWindow::~MainWindow()
@@ -120,27 +116,22 @@ void MainWindow::about() {
                                           "Author: Nikolay Tischenko aka \"somebody\" <niktischenko@gmail.com>");
 }
 
-void MainWindow::player(bool reread) {
-       ui->stackedWidget->setCurrentIndex(0);
-       _player_form->reload(reread);
-       setWindowTitle("SomePlayer");
+void MainWindow::player() {
+       _player_form->reload(true);
        _orientation_changed(); // workaround
 }
 
 void MainWindow::library() {
        ui->menuBar->setEnabled(true);
-       _library_form->refresh();
-       ui->stackedWidget->setCurrentIndex(1);
-       setWindowTitle("SomePlayer Library");
+       _library_form->show();
        _orientation_changed(); // workaround
+       _busy_widget->hide();
+       _manage_library_form->hide();
+       _player_form->show();
 }
 
-void MainWindow::_add_directory() {
-       QString directory = QFileDialog::getExistingDirectory (this, "Select directory", "/home/user/MyDocs", QFileDialog::ShowDirsOnly );
-       if (!directory.isEmpty()) {
-               showBusyWidget("<H1>Scanning... Please wait</H1>");
-               _library->addDirectory(directory);
-       }
+void MainWindow::_manage_library() {
+       _manage_library_form->show();
 }
 
 void MainWindow::_save_playlist() {
@@ -186,7 +177,8 @@ void MainWindow::_clear_current_playlist() {
 void MainWindow::showBusyWidget(QString caption) {
        _busy_widget->setText(caption);
        ui->menuBar->setEnabled(false);
-       ui->stackedWidget->setCurrentIndex(2);
+       _player_form->hide();
+       _busy_widget->show();
 }
 
 void MainWindow::_add_files() {
index 7fc05dd..df6c266 100644 (file)
@@ -26,6 +26,7 @@
 #include "libraryform.h"
 #include "busywidget.h"
 #include "equalizerdialog.h"
+#include "managelibraryform.h"
 #include "library.h"
 #include <QTimer>
 
@@ -52,12 +53,13 @@ signals:
 
 public slots:
        void about();
-       void player(bool);
+       void player();
        void library();
        void settings();
        void showBusyWidget(QString);
 private slots:
-       void _add_directory();
+       void _manage_library();
+//     void _add_directory();
        void _save_playlist();
        void _clear_current_playlist();
        void _add_files();
@@ -74,6 +76,7 @@ private:
        Library *_library;
        QTimer *_timer;
        EqualizerDialog *_equalizer_dialog;
+       ManageLibraryForm *_manage_library_form;
 };
 
 #endif // MAINWINDOW_H
diff --git a/src/managelibraryform.cpp b/src/managelibraryform.cpp
new file mode 100644 (file)
index 0000000..066d4ac
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * SomePlayer - An alternate music player for Maemo 5
+ * Copyright (C) 2010 Nikolay (somebody) Tischenko <niktischenko@gmail.com>
+ *
+ * This program 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 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+#include "managelibraryform.h"
+#include "ui_managelibraryform.h"
+#include "library.h"
+#include <QFileDialog>
+
+using namespace SomePlayer::DataObjects;
+
+ManageLibraryForm::ManageLibraryForm(Library *library, QWidget *parent) :
+               QWidget(parent),
+               ui(new Ui::ManageLibraryForm),
+               _library (library)
+{
+       ui->setupUi(this);
+       connect(ui->addButton, SIGNAL(clicked()), this, SLOT(add()));
+}
+
+ManageLibraryForm::~ManageLibraryForm()
+{
+       delete ui;
+}
+
+void ManageLibraryForm::add() {
+       QString directory = QFileDialog::getExistingDirectory (this, "Select directory", "/home/user/MyDocs", QFileDialog::ShowDirsOnly );
+       if (!directory.isEmpty()) {
+               _library->addDirectory(directory);
+       }
+}
diff --git a/src/managelibraryform.h b/src/managelibraryform.h
new file mode 100644 (file)
index 0000000..91568b8
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * SomePlayer - An alternate music player for Maemo 5
+ * Copyright (C) 2010 Nikolay (somebody) Tischenko <niktischenko@gmail.com>
+ *
+ * This program 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 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+#ifndef MANAGELIBRARYFORM_H
+#define MANAGELIBRARYFORM_H
+
+#include <QWidget>
+#include "someplayer.h"
+
+namespace Ui {
+       class ManageLibraryForm;
+}
+
+using SomePlayer::DataObjects::Library;
+
+class ManageLibraryForm : public QWidget
+{
+       Q_OBJECT
+
+public:
+       explicit ManageLibraryForm(Library *library, QWidget *parent = 0);
+       ~ManageLibraryForm();
+
+private slots:
+       void add();
+
+private:
+       Ui::ManageLibraryForm *ui;
+       Library *_library;
+};
+
+#endif // MANAGELIBRARYFORM_H
index fd41832..567f7b6 100644 (file)
@@ -83,6 +83,7 @@ PlayerForm::PlayerForm(Library* lib, QWidget *parent) :
        _model = new QStandardItemModel(0, 2, this);
        ui->playlistView->setModel(_model);
        _context_menu = new QMenu(ui->playlistView);
+       QAction *clear_playlist = _context_menu->addAction("Clear playlist");
        QAction *delete_action = _context_menu->addAction("Delete");
        QAction *add_to_favorites = _context_menu->addAction("Add to favorites");
        QAction *enqueue_action = _context_menu->addAction("Enqueue");
@@ -110,6 +111,7 @@ PlayerForm::PlayerForm(Library* lib, QWidget *parent) :
        connect(ui->seekSlider, SIGNAL(sliderMoved(int)), _player, SLOT(seek(int)));
        connect(ui->volumeSlider, SIGNAL(sliderMoved(int)), _player, SLOT(setVolume(int)));
        connect(ui->playlistView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(_custom_context_menu_requested(QPoint)));
+       connect(clear_playlist, SIGNAL(triggered()), this, SIGNAL(clearPlaylist()));
        connect(delete_action, SIGNAL(triggered()), this, SLOT(_delete_track()));
        connect(enqueue_action, SIGNAL(triggered()), this, SLOT(_enqueue_track()));
        connect(add_to_favorites, SIGNAL(triggered()), this, SLOT(_add_to_favorites()));
@@ -497,9 +499,9 @@ void PlayerForm::updateIcons() {
        _tools_widget->updateIcons();
        ui->libraryButton->setIcon(QIcon(":/icons/"+_icons_theme+"/library.png"));
        if (_tools_widget->isVisible()) {
-               ui->moreButton->setIcon(QIcon(landscape ? ":/icons/"+_icons_theme+"/unmore.png" : ":/icons/"+_icons_theme+"/more.png"));
+               ui->moreButton->setIcon(QIcon(landscape ? ":/icons/" + _icons_theme + "/unmore.png" : ":/icons/" + _icons_theme + "/more.png"));
        } else {
-               ui->moreButton->setIcon(QIcon(landscape ? ":/icons/"+_icons_theme+"/more.png" : ":/icons/"+_icons_theme+"/unmore.png"));
+               ui->moreButton->setIcon(QIcon(landscape ? ":/icons/" + _icons_theme + "/more.png" : ":/icons/" + _icons_theme + "/unmore.png"));
        }
        ui->nextButton->setIcon(QIcon(":/icons/"+_icons_theme+"/next.png"));
        ui->stopButton->setIcon(QIcon(":/icons/"+_icons_theme+"/stop.png"));
index c7c1c1b..1be2824 100644 (file)
@@ -57,6 +57,7 @@ public:
 signals:
        void library();
        void fullscreen(bool);
+       void clearPlaylist();
 
 public slots:
        void reload(bool);
index 07aea3b..08a8cb0 100644 (file)
@@ -74,3 +74,7 @@ void ToolsWidget::toggleArrows(bool state) {
        ui->nextButton->setVisible(state);
        ui->prevButton->setVisible(state);
 }
+
+void ToolsWidget::hideFSButton() {
+       ui->fscreenButton->hide();
+}
index 82a9b3b..dd6d180 100644 (file)
@@ -40,6 +40,7 @@ public slots:
        void updateIcons();
        void show();
        void toggleArrows(bool);
+       void hideFSButton();
 
 signals:
        void toggleFullscreen(bool);
index c7064ac..918c94b 100644 (file)
     <height>480</height>
    </rect>
   </property>
-  <property name="palette">
-   <palette>
-    <active>
-     <colorrole role="Text">
-      <brush brushstyle="SolidPattern">
-       <color alpha="255">
-        <red>0</red>
-        <green>85</green>
-        <blue>255</blue>
-       </color>
-      </brush>
-     </colorrole>
-    </active>
-    <inactive>
-     <colorrole role="Text">
-      <brush brushstyle="SolidPattern">
-       <color alpha="255">
-        <red>0</red>
-        <green>85</green>
-        <blue>255</blue>
-       </color>
-      </brush>
-     </colorrole>
-    </inactive>
-    <disabled>
-     <colorrole role="Text">
-      <brush brushstyle="SolidPattern">
-       <color alpha="255">
-        <red>127</red>
-        <green>127</green>
-        <blue>126</blue>
-       </color>
-      </brush>
-     </colorrole>
-    </disabled>
-   </palette>
-  </property>
   <property name="windowTitle">
-   <string>Form</string>
+   <string>SomePlayer Library</string>
   </property>
   <layout class="QVBoxLayout" name="verticalLayout_2">
    <property name="spacing">
index 7bd4bc0..7da86cc 100644 (file)
    <string>someplayer</string>
   </property>
   <widget class="QWidget" name="centralWidget">
-   <layout class="QVBoxLayout" name="verticalLayout" stretch="0">
+   <layout class="QVBoxLayout" name="verticalLayout">
     <property name="spacing">
      <number>0</number>
     </property>
     <property name="margin">
      <number>0</number>
     </property>
-    <item>
-     <widget class="QStackedWidget" name="stackedWidget">
-      <widget class="QWidget" name="page"/>
-      <widget class="QWidget" name="page_2"/>
-     </widget>
-    </item>
    </layout>
   </widget>
   <widget class="QMenuBar" name="menuBar">
     <property name="title">
      <string>Library</string>
     </property>
+    <addaction name="actionManageLibrary"/>
+   </widget>
+   <widget class="QMenu" name="menuTools">
+    <property name="title">
+     <string>Tools</string>
+    </property>
+    <addaction name="actionEqualizer"/>
+    <addaction name="actionSetTimer"/>
+   </widget>
+   <widget class="QMenu" name="menuPlayer">
+    <property name="title">
+     <string>Player</string>
+    </property>
+    <addaction name="actionSavePlaylist"/>
    </widget>
    <addaction name="menuHelp"/>
+   <addaction name="menuPlayer"/>
    <addaction name="menuLibrary"/>
+   <addaction name="menuTools"/>
   </widget>
   <action name="actionAbout">
    <property name="text">
     <string>Settings</string>
    </property>
   </action>
+  <action name="actionManageLibrary">
+   <property name="text">
+    <string>Manage library</string>
+   </property>
+  </action>
+  <action name="actionEqualizer">
+   <property name="text">
+    <string>Equalizer</string>
+   </property>
+  </action>
+  <action name="actionSetTimer">
+   <property name="text">
+    <string>Set timer</string>
+   </property>
+  </action>
+  <action name="actionSavePlaylist">
+   <property name="text">
+    <string>Save playlist</string>
+   </property>
+  </action>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
  <resources/>
diff --git a/src/ui/managelibraryform.ui b/src/ui/managelibraryform.ui
new file mode 100644 (file)
index 0000000..beab448
--- /dev/null
@@ -0,0 +1,180 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ManageLibraryForm</class>
+ <widget class="QWidget" name="ManageLibraryForm">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>553</width>
+    <height>300</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout_2">
+   <property name="spacing">
+    <number>6</number>
+   </property>
+   <property name="margin">
+    <number>9</number>
+   </property>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_2">
+     <property name="spacing">
+      <number>0</number>
+     </property>
+     <item>
+      <widget class="QPushButton" name="addButton">
+       <property name="text">
+        <string>Add new</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer_3">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QPushButton" name="updateButton">
+       <property name="text">
+        <string>Update</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer_2">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QPushButton" name="deleteButton">
+       <property name="text">
+        <string>Delete</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QVBoxLayout" name="verticalLayout">
+     <property name="spacing">
+      <number>0</number>
+     </property>
+     <item>
+      <layout class="QHBoxLayout" name="horizontalLayout">
+       <property name="spacing">
+        <number>0</number>
+       </property>
+       <item>
+        <widget class="QLabel" name="label">
+         <property name="text">
+          <string>Added directories:</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <spacer name="horizontalSpacer">
+         <property name="orientation">
+          <enum>Qt::Horizontal</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>40</width>
+           <height>20</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+      </layout>
+     </item>
+     <item>
+      <widget class="QTableView" name="dirView">
+       <property name="horizontalScrollBarPolicy">
+        <enum>Qt::ScrollBarAlwaysOff</enum>
+       </property>
+       <property name="editTriggers">
+        <set>QAbstractItemView::NoEditTriggers</set>
+       </property>
+       <property name="selectionMode">
+        <enum>QAbstractItemView::MultiSelection</enum>
+       </property>
+       <property name="selectionBehavior">
+        <enum>QAbstractItemView::SelectRows</enum>
+       </property>
+       <property name="iconSize">
+        <size>
+         <width>50</width>
+         <height>50</height>
+        </size>
+       </property>
+       <property name="showGrid">
+        <bool>false</bool>
+       </property>
+       <attribute name="horizontalHeaderVisible">
+        <bool>false</bool>
+       </attribute>
+       <attribute name="horizontalHeaderStretchLastSection">
+        <bool>true</bool>
+       </attribute>
+       <attribute name="verticalHeaderVisible">
+        <bool>false</bool>
+       </attribute>
+       <attribute name="verticalHeaderDefaultSectionSize">
+        <number>70</number>
+       </attribute>
+       <attribute name="verticalHeaderMinimumSectionSize">
+        <number>70</number>
+       </attribute>
+      </widget>
+     </item>
+     <item>
+      <layout class="QHBoxLayout" name="horizontalLayout_3">
+       <item>
+        <widget class="QLabel" name="artistsLabel">
+         <property name="text">
+          <string>0 artitst</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QLabel" name="albumsLabel">
+         <property name="text">
+          <string>0 albums</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QLabel" name="tracksView">
+         <property name="text">
+          <string>0 tracks</string>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
index 5c48ec1..a4ae191 100644 (file)
@@ -11,7 +11,7 @@
    </rect>
   </property>
   <property name="windowTitle">
-   <string>Form</string>
+   <string>SomePlayer</string>
   </property>
   <layout class="QVBoxLayout" name="verticalLayout">
    <property name="spacing">