Пример #1
0
TrackSelectionDialog::TrackSelectionDialog(QWidget* parent)
    : QDialog(parent), ui_(new Ui_TrackSelectionDialog), save_on_close_(false) {
  // Setup dialog window
  ui_->setupUi(this);

  connect(ui_->song_list, SIGNAL(currentRowChanged(int)), SLOT(UpdateStack()));
  connect(ui_->results,
          SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
          SLOT(ResultSelected()));

  ui_->splitter->setSizes(QList<int>() << 200 << width() - 200);
  SetLoading(QString());

  // Add the next/previous buttons
  previous_button_ =
      new QPushButton(IconLoader::Load("go-previous", IconLoader::Base), 
                      tr("Previous"), this);
  next_button_ = new QPushButton(IconLoader::Load("go-next", IconLoader::Base), 
                                 tr("Next"), this);
  ui_->button_box->addButton(previous_button_, QDialogButtonBox::ResetRole);
  ui_->button_box->addButton(next_button_, QDialogButtonBox::ResetRole);

  connect(previous_button_, SIGNAL(clicked()), SLOT(PreviousSong()));
  connect(next_button_, SIGNAL(clicked()), SLOT(NextSong()));

  // Set some shortcuts for the buttons
  new QShortcut(QKeySequence::Back, previous_button_, SLOT(click()));
  new QShortcut(QKeySequence::Forward, next_button_, SLOT(click()));
  new QShortcut(QKeySequence::MoveToPreviousPage, previous_button_,
                SLOT(click()));
  new QShortcut(QKeySequence::MoveToNextPage, next_button_, SLOT(click()));

  // Resize columns
  ui_->results->setColumnWidth(0, 50);   // Track column
  ui_->results->setColumnWidth(1, 50);   // Year column
  ui_->results->setColumnWidth(2, 160);  // Title column
  ui_->results->setColumnWidth(3, 160);  // Artist column
  ui_->results->setColumnWidth(4, 160);  // Album column
}
Пример #2
0
void CMusikPlayer::PlayPause()
{
	//--- paused, so play ---//
	if ( IsPlaying() && !IsPaused() )
		Pause();

	//--- paused, so resume ---//
	else if ( IsPlaying() && IsPaused() )
		Resume();

	//--- start playing ---//
	else if ( !IsPlaying() )
	{
		if(GetPlaymode() == MUSIK_PLAYMODE_SHUFFLE)
		{
			NextSong();
		}
		else
		{
			PlayByUser( m_SongIndex );
		}
	}
}
Пример #3
0
/* Check for the quit event, return true if detected*/
char getEvent(display *d, Button *buttons[NUM_BUTTONS], Button *HomeButtons[HOME_BUTTON_NUM], Button *OptionButtons[O_B_TOTAL])
{
  char what = NONE;
  int sym;
  //avoid repeating inputs ---------------------
  while (SDL_PollEvent(d->event) != 0) {
    int x, y;
    SDL_GetMouseState(&x, &y);
    switch (d->event->type) {
      case SDL_QUIT:
        what = QUIT;
        break;
      case  SDL_TEXTINPUT:
        if ((what != CLICK1) && (what != HINT)) {
          what = d->event->text.text[0];
          printf("ordinary character form keyboard %c\n", what);
          fflush(stdout);
          break;
        }
      case SDL_KEYDOWN:
        sym = d->event->key.keysym.sym;
        if (sym == ENTER) {
          what = (char)sym;
        }
        else if ((sym == SDLK_LCTRL) || (sym == SDLK_RCTRL)) {
          ctrl_pressed = true; //ctrl part--------------
        }
        else if (ctrl_pressed) {
          if (sym == MUTE) {
            if (Mix_PausedMusic() == true) {
              Mix_ResumeMusic();
              m_state = MUSIC_ON;
            }
            else {
              Mix_PauseMusic();
              m_state = MUSIC_OFF;
            }
          }
          if (sym == SDLK_q) {
            what = QUIT;
          }
          //----------next song
          if (sym == SDLK_n) {
            NextSong();
            m_state = MUSIC_ON;
          }
          ctrl_pressed = false;
        }
        else if (sym == BS || sym == TAB || sym == ENTER || sym == DEL) {
          what = (char)sym;
        }
        else if (sym == SDLK_UP) {
          what = (char)UP;
        }
        else if (sym == SDLK_DOWN) {
          what = (char)DOWN;
        }
        else if (sym == SDLK_LEFT) {
          what = (char)LEFT;
        }
        else if (sym == SDLK_RIGHT) {
          what = (char)RIGHT;
        }
        break;
      case SDL_MOUSEBUTTONDOWN:
        printf("in mouse %d  %d\n", d->event->button.x, d->event->button.y);
        fflush(stdout);
        //-------------------------------------
        if (gScene == HOME_SCREEN) {
          if (is_point_in_rect(d->event->button.x, d->event->button.y, &HomeButtons[0]->rectangle)) {
            what = ENTER_GAME;
          }
          if (is_point_in_rect(d->event->button.x, d->event->button.y, &HomeButtons[1]->rectangle)) {
            what = ENTER_OPTION;
          }
          if (is_point_in_rect(d->event->button.x, d->event->button.y, &HomeButtons[2]->rectangle)) {
            what = ENTER_ABOUT;
          }
        }
        else if (gScene == GAME_SCREEN) {
          if (is_point_in_rect(d->event->button.x, d->event->button.y, &buttons[0]->rectangle)) {
            what = CLICK1;
          }
          else if (is_point_in_rect(d->event->button.x, d->event->button.y, &buttons[1]->rectangle)) {
            what = HINT;
          }
          else if (is_point_in_rect(d->event->button.x, d->event->button.y, &buttons[2]->rectangle)) {
            what = NEWGAME;
          }
          else if (is_point_in_rect(d->event->button.x, d->event->button.y, &buttons[3]->rectangle)) {
            what = STOOL;
          }
          else if (is_point_in_rect(d->event->button.x, d->event->button.y, &buttons[4]->rectangle)) {
            what = BOOTH;
          }
          else if (is_point_in_rect(d->event->button.x, d->event->button.y, &buttons[5]->rectangle)) {
            what = GREEN;
          }
        }
        break;
      case SDL_MOUSEMOTION:
        if (gScene == HOME_SCREEN) {
          if (is_point_in_rect(x, y, &HomeButtons[0]->rectangle)) {
            what = HOVER_GAME;
          }
          else if (is_point_in_rect(x, y, &HomeButtons[1]->rectangle)) {
            what = HOVER_OPTION;
          }
          else if (is_point_in_rect(x, y, &HomeButtons[2]->rectangle)) {
            what = HOVER_ABOUT;
          }
          else
          {
            what = OUT_BUTTON;
          }
        }
        else if (gScene == OPTION_SCREEN) {
          if (is_point_in_rect(x, y, &OptionButtons[BACK]->rectangle)) {
            what = BACK_HOVER;
          }
          else {
            what = OUT_BACK;
          }
        }
        break;
      case SDL_MOUSEBUTTONUP:
        if (gScene == OPTION_SCREEN) {
          if (is_point_in_rect(x, y, &OptionButtons[BACK]->rectangle)) {
            what = BACK_HOME;
          }
        }
        break;
      default:
        break;
    }
  }
  return what;
}
Пример #4
0
EditTagDialog::EditTagDialog(Application* app, QWidget* parent)
    : QDialog(parent),
      ui_(new Ui_EditTagDialog),
      app_(app),
      album_cover_choice_controller_(new AlbumCoverChoiceController(this)),
      loading_(false),
      ignore_edits_(false),
      tag_fetcher_(new TagFetcher(this)),
      cover_art_id_(0),
      cover_art_is_set_(false),
      results_dialog_(new TrackSelectionDialog(this)) {
  cover_options_.default_output_image_ =
      AlbumCoverLoader::ScaleAndPad(cover_options_, QImage(":nocover.png"));

  connect(app_->album_cover_loader(),
          SIGNAL(ImageLoaded(quint64, QImage, QImage)),
          SLOT(ArtLoaded(quint64, QImage, QImage)));

  connect(tag_fetcher_, SIGNAL(ResultAvailable(Song, SongList)),
          results_dialog_, SLOT(FetchTagFinished(Song, SongList)),
          Qt::QueuedConnection);
  connect(tag_fetcher_, SIGNAL(Progress(Song, QString)), results_dialog_,
          SLOT(FetchTagProgress(Song, QString)));
  connect(results_dialog_, SIGNAL(SongChosen(Song, Song)),
          SLOT(FetchTagSongChosen(Song, Song)));
  connect(results_dialog_, SIGNAL(finished(int)), tag_fetcher_, SLOT(Cancel()));

  album_cover_choice_controller_->SetApplication(app_);

  ui_->setupUi(this);
  ui_->splitter->setSizes(QList<int>() << 200 << width() - 200);
  ui_->loading_label->hide();

  // An editable field is one that has a label as a buddy.  The label is
  // important because it gets turned bold when the field is changed.
  for (QLabel* label : findChildren<QLabel*>()) {
    QWidget* widget = label->buddy();
    if (widget) {
      // Store information about the field
      fields_ << FieldData(label, widget, widget->objectName());

      // Connect the Reset signal
      if (dynamic_cast<ExtendedEditor*>(widget)) {
        connect(widget, SIGNAL(Reset()), SLOT(ResetField()));
      }

      // Connect the edited signal
      if (qobject_cast<QLineEdit*>(widget)) {
        connect(widget, SIGNAL(textChanged(QString)), SLOT(FieldValueEdited()));
      } else if (qobject_cast<QPlainTextEdit*>(widget)) {
        connect(widget, SIGNAL(textChanged()), SLOT(FieldValueEdited()));
      } else if (qobject_cast<QSpinBox*>(widget)) {
        connect(widget, SIGNAL(valueChanged(int)), SLOT(FieldValueEdited()));
      }
    }
  }

  // Set the colour of all the labels on the summary page
  const bool light = palette().color(QPalette::Base).value() > 128;
  const QColor color = palette().color(QPalette::Dark);
  QPalette summary_label_palette(palette());
  summary_label_palette.setColor(
      QPalette::WindowText, light ? color.darker(150) : color.lighter(125));

  for (QLabel* label : ui_->summary_tab->findChildren<QLabel*>()) {
    if (label->property("field_label").toBool()) {
      label->setPalette(summary_label_palette);
    }
  }

  // Pretend the summary text is just a label
  ui_->summary->setMaximumHeight(ui_->art->height() -
                                 ui_->summary_art_button->height() - 4);

  connect(ui_->song_list->selectionModel(),
          SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
          SLOT(SelectionChanged()));
  connect(ui_->button_box, SIGNAL(clicked(QAbstractButton*)),
          SLOT(ButtonClicked(QAbstractButton*)));
  connect(ui_->rating, SIGNAL(RatingChanged(float)), SLOT(SongRated(float)));
  connect(ui_->playcount_reset, SIGNAL(clicked()), SLOT(ResetPlayCounts()));
  connect(ui_->fetch_tag, SIGNAL(clicked()), SLOT(FetchTag()));

  // Set up the album cover menu
  cover_menu_ = new QMenu(this);

  QList<QAction*> actions = album_cover_choice_controller_->GetAllActions();

  connect(album_cover_choice_controller_->cover_from_file_action(),
          SIGNAL(triggered()), this, SLOT(LoadCoverFromFile()));
  connect(album_cover_choice_controller_->cover_to_file_action(),
          SIGNAL(triggered()), this, SLOT(SaveCoverToFile()));
  connect(album_cover_choice_controller_->cover_from_url_action(),
          SIGNAL(triggered()), this, SLOT(LoadCoverFromURL()));
  connect(album_cover_choice_controller_->search_for_cover_action(),
          SIGNAL(triggered()), this, SLOT(SearchForCover()));
  connect(album_cover_choice_controller_->unset_cover_action(),
          SIGNAL(triggered()), this, SLOT(UnsetCover()));
  connect(album_cover_choice_controller_->show_cover_action(),
          SIGNAL(triggered()), this, SLOT(ShowCover()));

  cover_menu_->addActions(actions);

  ui_->summary_art_button->setMenu(cover_menu_);

  ui_->art->installEventFilter(this);
  ui_->art->setAcceptDrops(true);

  // Add the next/previous buttons
  previous_button_ =
      new QPushButton(IconLoader::Load("go-previous"), tr("Previous"), this);
  next_button_ = new QPushButton(IconLoader::Load("go-next"), tr("Next"), this);
  ui_->button_box->addButton(previous_button_, QDialogButtonBox::ResetRole);
  ui_->button_box->addButton(next_button_, QDialogButtonBox::ResetRole);

  connect(previous_button_, SIGNAL(clicked()), SLOT(PreviousSong()));
  connect(next_button_, SIGNAL(clicked()), SLOT(NextSong()));

  // Set some shortcuts for the buttons
  new QShortcut(QKeySequence::Back, previous_button_, SLOT(click()));
  new QShortcut(QKeySequence::Forward, next_button_, SLOT(click()));
  new QShortcut(QKeySequence::MoveToPreviousPage, previous_button_,
                SLOT(click()));
  new QShortcut(QKeySequence::MoveToNextPage, next_button_, SLOT(click()));

  // Show the shortcuts as tooltips
  previous_button_->setToolTip(QString("%1 (%2 / %3)").arg(
      previous_button_->text(),
      QKeySequence(QKeySequence::Back).toString(QKeySequence::NativeText),
      QKeySequence(QKeySequence::MoveToPreviousPage)
          .toString(QKeySequence::NativeText)));
  next_button_->setToolTip(QString("%1 (%2 / %3)").arg(
      next_button_->text(),
      QKeySequence(QKeySequence::Forward).toString(QKeySequence::NativeText),
      QKeySequence(QKeySequence::MoveToNextPage)
          .toString(QKeySequence::NativeText)));

  new TagCompleter(app_->library_backend(), Playlist::Column_Artist,
                   ui_->artist);
  new TagCompleter(app_->library_backend(), Playlist::Column_Album, ui_->album);
  new TagCompleter(app_->library_backend(), Playlist::Column_AlbumArtist,
                   ui_->albumartist);
  new TagCompleter(app_->library_backend(), Playlist::Column_Genre, ui_->genre);
  new TagCompleter(app_->library_backend(), Playlist::Column_Composer,
                   ui_->composer);
  new TagCompleter(app_->library_backend(), Playlist::Column_Performer,
                   ui_->performer);
  new TagCompleter(app_->library_backend(), Playlist::Column_Grouping,
                   ui_->grouping);
}
Пример #5
0
void Player::changeSong(QMediaPlayer::MediaStatus status)
{
    if (status == QMediaPlayer::EndOfMedia)
        NextSong();
}