Added fullscreen button
authorNikolay Tischenko <niktischenko@gmail.com>
Wed, 22 Sep 2010 06:09:05 +0000 (13:09 +0700)
committerNikolay Tischenko <niktischenko@gmail.com>
Wed, 22 Sep 2010 06:09:05 +0000 (13:09 +0700)
resources/fullscreen.png [new file with mode: 0644]
resources/resources.qrc
resources/window.png [new file with mode: 0644]
src/filestorage.cpp
src/filestorage.h
src/libraryform.cpp
src/mainwindow.cpp
src/mainwindow.h
src/player/player.cpp
src/ui/libraryform.ui
src/ui/mainwindow.ui

diff --git a/resources/fullscreen.png b/resources/fullscreen.png
new file mode 100644 (file)
index 0000000..5b60f68
Binary files /dev/null and b/resources/fullscreen.png differ
index 24f51a2..444ab95 100644 (file)
@@ -23,5 +23,7 @@
         <file>dynamic.png</file>
         <file>fav.png</file>
         <file>forward.png</file>
+        <file>window.png</file>
+        <file>fullscreen.png</file>
     </qresource>
 </RCC>
diff --git a/resources/window.png b/resources/window.png
new file mode 100644 (file)
index 0000000..d55f245
Binary files /dev/null and b/resources/window.png differ
index 93c7261..3d6d730 100644 (file)
@@ -27,6 +27,8 @@ 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_);
        Playlist playlist;
        playlist.setName(PLAYLIST_BAD_NAME);
@@ -68,6 +70,8 @@ QStringList FileStorage::getPlaylistsNames() {
                QString suffix = info.suffix().toLower();
                if (suffix == _PLAYLIST_FILE_EXTENSION_) {
                        QString name = info.fileName().replace(QString(".%1").arg(_PLAYLIST_FILE_EXTENSION_), "", Qt::CaseInsensitive);
+                       if (name == _CURRENT_PLAYLIST_NAME_)
+                           name = _CURRENT_PLAYLIST_SUBST_;
                        playlistNames.append(name);
                }
        }
@@ -75,7 +79,10 @@ QStringList FileStorage::getPlaylistsNames() {
 }
 
 void FileStorage::savePlaylist(Playlist playlist) {
-       QString filename = _path_prefix + "/" +playlist.name()+"."_PLAYLIST_FILE_EXTENSION_;
+       QString name = playlist.name();
+       if (playlist.name() == _CURRENT_PLAYLIST_SUBST_)
+               name = _CURRENT_PLAYLIST_NAME_;
+       QString filename = _path_prefix + "/" +name+"."_PLAYLIST_FILE_EXTENSION_;
        QFile playlistFile(filename);
        if (playlistFile.exists()) {
                playlistFile.remove();
@@ -99,7 +106,8 @@ void FileStorage::removePlaylist(Playlist playlist) {
 }
 
 void FileStorage::removePlaylist(QString name) {
-       QString filename = _path_prefix + "/" + name + "." + _PLAYLIST_FILE_EXTENSION_;
+       QString filename = _path_prefix + "/" + (name == _CURRENT_PLAYLIST_SUBST_ ? _CURRENT_PLAYLIST_NAME_ : name)
+                          + "." + _PLAYLIST_FILE_EXTENSION_;
        QFile file(filename);
        file.remove();
 }
index d49216f..dcc0edc 100644 (file)
@@ -7,6 +7,7 @@
 #include <QRegExp>
 
 #define _CURRENT_PLAYLIST_NAME_ "___current"
+#define _CURRENT_PLAYLIST_SUBST_ "Now playing"
 #define _PLAYLIST_FILE_EXTENSION_ "spls"
 #define _PLAYLIST_SIGNATURE_ "#SOMEPLAYLIST"
 #define _PLAYLIST_META_KEYWORD_ "#META"
index 8ce4c1d..3704819 100644 (file)
@@ -271,14 +271,17 @@ void LibraryForm::_delete_button() {
                QModelIndexList selected = ui->listView->selectionModel()->selectedIndexes();
                QQueue<int> to_delete;
                foreach (QModelIndex id, selected) {
-                       _delete_track(_current_tracks.at(id.row()));
                        to_delete.append(id.row());
                }
                qSort(to_delete);
                int count = to_delete.count();
                for (int i = count-1; i >= 0; i--) {
-                       _lib->removePlaylist(_model->item(to_delete.at(i))->data().toString());
-                       _model->removeRow(to_delete.at(i));
+                       QString name = _model->item(to_delete.at(i))->text();
+                       if (name != _CURRENT_PLAYLIST_SUBST_) {
+                               qDebug() << "deleting " << name;
+                               _lib->removePlaylist(name);
+                               _model->removeRow(to_delete.at(i));
+                       }
                }
        }
 }
index f9d470e..dc82962 100644 (file)
@@ -43,6 +43,7 @@ MainWindow::MainWindow(QWidget *parent) :
        connect(ui->searchLine, SIGNAL(textChanged(QString)), this, SLOT(_search(QString)));
        connect(ui->nextButton, SIGNAL(clicked()), this, SLOT(_nextItem()));
        connect(ui->prevButton, SIGNAL(clicked()), this, SLOT(_prevItem()));
+       connect(ui->fscreenButton, SIGNAL(clicked()), this, SLOT(_toggle_full_screen()));
        hideSearchPanel();
        library();
 }
@@ -156,3 +157,13 @@ void MainWindow::_cancelSearch() {
                _player_form->cancelSearch();
        }
 }
+
+void MainWindow::_toggle_full_screen() {
+       if (isFullScreen()) {
+               ui->fscreenButton->setIcon(QIcon(":/icons/fullscreen.png"));
+               showNormal();
+       } else {
+               ui->fscreenButton->setIcon(QIcon(":/icons/window.png"));
+               showFullScreen();
+       }
+}
index e9b4608..0a31c0e 100644 (file)
@@ -42,6 +42,7 @@ private slots:
        void _nextItem();
        void _prevItem();
        void _cancelSearch();
+       void _toggle_full_screen();
 private:
        PlayerForm *_player_form;
        LibraryForm *_library_form;
index 0f11f9d..fb000d9 100644 (file)
@@ -133,6 +133,8 @@ void Player::_tick(qint64 ticks) {
 void Player::setPlaylist(Playlist playlist) {
        _playlist = playlist;
        _history.clear();
+       _prev_history.clear();
+       _queue.clear();
 }
 
 void Player::seek(int s) {
index 10e9499..6ba7458 100644 (file)
@@ -50,7 +50,7 @@
   <property name="windowTitle">
    <string>Form</string>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout_2">
+  <layout class="QHBoxLayout" name="horizontalLayout">
    <property name="spacing">
     <number>0</number>
    </property>
@@ -58,9 +58,9 @@
     <number>0</number>
    </property>
    <item>
-    <layout class="QHBoxLayout" name="horizontalLayout">
+    <layout class="QVBoxLayout" name="verticalLayout">
      <item>
-      <widget class="QPushButton" name="viewButton">
+      <widget class="QPushButton" name="backButton">
        <property name="sizePolicy">
         <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
          <horstretch>0</horstretch>
@@ -84,7 +84,7 @@
        </property>
        <property name="icon">
         <iconset resource="../../resources/resources.qrc">
-         <normaloff>:/icons/artists.png</normaloff>:/icons/artists.png</iconset>
+         <normaloff>:/icons/back.png</normaloff>:/icons/back.png</iconset>
        </property>
        <property name="flat">
         <bool>true</bool>
       </widget>
      </item>
      <item>
-      <spacer name="horizontalSpacer_2">
-       <property name="orientation">
-        <enum>Qt::Horizontal</enum>
+      <widget class="QPushButton" name="addButton">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
        </property>
-       <property name="sizeHint" stdset="0">
+       <property name="minimumSize">
+        <size>
+         <width>70</width>
+         <height>70</height>
+        </size>
+       </property>
+       <property name="maximumSize">
         <size>
-         <width>40</width>
-         <height>20</height>
+         <width>70</width>
+         <height>70</height>
         </size>
        </property>
-      </spacer>
+       <property name="text">
+        <string/>
+       </property>
+       <property name="icon">
+        <iconset resource="../../resources/resources.qrc">
+         <normaloff>:/icons/add.png</normaloff>:/icons/add.png</iconset>
+       </property>
+       <property name="flat">
+        <bool>true</bool>
+       </property>
+      </widget>
      </item>
      <item>
-      <widget class="QPushButton" name="dynamicButton">
+      <widget class="QPushButton" name="deleteButton">
+       <property name="minimumSize">
+        <size>
+         <width>70</width>
+         <height>70</height>
+        </size>
+       </property>
+       <property name="maximumSize">
+        <size>
+         <width>70</width>
+         <height>70</height>
+        </size>
+       </property>
+       <property name="text">
+        <string/>
+       </property>
+       <property name="icon">
+        <iconset resource="../../resources/resources.qrc">
+         <normaloff>:/icons/delete.png</normaloff>:/icons/delete.png</iconset>
+       </property>
+       <property name="flat">
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="useButton">
        <property name="sizePolicy">
         <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
          <horstretch>0</horstretch>
        </property>
        <property name="icon">
         <iconset resource="../../resources/resources.qrc">
-         <normaloff>:/icons/dynamic.png</normaloff>:/icons/dynamic.png</iconset>
+         <normaloff>:/icons/use.png</normaloff>:/icons/use.png</iconset>
        </property>
        <property name="flat">
         <bool>true</bool>
       </widget>
      </item>
      <item>
-      <spacer name="horizontalSpacer">
+      <spacer name="verticalSpacer_3">
        <property name="orientation">
-        <enum>Qt::Horizontal</enum>
+        <enum>Qt::Vertical</enum>
        </property>
        <property name="sizeHint" stdset="0">
         <size>
-         <width>40</width>
-         <height>20</height>
+         <width>20</width>
+         <height>40</height>
         </size>
        </property>
       </spacer>
      </item>
      <item>
-      <widget class="QPushButton" name="playlistsButton">
+      <widget class="QPushButton" name="playerButton">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
        <property name="minimumSize">
         <size>
          <width>70</width>
        </property>
        <property name="icon">
         <iconset resource="../../resources/resources.qrc">
-         <normaloff>:/icons/playlists.png</normaloff>:/icons/playlists.png</iconset>
+         <normaloff>:/icons/player.png</normaloff>:/icons/player.png</iconset>
        </property>
        <property name="flat">
         <bool>true</bool>
     </layout>
    </item>
    <item>
-    <layout class="QHBoxLayout" name="horizontalLayout_2">
+    <layout class="QVBoxLayout" name="verticalLayout_3">
      <property name="spacing">
       <number>0</number>
      </property>
      <item>
-      <layout class="QVBoxLayout" name="verticalLayout">
-       <item>
-        <widget class="QPushButton" name="backButton">
-         <property name="sizePolicy">
-          <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-         <property name="minimumSize">
-          <size>
-           <width>70</width>
-           <height>70</height>
-          </size>
-         </property>
-         <property name="maximumSize">
-          <size>
-           <width>70</width>
-           <height>70</height>
-          </size>
-         </property>
-         <property name="text">
-          <string/>
-         </property>
-         <property name="icon">
-          <iconset resource="../../resources/resources.qrc">
-           <normaloff>:/icons/back.png</normaloff>:/icons/back.png</iconset>
-         </property>
-         <property name="flat">
-          <bool>true</bool>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QPushButton" name="addButton">
-         <property name="sizePolicy">
-          <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-         <property name="minimumSize">
-          <size>
-           <width>70</width>
-           <height>70</height>
-          </size>
-         </property>
-         <property name="maximumSize">
-          <size>
-           <width>70</width>
-           <height>70</height>
-          </size>
-         </property>
-         <property name="text">
-          <string/>
-         </property>
-         <property name="icon">
-          <iconset resource="../../resources/resources.qrc">
-           <normaloff>:/icons/add.png</normaloff>:/icons/add.png</iconset>
-         </property>
-         <property name="flat">
-          <bool>true</bool>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QPushButton" name="deleteButton">
-         <property name="minimumSize">
-          <size>
-           <width>70</width>
-           <height>70</height>
-          </size>
-         </property>
-         <property name="maximumSize">
-          <size>
-           <width>70</width>
-           <height>70</height>
-          </size>
-         </property>
-         <property name="text">
-          <string/>
-         </property>
-         <property name="icon">
-          <iconset resource="../../resources/resources.qrc">
-           <normaloff>:/icons/delete.png</normaloff>:/icons/delete.png</iconset>
-         </property>
-         <property name="flat">
-          <bool>true</bool>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QPushButton" name="useButton">
-         <property name="sizePolicy">
-          <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-         <property name="minimumSize">
-          <size>
-           <width>70</width>
-           <height>70</height>
-          </size>
-         </property>
-         <property name="maximumSize">
-          <size>
-           <width>70</width>
-           <height>70</height>
-          </size>
-         </property>
-         <property name="text">
-          <string/>
-         </property>
-         <property name="icon">
-          <iconset resource="../../resources/resources.qrc">
-           <normaloff>:/icons/use.png</normaloff>:/icons/use.png</iconset>
-         </property>
-         <property name="flat">
-          <bool>true</bool>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <spacer name="verticalSpacer_3">
-         <property name="orientation">
-          <enum>Qt::Vertical</enum>
-         </property>
-         <property name="sizeHint" stdset="0">
-          <size>
-           <width>20</width>
-           <height>40</height>
-          </size>
-         </property>
-        </spacer>
-       </item>
-       <item>
-        <widget class="QPushButton" name="playerButton">
-         <property name="sizePolicy">
-          <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-         <property name="minimumSize">
-          <size>
-           <width>70</width>
-           <height>70</height>
-          </size>
-         </property>
-         <property name="maximumSize">
-          <size>
-           <width>70</width>
-           <height>70</height>
-          </size>
-         </property>
-         <property name="text">
-          <string/>
-         </property>
-         <property name="icon">
-          <iconset resource="../../resources/resources.qrc">
-           <normaloff>:/icons/player.png</normaloff>:/icons/player.png</iconset>
-         </property>
-         <property name="flat">
-          <bool>true</bool>
-         </property>
-        </widget>
-       </item>
-      </layout>
+      <widget class="QLabel" name="listLabel">
+       <property name="enabled">
+        <bool>false</bool>
+       </property>
+       <property name="text">
+        <string/>
+       </property>
+       <property name="textFormat">
+        <enum>Qt::AutoText</enum>
+       </property>
+       <property name="alignment">
+        <set>Qt::AlignCenter</set>
+       </property>
+      </widget>
      </item>
      <item>
-      <layout class="QVBoxLayout" name="verticalLayout_3">
+      <widget class="QListView" name="listView">
+       <property name="editTriggers">
+        <set>QAbstractItemView::NoEditTriggers</set>
+       </property>
+       <property name="selectionMode">
+        <enum>QAbstractItemView::MultiSelection</enum>
+       </property>
+       <property name="isWrapping" stdset="0">
+        <bool>false</bool>
+       </property>
        <property name="spacing">
-        <number>0</number>
-       </property>
-       <item>
-        <widget class="QLabel" name="listLabel">
-         <property name="enabled">
-          <bool>false</bool>
-         </property>
-         <property name="text">
-          <string/>
-         </property>
-         <property name="textFormat">
-          <enum>Qt::AutoText</enum>
-         </property>
-         <property name="alignment">
-          <set>Qt::AlignCenter</set>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QListView" name="listView">
-         <property name="editTriggers">
-          <set>QAbstractItemView::NoEditTriggers</set>
-         </property>
-         <property name="selectionMode">
-          <enum>QAbstractItemView::MultiSelection</enum>
-         </property>
-         <property name="isWrapping" stdset="0">
-          <bool>false</bool>
-         </property>
-         <property name="spacing">
-          <number>1</number>
-         </property>
-         <property name="selectionRectVisible">
-          <bool>false</bool>
-         </property>
-        </widget>
-       </item>
-      </layout>
+        <number>1</number>
+       </property>
+       <property name="selectionRectVisible">
+        <bool>false</bool>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QVBoxLayout" name="verticalLayout_2">
+     <item>
+      <widget class="QPushButton" name="viewButton">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="minimumSize">
+        <size>
+         <width>70</width>
+         <height>70</height>
+        </size>
+       </property>
+       <property name="maximumSize">
+        <size>
+         <width>70</width>
+         <height>70</height>
+        </size>
+       </property>
+       <property name="text">
+        <string/>
+       </property>
+       <property name="icon">
+        <iconset resource="../../resources/resources.qrc">
+         <normaloff>:/icons/artists.png</normaloff>:/icons/artists.png</iconset>
+       </property>
+       <property name="flat">
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="verticalSpacer">
+       <property name="orientation">
+        <enum>Qt::Vertical</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>20</width>
+         <height>40</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QPushButton" name="dynamicButton">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="minimumSize">
+        <size>
+         <width>70</width>
+         <height>70</height>
+        </size>
+       </property>
+       <property name="maximumSize">
+        <size>
+         <width>70</width>
+         <height>70</height>
+        </size>
+       </property>
+       <property name="text">
+        <string/>
+       </property>
+       <property name="icon">
+        <iconset resource="../../resources/resources.qrc">
+         <normaloff>:/icons/dynamic.png</normaloff>:/icons/dynamic.png</iconset>
+       </property>
+       <property name="flat">
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="verticalSpacer_2">
+       <property name="orientation">
+        <enum>Qt::Vertical</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>20</width>
+         <height>40</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QPushButton" name="playlistsButton">
+       <property name="minimumSize">
+        <size>
+         <width>70</width>
+         <height>70</height>
+        </size>
+       </property>
+       <property name="maximumSize">
+        <size>
+         <width>70</width>
+         <height>70</height>
+        </size>
+       </property>
+       <property name="text">
+        <string/>
+       </property>
+       <property name="icon">
+        <iconset resource="../../resources/resources.qrc">
+         <normaloff>:/icons/playlists.png</normaloff>:/icons/playlists.png</iconset>
+       </property>
+       <property name="flat">
+        <bool>true</bool>
+       </property>
+      </widget>
      </item>
     </layout>
    </item>
index b6c3180..4361c8d 100644 (file)
        <number>0</number>
       </property>
       <item>
+       <widget class="QPushButton" name="fscreenButton">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="minimumSize">
+         <size>
+          <width>60</width>
+          <height>60</height>
+         </size>
+        </property>
+        <property name="maximumSize">
+         <size>
+          <width>60</width>
+          <height>60</height>
+         </size>
+        </property>
+        <property name="text">
+         <string/>
+        </property>
+        <property name="icon">
+         <iconset resource="../../resources/resources.qrc">
+          <normaloff>:/icons/fullscreen.png</normaloff>:/icons/fullscreen.png</iconset>
+        </property>
+        <property name="flat">
+         <bool>true</bool>
+        </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>
        <spacer name="horizontalSpacer">
         <property name="orientation">
          <enum>Qt::Horizontal</enum>