Skip to content

Commit

Permalink
Some tab improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
brookite committed Sep 11, 2022
1 parent 3ef61f7 commit 26f869a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def __init__(self, app):
self.setupUi(self)
self.shelfs = []
self.load_shelfs()
# common selected shelf index (this tab)
self.shelf_index = 0
# selected shelf index for user selection (not only this tab)
self._selected_shelf_index = -1
self.scrollArea.setWidget(self.get_current_shelf())
self.get_current_shelf().scrollbar = self.scrollArea.verticalScrollBar()
Expand Down Expand Up @@ -130,7 +132,8 @@ def open_random_book(self):
book.open()

def rename_shelf(self):
old_name = self.get_current_shelf().metadata["name"]
index = self._selected_shelf_index
old_name = self.shelfs[index].metadata["name"]
if old_name == "$DEFAULT_NAME":
old_name = tr("My books")
name, success = QInputDialog.getText(
Expand All @@ -142,10 +145,11 @@ def rename_shelf(self):
if self.shelf_index == 0 and not name:
name = "$DEFAULT_NAME"
if success and name:
self.get_current_shelf().metadata["name"] = name
self.shelfs[index].metadata["name"] = name
display_name = name if name != "$DEFAULT_NAME" else tr("My books")
self.tabWidget.tabBar().setTabText(self.shelf_index, display_name)
self.tabWidget.tabBar().setTabText(self._selected_shelf_index, display_name)
self.settings.config.save()
self._selected_shelf_index = -1

def remove_shelf(self):
index = self._selected_shelf_index
Expand Down

0 comments on commit 26f869a

Please sign in to comment.