mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
Add a small dialog to show some info about a library
This commit is contained in:
parent
60af741593
commit
1c9f2133f6
@ -21,6 +21,7 @@ Version counting is based on semantic versioning (Major.Feature.Patch)
|
||||
* Fix crash when current folders is empty after an update.
|
||||
* Enable dropping content on the FolderContentView.
|
||||
* Fix `open containing folder...` shortcut for comics.
|
||||
* Add a dialog to show information about a library, it includes the number of folders and comics and the number of read comics.
|
||||
|
||||
### YACReaderLibraryServer
|
||||
* New command --system-info to print information about the execution environment and available resources (including what image formats are supported and what libraries are used by the app).
|
||||
|
@ -2022,3 +2022,39 @@ bool DBHelper::isFavoriteComic(qulonglong id, QSqlDatabase &db)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QString DBHelper::getLibraryInfo(QUuid id)
|
||||
{
|
||||
QString info;
|
||||
QString libraryPath = DBHelper::getLibraries().getPath(id);
|
||||
|
||||
info = "<b>Library path</b>:<br/>" + libraryPath + "<br/><br/>";
|
||||
|
||||
QString connectionName = "";
|
||||
QList<LibraryItem *> list;
|
||||
{
|
||||
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath + "/.yacreaderlibrary");
|
||||
connectionName = db.connectionName();
|
||||
|
||||
// num folders
|
||||
auto foldersQuery = db.exec("SELECT COUNT(*) FROM folder WHERE id <> 1");
|
||||
foldersQuery.next();
|
||||
|
||||
info += "<b>Number of folders</b>:<br/>" + foldersQuery.value(0).toString() + "<br/><br/>";
|
||||
|
||||
// num comics
|
||||
auto comicsQuery = db.exec("SELECT COUNT(*) FROM comic");
|
||||
comicsQuery.next();
|
||||
|
||||
info += "<b>Number of comics</b>:<br/>" + comicsQuery.value(0).toString() + "<br/><br/>";
|
||||
|
||||
// num read comics
|
||||
auto readComicsQuery = db.exec("SELECT count(*) FROM comic c INNER JOIN comic_info ci ON c.comicInfoId = ci.id WHERE ci.read = 1");
|
||||
readComicsQuery.next();
|
||||
|
||||
info += "<b>Number of read comics</b>:<br/>" + readComicsQuery.value(0).toString() + "<br/><br/>";
|
||||
}
|
||||
QSqlDatabase::removeDatabase(connectionName);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
@ -104,6 +104,9 @@ public:
|
||||
static QList<QString> loadSubfoldersNames(qulonglong folderId, QSqlDatabase &db);
|
||||
// queries
|
||||
static bool isFavoriteComic(qulonglong id, QSqlDatabase &db);
|
||||
|
||||
// library
|
||||
static QString getLibraryInfo(QUuid id);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -619,6 +619,9 @@ void LibraryWindow::createMenus()
|
||||
|
||||
selectedLibrary->addAction(actions.exportLibraryAction);
|
||||
selectedLibrary->addAction(actions.importLibraryAction);
|
||||
YACReader::addSperator(selectedLibrary);
|
||||
|
||||
selectedLibrary->addAction(actions.showLibraryInfo);
|
||||
|
||||
// MacOSX app menus
|
||||
#ifdef Q_OS_MACOS
|
||||
@ -648,6 +651,10 @@ void LibraryWindow::createMenus()
|
||||
libraryMenu->addAction(actions.exportLibraryAction);
|
||||
libraryMenu->addAction(actions.importLibraryAction);
|
||||
|
||||
libraryMenu->addSeparator();
|
||||
|
||||
libraryMenu->addAction(actions.showLibraryInfo);
|
||||
|
||||
// folder
|
||||
QMenu *folderMenu = new QMenu(tr("Folder"));
|
||||
folderMenu->addAction(actions.openContainingFolderAction);
|
||||
@ -1894,6 +1901,23 @@ void LibraryWindow::rescanLibraryForXMLInfo()
|
||||
xmlInfoLibraryScanner->scanLibrary(path, path + "/.yacreaderlibrary");
|
||||
}
|
||||
|
||||
void LibraryWindow::showLibraryInfo()
|
||||
{
|
||||
auto id = libraries.getUuid(selectedLibrary->currentText());
|
||||
auto info = DBHelper::getLibraryInfo(id);
|
||||
|
||||
// TODO: use something nicer than a QMessageBox
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(tr("Library info"));
|
||||
msgBox.setText(info);
|
||||
QSpacerItem *horizontalSpacer = new QSpacerItem(420, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||
QGridLayout *layout = (QGridLayout *)msgBox.layout();
|
||||
layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount());
|
||||
msgBox.setStandardButtons(QMessageBox::Close);
|
||||
msgBox.setDefaultButton(QMessageBox::Close);
|
||||
msgBox.exec();
|
||||
}
|
||||
|
||||
void LibraryWindow::rescanCurrentFolderForXMLInfo()
|
||||
{
|
||||
rescanFolderForXMLInfo(getCurrentFolderIndex());
|
||||
|
@ -251,6 +251,7 @@ public slots:
|
||||
void removeLibrary();
|
||||
void renameLibrary();
|
||||
void rescanLibraryForXMLInfo();
|
||||
void showLibraryInfo();
|
||||
void rescanCurrentFolderForXMLInfo();
|
||||
void rescanFolderForXMLInfo(QModelIndex modelIndex);
|
||||
void rename(QString newName);
|
||||
|
@ -101,6 +101,11 @@ void LibraryWindowActions::createActions(LibraryWindow *window, QSettings *setti
|
||||
rescanLibraryForXMLInfoAction->setData(RESCAN_LIBRARY_XML_INFO_ACTION_YL);
|
||||
rescanLibraryForXMLInfoAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(RESCAN_LIBRARY_XML_INFO_ACTION_YL));
|
||||
|
||||
showLibraryInfo = new QAction(tr("Show library info"), window);
|
||||
showLibraryInfo->setToolTip(tr("Show information about the current library"));
|
||||
showLibraryInfo->setData(SHOW_LIBRARY_INFO_ACTION_YL);
|
||||
showLibraryInfo->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_LIBRARY_INFO_ACTION_YL));
|
||||
|
||||
openComicAction = new QAction(tr("Open current comic"), window);
|
||||
openComicAction->setToolTip(tr("Open current comic on YACReader"));
|
||||
openComicAction->setData(OPEN_COMIC_ACTION_YL);
|
||||
@ -559,6 +564,8 @@ void LibraryWindowActions::createConnections(
|
||||
// connect(deleteLibraryAction,SIGNAL(triggered()),window,SLOT(deleteLibrary()));
|
||||
QObject::connect(removeLibraryAction, &QAction::triggered, window, &LibraryWindow::removeLibrary);
|
||||
QObject::connect(rescanLibraryForXMLInfoAction, &QAction::triggered, window, &LibraryWindow::rescanLibraryForXMLInfo);
|
||||
QObject::connect(showLibraryInfo, &QAction::triggered, window, &LibraryWindow::showLibraryInfo);
|
||||
|
||||
QObject::connect(openComicAction, &QAction::triggered, window, QOverload<>::of(&LibraryWindow::openComic));
|
||||
QObject::connect(helpAboutAction, &QAction::triggered, had, &QWidget::show);
|
||||
QObject::connect(addFolderAction, &QAction::triggered, window, &LibraryWindow::addFolderToCurrentIndex);
|
||||
@ -659,7 +666,8 @@ void LibraryWindowActions::setUpShortcutsManagement(EditShortcutsDialog *editSho
|
||||
<< updateLibraryAction
|
||||
<< renameLibraryAction
|
||||
<< removeLibraryAction
|
||||
<< rescanLibraryForXMLInfoAction);
|
||||
<< rescanLibraryForXMLInfoAction
|
||||
<< showLibraryInfo);
|
||||
|
||||
allActions << tmpList;
|
||||
|
||||
|
@ -39,6 +39,9 @@ public:
|
||||
QAction *removeLibraryAction;
|
||||
QAction *helpAboutAction;
|
||||
QAction *renameLibraryAction;
|
||||
|
||||
QAction *showLibraryInfo;
|
||||
|
||||
#ifndef Q_OS_MACOS
|
||||
QAction *toggleFullScreenAction;
|
||||
#endif
|
||||
|
@ -54,6 +54,12 @@ QString YACReaderLibraries::getPath(int id)
|
||||
return library != libraries.cend() ? library->getPath() : "";
|
||||
}
|
||||
|
||||
QString YACReaderLibraries::getPath(const QUuid &id)
|
||||
{
|
||||
auto library = std::find_if(libraries.cbegin(), libraries.cend(), [id](const YACReaderLibrary &library) { return library.getId() == id; });
|
||||
return library != libraries.cend() ? library->getPath() : "";
|
||||
}
|
||||
|
||||
QString YACReaderLibraries::getDBPath(int id)
|
||||
{
|
||||
return getPath(id) + "/.yacreaderlibrary";
|
||||
@ -101,6 +107,12 @@ int YACReaderLibraries::getId(const QString &name)
|
||||
return library != libraries.cend() ? library->getLegacyId() : -1;
|
||||
}
|
||||
|
||||
QUuid YACReaderLibraries::getUuid(const QString &name)
|
||||
{
|
||||
auto library = std::find_if(libraries.cbegin(), libraries.cend(), [name](const YACReaderLibrary &library) { return library.getName() == name; });
|
||||
return library != libraries.cend() ? library->getId() : QUuid();
|
||||
}
|
||||
|
||||
int YACReaderLibraries::getIdFromUuid(const QUuid &uuid)
|
||||
{
|
||||
auto library = std::find_if(libraries.cbegin(), libraries.cend(), [uuid](const YACReaderLibrary &library) { return library.getId() == uuid; });
|
||||
|
@ -15,6 +15,7 @@ public:
|
||||
QList<QString> getNames();
|
||||
QString getPath(const QString &name);
|
||||
QString getPath(int id);
|
||||
QString getPath(const QUuid &id);
|
||||
QString getDBPath(int id);
|
||||
QString getName(int id);
|
||||
bool isEmpty();
|
||||
@ -23,6 +24,7 @@ public:
|
||||
void remove(const QString &name);
|
||||
void rename(const QString &oldName, const QString &newName);
|
||||
int getId(const QString &name);
|
||||
QUuid getUuid(const QString &name);
|
||||
int getIdFromUuid(const QUuid &uuid);
|
||||
YACReaderLibraries &operator=(const YACReaderLibraries &source);
|
||||
QList<YACReaderLibrary> getLibraries() const;
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
#define RENAME_LIBRARY_ACTION_YL "RENAME_LIBRARY_ACTION_YL"
|
||||
#define REMOVE_LIBRARY_ACTION_YL "REMOVE_LIBRARY_ACTION_YL"
|
||||
#define RESCAN_LIBRARY_XML_INFO_ACTION_YL "RESCAN_LIBRARY_XML_INFO_ACTION_YL"
|
||||
#define SHOW_LIBRARY_INFO_ACTION_YL "SHOW_LIBRARY_INFO_ACTION_YL"
|
||||
#define OPEN_COMIC_ACTION_YL "OPEN_COMIC_ACTION_YL"
|
||||
#define SET_AS_READ_ACTION_YL "SET_AS_READ_ACTION_YL"
|
||||
#define SET_AS_NON_READ_ACTION_YL "SET_AS_NON_READ_ACTION_YL"
|
||||
|
Loading…
Reference in New Issue
Block a user