Skip to content

Commit

Permalink
Added "Open Recent" button to StartupView.
Browse files Browse the repository at this point in the history
- Also disabled broken MacOS build in travis CI file
  • Loading branch information
jimevins committed Nov 13, 2019
1 parent 75e613e commit f09ca36
Show file tree
Hide file tree
Showing 17 changed files with 267 additions and 57 deletions.
44 changes: 22 additions & 22 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)


# #####################
Expand Down
15 changes: 15 additions & 0 deletions glabels/Icons.h
Original file line number Diff line number Diff line change
Expand Up @@ -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" ) );
}
};

Expand All @@ -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" ) );
}
};

Expand Down
2 changes: 1 addition & 1 deletion glabels/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
32 changes: 32 additions & 0 deletions glabels/StartupView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
#include "File.h"
#include "MainWindow.h"

#include "model/Settings.h"

#include <QAction>
#include <QFileInfo>
#include <QMenu>
#include <QtDebug>


Expand All @@ -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 );
}


Expand All @@ -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
1 change: 1 addition & 0 deletions glabels/StartupView.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ namespace glabels
private slots:
void onNewProjectButtonClicked();
void onOpenProjectButtonClicked();
void onOpenRecentAction();


/////////////////////////////////
Expand Down
6 changes: 6 additions & 0 deletions glabels/icons.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<file>icons/flat/16x16/glabels-ellipse.svg</file>
<file>icons/flat/16x16/glabels-file-new.svg</file>
<file>icons/flat/16x16/glabels-file-open.svg</file>
<file>icons/flat/16x16/glabels-file-recent.svg</file>
<file>icons/flat/16x16/glabels-file-save.svg</file>
<file>icons/flat/16x16/glabels-file-save-as.svg</file>
<file>icons/flat/16x16/glabels-flip-horiz.svg</file>
Expand Down Expand Up @@ -50,6 +51,7 @@
<file>icons/flat/22x22/glabels-ellipse.svg</file>
<file>icons/flat/22x22/glabels-file-new.svg</file>
<file>icons/flat/22x22/glabels-file-open.svg</file>
<file>icons/flat/22x22/glabels-file-recent.svg</file>
<file>icons/flat/22x22/glabels-file-save.svg</file>
<file>icons/flat/22x22/glabels-file-save-as.svg</file>
<file>icons/flat/22x22/glabels-format-text-bold.svg</file>
Expand Down Expand Up @@ -79,6 +81,7 @@
<file>icons/flat/24x24/glabels-ellipse.svg</file>
<file>icons/flat/24x24/glabels-file-new.svg</file>
<file>icons/flat/24x24/glabels-file-open.svg</file>
<file>icons/flat/24x24/glabels-file-recent.svg</file>
<file>icons/flat/24x24/glabels-file-save.svg</file>
<file>icons/flat/24x24/glabels-file-save-as.svg</file>
<file>icons/flat/24x24/glabels-format-text-bold.svg</file>
Expand All @@ -92,6 +95,9 @@
<file>icons/flat/24x24/glabels-valign-text-middle.svg</file>
<file>icons/flat/24x24/glabels-valign-text-top.svg</file>

<file>icons/flat/32x32/glabels-file-new.svg</file>
<file>icons/flat/32x32/glabels-file-open.svg</file>
<file>icons/flat/32x32/glabels-file-recent.svg</file>
<file>icons/flat/32x32/glabels-label-orientation-horiz.svg</file>
<file>icons/flat/32x32/glabels-label-orientation-vert.svg</file>
<file>icons/flat/32x32/glabels-print.svg</file>
Expand Down
12 changes: 6 additions & 6 deletions glabels/icons/flat/16x16/glabels-file-new.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions glabels/icons/flat/16x16/glabels-file-recent.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 8 additions & 8 deletions glabels/icons/flat/22x22/glabels-file-new.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions glabels/icons/flat/22x22/glabels-file-recent.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 8 additions & 8 deletions glabels/icons/flat/24x24/glabels-file-new.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions glabels/icons/flat/24x24/glabels-file-recent.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions glabels/icons/flat/32x32/glabels-file-new.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f09ca36

Please sign in to comment.