Changeset 25 for gui/main_window.cpp


Ignore:
Timestamp:
12/31/07 15:06:00 (4 years ago)
Author:
sander
Message:

Preferences dialog is now functional and pops up when no connection can be made

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gui/main_window.cpp

    r19 r25  
    11#include <cmath> 
    22#include <QtGui> 
     3 
    34#include "main_window.h" 
     5#include "preferences_dialog.h" 
    46 
    57MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) 
    68{ 
     9    QSettings settings; 
     10 
    711    setupUi(this); 
    812 
    9     //mpd_status = NULL; 
    1013    slidingVolume = false; 
    1114 
     15    // Start connection thread 
    1216    mpd.start(); 
    13     mpd.setHostname("mediapc"); 
    14     mpd.setPort(6600); 
    15     if(!mpd.connectToMPD()) { 
    16         qDebug("Big trouble! Exiting..."); 
    17         qApp->quit(); 
     17 
     18    // Set connection data 
     19    mpd.setHostname(settings.value("connection/host").toString()); 
     20    mpd.setPort(settings.value("connection/port").toInt()); 
     21 
     22    while(!mpd.connectToMPD()) { 
     23        showPreferencesDialog(); 
     24 
     25        mpd.setHostname(settings.value("connection/host").toString()); 
     26        mpd.setPort(settings.value("connection/port").toInt()); 
    1827    } 
    1928 
     
    3342 
    3443    // GUI 
     44    connect(action_Preferences, SIGNAL(triggered(bool)), this, SLOT(showPreferencesDialog())); 
    3545    connect(volumeSlider, SIGNAL(sliderPressed()), this, SLOT(volumeSliderPressed())); 
    3646    connect(volumeSlider, SIGNAL(sliderReleased()), this, SLOT(setVolume())); 
     
    5868}*/ 
    5969 
     70void MainWindow::showPreferencesDialog() 
     71{ 
     72    PreferencesDialog pref(this); 
     73    pref.exec(); 
     74} 
     75 
    6076void MainWindow::volumeSliderPressed() 
    6177{ 
     
    210226    QModelIndex mappedIndex = libraryProxyModel.mapToSource(index); 
    211227    item = static_cast<MusicLibraryItem *>(mappedIndex.internalPointer()); 
     228    MPDStatus::State curState = mpd_status.state; 
    212229 
    213230    switch(item->type()) { 
     
    232249    if(!files.isEmpty()) { 
    233250        mpd.add(files); 
    234         mpd.startPlayingSong(); 
    235     } 
    236 } 
     251        if(curState != MPDStatus::State_Playing) 
     252            mpd.startPlayingSong(); 
     253    } 
     254} 
Note: See TracChangeset for help on using the changeset viewer.