Skip to content

Commit

Permalink
Add shortcuts for library in Cards tab
Browse files Browse the repository at this point in the history
  • Loading branch information
ping committed Aug 1, 2023
1 parent cd36e61 commit d9880e1
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions calibre-plugin/dialog/cards.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ def __init__(self, card, library, tab, *args, **kwargs):
curr_font.setPointSizeF(curr_font.pointSizeF() * 1.2)
library_lbl.setFont(curr_font)
library_lbl.setStyleSheet("font-weight: bold;")
library_lbl.doubleClicked.connect(
lambda: self.tab.display_debug("Library", self.library)
library_lbl.setContextMenuPolicy(Qt.CustomContextMenu)
library_lbl.customContextMenuRequested.connect(
self.library_lbl_context_menu_requested
)
layout.addWidget(library_lbl, widget_row_pos, 0, 1, 2)
widget_row_pos += 1
Expand Down Expand Up @@ -182,6 +183,16 @@ def __init__(self, card, library, tab, *args, **kwargs):
)
layout.addWidget(holds_progressbar, widget_row_pos, 0, 1, 2)

def library_lbl_context_menu_requested(self):
menu = QMenu(self)
view_in_libby_action = menu.addAction(_("View in Libby"))
view_in_libby_action.setIcon(self.icons[PluginIcons.ExternalLink])
view_in_libby_action.triggered.connect(self.open_libby_library)
view_in_overdrive_action = menu.addAction(_("View in OverDrive"))
view_in_overdrive_action.setIcon(self.icons[PluginIcons.ExternalLink])
view_in_overdrive_action.triggered.connect(self.open_overdrive_library)
menu.exec(QCursor.pos())

def loans_progressbar_context_menu_requested(self):
menu = QMenu(self)
view_in_libby_action = menu.addAction(_("View in Libby"))
Expand All @@ -208,6 +219,12 @@ def open_link(self, link):
def overdrive_url(self):
return f'https://{self.library["preferredKey"]}.overdrive.com/'

def open_libby_library(self):
self.open_link(f'https://libbyapp.com/library/{self.library["preferredKey"]}')

def open_overdrive_library(self):
self.open_link(self.overdrive_url())

def open_libby_loans(self):
self.open_link(
f'https://libbyapp.com/shelf/loans/default,all,{self.library["websiteId"]}'
Expand Down

0 comments on commit d9880e1

Please sign in to comment.