Commit 02b3411c authored by Madhav Kanbur's avatar Madhav Kanbur Committed by Nate Graham
Browse files

Add option to disable autoplaying videos



This prevents video from automatically starting when browsing.

The new checkbox can be found under Settings > General >
Autoplay videos when browsing.

BUG: 274901
Signed-off-by: Madhav Kanbur's avatarMadhav Kanbur <abcdjdj@gmail.com>
parent fa4956d1
......@@ -67,6 +67,11 @@ ConfigDialog::ConfigDialog(QWidget* parent)
mGeneralConfigPage.jpegQualitySpinner->setValue(mGeneralConfigPage.kcfg_JPEGQuality->value());
mGeneralConfigPage.backgroundValueFrame->setMinimumWidth(mGeneralConfigPage.jpegQualitySpinner->width());
mGeneralConfigPage.kcfg_AutoplayVideos->setEnabled(mGeneralConfigPage.kcfg_ListVideos->isChecked());
connect(mGeneralConfigPage.kcfg_ListVideos, &QCheckBox::stateChanged, [=](const int &state) {
mGeneralConfigPage.kcfg_AutoplayVideos->setEnabled(state == Qt::Checked);
});
// Image View
widget = setupPage(mImageViewConfigPage);
......
......@@ -25,7 +25,7 @@
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<spacer name="verticalSpacer_1">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -41,14 +41,14 @@
</property>
</spacer>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Background color:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<layout class="QHBoxLayout">
<item>
<widget class="QSlider" name="kcfg_ViewBackgroundValue">
......@@ -106,7 +106,7 @@
</item>
</layout>
</item>
<item row="3" column="1">
<item row="4" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -122,14 +122,14 @@
</property>
</spacer>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>JPEG save quality:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QSlider" name="kcfg_JPEGQuality">
......@@ -187,7 +187,7 @@
</item>
</layout>
</item>
<item row="6" column="1">
<item row="7" column="1">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -203,34 +203,41 @@
</property>
</spacer>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Thumbnail actions:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<item row="8" column="1">
<widget class="QRadioButton" name="allButtonsThumbnailActionsRadioButton">
<property name="text">
<string>All buttons</string>
</property>
</widget>
</item>
<item row="8" column="1">
<item row="9" column="1">
<widget class="QRadioButton" name="selectionOnlyThumbnailActionsRadioButton">
<property name="text">
<string>Show selection button only</string>
</property>
</widget>
</item>
<item row="9" column="1">
<item row="10" column="1">
<widget class="QRadioButton" name="noneThumbnailActionsRadioButton">
<property name="text">
<string>None</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="kcfg_AutoplayVideos">
<property name="text">
<string>Automatically play</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
......
......@@ -43,6 +43,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
#include <hud/hudslider.h>
#include <hud/hudwidget.h>
#include <graphicswidgetfloater.h>
#include <lib/gwenviewconfig.h>
namespace Gwenview
{
......@@ -61,6 +62,7 @@ struct VideoViewAdapterPrivate
QAction* mPlayPauseAction;
QAction* mMuteAction;
QGraphicsProxyWidget* mProxy;
HudSlider* mVolumeSlider;
QTime mLastVolumeSliderChangeTime;
......@@ -211,14 +213,14 @@ VideoViewAdapter::VideoViewAdapter()
d->mAudioOutput = new Phonon::AudioOutput(Phonon::VideoCategory, this);
Phonon::createPath(d->mMediaObject, d->mAudioOutput);
QGraphicsProxyWidget* proxy = new DoubleClickableProxyWidget;
proxy->setFlag(QGraphicsItem::ItemIsSelectable); // Needed for doubleclick to work
proxy->setWidget(d->mVideoWidget);
proxy->setAcceptHoverEvents(true);
setWidget(proxy);
d->mProxy = new DoubleClickableProxyWidget;
d->mProxy->setFlag(QGraphicsItem::ItemIsSelectable); // Needed for doubleclick to work
d->mProxy->setWidget(d->mVideoWidget);
d->mProxy->setAcceptHoverEvents(GwenviewConfig::autoplayVideos()); // Makes hud visible when autoplay is disabled
setWidget(d->mProxy);
d->setupActions();
d->setupHud(proxy);
d->setupHud(d->mProxy);
updatePlayUi();
updateMuteAction();
......@@ -239,7 +241,9 @@ void VideoViewAdapter::setDocument(const Document::Ptr &doc)
d->mHud->show();
d->mDocument = doc;
d->mMediaObject->setCurrentSource(d->mDocument->url());
d->mMediaObject->play();
if (GwenviewConfig::autoplayVideos()) {
d->mMediaObject->play();
}
// If we do not use a queued connection, the signal arrives too early,
// preventing the listing of the dir content when Gwenview is started with
// a video as an argument.
......@@ -255,8 +259,11 @@ void VideoViewAdapter::slotPlayPauseClicked()
{
if (d->isPlaying()) {
d->mMediaObject->pause();
d->mHud->fadeIn();
d->mProxy->setAcceptHoverEvents(false);
} else {
d->mMediaObject->play();
d->mProxy->setAcceptHoverEvents(true);
}
}
......
......@@ -240,6 +240,10 @@
<entry name="ListVideos" type="Bool">
<default>true</default>
</entry>
<entry name="AutoplayVideos" type="Bool">
<default>false</default>
</entry>
</group>
<group name="Print">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment