コード例 #1
0
ファイル: song.cpp プロジェクト: Fat-Zer/Clementine
void Song::MergeUserSetData(const Song& other) {
  set_playcount(other.playcount());
  set_skipcount(other.skipcount());
  set_lastplayed(other.lastplayed());
  set_score(other.score());
  set_art_manual(other.art_manual());
  if (rating() == -1.0f) {
    set_rating(other.rating());
  }
}
コード例 #2
0
ファイル: song.cpp プロジェクト: minneyar/Clementine
bool Song::IsOnSameAlbum(const Song& other) const {
  if (is_compilation() != other.is_compilation()) return false;

  if (has_cue() && other.has_cue() && cue_path() == other.cue_path())
    return true;

  if (is_compilation() && album() == other.album()) return true;

  return album() == other.album() && artist() == other.artist();
}
コード例 #3
0
void SongLoader::AudioCDTagsLoaded(const QString& artist, const QString& album,
                                   const MusicBrainzClient::ResultList& results) {
  // Remove previously added songs metadata, because there are not needed
  // and that we are going to fill it with new (more complete) ones
  songs_.clear();
  int track_number = 1;
  foreach (const MusicBrainzClient::Result& ret, results) {
    Song song;
    song.set_artist(artist);
    song.set_album(album);
    song.set_title(ret.title_);
    song.set_length_nanosec(ret.duration_msec_ * kNsecPerMsec);
    song.set_track(track_number);
    song.set_year(ret.year_);
    // We need to set url: that's how playlist will find the correct item to update
    song.set_url(QUrl(QString("cdda://%1").arg(track_number++)));
    songs_ << song;
  }
コード例 #4
0
ファイル: cddadevice.cpp プロジェクト: BrummbQ/Clementine
void CddaDevice::AudioCDTagsLoaded(const QString& artist, const QString& album,
                                   const MusicBrainzClient::ResultList& results) {
  MusicBrainzClient *musicbrainz_client = qobject_cast<MusicBrainzClient*>(sender());
  musicbrainz_client->deleteLater();
  SongList songs;
  int track_number = 1;
  if (results.size() == 0)
    return;
  model_->Reset();
  foreach (const MusicBrainzClient::Result& ret, results) {
    Song song;
    song.set_artist(artist);
    song.set_album(album);
    song.set_title(ret.title_);
    song.set_length_nanosec(ret.duration_msec_ * kNsecPerMsec);
    song.set_track(track_number);
    song.set_year(ret.year_);
    song.set_id(track_number);
    // We need to set url: that's how playlist will find the correct item to update
    song.set_url(QUrl(QString("cdda://%1/%2").arg(unique_id()).arg(track_number++)));
    songs << song;
  }
コード例 #5
0
void AlbumCoverManager::SaveCoverToFile() {
  Song song = GetSingleSelectionAsSong();
  if (!song.is_valid()) return;

  QImage image;

  // load the image from disk
  if (song.has_manually_unset_cover()) {
    image = QImage(":/nocover.png");
  } else {
    if (!song.art_manual().isEmpty() && QFile::exists(song.art_manual())) {
      image = QImage(song.art_manual());
    } else if (!song.art_automatic().isEmpty() &&
               QFile::exists(song.art_automatic())) {
      image = QImage(song.art_automatic());
    } else {
      image = QImage(":/nocover.png");
    }
  }

  album_cover_choice_controller_->SaveCoverToFile(song, image);
}
コード例 #6
0
ファイル: organiseformat.cpp プロジェクト: Gu1/Clementine
QString OrganiseFormat::GetFilenameForSong(const Song& song) const {
    QString filename = ParseBlock(format_, song);

    if (QFileInfo(filename).completeBaseName().isEmpty()) {
        // Avoid having empty filenames, or filenames with extension only: in this
        // case, keep the original filename.
        // We remove the extension from "filename" if it exists, as
        // song.basefilename()
        // also contains the extension.
        filename =
            Utilities::PathWithoutFilenameExtension(filename) + song.basefilename();
    }

    if (replace_spaces_) filename.replace(QRegExp("\\s"), "_");

    if (replace_non_ascii_) {
        QString stripped;
        for (int i = 0; i < filename.length(); ++i) {
            const QCharRef c = filename[i];
            if (c < 128) {
                stripped.append(c);
            } else {
                const QString decomposition = c.decomposition();
                if (!decomposition.isEmpty() && decomposition[0] < 128)
                    stripped.append(decomposition[0]);
                else
                    stripped.append("_");
            }
        }
        filename = stripped;
    }

    // Fix any parts of the path that start with dots.
    QStringList parts = filename.split("/");
    for (int i = 0; i < parts.count(); ++i) {
        QString* part = &parts[i];
        for (int j = 0; j < kInvalidPrefixCharactersCount; ++j) {
            if (part->startsWith(kInvalidPrefixCharacters[j])) {
                part->replace(0, 1, '_');
                break;
            }
        }
    }

    return parts.join("/");
}
コード例 #7
0
ファイル: onlineview.cpp プロジェクト: Civil/cantata
void OnlineView::update(const Song &song, bool force)
{
    if (force || song!=currentSong) {
        currentSong=song;
        if (!isVisible()) {
            needToUpdate=true;
            return;
        }
        setHeader(song.describe(true));
        Covers::Image cImg=Covers::self()->requestImage(song, true);
        if (!cImg.img.isNull()) {
            setHtml(createPicTag(cImg.img, cImg.fileName));
        } else {
            setHtml(QString());
        }
    }
}
コード例 #8
0
void EditTagDialog::UpdateStatisticsTab(const Song& song) {
  ui_->playcount->setText(QString::number(qMax(0, song.playcount())));
  ui_->skipcount->setText(QString::number(qMax(0, song.skipcount())));
  ui_->score->setText(QString::number(qMax(0, song.score())));
  ui_->rating->set_rating(song.rating());

  ui_->lastplayed->setText(
      song.lastplayed() <= 0
          ? tr("Never")
          : QDateTime::fromTime_t(song.lastplayed()).toString(
                QLocale::system().dateTimeFormat(QLocale::LongFormat)));
}
コード例 #9
0
ファイル: titlewidget.cpp プロジェクト: BinChengfei/cantata
void TitleWidget::update(const Song &sng, const QIcon &icon, const QString &text, const QString &sub, bool showControls)
{
    song=sng;
    image->setVisible(true);
    mainText->setText(text);
    subText->setText(sub);
    if (!showControls) {
        if (controls) {
            controls->setVisible(false);
        }
    } else {
        if (!controls) {
            controls=new QWidget(this);
            QVBoxLayout *l=new QVBoxLayout(controls);
            l->setMargin(0);
            l->setSpacing(0);
            ToolButton *add=new ToolButton(this);
            ToolButton *replace=new ToolButton(this);
            add->QAbstractButton::setIcon(StdActions::self()->appendToPlayQueueAction->icon());
            replace->QAbstractButton::setIcon(StdActions::self()->replacePlayQueueAction->icon());
            add->setToolTip(i18n("Add All To Play Queue"));
            replace->setToolTip(i18n("Add All And Replace Play Queue"));
            l->addWidget(replace);
            l->addWidget(add);
            connect(add, SIGNAL(clicked()), this, SIGNAL(addToPlayQueue()));
            connect(replace, SIGNAL(clicked()), this, SIGNAL(replacePlayQueue()));
            static_cast<QGridLayout *>(layout())->addWidget(controls, 0, 4, 2, 1);
        }
        controls->setVisible(true);
    }
    subText->setVisible(!sub.isEmpty());
    mainText->setAlignment(sub.isEmpty() ? Qt::AlignVCenter : Qt::AlignBottom);
    if (!sng.isEmpty()) {
        Covers::Image cImg=Covers::self()->requestImage(sng, true);
        if (!cImg.img.isNull()) {
            image->setPixmap(QPixmap::fromImage(cImg.img.scaled(image->width()-2, image->height()-2, Qt::KeepAspectRatio, Qt::SmoothTransformation)));
            return;
        }
    }
    if (icon.isNull()) {
        image->setVisible(false);
    } else {
        image->setPixmap(Icon::getScaledPixmap(icon, image->width(), image->height(), 96));
    }
}
コード例 #10
0
void EditTagDialog::ResetPlayCounts() {
  const QModelIndexList sel =
      ui_->song_list->selectionModel()->selectedIndexes();
  if (sel.isEmpty()) return;
  Song* song = &data_[sel.first().row()].original_;
  if (!song->is_valid() || song->id() == -1) return;

  if (QMessageBox::question(
          this, tr("Reset play counts"),
          tr("Are you sure you want to reset this song's statistics?"),
          QMessageBox::Reset, QMessageBox::Cancel) != QMessageBox::Reset) {
    return;
  }

  song->set_playcount(0);
  song->set_skipcount(0);
  song->set_lastplayed(-1);
  song->set_score(0);
  app_->library_backend()->ResetStatisticsAsync(song->id());
  UpdateStatisticsTab(*song);
}
コード例 #11
0
ファイル: spotifyservice.cpp プロジェクト: Korvox/Clementine
QList<QAction*> SpotifyService::playlistitem_actions(const Song& song) {
  // Clear previous actions
  while (!playlistitem_actions_.isEmpty()) {
    QAction* action = playlistitem_actions_.takeFirst();
    delete action->menu();
    delete action;
  }

  QAction* add_to_starred =
      new QAction(QIcon(":/star-on.png"), tr("Add to Spotify starred"), this);
  connect(add_to_starred, SIGNAL(triggered()),
          SLOT(AddCurrentSongToStarredPlaylist()));
  playlistitem_actions_.append(add_to_starred);

  // Create a menu with 'add to playlist' actions for each Spotify playlist
  QAction* add_to_playlists = new QAction(IconLoader::Load("list-add", 
                                          IconLoader::Base),
                                          tr("Add to Spotify playlists"), this);
  QMenu* playlists_menu = new QMenu();
  for (const QStandardItem* playlist_item : playlists_) {
    if (!playlist_item->data(InternetModel::Role_CanBeModified).toBool()) {
      continue;
    }
    QAction* add_to_playlist = new QAction(playlist_item->text(), this);
    add_to_playlist->setData(playlist_item->data(Role_UserPlaylistIndex));
    playlists_menu->addAction(add_to_playlist);
  }
  connect(playlists_menu, SIGNAL(triggered(QAction*)),
          SLOT(AddCurrentSongToUserPlaylist(QAction*)));
  add_to_playlists->setMenu(playlists_menu);
  playlistitem_actions_.append(add_to_playlists);

  QAction* share_song =
      new QAction(tr("Get a URL to share this Spotify song"), this);
  connect(share_song, SIGNAL(triggered()), SLOT(GetCurrentSongUrlToShare()));
  playlistitem_actions_.append(share_song);

  // Keep in mind the current song URL
  current_song_url_ = song.url();

  return playlistitem_actions_;
}
コード例 #12
0
ファイル: main.cpp プロジェクト: byliuyang/HIVE_LIBS
int main(int argc, char* argv[]){

	song.initialize(argv[1]);

	Hive test;
	test.display_version();
	Scene scene;
	scene.initialize("Window", 640*1.5, 480*1.5);
	scene.angle = 0.0;

	button1.initialize(&scene.mouse,100,440,70,40,false);
	button2.initialize(&scene.mouse,60,675,40,40,false);
	slider1.initialize(&scene.mouse, 480, 675, 750, 40, 0, false);

	std::thread thread1(run_audio);

	double xcoord = -0.9;
	for (int i = 0; i < 2000; ++i)
	{
		pointsl[i].initialize(xcoord,0,0,3,Color4d(1,1,1,1),Color4d(1,1,1,1));
		xcoord += 1.8/2000;
	}

	xcoord = -0.9;

	for (int i = 0; i < 2000; ++i)
	{
		pointsd[i].initialize(xcoord,0,0,3,Color4d(1,1,1,1),Color4d(1,1,1,1));
		xcoord += 1.8/2000;
	}


	while(scene.run()){
		
	}

	threadexit = false;

	thread1.join();

	return 0;
}
コード例 #13
0
void TrackSelectionDialog::FetchTagProgress(const Song& original_song,
                                            const QString& progress) {
  // Find the item with this filename
  int row = -1;
  for (int i = 0; i < data_.count(); ++i) {
    if (data_[i].original_song_.url() == original_song.url()) {
      row = i;
      break;
    }
  }

  if (row == -1) return;

  data_[row].progress_string_ = progress;

  // If it's the current item, update the display
  if (ui_->song_list->currentIndex().row() == row) {
    UpdateStack();
  }
}
コード例 #14
0
bool Song::IsMetadataEqual(const Song& other) const {
  return d->title_ == other.d->title_ &&
         d->album_ == other.d->album_ &&
         d->artist_ == other.d->artist_ &&
         d->albumartist_ == other.d->albumartist_ &&
         d->composer_ == other.d->composer_ &&
         d->track_ == other.d->track_ &&
         d->disc_ == other.d->disc_ &&
         qFuzzyCompare(d->bpm_, other.d->bpm_) &&
         d->year_ == other.d->year_ &&
         d->genre_ == other.d->genre_ &&
         d->comment_ == other.d->comment_ &&
         d->compilation_ == other.d->compilation_ &&
         d->beginning_ == other.d->beginning_ &&
         length_nanosec() == other.length_nanosec() &&
         d->bitrate_ == other.d->bitrate_ &&
         d->samplerate_ == other.d->samplerate_ &&
         d->art_automatic_ == other.d->art_automatic_ &&
         d->art_manual_ == other.d->art_manual_ &&
         d->cue_path_ == other.d->cue_path_;
}
コード例 #15
0
static Song SongFromUrl(const QUrl& url) {
  Song result;
  if (url.scheme() == "vk" && url.host() == "song") {
    QStringList ids = url.path().split('/');
    if (ids.size() == 4) {
      result.set_artist(ids[2]);
      result.set_title(ids[3]);
      result.set_valid(true);
    } else {
      qLog(Error) << "Wrong song url" << url;
      result.set_valid(false);
    }
    result.set_url(url);
  } else {
    qLog(Error) << "Wrong song url" << url;
    result.set_valid(false);
  }
  return result;
}
コード例 #16
0
void AlbumCoverChoiceController::ShowCover(const Song& song) {
  QDialog* dialog = new QDialog(this);
  dialog->setAttribute(Qt::WA_DeleteOnClose, true);

  // Use Artist - Album as the window title
  QString title_text(song.albumartist());
  if (title_text.isEmpty()) title_text = song.artist();

  if (!song.album().isEmpty()) title_text += " - " + song.album();

  dialog->setWindowTitle(title_text);

  QLabel* label = new QLabel(dialog);
  label->setPixmap(AlbumCoverLoader::TryLoadPixmap(
      song.art_automatic(), song.art_manual(), song.url().toLocalFile()));

  dialog->resize(label->pixmap()->size());
  dialog->show();
}
コード例 #17
0
ファイル: modifytag.cpp プロジェクト: mhaehnel/UltraEdit
bool Song::ModifyTag::perform(Song& song) {
    switch (operation_) {
        case Op::Create:
            return song.addTag(tag_,newVal_);
        case Op::Modify:
            if (!song.hasTag(tag_)) return false;
            oldVal_ = song.tag(tag_);
            return song.setTag(tag_,newVal_);
        case Op::Delete:
            if (!song.hasTag(tag_)) return false;
            oldVal_ = song.tag(tag_);
            song.tags.remove(tag_);
            return true;
    }
    return false; //Stupid GCC
}
コード例 #18
0
ファイル: MediaApp.cpp プロジェクト: helcl42/Streaming
/**
 * function adds to playlist any 
 * selected files from file dialog
 */
void MediaApp::open() {
    QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open a Media"), m_baseDir);

    for (int i = 0; i < fileNames.count(); i++) {
        if (!fileNames.at(i).isEmpty()) {
            Song* song = new Song();
            song->setId(m_playlist->getActualPosition() + 1);
            song->setTitle(Song::getSongTitleFromPath(fileNames.at(i).toStdString()));
            song->setUrl(fileNames.at(i).toStdString());
            song->setLength(m_player->getLength().toString("hh:mm:ss").toStdString());
            song->setFromLibrary(false);
            song->setAudio(Song::findOutIfAudioMedia(song));
            m_playlist->insert(song);

            if (i == 0) {
                openFile(song);
            }
        }
    }
}
コード例 #19
0
QString AlbumCoverChoiceController::GetInitialPathForFileDialog(
    const Song& song, const QString& filename) {
  // art automatic is first to show user which cover the album may be
  // using now; the song is using it if there's no manual path but we
  // cannot use manual path here because it can contain cached paths
  if (!song.art_automatic().isEmpty() && !song.has_embedded_cover()) {
    return song.art_automatic();

    // if no automatic art, start in the song's folder
  } else if (!song.url().isEmpty() && song.url().toLocalFile().contains('/')) {
    return song.url().toLocalFile().section('/', 0, -2) + filename;

    // fallback - start in home
  } else {
    return QDir::home().absolutePath() + filename;
  }
}
コード例 #20
0
ファイル: NotesLoaderSM.cpp プロジェクト: AratnitY/stepmania
void SMLoader::ProcessBGChanges( Song &out, const RString &sValueName, const RString &sPath, const RString &sParam )
{
	BackgroundLayer iLayer = BACKGROUND_LAYER_1;
	if( sscanf(sValueName, "BGCHANGES%d", &*ConvertValue<int>(&iLayer)) == 1 )
		enum_add(iLayer, -1);	// #BGCHANGES2 = BACKGROUND_LAYER_2
	
	bool bValid = iLayer>=0 && iLayer<NUM_BackgroundLayer;
	if( !bValid )
	{
		LOG->UserLog( "Song file", sPath, "has a #BGCHANGES tag \"%s\" that is out of range.", sValueName.c_str() );
	}
	else
	{
		vector<RString> aBGChangeExpressions;
		split( sParam, ",", aBGChangeExpressions );
		
		for( unsigned b=0; b<aBGChangeExpressions.size(); b++ )
		{
			BackgroundChange change;
			if( LoadFromBGChangesString( change, aBGChangeExpressions[b] ) )
				out.AddBackgroundChange( iLayer, change );
		}
	}
}
コード例 #21
0
void  TestUseCaseUndo::select (Song & song, const std::set <Ref> & ref_set)
{
   for (const auto & ref : ref_set)
   {
      // insert if not in selection

      auto it = song._selection.find_if ([&ref](SelectionElem & elem) {
         return elem.template use <Object> ().ref () == ref;
      });

      if (it == song._selection.end ())
      {
         song._selection.emplace (song.document ().object <Object> (ref));
      }
   }

   auto it = song._selection.begin ();
   auto it_end = song._selection.end ();

   for (; it != it_end ;)
   {
      auto it_next = it;
      ++it_next;

      auto & elem = *it;

      // erase if not in 'ref_set'

      if (ref_set.find (elem.use <Object> ().ref ()) == ref_set.end ())
      {
         song._selection.erase (it);
      }

      it = it_next;
   }
}
コード例 #22
0
void AlbumCoverChoiceController::ShowCover(const Song& song) {
  QDialog* dialog = new QDialog(this);
  dialog->setAttribute(Qt::WA_DeleteOnClose, true);

  // Use (Album)Artist - Album as the window title
  QString title_text(song.effective_albumartist());
  if (!song.effective_album().isEmpty())
    title_text += " - " + song.effective_album();

  QLabel* label = new QLabel(dialog);
  label->setPixmap(AlbumCoverLoader::TryLoadPixmap(
      song.art_automatic(), song.art_manual(), song.url().toLocalFile()));

  // add (WxHpx) to the title before possibly resizing
  title_text += " (" + QString::number(label->pixmap()->width()) + "x" +
                QString::number(label->pixmap()->height()) + "px)";

  // if the cover is larger than the screen, resize the window
  // 85% seems to be enough to account for title bar and taskbar etc.
  QDesktopWidget desktop;
  int current_screen = desktop.screenNumber(this);
  int desktop_height = desktop.screenGeometry(current_screen).height();
  int desktop_width = desktop.screenGeometry(current_screen).width();

  // resize differently if monitor is in portrait mode
  if (desktop_width < desktop_height) {
    const int new_width = (double)desktop_width * 0.95;
    if (new_width < label->pixmap()->width()) {
      label->setPixmap(
          label->pixmap()->scaledToWidth(new_width, Qt::SmoothTransformation));
    }
  } else {
    const int new_height = (double)desktop_height * 0.85;
    if (new_height < label->pixmap()->height()) {
      label->setPixmap(label->pixmap()->scaledToHeight(
          new_height, Qt::SmoothTransformation));
    }
  }

  dialog->setWindowTitle(title_text);
  dialog->setFixedSize(label->pixmap()->size());
  dialog->show();
}
コード例 #23
0
TEST_F(ASXParserTest, SavesSong) {
  QByteArray data;
  QBuffer buffer(&data);
  buffer.open(QIODevice::WriteOnly);
  ASXParser parser(NULL);
  Song one;
  one.set_url(QUrl("http://www.example.com/foo.mp3"));
  one.set_filetype(Song::Type_Stream);
  one.set_title("foo");
  one.set_length_nanosec(123 * kNsecPerSec);
  one.set_artist("bar");
  SongList songs;
  songs << one;

  parser.Save(songs, &buffer);
  EXPECT_THAT(data.constData(), HasSubstr("<ref href=\"http://www.example.com/foo.mp3\"/>"));
  EXPECT_THAT(data.constData(), HasSubstr("<title>foo</title>"));
  EXPECT_THAT(data.constData(), HasSubstr("<author>bar</author>"));
}
コード例 #24
0
TEST_F(XSPFParserTest, SavesLocalFile) {
  QByteArray data;
  QBuffer buffer(&data);
  buffer.open(QIODevice::WriteOnly);
  XSPFParser parser(NULL);
  Song one;
  one.set_url(QUrl("file:///bar/foo.mp3"));
  one.set_filetype(Song::Type_Mpeg);
  one.set_title("foo");
  one.set_length_nanosec(123 * kNsecPerSec);
  one.set_artist("bar");
  SongList songs;
  songs << one;

  parser.Save(songs, &buffer);
  EXPECT_THAT(data.constData(), HasSubstr("<location>file:///bar/foo.mp3</location>"));
  EXPECT_THAT(data.constData(), HasSubstr("<duration>123000</duration>"));
  EXPECT_THAT(data.constData(), HasSubstr("<title>foo</title>"));
  EXPECT_THAT(data.constData(), HasSubstr("<creator>bar</creator>"));
}
コード例 #25
0
ファイル: MainForm.cpp プロジェクト: draekko/hydrogen
MainForm::MainForm( QApplication *app, const QString& songFilename )
	: QMainWindow( 0, 0 )
	, Object( __class_name )
{
	setMinimumSize( QSize( 1000, 500 ) );
	setWindowIcon( QPixmap( Skin::getImagePath() + "/icon16.png" ) );

#ifndef WIN32
	if (::socketpair(AF_UNIX, SOCK_STREAM, 0, sigusr1Fd))
		qFatal("Couldn't create HUP socketpair");
	snUsr1 = new QSocketNotifier(sigusr1Fd[1], QSocketNotifier::Read, this);
	connect(snUsr1, SIGNAL(activated(int)), this, SLOT( handleSigUsr1() ));
#endif


	m_pQApp = app;

	m_pQApp->processEvents();

	// Load default song
	Song *pSong = NULL;

	if ( !songFilename.isEmpty() ) {
		pSong = Song::load( songFilename );

		/*
		 * If the song could not be loaded, create
		 * a new one with the specified filename
		 */
		if (pSong == NULL) {
			pSong = Song::get_empty_song();
			pSong->set_filename( songFilename );
		}
	}
	else {
		Preferences *pref = Preferences::get_instance();
		bool restoreLastSong = pref->isRestoreLastSongEnabled();
		QString filename = pref->getLastSongFilename();
		if ( restoreLastSong && ( !filename.isEmpty() )) {
			pSong = Song::load( filename );
			if (pSong == NULL) {
				//QMessageBox::warning( this, "Hydrogen", trUtf8("Error restoring last song.") );
				pSong = Song::get_empty_song();
				pSong->set_filename( "" );
			}
		}
		else {
			pSong = Song::get_empty_song();
			pSong->set_filename( "" );
		}
	}

	h2app = new HydrogenApp( this, pSong );
	h2app->addEventListener( this );
	createMenuBar();

	h2app->setStatusBarMessage( trUtf8("Hydrogen Ready."), 10000 );

	initKeyInstMap();

	// we need to do all this to support the keyboard playing
	// for all the window modes
	h2app->getMixer()->installEventFilter (this);
	h2app->getPatternEditorPanel()->installEventFilter (this);
	h2app->getPatternEditorPanel()->getPianoRollEditor()->installEventFilter (this);
	h2app->getSongEditorPanel()->installEventFilter (this);
	h2app->getPlayerControl()->installEventFilter(this);
	InstrumentEditorPanel::get_instance()->installEventFilter(this);
	h2app->getAudioEngineInfoForm()->installEventFilter(this);
	h2app->getDirector()->installEventFilter(this);
	//	h2app->getPlayListDialog()->installEventFilter(this);
	installEventFilter( this );

	showDevelWarning();

	connect( &m_autosaveTimer, SIGNAL(timeout()), this, SLOT(onAutoSaveTimer()));
	m_autosaveTimer.start( 60 * 1000 );


#ifdef H2CORE_HAVE_LASH

	if ( Preferences::get_instance()->useLash() ){
		LashClient* lashClient = LashClient::get_instance();
		if (lashClient->isConnected())
		{
			// send alsa client id now since it can only be sent
			// after the audio engine has been started.
			Preferences *pref = Preferences::get_instance();
			if ( pref->m_sMidiDriver == "ALSA" ) {
				//			infoLog("[LASH] Sending alsa seq id to LASH server");
				lashClient->sendAlsaClientId();
			}
			// start timer for polling lash events
			lashPollTimer = new QTimer(this);
			connect( lashPollTimer, SIGNAL( timeout() ), this, SLOT( onLashPollTimer() ) );
			lashPollTimer->start(500);
		}
	}
#endif


	//playlist display timer
	QTimer *playlistDisplayTimer = new QTimer(this);
	connect( playlistDisplayTimer, SIGNAL( timeout() ), this, SLOT( onPlaylistDisplayTimer() ) );
	playlistDisplayTimer->start(30000);	// update player control at
	// ~ playlist display timer

	//beatcouter
	Hydrogen::get_instance()->setBcOffsetAdjust();
	// director
	EventQueue::get_instance()->push_event( EVENT_METRONOME, 1 );
	EventQueue::get_instance()->push_event( EVENT_METRONOME, 3 );

	undoView = new QUndoView(h2app->m_undoStack);
	undoView->setWindowTitle(tr("Undo history"));
	undoView->setWindowIcon( QPixmap( Skin::getImagePath() + "/icon16.png" ) );

	//restore last playlist
	if( Preferences::get_instance()->isRestoreLastPlaylistEnabled() ){
		bool loadlist = h2app->getPlayListDialog()->loadListByFileName( Preferences::get_instance()->getLastPlaylistFilename() );
		if( !loadlist ){
			_ERRORLOG ( "Error loading the playlist" );
		}
	}
}
コード例 #26
0
ファイル: MainForm.cpp プロジェクト: draekko/hydrogen
void MainForm::action_file_export_pattern_as()
{
	if ( ( Hydrogen::get_instance()->getState() == STATE_PLAYING ) )
	{
		Hydrogen::get_instance()->sequencer_stop();
	}

	Hydrogen *engine = Hydrogen::get_instance();
	int selectedpattern = engine->getSelectedPatternNumber();
	Song *song = engine->getSong();
	Pattern *pat = song->get_pattern_list()->get ( selectedpattern );

	Instrument *instr = song->get_instrument_list()->get ( 0 );
	assert ( instr );

	QDir dir  = Preferences::get_instance()->__lastspatternDirectory;


	QFileDialog fd(this);
	fd.setFileMode ( QFileDialog::AnyFile );
	fd.setFilter ( trUtf8 ( "Hydrogen Pattern (*.h2pattern)" ) );
	fd.setAcceptMode ( QFileDialog::AcceptSave );
	fd.setWindowTitle ( trUtf8 ( "Save Pattern as ..." ) );
	fd.setDirectory ( dir );
	fd.setSidebarUrls( fd.sidebarUrls() << QUrl::fromLocalFile( Filesystem::patterns_dir() ) );



	QString defaultPatternname = QString ( pat->get_name() );

	fd.selectFile ( defaultPatternname );

	LocalFileMng fileMng;
	QString filename;
	if ( fd.exec() == QDialog::Accepted )
	{
		filename = fd.selectedFiles().first();
		QString tmpfilename = filename;
		QString toremove = tmpfilename.section( '/', -1 );
		QString newdatapath =  tmpfilename.replace( toremove, "" );
		Preferences::get_instance()->__lastspatternDirectory = newdatapath;
	}

	if ( !filename.isEmpty() )
	{
		QString sNewFilename = filename;
		if(sNewFilename.endsWith( ".h2pattern" ) ){
			sNewFilename += "";
		}
		else{
			sNewFilename += ".h2pattern";
		}
		QString patternname = sNewFilename;
		QString realpatternname = filename;
		QString realname = realpatternname.mid( realpatternname.lastIndexOf( "/" ) + 1 );
		if ( realname.endsWith( ".h2pattern" ) )
			realname.replace( ".h2pattern", "" );
		pat->set_name(realname);
		HydrogenApp::get_instance()->getSongEditorPanel()->updateAll();
		int err = fileMng.savePattern ( song, engine->getCurrentDrumkitname(), selectedpattern, patternname, realname, 2 );
		if ( err != 0 )
		{
			QMessageBox::warning( this, "Hydrogen", trUtf8("Could not export pattern.") );
			_ERRORLOG ( "Error saving the pattern" );
		}
	}
	h2app->setStatusBarMessage ( trUtf8 ( "Pattern saved." ), 10000 );

	//update SoundlibraryPanel
	HydrogenApp::get_instance()->getInstrumentRack()->getSoundLibraryPanel()->test_expandedItems();
	HydrogenApp::get_instance()->getInstrumentRack()->getSoundLibraryPanel()->updateDrumkitList();
}
コード例 #27
0
ファイル: MainForm.cpp プロジェクト: draekko/hydrogen
void MainForm::onLashPollTimer()
{
#ifdef H2CORE_HAVE_LASH
	if ( Preferences::get_instance()->useLash() ){
		LashClient* client = LashClient::get_instance();

		if (!client->isConnected())
		{
			WARNINGLOG("[LASH] Not connected to server!");
			return;
		}

		bool keep_running = true;

		lash_event_t* event;

		string songFilename;
		QString filenameSong;
		Song *song = Hydrogen::get_instance()->getSong();
		// Extra parentheses for -Wparentheses
		while ( (event = client->getNextEvent()) ) {

			switch (lash_event_get_type(event)) {

			case LASH_Save_File:

				INFOLOG("[LASH] Save file");

				songFilename.append(lash_event_get_string(event));
				songFilename.append("/hydrogen.h2song");

				filenameSong = QString::fromLocal8Bit( songFilename.c_str() );
				song->set_filename( filenameSong );
				action_file_save();

				client->sendEvent(LASH_Save_File);

				break;

			case LASH_Restore_File:

				songFilename.append(lash_event_get_string(event));
				songFilename.append("/hydrogen.h2song");

				INFOLOG( QString("[LASH] Restore file: %1")
						 .arg( songFilename.c_str() ) );

				filenameSong = QString::fromLocal8Bit( songFilename.c_str() );

				openSongFile( filenameSong );

				client->sendEvent(LASH_Restore_File);

				break;

			case LASH_Quit:

				//				infoLog("[LASH] Quit!");
				keep_running = false;

				break;

			default:
				;
				//				infoLog("[LASH] Got unknown event!");

			}

			lash_event_destroy(event);

		}

		if (!keep_running)
		{
			lashPollTimer->stop();
			action_file_exit();
		}
	}
#endif
}
コード例 #28
0
ファイル: song.cpp プロジェクト: ConfusedGiant/Clementine
int CompareSongsName(const Song& song1, const Song& song2) {
  return song1.PrettyTitleWithArtist().localeAwareCompare(
             song2.PrettyTitleWithArtist()) < 0;
}
コード例 #29
0
ファイル: song.cpp プロジェクト: ConfusedGiant/Clementine
uint HashSimilar(const Song& song) {
  // Should compare the same fields as function IsSimilar
  return qHash(song.title().toLower()) ^ qHash(song.artist().toLower());
}
コード例 #30
0
ファイル: song.cpp プロジェクト: ConfusedGiant/Clementine
bool Song::IsSimilar(const Song& other) const {
  return title().compare(other.title(), Qt::CaseInsensitive) == 0 &&
         artist().compare(other.artist(), Qt::CaseInsensitive) == 0;
}