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)
{
#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));
}

View File

@ -153,3 +153,10 @@ void YACReaderLibraryToolbar::setDisabled(bool 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 setTitle(const QString &title);
private:
QMainWindow *mainWindow;
bool isMacosNative;

View File

@ -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;

View File

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