diff --git a/glabels/CMakeLists.txt b/glabels/CMakeLists.txt index 4deacee..b2fc719 100644 --- a/glabels/CMakeLists.txt +++ b/glabels/CMakeLists.txt @@ -43,6 +43,7 @@ set (glabels_sources PreviewOverlayItem.cpp SelectProductDialog.cpp SimplePreview.cpp + StartupWizard.cpp TemplatePicker.cpp TemplatePickerItem.cpp TextNode.cpp @@ -77,6 +78,7 @@ set (glabels_qobject_headers Preview.h SelectProductDialog.h SimplePreview.h + StartupWizard.h TemplatePicker.h View.h ) @@ -87,6 +89,7 @@ set (glabels_forms ui/PrintView.ui ui/PropertiesView.ui ui/SelectProductDialog.ui + ui/StartupWizard.ui ) set (glabels_resource_files diff --git a/glabels/File.cpp b/glabels/File.cpp index 8cbcc49..342feed 100644 --- a/glabels/File.cpp +++ b/glabels/File.cpp @@ -22,7 +22,7 @@ #include "MainWindow.h" #include "LabelModel.h" -#include "libglabels/Db.h" +#include "SelectProductDialog.h" #include "XmlLabelParser.h" #include "XmlLabelCreator.h" #include "FileUtil.h" @@ -36,17 +36,31 @@ /// /// New Label Dialog /// -void File::newLabel( MainWindow *window ) +bool File::newLabel( MainWindow *window ) { - // @TODO lookup latest template, if none default based on locale - const glabels::Template* tmplate = glabels::Db::lookupTemplateFromBrandPart( "Avery", "5159" ); - LabelModel* label = new LabelModel(); - label->setTmplate( tmplate ); - label->setRotate( false ); + SelectProductDialog dialog( window ); + dialog.exec(); - MainWindow *newWindow = new MainWindow(); - newWindow->setModel( label ); - newWindow->show(); + const glabels::Template* tmplate = dialog.tmplate(); + if ( tmplate ) + { + 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; + } } diff --git a/glabels/File.h b/glabels/File.h index e679191..aa562c9 100644 --- a/glabels/File.h +++ b/glabels/File.h @@ -36,7 +36,7 @@ class File : public QObject Q_OBJECT public: - static void newLabel( MainWindow *window = 0 ); + static bool newLabel( MainWindow *window = 0 ); static void open( MainWindow *window ); static bool save( MainWindow *window ); static bool saveAs( MainWindow *window ); diff --git a/glabels/MainWindow.cpp b/glabels/MainWindow.cpp index 5c0d33b..ea2b4cf 100644 --- a/glabels/MainWindow.cpp +++ b/glabels/MainWindow.cpp @@ -81,6 +81,13 @@ MainWindow::MainWindow() setPasteVerbsEnabled( false ); 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(); smWindowList.push_back( this ); @@ -603,19 +610,7 @@ void MainWindow::createToolBars() /// void MainWindow::createStatusBar() { - cursorInfoLabel = new QLabel; - 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()) ); + statusBar(); } diff --git a/glabels/StartupWizard.cpp b/glabels/StartupWizard.cpp new file mode 100644 index 0000000..8d7f7bd --- /dev/null +++ b/glabels/StartupWizard.cpp @@ -0,0 +1,61 @@ +/* StartupWizard.cpp + * + * Copyright (C) 2016 Jim Evins + * + * 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 . + */ + +#include "StartupWizard.h" + +#include "File.h" +#include + + +/// +/// 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"; +} diff --git a/glabels/StartupWizard.h b/glabels/StartupWizard.h new file mode 100644 index 0000000..42dc6c9 --- /dev/null +++ b/glabels/StartupWizard.h @@ -0,0 +1,52 @@ +/* StartupWizard.h + * + * Copyright (C) 2016 Jim Evins + * + * 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 . + */ + +#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 diff --git a/glabels/glabels_main.cpp b/glabels/glabels_main.cpp index 9eeee7c..1012136 100644 --- a/glabels/glabels_main.cpp +++ b/glabels/glabels_main.cpp @@ -21,8 +21,8 @@ #include -#include "File.h" #include "libglabels/Db.h" +#include "StartupWizard.h" int main( int argc, char **argv ) @@ -43,7 +43,9 @@ int main( int argc, char **argv ) #endif ///////////////////////////////// - File::newLabel(); + /// @TODO open file(s) from command line if present, otherwise start wizard + StartupWizard startupWizard; + startupWizard.show(); return app.exec(); } diff --git a/glabels/ui/PropertiesView.ui b/glabels/ui/PropertiesView.ui index 9407214..ebf3009 100644 --- a/glabels/ui/PropertiesView.ui +++ b/glabels/ui/PropertiesView.ui @@ -225,11 +225,14 @@ + + <html><head/><body><p>Select another product for this gLabels project.</p></body></html> + text-align:left; padding:3px; - Select another product + Change product @@ -268,6 +271,9 @@ 0 + + Select horizontal or vertical orientation. + 32 diff --git a/glabels/ui/SelectProductDialog.ui b/glabels/ui/SelectProductDialog.ui index e06629c..8bdbe3f 100644 --- a/glabels/ui/SelectProductDialog.ui +++ b/glabels/ui/SelectProductDialog.ui @@ -11,7 +11,7 @@ - Dialog + gLabels - Select Product diff --git a/glabels/ui/StartupWizard.ui b/glabels/ui/StartupWizard.ui new file mode 100644 index 0000000..6297678 --- /dev/null +++ b/glabels/ui/StartupWizard.ui @@ -0,0 +1,165 @@ + + + StartupWizard + + + + 0 + 0 + 339 + 218 + + + + + 0 + 0 + + + + gLabels - Startup Wizard + + + 0.000000000000000 + + + + + + + + + 0 + 0 + + + + + 319 + 53 + + + + + 16777215 + 53 + + + + padding:8px; + + + <html><head/><body><p><span style=" font-size:24pt; font-weight:600;">gLabels </span><span style=" font-size:16pt; color:#909090;">Label Designer</span></p></body></html> + + + + + + + Qt::Horizontal + + + + + + + + 319 + 59 + + + + + 16777215 + 59 + + + + New Project + + + Create a new blank gLabels project + + + + + + + + 319 + 59 + + + + + 16777215 + 59 + + + + Open Project + + + Open an existing gLabels project + + + + + + + + + Qt::Vertical + + + + 20 + 0 + + + + + + + + + + + + newProjectButton + clicked() + StartupWizard + onNewProjectButtonClicked() + + + 291 + 102 + + + 338 + 108 + + + + + openProjectButton + clicked() + StartupWizard + onOpenProjectButtonClicked() + + + 312 + 170 + + + 338 + 169 + + + + + + onNewProjectButtonClicked() + onOpenProjectButtonClicked() + +