您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

mainwindow.cpp 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3. #include <yaml-cpp/yaml.h>
  4. MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)//, buf(&tmp)
  5. {
  6. ui->setupUi(this);
  7. currentRadio = 0;
  8. nrj = new NRJ(this);
  9. connect(nrj, SIGNAL(setupFinished()), this, SLOT(setupFinished()));
  10. nrj->setupPlayer();
  11. }
  12. MainWindow::~MainWindow()
  13. {
  14. delete ui;
  15. }
  16. void MainWindow::setupFinished()
  17. {
  18. int i = 0;
  19. foreach(Radio* r, nrj->getRadios())
  20. {
  21. RadioWidget* w = new RadioWidget();
  22. ui->layRadios->addWidget(w, i / 2, i % 2);
  23. connect(w, SIGNAL(clicked(Radio*)), this, SLOT(radioChanged(Radio*)));
  24. w->setRadio(r);
  25. ++i;
  26. }
  27. nrj->getAllCur();
  28. }
  29. void MainWindow::radioChanged(Radio *r)
  30. {
  31. if(currentRadio != 0)
  32. {
  33. currentRadio->stopStream();
  34. currentRadio->disconnect(this);
  35. }
  36. currentRadio = r;
  37. if(currentRadio != 0)
  38. {
  39. currentRadio->startStream();
  40. }
  41. }