diff --git a/src/app/app.pri b/src/app/app.pri index bfc1e20c3..ceb1aeec4 100644 --- a/src/app/app.pri +++ b/src/app/app.pri @@ -19,7 +19,8 @@ SOURCES += \ $$PWD/tablewindow.cpp \ $$PWD/stable.cpp \ $$PWD/version.cpp \ - $$PWD/options.cpp + $$PWD/options.cpp \ + $$PWD/mainwindowsnogui.cpp # Some header files HEADERS += \ @@ -27,7 +28,8 @@ HEADERS += \ $$PWD/options.h \ $$PWD/tablewindow.h \ $$PWD/stable.h \ - $$PWD/version.h + $$PWD/version.h \ + $$PWD/mainwindowsnogui.h # Main forms FORMS += \ diff --git a/src/app/main.cpp b/src/app/main.cpp index a2c470d01..b3556fd2c 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -118,9 +118,6 @@ int main(int argc, char *argv[]) MainWindow w; app.setWindowIcon(QIcon(":/icon/64x64/icon64x64.png")); app.setMainWindow(&w); - TableWindow table; - QObject::connect(&w, &MainWindow::ModelChosen, &table, &TableWindow::ModelChosen); - QObject::connect(&table, &TableWindow::closed, &w, &MainWindow::tableClosed); QCommandLineParser parser; parser.setApplicationDescription(QCoreApplication::translate("main", "Pattern making program.")); diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index 95687119f..025fceb32 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -73,8 +73,8 @@ Q_LOGGING_CATEGORY(vMainWindow, "v.mainwindow") * @param parent parent widget. */ MainWindow::MainWindow(QWidget *parent) - :QMainWindow(parent), ui(new Ui::MainWindow), pattern(nullptr), doc(nullptr), currentTool(Tool::Arrow), - lastUsedTool(Tool::Arrow), currentScene(nullptr), sceneDraw(nullptr), sceneDetails(nullptr), + :MainWindowsNoGUI(parent), ui(new Ui::MainWindow), doc(nullptr), currentTool(Tool::Arrow), + lastUsedTool(Tool::Arrow), sceneDraw(nullptr), sceneDetails(nullptr), mouseCoordinate(nullptr), helpLabel(nullptr), isInitialized(false), dialogTable(nullptr), dialogTool(nullptr), dialogHistory(nullptr), comboBoxDraws(nullptr), curFile(QString()), mode(Draw::Calculation), currentDrawIndex(0), currentToolBoxIndex(0), drawMode(true), recentFileActs(), @@ -95,33 +95,13 @@ MainWindow::MainWindow(QWidget *parent) CreateMenus(); ToolBarDraws(); InitToolButtons(); - - sceneDraw = new VMainGraphicsScene(); - currentScene = sceneDraw; - qApp->setCurrentScene(currentScene); - connect(this, &MainWindow::EnableItemMove, sceneDraw, &VMainGraphicsScene::EnableItemMove); - connect(sceneDraw, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove); - sceneDetails = new VMainGraphicsScene(); - connect(sceneDetails, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove); - - ui->view->setScene(currentScene); - - sceneDraw->setTransform(ui->view->transform()); - sceneDetails->setTransform(ui->view->transform()); - - connect(ui->view, &VMainGraphicsView::NewFactor, sceneDraw, &VMainGraphicsScene::SetFactor); - QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding); - policy.setHorizontalStretch(12); - ui->view->setSizePolicy(policy); - qApp->setSceneView(ui->view); + InitScenes(); helpLabel = new QLabel(QObject::tr("Create new pattern piece to start working.")); ui->statusBar->addWidget(helpLabel); ToolBarTools(); - pattern = new VContainer(); - doc = new VPattern(pattern, &mode, sceneDraw, sceneDetails); connect(doc, &VPattern::ClearMainWindow, this, &MainWindow::Clear); connect(doc, &VPattern::patternChanged, this, &MainWindow::PatternWasModified); @@ -221,6 +201,29 @@ void MainWindow::AddPP(const QString &PPName, const QString &path) ui->actionNewDraw->setEnabled(true); } +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::InitScenes() +{ + sceneDraw = new VMainGraphicsScene(); + currentScene = sceneDraw; + qApp->setCurrentScene(currentScene); + connect(this, &MainWindow::EnableItemMove, sceneDraw, &VMainGraphicsScene::EnableItemMove); + connect(sceneDraw, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove); + sceneDetails = new VMainGraphicsScene(); + connect(sceneDetails, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove); + + ui->view->setScene(currentScene); + + sceneDraw->setTransform(ui->view->transform()); + sceneDetails->setTransform(ui->view->transform()); + + connect(ui->view, &VMainGraphicsView::NewFactor, sceneDraw, &VMainGraphicsScene::SetFactor); + QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding); + policy.setHorizontalStretch(12); + ui->view->setSizePolicy(policy); + qApp->setSceneView(ui->view); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief OptionDraw help change name of pattern piece. @@ -704,16 +707,6 @@ void MainWindow::ShowToolTip(const QString &toolTip) helpLabel->setText(toolTip); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief tableClosed handle after close layout window. - */ -void MainWindow::tableClosed() -{ - ui->actionDetails->setChecked(true); - show(); -} - //--------------------------------------------------------------------------------------------------------------------- void MainWindow::OpenRecentFile() { @@ -1125,13 +1118,16 @@ void MainWindow::keyPressEvent ( QKeyEvent * event ) */ void MainWindow::SaveCurrentScene() { - /*Save transform*/ - currentScene->setTransform(ui->view->transform()); - /*Save scroll bars value for previous scene.*/ - QScrollBar *horScrollBar = ui->view->horizontalScrollBar(); - currentScene->setHorScrollBar(horScrollBar->value()); - QScrollBar *verScrollBar = ui->view->verticalScrollBar(); - currentScene->setVerScrollBar(verScrollBar->value()); + if (mode == Draw::Calculation || mode == Draw::Modeling) + { + /*Save transform*/ + currentScene->setTransform(ui->view->transform()); + /*Save scroll bars value for previous scene.*/ + QScrollBar *horScrollBar = ui->view->horizontalScrollBar(); + currentScene->setHorScrollBar(horScrollBar->value()); + QScrollBar *verScrollBar = ui->view->verticalScrollBar(); + currentScene->setVerScrollBar(verScrollBar->value()); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -1160,11 +1156,13 @@ void MainWindow::ActionDraw(bool checked) { qCDebug(vMainWindow, "Show draw scene"); ui->actionDetails->setChecked(false); + ui->actionLayout->setChecked(false); SaveCurrentScene(); currentScene = sceneDraw; ui->view->setScene(currentScene); - connect(ui->view, &VMainGraphicsView::NewFactor, sceneDraw, &VMainGraphicsScene::SetFactor); + connect(ui->view, &VMainGraphicsView::NewFactor, sceneDraw, &VMainGraphicsScene::SetFactor, + Qt::UniqueConnection); RestoreCurrentScene(); mode = Draw::Calculation; @@ -1180,6 +1178,8 @@ void MainWindow::ActionDraw(bool checked) ui->actionOptionDraw->setEnabled(true); ui->actionNewDraw->setEnabled(true); + ui->dockWidgetLayoutPages->setVisible(false); + ui->dockWidgetToolOptions->setVisible(true); } else { @@ -1198,11 +1198,12 @@ void MainWindow::ActionDetails(bool checked) { qCDebug(vMainWindow, "Show details scene"); ui->actionDraw->setChecked(false); + ui->actionLayout->setChecked(false); SaveCurrentScene(); currentScene = sceneDetails; ui->view->itemClicked(nullptr); - ui->view->setScene(sceneDetails); + ui->view->setScene(currentScene); disconnect(ui->view, &VMainGraphicsView::NewFactor, sceneDraw, &VMainGraphicsScene::SetFactor); RestoreCurrentScene(); @@ -1211,16 +1212,20 @@ void MainWindow::ActionDetails(bool checked) comboBoxDraws->setCurrentIndex(comboBoxDraws->count()-1); comboBoxDraws->setEnabled(false); - + if (mode == Draw::Calculation) + { + currentToolBoxIndex = ui->toolBox->currentIndex(); + } mode = Draw::Modeling; SetEnableTool(true); - currentToolBoxIndex = ui->toolBox->currentIndex(); ui->toolBox->setCurrentIndex(4); ui->actionHistory->setEnabled(false); ui->actionOptionDraw->setEnabled(false); ui->actionNewDraw->setEnabled(false); + ui->dockWidgetLayoutPages->setVisible(false); + ui->dockWidgetToolOptions->setVisible(true); } else { @@ -1228,6 +1233,60 @@ void MainWindow::ActionDetails(bool checked) } } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ActionLayout begin creation layout. + * @param checked true - button checked. + */ +void MainWindow::ActionLayout(bool checked) +{ + if (checked) + { + qCDebug(vMainWindow, "Show layout scene"); + ui->actionDraw->setChecked(false); + ui->actionDetails->setChecked(false); + SaveCurrentScene(); + + const QHash *details = pattern->DataDetails(); + if (details->count() == 0) + { + Layout(); + return; + } + + PrepareDetailsForLayout(details); + + currentScene = tempSceneLayout; + ui->view->itemClicked(nullptr); + ui->view->setScene(currentScene); + disconnect(ui->view, &VMainGraphicsView::NewFactor, sceneDraw, &VMainGraphicsScene::SetFactor); + + drawMode = false; + currentDrawIndex = comboBoxDraws->currentIndex();//save current pattern peace + comboBoxDraws->setCurrentIndex(-1); + comboBoxDraws->setEnabled(false); + + if (mode == Draw::Calculation) + { + currentToolBoxIndex = ui->toolBox->currentIndex(); + } + mode = Draw::Layout; + SetEnableTool(true); + ui->toolBox->setCurrentIndex(5); + + ui->actionHistory->setEnabled(false); + ui->actionOptionDraw->setEnabled(false); + ui->actionNewDraw->setEnabled(false); + + ui->dockWidgetLayoutPages->setVisible(true); + ui->dockWidgetToolOptions->setVisible(false); + } + else + { + ui->actionLayout->setChecked(true); + } +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief SaveAs save as pattern file. @@ -1644,16 +1703,17 @@ void MainWindow::ClickEndVisualization() //--------------------------------------------------------------------------------------------------------------------- void MainWindow::Layout() { - const QHash *details = pattern->DataDetails(); - if (details->size() > 0) + if (pattern->DataDetails()->size() > 0) { ui->actionDetails->setEnabled(true); ui->actionLayout->setEnabled(true); } else { + listDetails.clear(); ui->actionDetails->setEnabled(false); ui->actionLayout->setEnabled(false); + ui->actionDraw->setChecked(true); } } @@ -1898,41 +1958,6 @@ void MainWindow::ActionCurveDetailsMode(bool checked) sceneDraw->EnableDetailsMode(checked); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief ActionLayout begin creation layout. - * @param checked true - button checked. - */ -void MainWindow::ActionLayout(bool checked) -{ - Q_UNUSED(checked); - ActionDetails(true);//Get all list of details. - QVector listDetails; - const QHash *details = pattern->DataDetails(); - if (details->count() == 0) - { - return; - } - hide();//Now we can hide window - QHashIterator idetail(*details); - while (idetail.hasNext()) - { - idetail.next(); - VLayoutDetail det = VLayoutDetail(); - det.SetCountourPoints(idetail.value().ContourPoints(pattern)); - det.SetSeamAllowencePoints(idetail.value().SeamAllowancePoints(pattern), idetail.value().getSeamAllowance()); - det.setName(idetail.value().getName()); - det.setWidth(qApp->toPixel(idetail.value().getWidth())); - - listDetails.append(det); - } - QString description = doc->GetDescription(); - - QString fileName; - curFile.isEmpty() ? fileName = "unnamed" : fileName = curFile; - emit ModelChosen(listDetails, fileName, description); -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief ClosedActionHistory actions after closing history window with variables. @@ -1952,14 +1977,23 @@ void MainWindow::SetEnableTool(bool enable) { bool drawTools = false; bool modelingTools = false; - if (mode == Draw::Calculation) + bool layoutTools = false; + + switch (mode) { - drawTools = enable; - } - else - { - modelingTools = enable; + case Draw::Calculation: + drawTools = enable; + break; + case Draw::Modeling: + modelingTools = enable; + break; + case Draw::Layout: + layoutTools = enable; + break; + default: + break; } + //Drawing Tools ui->toolButtonEndLine->setEnabled(drawTools); ui->toolButtonLine->setEnabled(drawTools); @@ -1987,6 +2021,9 @@ void MainWindow::SetEnableTool(bool enable) //Modeling Tools ui->toolButtonUnionDetails->setEnabled(modelingTools); + + //Layout tools + ui->toolButtonLayoutSettings->setEnabled(layoutTools); } //--------------------------------------------------------------------------------------------------------------------- @@ -2456,7 +2493,6 @@ MainWindow::~MainWindow() #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) delete lock; // Unlock pattern file #endif - delete pattern; delete doc; delete sceneDetails; delete sceneDraw; diff --git a/src/app/mainwindow.h b/src/app/mainwindow.h index 62330c558..1e7a1202e 100644 --- a/src/app/mainwindow.h +++ b/src/app/mainwindow.h @@ -29,15 +29,14 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H -#include -#include "widgets/vmaingraphicsscene.h" +#include "mainwindowsnogui.h" #include "widgets/vmaingraphicsview.h" #include "dialogs/dialogs.h" #include "tools/vtooldetail.h" #include "tools/vtooluniondetails.h" #include "tools/drawTools/drawtools.h" #include "xml/vdomdocument.h" -#include "../libs/vlayout/vlayoutdetail.h" + namespace Ui { @@ -49,7 +48,7 @@ class VToolOptionsPropertyBrowser; /** * @brief The MainWindow class main windows. */ -class MainWindow : public QMainWindow +class MainWindow : public MainWindowsNoGUI { Q_OBJECT public: @@ -70,7 +69,6 @@ public slots: void ActionCurveDetailsMode(bool checked); void DrawOption(); - void tableClosed(); void ClosedActionTable(); void ClosedActionHistory(); @@ -141,13 +139,6 @@ public slots: void WindowsLocale(); void ToolBarStyles(); signals: - /** - * @brief ModelChosen emit after calculation all details. - * @param listDetails list of details. - * @param description pattern description. - */ - void ModelChosen(QVector listDetails, const QString &curFile, - const QString &description); void RefreshHistory(); void EnableItemMove(bool move); protected: @@ -160,9 +151,6 @@ private: /** @brief ui keeps information about user interface */ Ui::MainWindow *ui; - /** @brief pattern container with data (points, arcs, splines, spline paths, variables) */ - VContainer *pattern; - /** @brief doc dom document container */ VPattern *doc; @@ -172,9 +160,6 @@ private: /** @brief tool last used tool */ Tool lastUsedTool; - /** @brief currentScene pointer to current scene. */ - VMainGraphicsScene *currentScene; - /** @brief sceneDraw draw scene. */ VMainGraphicsScene *sceneDraw; @@ -284,6 +269,8 @@ private: void ToolBarStyle(QToolBar *bar); void AddPP(const QString &PPName, const QString &path); + + void InitScenes(); }; #endif // MAINWINDOW_H diff --git a/src/app/mainwindow.ui b/src/app/mainwindow.ui index 067fc3773..77573adb3 100644 --- a/src/app/mainwindow.ui +++ b/src/app/mainwindow.ui @@ -40,7 +40,7 @@ - 4 + 5 @@ -734,6 +734,32 @@ + + + Layout + + + + + + Settings + + + + + + + 32 + 32 + + + + true + + + + + @@ -990,6 +1016,40 @@ + + + QDockWidget::NoDockWidgetFeatures + + + Qt::RightDockWidgetArea + + + Layout pages + + + 2 + + + + + + + + 0 + 0 + + + + + 150 + 200 + + + + + + + @@ -1202,6 +1262,9 @@ + + true + false diff --git a/src/app/mainwindowsnogui.cpp b/src/app/mainwindowsnogui.cpp new file mode 100644 index 000000000..5e2d37c22 --- /dev/null +++ b/src/app/mainwindowsnogui.cpp @@ -0,0 +1,81 @@ +/************************************************************************ + ** + ** @file mainwindowsnogui.cpp + ** @author Roman Telezhynskyi + ** @date 12 5, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina 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. + ** + ** Valentina 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 Valentina. If not, see . + ** + *************************************************************************/ + +#include "mainwindowsnogui.h" +#include "../core/vapplication.h" +#include "../container/vcontainer.h" + +#include + +//--------------------------------------------------------------------------------------------------------------------- +MainWindowsNoGUI::MainWindowsNoGUI(QWidget *parent) + : QMainWindow(parent), listDetails(QVector()), currentScene(nullptr), tempSceneLayout(nullptr), + pattern(new VContainer()) +{ + InitTempLayoutScene(); +} + +//--------------------------------------------------------------------------------------------------------------------- +MainWindowsNoGUI::~MainWindowsNoGUI() +{ + delete tempSceneLayout; + delete pattern; +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindowsNoGUI::PrepareDetailsForLayout(const QHash *details) +{ + SCASSERT(details != nullptr) + if (details->count() == 0) + { + listDetails.clear(); + return; + } + + listDetails.clear(); + QHashIterator idetail(*details); + while (idetail.hasNext()) + { + idetail.next(); + VLayoutDetail det = VLayoutDetail(); + det.SetCountourPoints(idetail.value().ContourPoints(pattern)); + det.SetSeamAllowencePoints(idetail.value().SeamAllowancePoints(pattern), + idetail.value().getSeamAllowance()); + det.setName(idetail.value().getName()); + det.setWidth(qApp->toPixel(idetail.value().getWidth())); + + listDetails.append(det); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindowsNoGUI::InitTempLayoutScene() +{ + tempSceneLayout = new VMainGraphicsScene(); + tempSceneLayout->setBackgroundBrush( QBrush(QColor(Qt::gray), Qt::SolidPattern) ); +} diff --git a/src/app/mainwindowsnogui.h b/src/app/mainwindowsnogui.h new file mode 100644 index 000000000..4edbb8f93 --- /dev/null +++ b/src/app/mainwindowsnogui.h @@ -0,0 +1,65 @@ +/************************************************************************ + ** + ** @file mainwindowsnogui.h + ** @author Roman Telezhynskyi + ** @date 12 5, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina 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. + ** + ** Valentina 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 Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef MAINWINDOWSNOGUI_H +#define MAINWINDOWSNOGUI_H + +#include + +#include "../geometry/vdetail.h" +#include "../libs/vlayout/vlayoutdetail.h" +#include "../widgets/vmaingraphicsscene.h" + +class MainWindowsNoGUI : public QMainWindow +{ + Q_OBJECT +public: + MainWindowsNoGUI(QWidget *parent = nullptr); + virtual ~MainWindowsNoGUI(); + +protected: + QVector listDetails; + + /** @brief currentScene pointer to current scene. */ + VMainGraphicsScene *currentScene; + + VMainGraphicsScene *tempSceneLayout; + + /** @brief pattern container with data (points, arcs, splines, spline paths, variables) */ + VContainer *pattern; + + void PrepareDetailsForLayout(const QHash *details); + + void InitTempLayoutScene(); + +private: + Q_DISABLE_COPY(MainWindowsNoGUI) + +}; + +#endif // MAINWINDOWSNOGUI_H diff --git a/src/app/share/resources/icons/win.icon.theme/32x32/emblems/emblem-system.png b/src/app/share/resources/icons/win.icon.theme/32x32/emblems/emblem-system.png new file mode 100644 index 000000000..41408e946 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/32x32/emblems/emblem-system.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/index.theme b/src/app/share/resources/icons/win.icon.theme/index.theme index 2f0b86327..078e57995 100755 --- a/src/app/share/resources/icons/win.icon.theme/index.theme +++ b/src/app/share/resources/icons/win.icon.theme/index.theme @@ -5,7 +5,7 @@ Inherits=gnome,hicolor Example=x-directory-normal #Directories -Directories=16x16/actions,24x24/actions,32x32/actions +Directories=16x16/actions,24x24/actions,32x32/actions,32x32/emblems [16x16/actions] Size=16 @@ -22,4 +22,8 @@ Size=32 Context=Actions Type=Fixed +[32x32/emblemss] +Size=32 +Context=Emblems +Type=Fixed diff --git a/src/app/share/resources/theme.qrc b/src/app/share/resources/theme.qrc index 05b2ad324..f89a5ca50 100644 --- a/src/app/share/resources/theme.qrc +++ b/src/app/share/resources/theme.qrc @@ -67,5 +67,6 @@ icons/win.icon.theme/16x16/actions/document-print-preview.png icons/win.icon.theme/24x24/actions/document-print-preview.png icons/win.icon.theme/32x32/actions/document-print-preview.png + icons/win.icon.theme/32x32/emblems/emblem-system.png diff --git a/src/libs/vgeometry/vgeometrydef.h b/src/libs/vgeometry/vgeometrydef.h index 85edf189d..3ff9b30d0 100644 --- a/src/libs/vgeometry/vgeometrydef.h +++ b/src/libs/vgeometry/vgeometrydef.h @@ -31,7 +31,7 @@ #include -enum class Draw : char { Calculation, Modeling }; +enum class Draw : char { Calculation, Modeling, Layout }; enum class GOType : char { Point, Arc, Spline, SplinePath, Unknown }; enum class SplinePointPosition : char { FirstPoint, LastPoint };