Remove files from Settings::recentFileList(), if they fail to open. (#268)

- i.e. they no longer exist or have been moved
- update recent file menu in StartupView as Settings change
This commit is contained in:
Jaye Evins
2025-12-17 21:26:30 -05:00
committed by GitHub
parent aba0f11616
commit 90e236f847
5 changed files with 66 additions and 12 deletions
+39 -12
View File
@@ -47,18 +47,9 @@ namespace glabels
recentProjectButton->setEnabled( model::Settings::recentFileList().size() > 0 );
auto* recentMenu = new QMenu();
for ( auto& filename : model::Settings::recentFileList() )
{
QString basename = QFileInfo( filename ).completeBaseName();
auto* action = new QAction( basename, this );
action->setIcon( QIcon::fromTheme( "glabels" ) );
action->setData( filename );
connect( action, SIGNAL(triggered()), this, SLOT(onOpenRecentAction()) );
recentMenu->addAction( action );
}
recentMenu->setMinimumWidth( recentProjectButton->minimumWidth() );
recentProjectButton->setMenu( recentMenu );
loadRecentsMenu();
connect( model::Settings::instance(), SIGNAL(changed()), this, SLOT(onSettingsChanged()) );
}
@@ -92,4 +83,40 @@ namespace glabels
}
}
///
/// Settings changed Slot
///
void StartupView::onSettingsChanged()
{
// reload recents menu
loadRecentsMenu();
}
///
/// Create recents menu
///
void StartupView::loadRecentsMenu()
{
auto fileList = model::Settings::recentFileList();
auto* recentMenu = new QMenu();
for ( auto& filename : fileList )
{
QString basename = QFileInfo( filename ).completeBaseName();
auto* action = new QAction( basename, this );
action->setIcon( QIcon::fromTheme( "glabels" ) );
action->setData( filename );
connect( action, SIGNAL(triggered()), this, SLOT(onOpenRecentAction()) );
recentMenu->addAction( action );
}
recentMenu->setMinimumWidth( recentProjectButton->minimumWidth() );
recentProjectButton->setMenu( recentMenu );
recentProjectButton->setEnabled( fileList.size() != 0 );
}
} // namespace glabels