Esempio n. 1
0
LfoController::LfoController( Model * _parent ) :
	Controller( Controller::LfoController, _parent, tr( "LFO Controller" ) ),
	m_baseModel( 0.5, 0.0, 1.0, 0.001, this, tr( "Base value" ) ),
	m_speedModel( 2.0, 0.01, 20.0, 0.0001, 20000.0, this, tr( "Oscillator speed" ) ),
	m_amountModel( 1.0, -1.0, 1.0, 0.005, this, tr( "Oscillator amount" ) ),
	m_phaseModel( 0.0, 0.0, 360.0, 4.0, this, tr( "Oscillator phase" ) ),
	m_waveModel( Oscillator::SineWave, 0, Oscillator::NumWaveShapes,
			this, tr( "Oscillator waveform" ) ),
	m_multiplierModel( 0, 0, 2, this, tr( "Frequency Multiplier" ) ),
	m_duration( 1000 ),
	m_phaseOffset( 0 ),	
	m_currentPhase( 0 ),
	m_sampleFunction( &Oscillator::sinSample ),
	m_userDefSampleBuffer( new SampleBuffer )
{
	setSampleExact( true );
	connect( &m_waveModel, SIGNAL( dataChanged() ),
			this, SLOT( updateSampleFunction() ) );
	
	connect( &m_speedModel, SIGNAL( dataChanged() ),
			this, SLOT( updateDuration() ) );
	connect( &m_multiplierModel, SIGNAL( dataChanged() ),
			this, SLOT( updateDuration() ) );
	connect( engine::mixer(), SIGNAL( sampleRateChanged() ), 
			this, SLOT( updateDuration() ) );
	
	connect( engine::getSong(), SIGNAL( playbackStateChanged() ),
			this, SLOT( updatePhase() ) );
	connect( engine::getSong(), SIGNAL( playbackPositionChanged() ),
			this, SLOT( updatePhase() ) );
			
	updateDuration();
}
Esempio n. 2
0
void BoneSRTAnimation::addTranslationKey( float time, const Vector& translation )
{
   m_translation.addKey( time, translation );

   // update the animation duration
   updateDuration();
}
bool GameStateHandler::execute( GameNet::Box * box )
{
    auto message = box->getData();
    state = GameState();
    state.ParseFromString(message);
    
    CCLOG("Game state change:");
    CCLOG("===========");
    CCLOG("%s", state.DebugString().c_str());
    
    if( state.has_name() )
    {
        updateName();
    }
    
    if( state.has_pitchsize() )
    {
        updateSize();
    }
    
    if( state.has_duration() )
    {
        updateDuration();
    }
    
    if( state.has_state() )
    {
        updateMatchState();
    }
    
    return false;
}
Esempio n. 4
0
Event::Event(Task* parent): Model(parent)
{
    initialize<Event, EventAdaptor>();
    setTaskId(parent->id());

    connect (this, SIGNAL(timeChanged()), SLOT(updateDuration()));
}
Esempio n. 5
0
void BoneSRTAnimation::addOrientationKey( float time, const Quaternion& orientation )
{
   m_orientation.addKey( time, orientation );

   // update the animation duration
   updateDuration();
}
Esempio n. 6
0
//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){
    if (status == VISIBLE) {
        status = FORWARD;
        startTime = ofGetElapsedTimef();
        clickedPosition.x = x;
        clickedPosition.y = y;
        updateDuration();
    }
    else if(status == INVISIBLE) {
        status = BACKWARD;
        startTime = ofGetElapsedTimef();
        clickedPosition.x = x;
        clickedPosition.y = y;
        updateDuration();
    }
    else {
        ofLogWarning("処理中だお");
    }
}
Esempio n. 7
0
MusicWidget::MusicWidget(QWidget *parent,QMediaPlayer *player) : QWidget(parent),player(player),piclabel(0)
  ,piclabel2(0),timelabel(0),infolabel(0),ratelabel(0)
{
    createwidgets();
    player->setVolume(30);
    player->play();
    connect(player,SIGNAL(durationChanged(qint64)),this,SLOT(updateDuration(qint64)));
    connect(player,SIGNAL(positionChanged(qint64)),this,SLOT(updatePosition(qint64)));
    connect(player,SIGNAL(metaDataAvailableChanged(bool)),this,SLOT(updateInfo()));
}
Esempio n. 8
0
SudokuGame::~SudokuGame(void) {
    delete m_board;
    delete m_originalBoard;

    if (m_durationTimer != NULL) {
        m_durationTimer->stop();
        disconnect(m_durationTimer, SIGNAL(timeout()), this, SLOT(updateDuration()));
        delete m_durationTimer;
    }
}
Esempio n. 9
0
MainWindow::MainWindow(QWidget *parent) : KXmlGuiWindow(parent)
{
    setAttribute(Qt::WA_DeleteOnClose, false);

    systemTray = new KStatusNotifierItem("kourglass", this);
    systemTray->setStatus(KStatusNotifierItem::Active);
    systemTray->setIconByName("clock");
    systemTray->setTitle("Kourglass");
    systemTray->setToolTip("clock", "Kourglass", i18n("Track your time!"));

    QLabel* textStatusBar1 = new QLabel(i18n("Total calendar time:"), statusBar());
    m_statusBarTotalTime = new QLabel(i18n("00:00:00"), statusBar());
    QLabel* textStatusBar3 = new QLabel(i18n("Today:"), statusBar());
    m_statusBarToday = new QLabel(i18n("00:00:00"), statusBar());
    QLabel* textStatusBar5 = new QLabel(i18n("This week:"), statusBar());
    m_statusBarWeek = new QLabel(i18n("00:00:00"), statusBar());

    statusBar()->insertPermanentWidget(1, textStatusBar1);
    statusBar()->insertPermanentWidget(2, m_statusBarTotalTime);
    statusBar()->insertPermanentWidget(3, textStatusBar3);
    statusBar()->insertPermanentWidget(4, m_statusBarToday);
    statusBar()->insertPermanentWidget(5, textStatusBar5);
    statusBar()->insertPermanentWidget(5, m_statusBarWeek);


    m_storage = new Storage(this);
    connect(m_storage, SIGNAL(projectLoaded(QString&, QTreeWidgetItem*)), this, SLOT(addProjectLoaded(QString&, QTreeWidgetItem*)));

    m_mainView = new MainView(this);
    connect(m_mainView, SIGNAL(projectChanged(const QString&)), this, SLOT(changeCurrentProject(const QString&)));
    connect(m_mainView, SIGNAL(taskChanged(QTreeWidgetItem*)), this, SLOT(setCurrentTask(QTreeWidgetItem*)));
    connect(m_mainView, SIGNAL(calendarChanged(const Collection&)), this, SLOT(setCurrentCalendar(const Collection&)));
    connect(m_mainView, SIGNAL(dateFromChanged(const QDate&)), m_storage, SLOT(setDateFrom(const QDate&)));
    connect(m_mainView, SIGNAL(dateToChanged(const QDate&)), m_storage, SLOT(setDateTo(const QDate&)));
    connect(m_mainView, SIGNAL(hideUnusedChanged()), this, SLOT(hideUnusedChanged()));
    setCentralWidget(m_mainView);

    connect(m_mainView, SIGNAL(allDurationsChanged()), m_storage, SLOT(computeAllDurations()));

    m_addProjectDialog = new NewProjectDialog(this);
    connect(m_addProjectDialog, SIGNAL(projectAccepted(QString&)), this, SLOT(addProject(QString&)));

    m_addTaskDialog = new NewTaskDialog(this);
    connect(m_addTaskDialog, SIGNAL(taskAccepted(QString&)), this, SLOT(addTask(QString&)));

    m_addEventDialog = new NewEventDialog(this);
    connect(m_addEventDialog, SIGNAL(eventAccepted(QString&)), this, SLOT(renameLastEvent(QString&)));

    QTimer* durationUpdater = new QTimer(this);
    connect(durationUpdater, SIGNAL(timeout()), m_storage, SLOT(updateDuration()));
    connect(durationUpdater, SIGNAL(timeout()), this, SLOT(updateStatusBar()));
    durationUpdater->start(1000);

    setupActions();
}
Esempio n. 10
0
void KNMusicHeaderPlayer::reset()
{
    //Clear the labels.
    m_title->setText("");
    m_artistAlbum->setText("");
    //Set no album art icon.
    m_albumArt->setPixmap(knMusicGlobal->noAlbumArt());
    //Set the duration and position to 0.
    updateDuration(0);
    m_position->setText(KNMusicUtil::msecondToString(0));
    //Hide the main player and append menu button.
    m_showMainPlayer->hide();
    m_showAppendMenu->hide();
}
Esempio n. 11
0
IdleCorrectionDialog::IdleCorrectionDialog(const IdleDetector::IdlePeriod &idlePeriod, QWidget* parent )
    : QDialog( parent )
    , m_ui( new Ui::IdleCorrectionDialog )
    , m_start( idlePeriod.first )
{
    m_ui->setupUi( this );

    updateDuration();

    auto timer = new QTimer( this );
    timer->setInterval( 60000 );

    connect(timer, &QTimer::timeout, this, &IdleCorrectionDialog::updateDuration );
    timer->start();
}
Esempio n. 12
0
MusicPlayer::MusicPlayer(QWidget *parent) : QWidget(parent),
    taskbarButton(0), taskbarProgress(0), thumbnailToolBar(0),
    playToolButton(0), forwardToolButton(0), backwardToolButton(0),
    mediaPlayer(0), playButton(0), volumeButton(0),
    positionSlider(0), positionLabel(0), infoLabel(0)
{
    //playList = playlist;
    createWidgets();
    createShortcuts();
    createJumpList();
    createTaskbar();
    createThumbnailToolBar();

    connect(&mediaPlayer, SIGNAL(positionChanged(qint64)), this, SLOT(updatePosition(qint64)));
    connect(&mediaPlayer, SIGNAL(durationChanged(qint64)), this, SLOT(updateDuration(qint64)));
    connect(&mediaPlayer, SIGNAL(metaDataAvailableChanged(bool)), this, SLOT(updateInfo()));
    connect(&mediaPlayer, SIGNAL(error(QMediaPlayer::Error)), this, SLOT(handleError()));
    connect(&mediaPlayer, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(updateState(QMediaPlayer::State)));
}
Esempio n. 13
0
void KNewLoanWizard::updateLoanInfo()
{
  updateLoanAmount();
  updateInterestRate();
  updateDuration();
  updatePayment();
  updateFinalPayment();
  m_additionalFeesPage->updatePeriodicPayment(m_account);

  QString txt;

  int fraction = m_account.fraction(MyMoneyFile::instance()->security(m_account.currencyId()));
  setField("loanAmount6", field("loanAmountEdit").value<MyMoneyMoney>().formatMoney(fraction));
  setField("interestRate6", QString(field("interestRateEdit").value<MyMoneyMoney>().formatMoney("", 3) + QString("%")));
  txt = QString().sprintf("%d ", field("durationValueEdit").toInt())
        + field("durationUnitEdit").toString();
  setField("duration6", txt);
  setField("payment6", field("paymentEdit").value<MyMoneyMoney>().formatMoney(fraction));
  setField("balloon6", field("finalPaymentEdit").value<MyMoneyMoney>().formatMoney(fraction));
}
Esempio n. 14
0
void TimelineItem::stepTo( float newTime, bool reverse )
{
	if( mMarkedForRemoval )
		return;
	
	const float absTime = newTime - mStartTime;
	const float endTime = mStartTime + mDuration;

	updateDuration();

	if( ( ! mHasReverseStarted ) && reverse && ( newTime < mStartTime ) ) {
		mHasReverseStarted = true;
		mHasStarted = false;
		start( true );
	}	
	else if( newTime >= mStartTime ) {
		float relTime;
		if( mPingPong ) {
			relTime = math<float>::fmod( absTime * mInvDuration, 2 ); // varies from 0-2
			if( relTime > 1 )
				relTime = ( 2 - relTime );
		}
		else if( mLoop ) {
			relTime = math<float>::fmod( absTime * mInvDuration, 1 );
		}
		else
			relTime = math<float>::min( absTime * mInvDuration, 1 );
		
		if( ( ! mHasStarted ) && ( ! reverse ) ) {
			mHasStarted = true;
			mHasReverseStarted = false;
			mLastLoopIteration = 0;
			loopStart();
			start( false );
		}
		
		float time = ( mUseAbsoluteTime ) ? absTime : relTime;

		// accommodate a tween with a duration <= 0
		if( ( ! mUseAbsoluteTime ) && ( mInvDuration <= 0 ) )
			time = 1.0f;

		if( mLoop || mPingPong ) {
			int32_t loopIteration = static_cast<int32_t>( ( newTime - mStartTime ) * mInvDuration );
			if( loopIteration != mLastLoopIteration ) {
				mLastLoopIteration = loopIteration;
				loopStart();
				update( time );
			}
			else
				update( time );
		}
		else
			update( time );
	}

	if( newTime < endTime ) {
		if( ( ! mReverseComplete ) && reverse ) {
			mReverseComplete = true;
			mComplete = false;
			complete( true );
		}
	}
	else if( ( ! mLoop ) && ( ! mInfinite ) ) { // newTime >= endTime
		if( ( ! mComplete ) && ( ! reverse ) ) {
			mComplete = true;
			mReverseComplete = false;
			complete( false );
		}
	}
}
Esempio n. 15
0
Player::Player(QWidget *parent) : KXmlGuiWindow(parent) {
	//SETUP DATABASE
	QDir(KGlobal::dirs()->saveLocation("data")).mkdir("projekt7"); //NOTE: creates the projekt7 directory if it doesn't already exist
	QString db_path = KGlobal::dirs()->saveLocation("data") + "projekt7/tracks_db";
	int return_code = sqlite3_open(qtos(db_path), &tracks_db);
	if (return_code) {
		showError("Failed to open the Projekt7 Track Database: ", sqlite3_errmsg(tracks_db));
		exit(return_code);
	}
	const char *create_table = "CREATE TABLE IF NOT EXISTS `tracks` (`tid` INTEGER PRIMARY KEY, `artist` VARCHAR KEY ASC, `year` INT KEY ASC, `album` VARCHAR, `track_number` INT KEY ASC, `title` VARCHAR, `path` VARCHAR, `length` INT, `playcount` INT)"; //TODO make use of the `length` and `playcount` columns
	char *errmsg;
	return_code = sqlite3_exec(tracks_db, create_table, 0, 0, &errmsg);
	if (return_code) {
		showError("Failed to create `tracks` table: ", errmsg);
		sqlite3_free(errmsg);
		exit(return_code);
	}
	updateNumTracks();
	
	//SETUP PHONON
	now_playing = new Phonon::MediaObject(this);
	Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
	createPath(now_playing, audioOutput);
	now_playing->setTickInterval(1000);
	
	//SETUP WIDGETS
	QWidget *central_widget = new QWidget(this);
	KToolBar *toolbar_widget = new KToolBar(i18n("Main Toolbar"), central_widget);
	toolbar_widget->setIconDimensions(32);
	playlist_widget = new QWidget(central_widget);
	artist_list = new KListWidget(playlist_widget);
	artist_list->addItem(ALL);
	album_list = new KListWidget(playlist_widget);
	titles_list = new KListWidget(playlist_widget);
	QAction* tb_previousAction = toolbar_widget->addAction(KIcon("media-skip-backward"), "");
	QString previousHelpText = i18n("Play the previous track");
	tb_previousAction->setToolTip(previousHelpText);
	QAction* tb_pauseAction = toolbar_widget->addAction(KIcon("media-playback-pause"), "");
	QString plauseHelpText = i18n("Plause playback");
	tb_pauseAction->setToolTip(plauseHelpText);
	QAction* tb_playAction = toolbar_widget->addAction(KIcon("media-playback-start"), "");
	QString playHelpText = i18n("Play the track");
	tb_playAction->setToolTip(playHelpText);
	QAction* tb_nextAction = toolbar_widget->addAction(KIcon("media-skip-forward"), "");
	QString nextHelpText = i18n("Play the next track");
	tb_nextAction->setToolTip(nextHelpText);
	toolbar_widget->addSeparator();
	Phonon::VolumeSlider *volumeSlider = new Phonon::VolumeSlider;
	volumeSlider->setAudioOutput(audioOutput);
	volumeSlider->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
	toolbar_widget->addWidget(volumeSlider);
	toolbar_widget->addSeparator();
	Phonon::SeekSlider *seekSlider = new Phonon::SeekSlider(now_playing);
	volumeSlider->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
	toolbar_widget->addWidget(seekSlider);
	toolbar_widget->addSeparator();
	cur_time = new QLabel(" 0:00", toolbar_widget);
	cur_time->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
	toolbar_widget->addWidget(cur_time);
	toolbar_widget->addWidget(new QLabel(" / ", toolbar_widget));
	track_duration = new QLabel("0:00", toolbar_widget);
	track_duration->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
	toolbar_widget->addWidget(track_duration);
	queued = new KIcon("go-next-view");
	
	QHBoxLayout *listLayout = new QHBoxLayout;
	listLayout->addWidget(artist_list);
	listLayout->addWidget(album_list);
	listLayout->addWidget(titles_list);
	playlist_widget->setLayout(listLayout);
	
	QVBoxLayout *mainLayout = new QVBoxLayout;
	mainLayout->addWidget(toolbar_widget);
	mainLayout->addWidget(playlist_widget);
	central_widget->setLayout(mainLayout);
	
	setCentralWidget(central_widget);
	
	//SETUP STATUS BAR
	KStatusBar* bar = statusBar();
	bar->insertPermanentItem("", SONG_NAME, true);
	bar->setItemAlignment(SONG_NAME, Qt::AlignLeft | Qt::AlignVCenter);
	
	//SETUP SYSTEM TRAY ICON
	tray_icon = new KSystemTrayIcon("projekt7", this);
	tray_icon->show();
	
	//SETUP METADATA WINDOW
	metadata_window = new QWidget(this, Qt::Dialog);
	metadata_window->setWindowModality(Qt::WindowModal);
	metadata_window->setWindowTitle("Track Details  |  Projekt 7");
	mw_ok_button = new KPushButton(KIcon("dialog-ok-apply"), "OK", metadata_window);
	mw_ok_button->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
	
	QGridLayout *mwLayout = new QGridLayout;
	mwLayout->addWidget(new QLabel("Artist:",        metadata_window), 0, 0);
	mwLayout->addWidget(new QLabel("Year:",          metadata_window), 1, 0);
	mwLayout->addWidget(new QLabel("Album:",         metadata_window), 2, 0);
	mwLayout->addWidget(new QLabel("Track Number:",  metadata_window), 3, 0);
	mwLayout->addWidget(new QLabel("Title:",         metadata_window), 4, 0);
	mwLayout->addWidget(new QLabel("File Path:",     metadata_window), 5, 0);
	mwLayout->addWidget(mw_artist       = new QLabel(metadata_window), 0, 1);
	mwLayout->addWidget(mw_year         = new QLabel(metadata_window), 1, 1);
	mwLayout->addWidget(mw_album        = new QLabel(metadata_window), 2, 1);
	mwLayout->addWidget(mw_track_number = new QLabel(metadata_window), 3, 1);
	mwLayout->addWidget(mw_title        = new QLabel(metadata_window), 4, 1);
	mwLayout->addWidget(mw_path         = new QLabel(metadata_window), 5, 1);
	mwLayout->addWidget(mw_ok_button, 6, 0, 1, 2, Qt::AlignCenter);
	metadata_window->setLayout(mwLayout);
	
	//SETUP QUEUE EDITOR WINDOW
	queue_window = new QWidget(this, Qt::Dialog);
	queue_window->setWindowModality(Qt::WindowModal);
	queue_window->setWindowTitle("Track Queue Editor  |  Projekt 7");
	qw_ok_button = new KPushButton(KIcon("dialog-ok-apply"), "OK", queue_window);
	qw_ok_button->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
	
	QVBoxLayout *qw_buttons_layout = new QVBoxLayout;
	KPushButton *qw_top_button     = new KPushButton(KIcon("go-top"),      "", queue_window);
	KPushButton *qw_up_button      = new KPushButton(KIcon("go-up"),       "", queue_window);
	KPushButton *qw_down_button    = new KPushButton(KIcon("go-down"),     "", queue_window);
	KPushButton *qw_bottom_button  = new KPushButton(KIcon("go-bottom"),   "", queue_window);
	KPushButton *qw_remove_button  = new KPushButton(KIcon("edit-delete"), "", queue_window);
	qw_buttons_layout->addWidget(qw_top_button);
	qw_buttons_layout->addWidget(qw_up_button);
	qw_buttons_layout->addWidget(qw_down_button);
	qw_buttons_layout->addWidget(qw_bottom_button);
	qw_buttons_layout->addWidget(qw_remove_button);
	
	QHBoxLayout *qw_list_buttons_layout = new QHBoxLayout;
	qw_queue_list = new KListWidget(queue_window);
	QWidget *qw_button_holder = new QWidget(queue_window);
	qw_button_holder->setLayout(qw_buttons_layout);
	qw_list_buttons_layout->addWidget(qw_queue_list);
	qw_list_buttons_layout->addWidget(qw_button_holder);
	
	QVBoxLayout *qwLayout = new QVBoxLayout;
	QWidget *qw_list_buttons = new QWidget(queue_window);
	qw_list_buttons->setLayout(qw_list_buttons_layout);
	qwLayout->addWidget(qw_list_buttons);
	qwLayout->addWidget(qw_ok_button, 0, Qt::AlignCenter);
	queue_window->setLayout(qwLayout);
	
	//SETUP ACTIONS
 	KStandardAction::quit(kapp, SLOT(quit()), actionCollection());
	connect(kapp, SIGNAL(aboutToQuit()), this, SLOT(quit()));
	connect(now_playing, SIGNAL(aboutToFinish()), this, SLOT(enqueueNext()));
	connect(now_playing, SIGNAL(totalTimeChanged(qint64)), this, SLOT(updateDuration(qint64)));
	connect(now_playing, SIGNAL(tick(qint64)), this, SLOT(tick(qint64)));
	KAction *openFilesAction = setupKAction("document-open", i18n("Open"), i18n("Load the selected files"), "files");
	openFilesAction->setShortcut(QKeySequence::Open);
	connect(openFilesAction, SIGNAL(triggered(bool)), this, SLOT(loadFiles()));
	KAction *openDirectoryAction = setupKAction("document-open-folder", i18n("Open Directory..."), i18n("Load all files in the selected directory and its subdirectories"), "directory");
	openDirectoryAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D));
	connect(openDirectoryAction, SIGNAL(triggered(bool)), this, SLOT(loadDirectory()));
	KAction *previousAction = setupKAction("media-skip-backward", i18n("Previous"), previousHelpText, "previous");
	previousAction->setShortcut(QKeySequence(Qt::Key_Z));
	connect(previousAction, SIGNAL(triggered(bool)), this, SLOT(previous()));
	connect(tb_previousAction, SIGNAL(triggered(bool)), this, SLOT(previous()));
	KAction *pauseAction = setupKAction("media-playback-pause", i18n("Pause"), plauseHelpText, "pause");
	pauseAction->setShortcut(QKeySequence(Qt::Key_C));
	connect(pauseAction, SIGNAL(triggered(bool)), this, SLOT(pause()));
	connect(tb_pauseAction, SIGNAL(triggered(bool)), this, SLOT(pause()));
	KAction *playAction = setupKAction("media-playback-start", i18n("Play"), playHelpText, "play");
	playAction->setShortcut(QKeySequence(Qt::Key_X));
	connect(playAction, SIGNAL(triggered(bool)), this, SLOT(play()));
	connect(tb_playAction, SIGNAL(triggered(bool)), this, SLOT(play()));
	KAction *nextAction = setupKAction("media-skip-forward", i18n("Next"), nextHelpText, "next");
	nextAction->setShortcut(QKeySequence(Qt::Key_V));
	connect(nextAction, SIGNAL(triggered(bool)), this, SLOT(next()));
	connect(tb_nextAction, SIGNAL(triggered(bool)), this, SLOT(next()));
	KAction *queueAction = setupKAction("go-next-view", i18n("Queue Track"), "Enqueue the current track", "queue");
	queueAction->setShortcut(QKeySequence(Qt::Key_Q));
	connect(queueAction, SIGNAL(triggered(bool)), this, SLOT(queue()));
	shuffleAction = setupKAction("media-playlist-shuffle", i18n("Suffle"), "The next track will be random when checked", "shuffle");
	shuffleAction->setCheckable(true);
	connect(shuffleAction, SIGNAL(triggered(bool)), this, SLOT(shuffle(bool)));
	KAction *viewCurrentTrackAction = setupKAction("go-last", i18n("Current Track"), i18n("Show the Current Track in the Playlist"), "current_track");
	connect(viewCurrentTrackAction, SIGNAL(triggered(bool)), this, SLOT(viewCurrentTrack()));
	KAction *viewTrackDetailsAction = setupKAction("view-media-lyrics", i18n("Track Details"), i18n("View the playing track's metadata"), "track_details");
	connect(viewTrackDetailsAction, SIGNAL(triggered(bool)), this, SLOT(viewTrackDetails()));
	KAction *viewTrackQueueAction = setupKAction("view-time-schedule-edit", i18n("Track Queue"), i18n("Edit the track queue"), "track_queue");
	connect(viewTrackQueueAction, SIGNAL(triggered(bool)), this, SLOT(viewTrackQueue()));
	viewPlaylistAction = setupKAction("view-file-columns", i18n("Playlist"), i18n("Show/Hide the playlist"), "playlist");
	viewPlaylistAction->setCheckable(true);
	connect(viewPlaylistAction, SIGNAL(triggered(bool)), this, SLOT(viewPlaylist(bool)));
	connect(artist_list, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(updateAlbumList(QListWidgetItem *,  QListWidgetItem *)));
	connect(album_list,  SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(updateTitlesList(QListWidgetItem *, QListWidgetItem *)));
	connect(titles_list, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(showTrackInfo(QListWidgetItem *,    QListWidgetItem *)));
	connect(titles_list, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(play(QListWidgetItem *)));
	connect(mw_ok_button,     SIGNAL(clicked()), this, SLOT(hideTrackDetails()));
	connect(qw_top_button,    SIGNAL(clicked()), this, SLOT(moveQueuedTrackToTop()));
	connect(qw_up_button,     SIGNAL(clicked()), this, SLOT(moveQueuedTrackUp()));
	connect(qw_down_button,   SIGNAL(clicked()), this, SLOT(moveQueuedTrackDown()));
	connect(qw_bottom_button, SIGNAL(clicked()), this, SLOT(moveQueuedTrackToBottom()));
	connect(qw_remove_button, SIGNAL(clicked()), this, SLOT(dequeueTrack()));
	connect(qw_ok_button,     SIGNAL(clicked()), this, SLOT(hideTrackQueue()));
	
	//SETUP GUI
	qsrand(QDateTime::currentDateTime().toTime_t());
	setupGUI(Default, "projekt7ui.rc");
	updateArtistList(0);
	
	//READ CONFIG
	config = KGlobal::config();
	KConfigGroup curTrackDetails(config, "curTrackDetails");
	cur_artist = artist_list->item(curTrackDetails.readEntry("artist", QString()).toInt());
	cur_album = curTrackDetails.readEntry("album", QString()).toInt();
	cur_title = curTrackDetails.readEntry("title", QString()).toInt();
	KConfigGroup applicationSettings(config, "applicationSettings");
	viewPlaylistAction->setChecked(applicationSettings.readEntry("playlistVisible", QString()).toInt());
	shuffle_tracks = applicationSettings.readEntry("shuffleTracks", QString()).toInt();
	shuffleAction->setChecked(shuffle_tracks);
	viewCurrentTrack();
	if (titles_list->count() > 0) {
		if (titles_list->currentRow() == -1)
			titles_list->setCurrentRow(0);
		play(titles_list->currentItem()->data(Qt::UserRole).toInt(), false, false);
		pause();
		quint64 song_position = curTrackDetails.readEntry("tick", QString()).toLongLong();
		now_playing->seek(song_position);
		tick(song_position);
		//TODO update the seekSlider's position to match the "tick" location of the song
	}
}
void PlayerComponent::handleMpvEvent(mpv_event *event)
{
  switch (event->event_id)
  {
    case MPV_EVENT_START_FILE:
    {
      m_CurrentUrl = mpv::qt::get_property_variant(m_mpv, "path").toString();
      m_playbackStartSent = false;
      break;
    }
    case MPV_EVENT_FILE_LOADED:
    {
      emit playing(m_CurrentUrl);
      break;
    }
    case MPV_EVENT_END_FILE:
    {
      mpv_event_end_file *end_file = (mpv_event_end_file *)event->data;
      switch (end_file->reason)
      {
        case MPV_END_FILE_REASON_EOF:
          emit finished(m_CurrentUrl);
          break;
        case MPV_END_FILE_REASON_ERROR:
          emit error(end_file->error, mpv_error_string(end_file->error));
          break;
        default:
          emit stopped(m_CurrentUrl);
          break;
      }

      emit playbackEnded(m_CurrentUrl);
      m_CurrentUrl = "";

      m_restoreDisplayTimer.start(0);
      break;
    }
    case MPV_EVENT_IDLE:
    {
      emit playbackAllDone();
      break;
    }
    case MPV_EVENT_PLAYBACK_RESTART:
    {
      // it's also sent after seeks are completed
      if (!m_playbackStartSent)
        emit playbackStarting();
      m_playbackStartSent = true;
      break;
    }
    case MPV_EVENT_PROPERTY_CHANGE:
    {
      mpv_event_property *prop = (mpv_event_property *)event->data;
      if (strcmp(prop->name, "pause") == 0 && prop->format == MPV_FORMAT_FLAG)
      {
        int state = *(int *)prop->data;
        emit paused(state);
      }
      else if (strcmp(prop->name, "cache-buffering-state") == 0 && prop->format == MPV_FORMAT_INT64)
      {
        int64_t percentage = *(int64_t *)prop->data;
        emit buffering(percentage);
      }
      else if (strcmp(prop->name, "playback-time") == 0 && prop->format == MPV_FORMAT_DOUBLE)
      {
        double pos = *(double*)prop->data;
        if (fabs(pos - m_lastPositionUpdate) > 0.25)
        {
          quint64 ms = (quint64)(qMax(pos * 1000.0, 0.0));
          emit positionUpdate(ms);
          m_lastPositionUpdate = pos;
        }
      }
      else if (strcmp(prop->name, "vo-configured") == 0)
      {
        int state = prop->format == MPV_FORMAT_FLAG ? *(int *)prop->data : 0;
        emit windowVisible(state);
      }
      else if (strcmp(prop->name, "duration") == 0)
      {
        if (prop->format == MPV_FORMAT_DOUBLE)
          emit updateDuration(*(double *)prop->data * 1000.0);
      }
      else if (strcmp(prop->name, "audio-device-list") == 0)
      {
        updateAudioDeviceList();
      }
      break;
    }
    case MPV_EVENT_LOG_MESSAGE:
    {
      mpv_event_log_message *msg = (mpv_event_log_message *)event->data;
      // Strip the trailing '\n'
      size_t len = strlen(msg->text);
      if (len > 0 && msg->text[len - 1] == '\n')
        len -= 1;
      QString logline = QString::fromUtf8(msg->prefix) + ": " + QString::fromUtf8(msg->text, len);
      if (msg->log_level >= MPV_LOG_LEVEL_V)
        QLOG_DEBUG() << qPrintable(logline);
      else if (msg->log_level >= MPV_LOG_LEVEL_INFO)
        QLOG_INFO() << qPrintable(logline);
      else if (msg->log_level >= MPV_LOG_LEVEL_WARN)
        QLOG_WARN() << qPrintable(logline);
      else
        QLOG_ERROR() << qPrintable(logline);
      break;
    }
    case MPV_EVENT_CLIENT_MESSAGE:
    {
      mpv_event_client_message *msg = (mpv_event_client_message *)event->data;
      // This happens when the player is about to load the file, but no actual loading has taken part yet.
      // We use this to block loading until we explicitly tell it to continue.
      if (msg->num_args >= 3 && !strcmp(msg->args[0], "hook_run") && !strcmp(msg->args[1], "1"))
      {
        QString resume_id = QString::fromUtf8(msg->args[2]);
        // Calling this lambda will instruct mpv to continue loading the file.
        auto resume = [=] {
          QLOG_INFO() << "resuming loading";
          mpv::qt::command_variant(m_mpv, QStringList() << "hook-ack" << resume_id);
        };
        if (switchDisplayFrameRate())
        {
          // Now wait for some time for mode change - this is needed because mode changing can take some
          // time, during which the screen is black, and initializing hardware decoding could fail due
          // to various strange OS-related reasons.
          // (Better hope the user doesn't try to exit Konvergo during mode change.)
          int pause = SettingsComponent::Get().value(SETTINGS_SECTION_VIDEO, "refreshrate.delay").toInt() * 1000;
          QLOG_INFO() << "waiting" << pause << "msec after rate switch before loading";
          QTimer::singleShot(pause, resume);
        }
        else
        {
          resume();
        }
        break;
      }
    }
    default:; /* ignore */
  }
}
Esempio n. 17
0
bool KNewLoanWizard::validateCurrentPage()
{
  bool dontLeavePage = false;
  KLocalizedString ks = ki18n(
                          "The loan wizard is unable to calculate two different values for your loan "
                          "at the same time. "
                          "Please enter a value for the %1 on this page or backup to the page where the "
                          "current value to be calculated is defined and fill in a value.");

  if (currentPage() == m_lendBorrowPage) {
    // load the appropriate categories into the list
    loadAccountList();

  } else if (currentPage() == m_interestTypePage) {
    if (field("fixedInterestButton").toBool()) {
      m_pages.setBit(Page_PreviousPayments);
      if (field("previousPaymentButton").toBool())
        m_pages.setBit(Page_RecordPayment);
      else
        m_pages.clearBit(Page_RecordPayment);
      m_pages.clearBit(Page_VariableInterestDate);

    } else {
      m_pages.clearBit(Page_PreviousPayments);
      m_pages.clearBit(Page_RecordPayment);
      m_pages.setBit(Page_VariableInterestDate);
    }

  } else if (currentPage() == m_previousPaymentsPage) {
    if (field("previousPaymentButton").toBool()) {
      m_pages.setBit(Page_RecordPayment);
    } else if (field("noPreviousPaymentButton").toBool()) {
      m_pages.clearBit(Page_RecordPayment);
    }
  } else if (currentPage() == m_loanAmountPage) {
    if (field("thisYearPaymentButton").toBool()
        && !field("loanAmountEditValid").toBool()) {
      dontLeavePage = true;
      KMessageBox::error(0, i18n("You selected, that payments have already been made towards this loan. "
                                 "This requires you to enter the loan amount exactly as found on your "
                                 "last statement."), i18n("Calculation error"));
    } else
      updateLoanAmount();

  } else if (currentPage() == m_interestPage) {

    if (!field("loanAmountEditValid").toBool()
        && !field("interestRateEditValid").toBool()) {
      dontLeavePage = true;
      KMessageBox::error(0, ks.subs(i18n("interest rate")).toString(), i18n("Calculation error"));
    } else
      updateInterestRate();

  } else if (currentPage() == m_durationPage) {
    if ((!field("loanAmountEditValid").toBool()
         || !field("interestRateEditValid").toBool())
        && field("durationValueEdit").toInt() == 0) {
      dontLeavePage = true;
      KMessageBox::error(0, ks.subs(i18n("term")).toString(), i18n("Calculation error"));
    } else
      updateDuration();

  } else if (currentPage() == m_paymentPage) {
    if ((!field("loanAmountEditValid").toBool()
         || !field("interestRateEditValid").toBool()
         || field("durationValueEdit").toInt() == 0)
        && !field("paymentEditValid").toBool()) {
      dontLeavePage = true;
      KMessageBox::error(0, ks.subs(i18n("principal and interest")).toString(), i18n("Calculation error"));
    } else
      updatePayment();

  } else if (currentPage() == m_finalPaymentPage) {
    if ((!field("loanAmountEditValid").toBool()
         || !field("interestRateEditValid").toBool()
         || field("durationValueEdit").toInt() == 0
         || !field("paymentEditValid").toBool())
        && !field("finalPaymentEditValid").toBool()) {
      // if two fields are empty and one of them is the final payment
      // we assume the final payment to be 0 instead of presenting a dialog
      setField("finalPaymentEdit", QVariant::fromValue<MyMoneyMoney>((MyMoneyMoney())));
    }
    updateFinalPayment();
    if (!calculateLoan()) {
      dontLeavePage = true;
    } else
      updateLoanInfo();
  } else if (currentPage() == m_schedulePage) {
    if (field("allPaymentsButton").toBool() || field("noPreviousPaymentButton").toBool()) {
      if (m_assetAccountPage)
        m_pages.setBit(Page_AssetAccount);
    } else {
      if (m_assetAccountPage)
        m_pages.clearBit(Page_AssetAccount);
      m_assetAccountPage->m_assetAccountEdit->slotDeselectAllAccounts();
    }
  }

  if (!dontLeavePage)
    return KNewLoanWizardDecl::validateCurrentPage();
  else
    return false;
}
Esempio n. 18
0
void BoneSRTAnimation::onObjectLoaded()
{
   __super::onObjectLoaded();

   updateDuration();
}