Added Barcode menu class.
This commit is contained in:
@@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -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
@@ -27,18 +27,12 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
/// Constructor From Data
|
/// Constructor From Data
|
||||||
///
|
///
|
||||||
BarcodeMenuItem::BarcodeMenuItem( BarcodeStyle* bcStyle, QObject* parent )
|
BarcodeMenuItem::BarcodeMenuItem( const BarcodeStyle* bcStyle, QObject* parent )
|
||||||
: QAction(parent), mBcStyle(bcStyle)
|
: QAction(parent), mBcStyle(bcStyle)
|
||||||
{
|
{
|
||||||
setText( bcStyle->name() );
|
setText( bcStyle->name() );
|
||||||
}
|
|
||||||
|
|
||||||
|
connect( this, SIGNAL(triggered()), this, SLOT(onTriggered()) );
|
||||||
///
|
|
||||||
/// Destructor
|
|
||||||
///
|
|
||||||
BarcodeMenuItem::~BarcodeMenuItem()
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -50,5 +44,14 @@ namespace glabels
|
|||||||
return mBcStyle;
|
return mBcStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// onTriggered slot
|
||||||
|
///
|
||||||
|
void BarcodeMenuItem::onTriggered()
|
||||||
|
{
|
||||||
|
emit activated( mBcStyle );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+17
-4
@@ -33,28 +33,41 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
class BarcodeMenuItem : public QAction
|
class BarcodeMenuItem : public QAction
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Life Cycle
|
// Life Cycle
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
BarcodeMenuItem( BarcodeStyle* bcStyle, QObject* parent );
|
BarcodeMenuItem( const BarcodeStyle* bcStyle, QObject* parent = 0 );
|
||||||
|
|
||||||
virtual ~BarcodeMenuItem();
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Signals
|
||||||
|
/////////////////////////////////
|
||||||
|
signals:
|
||||||
|
void activated( const BarcodeStyle* bcStyle );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Properties
|
// Properties
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
const BarcodeStyle* bcStyle() const;
|
const BarcodeStyle* bcStyle() const;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Slots
|
||||||
|
/////////////////////////////////
|
||||||
|
private slots:
|
||||||
|
void onTriggered();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Private Data
|
// Private Data
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
BarcodeStyle* mBcStyle;
|
const BarcodeStyle* mBcStyle;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ project (app CXX)
|
|||||||
set (glabels_sources
|
set (glabels_sources
|
||||||
glabels_main.cpp
|
glabels_main.cpp
|
||||||
BarcodeBackends.cpp
|
BarcodeBackends.cpp
|
||||||
|
BarcodeMenu.cpp
|
||||||
BarcodeMenuItem.cpp
|
BarcodeMenuItem.cpp
|
||||||
BarcodeStyle.cpp
|
BarcodeStyle.cpp
|
||||||
ColorNode.cpp
|
ColorNode.cpp
|
||||||
@@ -26,6 +27,8 @@ set (glabels_sources
|
|||||||
)
|
)
|
||||||
|
|
||||||
set (glabels_qobject_headers
|
set (glabels_qobject_headers
|
||||||
|
BarcodeMenu.h
|
||||||
|
BarcodeMenuItem.h
|
||||||
LabelModel.h
|
LabelModel.h
|
||||||
LabelModelObject.h
|
LabelModelObject.h
|
||||||
LabelModelBoxObject.h
|
LabelModelBoxObject.h
|
||||||
|
|||||||
Reference in New Issue
Block a user