Skip to content

Commit

Permalink
1.7.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
noembryo committed Jan 13, 2024
1 parent 853c350 commit 74ec2c6
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 57 deletions.
11 changes: 6 additions & 5 deletions boot_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
PORTABLE = False
PYTHON2 = sys.version_info < (3, 0)

USE_QT6 = True # select between PySide2/Qt5 and Pyside6/Qt6 if both are installed

if PYTHON2:
from io import open
from codecs import open as c_open
Expand All @@ -22,20 +24,19 @@
# noinspection PyShadowingBuiltins
unicode, basestring = str, str
c_open = open
try:
from PySide2.QtCore import qVersion
except ImportError:
if USE_QT6:
from PySide6.QtCore import qVersion
else:
from PySide2.QtCore import qVersion

USE_QT6 = False # select between PySide2/Qt5 and Pyside6/Qt6 if both are installed
# noinspection PyTypeChecker
qt_version = qVersion().split(".")[0]
QT4 = qt_version == "4"
QT5 = qt_version == "5"
QT6 = qt_version == "6"
if QT6 and QT5:
if USE_QT6:
USE_QT5 = False
QT5 = False

if sys.platform == "win32": # Windows
import win32api
Expand Down
21 changes: 0 additions & 21 deletions images_rc.py

This file was deleted.

52 changes: 29 additions & 23 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from datetime import datetime
from functools import partial
from collections import defaultdict
from distutils.version import LooseVersion
from os.path import (isdir, isfile, join, basename, splitext, dirname, split, getmtime,
abspath, splitdrive)
from pprint import pprint
Expand Down Expand Up @@ -46,12 +45,14 @@

if PYTHON2: # ___ __________ PYTHON 2/3 COMPATIBILITY ______________
import cPickle as pickle
from distutils.version import LooseVersion as version_parse
else:
from packaging.version import parse as version_parse
import pickle


__author__ = "noEmbryo"
__version__ = "1.7.4.0"
__version__ = "1.7.5.0"


# if sys.platform.lower().startswith("win"):
Expand Down Expand Up @@ -351,8 +352,8 @@ def init_db(self):
print("Could not open database!")
return
self.query = QSqlQuery()
# if QT6:
# self.query.exec_ = self.query.exec
if QT6: # QT6 requires exec() instead of exec_()
self.query.exec_ = getattr(self.query, "exec")
if app_config:
pass
# self.query.exec_("""PRAGMA user_version""") # 2do: enable if db changes
Expand All @@ -361,17 +362,17 @@ def init_db(self):
self.set_db_version() if not isfile(self.db_path) else None
self.create_books_table()

def check_db_version(self, version):
def check_db_version(self, db_version):
""" Updates the db to the last version
:type version: int
:param version: The db file version
:type db_version: int
:param db_version: The db file version
"""
if version == DB_VERSION or not isfile(self.db_path):
if db_version == DB_VERSION or not isfile(self.db_path):
return # the db is up to date or does not exists yet
self.update_db(version)
self.update_db(db_version)

def update_db(self, version):
def update_db(self, db_version):
""" Updates the db to the last version"""
pass

Expand Down Expand Up @@ -612,8 +613,8 @@ def on_file_table_customContextMenuRequested(self, point):
return

menu = QMenu(self.file_table)
# if QT6:
# menu.exec_ = menu.exec
if QT6: # QT6 requires exec() instead of exec_()
menu.exec_ = getattr(menu, "exec")

row = self.file_table.itemAt(point).row()
self.act_view_book.setEnabled(self.toolbar.open_btn.isEnabled())
Expand Down Expand Up @@ -769,8 +770,8 @@ def on_column_right_clicked(self, pos):
name = self.file_table.horizontalHeaderItem(column).text()
if name == _("Title"):
menu = QMenu(self)
# if QT6:
# menu.exec_ = menu.exec
if QT6: # QT6 requires exec() instead of exec_()
menu.exec_ = getattr(menu, "exec")

action = QAction(_("Ignore english articles"), menu)
action.setCheckable(True)
Expand Down Expand Up @@ -1088,8 +1089,8 @@ def on_high_table_customContextMenuRequested(self, point):
return

menu = QMenu(self.high_table)
# if QT6:
# menu.exec_ = menu.exec
if QT6: # QT6 requires exec() instead of exec_()
menu.exec_ = getattr(menu, "exec")

row = self.high_table.itemAt(point).row()
self.act_view_book.setData(row)
Expand Down Expand Up @@ -1304,12 +1305,11 @@ def find_in_books(self, highlight):
self.toolbar.books_view_btn.setChecked(True)
self.toolbar.setup_buttons()
self.toolbar.activate_buttons()

self.file_table.selectRow(row) # select the book
self.on_file_table_itemClicked(item)
for high_row in range(self.high_list.count()): # find the highlight
if (self.high_list.item(high_row)
.data(Qt.UserRole)[HIGHLIGHT_TEXT] == highlight):
.data(Qt.UserRole)["text"] == highlight):
self.high_list.setCurrentRow(high_row) # select the highlight
return
except KeyError: # old metadata with no "stats"
Expand Down Expand Up @@ -1419,8 +1419,8 @@ def on_high_list_customContextMenuRequested(self, point):
"""
if self.sel_high_list:
menu = QMenu(self.high_list)
# if QT6:
# menu.exec_ = menu.exec
if QT6: # QT6 requires exec() instead of exec_()
menu.exec_ = getattr(menu, "exec")

action = QAction(_("Comments"), menu)
action.triggered.connect(self.on_edit_comment)
Expand Down Expand Up @@ -2569,6 +2569,8 @@ def popup(self, title, text, icon=QMessageBox.Warning, buttons=1,
elif input_text: # Show input QLineEdit
popup.set_input(input_text)

if QT6: # QT6 requires exec() instead of exec_()
popup.exec_ = getattr(popup, "exec")
popup.exec_()
return popup

Expand Down Expand Up @@ -2700,9 +2702,11 @@ def auto_check4update(self):
return
if not version_new:
return
version = LooseVersion(self.version)
skip_version = LooseVersion(self.skip_version)
if version_new > version and version_new != skip_version:
# current_version = LooseVersion(self.version)
# skip_version = LooseVersion(self.skip_version)
current_version = version_parse(self.version)
skip_version = version_parse(self.skip_version)
if version_new > current_version and version_new != skip_version:
popup = self.popup(_("Newer version exists!"),
_("There is a newer version (v.{}) online.\n"
"Open the site to download it now?")
Expand Down Expand Up @@ -2801,6 +2805,8 @@ def __init__(self, *args, **kwargs):
# else:
# self.parse_args()
self.base.setWindowTitle(APP_NAME + " portable" if PORTABLE else APP_NAME)
if QT6: # QT6 requires exec() instead of exec_()
self.exec_ = getattr(self, "exec")
self.exec_()
self.deleteLater() # avoids some QThread messages in the shell on exit
# show_console() if on_windows and compiled else None
Expand Down
26 changes: 18 additions & 8 deletions secondary.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import re
import webbrowser
from functools import partial
from distutils.version import LooseVersion
from os.path import join, basename, splitext, isfile
from pprint import pprint

Expand All @@ -27,6 +26,11 @@
QLineEdit, QToolButton, QWidget, QMenu, QFileDialog,
QDialog, QMessageBox, QCheckBox)

if PYTHON2: # ___ __________ PYTHON 2/3 COMPATIBILITY ______________
from distutils.version import LooseVersion as version_parse
else:
from packaging.version import parse as version_parse

import requests
from bs4 import BeautifulSoup
from slppu import slppu as lua # https://github.com/noembryo/slppu
Expand Down Expand Up @@ -541,6 +545,8 @@ def create_size_menu(self):
action.triggered.connect(partial(self.set_btn_size, size))
group.addAction(action)
menu.addAction(action)
if QT6: # QT6 requires exec() instead of exec_()
menu.exec_ = getattr(menu, "exec")
return menu

def set_btn_size(self, size):
Expand Down Expand Up @@ -671,6 +677,8 @@ def create_db_menu(self):
action.setIcon(self.base.ico_db_open)
action.triggered.connect(partial(self.base.change_db, CHANGE_DB))
menu.addAction(action)
if QT6: # QT6 requires exec() instead of exec_()
menu.exec_ = getattr(menu, "exec")
return menu

def change_view(self):
Expand Down Expand Up @@ -998,8 +1006,9 @@ def check_for_updates(self):
self.base.popup(_("No response!"), _("Version info is unreachable!\n"
"Please, try again later..."), buttons=1)
return
version = LooseVersion(self.base.version)
if version_new > version:
# current_version = LooseVersion(self.base.version)
current_version = version_parse(self.base.version)
if version_new > current_version:
popup = self.base.popup(_("Newer version exists!"),
_("There is a newer version (v.{}) online.\n"
"Open the site to download it now?")
Expand All @@ -1008,14 +1017,14 @@ def check_for_updates(self):
if popup.clickedButton().text() == "OK":
webbrowser.open("http://www.noembryo.com/apps.php?katalib")
self.close()
elif version_new == version:
elif version_new == current_version:
self.base.popup(_("No newer version exists!"),
_("{} is up to date (v.{})").format(APP_NAME, version),
_("{} is up to date (v.{})").format(APP_NAME, current_version),
icon=QMessageBox.Information, buttons=1)
elif version_new < version:
elif version_new < current_version:
self.base.popup(_("No newer version exists!"),
_("It seems that you are using a newer version ({0})\n"
"than the one online ({1})!").format(version, version_new),
"than the one online ({1})!").format(current_version, version_new),
icon=QMessageBox.Question, buttons=1)

@staticmethod
Expand All @@ -1036,7 +1045,8 @@ def get_online_version():
version_new = match.group(0)
except AttributeError: # no match found
version_new = "0.0.0.0"
return LooseVersion(version_new)
# return LooseVersion(version_new)
return version_parse(version_new)

def create_text(self):
# color = self.palette().color(QPalette.WindowText).name() # for links
Expand Down

0 comments on commit 74ec2c6

Please sign in to comment.