From f09ca36b7bef7c6076c96aa550ac7f6ef77ecebc Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Tue, 12 Nov 2019 21:40:43 -0500 Subject: [PATCH] Added "Open Recent" button to StartupView. - Also disabled broken MacOS build in travis CI file --- .travis.yml | 44 +++++++++---------- glabels/Icons.h | 15 +++++++ glabels/MainWindow.cpp | 2 +- glabels/StartupView.cpp | 32 ++++++++++++++ glabels/StartupView.h | 1 + glabels/icons.qrc | 6 +++ glabels/icons/flat/16x16/glabels-file-new.svg | 12 ++--- .../icons/flat/16x16/glabels-file-recent.svg | 16 +++++++ glabels/icons/flat/22x22/glabels-file-new.svg | 16 +++---- .../icons/flat/22x22/glabels-file-recent.svg | 16 +++++++ glabels/icons/flat/24x24/glabels-file-new.svg | 16 +++---- .../icons/flat/24x24/glabels-file-recent.svg | 16 +++++++ glabels/icons/flat/32x32/glabels-file-new.svg | 43 ++++++++++++++++++ .../icons/flat/32x32/glabels-file-open.svg | 15 +++++++ .../icons/flat/32x32/glabels-file-recent.svg | 16 +++++++ glabels/ui/StartupView.ui | 44 +++++++++++++++---- translations/glabels_C.ts | 18 +++++--- 17 files changed, 269 insertions(+), 59 deletions(-) create mode 100644 glabels/icons/flat/16x16/glabels-file-recent.svg create mode 100644 glabels/icons/flat/22x22/glabels-file-recent.svg create mode 100644 glabels/icons/flat/24x24/glabels-file-recent.svg create mode 100644 glabels/icons/flat/32x32/glabels-file-new.svg create mode 100644 glabels/icons/flat/32x32/glabels-file-open.svg create mode 100644 glabels/icons/flat/32x32/glabels-file-recent.svg diff --git a/.travis.yml b/.travis.yml index cdd6612..d85e76d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -74,28 +74,28 @@ matrix: skip_cleanup: true - ##################### - # - # MacOS build - # - ##################### - - name: "MacOS" - os: osx - - install: - - brew install qt - - before_script: - - git fetch --unshallow # restore repository depth to properly count commits in auto versioning - - git checkout master # re-attach to master to satisfy auto versioning - - script: - - mkdir build - - cd build - - cmake .. -DCMAKE_PREFIX_PATH=/usr/local/opt/qt - - make -j4 - #- ctest --verbose - - VERSION=$(cat VERSION) +# ##################### +# # +# # MacOS build +# # +# ##################### +# - name: "MacOS" +# os: osx +# +# install: +# - brew install qt +# +# before_script: +# - git fetch --unshallow # restore repository depth to properly count commits in auto versioning +# - git checkout master # re-attach to master to satisfy auto versioning +# +# script: +# - mkdir build +# - cd build +# - cmake .. -DCMAKE_PREFIX_PATH=/usr/local/opt/qt +# - make -j4 +# #- ctest --verbose +# - VERSION=$(cat VERSION) # ##################### diff --git a/glabels/Icons.h b/glabels/Icons.h index 37dd081..7141bed 100644 --- a/glabels/Icons.h +++ b/glabels/Icons.h @@ -402,6 +402,7 @@ namespace glabels addPixmap( QPixmap( ":icons/flat/16x16/glabels-file-new.svg" ) ); addPixmap( QPixmap( ":icons/flat/22x22/glabels-file-new.svg" ) ); addPixmap( QPixmap( ":icons/flat/24x24/glabels-file-new.svg" ) ); + addPixmap( QPixmap( ":icons/flat/32x32/glabels-file-new.svg" ) ); } }; @@ -414,6 +415,20 @@ namespace glabels addPixmap( QPixmap( ":icons/flat/16x16/glabels-file-open.svg" ) ); addPixmap( QPixmap( ":icons/flat/22x22/glabels-file-open.svg" ) ); addPixmap( QPixmap( ":icons/flat/24x24/glabels-file-open.svg" ) ); + addPixmap( QPixmap( ":icons/flat/32x32/glabels-file-open.svg" ) ); + } + }; + + + class FileRecent : public QIcon + { + public: + FileRecent() + { + addPixmap( QPixmap( ":icons/flat/16x16/glabels-file-recent.svg" ) ); + addPixmap( QPixmap( ":icons/flat/22x22/glabels-file-recent.svg" ) ); + addPixmap( QPixmap( ":icons/flat/24x24/glabels-file-recent.svg" ) ); + addPixmap( QPixmap( ":icons/flat/32x32/glabels-file-recent.svg" ) ); } }; diff --git a/glabels/MainWindow.cpp b/glabels/MainWindow.cpp index 42c939d..55f2383 100644 --- a/glabels/MainWindow.cpp +++ b/glabels/MainWindow.cpp @@ -623,7 +623,7 @@ namespace glabels fileMenu = menuBar()->addMenu( tr("&File") ); fileMenu->addAction( fileNewAction ); fileMenu->addAction( fileOpenAction ); - fileRecentMenu = fileMenu->addMenu( tr("Open Recent") ); + fileRecentMenu = fileMenu->addMenu( Icons::FileRecent(), tr("Open Recent") ); for ( auto* action : fileRecentActionList ) { fileRecentMenu->addAction( action ); diff --git a/glabels/StartupView.cpp b/glabels/StartupView.cpp index 1dbae82..eeedf63 100644 --- a/glabels/StartupView.cpp +++ b/glabels/StartupView.cpp @@ -23,6 +23,11 @@ #include "File.h" #include "MainWindow.h" +#include "model/Settings.h" + +#include +#include +#include #include @@ -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( sender() ); + if ( action ) + { + File::open( action->data().toString(), mWindow ); + } + } + } // namespace glabels diff --git a/glabels/StartupView.h b/glabels/StartupView.h index 164197f..670eb49 100644 --- a/glabels/StartupView.h +++ b/glabels/StartupView.h @@ -53,6 +53,7 @@ namespace glabels private slots: void onNewProjectButtonClicked(); void onOpenProjectButtonClicked(); + void onOpenRecentAction(); ///////////////////////////////// diff --git a/glabels/icons.qrc b/glabels/icons.qrc index faa0f30..12e2c7b 100644 --- a/glabels/icons.qrc +++ b/glabels/icons.qrc @@ -21,6 +21,7 @@ icons/flat/16x16/glabels-ellipse.svg icons/flat/16x16/glabels-file-new.svg icons/flat/16x16/glabels-file-open.svg + icons/flat/16x16/glabels-file-recent.svg icons/flat/16x16/glabels-file-save.svg icons/flat/16x16/glabels-file-save-as.svg icons/flat/16x16/glabels-flip-horiz.svg @@ -50,6 +51,7 @@ icons/flat/22x22/glabels-ellipse.svg icons/flat/22x22/glabels-file-new.svg icons/flat/22x22/glabels-file-open.svg + icons/flat/22x22/glabels-file-recent.svg icons/flat/22x22/glabels-file-save.svg icons/flat/22x22/glabels-file-save-as.svg icons/flat/22x22/glabels-format-text-bold.svg @@ -79,6 +81,7 @@ icons/flat/24x24/glabels-ellipse.svg icons/flat/24x24/glabels-file-new.svg icons/flat/24x24/glabels-file-open.svg + icons/flat/24x24/glabels-file-recent.svg icons/flat/24x24/glabels-file-save.svg icons/flat/24x24/glabels-file-save-as.svg icons/flat/24x24/glabels-format-text-bold.svg @@ -92,6 +95,9 @@ icons/flat/24x24/glabels-valign-text-middle.svg icons/flat/24x24/glabels-valign-text-top.svg + icons/flat/32x32/glabels-file-new.svg + icons/flat/32x32/glabels-file-open.svg + icons/flat/32x32/glabels-file-recent.svg icons/flat/32x32/glabels-label-orientation-horiz.svg icons/flat/32x32/glabels-label-orientation-vert.svg icons/flat/32x32/glabels-print.svg diff --git a/glabels/icons/flat/16x16/glabels-file-new.svg b/glabels/icons/flat/16x16/glabels-file-new.svg index 3ec7ab7..7c0d820 100644 --- a/glabels/icons/flat/16x16/glabels-file-new.svg +++ b/glabels/icons/flat/16x16/glabels-file-new.svg @@ -5,27 +5,27 @@ d="M 3.5,1.5 3.5,14.5 13.5,14.5 13.5,4.5 10.5,1.5 Z" /> + + + + + + + + + diff --git a/glabels/icons/flat/22x22/glabels-file-new.svg b/glabels/icons/flat/22x22/glabels-file-new.svg index 9f4dab2..0b3dd35 100644 --- a/glabels/icons/flat/22x22/glabels-file-new.svg +++ b/glabels/icons/flat/22x22/glabels-file-new.svg @@ -5,35 +5,35 @@ d="M 4.5,1.5 4.5,19.5 18.5,19.5 18.5,6.5 13.5,1.5 Z" /> + + + + + + + + + diff --git a/glabels/icons/flat/24x24/glabels-file-new.svg b/glabels/icons/flat/24x24/glabels-file-new.svg index f69edb7..8eb1cef 100644 --- a/glabels/icons/flat/24x24/glabels-file-new.svg +++ b/glabels/icons/flat/24x24/glabels-file-new.svg @@ -5,35 +5,35 @@ d="M 5.5,2.5 5.5,20.5 19.5,20.5 19.5,7.5 14.5,2.5 Z" /> + + + + + + + + + diff --git a/glabels/icons/flat/32x32/glabels-file-new.svg b/glabels/icons/flat/32x32/glabels-file-new.svg new file mode 100644 index 0000000..525b04e --- /dev/null +++ b/glabels/icons/flat/32x32/glabels-file-new.svg @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/glabels/icons/flat/32x32/glabels-file-open.svg b/glabels/icons/flat/32x32/glabels-file-open.svg new file mode 100644 index 0000000..0efe158 --- /dev/null +++ b/glabels/icons/flat/32x32/glabels-file-open.svg @@ -0,0 +1,15 @@ + + + + + + + + + diff --git a/glabels/icons/flat/32x32/glabels-file-recent.svg b/glabels/icons/flat/32x32/glabels-file-recent.svg new file mode 100644 index 0000000..95fc950 --- /dev/null +++ b/glabels/icons/flat/32x32/glabels-file-recent.svg @@ -0,0 +1,16 @@ + + + + + + + + + + diff --git a/glabels/ui/StartupView.ui b/glabels/ui/StartupView.ui index 0aca3cb..f339483 100644 --- a/glabels/ui/StartupView.ui +++ b/glabels/ui/StartupView.ui @@ -7,7 +7,7 @@ 0 0 460 - 397 + 418 @@ -136,16 +136,16 @@ - New Project + New... - :/icons/flat/24x24/glabels-file-new.svg:/icons/flat/24x24/glabels-file-new.svg + :/icons/flat/32x32/glabels-file-new.svg:/icons/flat/32x32/glabels-file-new.svg - 24 - 24 + 32 + 32 @@ -168,16 +168,16 @@ - Open Project + Browse... - :/icons/flat/24x24/glabels-file-open.svg:/icons/flat/24x24/glabels-file-open.svg + :/icons/flat/32x32/glabels-file-open.svg:/icons/flat/32x32/glabels-file-open.svg - 24 - 24 + 32 + 32 @@ -185,6 +185,32 @@ + + + + + 319 + 59 + + + + Recent + + + + :/icons/flat/32x32/glabels-file-recent.svg:/icons/flat/32x32/glabels-file-recent.svg + + + + 32 + 32 + + + + Open a recent gLabels project + + + diff --git a/translations/glabels_C.ts b/translations/glabels_C.ts index 324c779..4380651 100644 --- a/translations/glabels_C.ts +++ b/translations/glabels_C.ts @@ -735,16 +735,24 @@ Welcome to gLabels. Let's get started: - - New Project - - Create a new blank gLabels project - Open Project + Open a recent gLabels project + + + + Recent + + + + New... + + + + Browse...