mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
DRYer
This commit is contained in:
parent
b57bd18b12
commit
e80f16ddbf
@ -22,7 +22,7 @@ from calibre.constants import (
|
|||||||
config_dir, filesystem_encoding, get_portable_base, isportable, iswindows
|
config_dir, filesystem_encoding, get_portable_base, isportable, iswindows
|
||||||
)
|
)
|
||||||
from calibre.gui2 import (
|
from calibre.gui2 import (
|
||||||
Dispatcher, choose_dir, choose_files, error_dialog, gprefs, info_dialog,
|
Dispatcher, choose_dir, choose_images, error_dialog, gprefs, info_dialog,
|
||||||
open_local_file, pixmap_to_data, question_dialog, warning_dialog
|
open_local_file, pixmap_to_data, question_dialog, warning_dialog
|
||||||
)
|
)
|
||||||
from calibre.gui2.actions import InterfaceAction
|
from calibre.gui2.actions import InterfaceAction
|
||||||
@ -348,12 +348,10 @@ class ChooseLibraryAction(InterfaceAction):
|
|||||||
|
|
||||||
def get_library_icon(self):
|
def get_library_icon(self):
|
||||||
try:
|
try:
|
||||||
path = choose_files(self.gui, 'choose_library_icon',
|
paths = choose_images(self.gui, 'choose_library_icon',
|
||||||
_('Select icon for library "%s"') % current_library_name(),
|
_('Select icon for library "%s"') % current_library_name())
|
||||||
filters=[('Images', ['png', 'gif', 'jpg', 'jpeg', 'webp'])],
|
if paths:
|
||||||
all_files=False, select_only_single_file=True)
|
path = paths[0]
|
||||||
if path:
|
|
||||||
path = path[0]
|
|
||||||
p = QIcon(path).pixmap(QSize(256, 256))
|
p = QIcon(path).pixmap(QSize(256, 256))
|
||||||
icp = library_icon_path()
|
icp = library_icon_path()
|
||||||
os.makedirs(os.path.dirname(icp), exist_ok=True)
|
os.makedirs(os.path.dirname(icp), exist_ok=True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user