mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 10:22:49 +00:00
kmediaplayer: restore the pause/play state aswell
chromium and some other applications have to catch up on session restoration, chromium for example cannot even shutdown correctly and it's a "uh, oh" situation the next time it is launched after logout (unless closed manually before logout). tabs restoration is not session restoration btw, not to X11 anyway. Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
64b76bb856
commit
bbcb990c65
2 changed files with 11 additions and 5 deletions
|
@ -41,7 +41,8 @@ KMediaWindow::KMediaWindow(QWidget *parent, Qt::WindowFlags flags)
|
|||
m_player(nullptr),
|
||||
m_recentfiles(nullptr),
|
||||
m_menu(nullptr),
|
||||
m_currenttime(float(0.0))
|
||||
m_currenttime(float(0.0)),
|
||||
m_playing(true)
|
||||
{
|
||||
m_config = new KConfig("kmediaplayerrc", KConfig::SimpleConfig);
|
||||
|
||||
|
@ -201,27 +202,31 @@ void KMediaWindow::slotQuit()
|
|||
qApp->quit();
|
||||
}
|
||||
|
||||
void KMediaWindow::slotDelayedPosition()
|
||||
void KMediaWindow::slotDelayedRestore()
|
||||
{
|
||||
disconnect(m_player->player(), SIGNAL(loaded()), this, SLOT(slotDelayedPosition()));
|
||||
disconnect(m_player->player(), SIGNAL(loaded()), this, SLOT(slotDelayedRestore()));
|
||||
m_player->setPosition(m_currenttime);
|
||||
m_player->setPlay(int(!m_playing));
|
||||
}
|
||||
|
||||
void KMediaWindow::saveProperties(KConfigGroup &configgroup)
|
||||
{
|
||||
const QString path = m_player->player()->path();
|
||||
const float currenttime = m_player->player()->currentTime();
|
||||
const bool playing = m_player->player()->isPlaying();
|
||||
configgroup.writeEntry("Path", path);
|
||||
configgroup.writeEntry("Position", currenttime);
|
||||
configgroup.writeEntry("Playing", playing);
|
||||
}
|
||||
|
||||
void KMediaWindow::readProperties(const KConfigGroup &configgroup)
|
||||
{
|
||||
const QString path = configgroup.readEntry("Path", QString());
|
||||
m_currenttime = configgroup.readEntry("Position", float(0.0));
|
||||
m_playing = configgroup.readEntry("Playing", true);
|
||||
kDebug() << path << m_currenttime;
|
||||
if (!path.isEmpty()) {
|
||||
connect(m_player->player(), SIGNAL(loaded()), this, SLOT(slotDelayedPosition()));
|
||||
connect(m_player->player(), SIGNAL(loaded()), this, SLOT(slotDelayedRestore()));
|
||||
m_player->open(path);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public slots:
|
|||
void slotQuit();
|
||||
|
||||
private slots:
|
||||
void slotDelayedPosition();
|
||||
void slotDelayedRestore();
|
||||
|
||||
protected:
|
||||
// KMainWindow reimplementations
|
||||
|
@ -57,6 +57,7 @@ private:
|
|||
KRecentFilesAction *m_recentfiles;
|
||||
QMenu *m_menu;
|
||||
float m_currenttime;
|
||||
bool m_playing;
|
||||
};
|
||||
|
||||
#endif // KMEDIAWINDOW_H
|
||||
|
|
Loading…
Add table
Reference in a new issue