Skip to content

feat: merge media controls. #805

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Mar 31, 2025
Merged
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
1 change: 1 addition & 0 deletions src/tagstudio/core/global_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class GlobalSettings(BaseModel):
language: str = Field(default="en")
open_last_loaded_on_startup: bool = Field(default=False)
autoplay: bool = Field(default=False)
loop: bool = Field(default=True)
show_filenames_in_grid: bool = Field(default=False)
page_size: int = Field(default=500)
show_filepath: ShowFilepathOption = Field(default=ShowFilepathOption.DEFAULT)
Expand Down
43 changes: 43 additions & 0 deletions src/tagstudio/qt/helpers/qslider_wrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright (C) 2025
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio

from typing import override

from PySide6.QtGui import QMouseEvent
from PySide6.QtWidgets import QSlider, QStyle, QStyleOptionSlider


class QClickSlider(QSlider):
"""Custom QSlider wrapper.

The purpose of this wrapper is to allow us to set slider positions
based on click events.
"""

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

@override
def mousePressEvent(self, ev: QMouseEvent):
"""Override to handle mouse clicks.

Overriding the mousePressEvent allows us to seek
directly to the position the user clicked instead
of stepping.
"""
opt = QStyleOptionSlider()
self.initStyleOption(opt)
handle_rect = self.style().subControlRect(
QStyle.ComplexControl.CC_Slider, opt, QStyle.SubControl.SC_SliderHandle, self
)

was_slider_clicked = handle_rect.contains(int(ev.position().x()), int(ev.position().y()))

if not was_slider_clicked:
self.setValue(
QStyle.sliderValueFromPosition(self.minimum(), self.maximum(), ev.x(), self.width())
)
self.mouse_pressed = True

super().mousePressEvent(ev)
Loading