Changeset 28


Ignore:
Timestamp:
01/05/08 16:32:32 (4 years ago)
Author:
sander
Message:

Made it possible to set "random" and "repeat"

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • gui/main_window.cpp

    r26 r28  
    5050    connect(playPauseTrackButton, SIGNAL(clicked(bool)), this, SLOT(playPauseTrack())); 
    5151    connect(nextTrackButton, SIGNAL(clicked(bool)), this, SLOT(nextTrack())); 
     52    connect(randomCheckBox, SIGNAL(stateChanged(int)), this, SLOT(setRandom(int))); 
     53    connect(repeatCheckBox, SIGNAL(stateChanged(int)), this, SLOT(setRepeat(int))); 
    5254    connect(playlistTableView, SIGNAL(activated(const QModelIndex &)), this, SLOT(playlistItemActivated(const QModelIndex &))); 
    5355    connect(removeFromPlaylistPushButton, SIGNAL(clicked(bool)), this, SLOT(removeFromPlaylist())); 
     
    116118} 
    117119 
     120void MainWindow::setRandom(int state) 
     121{ 
     122    if(state == Qt::Checked) 
     123        mpd.setRandom(true); 
     124    else 
     125        mpd.setRandom(false); 
     126} 
     127 
     128void MainWindow::setRepeat(int state) 
     129{ 
     130    if(state == Qt::Checked) 
     131        mpd.setRepeat(true); 
     132    else 
     133        mpd.setRepeat(false); 
     134} 
     135 
    118136void MainWindow::updateCurrentSong(Song *song) 
    119137{ 
     
    136154    if(!slidingVolume) 
    137155        volumeSlider->setValue(status.volume); 
     156 
     157    if(status.random) { 
     158        randomCheckBox->setCheckState(Qt::Checked); 
     159    } else { 
     160        randomCheckBox->setCheckState(Qt::Unchecked); 
     161    } 
     162 
     163    if(status.repeat) { 
     164        repeatCheckBox->setCheckState(Qt::Checked); 
     165    } else { 
     166        repeatCheckBox->setCheckState(Qt::Unchecked); 
     167    } 
    138168 
    139169    if(status.time_total == -1) { 
  • gui/main_window.h

    r26 r28  
    3838        void previousTrack(); 
    3939        void setVolume(); 
     40        void setRandom(int); 
     41        void setRepeat(int); 
    4042        void updateCurrentSong(Song *song); 
    4143        void updateStatus(const MPDStatus &status); 
  • gui/main_window.ui

    r26 r28  
    66    <x>0</x> 
    77    <y>0</y> 
    8     <width>649</width> 
     8    <width>918</width> 
    99    <height>600</height> 
    1010   </rect> 
     
    173173          <layout class="QHBoxLayout" > 
    174174           <item> 
    175             <widget class="QPushButton" name="prevTrackButton" > 
    176              <property name="sizePolicy" > 
    177               <sizepolicy vsizetype="Fixed" hsizetype="Maximum" > 
    178                <horstretch>0</horstretch> 
    179                <verstretch>0</verstretch> 
    180               </sizepolicy> 
    181              </property> 
    182              <property name="text" > 
    183               <string>Previous</string> 
    184              </property> 
    185             </widget> 
    186            </item> 
    187            <item> 
    188             <widget class="QPushButton" name="stopTrackButton" > 
    189              <property name="sizePolicy" > 
    190               <sizepolicy vsizetype="Fixed" hsizetype="Maximum" > 
    191                <horstretch>0</horstretch> 
    192                <verstretch>0</verstretch> 
    193               </sizepolicy> 
    194              </property> 
    195              <property name="text" > 
    196               <string>Stop</string> 
    197              </property> 
    198             </widget> 
    199            </item> 
    200            <item> 
    201             <widget class="QPushButton" name="playPauseTrackButton" > 
    202              <property name="sizePolicy" > 
    203               <sizepolicy vsizetype="Fixed" hsizetype="Maximum" > 
    204                <horstretch>0</horstretch> 
    205                <verstretch>0</verstretch> 
    206               </sizepolicy> 
    207              </property> 
    208              <property name="text" > 
    209               <string>Play</string> 
    210              </property> 
    211              <property name="checkable" > 
    212               <bool>true</bool> 
    213              </property> 
    214             </widget> 
    215            </item> 
    216            <item> 
    217             <widget class="QPushButton" name="nextTrackButton" > 
    218              <property name="sizePolicy" > 
    219               <sizepolicy vsizetype="Fixed" hsizetype="Maximum" > 
    220                <horstretch>0</horstretch> 
    221                <verstretch>0</verstretch> 
    222               </sizepolicy> 
    223              </property> 
    224              <property name="text" > 
    225               <string>Next</string> 
    226              </property> 
    227             </widget> 
     175            <layout class="QHBoxLayout" > 
     176             <item> 
     177              <widget class="QPushButton" name="prevTrackButton" > 
     178               <property name="sizePolicy" > 
     179                <sizepolicy vsizetype="Fixed" hsizetype="Maximum" > 
     180                 <horstretch>0</horstretch> 
     181                 <verstretch>0</verstretch> 
     182                </sizepolicy> 
     183               </property> 
     184               <property name="text" > 
     185                <string>Previous</string> 
     186               </property> 
     187              </widget> 
     188             </item> 
     189             <item> 
     190              <widget class="QPushButton" name="stopTrackButton" > 
     191               <property name="sizePolicy" > 
     192                <sizepolicy vsizetype="Fixed" hsizetype="Maximum" > 
     193                 <horstretch>0</horstretch> 
     194                 <verstretch>0</verstretch> 
     195                </sizepolicy> 
     196               </property> 
     197               <property name="text" > 
     198                <string>Stop</string> 
     199               </property> 
     200              </widget> 
     201             </item> 
     202             <item> 
     203              <widget class="QPushButton" name="playPauseTrackButton" > 
     204               <property name="sizePolicy" > 
     205                <sizepolicy vsizetype="Fixed" hsizetype="Maximum" > 
     206                 <horstretch>0</horstretch> 
     207                 <verstretch>0</verstretch> 
     208                </sizepolicy> 
     209               </property> 
     210               <property name="text" > 
     211                <string>Play</string> 
     212               </property> 
     213               <property name="checkable" > 
     214                <bool>true</bool> 
     215               </property> 
     216              </widget> 
     217             </item> 
     218             <item> 
     219              <widget class="QPushButton" name="nextTrackButton" > 
     220               <property name="sizePolicy" > 
     221                <sizepolicy vsizetype="Fixed" hsizetype="Maximum" > 
     222                 <horstretch>0</horstretch> 
     223                 <verstretch>0</verstretch> 
     224                </sizepolicy> 
     225               </property> 
     226               <property name="text" > 
     227                <string>Next</string> 
     228               </property> 
     229              </widget> 
     230             </item> 
     231            </layout> 
    228232           </item> 
    229233           <item> 
     
    234238             <property name="sizeHint" > 
    235239              <size> 
    236                <width>40</width> 
     240               <width>108</width> 
    237241               <height>20</height> 
    238242              </size> 
    239243             </property> 
    240244            </spacer> 
     245           </item> 
     246           <item> 
     247            <layout class="QVBoxLayout" > 
     248             <property name="leftMargin" > 
     249              <number>16</number> 
     250             </property> 
     251             <property name="rightMargin" > 
     252              <number>16</number> 
     253             </property> 
     254             <item> 
     255              <widget class="QCheckBox" name="randomCheckBox" > 
     256               <property name="text" > 
     257                <string>Random</string> 
     258               </property> 
     259              </widget> 
     260             </item> 
     261             <item> 
     262              <widget class="QCheckBox" name="repeatCheckBox" > 
     263               <property name="text" > 
     264                <string>Repeat</string> 
     265               </property> 
     266              </widget> 
     267             </item> 
     268            </layout> 
    241269           </item> 
    242270          </layout> 
     
    374402     <x>0</x> 
    375403     <y>0</y> 
    376      <width>649</width> 
     404     <width>918</width> 
    377405     <height>29</height> 
    378406    </rect> 
  • lib/mpdparseutils.cpp

    r27 r28  
    1616            destStatus.volume = tokens.at(1).toUInt(); 
    1717        } else if(tokens.at(0) == "repeat") { 
    18             if(tokens.at(1) == "1") { 
     18            if(tokens.at(1).trimmed() == "1") { 
    1919                destStatus.repeat = true; 
    2020            } else { 
     
    2222            } 
    2323        } else if(tokens.at(0) == "random") { 
    24             if(tokens.at(1) == "1") { 
    25                 destStatus.random = "1"; 
     24            if(tokens.at(1).trimmed() == "1") { 
     25                destStatus.random = true; 
    2626            } else { 
    27                 destStatus.random = "0"; 
     27                destStatus.random = false; 
    2828            } 
    2929        } else if(tokens.at(0) == "playlist") { 
Note: See TracChangeset for help on using the changeset viewer.