Added Barcode menu class.

This commit is contained in:
Jim Evins
2014-07-06 00:13:41 -04:00
parent 8c781ee1d4
commit a9d9313e5a
5 changed files with 176 additions and 12 deletions
+68
View File
@@ -0,0 +1,68 @@
/* BarcodeMenu.cpp
*
* Copyright (C) 2014 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#include "BarcodeMenu.h"
#include "BarcodeBackends.h"
#include "BarcodeMenuItem.h"
namespace glabels
{
///
/// Constructor
///
BarcodeMenu::BarcodeMenu()
{
foreach ( QString name, BarcodeBackends::getNameList() )
{
const BarcodeStyle* bcStyle = BarcodeBackends::lookupStyleFromName( name );
BarcodeMenuItem* bcMenuItem = new BarcodeMenuItem( bcStyle );
connect( bcMenuItem, SIGNAL(activated()), this, SLOT(onMenuItemActivated) );
addAction( bcMenuItem );
}
}
///
/// bcStyle getter
///
const BarcodeStyle* BarcodeMenu::bcStyle() const
{
return mBcStyle;
}
///
/// onMenuItemActivated slot
///
void BarcodeMenu::onMenuItemActivated( BarcodeStyle *bcStyle )
{
mBcStyle = bcStyle;
emit styleChanged();
}
}
+77
View File
@@ -0,0 +1,77 @@
/* BarcodeMenu.h
*
* Copyright (C) 2014 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glabels_BarcodeMenu_h
#define glabels_BarcodeMenu_h
#include <QMenu>
#include "BarcodeStyle.h"
namespace glabels
{
///
/// Barcode Menu Item
///
class BarcodeMenu : public QMenu
{
Q_OBJECT
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
BarcodeMenu();
/////////////////////////////////
// Signals
/////////////////////////////////
signals:
void styleChanged();
/////////////////////////////////
// Properties
/////////////////////////////////
public:
const BarcodeStyle* bcStyle() const;
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onMenuItemActivated( BarcodeStyle *bcStyle );
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
BarcodeStyle* mBcStyle;
};
}
#endif // glabels_BarcodeMenu_h
+11 -8
View File
@@ -27,18 +27,12 @@ namespace glabels
///
/// Constructor From Data
///
BarcodeMenuItem::BarcodeMenuItem( BarcodeStyle* bcStyle, QObject* parent )
BarcodeMenuItem::BarcodeMenuItem( const BarcodeStyle* bcStyle, QObject* parent )
: QAction(parent), mBcStyle(bcStyle)
{
setText( bcStyle->name() );
}
///
/// Destructor
///
BarcodeMenuItem::~BarcodeMenuItem()
{
connect( this, SIGNAL(triggered()), this, SLOT(onTriggered()) );
}
@@ -50,5 +44,14 @@ namespace glabels
return mBcStyle;
}
///
/// onTriggered slot
///
void BarcodeMenuItem::onTriggered()
{
emit activated( mBcStyle );
}
}
+17 -4
View File
@@ -33,28 +33,41 @@ namespace glabels
///
class BarcodeMenuItem : public QAction
{
Q_OBJECT
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
BarcodeMenuItem( BarcodeStyle* bcStyle, QObject* parent );
BarcodeMenuItem( const BarcodeStyle* bcStyle, QObject* parent = 0 );
virtual ~BarcodeMenuItem();
/////////////////////////////////
// Signals
/////////////////////////////////
signals:
void activated( const BarcodeStyle* bcStyle );
/////////////////////////////////
// Properties
/////////////////////////////////
public:
const BarcodeStyle* bcStyle() const;
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onTriggered();
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
BarcodeStyle* mBcStyle;
const BarcodeStyle* mBcStyle;
};
+3
View File
@@ -5,6 +5,7 @@ project (app CXX)
set (glabels_sources
glabels_main.cpp
BarcodeBackends.cpp
BarcodeMenu.cpp
BarcodeMenuItem.cpp
BarcodeStyle.cpp
ColorNode.cpp
@@ -26,6 +27,8 @@ set (glabels_sources
)
set (glabels_qobject_headers
BarcodeMenu.h
BarcodeMenuItem.h
LabelModel.h
LabelModelObject.h
LabelModelBoxObject.h