Compare commits
No commits in common. "f1796451ae97c6406ef0b1fbb2a32a6e4710fae4" and "7d71e8ce64de34cadb1ce90c596113e737f4e8f3" have entirely different histories.
f1796451ae
...
7d71e8ce64
@ -2,9 +2,12 @@
|
|||||||
|
|
||||||
from log import log
|
from log import log
|
||||||
# import argparse
|
# import argparse
|
||||||
|
# import psutil
|
||||||
import sys
|
import sys
|
||||||
# import threading
|
# import threading
|
||||||
|
# import webbrowser
|
||||||
|
#
|
||||||
|
#
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
# from typing import Callable, Dict, List, Optional, Tuple
|
# from typing import Callable, Dict, List, Optional, Tuple
|
||||||
#
|
#
|
||||||
@ -75,41 +78,38 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
self.previous_track: Optional[TrackData] = None
|
self.previous_track: Optional[TrackData] = None
|
||||||
self.previous_track_position: Optional[int] = None
|
self.previous_track_position: Optional[int] = None
|
||||||
|
|
||||||
self.set_main_window_size()
|
# self.set_main_window_size()
|
||||||
self.lblSumPlaytime = QLabel("")
|
self.lblSumPlaytime = QLabel("")
|
||||||
self.statusbar.addPermanentWidget(self.lblSumPlaytime)
|
self.statusbar.addPermanentWidget(self.lblSumPlaytime)
|
||||||
# self.txtSearch = QLineEdit()
|
# self.txtSearch = QLineEdit()
|
||||||
# self.statusbar.addWidget(self.txtSearch)
|
# self.statusbar.addWidget(self.txtSearch)
|
||||||
# self.txtSearch.setHidden(True)
|
# self.txtSearch.setHidden(True)
|
||||||
self.hide_played_tracks = False
|
self.hide_played_tracks = False
|
||||||
|
#
|
||||||
|
self.splitter.setSizes([200, 200])
|
||||||
self.visible_playlist_tab: Callable[[], PlaylistTab] = \
|
self.visible_playlist_tab: Callable[[], PlaylistTab] = \
|
||||||
self.tabPlaylist.currentWidget
|
self.tabPlaylist.currentWidget
|
||||||
|
|
||||||
self._load_last_playlists()
|
self._load_last_playlists()
|
||||||
self.enable_play_next_controls()
|
self.enable_play_next_controls()
|
||||||
|
# self.check_audacity()
|
||||||
self.timer.start(Config.TIMER_MS)
|
self.timer.start(Config.TIMER_MS)
|
||||||
self.connect_signals_slots()
|
self.connect_signals_slots()
|
||||||
|
#
|
||||||
def set_main_window_size(self) -> None:
|
# def set_main_window_size(self) -> None:
|
||||||
"""Set size of window from database"""
|
# """Set size of window from database"""
|
||||||
|
#
|
||||||
with Session() as session:
|
# with Session() as session:
|
||||||
record = Settings.get_int_settings(session, "mainwindow_x")
|
# record = Settings.get_int_settings(session, "mainwindow_x")
|
||||||
x = record.f_int or 1
|
# x = record.f_int or 1
|
||||||
record = Settings.get_int_settings(session, "mainwindow_y")
|
# record = Settings.get_int_settings(session, "mainwindow_y")
|
||||||
y = record.f_int or 1
|
# y = record.f_int or 1
|
||||||
record = Settings.get_int_settings(session, "mainwindow_width")
|
# record = Settings.get_int_settings(session, "mainwindow_width")
|
||||||
width = record.f_int or 1599
|
# width = record.f_int or 1599
|
||||||
record = Settings.get_int_settings(session, "mainwindow_height")
|
# record = Settings.get_int_settings(session, "mainwindow_height")
|
||||||
height = record.f_int or 981
|
# height = record.f_int or 981
|
||||||
self.setGeometry(x, y, width, height)
|
# self.setGeometry(x, y, width, height)
|
||||||
record = Settings.get_int_settings(session, "splitter_top")
|
# return
|
||||||
splitter_top = record.f_int or 256
|
|
||||||
record = Settings.get_int_settings(session, "splitter_bottom")
|
|
||||||
splitter_bottom = record.f_int or 256
|
|
||||||
self.splitter.setSizes([splitter_top, splitter_bottom])
|
|
||||||
return
|
|
||||||
#
|
#
|
||||||
# @staticmethod
|
# @staticmethod
|
||||||
# def print_current_database():
|
# def print_current_database():
|
||||||
@ -117,6 +117,18 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
# db = session.bind.engine.url.database
|
# db = session.bind.engine.url.database
|
||||||
# print(f"{db=}")
|
# print(f"{db=}")
|
||||||
#
|
#
|
||||||
|
# @staticmethod
|
||||||
|
# def check_audacity() -> None:
|
||||||
|
# """Offer to run Audacity if not running"""
|
||||||
|
#
|
||||||
|
# if not Config.CHECK_AUDACITY_AT_STARTUP:
|
||||||
|
# return
|
||||||
|
#
|
||||||
|
# if "audacity" in [i.name() for i in psutil.process_iter()]:
|
||||||
|
# return
|
||||||
|
#
|
||||||
|
# if helpers.ask_yes_no("Audacity not running", "Start Audacity?"):
|
||||||
|
# QProcess.startDetached(Config.AUDACITY_COMMAND, [])
|
||||||
|
|
||||||
def clear_selection(self) -> None:
|
def clear_selection(self) -> None:
|
||||||
""" Clear selected row"""
|
""" Clear selected row"""
|
||||||
@ -683,6 +695,27 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
|
|
||||||
idx = self.tabPlaylist.indexOf(widget)
|
idx = self.tabPlaylist.indexOf(widget)
|
||||||
self.tabPlaylist.tabBar().setTabTextColor(idx, colour)
|
self.tabPlaylist.tabBar().setTabTextColor(idx, colour)
|
||||||
|
#
|
||||||
|
# def song_info_search(self) -> None:
|
||||||
|
# """
|
||||||
|
# Open browser tab for Wikipedia, searching for
|
||||||
|
# the first that exists of:
|
||||||
|
# - selected track
|
||||||
|
# - next track
|
||||||
|
# - current track
|
||||||
|
# """
|
||||||
|
#
|
||||||
|
# title: Optional[str] = self.visible_playlist_tab().get_selected_title()
|
||||||
|
# if not title:
|
||||||
|
# if self.next_track:
|
||||||
|
# title = self.next_track.title
|
||||||
|
# if not title:
|
||||||
|
# if self.current_track:
|
||||||
|
# title = self.current_track.title
|
||||||
|
# if title:
|
||||||
|
# txt = urllib.parse.quote_plus(title)
|
||||||
|
# url = Config.TAB_URL % txt
|
||||||
|
# webbrowser.open(url, new=2)
|
||||||
|
|
||||||
def stop(self) -> None:
|
def stop(self) -> None:
|
||||||
"""Stop playing immediately"""
|
"""Stop playing immediately"""
|
||||||
|
|||||||
@ -15,7 +15,7 @@ from PyQt5.QtGui import (
|
|||||||
)
|
)
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QAbstractItemView,
|
QAbstractItemView,
|
||||||
QApplication,
|
# QApplication,
|
||||||
# QInputDialog,
|
# QInputDialog,
|
||||||
# QLineEdit,
|
# QLineEdit,
|
||||||
QMainWindow,
|
QMainWindow,
|
||||||
@ -266,9 +266,6 @@ class PlaylistTab(QTableWidget):
|
|||||||
act_info.triggered.connect(
|
act_info.triggered.connect(
|
||||||
lambda: self._info_row(track_id)
|
lambda: self._info_row(track_id)
|
||||||
)
|
)
|
||||||
act_copypath = self.menu.addAction("Copy track path")
|
|
||||||
act_copypath.triggered.connect(
|
|
||||||
lambda: self._copy_path(row_number))
|
|
||||||
|
|
||||||
self.menu.addSeparator()
|
self.menu.addSeparator()
|
||||||
|
|
||||||
@ -718,16 +715,19 @@ class PlaylistTab(QTableWidget):
|
|||||||
|
|
||||||
def save_playlist(self, session: Session) -> None:
|
def save_playlist(self, session: Session) -> None:
|
||||||
"""
|
"""
|
||||||
All playlist rows have a PlaylistRows id. Check that that id points
|
Save playlist to database
|
||||||
to this playlist (in case track has been moved from other) and that
|
|
||||||
the row number is correct (in case tracks have been reordered).
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Iteratate through playlist and check that the row in each
|
||||||
|
# playlist_row object is correct
|
||||||
for row in range(self.rowCount()):
|
for row in range(self.rowCount()):
|
||||||
plr = session.get(PlaylistRows, self._get_playlistrow_id(row))
|
plr = session.get(PlaylistRows, self._get_playlistrow_id(row))
|
||||||
# Set the row number and playlist id (even if correct)
|
# Set the row number (even if it's already correct)
|
||||||
|
if plr.row_number != row:
|
||||||
|
log.debug(
|
||||||
|
f"Updating PlaylistRow: {plr.row_number=}, {row=}"
|
||||||
|
)
|
||||||
plr.row_number = row
|
plr.row_number = row
|
||||||
plr.playlist_id = self.playlist_id
|
|
||||||
|
|
||||||
# Any rows in the database with a row_number higher that the
|
# Any rows in the database with a row_number higher that the
|
||||||
# current value of 'row' should not be there. Commit session
|
# current value of 'row' should not be there. Commit session
|
||||||
@ -1140,27 +1140,24 @@ class PlaylistTab(QTableWidget):
|
|||||||
|
|
||||||
assert self.menu
|
assert self.menu
|
||||||
self.menu.exec_(self.mapToGlobal(pos))
|
self.menu.exec_(self.mapToGlobal(pos))
|
||||||
|
#
|
||||||
def _copy_path(self, row: int) -> None:
|
# def _copy_path(self, row: int) -> None:
|
||||||
"""
|
# """
|
||||||
If passed row has a track, copy the track path, single-quoted,
|
# If passed row is track row, copy the track path to the clipboard.
|
||||||
to the clipboard. Otherwise, return None.
|
# Otherwise, return None.
|
||||||
"""
|
# """
|
||||||
|
#
|
||||||
track_id = self._get_row_track_id(row)
|
# log.debug(f"_copy_path({row})")
|
||||||
if track_id is None:
|
#
|
||||||
return
|
# if row in self._get_notes_rows():
|
||||||
|
# return None
|
||||||
with Session() as session:
|
#
|
||||||
track = session.get(Tracks, track_id)
|
# with Session() as session:
|
||||||
if track:
|
# track: Optional[Tracks] = self._get_row_track_object(row, session)
|
||||||
# Escape single quotes and spaces in name
|
# if track:
|
||||||
path = track.path
|
# cb = QApplication.clipboard()
|
||||||
pathq = path.replace("'", "\\'")
|
# cb.clear(mode=cb.Clipboard)
|
||||||
pathqs = pathq.replace(" ", "\\ ")
|
# cb.setText(track.path, mode=cb.Clipboard)
|
||||||
cb = QApplication.clipboard()
|
|
||||||
cb.clear(mode=cb.Clipboard)
|
|
||||||
cb.setText(pathqs, mode=cb.Clipboard)
|
|
||||||
#
|
#
|
||||||
# def _cell_changed(self, row: int, column: int) -> None:
|
# def _cell_changed(self, row: int, column: int) -> None:
|
||||||
# """Called when cell content has changed"""
|
# """Called when cell content has changed"""
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user