From e7922a0e51dde828419fedaaca071f877cf9a0b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Wed, 12 Sep 2018 10:22:39 +0200 Subject: [PATCH] Implement a way for setting the title in the main toolbar. --- YACReaderLibrary/library_window.cpp | 29 ++++++++++--------- .../yacreader_library_toolbar.cpp | 7 +++++ YACReaderLibrary/yacreader_library_toolbar.h | 2 ++ YACReaderLibrary/yacreader_main_toolbar.cpp | 2 +- YACReaderLibrary/yacreader_main_toolbar.h | 2 +- 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index 04a536ac..8beb3595 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -1567,12 +1567,12 @@ void LibraryWindow::onAddComicsToLabel() void LibraryWindow::setToolbarTitle(const QModelIndex &modelIndex) { -#ifndef Q_OS_MAC - if (!modelIndex.isValid()) - libraryToolBar->setCurrentFolderName(selectedLibrary->currentText()); - else - libraryToolBar->setCurrentFolderName(modelIndex.data().toString()); -#endif + if (!theme.isMacosNative) { + if (!modelIndex.isValid()) + libraryToolBar->setTitle(selectedLibrary->currentText()); + else + libraryToolBar->setTitle(modelIndex.data().toString()); + } } void LibraryWindow::saveSelectedCoversTo() @@ -1839,20 +1839,23 @@ void LibraryWindow::rename(QString newName) //TODO replace QString currentLibrary = selectedLibrary->currentText(); if (newName != currentLibrary) { if (!libraries.contains(newName)) { - libraries.rename(currentLibrary, newName); + libraries.rename(currentLibrary,newName); //selectedLibrary->removeItem(selectedLibrary->currentIndex()); //libraries.addLibrary(newName,path); selectedLibrary->renameCurrentLibrary(newName); libraries.save(); renameLibraryDialog->close(); -#ifndef Q_OS_MAC - if (!foldersModelProxy->mapToSource(foldersView->currentIndex()).isValid()) - libraryToolBar->setCurrentFolderName(selectedLibrary->currentText()); -#endif - } else { + + if (!theme.isMacosNative) { + if(!foldersModelProxy->mapToSource(foldersView->currentIndex()).isValid()) + libraryToolBar->setTitle(selectedLibrary->currentText()); + } + } + else { libraryAlreadyExists(newName); } - } else + } + else renameLibraryDialog->close(); //selectedLibrary->setCurrentIndex(selectedLibrary->findText(newName)); } diff --git a/YACReaderLibrary/yacreader_library_toolbar.cpp b/YACReaderLibrary/yacreader_library_toolbar.cpp index 2796e597..c53b06d7 100644 --- a/YACReaderLibrary/yacreader_library_toolbar.cpp +++ b/YACReaderLibrary/yacreader_library_toolbar.cpp @@ -153,3 +153,10 @@ void YACReaderLibraryToolbar::setDisabled(bool disabled) defaultToolbar->setDisabled(disabled); } } + +void YACReaderLibraryToolbar::setTitle(const QString &title) +{ + if (defaultToolbar != nullptr) { + defaultToolbar->setTitle(title); + } +} diff --git a/YACReaderLibrary/yacreader_library_toolbar.h b/YACReaderLibrary/yacreader_library_toolbar.h index 7089ecce..57d6fd2f 100644 --- a/YACReaderLibrary/yacreader_library_toolbar.h +++ b/YACReaderLibrary/yacreader_library_toolbar.h @@ -37,6 +37,8 @@ public slots: void setDisabled(bool disabled); + void setTitle(const QString &title); + private: QMainWindow *mainWindow; bool isMacosNative; diff --git a/YACReaderLibrary/yacreader_main_toolbar.cpp b/YACReaderLibrary/yacreader_main_toolbar.cpp index 378e56a7..62278c32 100644 --- a/YACReaderLibrary/yacreader_main_toolbar.cpp +++ b/YACReaderLibrary/yacreader_main_toolbar.cpp @@ -132,7 +132,7 @@ void YACReaderMainToolBar::addWideDivider() mainLayout->addSpacing(3); } -void YACReaderMainToolBar::setCurrentFolderName(const QString &name) +void YACReaderMainToolBar::setTitle(const QString & name) { currentFolder->setText(name); currentFolderName = name; diff --git a/YACReaderLibrary/yacreader_main_toolbar.h b/YACReaderLibrary/yacreader_main_toolbar.h index 80323b30..78e20b28 100644 --- a/YACReaderLibrary/yacreader_main_toolbar.h +++ b/YACReaderLibrary/yacreader_main_toolbar.h @@ -26,7 +26,7 @@ public: QToolButton *fullscreenButton; void setSearchWidget(QWidget *w); - void setCurrentFolderName(const QString &name); + void setTitle(const QString &name); signals: public slots: