Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 32 additions & 10 deletions src/basegui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/basegui.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
36 changes: 36 additions & 0 deletions src/mplayerwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)));
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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"
8 changes: 8 additions & 0 deletions src/mplayerwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -156,6 +160,8 @@ protected slots:
void wheelDown();
void mouseMovedDiff(QPoint);
void mouseMoved(QPoint);
void leftButtonPressed();
void leftButtonReleased();

protected:
int video_width, video_height;
Expand Down Expand Up @@ -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
Expand All @@ -201,6 +208,7 @@ protected slots:
TDragState drag_state;
QPoint start_drag;
bool mouse_drag_tracking;
bool left_button_pressed_emitted;
};

#endif
Expand Down
9 changes: 9 additions & 0 deletions src/preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 4 additions & 0 deletions src/preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
39 changes: 36 additions & 3 deletions src/prefinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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.") +"<br>"+
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 "
Expand Down
6 changes: 6 additions & 0 deletions src/prefinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
63 changes: 63 additions & 0 deletions src/prefinterface.ui
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,69 @@
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="QCheckBox" name="enable_pressed_speed_check">
<property name="text">
<string>Enable &amp;pressed speed</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_pressed_speed">
<item>
<widget class="QLabel" name="pressed_speed_label">
<property name="text">
<string>P&amp;ressed speed:</string>
</property>
<property name="buddy">
<cstring>pressed_speed_spin</cstring>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="pressed_speed_spin">
<property name="minimum">
<double>0.100000000000000</double>
</property>
<property name="maximum">
<double>10.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>2.000000000000000</double>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_pressed_speed">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="9" column="0" colspan="2">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
Expand Down