Commit 0079c892 authored by luyikei's avatar luyikei

MainWindow: Add Recent Projects action

parent 3b9a5f75
......@@ -90,6 +90,7 @@ MainWindow::MainWindow( Backend::IBackend* backend, QWidget *parent )
checkFolders();
loadGlobalProxySettings();
createProjectPreferences();
updateRecentProjects();
#ifdef WITH_CRASHBUTTON
setupCrashTester();
......@@ -105,6 +106,8 @@ MainWindow::MainWindow( Backend::IBackend* backend, QWidget *parent )
this, SLOT( onProjectSaved() ) );
connect( Core::instance()->project(), &Project::cleanStateChanged,
this, &MainWindow::cleanStateChanged );
connect( Core::instance()->recentProjects(), &RecentProjects::updated,
this, &MainWindow::updateRecentProjects );
//Connecting Library stuff:
const ClipRenderer* clipRenderer = qobject_cast<const ClipRenderer*>( m_clipPreview->getAbstractRenderer() );
......@@ -820,6 +823,27 @@ MainWindow::closeEvent( QCloseEvent* e )
e->accept();
}
void
MainWindow::updateRecentProjects()
{
auto menu = new QMenu;
for ( const auto& var : Core::instance()->recentProjects()->toVariant().toList() )
{
const auto& m = var.toMap();
auto name = m["name"].toString();
auto file = m["file"].toString();
auto action = menu->addAction( QString( "%1 - %2" )
.arg( name )
.arg( file )
);
connect( action, &QAction::triggered, this, [this, file]()
{
Core::instance()->loadProject( file );
} );
}
m_ui.actionRecent_Projects->setMenu( menu );
}
void
MainWindow::projectNameChanged( const QString& projectName )
{
......
......@@ -157,6 +157,7 @@ private slots:
void on_actionCrash_triggered();
void on_actionImport_triggered();
void toolButtonClicked( QAction *action );
void updateRecentProjects();
void projectNameChanged(const QString& projectName);
void cleanStateChanged( bool isClean );
void canUndoChanged( bool canUndo );
......
......@@ -65,6 +65,7 @@
<addaction name="separator"/>
<addaction name="actionSave"/>
<addaction name="actionSave_As"/>
<addaction name="actionRecent_Projects"/>
<addaction name="separator"/>
<addaction name="actionImport"/>
<addaction name="menu_Export"/>
......@@ -396,6 +397,11 @@
<bool>false</bool>
</property>
</action>
<action name="actionRecent_Projects">
<property name="text">
<string>&amp;Recent Projects</string>
</property>
</action>
</widget>
<resources>
<include location="../../../resources.qrc"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment