Added "Open Recent" button to StartupView.

- Also disabled broken MacOS build in travis CI file
This commit is contained in:
Jim Evins
2019-11-12 21:40:43 -05:00
parent 75e613e9f1
commit f09ca36b7b
17 changed files with 269 additions and 59 deletions
+32
View File
@@ -23,6 +23,11 @@
#include "File.h"
#include "MainWindow.h"
#include "model/Settings.h"
#include <QAction>
#include <QFileInfo>
#include <QMenu>
#include <QtDebug>
@@ -39,6 +44,20 @@ namespace glabels
QString titleImage = ":images/glabels-label-designer.png";
titleLabel->setPixmap( QPixmap( titleImage ) );
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->setData( filename );
connect( action, SIGNAL(triggered()), this, SLOT(onOpenRecentAction()) );
recentMenu->addAction( action );
}
recentMenu->setMinimumWidth( recentProjectButton->minimumWidth() );
recentProjectButton->setMenu( recentMenu );
}
@@ -59,4 +78,17 @@ namespace glabels
File::open( mWindow );
}
///
/// "Open Recent" Action Activated Slot
///
void StartupView::onOpenRecentAction()
{
QAction* action = qobject_cast<QAction*>( sender() );
if ( action )
{
File::open( action->data().toString(), mWindow );
}
}
} // namespace glabels