Added a startup wizard.

This commit is contained in:
Jim Evins
2016-03-27 17:06:53 -04:00
parent 9a92c2a064
commit 5b21e8a23f
10 changed files with 326 additions and 28 deletions
+3
View File
@@ -43,6 +43,7 @@ set (glabels_sources
PreviewOverlayItem.cpp PreviewOverlayItem.cpp
SelectProductDialog.cpp SelectProductDialog.cpp
SimplePreview.cpp SimplePreview.cpp
StartupWizard.cpp
TemplatePicker.cpp TemplatePicker.cpp
TemplatePickerItem.cpp TemplatePickerItem.cpp
TextNode.cpp TextNode.cpp
@@ -77,6 +78,7 @@ set (glabels_qobject_headers
Preview.h Preview.h
SelectProductDialog.h SelectProductDialog.h
SimplePreview.h SimplePreview.h
StartupWizard.h
TemplatePicker.h TemplatePicker.h
View.h View.h
) )
@@ -87,6 +89,7 @@ set (glabels_forms
ui/PrintView.ui ui/PrintView.ui
ui/PropertiesView.ui ui/PropertiesView.ui
ui/SelectProductDialog.ui ui/SelectProductDialog.ui
ui/StartupWizard.ui
) )
set (glabels_resource_files set (glabels_resource_files
+24 -10
View File
@@ -22,7 +22,7 @@
#include "MainWindow.h" #include "MainWindow.h"
#include "LabelModel.h" #include "LabelModel.h"
#include "libglabels/Db.h" #include "SelectProductDialog.h"
#include "XmlLabelParser.h" #include "XmlLabelParser.h"
#include "XmlLabelCreator.h" #include "XmlLabelCreator.h"
#include "FileUtil.h" #include "FileUtil.h"
@@ -36,17 +36,31 @@
/// ///
/// New Label Dialog /// New Label Dialog
/// ///
void File::newLabel( MainWindow *window ) bool File::newLabel( MainWindow *window )
{ {
// @TODO lookup latest template, if none default based on locale SelectProductDialog dialog( window );
const glabels::Template* tmplate = glabels::Db::lookupTemplateFromBrandPart( "Avery", "5159" ); dialog.exec();
LabelModel* label = new LabelModel();
label->setTmplate( tmplate );
label->setRotate( false );
MainWindow *newWindow = new MainWindow(); const glabels::Template* tmplate = dialog.tmplate();
newWindow->setModel( label ); if ( tmplate )
newWindow->show(); {
LabelModel* label = new LabelModel();
label->setTmplate( tmplate );
// Intelligently decide to rotate label by default
const glabels::Frame* frame = tmplate->frames().first();
label->setRotate( frame->h() > frame->w() );
MainWindow *newWindow = new MainWindow();
newWindow->setModel( label );
newWindow->show();
return true;
}
else
{
return false;
}
} }
+1 -1
View File
@@ -36,7 +36,7 @@ class File : public QObject
Q_OBJECT Q_OBJECT
public: public:
static void newLabel( MainWindow *window = 0 ); static bool newLabel( MainWindow *window = 0 );
static void open( MainWindow *window ); static void open( MainWindow *window );
static bool save( MainWindow *window ); static bool save( MainWindow *window );
static bool saveAs( MainWindow *window ); static bool saveAs( MainWindow *window );
+8 -13
View File
@@ -81,6 +81,13 @@ MainWindow::MainWindow()
setPasteVerbsEnabled( false ); setPasteVerbsEnabled( false );
setTitle(); setTitle();
connect( mView, SIGNAL(zoomChanged()), this, SLOT(onZoomChanged()) );
#if 0
connect( mView, SIGNAL(pointerMoved(double, double)),
this, SLOT(onPointerMoved(double, double)) );
connect( mView, SIGNAL(pointerExited()), this, SLOT(onPointerExit()) );
#endif
readSettings(); readSettings();
smWindowList.push_back( this ); smWindowList.push_back( this );
@@ -603,19 +610,7 @@ void MainWindow::createToolBars()
/// ///
void MainWindow::createStatusBar() void MainWindow::createStatusBar()
{ {
cursorInfoLabel = new QLabel; statusBar();
cursorInfoLabel->setIndent( 3 );
cursorInfoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken );
statusBar()->addWidget( cursorInfoLabel, 1 );
onZoomChanged();
onPointerExit();
connect( mView, SIGNAL(zoomChanged()), this, SLOT(onZoomChanged()) );
connect( mView, SIGNAL(pointerMoved(double, double)),
this, SLOT(onPointerMoved(double, double)) );
connect( mView, SIGNAL(pointerExited()), this, SLOT(onPointerExit()) );
} }
+61
View File
@@ -0,0 +1,61 @@
/* StartupWizard.cpp
*
* Copyright (C) 2016 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 "StartupWizard.h"
#include "File.h"
#include <QtDebug>
///
/// Constructor
///
StartupWizard::StartupWizard( QWidget *parent )
: QDialog(parent)
{
setupUi( this );
}
///
/// "New Project" Button Clicked Slot
///
void StartupWizard::onNewProjectButtonClicked()
{
hide();
if ( File::newLabel() )
{
close();
}
else
{
show();
}
}
///
/// "Open Project" Button Clicked Slot
///
void StartupWizard::onOpenProjectButtonClicked()
{
qDebug() << "OPEN PROJECT";
}
+52
View File
@@ -0,0 +1,52 @@
/* StartupWizard.h
*
* Copyright (C) 2016 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 StartupWizard_h
#define StartupWizard_h
#include "ui_StartupWizard.h"
///
/// Startup Wizard Dialog Widget
///
class StartupWizard : public QDialog, public Ui_StartupWizard
{
Q_OBJECT
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
StartupWizard( QWidget *parent = 0 );
/////////////////////////////////
// Slots
/////////////////////////////////
private slots:
void onNewProjectButtonClicked();
void onOpenProjectButtonClicked();
};
#endif // StartupWizard_h
+4 -2
View File
@@ -21,8 +21,8 @@
#include <QApplication> #include <QApplication>
#include "File.h"
#include "libglabels/Db.h" #include "libglabels/Db.h"
#include "StartupWizard.h"
int main( int argc, char **argv ) int main( int argc, char **argv )
@@ -43,7 +43,9 @@ int main( int argc, char **argv )
#endif #endif
///////////////////////////////// /////////////////////////////////
File::newLabel(); /// @TODO open file(s) from command line if present, otherwise start wizard
StartupWizard startupWizard;
startupWizard.show();
return app.exec(); return app.exec();
} }
+7 -1
View File
@@ -225,11 +225,14 @@
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QPushButton" name="changeProductButton"> <widget class="QPushButton" name="changeProductButton">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Select another product for this gLabels project.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">text-align:left; padding:3px;</string> <string notr="true">text-align:left; padding:3px;</string>
</property> </property>
<property name="text"> <property name="text">
<string>Select another product</string> <string>Change product</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../icons.qrc"> <iconset resource="../icons.qrc">
@@ -268,6 +271,9 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="toolTip">
<string>Select horizontal or vertical orientation.</string>
</property>
<property name="iconSize"> <property name="iconSize">
<size> <size>
<width>32</width> <width>32</width>
+1 -1
View File
@@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Dialog</string> <string>gLabels - Select Product</string>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<item> <item>
+165
View File
@@ -0,0 +1,165 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>StartupWizard</class>
<widget class="QDialog" name="StartupWizard">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>339</width>
<height>218</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>gLabels - Startup Wizard</string>
</property>
<property name="windowOpacity">
<double>0.000000000000000</double>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>319</width>
<height>53</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>53</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">padding:8px;</string>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:24pt; font-weight:600;&quot;&gt;gLabels &lt;/span&gt;&lt;span style=&quot; font-size:16pt; color:#909090;&quot;&gt;Label Designer&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QCommandLinkButton" name="newProjectButton">
<property name="minimumSize">
<size>
<width>319</width>
<height>59</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>59</height>
</size>
</property>
<property name="text">
<string>New Project</string>
</property>
<property name="description">
<string>Create a new blank gLabels project</string>
</property>
</widget>
</item>
<item>
<widget class="QCommandLinkButton" name="openProjectButton">
<property name="minimumSize">
<size>
<width>319</width>
<height>59</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>59</height>
</size>
</property>
<property name="text">
<string>Open Project</string>
</property>
<property name="description">
<string>Open an existing gLabels project</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources>
<include location="../images.qrc"/>
</resources>
<connections>
<connection>
<sender>newProjectButton</sender>
<signal>clicked()</signal>
<receiver>StartupWizard</receiver>
<slot>onNewProjectButtonClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>291</x>
<y>102</y>
</hint>
<hint type="destinationlabel">
<x>338</x>
<y>108</y>
</hint>
</hints>
</connection>
<connection>
<sender>openProjectButton</sender>
<signal>clicked()</signal>
<receiver>StartupWizard</receiver>
<slot>onOpenProjectButtonClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>312</x>
<y>170</y>
</hint>
<hint type="destinationlabel">
<x>338</x>
<y>169</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>onNewProjectButtonClicked()</slot>
<slot>onOpenProjectButtonClicked()</slot>
</slots>
</ui>