diff --git a/src/basegui.cpp b/src/basegui.cpp
index e709a6d27..5c4e9a3b7 100644
--- a/src/basegui.cpp
+++ b/src/basegui.cpp
@@ -2435,18 +2435,16 @@ void BaseGui::createMplayerWindow() {
panel->setLayout(layout);
// mplayerwindow
- /*
- connect( mplayerwindow, SIGNAL(rightButtonReleased(QPoint)),
- this, SLOT(showPopupMenu(QPoint)) );
- */
-
- // mplayerwindow mouse events
- connect( mplayerwindow, SIGNAL(doubleClicked()),
- this, SLOT(doubleClickFunction()) );
- connect( mplayerwindow, SIGNAL(leftClicked()),
- this, SLOT(leftClickFunction()) );
+ connect( mplayerwindow, SIGNAL(leftButtonPressed()),
+ this, SLOT(leftButtonPressFunction()) );
+ connect( mplayerwindow, SIGNAL(leftButtonReleased()),
+ this, SLOT(leftButtonReleaseFunction()) );
connect( mplayerwindow, SIGNAL(rightClicked()),
this, SLOT(rightClickFunction()) );
+ connect( mplayerwindow, SIGNAL(leftClicked()),
+ this, SLOT(leftClickFunction()) );
+ connect( mplayerwindow, SIGNAL(doubleClicked()),
+ this, SLOT(doubleClickFunction()) );
connect( mplayerwindow, SIGNAL(middleClicked()),
this, SLOT(middleClickFunction()) );
connect( mplayerwindow, SIGNAL(xbutton1Clicked()),
@@ -4904,8 +4902,32 @@ void BaseGui::leftClickFunction() {
}
}
+void BaseGui::leftButtonPressFunction() {
+ qDebug("BaseGui::leftButtonPressFunction");
+ if (pref->enable_pressed_speed) {
+ double speed = pref->pressed_speed;
+ if (speed != core->mset.speed) {
+ core->setSpeed(speed);
+ }
+ }
+}
+
+void BaseGui::leftButtonReleaseFunction() {
+ qDebug("BaseGui::leftButtonReleaseFunction");
+ if (pref->enable_pressed_speed) {
+ if (core->mset.speed != 1.0) {
+ core->setSpeed(1.0);
+ }
+ }
+}
+
void BaseGui::rightClickFunction() {
qDebug("BaseGui::rightClickFunction");
+ if (pref->enable_pressed_speed) {
+ if (core->mset.speed != 1.0) {
+ core->setSpeed(1.0);
+ }
+ }
if (!pref->mouse_right_click_function.isEmpty()) {
processFunction(pref->mouse_right_click_function);
diff --git a/src/basegui.h b/src/basegui.h
index cb98b27f0..80af193f6 100644
--- a/src/basegui.h
+++ b/src/basegui.h
@@ -297,7 +297,8 @@ protected slots:
virtual void mouseReleaseEvent( QMouseEvent * e );
virtual void mouseDoubleClickEvent( QMouseEvent * e );
*/
-
+ virtual void leftButtonPressFunction();
+ virtual void leftButtonReleaseFunction();
virtual void leftClickFunction();
virtual void rightClickFunction();
virtual void doubleClickFunction();
diff --git a/src/mplayerwindow.cpp b/src/mplayerwindow.cpp
index 8df736b31..cb648c7f0 100644
--- a/src/mplayerwindow.cpp
+++ b/src/mplayerwindow.cpp
@@ -72,6 +72,7 @@ MplayerWindow::MplayerWindow(QWidget* parent, Qt::WindowFlags f)
, resize_timer(0)
#endif
, delay_left_click(false)
+ , left_pressed_timer(0)
, left_click_timer(0)
, double_clicked(false)
#if LOGO_ANIMATION
@@ -81,6 +82,7 @@ MplayerWindow::MplayerWindow(QWidget* parent, Qt::WindowFlags f)
, drag_state(NOT_DRAGGING)
, start_drag(QPoint(0,0))
, mouse_drag_tracking(false)
+ , left_button_pressed_emitted(false)
{
helper = new ScreenHelper(this);
connect(helper, SIGNAL(mouseMoved(QPoint)), this, SIGNAL(mouseMoved(QPoint)));
@@ -132,6 +134,11 @@ MplayerWindow::MplayerWindow(QWidget* parent, Qt::WindowFlags f)
left_click_timer->setInterval(qApp->doubleClickInterval()+10);
connect(left_click_timer, SIGNAL(timeout()), this, SIGNAL(leftClicked()));
+ left_pressed_timer = new QTimer(this);
+ left_pressed_timer->setSingleShot(true);
+ left_pressed_timer->setInterval(qApp->doubleClickInterval()+10);
+ connect(left_pressed_timer, SIGNAL(timeout()), this, SLOT(emitLeftButtonPressed()));
+
retranslateStrings();
}
@@ -334,11 +341,27 @@ void MplayerWindow::updateVideoWindow()
}
+void MplayerWindow::mousePressEvent( QMouseEvent * e) {
+ qDebug( "MplayerWindow::mousePressEvent" );
+
+ if (e->button() == Qt::LeftButton) {
+ e->accept();
+ if (!double_clicked) left_pressed_timer->start();
+ } else {
+ e->ignore();
+ }
+}
+
void MplayerWindow::mouseReleaseEvent( QMouseEvent * e) {
qDebug( "MplayerWindow::mouseReleaseEvent" );
if (e->button() == Qt::LeftButton) {
e->accept();
+ left_pressed_timer->stop();
+ if (left_button_pressed_emitted) {
+ emit leftButtonReleased();
+ left_button_pressed_emitted = false;
+ }
if (delay_left_click) {
if (!double_clicked) left_click_timer->start();
double_clicked = false;
@@ -454,6 +477,13 @@ bool MplayerWindow::eventFilter( QObject * object, QEvent * event ) {
// Stop dragging and eat event
drag_state = NOT_DRAGGING;
+
+ // Emit leftButtonReleased signal if we were dragging
+ if (left_button_pressed_emitted) {
+ emit leftButtonReleased();
+ left_button_pressed_emitted = false;
+ }
+
event->accept();
return true;
}
@@ -578,4 +608,10 @@ void MplayerWindow::changeEvent(QEvent *e) {
}
}
+void MplayerWindow::emitLeftButtonPressed() {
+ qDebug("MplayerWindow::emitLeftButtonPressed");
+ left_button_pressed_emitted = true;
+ emit leftButtonPressed();
+}
+
#include "moc_mplayerwindow.cpp"
diff --git a/src/mplayerwindow.h b/src/mplayerwindow.h
index dffc56993..42680772b 100644
--- a/src/mplayerwindow.h
+++ b/src/mplayerwindow.h
@@ -133,11 +133,15 @@ protected slots:
void resizeLater();
#endif
+protected slots:
+ void emitLeftButtonPressed();
+
protected:
virtual void retranslateStrings();
virtual void changeEvent ( QEvent * event ) ;
virtual void resizeEvent( QResizeEvent * e);
+ virtual void mousePressEvent( QMouseEvent * e);
virtual void mouseReleaseEvent( QMouseEvent * e);
virtual void mouseDoubleClickEvent( QMouseEvent * e );
virtual void wheelEvent( QWheelEvent * e );
@@ -156,6 +160,8 @@ protected slots:
void wheelDown();
void mouseMovedDiff(QPoint);
void mouseMoved(QPoint);
+ void leftButtonPressed();
+ void leftButtonReleased();
protected:
int video_width, video_height;
@@ -185,6 +191,7 @@ protected slots:
// Delay left click event
bool delay_left_click;
QTimer * left_click_timer;
+ QTimer * left_pressed_timer;
bool double_clicked;
#if LOGO_ANIMATION
@@ -201,6 +208,7 @@ protected slots:
TDragState drag_state;
QPoint start_drag;
bool mouse_drag_tracking;
+ bool left_button_pressed_emitted;
};
#endif
diff --git a/src/preferences.cpp b/src/preferences.cpp
index 40b7452e0..c8b80707a 100644
--- a/src/preferences.cpp
+++ b/src/preferences.cpp
@@ -178,6 +178,9 @@ void Preferences::reset() {
global_speed = false;
speed = 1.0;
+
+ enable_pressed_speed = true;
+ pressed_speed = 2.0;
autosync = false;
autosync_factor = 100;
@@ -758,6 +761,9 @@ void Preferences::save() {
set->setValue("global_speed", global_speed);
set->setValue("speed", speed);
+
+ set->setValue("enable_pressed_speed", enable_pressed_speed);
+ set->setValue("pressed_speed", pressed_speed);
set->setValue("autosync", autosync);
set->setValue("autosync_factor", autosync_factor);
@@ -1357,6 +1363,9 @@ void Preferences::load() {
global_speed = set->value("global_speed", global_speed).toBool();
speed = set->value("speed", speed).toDouble();
+
+ enable_pressed_speed = set->value("enable_pressed_speed", enable_pressed_speed).toBool();
+ pressed_speed = set->value("pressed_speed", pressed_speed).toDouble();
autosync = set->value("autosync", autosync).toBool();
autosync_factor = set->value("autosync_factor", autosync_factor).toInt();
diff --git a/src/preferences.h b/src/preferences.h
index 97fe027f7..4bde1fae7 100644
--- a/src/preferences.h
+++ b/src/preferences.h
@@ -154,6 +154,10 @@ class Preferences {
bool global_speed;
double speed;
+ // Pressed speed
+ bool enable_pressed_speed;
+ double pressed_speed;
+
bool autosync;
int autosync_factor;
diff --git a/src/prefinterface.cpp b/src/prefinterface.cpp
index 1fb5f784d..60e76b004 100644
--- a/src/prefinterface.cpp
+++ b/src/prefinterface.cpp
@@ -147,6 +147,9 @@ PrefInterface::PrefInterface(QWidget * parent, Qt::WindowFlags f)
tabWidget->setTabEnabled(HDPI_TAB, false);
#endif
+ connect(enable_pressed_speed_check, SIGNAL(toggled(bool)), pressed_speed_label, SLOT(setEnabled(bool)));
+ connect(enable_pressed_speed_check, SIGNAL(toggled(bool)), pressed_speed_spin, SLOT(setEnabled(bool)));
+
retranslateStrings();
}
@@ -294,6 +297,9 @@ void PrefInterface::setData(Preferences * pref) {
#endif
setPreciseSeeking(pref->precise_seeking);
+ setEnablePressedSpeed(pref->enable_pressed_speed);
+ setPressedSpeed(pref->pressed_speed);
+
reset_stop_check->setChecked(pref->reset_stop);
setDefaultFont(pref->default_font);
@@ -370,6 +376,9 @@ void PrefInterface::getData(Preferences * pref) {
#endif
pref->precise_seeking = preciseSeeking();
+ pref->enable_pressed_speed = enablePressedSpeed();
+ pref->pressed_speed = pressedSpeed();
+
pref->reset_stop = reset_stop_check->isChecked();
if (pref->default_font != defaultFont()) {
@@ -597,6 +606,24 @@ bool PrefInterface::preciseSeeking() {
return precise_seeking_check->isChecked();
}
+void PrefInterface::setEnablePressedSpeed(bool b) {
+ enable_pressed_speed_check->setChecked(b);
+ pressed_speed_spin->setEnabled(b);
+ pressed_speed_label->setEnabled(b);
+}
+
+bool PrefInterface::enablePressedSpeed() {
+ return enable_pressed_speed_check->isChecked();
+}
+
+void PrefInterface::setPressedSpeed(double d) {
+ pressed_speed_spin->setValue(d);
+}
+
+double PrefInterface::pressedSpeed() {
+ return pressed_speed_spin->value();
+}
+
void PrefInterface::setDefaultFont(QString font_desc) {
default_font_edit->setText(font_desc);
}
@@ -824,9 +851,15 @@ void PrefInterface::createHelp() {
#endif
setWhatsThis(precise_seeking_check, tr("Precise seeking"),
- tr("If this option is enabled, seeks are more accurate but they "
- "can be a little bit slower. May not work with some video formats.") +"
"+
- tr("Note: this option only works when using mpv as multimedia engine.") );
+ tr("If this option is checked, seeks are more accurate but they can be a little bit slower. "
+ "Note: this option only affects the slider behavior, it doesn't affect the seeking "
+ "by clicking on the waveform.") );
+
+ setWhatsThis(enable_pressed_speed_check, tr("Enable pressed speed"),
+ tr("If this option is checked, the playback speed will be changed when the left mouse button is pressed on the video window.") );
+
+ setWhatsThis(pressed_speed_spin, tr("Pressed speed"),
+ tr("If you hold the left mouse button in the video window, the media will be played at this speed.") );
setWhatsThis(reset_stop_check, tr("Pressing the stop button once resets the time position"),
tr("By default when the stop button is pressed the time position is remembered "
diff --git a/src/prefinterface.h b/src/prefinterface.h
index 066278c15..3dffb5ddf 100644
--- a/src/prefinterface.h
+++ b/src/prefinterface.h
@@ -100,6 +100,12 @@ class PrefInterface : public PrefWidget, public Ui::PrefInterface
void setPreciseSeeking(bool);
bool preciseSeeking();
+ void setEnablePressedSpeed(bool b);
+ bool enablePressedSpeed();
+
+ void setPressedSpeed(double d);
+ double pressedSpeed();
+
void setDefaultFont(QString font_desc);
QString defaultFont();
diff --git a/src/prefinterface.ui b/src/prefinterface.ui
index 99016b82c..ab0e17494 100644
--- a/src/prefinterface.ui
+++ b/src/prefinterface.ui
@@ -614,6 +614,69 @@
+ -
+
+
+ Enable &pressed speed
+
+
+
+ -
+
+
-
+
+
+ P&ressed speed:
+
+
+ pressed_speed_spin
+
+
+
+ -
+
+
+ 0.100000000000000
+
+
+ 10.000000000000000
+
+
+ 0.100000000000000
+
+
+ 2.000000000000000
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+