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) ...@@ -67,6 +67,11 @@ ConfigDialog::ConfigDialog(QWidget* parent)
mGeneralConfigPage.jpegQualitySpinner->setValue(mGeneralConfigPage.kcfg_JPEGQuality->value()); mGeneralConfigPage.jpegQualitySpinner->setValue(mGeneralConfigPage.kcfg_JPEGQuality->value());
mGeneralConfigPage.backgroundValueFrame->setMinimumWidth(mGeneralConfigPage.jpegQualitySpinner->width()); 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 // Image View
widget = setupPage(mImageViewConfigPage); widget = setupPage(mImageViewConfigPage);
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="2" column="1">
<spacer name="verticalSpacer_1"> <spacer name="verticalSpacer_1">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
...@@ -41,14 +41,14 @@ ...@@ -41,14 +41,14 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="2" column="0"> <item row="3" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>Background color:</string> <string>Background color:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="3" column="1">
<layout class="QHBoxLayout"> <layout class="QHBoxLayout">
<item> <item>
<widget class="QSlider" name="kcfg_ViewBackgroundValue"> <widget class="QSlider" name="kcfg_ViewBackgroundValue">
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="3" column="1"> <item row="4" column="1">
<spacer name="verticalSpacer_2"> <spacer name="verticalSpacer_2">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
...@@ -122,14 +122,14 @@ ...@@ -122,14 +122,14 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="5" column="0"> <item row="6" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>JPEG save quality:</string> <string>JPEG save quality:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="1"> <item row="6" column="1">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QSlider" name="kcfg_JPEGQuality"> <widget class="QSlider" name="kcfg_JPEGQuality">
...@@ -187,7 +187,7 @@ ...@@ -187,7 +187,7 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="6" column="1"> <item row="7" column="1">
<spacer name="verticalSpacer_3"> <spacer name="verticalSpacer_3">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
...@@ -203,34 +203,41 @@ ...@@ -203,34 +203,41 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="7" column="0"> <item row="8" column="0">
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="text"> <property name="text">
<string>Thumbnail actions:</string> <string>Thumbnail actions:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="1"> <item row="8" column="1">
<widget class="QRadioButton" name="allButtonsThumbnailActionsRadioButton"> <widget class="QRadioButton" name="allButtonsThumbnailActionsRadioButton">
<property name="text"> <property name="text">
<string>All buttons</string> <string>All buttons</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="1"> <item row="9" column="1">
<widget class="QRadioButton" name="selectionOnlyThumbnailActionsRadioButton"> <widget class="QRadioButton" name="selectionOnlyThumbnailActionsRadioButton">
<property name="text"> <property name="text">
<string>Show selection button only</string> <string>Show selection button only</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="1"> <item row="10" column="1">
<widget class="QRadioButton" name="noneThumbnailActionsRadioButton"> <widget class="QRadioButton" name="noneThumbnailActionsRadioButton">
<property name="text"> <property name="text">
<string>None</string> <string>None</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<widget class="QCheckBox" name="kcfg_AutoplayVideos">
<property name="text">
<string>Automatically play</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>
......
...@@ -43,6 +43,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA ...@@ -43,6 +43,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
#include <hud/hudslider.h> #include <hud/hudslider.h>
#include <hud/hudwidget.h> #include <hud/hudwidget.h>
#include <graphicswidgetfloater.h> #include <graphicswidgetfloater.h>
#include <lib/gwenviewconfig.h>
namespace Gwenview namespace Gwenview
{ {
...@@ -61,6 +62,7 @@ struct VideoViewAdapterPrivate ...@@ -61,6 +62,7 @@ struct VideoViewAdapterPrivate
QAction* mPlayPauseAction; QAction* mPlayPauseAction;
QAction* mMuteAction; QAction* mMuteAction;
QGraphicsProxyWidget* mProxy;
HudSlider* mVolumeSlider; HudSlider* mVolumeSlider;
QTime mLastVolumeSliderChangeTime; QTime mLastVolumeSliderChangeTime;
...@@ -211,14 +213,14 @@ VideoViewAdapter::VideoViewAdapter() ...@@ -211,14 +213,14 @@ VideoViewAdapter::VideoViewAdapter()
d->mAudioOutput = new Phonon::AudioOutput(Phonon::VideoCategory, this); d->mAudioOutput = new Phonon::AudioOutput(Phonon::VideoCategory, this);
Phonon::createPath(d->mMediaObject, d->mAudioOutput); Phonon::createPath(d->mMediaObject, d->mAudioOutput);
QGraphicsProxyWidget* proxy = new DoubleClickableProxyWidget; d->mProxy = new DoubleClickableProxyWidget;
proxy->setFlag(QGraphicsItem::ItemIsSelectable); // Needed for doubleclick to work d->mProxy->setFlag(QGraphicsItem::ItemIsSelectable); // Needed for doubleclick to work
proxy->setWidget(d->mVideoWidget); d->mProxy->setWidget(d->mVideoWidget);
proxy->setAcceptHoverEvents(true); d->mProxy->setAcceptHoverEvents(GwenviewConfig::autoplayVideos()); // Makes hud visible when autoplay is disabled
setWidget(proxy); setWidget(d->mProxy);
d->setupActions(); d->setupActions();
d->setupHud(proxy); d->setupHud(d->mProxy);
updatePlayUi(); updatePlayUi();
updateMuteAction(); updateMuteAction();
...@@ -239,7 +241,9 @@ void VideoViewAdapter::setDocument(const Document::Ptr &doc) ...@@ -239,7 +241,9 @@ void VideoViewAdapter::setDocument(const Document::Ptr &doc)
d->mHud->show(); d->mHud->show();
d->mDocument = doc; d->mDocument = doc;
d->mMediaObject->setCurrentSource(d->mDocument->url()); 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, // 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 // preventing the listing of the dir content when Gwenview is started with
// a video as an argument. // a video as an argument.
...@@ -255,8 +259,11 @@ void VideoViewAdapter::slotPlayPauseClicked() ...@@ -255,8 +259,11 @@ void VideoViewAdapter::slotPlayPauseClicked()
{ {
if (d->isPlaying()) { if (d->isPlaying()) {
d->mMediaObject->pause(); d->mMediaObject->pause();
d->mHud->fadeIn();
d->mProxy->setAcceptHoverEvents(false);
} else { } else {
d->mMediaObject->play(); d->mMediaObject->play();
d->mProxy->setAcceptHoverEvents(true);
} }
} }
......
...@@ -240,6 +240,10 @@ ...@@ -240,6 +240,10 @@
<entry name="ListVideos" type="Bool"> <entry name="ListVideos" type="Bool">
<default>true</default> <default>true</default>
</entry> </entry>
<entry name="AutoplayVideos" type="Bool">
<default>false</default>
</entry>
</group> </group>
<group name="Print"> <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