Changeset 25
- Timestamp:
- 12/31/07 15:06:00 (4 years ago)
- Files:
-
- 7 edited
-
QtMPC.pro (modified) (1 diff)
-
gui/main_window.cpp (modified) (5 diffs)
-
gui/main_window.h (modified) (1 diff)
-
gui/preferences_dialog.cpp (modified) (3 diffs)
-
gui/preferences_dialog.h (modified) (2 diffs)
-
lib/mpdparseutils.cpp (modified) (3 diffs)
-
main.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
QtMPC.pro
r24 r25 9 9 CONFIG += qt debug 10 10 QT += network 11 #DEFINES += QT_NO_DEBUG_OUTPUT11 DEFINES += QT_NO_DEBUG_OUTPUT 12 12 13 13 # Input -
gui/main_window.cpp
r19 r25 1 1 #include <cmath> 2 2 #include <QtGui> 3 3 4 #include "main_window.h" 5 #include "preferences_dialog.h" 4 6 5 7 MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) 6 8 { 9 QSettings settings; 10 7 11 setupUi(this); 8 12 9 //mpd_status = NULL;10 13 slidingVolume = false; 11 14 15 // Start connection thread 12 16 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()); 18 27 } 19 28 … … 33 42 34 43 // GUI 44 connect(action_Preferences, SIGNAL(triggered(bool)), this, SLOT(showPreferencesDialog())); 35 45 connect(volumeSlider, SIGNAL(sliderPressed()), this, SLOT(volumeSliderPressed())); 36 46 connect(volumeSlider, SIGNAL(sliderReleased()), this, SLOT(setVolume())); … … 58 68 }*/ 59 69 70 void MainWindow::showPreferencesDialog() 71 { 72 PreferencesDialog pref(this); 73 pref.exec(); 74 } 75 60 76 void MainWindow::volumeSliderPressed() 61 77 { … … 210 226 QModelIndex mappedIndex = libraryProxyModel.mapToSource(index); 211 227 item = static_cast<MusicLibraryItem *>(mappedIndex.internalPointer()); 228 MPDStatus::State curState = mpd_status.state; 212 229 213 230 switch(item->type()) { … … 232 249 if(!files.isEmpty()) { 233 250 mpd.add(files); 234 mpd.startPlayingSong(); 235 } 236 } 251 if(curState != MPDStatus::State_Playing) 252 mpd.startPlayingSong(); 253 } 254 } -
gui/main_window.h
r19 r25 30 30 31 31 private slots: 32 void showPreferencesDialog(); 32 33 void volumeSliderPressed(); 33 34 void volumeSliderReleased(); -
gui/preferences_dialog.cpp
r23 r25 3 3 PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f) 4 4 { 5 //loadSettings(); 5 setupUi(this); 6 7 connect(buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(buttonPressed(QAbstractButton *))); 8 9 loadSettings(); 6 10 } 7 11 … … 9 13 { 10 14 hostLineEdit->setText(settings.value("connection/host", "").toString()); 11 portSpinBox->setValue(settings.value("connection/port", 6600).toInt()); 15 portSpinBox->setValue(settings.value("connection/port").toInt()); 16 passwordLineEdit->setText(settings.value("connection/password", "").toString()); 12 17 } 13 18 … … 15 20 { 16 21 } 22 23 void PreferencesDialog::buttonPressed(QAbstractButton *button) 24 { 25 switch(buttonBox->buttonRole(button)) { 26 case QDialogButtonBox::AcceptRole: 27 case QDialogButtonBox::ApplyRole: 28 settings.setValue("connection/host", hostLineEdit->text()); 29 settings.setValue("connection/port", portSpinBox->value()); 30 settings.setValue("connection/password", passwordLineEdit->text()); 31 break; 32 case QDialogButtonBox::RejectRole: 33 break; 34 default: 35 /* unhandled button */ 36 break; 37 } 38 } -
gui/preferences_dialog.h
r23 r25 12 12 13 13 public: 14 PreferencesDialog(QWidget * parent = 0, Qt::WindowFlags f = 0);14 PreferencesDialog(QWidget *parent = 0, Qt::WindowFlags f = 0); 15 15 16 16 private: … … 20 20 void loadSettings(); 21 21 void writeSettings(); 22 void buttonPressed(QAbstractButton *button); 22 23 }; 23 24 -
lib/mpdparseutils.cpp
r19 r25 79 79 if(j != 1 && j != tokens.size() - 1) 80 80 song->album += ":"; 81 song->album += tokens.at(j);81 song->album += QString::fromUtf8(tokens.at(j)); 82 82 } 83 83 } else if(tokens.at(0) == "Artist") { … … 85 85 if(j != 1 && j != tokens.size() - 1) 86 86 song->artist += ":"; 87 song->artist += tokens.at(j);87 song->artist += QString::fromUtf8(tokens.at(j)); 88 88 } 89 89 } else if(tokens.at(0) == "Title") { … … 91 91 if(j != 1 && j != tokens.size() - 1) 92 92 song->title += ":"; 93 song->title += tokens.at(j);93 song->title += QString::fromUtf8(tokens.at(j)); 94 94 } 95 95 } else if(tokens.at(0) == "Track") { -
main.cpp
r8 r25 7 7 QApplication app(argc, argv); 8 8 QApplication::setApplicationName("qtmpc"); 9 QApplication::setOrganizationName("lowblogprojects"); 9 10 10 11 MainWindow w;
Note: See TracChangeset
for help on using the changeset viewer.
