Implement a way for setting the title in the main toolbar.

This commit is contained in:
Luis Ángel San Martín 2018-09-12 10:22:39 +02:00 committed by Luis Ángel San Martín
parent ca5096fba4
commit e7922a0e51
5 changed files with 27 additions and 15 deletions

View File

@ -1567,12 +1567,12 @@ void LibraryWindow::onAddComicsToLabel()
void LibraryWindow::setToolbarTitle(const QModelIndex &modelIndex) void LibraryWindow::setToolbarTitle(const QModelIndex &modelIndex)
{ {
#ifndef Q_OS_MAC if (!theme.isMacosNative) {
if (!modelIndex.isValid()) if (!modelIndex.isValid())
libraryToolBar->setCurrentFolderName(selectedLibrary->currentText()); libraryToolBar->setTitle(selectedLibrary->currentText());
else else
libraryToolBar->setCurrentFolderName(modelIndex.data().toString()); libraryToolBar->setTitle(modelIndex.data().toString());
#endif }
} }
void LibraryWindow::saveSelectedCoversTo() void LibraryWindow::saveSelectedCoversTo()
@ -1839,20 +1839,23 @@ void LibraryWindow::rename(QString newName) //TODO replace
QString currentLibrary = selectedLibrary->currentText(); QString currentLibrary = selectedLibrary->currentText();
if (newName != currentLibrary) { if (newName != currentLibrary) {
if (!libraries.contains(newName)) { if (!libraries.contains(newName)) {
libraries.rename(currentLibrary, newName); libraries.rename(currentLibrary,newName);
//selectedLibrary->removeItem(selectedLibrary->currentIndex()); //selectedLibrary->removeItem(selectedLibrary->currentIndex());
//libraries.addLibrary(newName,path); //libraries.addLibrary(newName,path);
selectedLibrary->renameCurrentLibrary(newName); selectedLibrary->renameCurrentLibrary(newName);
libraries.save(); libraries.save();
renameLibraryDialog->close(); renameLibraryDialog->close();
#ifndef Q_OS_MAC
if (!foldersModelProxy->mapToSource(foldersView->currentIndex()).isValid()) if (!theme.isMacosNative) {
libraryToolBar->setCurrentFolderName(selectedLibrary->currentText()); if(!foldersModelProxy->mapToSource(foldersView->currentIndex()).isValid())
#endif libraryToolBar->setTitle(selectedLibrary->currentText());
} else { }
}
else {
libraryAlreadyExists(newName); libraryAlreadyExists(newName);
} }
} else }
else
renameLibraryDialog->close(); renameLibraryDialog->close();
//selectedLibrary->setCurrentIndex(selectedLibrary->findText(newName)); //selectedLibrary->setCurrentIndex(selectedLibrary->findText(newName));
} }

View File

@ -153,3 +153,10 @@ void YACReaderLibraryToolbar::setDisabled(bool disabled)
defaultToolbar->setDisabled(disabled); defaultToolbar->setDisabled(disabled);
} }
} }
void YACReaderLibraryToolbar::setTitle(const QString &title)
{
if (defaultToolbar != nullptr) {
defaultToolbar->setTitle(title);
}
}

View File

@ -37,6 +37,8 @@ public slots:
void setDisabled(bool disabled); void setDisabled(bool disabled);
void setTitle(const QString &title);
private: private:
QMainWindow *mainWindow; QMainWindow *mainWindow;
bool isMacosNative; bool isMacosNative;

View File

@ -132,7 +132,7 @@ void YACReaderMainToolBar::addWideDivider()
mainLayout->addSpacing(3); mainLayout->addSpacing(3);
} }
void YACReaderMainToolBar::setCurrentFolderName(const QString &name) void YACReaderMainToolBar::setTitle(const QString & name)
{ {
currentFolder->setText(name); currentFolder->setText(name);
currentFolderName = name; currentFolderName = name;

View File

@ -26,7 +26,7 @@ public:
QToolButton *fullscreenButton; QToolButton *fullscreenButton;
void setSearchWidget(QWidget *w); void setSearchWidget(QWidget *w);
void setCurrentFolderName(const QString &name); void setTitle(const QString &name);
signals: signals:
public slots: public slots: