trackma 0.4__py2.7.egg → 0.5__py2.7.egg
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- EGG-INFO/PKG-INFO +1 -1
- EGG-INFO/SOURCES.txt +2 -0
- trackma/__init__.pyc +0 -0
- trackma/accounts.py +36 -1
- trackma/accounts.pyc +0 -0
- trackma/data/shikimori.jpg +0 -0
- trackma/data.py +33 -20
- trackma/data.pyc +0 -0
- trackma/engine.py +82 -11
- trackma/engine.pyc +0 -0
- trackma/extras/AnimeInfoExtractor.pyc +0 -0
- trackma/extras/__init__.pyc +0 -0
- trackma/extras/plex.pyc +0 -0
- trackma/lib/__init__.pyc +0 -0
- trackma/lib/lib.pyc +0 -0
- trackma/lib/libanilist.py +65 -17
- trackma/lib/libanilist.pyc +0 -0
- trackma/lib/libhb.py +4 -5
- trackma/lib/libhb.pyc +0 -0
- trackma/lib/libmal.py +10 -7
- trackma/lib/libmal.pyc +0 -0
- trackma/lib/libmelative.py +1 -1
- trackma/lib/libmelative.pyc +0 -0
- trackma/lib/libshikimori.py +338 -0
- trackma/lib/libshikimori.pyc +0 -0
- trackma/lib/libvndb.py +1 -0
- trackma/lib/libvndb.pyc +0 -0
- trackma/messenger.pyc +0 -0
- trackma/tracker.py +64 -17
- trackma/tracker.pyc +0 -0
- trackma/ui/__init__.pyc +0 -0
- trackma/ui/cli.py +191 -70
- trackma/ui/cli.pyc +0 -0
- trackma/ui/curses.py +14 -3
- trackma/ui/curses.pyc +0 -0
- trackma/ui/gtkui.py +341 -110
- trackma/ui/gtkui.pyc +0 -0
- trackma/ui/qtui.py +1243 -327
- trackma/ui/qtui.pyc +0 -0
- trackma/utils.py +118 -38
- trackma/utils.pyc +0 -0
trackma/ui/qtui.py
CHANGED
|
@@ -17,16 +17,57 @@
|
|
|
17
17
|
|
|
18
18
|
import sys
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
pyqt_version = 0
|
|
21
|
+
try_pyqt5 = True # TODO: Make this a program argument or something
|
|
22
|
+
|
|
23
|
+
if try_pyqt5:
|
|
24
|
+
try:
|
|
25
|
+
from PyQt5 import QtGui, QtCore
|
|
26
|
+
from PyQt5.QtGui import QIcon, QPalette
|
|
27
|
+
from PyQt5.QtWidgets import (QApplication, QMainWindow, QFormLayout,
|
|
28
|
+
QGridLayout, QHBoxLayout, QVBoxLayout,
|
|
29
|
+
QAbstractItemView, QHeaderView, QListWidget,
|
|
30
|
+
QListWidgetItem, QTabWidget, QTableWidget,
|
|
31
|
+
QTableWidgetItem, QFrame, QScrollArea,
|
|
32
|
+
QStackedWidget, QWidget, QCheckBox, QComboBox,
|
|
33
|
+
QDoubleSpinBox, QGroupBox, QLineEdit,
|
|
34
|
+
QPushButton, QRadioButton, QSpinBox,
|
|
35
|
+
QStyleOptionButton, QToolButton, QProgressBar,
|
|
36
|
+
QDialog, QColorDialog, QDialogButtonBox,
|
|
37
|
+
QFileDialog, QInputDialog, QMessageBox,
|
|
38
|
+
QAction, QActionGroup, QLabel, QMenu, QStyle,
|
|
39
|
+
QSystemTrayIcon)
|
|
40
|
+
pyqt_version = 5
|
|
41
|
+
except ImportError:
|
|
42
|
+
print ("Couldn't import Qt5 dependencies. Make sure you "
|
|
43
|
+
"installed the PyQt5 package.")
|
|
44
|
+
#sys.exit(-1)
|
|
45
|
+
if pyqt_version is 0:
|
|
46
|
+
try:
|
|
47
|
+
import sip
|
|
48
|
+
sip.setapi('QVariant', 2)
|
|
49
|
+
from PyQt4 import QtGui, QtCore
|
|
50
|
+
from PyQt4.QtGui import (QApplication, QMainWindow,
|
|
51
|
+
QFormLayout, QGridLayout, QHBoxLayout, QVBoxLayout,
|
|
52
|
+
QAbstractItemView, QHeaderView,
|
|
53
|
+
QListWidget, QListWidgetItem, QTabWidget, QTableWidget, QTableWidgetItem,
|
|
54
|
+
QFrame, QScrollArea, QStackedWidget,
|
|
55
|
+
QWidget, QCheckBox, QComboBox, QDoubleSpinBox, QGroupBox, QLineEdit,
|
|
56
|
+
QPushButton, QRadioButton, QSpinBox, QStyleOptionButton, QToolButton,
|
|
57
|
+
QProgressBar,
|
|
58
|
+
QDialog, QColorDialog, QDialogButtonBox, QFileDialog, QInputDialog, QMessageBox,
|
|
59
|
+
QAction, QActionGroup, QLabel, QMenu, QStyle,
|
|
60
|
+
QSystemTrayIcon, QIcon, QPalette)
|
|
61
|
+
pyqt_version = 4
|
|
62
|
+
except ImportError:
|
|
63
|
+
print ("Couldn't import Qt dependencies. Make sure you "
|
|
64
|
+
"installed the PyQt4 package.")
|
|
65
|
+
sys.exit(-1)
|
|
26
66
|
|
|
27
67
|
import os
|
|
28
68
|
from cStringIO import StringIO
|
|
29
69
|
import urllib2
|
|
70
|
+
import base64
|
|
30
71
|
|
|
31
72
|
import trackma.messenger as messenger
|
|
32
73
|
import trackma.utils as utils
|
|
@@ -35,17 +76,26 @@ from trackma.engine import Engine
|
|
|
35
76
|
from trackma.accounts import AccountManager
|
|
36
77
|
|
|
37
78
|
try:
|
|
38
|
-
import Image
|
|
79
|
+
from PIL import Image
|
|
39
80
|
imaging_available = True
|
|
40
81
|
except ImportError:
|
|
41
82
|
try:
|
|
42
|
-
|
|
83
|
+
import Image
|
|
43
84
|
imaging_available = True
|
|
44
85
|
except ImportError:
|
|
45
86
|
print "Warning: PIL or Pillow isn't available. Preview images will be disabled."
|
|
46
87
|
imaging_available = False
|
|
47
88
|
|
|
48
|
-
|
|
89
|
+
try:
|
|
90
|
+
import dateutil.parser
|
|
91
|
+
import dateutil.tz
|
|
92
|
+
import datetime
|
|
93
|
+
dateutil_available = True
|
|
94
|
+
except ImportError:
|
|
95
|
+
print "Warning: DateUtil is unavailable. Next episode countdown will be disabled."
|
|
96
|
+
dateutil_available = False
|
|
97
|
+
|
|
98
|
+
class Trackma(QMainWindow):
|
|
49
99
|
"""
|
|
50
100
|
Main GUI class
|
|
51
101
|
|
|
@@ -62,14 +112,16 @@ class Trackma(QtGui.QMainWindow):
|
|
|
62
112
|
was_maximized = False
|
|
63
113
|
|
|
64
114
|
def __init__(self):
|
|
65
|
-
|
|
115
|
+
QMainWindow.__init__(self, None)
|
|
66
116
|
|
|
67
117
|
# Load QT specific configuration
|
|
68
118
|
self.configfile = utils.get_root_filename('ui-qt.json')
|
|
69
119
|
self.config = utils.parse_config(self.configfile, utils.qt_defaults)
|
|
120
|
+
self.api_configfile = utils.get_root_filename('ui-qt.0.json')
|
|
121
|
+
self.api_config = {}
|
|
70
122
|
|
|
71
123
|
# Build UI
|
|
72
|
-
|
|
124
|
+
QApplication.setWindowIcon(QIcon(utils.datadir + '/data/icon.png'))
|
|
73
125
|
self.setWindowTitle('Trackma-qt')
|
|
74
126
|
|
|
75
127
|
self.accountman = AccountManager()
|
|
@@ -97,6 +149,7 @@ class Trackma(QtGui.QMainWindow):
|
|
|
97
149
|
else:
|
|
98
150
|
self.start(account)
|
|
99
151
|
|
|
152
|
+
|
|
100
153
|
def start(self, account):
|
|
101
154
|
"""
|
|
102
155
|
Start engine and everything
|
|
@@ -118,63 +171,136 @@ class Trackma(QtGui.QMainWindow):
|
|
|
118
171
|
self.busy_timer.timeout.connect(self.s_busy)
|
|
119
172
|
|
|
120
173
|
# Build menus
|
|
121
|
-
action_play_next =
|
|
174
|
+
action_play_next = QAction(getIcon('media-playback-start'), 'Play &Next', self)
|
|
122
175
|
action_play_next.setStatusTip('Play the next unwatched episode.')
|
|
123
176
|
action_play_next.setShortcut('Ctrl+N')
|
|
124
177
|
action_play_next.triggered.connect(lambda: self.s_play(True))
|
|
125
|
-
|
|
178
|
+
action_play_dialog = QAction('Play Episode...', self)
|
|
179
|
+
action_play_dialog.setStatusTip('Select an episode to play.')
|
|
180
|
+
action_play_dialog.triggered.connect(self.s_play_number)
|
|
181
|
+
action_details = QAction('Show &details...', self)
|
|
126
182
|
action_details.setStatusTip('Show detailed information about the selected show.')
|
|
127
183
|
action_details.triggered.connect(self.s_show_details)
|
|
128
|
-
action_altname =
|
|
184
|
+
action_altname = QAction('Change &alternate name...', self)
|
|
129
185
|
action_altname.setStatusTip('Set an alternate title for the tracker.')
|
|
130
186
|
action_altname.triggered.connect(self.s_altname)
|
|
131
|
-
|
|
187
|
+
action_play_random = QAction('Play &random show', self)
|
|
188
|
+
action_play_random.setStatusTip('Pick a random show with a new episode and play it.')
|
|
189
|
+
action_play_random.setShortcut('Ctrl+R')
|
|
190
|
+
action_play_random.triggered.connect(self.s_play_random)
|
|
191
|
+
action_add = QAction(getIcon('edit-find'), 'Search/Add from Remote', self)
|
|
132
192
|
action_add.setShortcut('Ctrl+A')
|
|
133
193
|
action_add.triggered.connect(self.s_add)
|
|
134
|
-
action_delete =
|
|
194
|
+
action_delete = QAction(getIcon('edit-delete'), '&Delete', self)
|
|
135
195
|
action_delete.setStatusTip('Remove this show from your list.')
|
|
136
196
|
action_delete.triggered.connect(self.s_delete)
|
|
137
|
-
action_quit =
|
|
197
|
+
action_quit = QAction(getIcon('application-exit'), '&Quit', self)
|
|
138
198
|
action_quit.setShortcut('Ctrl+Q')
|
|
139
199
|
action_quit.setStatusTip('Exit Trackma.')
|
|
140
200
|
action_quit.triggered.connect(self._exit)
|
|
141
201
|
|
|
142
|
-
action_sync =
|
|
202
|
+
action_sync = QAction('&Sync', self)
|
|
143
203
|
action_sync.setStatusTip('Send changes and then retrieve remote list')
|
|
144
204
|
action_sync.setShortcut('Ctrl+S')
|
|
145
205
|
action_sync.triggered.connect(lambda: self.s_send(True))
|
|
146
|
-
action_send =
|
|
206
|
+
action_send = QAction('S&end changes', self)
|
|
147
207
|
action_send.setShortcut('Ctrl+E')
|
|
148
208
|
action_send.setStatusTip('Upload any changes made to the list immediately.')
|
|
149
209
|
action_send.triggered.connect(self.s_send)
|
|
150
|
-
action_retrieve =
|
|
151
|
-
action_retrieve.setShortcut('Ctrl+
|
|
210
|
+
action_retrieve = QAction('Re&download list', self)
|
|
211
|
+
action_retrieve.setShortcut('Ctrl+D')
|
|
152
212
|
action_retrieve.setStatusTip('Discard any changes made to the list and re-download it.')
|
|
153
213
|
action_retrieve.triggered.connect(self.s_retrieve)
|
|
154
|
-
action_scan_library =
|
|
214
|
+
action_scan_library = QAction('Rescan &Library', self)
|
|
155
215
|
action_scan_library.triggered.connect(self.s_scan_library)
|
|
156
216
|
|
|
157
|
-
action_reload =
|
|
217
|
+
action_reload = QAction('Switch &Account', self)
|
|
158
218
|
action_reload.setStatusTip('Switch to a different account.')
|
|
159
219
|
action_reload.triggered.connect(self.s_switch_account)
|
|
160
|
-
action_settings =
|
|
220
|
+
action_settings = QAction('&Settings...', self)
|
|
161
221
|
action_settings.triggered.connect(self.s_settings)
|
|
162
222
|
|
|
163
|
-
action_about =
|
|
223
|
+
action_about = QAction(getIcon('help-about'), 'About...', self)
|
|
164
224
|
action_about.triggered.connect(self.s_about)
|
|
165
|
-
action_about_qt =
|
|
225
|
+
action_about_qt = QAction('About Qt...', self)
|
|
166
226
|
action_about_qt.triggered.connect(self.s_about_qt)
|
|
167
227
|
|
|
168
228
|
menubar = self.menuBar()
|
|
169
229
|
self.menu_show = menubar.addMenu('&Show')
|
|
170
230
|
self.menu_show.addAction(action_play_next)
|
|
231
|
+
self.menu_show.addAction(action_play_dialog)
|
|
171
232
|
self.menu_show.addAction(action_details)
|
|
172
233
|
self.menu_show.addAction(action_altname)
|
|
173
234
|
self.menu_show.addSeparator()
|
|
235
|
+
self.menu_show.addAction(action_play_random)
|
|
236
|
+
self.menu_show.addSeparator()
|
|
174
237
|
self.menu_show.addAction(action_add)
|
|
175
238
|
self.menu_show.addAction(action_delete)
|
|
176
239
|
self.menu_show.addSeparator()
|
|
177
240
|
self.menu_show.addAction(action_quit)
|
|
241
|
+
|
|
242
|
+
self.menu_play = QMenu('Play')
|
|
243
|
+
|
|
244
|
+
# Context menu for right click on list item
|
|
245
|
+
self.menu_show_context = QMenu()
|
|
246
|
+
#self.menu_show_context.addAction(action_play_next)
|
|
247
|
+
#self.menu_show_context.addAction(action_play_dialog)
|
|
248
|
+
self.menu_show_context.addMenu(self.menu_play)
|
|
249
|
+
self.menu_show_context.addAction(action_details)
|
|
250
|
+
self.menu_show_context.addAction(action_altname)
|
|
251
|
+
self.menu_show_context.addSeparator()
|
|
252
|
+
self.menu_show_context.addAction(action_delete)
|
|
253
|
+
|
|
254
|
+
# Context menu for right click on list header
|
|
255
|
+
self.menu_columns = QMenu()
|
|
256
|
+
self.available_columns = ['ID', 'Title', 'Progress', 'Score',
|
|
257
|
+
'Percent', 'Next Episode', 'Start date', 'End date',
|
|
258
|
+
'My start', 'My finish', 'Tags']
|
|
259
|
+
self.column_keys = {'id': 0,
|
|
260
|
+
'title': 1,
|
|
261
|
+
'progress': 2,
|
|
262
|
+
'score': 3,
|
|
263
|
+
'percent': 4,
|
|
264
|
+
'next_ep': 5,
|
|
265
|
+
'date_start': 6,
|
|
266
|
+
'date_end': 7,
|
|
267
|
+
'my_start': 8,
|
|
268
|
+
'my_end': 9,
|
|
269
|
+
'tag': 10}
|
|
270
|
+
|
|
271
|
+
self.menu_columns_group = QActionGroup(self, exclusive=False)
|
|
272
|
+
self.menu_columns_group.triggered.connect(self.s_toggle_column)
|
|
273
|
+
|
|
274
|
+
self.api_configfile = utils.get_root_filename('ui-qt.%s.json' % account['api'])
|
|
275
|
+
self.api_config = utils.parse_config(self.api_configfile, utils.qt_per_api_defaults)
|
|
276
|
+
if self.config['columns_per_api']:
|
|
277
|
+
self.config['visible_columns'] = self.api_config['visible_columns']
|
|
278
|
+
self.config['columns_state'] = self.api_config['columns_state']
|
|
279
|
+
|
|
280
|
+
for column_name in self.available_columns:
|
|
281
|
+
action = QAction(column_name, self, checkable=True)
|
|
282
|
+
if column_name in self.config['visible_columns']:
|
|
283
|
+
action.setChecked(True)
|
|
284
|
+
|
|
285
|
+
self.menu_columns_group.addAction(action)
|
|
286
|
+
self.menu_columns.addAction(action)
|
|
287
|
+
|
|
288
|
+
# Make icons for viewed episodes
|
|
289
|
+
rect = QtCore.QSize(16,16)
|
|
290
|
+
buffer = QtGui.QPixmap(rect)
|
|
291
|
+
ep_icon_states = {'all': QStyle.State_On,
|
|
292
|
+
'part': QStyle.State_NoChange,
|
|
293
|
+
'none': QStyle.State_Off}
|
|
294
|
+
self.ep_icons = {}
|
|
295
|
+
for key, state in ep_icon_states.items():
|
|
296
|
+
buffer.fill(QtCore.Qt.transparent)
|
|
297
|
+
painter = QtGui.QPainter(buffer)
|
|
298
|
+
opt = QStyleOptionButton()
|
|
299
|
+
opt.state = state
|
|
300
|
+
self.style().drawPrimitive(QStyle.PE_IndicatorMenuCheckMark, opt, painter)
|
|
301
|
+
self.ep_icons[key] = QIcon(buffer)
|
|
302
|
+
painter.end()
|
|
303
|
+
|
|
178
304
|
menu_list = menubar.addMenu('&List')
|
|
179
305
|
menu_list.addAction(action_sync)
|
|
180
306
|
menu_list.addSeparator()
|
|
@@ -183,7 +309,7 @@ class Trackma(QtGui.QMainWindow):
|
|
|
183
309
|
menu_list.addSeparator()
|
|
184
310
|
menu_list.addAction(action_scan_library)
|
|
185
311
|
self.menu_mediatype = menubar.addMenu('&Mediatype')
|
|
186
|
-
self.mediatype_actiongroup =
|
|
312
|
+
self.mediatype_actiongroup = QActionGroup(self, exclusive=True)
|
|
187
313
|
self.mediatype_actiongroup.triggered.connect(self.s_mediatype)
|
|
188
314
|
menu_options = menubar.addMenu('&Options')
|
|
189
315
|
menu_options.addAction(action_reload)
|
|
@@ -194,94 +320,148 @@ class Trackma(QtGui.QMainWindow):
|
|
|
194
320
|
menu_help.addAction(action_about_qt)
|
|
195
321
|
|
|
196
322
|
# Build layout
|
|
197
|
-
main_layout =
|
|
198
|
-
top_hbox =
|
|
199
|
-
main_hbox =
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
self.
|
|
323
|
+
main_layout = QVBoxLayout()
|
|
324
|
+
top_hbox = QHBoxLayout()
|
|
325
|
+
main_hbox = QHBoxLayout()
|
|
326
|
+
self.list_box = QVBoxLayout()
|
|
327
|
+
filter_bar_box_layout = QHBoxLayout()
|
|
328
|
+
self.filter_bar_box = QWidget()
|
|
329
|
+
left_box = QFormLayout()
|
|
330
|
+
small_btns_hbox = QHBoxLayout()
|
|
331
|
+
|
|
332
|
+
self.show_title = QLabel('Trackma-qt')
|
|
203
333
|
show_title_font = QtGui.QFont()
|
|
204
334
|
show_title_font.setBold(True)
|
|
205
335
|
show_title_font.setPointSize(12)
|
|
206
336
|
self.show_title.setFont(show_title_font)
|
|
207
337
|
|
|
208
|
-
self.api_icon =
|
|
209
|
-
self.api_user =
|
|
338
|
+
self.api_icon = QLabel('icon')
|
|
339
|
+
self.api_user = QLabel('user')
|
|
210
340
|
|
|
211
341
|
top_hbox.addWidget(self.show_title, 1)
|
|
212
342
|
top_hbox.addWidget(self.api_icon)
|
|
213
343
|
top_hbox.addWidget(self.api_user)
|
|
214
344
|
|
|
215
|
-
self.notebook =
|
|
345
|
+
self.notebook = QTabWidget()
|
|
216
346
|
self.notebook.currentChanged.connect(self.s_tab_changed)
|
|
347
|
+
self.show_filter = QLineEdit()
|
|
348
|
+
self.show_filter.textChanged.connect(self.s_filter_changed)
|
|
349
|
+
filter_tooltip = ("General Search: All fields (columns) of each show will be matched against the search term."
|
|
350
|
+
"\nAdvanced Searching: A field can be specified by using its key followed by a colon"
|
|
351
|
+
" e.g. 'title:My_Show date_start:2016'."
|
|
352
|
+
"\n Any field may be specified multiple times to match terms in any order e.g. 'tag:Battle+Shounen tag:Ecchi'. "
|
|
353
|
+
"\n + and _ are replaced with spaces when searching specific fields."
|
|
354
|
+
"\n If colon is used after something that is not a column key, it will treat it as a general term."
|
|
355
|
+
"\n ALL terms not attached to a field will be combined into a single general search term"
|
|
356
|
+
"\n - 'My date_end:2016 Show' will match shows that have 'My Show' in any field and 2016 in the End Date field."
|
|
357
|
+
"\n Available field keys are: ")
|
|
358
|
+
colkeys = ', '.join(sorted(self.column_keys.keys()))
|
|
359
|
+
self.show_filter.setToolTip(filter_tooltip + colkeys + '.')
|
|
360
|
+
self.show_filter_invert = QCheckBox()
|
|
361
|
+
self.show_filter_invert.stateChanged.connect(self.s_filter_changed)
|
|
362
|
+
self.show_filter_casesens = QCheckBox()
|
|
363
|
+
self.show_filter_casesens.stateChanged.connect(self.s_filter_changed)
|
|
364
|
+
|
|
217
365
|
self.setMinimumSize(740, 480)
|
|
218
366
|
if self.config['remember_geometry']:
|
|
219
367
|
self.setGeometry(self.config['last_x'], self.config['last_y'],
|
|
220
368
|
self.config['last_width'], self.config['last_height'])
|
|
221
369
|
|
|
222
|
-
self.show_image =
|
|
370
|
+
self.show_image = QLabel('Trackma-qt')
|
|
223
371
|
self.show_image.setFixedHeight( 149 )
|
|
224
372
|
self.show_image.setFixedWidth( 100 )
|
|
225
373
|
self.show_image.setAlignment( QtCore.Qt.AlignCenter )
|
|
226
374
|
self.show_image.setStyleSheet("border: 1px solid #777;background-color:#999;text-align:center")
|
|
227
|
-
show_progress_label =
|
|
228
|
-
self.show_progress =
|
|
229
|
-
self.show_progress_bar =
|
|
230
|
-
self.show_progress_btn =
|
|
375
|
+
show_progress_label = QLabel('Progress')
|
|
376
|
+
self.show_progress = QSpinBox()
|
|
377
|
+
self.show_progress_bar = QProgressBar()
|
|
378
|
+
self.show_progress_btn = QPushButton('Update')
|
|
379
|
+
self.show_progress_btn.setToolTip('Set number of episodes watched to the value entered above')
|
|
231
380
|
self.show_progress_btn.clicked.connect(self.s_set_episode)
|
|
232
|
-
self.show_play_btn =
|
|
233
|
-
self.
|
|
234
|
-
self.
|
|
235
|
-
self.
|
|
236
|
-
self.
|
|
237
|
-
self.
|
|
238
|
-
self.
|
|
239
|
-
self.
|
|
240
|
-
self.
|
|
241
|
-
self.
|
|
242
|
-
|
|
243
|
-
self.
|
|
244
|
-
self.
|
|
381
|
+
self.show_play_btn = QToolButton()
|
|
382
|
+
self.show_play_btn.setIcon(getIcon('media-playback-start'))
|
|
383
|
+
self.show_play_btn.setToolTip('Play the next unwatched episode\nHold to play other episodes')
|
|
384
|
+
self.show_play_btn.clicked.connect(lambda: self.s_play(True))
|
|
385
|
+
self.show_play_btn.setMenu(self.menu_play)
|
|
386
|
+
self.show_inc_btn = QToolButton()
|
|
387
|
+
self.show_inc_btn.setIcon(getIcon('list-add'))
|
|
388
|
+
self.show_inc_btn.setShortcut('Ctrl+Right')
|
|
389
|
+
self.show_inc_btn.setToolTip('Increment number of episodes watched')
|
|
390
|
+
self.show_inc_btn.clicked.connect(self.s_plus_episode)
|
|
391
|
+
self.show_dec_btn = QToolButton()
|
|
392
|
+
self.show_dec_btn.setIcon(getIcon('list-remove'))
|
|
393
|
+
self.show_dec_btn.clicked.connect(self.s_rem_episode)
|
|
394
|
+
self.show_dec_btn.setShortcut('Ctrl+Left')
|
|
395
|
+
self.show_dec_btn.setToolTip('Decrement number of episodes watched')
|
|
396
|
+
show_score_label = QLabel('Score')
|
|
397
|
+
self.show_score = QDoubleSpinBox()
|
|
398
|
+
self.show_score_btn = QPushButton('Set')
|
|
399
|
+
self.show_score_btn.setToolTip('Set score to the value entered above')
|
|
245
400
|
self.show_score_btn.clicked.connect(self.s_set_score)
|
|
246
|
-
self.
|
|
401
|
+
self.show_tags_btn = QPushButton('Edit Tags...')
|
|
402
|
+
self.show_tags_btn.setToolTip('Open a dialog to edit your tags for this show')
|
|
403
|
+
self.show_tags_btn.clicked.connect(self.s_set_tags)
|
|
404
|
+
self.show_status = QComboBox()
|
|
405
|
+
self.show_status.setToolTip('Change your watching status of this show')
|
|
247
406
|
self.show_status.currentIndexChanged.connect(self.s_set_status)
|
|
248
407
|
|
|
408
|
+
small_btns_hbox.addWidget(self.show_dec_btn)
|
|
409
|
+
small_btns_hbox.addWidget(self.show_play_btn)
|
|
410
|
+
small_btns_hbox.addWidget(self.show_inc_btn)
|
|
411
|
+
small_btns_hbox.setAlignment( QtCore.Qt.AlignCenter )
|
|
412
|
+
|
|
249
413
|
left_box.addRow(self.show_image)
|
|
250
414
|
left_box.addRow(self.show_progress_bar)
|
|
415
|
+
left_box.addRow(small_btns_hbox)
|
|
251
416
|
left_box.addRow(show_progress_label, self.show_progress)
|
|
252
|
-
left_box.addRow(self.show_plus_btn)
|
|
253
|
-
left_box.addRow(self.show_rem_btn)
|
|
254
417
|
left_box.addRow(self.show_progress_btn)
|
|
255
|
-
left_box.addRow(self.show_play_btn)
|
|
256
|
-
left_box.addRow(self.show_play_next_btn)
|
|
257
418
|
left_box.addRow(show_score_label, self.show_score)
|
|
258
419
|
left_box.addRow(self.show_score_btn)
|
|
259
420
|
left_box.addRow(self.show_status)
|
|
421
|
+
left_box.addRow(self.show_tags_btn)
|
|
422
|
+
|
|
423
|
+
filter_bar_box_layout.addWidget(QLabel('Filter:'))
|
|
424
|
+
filter_bar_box_layout.addWidget(self.show_filter)
|
|
425
|
+
filter_bar_box_layout.addWidget(QLabel('Invert'))
|
|
426
|
+
filter_bar_box_layout.addWidget(self.show_filter_invert)
|
|
427
|
+
filter_bar_box_layout.addWidget(QLabel('Case Sensitive'))
|
|
428
|
+
filter_bar_box_layout.addWidget(self.show_filter_casesens)
|
|
429
|
+
self.filter_bar_box.setLayout(filter_bar_box_layout)
|
|
430
|
+
|
|
431
|
+
if self.config['filter_bar_position'] is FilterBar.PositionHidden:
|
|
432
|
+
self.list_box.addWidget(self.notebook)
|
|
433
|
+
self.filter_bar_box.hide()
|
|
434
|
+
elif self.config['filter_bar_position'] is FilterBar.PositionAboveLists:
|
|
435
|
+
self.list_box.addWidget(self.filter_bar_box)
|
|
436
|
+
self.list_box.addWidget(self.notebook)
|
|
437
|
+
elif self.config['filter_bar_position'] is FilterBar.PositionBelowLists:
|
|
438
|
+
self.list_box.addWidget(self.notebook)
|
|
439
|
+
self.list_box.addWidget(self.filter_bar_box)
|
|
260
440
|
|
|
261
441
|
main_hbox.addLayout(left_box)
|
|
262
|
-
main_hbox.
|
|
442
|
+
main_hbox.addLayout(self.list_box, 1)
|
|
263
443
|
|
|
264
444
|
main_layout.addLayout(top_hbox)
|
|
265
445
|
main_layout.addLayout(main_hbox)
|
|
266
446
|
|
|
267
|
-
self.main_widget =
|
|
447
|
+
self.main_widget = QWidget(self)
|
|
268
448
|
self.main_widget.setLayout(main_layout)
|
|
269
449
|
self.setCentralWidget(self.main_widget)
|
|
270
450
|
|
|
271
451
|
# Statusbar
|
|
272
|
-
self.status_text =
|
|
273
|
-
self.queue_text =
|
|
452
|
+
self.status_text = QLabel('Trackma-qt')
|
|
453
|
+
self.queue_text = QLabel('Unsynced items: N/A')
|
|
274
454
|
self.statusBar().addWidget(self.status_text, 1)
|
|
275
455
|
self.statusBar().addWidget(self.queue_text)
|
|
276
456
|
|
|
277
457
|
# Tray icon
|
|
278
|
-
tray_menu =
|
|
279
|
-
action_hide =
|
|
458
|
+
tray_menu = QMenu(self)
|
|
459
|
+
action_hide = QAction('Show/Hide', self)
|
|
280
460
|
action_hide.triggered.connect(self.s_hide)
|
|
281
461
|
tray_menu.addAction(action_hide)
|
|
282
462
|
tray_menu.addAction(action_quit)
|
|
283
463
|
|
|
284
|
-
self.tray =
|
|
464
|
+
self.tray = QSystemTrayIcon(self.windowIcon())
|
|
285
465
|
self.tray.setContextMenu(tray_menu)
|
|
286
466
|
self.tray.activated.connect(self.s_tray_clicked)
|
|
287
467
|
self._tray()
|
|
@@ -309,6 +489,11 @@ class Trackma(QtGui.QMainWindow):
|
|
|
309
489
|
if account:
|
|
310
490
|
self.account = account
|
|
311
491
|
|
|
492
|
+
self.api_configfile = utils.get_root_filename('ui-qt.%s.json' % self.account['api'])
|
|
493
|
+
self.api_config = utils.parse_config(self.api_configfile, utils.qt_per_api_defaults)
|
|
494
|
+
if self.config['columns_per_api']:
|
|
495
|
+
self.config['visible_columns'] = self.api_config['visible_columns']
|
|
496
|
+
|
|
312
497
|
self.show()
|
|
313
498
|
self._busy(False)
|
|
314
499
|
self.worker_call('reload', self.r_engine_loaded, account, mediatype)
|
|
@@ -329,10 +514,10 @@ class Trackma(QtGui.QMainWindow):
|
|
|
329
514
|
|
|
330
515
|
def error(self, msg):
|
|
331
516
|
self.status('Error: {}'.format(msg))
|
|
332
|
-
|
|
517
|
+
QMessageBox.critical(self, 'Error', msg, QMessageBox.Ok)
|
|
333
518
|
|
|
334
519
|
def fatal(self, msg):
|
|
335
|
-
|
|
520
|
+
QMessageBox.critical(self, 'Fatal Error', "Fatal Error! Reason:\n\n{0}".format(msg), QMessageBox.Ok)
|
|
336
521
|
self._busy()
|
|
337
522
|
self.finish = False
|
|
338
523
|
self.worker_call('unload', self.r_engine_unloaded)
|
|
@@ -347,6 +532,8 @@ class Trackma(QtGui.QMainWindow):
|
|
|
347
532
|
self._busy()
|
|
348
533
|
if self.config['remember_geometry']:
|
|
349
534
|
self._store_geometry()
|
|
535
|
+
if self.config['remember_columns']:
|
|
536
|
+
self._store_columnstate()
|
|
350
537
|
self.finish = True
|
|
351
538
|
self.worker_call('unload', self.r_engine_unloaded)
|
|
352
539
|
|
|
@@ -357,6 +544,17 @@ class Trackma(QtGui.QMainWindow):
|
|
|
357
544
|
self.config['last_height'] = self.height()
|
|
358
545
|
utils.save_config(self.config, self.configfile)
|
|
359
546
|
|
|
547
|
+
def _store_columnstate(self):
|
|
548
|
+
self.config['columns_state'] = dict()
|
|
549
|
+
for status in self.statuses_nums:
|
|
550
|
+
state = self.show_lists[status].horizontalHeader().saveState()
|
|
551
|
+
self.config['columns_state'][status] = base64.b64encode(state)
|
|
552
|
+
if self.config['columns_per_api']:
|
|
553
|
+
self.api_config['columns_state'] = self.config['columns_state']
|
|
554
|
+
utils.save_config(self.api_config, self.api_configfile)
|
|
555
|
+
else:
|
|
556
|
+
utils.save_config(self.config, self.configfile)
|
|
557
|
+
|
|
360
558
|
def _enable_widgets(self, enable):
|
|
361
559
|
self.notebook.setEnabled(enable)
|
|
362
560
|
self.menuBar().setEnabled(enable)
|
|
@@ -364,18 +562,47 @@ class Trackma(QtGui.QMainWindow):
|
|
|
364
562
|
if self.selected_show_id:
|
|
365
563
|
self.show_progress_btn.setEnabled(enable)
|
|
366
564
|
self.show_score_btn.setEnabled(enable)
|
|
565
|
+
if 'can_tag' in self.mediainfo and self.mediainfo.get('can_tag'):
|
|
566
|
+
self.show_tags_btn.setEnabled(enable)
|
|
567
|
+
else:
|
|
568
|
+
self.show_tags_btn.setEnabled(False)
|
|
367
569
|
self.show_play_btn.setEnabled(enable)
|
|
368
|
-
self.
|
|
570
|
+
self.show_inc_btn.setEnabled(enable)
|
|
571
|
+
self.show_dec_btn.setEnabled(enable)
|
|
369
572
|
self.show_status.setEnabled(enable)
|
|
370
573
|
|
|
371
574
|
def _update_queue_counter(self, queue):
|
|
372
575
|
self.queue_text.setText("Unsynced items: %d" % queue)
|
|
373
576
|
|
|
577
|
+
def _update_config(self):
|
|
578
|
+
self._tray()
|
|
579
|
+
self._filter_bar()
|
|
580
|
+
# TODO: Reload listviews?
|
|
581
|
+
|
|
374
582
|
def _tray(self):
|
|
375
583
|
if self.tray.isVisible() and not self.config['show_tray']:
|
|
376
584
|
self.tray.hide()
|
|
377
585
|
elif not self.tray.isVisible() and self.config['show_tray']:
|
|
378
586
|
self.tray.show()
|
|
587
|
+
if self.tray.isVisible():
|
|
588
|
+
if self.config['tray_api_icon']:
|
|
589
|
+
self.tray.setIcon( QIcon( utils.available_libs[self.account['api']][1] ) )
|
|
590
|
+
else:
|
|
591
|
+
self.tray.setIcon( self.windowIcon() )
|
|
592
|
+
|
|
593
|
+
def _filter_bar(self):
|
|
594
|
+
self.list_box.removeWidget(self.filter_bar_box)
|
|
595
|
+
self.list_box.removeWidget(self.notebook)
|
|
596
|
+
self.filter_bar_box.show()
|
|
597
|
+
if self.config['filter_bar_position'] is FilterBar.PositionHidden:
|
|
598
|
+
self.list_box.addWidget(self.notebook)
|
|
599
|
+
self.filter_bar_box.hide()
|
|
600
|
+
elif self.config['filter_bar_position'] is FilterBar.PositionAboveLists:
|
|
601
|
+
self.list_box.addWidget(self.filter_bar_box)
|
|
602
|
+
self.list_box.addWidget(self.notebook)
|
|
603
|
+
elif self.config['filter_bar_position'] is FilterBar.PositionBelowLists:
|
|
604
|
+
self.list_box.addWidget(self.notebook)
|
|
605
|
+
self.list_box.addWidget(self.filter_bar_box)
|
|
379
606
|
|
|
380
607
|
def _busy(self, wait=False):
|
|
381
608
|
if wait:
|
|
@@ -414,18 +641,35 @@ class Trackma(QtGui.QMainWindow):
|
|
|
414
641
|
library = self.worker.engine.library()
|
|
415
642
|
|
|
416
643
|
widget = self.show_lists[status]
|
|
417
|
-
|
|
644
|
+
|
|
418
645
|
widget.clear()
|
|
419
646
|
widget.setSortingEnabled(False)
|
|
420
647
|
widget.setRowCount(len(showlist))
|
|
421
|
-
widget.setColumnCount(len(
|
|
422
|
-
widget.setHorizontalHeaderLabels(
|
|
423
|
-
|
|
424
|
-
|
|
648
|
+
widget.setColumnCount(len(self.available_columns))
|
|
649
|
+
widget.setHorizontalHeaderLabels(self.available_columns)
|
|
650
|
+
|
|
651
|
+
# Hide invisible columns
|
|
652
|
+
for i, column in enumerate(self.available_columns):
|
|
653
|
+
if column not in self.config['visible_columns']:
|
|
654
|
+
widget.setColumnHidden(i, True)
|
|
655
|
+
|
|
656
|
+
if pyqt_version is 5:
|
|
657
|
+
widget.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch)
|
|
658
|
+
widget.horizontalHeader().setSectionResizeMode(2, QHeaderView.Fixed)
|
|
659
|
+
widget.horizontalHeader().setSectionResizeMode(3, QHeaderView.Fixed)
|
|
660
|
+
else:
|
|
661
|
+
widget.horizontalHeader().setResizeMode(1, QHeaderView.Stretch)
|
|
662
|
+
widget.horizontalHeader().setResizeMode(2, QHeaderView.Fixed)
|
|
663
|
+
widget.horizontalHeader().setResizeMode(3, QHeaderView.Fixed)
|
|
664
|
+
|
|
425
665
|
widget.horizontalHeader().resizeSection(2, 70)
|
|
426
666
|
widget.horizontalHeader().resizeSection(3, 55)
|
|
427
667
|
widget.horizontalHeader().resizeSection(4, 100)
|
|
428
668
|
|
|
669
|
+
if self.config['remember_columns'] and str(status) in self.config['columns_state']:
|
|
670
|
+
state = QtCore.QByteArray(base64.b64decode(self.config['columns_state'][str(status)]))
|
|
671
|
+
widget.horizontalHeader().restoreState(state)
|
|
672
|
+
|
|
429
673
|
i = 0
|
|
430
674
|
|
|
431
675
|
if status == self.worker.engine.mediainfo['status_start']:
|
|
@@ -446,52 +690,76 @@ class Trackma(QtGui.QMainWindow):
|
|
|
446
690
|
self.notebook.setTabText(tab_index, tab_name)
|
|
447
691
|
|
|
448
692
|
def _update_row(self, widget, row, show, altname, library_episodes=None, is_playing=False):
|
|
449
|
-
|
|
450
|
-
color = QtGui.QColor(150, 150, 250)
|
|
451
|
-
else:
|
|
452
|
-
color = self._get_color(show, library_episodes)
|
|
693
|
+
color = self._get_color(is_playing, show, library_episodes)
|
|
453
694
|
|
|
454
695
|
title_str = show['title']
|
|
455
696
|
if altname:
|
|
456
697
|
title_str += " [%s]" % altname
|
|
457
698
|
progress_str = "%d / %d" % (show['my_progress'], show['total'])
|
|
458
|
-
percent_widget = EpisodeBar()
|
|
699
|
+
percent_widget = EpisodeBar(self, self.config['colors'])
|
|
459
700
|
percent_widget.setRange(0, 100)
|
|
460
|
-
|
|
461
|
-
|
|
701
|
+
percent_widget.setBarStyle(self.config['episodebar_style'], self.config['episodebar_text'])
|
|
702
|
+
tooltip = "Watched: %d<br>" % show['my_progress']
|
|
462
703
|
|
|
704
|
+
if show['total'] > 0:
|
|
463
705
|
percent_widget.setMaximum(show['total'])
|
|
464
|
-
|
|
706
|
+
else:
|
|
707
|
+
percent_widget.setMaximum((int(show['my_progress']/12)+1)*12) # Round up to the next cour
|
|
708
|
+
percent_widget.setValue(show['my_progress'])
|
|
465
709
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
if library_episodes:
|
|
471
|
-
eps = library_episodes.keys()
|
|
472
|
-
tooltip += "Latest available: %d<br>" % max(eps)
|
|
473
|
-
percent_widget.setEpisodes(eps)
|
|
710
|
+
aired_eps = utils.estimate_aired_episodes(show)
|
|
711
|
+
if aired_eps:
|
|
712
|
+
percent_widget.setSubValue(aired_eps)
|
|
713
|
+
tooltip += "Aired (estimated): %d<br>" % aired_eps
|
|
474
714
|
|
|
475
|
-
|
|
476
|
-
|
|
715
|
+
if library_episodes:
|
|
716
|
+
eps = library_episodes.keys()
|
|
717
|
+
tooltip += "Latest available: %d<br>" % max(eps)
|
|
718
|
+
percent_widget.setEpisodes(eps)
|
|
719
|
+
|
|
720
|
+
tooltip += "Total: %d" % show['total']
|
|
721
|
+
percent_widget.setToolTip(tooltip)
|
|
722
|
+
percent = percent_widget.value() * 100 / percent_widget.maximum()
|
|
477
723
|
|
|
478
724
|
widget.setRowHeight(row, QtGui.QFontMetrics(widget.font()).height() + 2);
|
|
479
725
|
widget.setItem(row, 0, ShowItem( str(show['id']), color ))
|
|
480
726
|
widget.setItem(row, 1, ShowItem( title_str, color ))
|
|
481
727
|
widget.setItem(row, 2, ShowItemNum( show['my_progress'], progress_str, color ))
|
|
482
728
|
widget.setItem(row, 3, ShowItemNum( show['my_score'], str(show['my_score']), color ))
|
|
729
|
+
widget.setItem(row, 4, ShowItemNum( percent, str(percent), color ))
|
|
483
730
|
widget.setCellWidget(row, 4, percent_widget )
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
731
|
+
if 'date_next_ep' in self.mediainfo \
|
|
732
|
+
and self.mediainfo['date_next_ep'] \
|
|
733
|
+
and 'next_ep_time' in show \
|
|
734
|
+
and dateutil_available:
|
|
735
|
+
next_ep_dt = dateutil.parser.parse(show['next_ep_time'])
|
|
736
|
+
delta = next_ep_dt - datetime.datetime.now(dateutil.tz.tzutc())
|
|
737
|
+
widget.setItem(row, 5, ShowItem( "%i days, %02d hrs." % (delta.days, delta.seconds/3600), color, QtCore.Qt.AlignHCenter ))
|
|
738
|
+
else:
|
|
739
|
+
widget.setItem(row, 5, ShowItem( "-", color, QtCore.Qt.AlignHCenter ))
|
|
740
|
+
widget.setItem(row, 6, ShowItemDate( show['start_date'], color ))
|
|
741
|
+
widget.setItem(row, 7, ShowItemDate( show['end_date'], color ))
|
|
742
|
+
widget.setItem(row, 8, ShowItemDate( show['my_start_date'], color ))
|
|
743
|
+
widget.setItem(row, 9, ShowItemDate( show['my_finish_date'], color ))
|
|
744
|
+
try:
|
|
745
|
+
tag_str = show['my_tags']
|
|
746
|
+
if not tag_str:
|
|
747
|
+
tag_str = '-'
|
|
748
|
+
except:
|
|
749
|
+
tag_str = '-'
|
|
750
|
+
widget.setItem(row, 10, ShowItem( tag_str, color ))
|
|
751
|
+
|
|
752
|
+
def _get_color(self, is_playing, show, eps):
|
|
753
|
+
if is_playing:
|
|
754
|
+
return getColor(self.config['colors']['is_playing'])
|
|
755
|
+
elif show.get('queued'):
|
|
756
|
+
return getColor(self.config['colors']['is_queued'])
|
|
489
757
|
elif eps and max(eps) > show['my_progress']:
|
|
490
|
-
return
|
|
758
|
+
return getColor(self.config['colors']['new_episode'])
|
|
491
759
|
elif show['status'] == utils.STATUS_AIRING:
|
|
492
|
-
return
|
|
760
|
+
return getColor(self.config['colors']['is_airing'])
|
|
493
761
|
elif show['status'] == utils.STATUS_NOTYET:
|
|
494
|
-
return
|
|
762
|
+
return getColor(self.config['colors']['not_aired'])
|
|
495
763
|
else:
|
|
496
764
|
return None
|
|
497
765
|
|
|
@@ -518,8 +786,10 @@ class Trackma(QtGui.QMainWindow):
|
|
|
518
786
|
self.show_status.setEnabled(False)
|
|
519
787
|
self.show_progress_btn.setEnabled(False)
|
|
520
788
|
self.show_score_btn.setEnabled(False)
|
|
789
|
+
self.show_tags_btn.setEnabled(False)
|
|
521
790
|
self.show_play_btn.setEnabled(False)
|
|
522
|
-
self.
|
|
791
|
+
self.show_inc_btn.setEnabled(False)
|
|
792
|
+
self.show_dec_btn.setEnabled(False)
|
|
523
793
|
return
|
|
524
794
|
|
|
525
795
|
# Block signals
|
|
@@ -529,8 +799,11 @@ class Trackma(QtGui.QMainWindow):
|
|
|
529
799
|
if show['total']:
|
|
530
800
|
self.show_progress.setMaximum(show['total'])
|
|
531
801
|
self.show_progress_bar.setMaximum(show['total'])
|
|
802
|
+
# Regenerate Play Episode Menu
|
|
803
|
+
self.generate_episode_menus(self.menu_play, show['total'], show['my_progress'])
|
|
532
804
|
else:
|
|
533
|
-
self.show_progress.setMaximum(
|
|
805
|
+
self.show_progress.setMaximum(utils.estimate_aired_episodes(show))
|
|
806
|
+
self.generate_episode_menus(self.menu_play, utils.estimate_aired_episodes(show),show['my_progress'])
|
|
534
807
|
|
|
535
808
|
# Update information
|
|
536
809
|
self.show_title.setText(show['title'])
|
|
@@ -543,10 +816,11 @@ class Trackma(QtGui.QMainWindow):
|
|
|
543
816
|
self.show_score.setEnabled(True)
|
|
544
817
|
self.show_progress_btn.setEnabled(True)
|
|
545
818
|
self.show_score_btn.setEnabled(True)
|
|
546
|
-
self.
|
|
547
|
-
|
|
819
|
+
if 'can_tag' in self.mediainfo and self.mediainfo.get('can_tag'):
|
|
820
|
+
self.show_tags_btn.setEnabled(True)
|
|
821
|
+
self.show_inc_btn.setEnabled(True)
|
|
822
|
+
self.show_dec_btn.setEnabled(True)
|
|
548
823
|
self.show_play_btn.setEnabled(True)
|
|
549
|
-
self.show_play_next_btn.setEnabled(True)
|
|
550
824
|
self.show_status.setEnabled(True)
|
|
551
825
|
|
|
552
826
|
# Download image or use cache
|
|
@@ -555,7 +829,7 @@ class Trackma(QtGui.QMainWindow):
|
|
|
555
829
|
self.image_worker.cancel()
|
|
556
830
|
|
|
557
831
|
utils.make_dir('cache')
|
|
558
|
-
filename = utils.get_filename('cache', "%s.jpg" % show['id'])
|
|
832
|
+
filename = utils.get_filename('cache', "%s_%s_%s.jpg" % (self.api_info['shortname'], self.api_info['mediatype'], show['id']))
|
|
559
833
|
|
|
560
834
|
if os.path.isfile(filename):
|
|
561
835
|
self.s_show_image(filename)
|
|
@@ -577,6 +851,147 @@ class Trackma(QtGui.QMainWindow):
|
|
|
577
851
|
# Unblock signals
|
|
578
852
|
self.show_status.blockSignals(False)
|
|
579
853
|
|
|
854
|
+
def _filter_check_row(self, table, row, expression, case_sensitive=False):
|
|
855
|
+
# Determine if a show matches a filter. True -> match -> do not hide
|
|
856
|
+
# Advanced search: Separate the expression into specific field terms, fail if any are not met
|
|
857
|
+
if ':' in expression:
|
|
858
|
+
exprs = expression.split(' ')
|
|
859
|
+
expr_list = []
|
|
860
|
+
for expr in exprs:
|
|
861
|
+
if ':' in expr:
|
|
862
|
+
expr_terms = expr.split(':',1)
|
|
863
|
+
if expr_terms[0] in self.column_keys:
|
|
864
|
+
col = self.column_keys[expr_terms[0]]
|
|
865
|
+
sub_expr = expr_terms[1].replace('_', ' ').replace('+', ' ')
|
|
866
|
+
item = table.item(row, col)
|
|
867
|
+
if case_sensitive:
|
|
868
|
+
if not sub_expr in unicode(item.text()):
|
|
869
|
+
return False
|
|
870
|
+
else:
|
|
871
|
+
if not sub_expr.lower() in unicode(item.text()).lower():
|
|
872
|
+
return False
|
|
873
|
+
else: # If it's not a field key, let it be a regular search term
|
|
874
|
+
expr_list.append(expr)
|
|
875
|
+
else:
|
|
876
|
+
expr_list.append(expr)
|
|
877
|
+
expression = ' '.join(expr_list)
|
|
878
|
+
|
|
879
|
+
# General case: if any fields match the remaining expression, success.
|
|
880
|
+
for col in range(table.columnCount()):
|
|
881
|
+
item = table.item(row, col)
|
|
882
|
+
itemtext = unicode(item.text())
|
|
883
|
+
if case_sensitive:
|
|
884
|
+
if expression in itemtext:
|
|
885
|
+
return True
|
|
886
|
+
else:
|
|
887
|
+
if expression.lower() in itemtext.lower():
|
|
888
|
+
return True
|
|
889
|
+
return False
|
|
890
|
+
|
|
891
|
+
def generate_episode_menus(self, menu, max_eps=1, watched_eps=0):
|
|
892
|
+
bp_top = 5 # No more than this many submenus/episodes in the root menu
|
|
893
|
+
bp_mid = 10 # No more than this many submenus in submenus
|
|
894
|
+
bp_btm = 13 # No more than this many episodes in the submenus
|
|
895
|
+
# The number of episodes where we ditch the submenus entirely since Qt doesn't deserve this abuse
|
|
896
|
+
breakpoint_no_menus = bp_top * bp_btm * bp_mid * bp_mid
|
|
897
|
+
|
|
898
|
+
menu.clear()
|
|
899
|
+
# Make basic actions
|
|
900
|
+
action_play_next = QAction(getIcon('media-skip-forward'), 'Play &Next Episode', self)
|
|
901
|
+
action_play_next.triggered.connect(lambda: self.s_play(True))
|
|
902
|
+
action_play_last = QAction(getIcon('view-refresh'), 'Play Last Watched Ep (#%d)' % watched_eps, self)
|
|
903
|
+
action_play_last.triggered.connect(lambda: self.s_play(False))
|
|
904
|
+
action_play_dialog = QAction('Play Episode...', self)
|
|
905
|
+
action_play_dialog.setStatusTip('Select an episode to play.')
|
|
906
|
+
action_play_dialog.triggered.connect(self.s_play_number)
|
|
907
|
+
|
|
908
|
+
menu.addAction(action_play_next)
|
|
909
|
+
menu.addAction(action_play_last)
|
|
910
|
+
|
|
911
|
+
if max_eps < 1 or max_eps > breakpoint_no_menus:
|
|
912
|
+
menu.addAction(action_play_dialog)
|
|
913
|
+
return menu
|
|
914
|
+
menu.addSeparator()
|
|
915
|
+
|
|
916
|
+
ep_actions = []
|
|
917
|
+
for ep in range(1, max_eps+1):
|
|
918
|
+
action = QAction('Ep. %d' % ep, self)
|
|
919
|
+
action.triggered.connect(self.s_play_ep_number(action, ep))
|
|
920
|
+
if ep <= watched_eps:
|
|
921
|
+
action.setIcon(self.ep_icons['all'])
|
|
922
|
+
else:
|
|
923
|
+
action.setIcon(self.ep_icons['none'])
|
|
924
|
+
ep_actions.append(action)
|
|
925
|
+
|
|
926
|
+
if max_eps <= bp_top:
|
|
927
|
+
# Just put the eps in the root menu
|
|
928
|
+
for action in ep_actions:
|
|
929
|
+
menu.addAction(action)
|
|
930
|
+
|
|
931
|
+
else:
|
|
932
|
+
# We need to go deeper. For now, put all the episodes into bottom-level submenus.
|
|
933
|
+
self.play_ep_submenus = [] # I don't like this scoping. If you find a way to transfer ownership of the submenu to the menu feel free to fix this.
|
|
934
|
+
current_actions = bp_btm + 1 # A bit hacky but avoids a special case for the first submenu
|
|
935
|
+
for action in ep_actions:
|
|
936
|
+
if current_actions >= bp_btm:
|
|
937
|
+
current_actions = 0
|
|
938
|
+
l = len(self.play_ep_submenus)
|
|
939
|
+
self.play_ep_submenus.append(QMenu('Episodes %d-%d:' % (l*bp_btm + 1, min((l+1)*bp_btm, max_eps))))
|
|
940
|
+
if watched_eps > min((l+1)*bp_btm, max_eps):
|
|
941
|
+
self.play_ep_submenus[-1].setIcon(self.ep_icons['all'])
|
|
942
|
+
elif watched_eps > l*bp_btm:
|
|
943
|
+
self.play_ep_submenus[-1].setIcon(self.ep_icons['part'])
|
|
944
|
+
else:
|
|
945
|
+
self.play_ep_submenus[-1].setIcon(self.ep_icons['none'])
|
|
946
|
+
self.play_ep_submenus[-1].addAction(action)
|
|
947
|
+
current_actions += 1
|
|
948
|
+
|
|
949
|
+
# Now to put the bottom level menus into other things
|
|
950
|
+
if len(self.play_ep_submenus) <= bp_top: # Straight into the root menu, easy!
|
|
951
|
+
for submenu in self.play_ep_submenus:
|
|
952
|
+
menu.addMenu(submenu)
|
|
953
|
+
else: # For now, put them into another level of submenus
|
|
954
|
+
self.play_ep_sub2menus = []
|
|
955
|
+
current_menus = bp_mid + 1
|
|
956
|
+
for s in self.play_ep_submenus:
|
|
957
|
+
if current_menus >= bp_mid:
|
|
958
|
+
current_menus = 0
|
|
959
|
+
l = len(self.play_ep_sub2menus)
|
|
960
|
+
self.play_ep_sub2menus.append(QMenu('Episodes %d-%d:' % (l*bp_btm*bp_mid + 1, min((l+1)*bp_btm*bp_mid, max_eps))))
|
|
961
|
+
self.play_ep_sub2menus[-1].addMenu(s)
|
|
962
|
+
if watched_eps > min((l+1)*bp_btm*bp_mid, max_eps):
|
|
963
|
+
self.play_ep_sub2menus[-1].setIcon(self.ep_icons['all'])
|
|
964
|
+
elif watched_eps > l*bp_btm*bp_mid:
|
|
965
|
+
self.play_ep_sub2menus[-1].setIcon(self.ep_icons['part'])
|
|
966
|
+
else:
|
|
967
|
+
self.play_ep_sub2menus[-1].setIcon(self.ep_icons['none'])
|
|
968
|
+
current_menus += 1
|
|
969
|
+
|
|
970
|
+
if len(self.play_ep_sub2menus) <= bp_top:
|
|
971
|
+
for submenu in self.play_ep_sub2menus:
|
|
972
|
+
menu.addMenu(submenu)
|
|
973
|
+
else:
|
|
974
|
+
# I seriously hope this additional level is not needed, but maybe someone will want to set smaller breakpoints.
|
|
975
|
+
self.play_ep_sub3menus = []
|
|
976
|
+
current_menus = bp_mid + 1
|
|
977
|
+
for s in self.play_ep_sub2menus:
|
|
978
|
+
if current_menus >= bp_mid:
|
|
979
|
+
current_menus = 0
|
|
980
|
+
l = len(self.play_ep_sub3menus)
|
|
981
|
+
self.play_ep_sub3menus.append(QMenu('Episodes %d-%d:' % (l*bp_btm*bp_mid*bp_mid + 1, min((l+1)*bp_btm*bp_mid*bp_mid, max_eps))))
|
|
982
|
+
self.play_ep_sub3menus[-1].addMenu(s)
|
|
983
|
+
if watched_eps > min((l+1)*bp_btm*bp_mid*bp_mid, max_eps):
|
|
984
|
+
self.play_ep_sub3menus[-1].setIcon(self.ep_icons['all'])
|
|
985
|
+
elif watched_eps > l*bp_btm*bp_mid*bp_mid:
|
|
986
|
+
self.play_ep_sub3menus[-1].setIcon(self.ep_icons['part'])
|
|
987
|
+
else:
|
|
988
|
+
self.play_ep_sub3menus[-1].setIcon(self.ep_icons['none'])
|
|
989
|
+
current_menus += 1
|
|
990
|
+
# No more levels, our sanity check earlier ensured that.
|
|
991
|
+
for submenu in self.play_ep_sub3menus:
|
|
992
|
+
menu.addMenu(submenu)
|
|
993
|
+
return menu
|
|
994
|
+
|
|
580
995
|
### Slots
|
|
581
996
|
def s_hide(self):
|
|
582
997
|
if self.isVisible():
|
|
@@ -590,7 +1005,7 @@ class Trackma(QtGui.QMainWindow):
|
|
|
590
1005
|
self.show()
|
|
591
1006
|
|
|
592
1007
|
def s_tray_clicked(self, reason):
|
|
593
|
-
if reason ==
|
|
1008
|
+
if reason == QSystemTrayIcon.Trigger:
|
|
594
1009
|
self.s_hide()
|
|
595
1010
|
|
|
596
1011
|
def s_busy(self):
|
|
@@ -615,7 +1030,7 @@ class Trackma(QtGui.QMainWindow):
|
|
|
615
1030
|
def s_download_image(self):
|
|
616
1031
|
show = self.worker.engine.get_show_info(self.selected_show_id)
|
|
617
1032
|
self.show_image.setText('Downloading...')
|
|
618
|
-
filename = utils.get_filename('cache', "%s.jpg" % show['id'])
|
|
1033
|
+
filename = utils.get_filename('cache', "%s_%s_%s.jpg" % (self.api_info['shortname'], self.api_info['mediatype'], show['id']))
|
|
619
1034
|
|
|
620
1035
|
self.image_worker = Image_Worker(show.get('image_thumb') or show['image'], filename, (100, 140))
|
|
621
1036
|
self.image_worker.finished.connect(self.s_show_image)
|
|
@@ -625,6 +1040,37 @@ class Trackma(QtGui.QMainWindow):
|
|
|
625
1040
|
item = self.notebook.currentWidget().currentItem()
|
|
626
1041
|
if item:
|
|
627
1042
|
self.s_show_selected(item)
|
|
1043
|
+
self.s_filter_changed() # Refresh filter
|
|
1044
|
+
|
|
1045
|
+
def s_filter_changed(self):
|
|
1046
|
+
tabs = []
|
|
1047
|
+
if self.config['filter_global']:
|
|
1048
|
+
tabs = range(len(self.notebook))
|
|
1049
|
+
else:
|
|
1050
|
+
tabs = [self.notebook.currentIndex()]
|
|
1051
|
+
expr = unicode(self.show_filter.text())
|
|
1052
|
+
casesens = self.show_filter_casesens.isChecked()
|
|
1053
|
+
for tab_index in tabs:
|
|
1054
|
+
table = self.notebook.widget(tab_index)
|
|
1055
|
+
shown = 0
|
|
1056
|
+
total = 0
|
|
1057
|
+
for row in range(table.rowCount()):
|
|
1058
|
+
if not expr:
|
|
1059
|
+
table.setRowHidden(row, False)
|
|
1060
|
+
elif self.show_filter_invert.isChecked():
|
|
1061
|
+
table.setRowHidden(row, self._filter_check_row(table, row, expr, casesens))
|
|
1062
|
+
else:
|
|
1063
|
+
table.setRowHidden(row, not self._filter_check_row(table, row, expr, casesens))
|
|
1064
|
+
if not table.isRowHidden(row):
|
|
1065
|
+
shown += 1
|
|
1066
|
+
total += 1
|
|
1067
|
+
# Update tab name with matches out of total
|
|
1068
|
+
status = self.statuses_nums[tab_index]
|
|
1069
|
+
if expr:
|
|
1070
|
+
tab_name = "%s (%d/%d)" % (self.statuses_names[status], shown, total)
|
|
1071
|
+
else:
|
|
1072
|
+
tab_name = "%s (%d)" % (self.statuses_names[status], total) # Filter disabled
|
|
1073
|
+
self.notebook.setTabText(tab_index, tab_name)
|
|
628
1074
|
|
|
629
1075
|
def s_plus_episode(self):
|
|
630
1076
|
self._busy(True)
|
|
@@ -648,24 +1094,60 @@ class Trackma(QtGui.QMainWindow):
|
|
|
648
1094
|
self._busy(True)
|
|
649
1095
|
self.worker_call('set_status', self.r_generic, self.selected_show_id, self.statuses_nums[index])
|
|
650
1096
|
|
|
651
|
-
def
|
|
1097
|
+
def s_set_tags(self):
|
|
1098
|
+
show = self.worker.engine.get_show_info(self.selected_show_id)
|
|
1099
|
+
if show['my_tags']:
|
|
1100
|
+
tags = show['my_tags']
|
|
1101
|
+
else:
|
|
1102
|
+
tags = ''
|
|
1103
|
+
tags, ok = QInputDialog.getText(self, 'Edit Tags',
|
|
1104
|
+
'Enter desired tags (comma separated)',
|
|
1105
|
+
text=tags)
|
|
1106
|
+
if ok:
|
|
1107
|
+
self.s_edit_tags(show, tags)
|
|
1108
|
+
|
|
1109
|
+
def s_edit_tags(self, show, tags):
|
|
1110
|
+
self._busy(True)
|
|
1111
|
+
self.worker_call('set_tags', self.r_generic, show['id'], tags)
|
|
1112
|
+
|
|
1113
|
+
def s_play(self, play_next, episode=0):
|
|
652
1114
|
if self.selected_show_id:
|
|
653
1115
|
show = self.worker.engine.get_show_info(self.selected_show_id)
|
|
654
1116
|
|
|
655
|
-
episode = 0 # Engine plays next unwatched episode
|
|
656
|
-
if not play_next:
|
|
1117
|
+
#episode = 0 # Engine plays next unwatched episode
|
|
1118
|
+
if not play_next and not episode:
|
|
657
1119
|
episode = self.show_progress.value()
|
|
658
1120
|
|
|
659
|
-
self._busy(
|
|
1121
|
+
self._busy(True)
|
|
660
1122
|
self.worker_call('play_episode', self.r_generic, show, episode)
|
|
661
1123
|
|
|
1124
|
+
def s_play_random(self):
|
|
1125
|
+
self._busy(True)
|
|
1126
|
+
self.worker_call('play_random', self.r_generic)
|
|
1127
|
+
|
|
1128
|
+
def s_play_number(self):
|
|
1129
|
+
show = self.worker.engine.get_show_info(self.selected_show_id)
|
|
1130
|
+
ep_default = 1
|
|
1131
|
+
ep_min = 1
|
|
1132
|
+
ep_max = utils.estimate_aired_episodes(show)
|
|
1133
|
+
if ep_max is None:
|
|
1134
|
+
ep_max = max(show['total'],1)
|
|
1135
|
+
episode, ok = QInputDialog.getInt(self, 'Play Episode',
|
|
1136
|
+
'Enter an episode number of %s to play:' % show['title'],
|
|
1137
|
+
ep_default, ep_min, ep_max)
|
|
1138
|
+
if ok:
|
|
1139
|
+
self.s_play(False, episode)
|
|
1140
|
+
|
|
1141
|
+
def s_play_ep_number(self, action, number):
|
|
1142
|
+
return lambda: [action.setIcon(self.ep_icons['part']), self.s_play(False, number)]
|
|
1143
|
+
|
|
662
1144
|
def s_delete(self):
|
|
663
1145
|
show = self.worker.engine.get_show_info(self.selected_show_id)
|
|
664
|
-
reply =
|
|
1146
|
+
reply = QMessageBox.question(self, 'Confirmation',
|
|
665
1147
|
'Are you sure you want to delete %s?' % show['title'],
|
|
666
|
-
|
|
1148
|
+
QMessageBox.Yes, QMessageBox.No)
|
|
667
1149
|
|
|
668
|
-
if reply ==
|
|
1150
|
+
if reply == QMessageBox.Yes:
|
|
669
1151
|
self.worker_call('delete_show', self.r_generic, show)
|
|
670
1152
|
|
|
671
1153
|
def s_scan_library(self):
|
|
@@ -676,7 +1158,7 @@ class Trackma(QtGui.QMainWindow):
|
|
|
676
1158
|
show = self.worker.engine.get_show_info(self.selected_show_id)
|
|
677
1159
|
current_altname = self.worker.engine.altname(self.selected_show_id)
|
|
678
1160
|
|
|
679
|
-
new_altname, ok =
|
|
1161
|
+
new_altname, ok = QInputDialog.getText(self, 'Alternative title',
|
|
680
1162
|
'Set the new alternative title for %s (blank to remove):' % show['title'],
|
|
681
1163
|
text=current_altname)
|
|
682
1164
|
|
|
@@ -688,13 +1170,13 @@ class Trackma(QtGui.QMainWindow):
|
|
|
688
1170
|
queue = self.worker.engine.get_queue()
|
|
689
1171
|
|
|
690
1172
|
if queue:
|
|
691
|
-
reply =
|
|
1173
|
+
reply = QMessageBox.question(self, 'Confirmation',
|
|
692
1174
|
'There are %d unsynced changes. Do you want to send them first? (Choosing No will discard them!)' % len(queue),
|
|
693
|
-
|
|
1175
|
+
QMessageBox.Yes, QMessageBox.No, QMessageBox.Cancel)
|
|
694
1176
|
|
|
695
|
-
if reply ==
|
|
1177
|
+
if reply == QMessageBox.Yes:
|
|
696
1178
|
self.s_send(True)
|
|
697
|
-
elif reply ==
|
|
1179
|
+
elif reply == QMessageBox.No:
|
|
698
1180
|
self._busy(True)
|
|
699
1181
|
self.worker_call('list_download', self.r_list_retrieved)
|
|
700
1182
|
else:
|
|
@@ -726,22 +1208,25 @@ class Trackma(QtGui.QMainWindow):
|
|
|
726
1208
|
self.detailswindow.show()
|
|
727
1209
|
|
|
728
1210
|
def s_add(self):
|
|
729
|
-
|
|
1211
|
+
page = self.notebook.currentIndex()
|
|
1212
|
+
current_status = self.statuses_nums[page]
|
|
1213
|
+
|
|
1214
|
+
self.addwindow = AddDialog(None, self.worker, current_status)
|
|
730
1215
|
self.addwindow.setModal(True)
|
|
731
1216
|
self.addwindow.show()
|
|
732
1217
|
|
|
733
1218
|
def s_mediatype(self, action):
|
|
734
|
-
index = action.data()
|
|
1219
|
+
index = action.data()
|
|
735
1220
|
mediatype = self.api_info['supported_mediatypes'][index]
|
|
736
1221
|
self.reload(None, mediatype)
|
|
737
1222
|
|
|
738
1223
|
def s_settings(self):
|
|
739
1224
|
dialog = SettingsDialog(None, self.worker, self.config, self.configfile)
|
|
740
|
-
dialog.saved.connect(self.
|
|
1225
|
+
dialog.saved.connect(self._update_config)
|
|
741
1226
|
dialog.exec_()
|
|
742
1227
|
|
|
743
1228
|
def s_about(self):
|
|
744
|
-
|
|
1229
|
+
QMessageBox.about(self, 'About Trackma-qt %s' % utils.VERSION,
|
|
745
1230
|
'<p><b>About Trackma-qt %s</b></p><p>Trackma is an open source client for media tracking websites.</p>'
|
|
746
1231
|
'<p>This program is licensed under the GPLv3, for more information read COPYING file.</p>'
|
|
747
1232
|
'<p>Thanks to all contributors. To see all contributors see AUTHORS file.</p>'
|
|
@@ -749,8 +1234,31 @@ class Trackma(QtGui.QMainWindow):
|
|
|
749
1234
|
'<p><a href="http://github.com/z411/trackma">http://github.com/z411/trackma</a></p>' % utils.VERSION)
|
|
750
1235
|
|
|
751
1236
|
def s_about_qt(self):
|
|
752
|
-
|
|
1237
|
+
QMessageBox.aboutQt(self, 'About Qt')
|
|
1238
|
+
|
|
1239
|
+
def s_show_menu_columns(self, pos):
|
|
1240
|
+
globalPos = self.sender().mapToGlobal(pos)
|
|
1241
|
+
globalPos += QtCore.QPoint(3, 3)
|
|
1242
|
+
self.menu_columns.exec_(globalPos)
|
|
753
1243
|
|
|
1244
|
+
def s_toggle_column(self, w):
|
|
1245
|
+
(column_name, visible) = (w.text(), w.isChecked())
|
|
1246
|
+
index = self.available_columns.index(column_name)
|
|
1247
|
+
|
|
1248
|
+
if visible:
|
|
1249
|
+
if column_name not in self.config['visible_columns']:
|
|
1250
|
+
self.config['visible_columns'].append(str(column_name))
|
|
1251
|
+
else:
|
|
1252
|
+
if column_name in self.config['visible_columns']:
|
|
1253
|
+
self.config['visible_columns'].remove(column_name)
|
|
1254
|
+
|
|
1255
|
+
utils.save_config(self.config, self.configfile)
|
|
1256
|
+
if self.config['columns_per_api']:
|
|
1257
|
+
self.api_config['visible_columns'] = self.config['visible_columns']
|
|
1258
|
+
utils.save_config(self.api_config, self.api_configfile)
|
|
1259
|
+
|
|
1260
|
+
for showlist in self.show_lists.itervalues():
|
|
1261
|
+
showlist.setColumnHidden(index, not visible)
|
|
754
1262
|
|
|
755
1263
|
### Worker slots
|
|
756
1264
|
def ws_changed_show(self, show, is_playing=False, episode=None, altname=None):
|
|
@@ -776,7 +1284,7 @@ class Trackma(QtGui.QMainWindow):
|
|
|
776
1284
|
if is_playing and self.config['show_tray'] and self.config['notifications']:
|
|
777
1285
|
if episode == (show['my_progress'] + 1):
|
|
778
1286
|
delay = self.worker.engine.get_config('tracker_update_wait_s')
|
|
779
|
-
self.tray.showMessage('Trackma Tracker', "Playing %s %s. Will update in %d
|
|
1287
|
+
self.tray.showMessage('Trackma Tracker', "Playing %s %s. Will update in %d seconds." % (show['title'], episode, delay))
|
|
780
1288
|
|
|
781
1289
|
def ws_changed_list(self, show, old_status=None):
|
|
782
1290
|
# Rebuild both new and old (if any) lists
|
|
@@ -786,16 +1294,18 @@ class Trackma(QtGui.QMainWindow):
|
|
|
786
1294
|
|
|
787
1295
|
# Set notebook to the new page
|
|
788
1296
|
self.notebook.setCurrentIndex( self.statuses_nums.index(show['my_status']) )
|
|
1297
|
+
# Refresh filter
|
|
1298
|
+
self.s_filter_changed()
|
|
789
1299
|
|
|
790
1300
|
def ws_changed_queue(self, queue):
|
|
791
1301
|
self._update_queue_counter(queue)
|
|
792
1302
|
|
|
793
1303
|
def ws_prompt_update(self, show, episode):
|
|
794
|
-
reply =
|
|
1304
|
+
reply = QMessageBox.question(self, 'Message',
|
|
795
1305
|
'Do you want to update %s to %d?' % (show['title'], episode),
|
|
796
|
-
|
|
1306
|
+
QMessageBox.Yes, QMessageBox.No)
|
|
797
1307
|
|
|
798
|
-
if reply ==
|
|
1308
|
+
if reply == QMessageBox.Yes:
|
|
799
1309
|
self.worker_call('set_episode', self.r_generic, show['id'], episode)
|
|
800
1310
|
|
|
801
1311
|
### Responses from the engine thread
|
|
@@ -839,12 +1349,19 @@ class Trackma(QtGui.QMainWindow):
|
|
|
839
1349
|
for status in self.statuses_nums:
|
|
840
1350
|
name = self.statuses_names[status]
|
|
841
1351
|
|
|
842
|
-
self.show_lists[status] =
|
|
843
|
-
self.show_lists[status].
|
|
1352
|
+
self.show_lists[status] = ShowsTableWidget()
|
|
1353
|
+
self.show_lists[status].context_menu = self.menu_show_context
|
|
1354
|
+
self.show_lists[status].setSelectionMode(QAbstractItemView.SingleSelection)
|
|
844
1355
|
#self.show_lists[status].setFocusPolicy(QtCore.Qt.NoFocus)
|
|
845
|
-
self.show_lists[status].setSelectionBehavior(
|
|
846
|
-
self.show_lists[status].setEditTriggers(
|
|
1356
|
+
self.show_lists[status].setSelectionBehavior(QAbstractItemView.SelectRows)
|
|
1357
|
+
self.show_lists[status].setEditTriggers(QAbstractItemView.NoEditTriggers)
|
|
847
1358
|
self.show_lists[status].horizontalHeader().setHighlightSections(False)
|
|
1359
|
+
if pyqt_version is 5:
|
|
1360
|
+
self.show_lists[status].horizontalHeader().setSectionsMovable(True)
|
|
1361
|
+
else:
|
|
1362
|
+
self.show_lists[status].horizontalHeader().setMovable(True)
|
|
1363
|
+
self.show_lists[status].horizontalHeader().setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
|
|
1364
|
+
self.show_lists[status].horizontalHeader().customContextMenuRequested.connect(self.s_show_menu_columns)
|
|
848
1365
|
self.show_lists[status].verticalHeader().hide()
|
|
849
1366
|
self.show_lists[status].setGridStyle(QtCore.Qt.NoPen)
|
|
850
1367
|
self.show_lists[status].currentItemChanged.connect(self.s_show_selected)
|
|
@@ -861,7 +1378,7 @@ class Trackma(QtGui.QMainWindow):
|
|
|
861
1378
|
self.mediatype_actiongroup.removeAction(action)
|
|
862
1379
|
|
|
863
1380
|
for n, mediatype in enumerate(self.api_info['supported_mediatypes']):
|
|
864
|
-
action =
|
|
1381
|
+
action = QAction(mediatype, self, checkable=True)
|
|
865
1382
|
if mediatype == self.api_info['mediatype']:
|
|
866
1383
|
action.setChecked(True)
|
|
867
1384
|
else:
|
|
@@ -871,6 +1388,8 @@ class Trackma(QtGui.QMainWindow):
|
|
|
871
1388
|
|
|
872
1389
|
# Show API info
|
|
873
1390
|
self.api_icon.setPixmap( QtGui.QPixmap( utils.available_libs[self.account['api']][1] ) )
|
|
1391
|
+
if self.config['tray_api_icon']:
|
|
1392
|
+
self.tray.setIcon( QIcon( utils.available_libs[self.account['api']][1] ) )
|
|
874
1393
|
self.api_user.setText( self.worker.engine.get_userconfig('username') )
|
|
875
1394
|
self.setWindowTitle( "Trackma-qt %s [%s (%s)]" % (utils.VERSION, self.api_info['name'], self.api_info['mediatype']) )
|
|
876
1395
|
|
|
@@ -915,17 +1434,17 @@ class Trackma(QtGui.QMainWindow):
|
|
|
915
1434
|
self.s_switch_account()
|
|
916
1435
|
|
|
917
1436
|
|
|
918
|
-
class DetailsDialog(
|
|
1437
|
+
class DetailsDialog(QDialog):
|
|
919
1438
|
def __init__(self, parent, worker, show):
|
|
920
|
-
|
|
1439
|
+
QDialog.__init__(self, parent)
|
|
921
1440
|
self.setMinimumSize(530, 550)
|
|
922
1441
|
self.setWindowTitle('Details')
|
|
923
1442
|
self.worker = worker
|
|
924
1443
|
|
|
925
|
-
main_layout =
|
|
1444
|
+
main_layout = QVBoxLayout()
|
|
926
1445
|
details = DetailsWidget(self, worker)
|
|
927
1446
|
|
|
928
|
-
bottom_buttons =
|
|
1447
|
+
bottom_buttons = QDialogButtonBox(QDialogButtonBox.Close)
|
|
929
1448
|
bottom_buttons.setCenterButtons(True)
|
|
930
1449
|
bottom_buttons.rejected.connect(self.close)
|
|
931
1450
|
|
|
@@ -935,39 +1454,43 @@ class DetailsDialog(QtGui.QDialog):
|
|
|
935
1454
|
self.setLayout(main_layout)
|
|
936
1455
|
details.load(show)
|
|
937
1456
|
|
|
938
|
-
class DetailsWidget(
|
|
1457
|
+
class DetailsWidget(QWidget):
|
|
939
1458
|
def __init__(self, parent, worker):
|
|
940
1459
|
self.worker = worker
|
|
941
1460
|
|
|
942
|
-
|
|
1461
|
+
QWidget.__init__(self, parent)
|
|
943
1462
|
|
|
944
1463
|
# Build layout
|
|
945
|
-
main_layout =
|
|
1464
|
+
main_layout = QVBoxLayout()
|
|
946
1465
|
main_layout.setContentsMargins(0, 0, 0, 0)
|
|
947
1466
|
|
|
948
|
-
self.show_title =
|
|
1467
|
+
self.show_title = QLabel()
|
|
949
1468
|
show_title_font = QtGui.QFont()
|
|
950
1469
|
show_title_font.setBold(True)
|
|
951
1470
|
show_title_font.setPointSize(12)
|
|
952
1471
|
self.show_title.setAlignment( QtCore.Qt.AlignCenter )
|
|
953
1472
|
self.show_title.setFont(show_title_font)
|
|
954
1473
|
|
|
955
|
-
info_area =
|
|
956
|
-
info_layout =
|
|
1474
|
+
info_area = QWidget()
|
|
1475
|
+
info_layout = QGridLayout()
|
|
957
1476
|
|
|
958
|
-
self.show_image =
|
|
1477
|
+
self.show_image = QLabel()
|
|
959
1478
|
self.show_image.setAlignment( QtCore.Qt.AlignTop )
|
|
960
|
-
self.show_info =
|
|
1479
|
+
self.show_info = QLabel()
|
|
961
1480
|
self.show_info.setWordWrap(True)
|
|
962
1481
|
self.show_info.setAlignment( QtCore.Qt.AlignTop )
|
|
1482
|
+
self.show_description = QLabel()
|
|
1483
|
+
self.show_description.setWordWrap(True)
|
|
1484
|
+
self.show_description.setAlignment( QtCore.Qt.AlignTop )
|
|
963
1485
|
|
|
964
|
-
info_layout.addWidget( self.show_image )
|
|
965
|
-
info_layout.addWidget( self.show_info,
|
|
1486
|
+
info_layout.addWidget( self.show_image, 0,0,1,1 )
|
|
1487
|
+
info_layout.addWidget( self.show_info, 1,0,1,1 )
|
|
1488
|
+
info_layout.addWidget( self.show_description, 0,1,2,1 )
|
|
966
1489
|
|
|
967
1490
|
info_area.setLayout(info_layout)
|
|
968
1491
|
|
|
969
|
-
scroll_area =
|
|
970
|
-
scroll_area.setBackgroundRole(
|
|
1492
|
+
scroll_area = QScrollArea()
|
|
1493
|
+
scroll_area.setBackgroundRole(QPalette.Light)
|
|
971
1494
|
scroll_area.setWidgetResizable(True)
|
|
972
1495
|
scroll_area.setWidget(info_area)
|
|
973
1496
|
|
|
@@ -990,9 +1513,10 @@ class DetailsWidget(QtGui.QWidget):
|
|
|
990
1513
|
# Load show info
|
|
991
1514
|
self.show_info.setText('Wait...')
|
|
992
1515
|
self.worker_call('get_show_details', self.r_details_loaded, show)
|
|
1516
|
+
api_info = self.worker.engine.api_info
|
|
993
1517
|
|
|
994
1518
|
# Load show image
|
|
995
|
-
filename = utils.get_filename('cache', "
|
|
1519
|
+
filename = utils.get_filename('cache', "%s_%s_f_%s.jpg" % (api_info['shortname'], api_info['mediatype'], show['id']))
|
|
996
1520
|
|
|
997
1521
|
if os.path.isfile(filename):
|
|
998
1522
|
self.s_show_image(filename)
|
|
@@ -1010,34 +1534,49 @@ class DetailsWidget(QtGui.QWidget):
|
|
|
1010
1534
|
details = result['details']
|
|
1011
1535
|
|
|
1012
1536
|
info_strings = []
|
|
1537
|
+
description_strings = []
|
|
1538
|
+
description_keys = {'Synopsis', 'English', 'Japanese', 'Synonyms'} # This might come down to personal preference
|
|
1539
|
+
list_keys = {'Genres'} # Anilist gives genres as a list, need a special case to fix formatting
|
|
1540
|
+
|
|
1013
1541
|
for line in details['extra']:
|
|
1014
1542
|
if line[0] and line[1]:
|
|
1015
|
-
|
|
1543
|
+
if line[0] in description_keys:
|
|
1544
|
+
description_strings.append( "<h3>%s</h3><p>%s</p>" % (line[0], line[1]) )
|
|
1545
|
+
else:
|
|
1546
|
+
if line[0] in list_keys:
|
|
1547
|
+
description_strings.append( "<h3>%s</h3><p>%s</p>" % (line[0], ', '.join(line[1])) )
|
|
1548
|
+
elif len("%s" % line[1]) >= 17: # Avoid short tidbits taking up too much vertical space
|
|
1549
|
+
info_strings.append( "<h3>%s</h3><p>%s</p>" % (line[0], line[1]) )
|
|
1550
|
+
else:
|
|
1551
|
+
info_strings.append( "<p><b>%s:</b> %s</p>" % (line[0], line[1]) )
|
|
1016
1552
|
|
|
1017
1553
|
info_string = ''.join(info_strings)
|
|
1018
1554
|
self.show_info.setText( info_string )
|
|
1555
|
+
description_string = ''.join(description_strings)
|
|
1556
|
+
self.show_description.setText( description_string )
|
|
1019
1557
|
else:
|
|
1020
1558
|
self.show_info.setText( 'There was an error while getting details.' )
|
|
1021
1559
|
|
|
1022
|
-
class AddDialog(
|
|
1560
|
+
class AddDialog(QDialog):
|
|
1023
1561
|
worker = None
|
|
1024
1562
|
selected_show = None
|
|
1025
1563
|
|
|
1026
|
-
def __init__(self, parent, worker):
|
|
1027
|
-
|
|
1564
|
+
def __init__(self, parent, worker, current_status):
|
|
1565
|
+
QMainWindow.__init__(self, parent)
|
|
1028
1566
|
self.setMinimumSize(700, 500)
|
|
1029
1567
|
self.setWindowTitle('Search/Add from Remote')
|
|
1030
1568
|
self.worker = worker
|
|
1569
|
+
self.current_status = current_status
|
|
1031
1570
|
|
|
1032
|
-
layout =
|
|
1571
|
+
layout = QGridLayout()
|
|
1033
1572
|
|
|
1034
1573
|
# Create top layout
|
|
1035
|
-
top_layout =
|
|
1036
|
-
search_lbl =
|
|
1037
|
-
self.search_txt =
|
|
1574
|
+
top_layout = QHBoxLayout()
|
|
1575
|
+
search_lbl = QLabel('Search terms:')
|
|
1576
|
+
self.search_txt = QLineEdit(self)
|
|
1038
1577
|
self.search_txt.returnPressed.connect(self.s_search)
|
|
1039
1578
|
self.search_txt.setFocus()
|
|
1040
|
-
self.search_btn =
|
|
1579
|
+
self.search_btn = QPushButton('Search')
|
|
1041
1580
|
self.search_btn.clicked.connect(self.s_search)
|
|
1042
1581
|
top_layout.addWidget(search_lbl)
|
|
1043
1582
|
top_layout.addWidget(self.search_txt)
|
|
@@ -1045,22 +1584,25 @@ class AddDialog(QtGui.QDialog):
|
|
|
1045
1584
|
|
|
1046
1585
|
# Create table
|
|
1047
1586
|
columns = ['Title', 'Type', 'Total']
|
|
1048
|
-
self.table =
|
|
1587
|
+
self.table = QTableWidget()
|
|
1049
1588
|
self.table.setColumnCount(len(columns))
|
|
1050
1589
|
self.table.setHorizontalHeaderLabels(columns)
|
|
1051
1590
|
self.table.horizontalHeader().setHighlightSections(False)
|
|
1052
|
-
self.table.setSelectionMode(
|
|
1053
|
-
self.table.setSelectionBehavior(
|
|
1054
|
-
self.table.setEditTriggers(
|
|
1591
|
+
self.table.setSelectionMode(QAbstractItemView.SingleSelection)
|
|
1592
|
+
self.table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
|
1593
|
+
self.table.setEditTriggers(QAbstractItemView.NoEditTriggers)
|
|
1055
1594
|
self.table.verticalHeader().hide()
|
|
1056
1595
|
self.table.setGridStyle(QtCore.Qt.NoPen)
|
|
1057
|
-
|
|
1596
|
+
if pyqt_version is 5:
|
|
1597
|
+
self.table.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch)
|
|
1598
|
+
else:
|
|
1599
|
+
self.table.horizontalHeader().setResizeMode(0, QHeaderView.Stretch)
|
|
1058
1600
|
self.table.currentItemChanged.connect(self.s_show_selected)
|
|
1059
1601
|
#self.table.doubleClicked.connect(self.s_show_details)
|
|
1060
1602
|
|
|
1061
|
-
bottom_buttons =
|
|
1062
|
-
bottom_buttons.addButton("Cancel",
|
|
1063
|
-
self.select_btn = bottom_buttons.addButton("Add",
|
|
1603
|
+
bottom_buttons = QDialogButtonBox(self)
|
|
1604
|
+
bottom_buttons.addButton("Cancel", QDialogButtonBox.RejectRole)
|
|
1605
|
+
self.select_btn = bottom_buttons.addButton("Add", QDialogButtonBox.AcceptRole)
|
|
1064
1606
|
bottom_buttons.accepted.connect(self.s_add)
|
|
1065
1607
|
bottom_buttons.rejected.connect(self.close)
|
|
1066
1608
|
|
|
@@ -1103,7 +1645,7 @@ class AddDialog(QtGui.QDialog):
|
|
|
1103
1645
|
|
|
1104
1646
|
def s_add(self):
|
|
1105
1647
|
if self.selected_show:
|
|
1106
|
-
self.worker_call('add_show', self.r_added, self.selected_show)
|
|
1648
|
+
self.worker_call('add_show', self.r_added, self.selected_show, self.current_status)
|
|
1107
1649
|
|
|
1108
1650
|
# Worker responses
|
|
1109
1651
|
def r_searched(self, result):
|
|
@@ -1122,6 +1664,9 @@ class AddDialog(QtGui.QDialog):
|
|
|
1122
1664
|
self.table.setItem(i, 2, ShowItem(str(res['total'])))
|
|
1123
1665
|
|
|
1124
1666
|
i += 1
|
|
1667
|
+
if self.table.currentRow() is 0: # Row number hasn't changed but the data probably has!
|
|
1668
|
+
self.s_show_selected(self.table.item(0,0))
|
|
1669
|
+
self.table.setCurrentItem(self.table.item(0,0))
|
|
1125
1670
|
else:
|
|
1126
1671
|
self.table.setRowCount(0)
|
|
1127
1672
|
|
|
@@ -1133,7 +1678,7 @@ class AddDialog(QtGui.QDialog):
|
|
|
1133
1678
|
pass
|
|
1134
1679
|
|
|
1135
1680
|
|
|
1136
|
-
class SettingsDialog(
|
|
1681
|
+
class SettingsDialog(QDialog):
|
|
1137
1682
|
worker = None
|
|
1138
1683
|
config = None
|
|
1139
1684
|
configfile = None
|
|
@@ -1141,52 +1686,53 @@ class SettingsDialog(QtGui.QDialog):
|
|
|
1141
1686
|
saved = QtCore.pyqtSignal()
|
|
1142
1687
|
|
|
1143
1688
|
def __init__(self, parent, worker, config, configfile):
|
|
1144
|
-
|
|
1689
|
+
QDialog.__init__(self, parent)
|
|
1145
1690
|
|
|
1146
1691
|
self.worker = worker
|
|
1147
1692
|
self.config = config
|
|
1148
1693
|
self.configfile = configfile
|
|
1149
1694
|
self.setStyleSheet("QGroupBox { font-weight: bold; } ")
|
|
1150
1695
|
self.setWindowTitle('Settings')
|
|
1151
|
-
layout =
|
|
1696
|
+
layout = QGridLayout()
|
|
1152
1697
|
|
|
1153
1698
|
# Categories
|
|
1154
|
-
self.category_list =
|
|
1155
|
-
category_media =
|
|
1156
|
-
category_sync =
|
|
1157
|
-
category_ui =
|
|
1158
|
-
self.category_list
|
|
1699
|
+
self.category_list = QListWidget()
|
|
1700
|
+
category_media = QListWidgetItem(getIcon('media-playback-start'), 'Media', self.category_list)
|
|
1701
|
+
category_sync = QListWidgetItem(getIcon('view-refresh'), 'Sync', self.category_list)
|
|
1702
|
+
category_ui = QListWidgetItem(getIcon('window-new'), 'User Interface', self.category_list)
|
|
1703
|
+
category_theme = QListWidgetItem(getIcon('applications-graphics'), 'Theme', self.category_list)
|
|
1704
|
+
self.category_list.setSelectionMode(QAbstractItemView.SingleSelection)
|
|
1159
1705
|
self.category_list.setCurrentRow(0)
|
|
1160
1706
|
self.category_list.setMaximumWidth(self.category_list.sizeHintForColumn(0) + 15)
|
|
1161
1707
|
self.category_list.setFocus()
|
|
1162
1708
|
self.category_list.currentItemChanged.connect(self.s_switch_page)
|
|
1163
1709
|
|
|
1164
1710
|
# Media tab
|
|
1165
|
-
page_media =
|
|
1166
|
-
page_media_layout =
|
|
1711
|
+
page_media = QWidget()
|
|
1712
|
+
page_media_layout = QVBoxLayout()
|
|
1167
1713
|
page_media_layout.setAlignment(QtCore.Qt.AlignTop)
|
|
1168
1714
|
|
|
1169
1715
|
# Group: Media settings
|
|
1170
|
-
g_media =
|
|
1716
|
+
g_media = QGroupBox('Media settings')
|
|
1171
1717
|
g_media.setFlat(True)
|
|
1172
|
-
g_media_layout =
|
|
1173
|
-
self.tracker_enabled =
|
|
1718
|
+
g_media_layout = QFormLayout()
|
|
1719
|
+
self.tracker_enabled = QCheckBox()
|
|
1174
1720
|
self.tracker_enabled.toggled.connect(self.tracker_type_change)
|
|
1175
|
-
self.tracker_type_local =
|
|
1721
|
+
self.tracker_type_local = QRadioButton('Local')
|
|
1176
1722
|
self.tracker_type_local.toggled.connect(self.tracker_type_change)
|
|
1177
|
-
self.tracker_type_plex =
|
|
1723
|
+
self.tracker_type_plex = QRadioButton('Plex media server')
|
|
1178
1724
|
self.tracker_type_plex.toggled.connect(self.tracker_type_change)
|
|
1179
|
-
self.plex_host =
|
|
1180
|
-
self.plex_port =
|
|
1181
|
-
self.tracker_interval =
|
|
1725
|
+
self.plex_host = QLineEdit()
|
|
1726
|
+
self.plex_port = QLineEdit()
|
|
1727
|
+
self.tracker_interval = QSpinBox()
|
|
1182
1728
|
self.tracker_interval.setRange(5, 1000)
|
|
1183
1729
|
self.tracker_interval.setMaximumWidth(60)
|
|
1184
|
-
self.tracker_process =
|
|
1185
|
-
self.tracker_update_wait =
|
|
1730
|
+
self.tracker_process = QLineEdit()
|
|
1731
|
+
self.tracker_update_wait = QSpinBox()
|
|
1186
1732
|
self.tracker_update_wait.setRange(0, 1000)
|
|
1187
1733
|
self.tracker_update_wait.setMaximumWidth(60)
|
|
1188
|
-
self.tracker_update_close =
|
|
1189
|
-
self.tracker_update_prompt =
|
|
1734
|
+
self.tracker_update_close = QCheckBox()
|
|
1735
|
+
self.tracker_update_prompt = QCheckBox()
|
|
1190
1736
|
|
|
1191
1737
|
g_media_layout.addRow( 'Enable tracker', self.tracker_enabled )
|
|
1192
1738
|
g_media_layout.addRow( self.tracker_type_local )
|
|
@@ -1202,20 +1748,20 @@ class SettingsDialog(QtGui.QDialog):
|
|
|
1202
1748
|
g_media.setLayout(g_media_layout)
|
|
1203
1749
|
|
|
1204
1750
|
# Group: Play Next
|
|
1205
|
-
g_playnext =
|
|
1751
|
+
g_playnext = QGroupBox('Play Next')
|
|
1206
1752
|
g_playnext.setFlat(True)
|
|
1207
|
-
self.player =
|
|
1208
|
-
self.player_browse =
|
|
1753
|
+
self.player = QLineEdit()
|
|
1754
|
+
self.player_browse = QPushButton('Browse...')
|
|
1209
1755
|
self.player_browse.clicked.connect(self.s_player_browse)
|
|
1210
|
-
self.searchdir =
|
|
1211
|
-
self.searchdir_browse =
|
|
1756
|
+
self.searchdir = QLineEdit()
|
|
1757
|
+
self.searchdir_browse = QPushButton('Browse...')
|
|
1212
1758
|
self.searchdir_browse.clicked.connect(self.s_searchdir_browse)
|
|
1213
1759
|
|
|
1214
|
-
g_playnext_layout =
|
|
1215
|
-
g_playnext_layout.addWidget(
|
|
1760
|
+
g_playnext_layout = QGridLayout()
|
|
1761
|
+
g_playnext_layout.addWidget( QLabel('Player'), 0, 0, 1, 1)
|
|
1216
1762
|
g_playnext_layout.addWidget( self.player, 0, 1, 1, 1)
|
|
1217
1763
|
g_playnext_layout.addWidget( self.player_browse, 0, 2, 1, 1)
|
|
1218
|
-
g_playnext_layout.addWidget(
|
|
1764
|
+
g_playnext_layout.addWidget( QLabel('Media directory'), 1, 0, 1, 1)
|
|
1219
1765
|
g_playnext_layout.addWidget( self.searchdir, 1, 1, 1, 1)
|
|
1220
1766
|
g_playnext_layout.addWidget( self.searchdir_browse, 1, 2, 1, 1)
|
|
1221
1767
|
|
|
@@ -1227,20 +1773,20 @@ class SettingsDialog(QtGui.QDialog):
|
|
|
1227
1773
|
page_media.setLayout(page_media_layout)
|
|
1228
1774
|
|
|
1229
1775
|
# Sync tab
|
|
1230
|
-
page_sync =
|
|
1231
|
-
page_sync_layout =
|
|
1776
|
+
page_sync = QWidget()
|
|
1777
|
+
page_sync_layout = QVBoxLayout()
|
|
1232
1778
|
page_sync_layout.setAlignment(QtCore.Qt.AlignTop)
|
|
1233
1779
|
|
|
1234
1780
|
# Group: Autoretrieve
|
|
1235
|
-
g_autoretrieve =
|
|
1781
|
+
g_autoretrieve = QGroupBox('Autoretrieve')
|
|
1236
1782
|
g_autoretrieve.setFlat(True)
|
|
1237
|
-
self.autoretrieve_off =
|
|
1238
|
-
self.autoretrieve_always =
|
|
1239
|
-
self.autoretrieve_days =
|
|
1783
|
+
self.autoretrieve_off = QRadioButton('Disabled')
|
|
1784
|
+
self.autoretrieve_always = QRadioButton('Always at start')
|
|
1785
|
+
self.autoretrieve_days = QRadioButton('After n days')
|
|
1240
1786
|
self.autoretrieve_days.toggled.connect(self.s_autoretrieve_days)
|
|
1241
|
-
self.autoretrieve_days_n =
|
|
1787
|
+
self.autoretrieve_days_n = QSpinBox()
|
|
1242
1788
|
self.autoretrieve_days_n.setRange(1, 100)
|
|
1243
|
-
g_autoretrieve_layout =
|
|
1789
|
+
g_autoretrieve_layout = QGridLayout()
|
|
1244
1790
|
g_autoretrieve_layout.setColumnStretch(0, 1)
|
|
1245
1791
|
g_autoretrieve_layout.addWidget(self.autoretrieve_off, 0, 0, 1, 1)
|
|
1246
1792
|
g_autoretrieve_layout.addWidget(self.autoretrieve_always, 1, 0, 1, 1)
|
|
@@ -1249,20 +1795,20 @@ class SettingsDialog(QtGui.QDialog):
|
|
|
1249
1795
|
g_autoretrieve.setLayout(g_autoretrieve_layout)
|
|
1250
1796
|
|
|
1251
1797
|
# Group: Autosend
|
|
1252
|
-
g_autosend =
|
|
1798
|
+
g_autosend = QGroupBox('Autosend')
|
|
1253
1799
|
g_autosend.setFlat(True)
|
|
1254
|
-
self.autosend_off =
|
|
1255
|
-
self.autosend_always =
|
|
1256
|
-
self.autosend_hours =
|
|
1800
|
+
self.autosend_off = QRadioButton('Disabled')
|
|
1801
|
+
self.autosend_always = QRadioButton('Immediately after every change')
|
|
1802
|
+
self.autosend_hours = QRadioButton('After n hours')
|
|
1257
1803
|
self.autosend_hours.toggled.connect(self.s_autosend_hours)
|
|
1258
|
-
self.autosend_hours_n =
|
|
1804
|
+
self.autosend_hours_n = QSpinBox()
|
|
1259
1805
|
self.autosend_hours_n.setRange(1, 1000)
|
|
1260
|
-
self.autosend_size =
|
|
1806
|
+
self.autosend_size = QRadioButton('After the queue reaches n items')
|
|
1261
1807
|
self.autosend_size.toggled.connect(self.s_autosend_size)
|
|
1262
|
-
self.autosend_size_n =
|
|
1808
|
+
self.autosend_size_n = QSpinBox()
|
|
1263
1809
|
self.autosend_size_n.setRange(2, 20)
|
|
1264
|
-
self.autosend_at_exit =
|
|
1265
|
-
g_autosend_layout =
|
|
1810
|
+
self.autosend_at_exit = QCheckBox('At exit')
|
|
1811
|
+
g_autosend_layout = QGridLayout()
|
|
1266
1812
|
g_autosend_layout.setColumnStretch(0, 1)
|
|
1267
1813
|
g_autosend_layout.addWidget(self.autosend_off, 0, 0, 1, 1)
|
|
1268
1814
|
g_autosend_layout.addWidget(self.autosend_always, 1, 0, 1, 1)
|
|
@@ -1274,13 +1820,13 @@ class SettingsDialog(QtGui.QDialog):
|
|
|
1274
1820
|
g_autosend.setLayout(g_autosend_layout)
|
|
1275
1821
|
|
|
1276
1822
|
# Group: Extra
|
|
1277
|
-
g_extra =
|
|
1823
|
+
g_extra = QGroupBox('Additional options')
|
|
1278
1824
|
g_extra.setFlat(True)
|
|
1279
|
-
self.auto_status_change =
|
|
1825
|
+
self.auto_status_change = QCheckBox('Change status automatically')
|
|
1280
1826
|
self.auto_status_change.toggled.connect(self.s_auto_status_change)
|
|
1281
|
-
self.auto_status_change_if_scored =
|
|
1282
|
-
self.auto_date_change =
|
|
1283
|
-
g_extra_layout =
|
|
1827
|
+
self.auto_status_change_if_scored = QCheckBox('Change status automatically only if scored')
|
|
1828
|
+
self.auto_date_change = QCheckBox('Change start and finish dates automatically')
|
|
1829
|
+
g_extra_layout = QVBoxLayout()
|
|
1284
1830
|
g_extra_layout.addWidget(self.auto_status_change)
|
|
1285
1831
|
g_extra_layout.addWidget(self.auto_status_change_if_scored)
|
|
1286
1832
|
g_extra_layout.addWidget(self.auto_date_change)
|
|
@@ -1293,49 +1839,139 @@ class SettingsDialog(QtGui.QDialog):
|
|
|
1293
1839
|
page_sync.setLayout(page_sync_layout)
|
|
1294
1840
|
|
|
1295
1841
|
# UI tab
|
|
1296
|
-
page_ui =
|
|
1297
|
-
page_ui_layout =
|
|
1842
|
+
page_ui = QWidget()
|
|
1843
|
+
page_ui_layout = QFormLayout()
|
|
1298
1844
|
page_ui_layout.setAlignment(QtCore.Qt.AlignTop)
|
|
1299
1845
|
|
|
1300
1846
|
# Group: Icon
|
|
1301
|
-
g_icon =
|
|
1847
|
+
g_icon = QGroupBox('Notification Icon')
|
|
1302
1848
|
g_icon.setFlat(True)
|
|
1303
|
-
self.tray_icon =
|
|
1849
|
+
self.tray_icon = QCheckBox('Show tray icon')
|
|
1304
1850
|
self.tray_icon.toggled.connect(self.s_tray_icon)
|
|
1305
|
-
self.close_to_tray =
|
|
1306
|
-
self.start_in_tray =
|
|
1307
|
-
self.
|
|
1308
|
-
|
|
1851
|
+
self.close_to_tray = QCheckBox('Close to tray')
|
|
1852
|
+
self.start_in_tray = QCheckBox('Start minimized to tray')
|
|
1853
|
+
self.tray_api_icon = QCheckBox('Use API icon as tray icon')
|
|
1854
|
+
self.notifications = QCheckBox('Show notification when tracker detects new media')
|
|
1855
|
+
g_icon_layout = QVBoxLayout()
|
|
1309
1856
|
g_icon_layout.addWidget(self.tray_icon)
|
|
1310
1857
|
g_icon_layout.addWidget(self.close_to_tray)
|
|
1311
1858
|
g_icon_layout.addWidget(self.start_in_tray)
|
|
1859
|
+
g_icon_layout.addWidget(self.tray_api_icon)
|
|
1312
1860
|
g_icon_layout.addWidget(self.notifications)
|
|
1313
1861
|
g_icon.setLayout(g_icon_layout)
|
|
1314
1862
|
|
|
1315
1863
|
# Group: Window
|
|
1316
|
-
g_window =
|
|
1864
|
+
g_window = QGroupBox('Window')
|
|
1317
1865
|
g_window.setFlat(True)
|
|
1318
|
-
self.remember_geometry =
|
|
1319
|
-
|
|
1866
|
+
self.remember_geometry = QCheckBox('Remember window size and position')
|
|
1867
|
+
self.remember_columns = QCheckBox('Remember column layouts and widths')
|
|
1868
|
+
self.columns_per_api = QCheckBox('Use different visible columns per API')
|
|
1869
|
+
g_window_layout = QVBoxLayout()
|
|
1320
1870
|
g_window_layout.addWidget(self.remember_geometry)
|
|
1871
|
+
g_window_layout.addWidget(self.remember_columns)
|
|
1872
|
+
g_window_layout.addWidget(self.columns_per_api)
|
|
1321
1873
|
g_window.setLayout(g_window_layout)
|
|
1322
1874
|
|
|
1875
|
+
# Group: Lists
|
|
1876
|
+
g_lists = QGroupBox('Lists')
|
|
1877
|
+
g_lists.setFlat(True)
|
|
1878
|
+
self.filter_bar_position = QComboBox()
|
|
1879
|
+
filter_bar_positions = [(FilterBar.PositionHidden, 'Hidden'),
|
|
1880
|
+
(FilterBar.PositionAboveLists, 'Above lists'),
|
|
1881
|
+
(FilterBar.PositionBelowLists, 'Below lists')]
|
|
1882
|
+
for (n,label) in filter_bar_positions:
|
|
1883
|
+
self.filter_bar_position.addItem(label, n)
|
|
1884
|
+
self.filter_global = QCheckBox('Update filter for all lists (slow)')
|
|
1885
|
+
g_lists_layout = QFormLayout()
|
|
1886
|
+
g_lists_layout.addRow('Filter bar position:',self.filter_bar_position)
|
|
1887
|
+
g_lists_layout.addRow(self.filter_global)
|
|
1888
|
+
g_lists.setLayout(g_lists_layout)
|
|
1889
|
+
|
|
1323
1890
|
# UI layout
|
|
1324
1891
|
page_ui_layout.addWidget(g_icon)
|
|
1325
1892
|
page_ui_layout.addWidget(g_window)
|
|
1893
|
+
page_ui_layout.addWidget(g_lists)
|
|
1326
1894
|
page_ui.setLayout(page_ui_layout)
|
|
1327
1895
|
|
|
1896
|
+
# Theming tab
|
|
1897
|
+
page_theme = QWidget()
|
|
1898
|
+
page_theme_layout = QFormLayout()
|
|
1899
|
+
page_theme_layout.setAlignment(QtCore.Qt.AlignTop)
|
|
1900
|
+
|
|
1901
|
+
# Group: Episode Bar
|
|
1902
|
+
g_ep_bar = QGroupBox('Episode Bar')
|
|
1903
|
+
g_ep_bar.setFlat(True)
|
|
1904
|
+
self.ep_bar_style = QComboBox()
|
|
1905
|
+
ep_bar_styles = [(EpisodeBar.BarStyleBasic, 'Basic'),
|
|
1906
|
+
(EpisodeBar.BarStyle04, 'Trackma v0.4 Dual'),
|
|
1907
|
+
(EpisodeBar.BarStyleHybrid, 'Hybrid Dual')]
|
|
1908
|
+
for (n,label) in ep_bar_styles:
|
|
1909
|
+
self.ep_bar_style.addItem(label, n)
|
|
1910
|
+
self.ep_bar_style.currentIndexChanged.connect(self.s_ep_bar_style)
|
|
1911
|
+
self.ep_bar_text = QCheckBox('Show text label')
|
|
1912
|
+
g_ep_bar_layout = QFormLayout()
|
|
1913
|
+
g_ep_bar_layout.addRow('Style:', self.ep_bar_style)
|
|
1914
|
+
g_ep_bar_layout.addRow(self.ep_bar_text)
|
|
1915
|
+
g_ep_bar.setLayout(g_ep_bar_layout)
|
|
1916
|
+
|
|
1917
|
+
# Group: Colour scheme
|
|
1918
|
+
g_scheme = QGroupBox('Color Scheme')
|
|
1919
|
+
g_scheme.setFlat(True)
|
|
1920
|
+
col_tabs = [('rows', '&Row highlights'),
|
|
1921
|
+
('progress', '&Progress widget')]
|
|
1922
|
+
self.colors = {}
|
|
1923
|
+
self.colors['rows'] = [('is_playing', 'Playing'),
|
|
1924
|
+
('is_queued', 'Queued'),
|
|
1925
|
+
('new_episode', 'New Episode'),
|
|
1926
|
+
('is_airing', 'Airing'),
|
|
1927
|
+
('not_aired', 'Unaired')]
|
|
1928
|
+
self.colors['progress'] = [('progress_bg', 'Background'),
|
|
1929
|
+
('progress_fg', 'Watched bar'),
|
|
1930
|
+
('progress_sub_bg', 'Aired episodes'),
|
|
1931
|
+
('progress_sub_fg', 'Stored episodes'),
|
|
1932
|
+
('progress_complete', 'Complete')]
|
|
1933
|
+
self.color_buttons = []
|
|
1934
|
+
self.syscolor_buttons = []
|
|
1935
|
+
g_scheme_layout = QGridLayout()
|
|
1936
|
+
tw_scheme = QTabWidget()
|
|
1937
|
+
for (key,tab_title) in col_tabs:
|
|
1938
|
+
page = QFrame()
|
|
1939
|
+
page_layout = QGridLayout()
|
|
1940
|
+
col = 0
|
|
1941
|
+
for (key,label) in self.colors[key]: # Generate widgets from the keys and values
|
|
1942
|
+
self.color_buttons.append( QPushButton() )
|
|
1943
|
+
# self.color_buttons[-1].setStyleSheet('background-color: ' + getColor(self.config['colors'][key]).name())
|
|
1944
|
+
self.color_buttons[-1].setFocusPolicy(QtCore.Qt.NoFocus)
|
|
1945
|
+
self.color_buttons[-1].clicked.connect( self.s_color_picker(key,False) )
|
|
1946
|
+
self.syscolor_buttons.append( QPushButton('System Colors') )
|
|
1947
|
+
self.syscolor_buttons[-1].clicked.connect( self.s_color_picker(key,True) )
|
|
1948
|
+
page_layout.addWidget( QLabel(label), col, 0, 1, 1 )
|
|
1949
|
+
page_layout.addWidget( self.color_buttons[-1], col, 1, 1, 1 )
|
|
1950
|
+
page_layout.addWidget( self.syscolor_buttons[-1], col, 2, 1, 1 )
|
|
1951
|
+
col+=1
|
|
1952
|
+
page.setLayout(page_layout)
|
|
1953
|
+
tw_scheme.addTab(page,tab_title)
|
|
1954
|
+
g_scheme_layout.addWidget(tw_scheme)
|
|
1955
|
+
g_scheme.setLayout(g_scheme_layout)
|
|
1956
|
+
|
|
1957
|
+
# UI layout
|
|
1958
|
+
page_theme_layout.addWidget(g_ep_bar)
|
|
1959
|
+
page_theme_layout.addWidget(g_scheme)
|
|
1960
|
+
page_theme.setLayout(page_theme_layout)
|
|
1961
|
+
|
|
1328
1962
|
# Content
|
|
1329
|
-
self.contents =
|
|
1963
|
+
self.contents = QStackedWidget()
|
|
1330
1964
|
self.contents.addWidget(page_media)
|
|
1331
1965
|
self.contents.addWidget(page_sync)
|
|
1332
1966
|
self.contents.addWidget(page_ui)
|
|
1333
|
-
self.contents.
|
|
1967
|
+
self.contents.addWidget(page_theme)
|
|
1968
|
+
if pyqt_version is not 5:
|
|
1969
|
+
self.contents.layout().setMargin(0)
|
|
1334
1970
|
|
|
1335
1971
|
# Bottom buttons
|
|
1336
|
-
bottombox =
|
|
1972
|
+
bottombox = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Apply|QDialogButtonBox.Cancel)
|
|
1337
1973
|
bottombox.accepted.connect(self.s_save)
|
|
1338
|
-
bottombox.button(
|
|
1974
|
+
bottombox.button(QDialogButtonBox.Apply).clicked.connect(self._save)
|
|
1339
1975
|
bottombox.rejected.connect(self.reject)
|
|
1340
1976
|
|
|
1341
1977
|
# Main layout finish
|
|
@@ -1345,6 +1981,7 @@ class SettingsDialog(QtGui.QDialog):
|
|
|
1345
1981
|
layout.setColumnStretch(1, 1)
|
|
1346
1982
|
|
|
1347
1983
|
self._load()
|
|
1984
|
+
self.update_colors()
|
|
1348
1985
|
|
|
1349
1986
|
self.setLayout(layout)
|
|
1350
1987
|
|
|
@@ -1403,8 +2040,16 @@ class SettingsDialog(QtGui.QDialog):
|
|
|
1403
2040
|
self.tray_icon.setChecked(self.config['show_tray'])
|
|
1404
2041
|
self.close_to_tray.setChecked(self.config['close_to_tray'])
|
|
1405
2042
|
self.start_in_tray.setChecked(self.config['start_in_tray'])
|
|
2043
|
+
self.tray_api_icon.setChecked(self.config['tray_api_icon'])
|
|
1406
2044
|
self.notifications.setChecked(self.config['notifications'])
|
|
1407
2045
|
self.remember_geometry.setChecked(self.config['remember_geometry'])
|
|
2046
|
+
self.remember_columns.setChecked(self.config['remember_columns'])
|
|
2047
|
+
self.columns_per_api.setChecked(self.config['columns_per_api'])
|
|
2048
|
+
self.filter_bar_position.setCurrentIndex(self.filter_bar_position.findData(self.config['filter_bar_position']))
|
|
2049
|
+
self.filter_global.setChecked(self.config['filter_global'])
|
|
2050
|
+
|
|
2051
|
+
self.ep_bar_style.setCurrentIndex(self.ep_bar_style.findData(self.config['episodebar_style']))
|
|
2052
|
+
self.ep_bar_text.setChecked(self.config['episodebar_text'])
|
|
1408
2053
|
|
|
1409
2054
|
self.autoretrieve_days_n.setEnabled(self.autoretrieve_days.isChecked())
|
|
1410
2055
|
self.autosend_hours_n.setEnabled(self.autosend_hours.isChecked())
|
|
@@ -1413,6 +2058,8 @@ class SettingsDialog(QtGui.QDialog):
|
|
|
1413
2058
|
self.start_in_tray.setEnabled(self.tray_icon.isChecked())
|
|
1414
2059
|
self.notifications.setEnabled(self.tray_icon.isChecked())
|
|
1415
2060
|
|
|
2061
|
+
self.color_values = self.config['colors'].copy()
|
|
2062
|
+
|
|
1416
2063
|
def _save(self):
|
|
1417
2064
|
engine = self.worker.engine
|
|
1418
2065
|
|
|
@@ -1464,8 +2111,18 @@ class SettingsDialog(QtGui.QDialog):
|
|
|
1464
2111
|
self.config['show_tray'] = self.tray_icon.isChecked()
|
|
1465
2112
|
self.config['close_to_tray'] = self.close_to_tray.isChecked()
|
|
1466
2113
|
self.config['start_in_tray'] = self.start_in_tray.isChecked()
|
|
2114
|
+
self.config['tray_api_icon'] = self.tray_api_icon.isChecked()
|
|
1467
2115
|
self.config['notifications'] = self.notifications.isChecked()
|
|
1468
2116
|
self.config['remember_geometry'] = self.remember_geometry.isChecked()
|
|
2117
|
+
self.config['remember_columns'] = self.remember_columns.isChecked()
|
|
2118
|
+
self.config['columns_per_api'] = self.columns_per_api.isChecked()
|
|
2119
|
+
self.config['filter_bar_position'] = self.filter_bar_position.itemData(self.filter_bar_position.currentIndex())
|
|
2120
|
+
self.config['filter_global'] = self.filter_global.isChecked()
|
|
2121
|
+
|
|
2122
|
+
self.config['episodebar_style'] = self.ep_bar_style.itemData(self.ep_bar_style.currentIndex())
|
|
2123
|
+
self.config['episodebar_text'] = self.ep_bar_text.isChecked()
|
|
2124
|
+
|
|
2125
|
+
self.config['colors'] = self.color_values
|
|
1469
2126
|
|
|
1470
2127
|
utils.save_config(self.config, self.configfile)
|
|
1471
2128
|
|
|
@@ -1510,16 +2167,26 @@ class SettingsDialog(QtGui.QDialog):
|
|
|
1510
2167
|
def s_tray_icon(self, checked):
|
|
1511
2168
|
self.close_to_tray.setEnabled(checked)
|
|
1512
2169
|
self.start_in_tray.setEnabled(checked)
|
|
2170
|
+
self.tray_api_icon.setEnabled(checked)
|
|
1513
2171
|
self.notifications.setEnabled(checked)
|
|
1514
2172
|
|
|
2173
|
+
def s_ep_bar_style(self, index):
|
|
2174
|
+
if self.ep_bar_style.itemData(index) == EpisodeBar.BarStyle04:
|
|
2175
|
+
self.ep_bar_text.setEnabled(False)
|
|
2176
|
+
else:
|
|
2177
|
+
self.ep_bar_text.setEnabled(True)
|
|
2178
|
+
|
|
1515
2179
|
def s_auto_status_change(self, checked):
|
|
1516
2180
|
self.auto_status_change_if_scored.setEnabled(checked)
|
|
1517
2181
|
|
|
1518
2182
|
def s_player_browse(self):
|
|
1519
|
-
|
|
2183
|
+
if pyqt_version is 5:
|
|
2184
|
+
self.player.setText( QFileDialog.getOpenFileName(caption='Choose player executable')[0] )
|
|
2185
|
+
else:
|
|
2186
|
+
self.player.setText( QFileDialog.getOpenFileName(caption='Choose player executable') )
|
|
1520
2187
|
|
|
1521
2188
|
def s_searchdir_browse(self):
|
|
1522
|
-
self.searchdir.setText(
|
|
2189
|
+
self.searchdir.setText( QFileDialog.getExistingDirectory(caption='Choose media directory') )
|
|
1523
2190
|
|
|
1524
2191
|
def s_switch_page(self, new, old):
|
|
1525
2192
|
if not new:
|
|
@@ -1527,51 +2194,130 @@ class SettingsDialog(QtGui.QDialog):
|
|
|
1527
2194
|
|
|
1528
2195
|
self.contents.setCurrentIndex( self.category_list.row( new ) )
|
|
1529
2196
|
|
|
1530
|
-
|
|
2197
|
+
def s_color_picker(self, key, system):
|
|
2198
|
+
return lambda: self.color_picker(key, system)
|
|
2199
|
+
|
|
2200
|
+
def color_picker(self, key, system):
|
|
2201
|
+
if system is True:
|
|
2202
|
+
current = self.color_values[key]
|
|
2203
|
+
result = ThemedColorPicker.do()
|
|
2204
|
+
if result is not None and result is not current:
|
|
2205
|
+
self.color_values[key] = result
|
|
2206
|
+
self.update_colors()
|
|
2207
|
+
else:
|
|
2208
|
+
current = getColor(self.color_values[key])
|
|
2209
|
+
result = QColorDialog.getColor(current)
|
|
2210
|
+
if result.isValid() and result is not current:
|
|
2211
|
+
self.color_values[key] = str(result.name())
|
|
2212
|
+
self.update_colors()
|
|
2213
|
+
|
|
2214
|
+
def update_colors(self):
|
|
2215
|
+
for ((key,label),color) in zip(self.colors['rows']+self.colors['progress'],self.color_buttons):
|
|
2216
|
+
color.setStyleSheet('background-color: ' + getColor(self.color_values[key]).name())
|
|
2217
|
+
|
|
2218
|
+
class ThemedColorPicker(QDialog):
|
|
2219
|
+
def __init__(self,parent=None,default=None):
|
|
2220
|
+
QDialog.__init__(self,parent)
|
|
2221
|
+
self.setWindowTitle('Select Color')
|
|
2222
|
+
layout = QVBoxLayout()
|
|
2223
|
+
colorbox = QGridLayout()
|
|
2224
|
+
self.colorString = default
|
|
2225
|
+
|
|
2226
|
+
self.groups = [0,1,2]
|
|
2227
|
+
self.roles = [1,2,3,4,5,11,12,16] # Only use background roles
|
|
2228
|
+
self.colors = []
|
|
2229
|
+
row = 0
|
|
2230
|
+
# Make colored buttons for selection
|
|
2231
|
+
for group in self.groups:
|
|
2232
|
+
col = 0
|
|
2233
|
+
for role in self.roles:
|
|
2234
|
+
self.colors.append( QPushButton() )
|
|
2235
|
+
self.colors[-1].setStyleSheet('background-color: ' + QtGui.QColor( QPalette().color(group, role) ).name() )
|
|
2236
|
+
self.colors[-1].setFocusPolicy(QtCore.Qt.NoFocus)
|
|
2237
|
+
self.colors[-1].clicked.connect( self.s_select(group,role) )
|
|
2238
|
+
colorbox.addWidget(self.colors[-1], row, col, 1, 1)
|
|
2239
|
+
col += 1
|
|
2240
|
+
row += 1
|
|
2241
|
+
bottombox = QDialogButtonBox()
|
|
2242
|
+
bottombox.addButton(QDialogButtonBox.Ok)
|
|
2243
|
+
bottombox.addButton(QDialogButtonBox.Cancel)
|
|
2244
|
+
bottombox.accepted.connect(self.accept)
|
|
2245
|
+
bottombox.rejected.connect(self.reject)
|
|
2246
|
+
layout.addLayout(colorbox)
|
|
2247
|
+
layout.addWidget(bottombox)
|
|
2248
|
+
self.setLayout(layout)
|
|
2249
|
+
|
|
2250
|
+
def s_select(self, group, role):
|
|
2251
|
+
return lambda: self.select(group, role)
|
|
2252
|
+
|
|
2253
|
+
def select(self, group, role):
|
|
2254
|
+
self.colorString = str(group) + ',' + str(role)
|
|
2255
|
+
|
|
2256
|
+
@staticmethod
|
|
2257
|
+
def do(parent=None, default=None):
|
|
2258
|
+
dialog = ThemedColorPicker(parent, default)
|
|
2259
|
+
result = dialog.exec_()
|
|
2260
|
+
|
|
2261
|
+
if result == QDialog.Accepted:
|
|
2262
|
+
return dialog.colorString
|
|
2263
|
+
else:
|
|
2264
|
+
return None
|
|
2265
|
+
|
|
2266
|
+
class AccountDialog(QDialog):
|
|
1531
2267
|
selected = QtCore.pyqtSignal(int, bool)
|
|
1532
2268
|
aborted = QtCore.pyqtSignal()
|
|
1533
2269
|
|
|
1534
2270
|
def __init__(self, parent, accountman):
|
|
1535
|
-
|
|
2271
|
+
QDialog.__init__(self, parent)
|
|
1536
2272
|
|
|
1537
2273
|
self.accountman = accountman
|
|
1538
2274
|
|
|
1539
|
-
layout =
|
|
2275
|
+
layout = QVBoxLayout()
|
|
1540
2276
|
|
|
1541
2277
|
self.setWindowTitle('Select Account')
|
|
1542
2278
|
|
|
1543
2279
|
# Create list
|
|
1544
|
-
self.table =
|
|
2280
|
+
self.table = QTableWidget()
|
|
1545
2281
|
self.table.horizontalHeader().setHighlightSections(False)
|
|
1546
|
-
self.table.setSelectionMode(
|
|
1547
|
-
self.table.setSelectionBehavior(
|
|
1548
|
-
self.table.setEditTriggers(
|
|
2282
|
+
self.table.setSelectionMode(QAbstractItemView.SingleSelection)
|
|
2283
|
+
self.table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
|
2284
|
+
self.table.setEditTriggers(QAbstractItemView.NoEditTriggers)
|
|
1549
2285
|
self.table.verticalHeader().hide()
|
|
1550
2286
|
self.table.setGridStyle(QtCore.Qt.NoPen)
|
|
1551
2287
|
self.table.doubleClicked.connect(self.select)
|
|
1552
2288
|
|
|
1553
|
-
bottom_layout =
|
|
1554
|
-
self.remember_chk =
|
|
2289
|
+
bottom_layout = QHBoxLayout()
|
|
2290
|
+
self.remember_chk = QCheckBox('Remember')
|
|
1555
2291
|
if self.accountman.get_default() is not None:
|
|
1556
2292
|
self.remember_chk.setChecked(True)
|
|
1557
|
-
cancel_btn =
|
|
2293
|
+
cancel_btn = QPushButton('Cancel')
|
|
1558
2294
|
cancel_btn.clicked.connect(self.cancel)
|
|
1559
|
-
add_btn =
|
|
2295
|
+
add_btn = QPushButton('Add')
|
|
1560
2296
|
add_btn.clicked.connect(self.add)
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
2297
|
+
self.edit_btns = QComboBox()
|
|
2298
|
+
self.edit_btns.blockSignals(True)
|
|
2299
|
+
self.edit_btns.addItem('Edit...')
|
|
2300
|
+
self.edit_btns.addItem('Update')
|
|
2301
|
+
self.edit_btns.addItem('Delete')
|
|
2302
|
+
self.edit_btns.addItem('Purge')
|
|
2303
|
+
self.edit_btns.setItemData( 1, 'Change the local password/PIN for this account', QtCore.Qt.ToolTipRole)
|
|
2304
|
+
self.edit_btns.setItemData( 2, 'Remove this account from Trackma', QtCore.Qt.ToolTipRole)
|
|
2305
|
+
self.edit_btns.setItemData( 3, 'Clear local DB for this account', QtCore.Qt.ToolTipRole)
|
|
2306
|
+
self.edit_btns.setCurrentIndex(0)
|
|
2307
|
+
self.edit_btns.blockSignals(False)
|
|
2308
|
+
self.edit_btns.activated.connect(self.s_edit)
|
|
2309
|
+
select_btn = QPushButton('Select')
|
|
1564
2310
|
select_btn.clicked.connect(self.select)
|
|
1565
2311
|
bottom_layout.addWidget(self.remember_chk) #, 1, QtCore.Qt.AlignRight)
|
|
1566
2312
|
bottom_layout.addWidget(cancel_btn)
|
|
1567
2313
|
bottom_layout.addWidget(add_btn)
|
|
1568
|
-
bottom_layout.addWidget(
|
|
2314
|
+
bottom_layout.addWidget(self.edit_btns)
|
|
1569
2315
|
bottom_layout.addWidget(select_btn)
|
|
1570
2316
|
|
|
1571
2317
|
# Get icons
|
|
1572
2318
|
self.icons = dict()
|
|
1573
2319
|
for libname, lib in utils.available_libs.iteritems():
|
|
1574
|
-
self.icons[libname] =
|
|
2320
|
+
self.icons[libname] = QIcon(lib[1])
|
|
1575
2321
|
|
|
1576
2322
|
# Populate list
|
|
1577
2323
|
self.rebuild()
|
|
@@ -1588,17 +2334,55 @@ class AccountDialog(QtGui.QDialog):
|
|
|
1588
2334
|
self.accountman.add_account(username, password, api)
|
|
1589
2335
|
self.rebuild()
|
|
1590
2336
|
|
|
2337
|
+
def edit(self):
|
|
2338
|
+
self.edit_btns.blockSignals(True)
|
|
2339
|
+
self.edit_btns.setCurrentIndex(0)
|
|
2340
|
+
self.edit_btns.blockSignals(False)
|
|
2341
|
+
try:
|
|
2342
|
+
selected_account_num = self.table.selectedItems()[0].num
|
|
2343
|
+
acct = self.accountman.get_account(selected_account_num)
|
|
2344
|
+
result = AccountAddDialog.do(icons=self.icons,
|
|
2345
|
+
edit=True,
|
|
2346
|
+
username=acct['username'],
|
|
2347
|
+
password=acct['password'],
|
|
2348
|
+
api=acct['api'])
|
|
2349
|
+
if result:
|
|
2350
|
+
(username, password, api) = result
|
|
2351
|
+
self.accountman.edit_account(selected_account_num, username, password, api)
|
|
2352
|
+
self.rebuild()
|
|
2353
|
+
except IndexError:
|
|
2354
|
+
self._error("Please select an account.")
|
|
2355
|
+
|
|
1591
2356
|
def delete(self):
|
|
1592
2357
|
try:
|
|
1593
2358
|
selected_account_num = self.table.selectedItems()[0].num
|
|
1594
|
-
reply =
|
|
2359
|
+
reply = QMessageBox.question(self, 'Confirmation', 'Do you want to delete the selected account?', QMessageBox.Yes, QMessageBox.No)
|
|
1595
2360
|
|
|
1596
|
-
if reply ==
|
|
2361
|
+
if reply == QMessageBox.Yes:
|
|
1597
2362
|
self.accountman.delete_account(selected_account_num)
|
|
1598
2363
|
self.rebuild()
|
|
1599
2364
|
except IndexError:
|
|
1600
2365
|
self._error("Please select an account.")
|
|
1601
2366
|
|
|
2367
|
+
def purge(self):
|
|
2368
|
+
try:
|
|
2369
|
+
selected_account_num = self.table.selectedItems()[0].num
|
|
2370
|
+
reply = QMessageBox.question(self, 'Confirmation', 'Do you want to purge the selected account\'s local data?', QMessageBox.Yes, QMessageBox.No)
|
|
2371
|
+
|
|
2372
|
+
if reply == QMessageBox.Yes:
|
|
2373
|
+
self.accountman.purge_account(selected_account_num)
|
|
2374
|
+
self.rebuild()
|
|
2375
|
+
except IndexError:
|
|
2376
|
+
self._error("Please select an account.")
|
|
2377
|
+
|
|
2378
|
+
def s_edit(self, index):
|
|
2379
|
+
if index is 1:
|
|
2380
|
+
self.edit()
|
|
2381
|
+
elif index is 2:
|
|
2382
|
+
self.delete()
|
|
2383
|
+
elif index is 3:
|
|
2384
|
+
self.purge()
|
|
2385
|
+
|
|
1602
2386
|
def rebuild(self):
|
|
1603
2387
|
self.table.clear()
|
|
1604
2388
|
|
|
@@ -1616,7 +2400,10 @@ class AccountDialog(QtGui.QDialog):
|
|
|
1616
2400
|
|
|
1617
2401
|
i += 1
|
|
1618
2402
|
|
|
1619
|
-
|
|
2403
|
+
if pyqt_version is 5:
|
|
2404
|
+
self.table.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch)
|
|
2405
|
+
else:
|
|
2406
|
+
self.table.horizontalHeader().setResizeMode(0, QHeaderView.Stretch)
|
|
1620
2407
|
|
|
1621
2408
|
def select(self, checked):
|
|
1622
2409
|
try:
|
|
@@ -1631,9 +2418,9 @@ class AccountDialog(QtGui.QDialog):
|
|
|
1631
2418
|
self.close()
|
|
1632
2419
|
|
|
1633
2420
|
def _error(self, msg):
|
|
1634
|
-
|
|
2421
|
+
QMessageBox.critical(self, 'Error', msg, QMessageBox.Ok)
|
|
1635
2422
|
|
|
1636
|
-
class AccountItem(
|
|
2423
|
+
class AccountItem(QTableWidgetItem):
|
|
1637
2424
|
"""
|
|
1638
2425
|
Regular item able to save account item
|
|
1639
2426
|
|
|
@@ -1641,27 +2428,39 @@ class AccountItem(QtGui.QTableWidgetItem):
|
|
|
1641
2428
|
num = None
|
|
1642
2429
|
|
|
1643
2430
|
def __init__(self, num, text, icon=None):
|
|
1644
|
-
|
|
2431
|
+
QTableWidgetItem.__init__(self, text)
|
|
1645
2432
|
self.num = num
|
|
1646
2433
|
if icon:
|
|
1647
2434
|
self.setIcon( icon )
|
|
1648
2435
|
|
|
1649
|
-
class
|
|
2436
|
+
class ShowsTableWidget(QTableWidget):
|
|
2437
|
+
"""
|
|
2438
|
+
Regular table widget with context menu for show actions.
|
|
2439
|
+
|
|
2440
|
+
"""
|
|
2441
|
+
def __init__(self, parent = None):
|
|
2442
|
+
QTableWidget.__init__(self, parent)
|
|
2443
|
+
|
|
2444
|
+
def contextMenuEvent(self, event):
|
|
2445
|
+
action = self.context_menu.exec_(event.globalPos())
|
|
2446
|
+
|
|
2447
|
+
class ShowItem(QTableWidgetItem):
|
|
1650
2448
|
"""
|
|
1651
2449
|
Regular item able to show colors and alignment
|
|
1652
2450
|
|
|
1653
2451
|
"""
|
|
1654
2452
|
|
|
1655
|
-
def __init__(self, text, color=None):
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
2453
|
+
def __init__(self, text, color=None, alignment=None):
|
|
2454
|
+
QTableWidgetItem.__init__(self, text)
|
|
2455
|
+
if alignment:
|
|
2456
|
+
self.setTextAlignment( alignment )
|
|
1659
2457
|
if color:
|
|
1660
|
-
self.
|
|
2458
|
+
self.setBackground( color )
|
|
1661
2459
|
|
|
1662
2460
|
class ShowItemNum(ShowItem):
|
|
1663
2461
|
def __init__(self, num, text, color=None):
|
|
1664
2462
|
ShowItem.__init__(self, text, color)
|
|
2463
|
+
self.setTextAlignment(QtCore.Qt.AlignHCenter)
|
|
1665
2464
|
self.num = num
|
|
1666
2465
|
|
|
1667
2466
|
def __lt__(self, other):
|
|
@@ -1670,13 +2469,16 @@ class ShowItemNum(ShowItem):
|
|
|
1670
2469
|
class ShowItemDate(ShowItem):
|
|
1671
2470
|
def __init__(self, date, color=None):
|
|
1672
2471
|
if date:
|
|
1673
|
-
|
|
2472
|
+
try:
|
|
2473
|
+
datestr = date.strftime("%Y-%m-%d")
|
|
2474
|
+
except ValueError:
|
|
2475
|
+
datestr = '?'
|
|
1674
2476
|
else:
|
|
1675
2477
|
datestr = '-'
|
|
1676
2478
|
|
|
1677
2479
|
self.date = date
|
|
1678
2480
|
|
|
1679
|
-
ShowItem.__init__(self, datestr, color)
|
|
2481
|
+
ShowItem.__init__(self, datestr, color, QtCore.Qt.AlignHCenter)
|
|
1680
2482
|
|
|
1681
2483
|
def __lt__(self, other):
|
|
1682
2484
|
if self.date and other.date:
|
|
@@ -1684,44 +2486,99 @@ class ShowItemDate(ShowItem):
|
|
|
1684
2486
|
else:
|
|
1685
2487
|
return True
|
|
1686
2488
|
|
|
1687
|
-
class
|
|
2489
|
+
class FilterBar(object):
|
|
2490
|
+
"""
|
|
2491
|
+
Constants relating to filter bar settings can live here.
|
|
2492
|
+
"""
|
|
2493
|
+
# Position
|
|
2494
|
+
PositionHidden = 0
|
|
2495
|
+
PositionAboveLists = 1
|
|
2496
|
+
PositionBelowLists = 2
|
|
2497
|
+
|
|
2498
|
+
class EpisodeBar(QProgressBar):
|
|
1688
2499
|
"""
|
|
1689
2500
|
Custom progress bar to show detailed information
|
|
1690
2501
|
about episodes
|
|
1691
2502
|
"""
|
|
2503
|
+
# Enum BarStyle
|
|
2504
|
+
BarStyleBasic = 0 # Basic native ProgressBar appearance
|
|
2505
|
+
BarStyle04 = 1 # Rectangular dual bar of Trackma v0.4
|
|
2506
|
+
BarStyleHybrid = 2 # Native ProgressBar with v0.4 library subbar overlaid
|
|
2507
|
+
|
|
1692
2508
|
_subvalue = -1
|
|
1693
2509
|
_episodes = []
|
|
1694
2510
|
_subheight = 5
|
|
2511
|
+
_bar_style = BarStyle04
|
|
2512
|
+
_show_text = False
|
|
1695
2513
|
|
|
1696
|
-
def __init__(self, parent=None):
|
|
1697
|
-
QtGui.QProgressBar.__init__(self, parent)
|
|
1698
2514
|
|
|
1699
|
-
def
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
painter.setBrush( QtGui.QColor(245, 245, 245) )
|
|
1703
|
-
painter.setPen(QtCore.Qt.transparent)
|
|
1704
|
-
painter.drawRect( QtCore.QRect(0, 0, self.width(), self.height()) )
|
|
2515
|
+
def __init__(self, parent, colors):
|
|
2516
|
+
QProgressBar.__init__(self, parent)
|
|
2517
|
+
self.colors = colors
|
|
1705
2518
|
|
|
2519
|
+
def paintEvent(self, event):
|
|
2520
|
+
rect = QtCore.QRect(0,0,self.width(), self.height())
|
|
2521
|
+
|
|
2522
|
+
if self._bar_style is self.BarStyleBasic:
|
|
2523
|
+
painter = QtGui.QPainter(self)
|
|
2524
|
+
prog_options = QtGui.QStyleOptionProgressBarV2()
|
|
2525
|
+
prog_options.maximum = self.maximum()
|
|
2526
|
+
prog_options.progress = self.value()
|
|
2527
|
+
prog_options.rect = rect
|
|
2528
|
+
prog_options.text = '%d%%' % (self.value()*100/self.maximum())
|
|
2529
|
+
prog_options.textVisible = self._show_text
|
|
2530
|
+
self.style().drawControl(QStyle.CE_ProgressBar, prog_options, painter)
|
|
2531
|
+
|
|
2532
|
+
elif self._bar_style is self.BarStyle04:
|
|
2533
|
+
painter = QtGui.QPainter(self)
|
|
2534
|
+
painter.setBrush( getColor(self.colors['progress_bg']) )
|
|
2535
|
+
painter.setPen(QtCore.Qt.transparent)
|
|
2536
|
+
painter.drawRect( rect )
|
|
2537
|
+
self.paintSubValue(painter)
|
|
2538
|
+
if self.value() > 0:
|
|
2539
|
+
if self.value() >= self.maximum():
|
|
2540
|
+
painter.setBrush( getColor(self.colors['progress_complete']) )
|
|
2541
|
+
mid = self.width()
|
|
2542
|
+
else:
|
|
2543
|
+
painter.setBrush( getColor(self.colors['progress_fg']) )
|
|
2544
|
+
mid = int(self.width() / float(self.maximum()) * self.value())
|
|
2545
|
+
progressRect = QtCore.QRect(0, 0, mid, self.height())
|
|
2546
|
+
painter.drawRect(progressRect)
|
|
2547
|
+
self.paintEpisodes(painter)
|
|
2548
|
+
|
|
2549
|
+
elif self._bar_style is self.BarStyleHybrid:
|
|
2550
|
+
buffer = QtGui.QImage(self.width(), self.height(), QtGui.QImage.Format_ARGB32_Premultiplied)
|
|
2551
|
+
painter = QtGui.QPainter(buffer)
|
|
2552
|
+
painter.setCompositionMode(QtGui.QPainter.CompositionMode_Source)
|
|
2553
|
+
painter.fillRect(rect, QtCore.Qt.transparent)
|
|
2554
|
+
painter.setCompositionMode(QtGui.QPainter.CompositionMode_SourceOver)
|
|
2555
|
+
prog_options = QtGui.QStyleOptionProgressBarV2()
|
|
2556
|
+
prog_options.maximum = self.maximum()
|
|
2557
|
+
prog_options.progress = self.value()
|
|
2558
|
+
prog_options.rect = rect
|
|
2559
|
+
prog_options.text = '%d%%' % (self.value()*100/self.maximum())
|
|
2560
|
+
self.style().drawControl(QStyle.CE_ProgressBar, prog_options, painter)
|
|
2561
|
+
painter.setCompositionMode(QtGui.QPainter.CompositionMode_SourceAtop)
|
|
2562
|
+
painter.setPen(QtCore.Qt.transparent)
|
|
2563
|
+
self.paintSubValue(painter)
|
|
2564
|
+
self.paintEpisodes(painter)
|
|
2565
|
+
painter = QtGui.QPainter(self)
|
|
2566
|
+
painter.setCompositionMode(QtGui.QPainter.CompositionMode_SourceOver)
|
|
2567
|
+
painter.drawImage(rect, buffer)
|
|
2568
|
+
if self._show_text:
|
|
2569
|
+
self.style().drawControl(QStyle.CE_ProgressBarLabel, prog_options, painter)
|
|
2570
|
+
|
|
2571
|
+
def paintSubValue(self, painter):
|
|
1706
2572
|
if self.subValue() > 0:
|
|
1707
|
-
painter.setBrush(
|
|
2573
|
+
painter.setBrush( getColor(self.colors['progress_sub_bg']) )
|
|
1708
2574
|
mid = int(self.width() / float(self.maximum()) * self.subValue())
|
|
1709
2575
|
progressRect = QtCore.QRect(0, self.height()-self._subheight, mid, self.height()-(self.height()-self._subheight))
|
|
1710
2576
|
painter.drawRect(progressRect)
|
|
1711
2577
|
|
|
1712
|
-
|
|
1713
|
-
if self.value() >= self.maximum():
|
|
1714
|
-
painter.setBrush( QtGui.QColor(0,210,0) )
|
|
1715
|
-
mid = self.width()
|
|
1716
|
-
else:
|
|
1717
|
-
painter.setBrush( QtGui.QColor(116, 192, 250) )
|
|
1718
|
-
mid = int(self.width() / float(self.maximum()) * self.value())
|
|
1719
|
-
progressRect = QtCore.QRect(0, 0, mid, self.height())
|
|
1720
|
-
painter.drawRect(progressRect)
|
|
1721
|
-
|
|
2578
|
+
def paintEpisodes(self, painter):
|
|
1722
2579
|
if self.episodes():
|
|
1723
2580
|
for episode in self.episodes():
|
|
1724
|
-
painter.setBrush(
|
|
2581
|
+
painter.setBrush( getColor(self.colors['progress_sub_fg']) )
|
|
1725
2582
|
if episode <= self.maximum():
|
|
1726
2583
|
start = int(self.width() / float(self.maximum()) * (episode -1))
|
|
1727
2584
|
finish = int(self.width() / float(self.maximum()) * episode)
|
|
@@ -1746,36 +2603,41 @@ class EpisodeBar(QtGui.QProgressBar):
|
|
|
1746
2603
|
def episodes(self):
|
|
1747
2604
|
return self._episodes
|
|
1748
2605
|
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
2606
|
+
def setBarStyle(self, style, show_text):
|
|
2607
|
+
self._bar_style = style
|
|
2608
|
+
self._show_text = show_text
|
|
2609
|
+
|
|
2610
|
+
class AccountAddDialog(QDialog):
|
|
2611
|
+
def __init__(self, parent, icons, edit=False, username='', password='', api=''):
|
|
2612
|
+
QDialog.__init__(self, parent)
|
|
2613
|
+
self.edit = edit
|
|
1752
2614
|
|
|
1753
2615
|
# Build UI
|
|
1754
|
-
layout =
|
|
2616
|
+
layout = QVBoxLayout()
|
|
1755
2617
|
|
|
1756
|
-
formlayout =
|
|
1757
|
-
self.lbl_username =
|
|
1758
|
-
self.username =
|
|
2618
|
+
formlayout = QFormLayout()
|
|
2619
|
+
self.lbl_username = QLabel('Username:')
|
|
2620
|
+
self.username = QLineEdit(username)
|
|
1759
2621
|
|
|
1760
|
-
pin_layout =
|
|
1761
|
-
self.lbl_password =
|
|
1762
|
-
self.password =
|
|
1763
|
-
self.api =
|
|
2622
|
+
pin_layout = QHBoxLayout()
|
|
2623
|
+
self.lbl_password = QLabel('Password:')
|
|
2624
|
+
self.password = QLineEdit(password)
|
|
2625
|
+
self.api = QComboBox()
|
|
1764
2626
|
self.api.currentIndexChanged.connect(self.s_refresh)
|
|
1765
|
-
self.api_auth =
|
|
2627
|
+
self.api_auth = QLabel('Request PIN')
|
|
1766
2628
|
self.api_auth.setTextFormat(QtCore.Qt.RichText)
|
|
1767
2629
|
self.api_auth.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
|
|
1768
2630
|
self.api_auth.setOpenExternalLinks(True)
|
|
1769
2631
|
pin_layout.addWidget(self.password)
|
|
1770
2632
|
pin_layout.addWidget(self.api_auth)
|
|
1771
2633
|
|
|
1772
|
-
formlayout.addRow(
|
|
2634
|
+
formlayout.addRow( QLabel('Site:'), self.api )
|
|
1773
2635
|
formlayout.addRow( self.lbl_username, self.username )
|
|
1774
2636
|
formlayout.addRow( self.lbl_password, pin_layout )
|
|
1775
2637
|
|
|
1776
|
-
bottombox =
|
|
1777
|
-
bottombox.addButton(
|
|
1778
|
-
bottombox.addButton(
|
|
2638
|
+
bottombox = QDialogButtonBox()
|
|
2639
|
+
bottombox.addButton(QDialogButtonBox.Save)
|
|
2640
|
+
bottombox.addButton(QDialogButtonBox.Cancel)
|
|
1779
2641
|
bottombox.accepted.connect(self.validate)
|
|
1780
2642
|
bottombox.rejected.connect(self.reject)
|
|
1781
2643
|
|
|
@@ -1783,6 +2645,11 @@ class AccountAddDialog(QtGui.QDialog):
|
|
|
1783
2645
|
for libname, lib in sorted(utils.available_libs.iteritems()):
|
|
1784
2646
|
self.api.addItem(icons[libname], lib[0], libname)
|
|
1785
2647
|
|
|
2648
|
+
if self.edit:
|
|
2649
|
+
self.username.setEnabled(False)
|
|
2650
|
+
self.api.setCurrentIndex(self.api.findData(api, QtCore.Qt.UserRole))
|
|
2651
|
+
self.api.setEnabled(False)
|
|
2652
|
+
|
|
1786
2653
|
# Finish layouts
|
|
1787
2654
|
layout.addLayout(formlayout)
|
|
1788
2655
|
layout.addWidget(bottombox)
|
|
@@ -1790,46 +2657,55 @@ class AccountAddDialog(QtGui.QDialog):
|
|
|
1790
2657
|
self.setLayout(layout)
|
|
1791
2658
|
|
|
1792
2659
|
def validate(self):
|
|
1793
|
-
if len(self.username.text())
|
|
1794
|
-
self.
|
|
2660
|
+
if len(self.username.text()) is 0:
|
|
2661
|
+
if len(self.password.text()) is 0:
|
|
2662
|
+
self._error('Please fill the credentials fields.')
|
|
2663
|
+
else:
|
|
2664
|
+
self._error('Please fill the username field.')
|
|
2665
|
+
elif len(self.password.text()) is 0:
|
|
2666
|
+
self._error('Please fill the password/PIN field.')
|
|
1795
2667
|
else:
|
|
1796
|
-
self.
|
|
2668
|
+
self.accept()
|
|
1797
2669
|
|
|
1798
2670
|
def s_refresh(self, index):
|
|
1799
|
-
self.
|
|
1800
|
-
|
|
2671
|
+
if not self.edit:
|
|
2672
|
+
self.username.setText("")
|
|
2673
|
+
self.password.setText("")
|
|
1801
2674
|
|
|
1802
|
-
|
|
2675
|
+
if pyqt_version is 5:
|
|
2676
|
+
apiname = self.api.itemData(index)
|
|
2677
|
+
else:
|
|
2678
|
+
apiname = str(self.api.itemData(index))
|
|
1803
2679
|
api = utils.available_libs[apiname]
|
|
1804
2680
|
if api[2] == utils.LOGIN_OAUTH:
|
|
1805
|
-
apiname = str(self.api.itemData(index)
|
|
2681
|
+
apiname = str(self.api.itemData(index))
|
|
1806
2682
|
url = utils.available_libs[apiname][4]
|
|
1807
2683
|
self.api_auth.setText( "<a href=\"{}\">Request PIN</a>".format(url) )
|
|
1808
2684
|
self.api_auth.show()
|
|
1809
2685
|
|
|
1810
2686
|
self.lbl_username.setText('Name:')
|
|
1811
2687
|
self.lbl_password.setText('PIN:')
|
|
1812
|
-
self.password.setEchoMode(
|
|
2688
|
+
self.password.setEchoMode(QLineEdit.Normal)
|
|
1813
2689
|
else:
|
|
1814
2690
|
self.lbl_username.setText('Username:')
|
|
1815
2691
|
self.lbl_password.setText('Password:')
|
|
1816
|
-
self.password.setEchoMode(
|
|
2692
|
+
self.password.setEchoMode(QLineEdit.Password)
|
|
1817
2693
|
self.api_auth.hide()
|
|
1818
2694
|
|
|
1819
2695
|
def _error(self, msg):
|
|
1820
|
-
|
|
2696
|
+
QMessageBox.critical(self, 'Error', msg, QMessageBox.Ok)
|
|
1821
2697
|
|
|
1822
2698
|
@staticmethod
|
|
1823
|
-
def do(parent=None, icons=None):
|
|
1824
|
-
dialog = AccountAddDialog(parent, icons)
|
|
2699
|
+
def do(parent=None, icons=None, edit=False, username='', password='', api=''):
|
|
2700
|
+
dialog = AccountAddDialog(parent, icons, edit, username, password, api)
|
|
1825
2701
|
result = dialog.exec_()
|
|
1826
2702
|
|
|
1827
|
-
if result ==
|
|
2703
|
+
if result == QDialog.Accepted:
|
|
1828
2704
|
currentIndex = dialog.api.currentIndex()
|
|
1829
2705
|
return (
|
|
1830
|
-
str(
|
|
1831
|
-
str(
|
|
1832
|
-
str(
|
|
2706
|
+
str(dialog.username.text()),
|
|
2707
|
+
str(dialog.password.text()),
|
|
2708
|
+
str(dialog.api.itemData(currentIndex))
|
|
1833
2709
|
)
|
|
1834
2710
|
else:
|
|
1835
2711
|
return None
|
|
@@ -1903,6 +2779,7 @@ class Engine_Worker(QtCore.QThread):
|
|
|
1903
2779
|
self.engine = Engine(account, self._messagehandler)
|
|
1904
2780
|
self.engine.connect_signal('episode_changed', self._changed_show)
|
|
1905
2781
|
self.engine.connect_signal('score_changed', self._changed_show)
|
|
2782
|
+
self.engine.connect_signal('tags_changed', self._changed_show)
|
|
1906
2783
|
self.engine.connect_signal('status_changed', self._changed_list)
|
|
1907
2784
|
self.engine.connect_signal('playing', self._playing_show)
|
|
1908
2785
|
self.engine.connect_signal('show_added', self._changed_list)
|
|
@@ -1918,7 +2795,9 @@ class Engine_Worker(QtCore.QThread):
|
|
|
1918
2795
|
'set_episode': self._set_episode,
|
|
1919
2796
|
'set_score': self._set_score,
|
|
1920
2797
|
'set_status': self._set_status,
|
|
2798
|
+
'set_tags': self._set_tags,
|
|
1921
2799
|
'play_episode': self._play_episode,
|
|
2800
|
+
'play_random': self._play_random,
|
|
1922
2801
|
'list_download': self._list_download,
|
|
1923
2802
|
'list_upload': self._list_upload,
|
|
1924
2803
|
'get_show_details': self._get_show_details,
|
|
@@ -1938,7 +2817,7 @@ class Engine_Worker(QtCore.QThread):
|
|
|
1938
2817
|
def _fatal(self, msg):
|
|
1939
2818
|
self.raised_fatal.emit(msg)
|
|
1940
2819
|
|
|
1941
|
-
def _changed_show(self, show):
|
|
2820
|
+
def _changed_show(self, show, changes=None):
|
|
1942
2821
|
self.changed_show.emit(show)
|
|
1943
2822
|
|
|
1944
2823
|
def _changed_list(self, show, old_status=None):
|
|
@@ -2027,6 +2906,15 @@ class Engine_Worker(QtCore.QThread):
|
|
|
2027
2906
|
|
|
2028
2907
|
return {'success': True}
|
|
2029
2908
|
|
|
2909
|
+
def _set_tags(self, showid, tags):
|
|
2910
|
+
try:
|
|
2911
|
+
self.engine.set_tags(showid, tags)
|
|
2912
|
+
except utils.TrackmaError, e:
|
|
2913
|
+
self._error(e.message)
|
|
2914
|
+
return {'success': False}
|
|
2915
|
+
|
|
2916
|
+
return {'success': True}
|
|
2917
|
+
|
|
2030
2918
|
def _play_episode(self, show, episode):
|
|
2031
2919
|
try:
|
|
2032
2920
|
played_ep = self.engine.play_episode(show, episode)
|
|
@@ -2036,6 +2924,15 @@ class Engine_Worker(QtCore.QThread):
|
|
|
2036
2924
|
|
|
2037
2925
|
return {'success': True, 'show': show, 'played_ep': played_ep}
|
|
2038
2926
|
|
|
2927
|
+
def _play_random(self):
|
|
2928
|
+
try:
|
|
2929
|
+
(show, ep) = self.engine.play_random()
|
|
2930
|
+
except utils.TrackmaError, e:
|
|
2931
|
+
self._error(e.message)
|
|
2932
|
+
return {'success': False}
|
|
2933
|
+
|
|
2934
|
+
return {'success': True, 'played_show': show, 'played_ep': ep}
|
|
2935
|
+
|
|
2039
2936
|
def _list_download(self):
|
|
2040
2937
|
try:
|
|
2041
2938
|
self.engine.list_download()
|
|
@@ -2072,9 +2969,9 @@ class Engine_Worker(QtCore.QThread):
|
|
|
2072
2969
|
|
|
2073
2970
|
return {'success': True, 'results': results}
|
|
2074
2971
|
|
|
2075
|
-
def _add_show(self, show):
|
|
2972
|
+
def _add_show(self, show, status):
|
|
2076
2973
|
try:
|
|
2077
|
-
results = self.engine.add_show(show)
|
|
2974
|
+
results = self.engine.add_show(show, status)
|
|
2078
2975
|
except utils.TrackmaError, e:
|
|
2079
2976
|
self._error(e.message)
|
|
2080
2977
|
return {'success': False}
|
|
@@ -2114,7 +3011,26 @@ class Engine_Worker(QtCore.QThread):
|
|
|
2114
3011
|
except utils.TrackmaFatal, e:
|
|
2115
3012
|
self._fatal(e.message)
|
|
2116
3013
|
|
|
3014
|
+
def getIcon(icon_name):
|
|
3015
|
+
fallback = QIcon(utils.datadir + '/data/qtui/{}.png'.format(icon_name))
|
|
3016
|
+
return QIcon.fromTheme(icon_name, fallback)
|
|
3017
|
+
|
|
3018
|
+
def getColor(colorString):
|
|
3019
|
+
# Takes a color string in either #RRGGBB format or group,role format (using QPalette int values)
|
|
3020
|
+
if colorString[0] == "#":
|
|
3021
|
+
return QtGui.QColor(colorString)
|
|
3022
|
+
else:
|
|
3023
|
+
(group, role) = [int(i) for i in colorString.split(',')]
|
|
3024
|
+
if (0 <= group <= 2) and (0 <= role <= 19):
|
|
3025
|
+
return QtGui.QColor( QPalette().color(group, role) )
|
|
3026
|
+
else:
|
|
3027
|
+
# Failsafe - return black
|
|
3028
|
+
return QtGui.QColor()
|
|
3029
|
+
|
|
2117
3030
|
def main():
|
|
2118
|
-
app =
|
|
2119
|
-
|
|
2120
|
-
|
|
3031
|
+
app = QApplication(sys.argv)
|
|
3032
|
+
try:
|
|
3033
|
+
mainwindow = Trackma()
|
|
3034
|
+
sys.exit(app.exec_())
|
|
3035
|
+
except utils.TrackmaFatal, e:
|
|
3036
|
+
QMessageBox.critical(None, 'Fatal Error', "{0}".format(e.message), QMessageBox.Ok)
|