mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
Replace magic number for open recent length with config setting (no gui yet, maybe later)
This commit is contained in:
parent
976daa3546
commit
6eb6b83efe
@ -71,7 +71,7 @@ void Configuration::updateOpenRecentList (QString path)
|
|||||||
list.removeAll(path);
|
list.removeAll(path);
|
||||||
list.prepend(path);
|
list.prepend(path);
|
||||||
//TODO: Make list lenght configurable
|
//TODO: Make list lenght configurable
|
||||||
while (list.length() > 25)
|
while (list.length() > getOpenRecentSize())
|
||||||
{
|
{
|
||||||
list.removeLast();
|
list.removeLast();
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,7 @@ using namespace YACReader;
|
|||||||
void setFitMode ( YACReader::FitMode fitMode ){ settings->setValue(FITMODE, static_cast<int>(fitMode)); }
|
void setFitMode ( YACReader::FitMode fitMode ){ settings->setValue(FITMODE, static_cast<int>(fitMode)); }
|
||||||
|
|
||||||
//openRecent
|
//openRecent
|
||||||
|
int getOpenRecentSize() { return settings->value("recentSize", 25).toInt();}
|
||||||
QStringList openRecentList() { return settings->value("recentFiles").toStringList(); }
|
QStringList openRecentList() { return settings->value("recentFiles").toStringList(); }
|
||||||
void updateOpenRecentList (QString path);
|
void updateOpenRecentList (QString path);
|
||||||
void clearOpenRecentList() { settings->remove("recentFiles"); }
|
void clearOpenRecentList() { settings->remove("recentFiles"); }
|
||||||
|
@ -231,7 +231,7 @@ void MainWindowViewer::createActions()
|
|||||||
|
|
||||||
QAction* recentFileAction = nullptr;
|
QAction* recentFileAction = nullptr;
|
||||||
//TODO: Replace limit with a configurable value
|
//TODO: Replace limit with a configurable value
|
||||||
for (int i = 0; i < 25; i++)
|
for (int i = 0; i < Configuration::getConfiguration().getOpenRecentSize(); i++)
|
||||||
{
|
{
|
||||||
recentFileAction = new QAction(this);
|
recentFileAction = new QAction(this);
|
||||||
recentFileAction->setVisible(false);
|
recentFileAction->setVisible(false);
|
||||||
@ -742,8 +742,8 @@ void MainWindowViewer::refreshRecentFilesActionList()
|
|||||||
QStringList recentFilePaths = Configuration::getConfiguration().openRecentList();
|
QStringList recentFilePaths = Configuration::getConfiguration().openRecentList();
|
||||||
|
|
||||||
//TODO: Replace limit with something configurable
|
//TODO: Replace limit with something configurable
|
||||||
int iteration = (recentFilePaths.size() < 25) ? recentFilePaths.size() : 25;
|
int iteration = (recentFilePaths.size() < Configuration::getConfiguration().getOpenRecentSize())
|
||||||
|
? recentFilePaths.size() : Configuration::getConfiguration().getOpenRecentSize();
|
||||||
for (int i = 0; i < iteration; i++)
|
for (int i = 0; i < iteration; i++)
|
||||||
{
|
{
|
||||||
QString strippedName = QFileInfo(recentFilePaths.at(i)).fileName();
|
QString strippedName = QFileInfo(recentFilePaths.at(i)).fileName();
|
||||||
@ -752,7 +752,7 @@ void MainWindowViewer::refreshRecentFilesActionList()
|
|||||||
recentFilesActionList.at(i)->setVisible(true);
|
recentFilesActionList.at(i)->setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = iteration; i < 25; i++)
|
for (int i = iteration; i < Configuration::getConfiguration().getOpenRecentSize(); i++)
|
||||||
{
|
{
|
||||||
recentFilesActionList.at(i)->setVisible(false);
|
recentFilesActionList.at(i)->setVisible(false);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user