Skip to content

Commit

Permalink
Added ability to rename all shelfs
Browse files Browse the repository at this point in the history
  • Loading branch information
brookite committed Sep 10, 2022
1 parent d196102 commit 3ef61f7
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 24 deletions.
4 changes: 2 additions & 2 deletions app/appinfo.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VERSION_NAME = "1.0 RC1"
BUILD_NUMBER = 1144
VERSION_NAME = "1.0 RC2"
BUILD_NUMBER = 1156
Binary file modified app/resources/i18n/bookshelf_ru_RU.qm
Binary file not shown.
57 changes: 37 additions & 20 deletions app/resources/i18n/bookshelf_ru_RU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,95 +44,112 @@
<translation>Приложение не может найти данную книгу. Пожалуйста, проверьте, существует ли эта книга</translation>
</message>
<message>
<location filename="../../window.py" line="99"/>
<location filename="../../window.py" line="268"/>
<location filename="../../window.py" line="101"/>
<location filename="../../window.py" line="290"/>
<source>Restore failed</source>
<translation>Восстановлено завершилось с ошибкой</translation>
</message>
<message>
<location filename="../../window.py" line="100"/>
<location filename="../../window.py" line="269"/>
<location filename="../../window.py" line="102"/>
<location filename="../../window.py" line="291"/>
<source>Backup wasn&apos;t restored. Check if your backup is valid</source>
<translation>Резервная копия не была восстановлена. Проверьте, что ваша резервная копия корректна</translation>
</message>
<message>
<location filename="../../window.py" line="135"/>
<location filename="../../window.py" line="164"/>
<source>Rename shelf</source>
<translation>Переименовать полку</translation>
</message>
<message>
<location filename="../../window.py" line="136"/>
<source>Input new name of your shelf</source>
<translation>Введите новое имя для Вашей полки</translation>
</message>
<message>
<location filename="../../window.py" line="139"/>
<location filename="../../window.py" line="145"/>
<source>My books</source>
<translation>Мои книги</translation>
</message>
<message>
<location filename="../../window.py" line="166"/>
<source>Remove shelf</source>
<translation>Удалить полку</translation>
</message>
<message>
<location filename="../../window.py" line="226"/>
<location filename="../../window.py" line="298"/>
<location filename="../../window.py" line="248"/>
<location filename="../../window.py" line="328"/>
<source>Limit has reached</source>
<translation>Превышен лимит</translation>
</message>
<message>
<location filename="../../window.py" line="227"/>
<location filename="../../window.py" line="249"/>
<source>You may create only {} shelfs</source>
<translation>Вы можете создать только {} полок</translation>
</message>
<message>
<location filename="../../window.py" line="231"/>
<location filename="../../window.py" line="253"/>
<source>Adding new shelf</source>
<translation>Добавление новой полки</translation>
</message>
<message>
<location filename="../../window.py" line="233"/>
<location filename="../../window.py" line="255"/>
<source>Input name of your new shelf</source>
<translation>Введите имя вашей новой полки</translation>
</message>
<message>
<location filename="../../window.py" line="245"/>
<location filename="../../window.py" line="267"/>
<source>Export backup</source>
<translation>Экспортирование резервной копии</translation>
</message>
<message>
<location filename="../../window.py" line="255"/>
<location filename="../../window.py" line="277"/>
<source>Import backup</source>
<translation>Импортирование резервной копии</translation>
</message>
<message>
<location filename="../../window.py" line="259"/>
<location filename="../../window.py" line="281"/>
<source>Data erase warning</source>
<translation>Предупреждение о стирании данных</translation>
</message>
<message>
<location filename="../../window.py" line="261"/>
<location filename="../../window.py" line="283"/>
<source>Your books and all app information will be replaced by backup data. Are you sure?</source>
<translation>Все ваши книги и настройки будут заменены данными резервной копии. Вы уверены?</translation>
</message>
<message>
<location filename="../../window.py" line="272"/>
<location filename="../../window.py" line="294"/>
<source>Restore finished</source>
<translation>Восстановление завершено</translation>
</message>
<message>
<location filename="../../window.py" line="274"/>
<location filename="../../window.py" line="296"/>
<source>Backup has been restored successfully. Application will be closed, please open it again</source>
<translation>Резервная копия была восстановлена. Приложение будет закрыто, пожалуйста, запустите его снова</translation>
</message>
<message>
<location filename="../../window.py" line="280"/>
<location filename="../../window.py" line="307"/>
<source>Adding books</source>
<translation>Добавление книг</translation>
</message>
<message>
<location filename="../../window.py" line="300"/>
<location filename="../../window.py" line="330"/>
<source>You may place in one shelf only {} books</source>
<translation>Вы можете размещать на одной полке только {} книг</translation>
</message>
<message>
<location filename="../../window.py" line="304"/>
<location filename="../../window.py" line="333"/>
<source>About Project Bookshelf</source>
<translation>О Project Bookshelf</translation>
</message>
<message>
<location filename="../../window.py" line="306"/>
<location filename="../../window.py" line="335"/>
<source>Elegant bookshelf for your documents</source>
<translation>Элегантная книжная полка для ваших документов</translation>
</message>
<message>
<location filename="../../window.py" line="307"/>
<location filename="../../window.py" line="336"/>
<source>Author: </source>
<translation>Разработчик: </translation>
</message>
Expand Down
26 changes: 24 additions & 2 deletions app/window.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import random

from PySide6.QtCore import QRect, QTimerEvent
from PySide6.QtGui import Qt, QKeyEvent, QCursor, QIcon, QCloseEvent, QResizeEvent, QPaintDevice
from PySide6.QtGui import Qt, QKeyEvent, QCursor, QIcon, QCloseEvent, QResizeEvent
from PySide6.QtWidgets import QMainWindow, QFileDialog, QInputDialog, \
QWidget, QScrollArea, QVBoxLayout, QMenu, QMessageBox, QApplication
QWidget, QScrollArea, QVBoxLayout, QMenu, QMessageBox

from app.appinfo import VERSION_NAME
from app.settings import SettingsWindow, BookPathsSetupWindow
Expand Down Expand Up @@ -64,6 +64,8 @@ def __init__(self, app):
self.get_current_shelf().scrollArea = self.scrollArea
if self.settings.config["defaultShelf"] != 0:
self.tabWidget.setCurrentIndex(self.settings.config["defaultShelf"])
if self.settings.config["shelfs"][0]["name"] != "$DEFAULT_NAME":
self.tabWidget.setTabText(0, self.settings.config["shelfs"][0]["name"])

def closeEvent(self, event: QCloseEvent) -> None:
self.settings.save()
Expand Down Expand Up @@ -127,6 +129,24 @@ def open_random_book(self):
book = random.choice(self.get_current_shelf().books)
book.open()

def rename_shelf(self):
old_name = self.get_current_shelf().metadata["name"]
if old_name == "$DEFAULT_NAME":
old_name = tr("My books")
name, success = QInputDialog.getText(
self,
tr("Rename shelf"),
tr("Input new name of your shelf"),
text=old_name
)
if self.shelf_index == 0 and not name:
name = "$DEFAULT_NAME"
if success and name:
self.get_current_shelf().metadata["name"] = name
display_name = name if name != "$DEFAULT_NAME" else tr("My books")
self.tabWidget.tabBar().setTabText(self.shelf_index, display_name)
self.settings.config.save()

def remove_shelf(self):
index = self._selected_shelf_index
if index == -1:
Expand All @@ -143,6 +163,8 @@ def remove_shelf(self):
def _tab_menu(self, index):
self._selected_shelf_index = index
menu = QMenu()
renameAction = menu.addAction(tr("Rename shelf"))
renameAction.triggered.connect(self.rename_shelf)
removeAction = menu.addAction(tr("Remove shelf"))
removeAction.triggered.connect(self.remove_shelf)
menu.exec(QCursor.pos())
Expand Down

0 comments on commit 3ef61f7

Please sign in to comment.