Added skeletal print view.

This commit is contained in:
Jim Evins
2015-08-20 21:02:13 -04:00
parent b614d8dacb
commit a345acb90f
8 changed files with 672 additions and 9 deletions
+3
View File
@@ -34,6 +34,7 @@ set (glabels_sources
NewLabelDialog.cpp
ObjectEditor.cpp
Outline.cpp
PrintView.cpp
TemplatePicker.cpp
TemplatePickerItem.cpp
TextNode.cpp
@@ -62,6 +63,7 @@ set (glabels_qobject_headers
MainWindow.h
NewLabelDialog.h
ObjectEditor.h
PrintView.h
SimplePreview.h
TemplatePicker.h
View.h
@@ -70,6 +72,7 @@ set (glabels_qobject_headers
set (glabels_forms
ui/NewLabelDialog.ui
ui/ObjectEditor.ui
ui/PrintView.ui
)
set (glabels_resource_files
+32 -1
View File
@@ -34,6 +34,7 @@
#include "libglabels/Db.h"
#include "View.h"
#include "ObjectEditor.h"
#include "PrintView.h"
#include "LabelModel.h"
#include "LabelModelBoxObject.h"
#include "Icons.h"
@@ -65,8 +66,15 @@ namespace glabels
createStatusBar();
QWidget* editorPage = createEditorPage();
QWidget* mergePage = createMergePage();
QWidget* printPage = createPrintPage();
QTabWidget* notebook = new QTabWidget();
notebook->addTab( editorPage, "Editor" );
notebook->addTab( mergePage, "Merge" );
notebook->addTab( printPage, "Print" );
setCentralWidget( editorPage );
setCentralWidget( notebook );
setDocVerbsEnabled( false );
setPasteVerbsEnabled( false );
@@ -104,6 +112,7 @@ namespace glabels
mModel = label;
mView->setModel( mModel );
mObjectEditor->setModel( mModel );
mPrintView->setModel( mModel );
setDocVerbsEnabled( true );
setSelectionVerbsEnabled( false );
@@ -593,6 +602,28 @@ namespace glabels
}
///
/// Create Merge Page
///
QWidget* MainWindow::createMergePage()
{
QWidget* page = new QWidget;
return page;
}
///
/// Create Print Page
///
QWidget* MainWindow::createPrintPage()
{
mPrintView = new PrintView();
return mPrintView;
}
///
/// Set enabled state of actions associated with a document.
///
+4
View File
@@ -37,6 +37,7 @@ namespace glabels
class LabelModel;
class View;
class ObjectEditor;
class PrintView;
///
@@ -152,6 +153,8 @@ namespace glabels
void createStatusBar();
QWidget* createEditorPage();
QWidget* createMergePage();
QWidget* createPrintPage();
void setDocVerbsEnabled( bool );
void setDocModifiedVerbsEnabled( bool );
@@ -189,6 +192,7 @@ namespace glabels
LabelModel* mModel;
View* mView;
ObjectEditor* mObjectEditor;
PrintView* mPrintView;
QLabel* zoomInfoLabel;
QLabel* cursorInfoLabel;
+70
View File
@@ -0,0 +1,70 @@
/* PrintView.cpp
*
* Copyright (C) 2013 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 "PrintView.h"
#include "LabelModel.h"
namespace glabels
{
///
/// Constructor
///
PrintView::PrintView( QWidget *parent )
: QWidget(parent)
{
setupUi( this );
}
///
/// Set Model
///
void PrintView::setModel( LabelModel* model )
{
mModel = model;
connect( mModel, SIGNAL(sizeChanged()), this, SLOT(onLabelSizeChanged()) );
connect( mModel, SIGNAL(changed()), this, SLOT(onLabelChanged()) );
onLabelSizeChanged();
onLabelChanged();
}
///
/// Label size changed handler
///
void PrintView::onLabelSizeChanged()
{
preview->setTemplate( mModel->tmplate() );
}
///
/// Label changed handler
///
void PrintView::onLabelChanged()
{
}
}
+71
View File
@@ -0,0 +1,71 @@
/* PrintView.h
*
* Copyright (C) 2013 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_PrintView_h
#define glabels_PrintView_h
#include "ui_PrintView.h"
namespace glabels
{
class LabelModel; // Forward reference
///
/// Print View Widget
///
class PrintView : public QWidget, public Ui_PrintView
{
Q_OBJECT
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
PrintView( QWidget *parent = 0 );
/////////////////////////////////
// Public methods
/////////////////////////////////
void setModel( LabelModel* model );
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onLabelChanged();
void onLabelSizeChanged();
/////////////////////////////////
// Private Data
/////////////////////////////////
private:
LabelModel* mModel;
};
}
#endif // glabels_PrintView_h
+16 -7
View File
@@ -22,7 +22,7 @@
#include <QGraphicsRectItem>
#include <QGraphicsDropShadowEffect>
#include <iostream>
#include <QtDebug>
//
@@ -58,7 +58,7 @@ namespace glabels
/// Constructor
///
SimplePreview::SimplePreview( QWidget *parent = 0 )
: mScale(1), mTmplate(NULL), mRotateFlag(false), QGraphicsView(parent)
: mTmplate(NULL), mRotateFlag(false), QGraphicsView(parent)
{
mScene = new QGraphicsScene();
setScene( mScene );
@@ -91,6 +91,15 @@ namespace glabels
}
///
/// Resize Event Handler
///
void SimplePreview::resizeEvent( QResizeEvent* event )
{
fitInView( mScene->sceneRect(), Qt::KeepAspectRatio );
}
///
/// Update View
///
@@ -107,9 +116,7 @@ namespace glabels
double h = 1.10 * mTmplate->pageHeight();
mScene->setSceneRect( x, y, w, h );
fitInView( x, y, w, h, Qt::KeepAspectRatio );
mScale = matrix().m11();
fitInView( mScene->sceneRect(), Qt::KeepAspectRatio );
drawPaper( mTmplate->pageWidth(), mTmplate->pageHeight() );
drawLabels();
@@ -143,7 +150,8 @@ namespace glabels
QBrush brush( paperColor );
QPen pen( paperOutlineColor );
pen.setWidthF( paperOutlineWidthPixels / mScale );
pen.setCosmetic( true );
pen.setWidthF( paperOutlineWidthPixels );
QGraphicsRectItem *pageItem = new QGraphicsRectItem( 0, 0, pw, ph );
pageItem->setBrush( brush );
@@ -175,7 +183,8 @@ namespace glabels
{
QBrush brush( labelColor );
QPen pen( labelOutlineColor );
pen.setWidthF( labelOutlineWidthPixels / mScale );
pen.setCosmetic( true );
pen.setWidthF( labelOutlineWidthPixels );
QGraphicsPathItem *labelItem = new QGraphicsPathItem( path );
labelItem->setBrush( brush );
+7 -1
View File
@@ -55,6 +55,13 @@ namespace glabels
void setRotate( bool rotateFlag );
/////////////////////////////////////
// Event handlers
/////////////////////////////////////
protected:
void resizeEvent( QResizeEvent* event );
/////////////////////////////////
// Internal Methods
/////////////////////////////////
@@ -75,7 +82,6 @@ namespace glabels
bool mRotateFlag;
QGraphicsScene *mScene;
double mScale;
};
+469
View File
@@ -0,0 +1,469 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PrintView</class>
<widget class="QWidget" name="PrintView">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>778</width>
<height>574</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="2">
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="glabels::SimplePreview" name="preview" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>400</width>
<height>520</height>
</size>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Page</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="pageSpin"/>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>of</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="nPagesLabel">
<property name="text">
<string>nn</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<property name="margin">
<number>24</number>
</property>
<item>
<widget class="QToolButton" name="printButton">
<property name="text">
<string>Print</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/24x24/actions/fallback-file-print.png</normaloff>:/icons/24x24/actions/fallback-file-print.png</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextUnderIcon</enum>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>16777215</height>
</size>
</property>
<property name="title">
<string>Printer</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QComboBox" name="printerCombo"/>
</item>
<item>
<widget class="QPushButton" name="printerPropertiesButton">
<property name="text">
<string>Properties</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="copiesBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>16777215</height>
</size>
</property>
<property name="title">
<string>Copies</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QRadioButton" name="copiesLabelsCombo">
<property name="text">
<string>Labels from:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="copiesFromSpin"/>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>to:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="copiesToSpin"/>
</item>
</layout>
</item>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QRadioButton" name="copiesSheetsRadio">
<property name="text">
<string>Sheets:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="copiesSheetsSpin"/>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="mergeBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>16777215</height>
</size>
</property>
<property name="title">
<string>Merge options</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Start on label:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="mergeStartSpin"/>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>on 1st sheet</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Copies:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="mergeCopiesSpin"/>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>16777215</height>
</size>
</property>
<property name="title">
<string>Print options</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="printOutlinesCheck">
<property name="text">
<string>print outlines</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="printCropMarksCheck">
<property name="text">
<string>print crop marks</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="printReverseCheck">
<property name="text">
<string>print in reverse (i.e. a mirror image)</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="0" column="1">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>glabels::SimplePreview</class>
<extends>QWidget</extends>
<header>SimplePreview.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../icons.qrc"/>
</resources>
<connections/>
</ui>