/************************************************************************ ** ** @file puzzlemainwindow.cpp ** @author Roman Telezhynskyi ** @date 16 2, 2020 ** ** @brief ** @copyright ** This source code is part of the Valentina project, a pattern making ** program, whose allow create and modeling patterns of clothing. ** Copyright (C) 2020 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 "puzzlemainwindow.h" #include "ui_puzzlemainwindow.h" #include "dialogs/dialogaboutpuzzle.h" //--------------------------------------------------------------------------------------------------------------------- PuzzleMainWindow::PuzzleMainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::PuzzleMainWindow) { ui->setupUi(this); InitMenuBar(); InitPropertyTabs(); } //--------------------------------------------------------------------------------------------------------------------- PuzzleMainWindow::~PuzzleMainWindow() { delete ui; } //--------------------------------------------------------------------------------------------------------------------- bool PuzzleMainWindow::LoadFile(const QString &path) { Q_UNUSED(path) return true; } //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::InitMenuBar() { // connects the actions for the file menu connect(ui->actionNew, &QAction::triggered, this, &PuzzleMainWindow::New); connect(ui->actionOpen, &QAction::triggered, this, &PuzzleMainWindow::Open); connect(ui->actionSave, &QAction::triggered, this, &PuzzleMainWindow::Save); connect(ui->actionSaveAs, &QAction::triggered, this, &PuzzleMainWindow::SaveAs); connect(ui->actionImportRawLayout, &QAction::triggered, this, &PuzzleMainWindow::ImportRawLayout); connect(ui->actionExit, &QAction::triggered, this, &PuzzleMainWindow::close); // connects the actions for the edit menu // TODO : initialise the undo / redo // connects the actions for the windows menu // TODO : initialise the entries for the different windows connect(ui->actionCloseLayout, &QAction::triggered, this, &PuzzleMainWindow::CloseLayout); // connects the action for the Help Menu connect(ui->actionAboutQt, &QAction::triggered, this, &PuzzleMainWindow::AboutQt); connect(ui->actionAboutPuzzle, &QAction::triggered, this, &PuzzleMainWindow::AboutPuzzle); } //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::InitPropertyTabs() { InitPropertyTabCurrentPiece(); InitPropertyTabLayout(); InitPropertyTabLayers(); InitPropertyTabTiles(); } //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::InitPropertyTabCurrentPiece() { } //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::InitPropertyTabLayout() { // -------------------- init the unit combobox --------------------- ui->comboBoxLayoutUnit->addItem(tr("Centimeters"), QVariant(UnitsToStr(Unit::Cm))); ui->comboBoxLayoutUnit->addItem(tr("Millimiters"), QVariant(UnitsToStr(Unit::Mm))); ui->comboBoxLayoutUnit->addItem(tr("Inches"), QVariant(UnitsToStr(Unit::Inch))); // set default unit - TODO when we have the setting for the unit const qint32 indexUnit = -1;//ui->comboBoxLayoutUnit->findData(qApp->ValentinaSettings()->GetUnit()); if (indexUnit != -1) { ui->comboBoxLayoutUnit->setCurrentIndex(indexUnit); } connect(ui->comboBoxLayoutUnit, QOverload::of(&QComboBox::currentIndexChanged), this, &PuzzleMainWindow::LayoutUnitChanged); // -------------------- init the template combobox --------------------- // TODO connect(ui->comboBoxLayoutTemplate, QOverload::of(&QComboBox::currentIndexChanged), this, &PuzzleMainWindow::LayoutTemplateChanged); // -------------------- layout width, length, orientation ------------------------ connect(ui->doubleSpinBoxLayoutWidth, QOverload::of(&QDoubleSpinBox::valueChanged), this, &PuzzleMainWindow::LayoutSizeChanged); connect(ui->doubleSpinBoxLayoutLength, QOverload::of(&QDoubleSpinBox::valueChanged), this, &PuzzleMainWindow::LayoutSizeChanged); connect(ui->radioButtonLayoutPortrait, QOverload::of(&QRadioButton::toggled), this, &PuzzleMainWindow::LayoutOrientationChanged); connect(ui->radioButtonLayoutLandscape, QOverload::of(&QRadioButton::toggled), this, &PuzzleMainWindow::LayoutOrientationChanged); connect(ui->pushButtonLayoutRemoveUnusedLength, QOverload::of(&QPushButton::clicked), this, &PuzzleMainWindow::LayoutRemoveUnusedLength); // -------------------- margins ------------------------ connect(ui->doubleSpinBoxLayoutMarginTop, QOverload::of(&QDoubleSpinBox::valueChanged), this, &PuzzleMainWindow::LayoutMarginChanged); connect(ui->doubleSpinBoxLayoutMarginRight, QOverload::of(&QDoubleSpinBox::valueChanged), this, &PuzzleMainWindow::LayoutMarginChanged); connect(ui->doubleSpinBoxLayoutMarginBottom, QOverload::of(&QDoubleSpinBox::valueChanged), this, &PuzzleMainWindow::LayoutMarginChanged); connect(ui->doubleSpinBoxLayoutMarginLeft, QOverload::of(&QDoubleSpinBox::valueChanged), this, &PuzzleMainWindow::LayoutMarginChanged); // ------------------- follow grainline ----------------------- connect(ui->radioButtonLayoutFollowGrainlineNo, QOverload::of(&QRadioButton::clicked), this, &PuzzleMainWindow::LayoutFollowGrainlineChanged); connect(ui->radioButtonLayoutFollowGrainlineVertical, QOverload::of(&QRadioButton::clicked), this, &PuzzleMainWindow::LayoutFollowGrainlineChanged); connect(ui->radioButtonLayoutFollowGrainlineHorizontal, QOverload::of(&QRadioButton::clicked), this, &PuzzleMainWindow::LayoutFollowGrainlineChanged); // -------------------- pieces gap and checkboxes --------------- connect(ui->doubleSpinBoxLayoutPiecesGap, QOverload::of(&QDoubleSpinBox::valueChanged), this, &PuzzleMainWindow::LayoutPiecesGapChanged); connect(ui->checkBoxLayoutWarningPiecesSuperposition, QOverload::of(&QCheckBox::toggled), this, &PuzzleMainWindow::LayoutWarningPiecesSuperpositionChanged); connect(ui->checkBoxLayoutWarningPiecesOutOfBound, QOverload::of(&QCheckBox::toggled), this, &PuzzleMainWindow::LayoutWarningPiecesOutOfBoundChanged); connect(ui->checkBoxLayoutStickyEdges, QOverload::of(&QCheckBox::toggled), this, &PuzzleMainWindow::LayoutStickyEdgesChanged); // -------------------- export --------------------------- connect(ui->pushButtonLayoutExport, QOverload::of(&QPushButton::clicked), this, &PuzzleMainWindow::LayoutExport); } //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::InitPropertyTabTiles() { // for the MVP we don't want the tiles tab. // we remove it. As soon as we need it, update this code ui->tabWidgetProperties->removeTab(2); // remove tiles } //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::InitPropertyTabLayers() { // for the MVP we don't want the layers tab. // we remove it. As soon as we need it, update this code ui->tabWidgetProperties->removeTab(3); // remove layers } //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::New() { // just for test purpuses, to be removed: QMessageBox msgBox; msgBox.setText("TODO PuzzleMainWindow::New"); int ret = msgBox.exec(); Q_UNUSED(ret); // TODO } //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::Open() { // just for test purpuses, to be removed: QMessageBox msgBox; msgBox.setText("TODO PuzzleMainWindow::Open"); int ret = msgBox.exec(); Q_UNUSED(ret); // TODO } //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::Save() { // just for test purpuses, to be removed: QMessageBox msgBox; msgBox.setText("TODO PuzzleMainWindow::Save"); int ret = msgBox.exec(); Q_UNUSED(ret); // TODO } //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::SaveAs() { // just for test purpuses, to be removed: QMessageBox msgBox; msgBox.setText("TODO PuzzleMainWindow::SaveAs"); int ret = msgBox.exec(); Q_UNUSED(ret); // TODO } //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::ImportRawLayout() { // just for test purpuses, to be removed: QMessageBox msgBox; msgBox.setText("TODO PuzzleMainWindow::ImportRawLayout"); int ret = msgBox.exec(); Q_UNUSED(ret); // TODO } //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::CloseLayout() { // just for test purpuses, to be removed: QMessageBox msgBox; msgBox.setText("TODO PuzzleMainWindow::CloseLayout"); int ret = msgBox.exec(); Q_UNUSED(ret); // TODO } //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::AboutQt() { QMessageBox::aboutQt(this, tr("About Qt")); } //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::AboutPuzzle() { auto *aboutDialog = new DialogAboutPuzzle(this); aboutDialog->setAttribute(Qt::WA_DeleteOnClose, true); aboutDialog->show(); } //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::LayoutUnitChanged(int index) { // just for test purpuses, to be removed: QMessageBox msgBox; msgBox.setText("TODO PuzzleMainWindow::LayoutUnitChanged"); int ret = msgBox.exec(); Q_UNUSED(index); Q_UNUSED(ret); // TODO } //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::LayoutTemplateChanged(int index) { // just for test purpuses, to be removed: QMessageBox msgBox; msgBox.setText("TODO PuzzleMainWindow::LayoutTemplateChanged"); int ret = msgBox.exec(); Q_UNUSED(index); Q_UNUSED(ret); // TODO } //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::LayoutSizeChanged() { // just for test purpuses, to be removed: QMessageBox msgBox; msgBox.setText("TODO PuzzleMainWindow::LayoutSizeChanged"); int ret = msgBox.exec(); Q_UNUSED(ret); } //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::LayoutOrientationChanged() { // just for test purpuses, to be removed: QMessageBox msgBox; msgBox.setText("TODO PuzzleMainWindow::LayoutOrientationChanged"); int ret = msgBox.exec(); Q_UNUSED(ret); } //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::LayoutRemoveUnusedLength() { // just for test purpuses, to be removed: QMessageBox msgBox; msgBox.setText("TODO PuzzleMainWindow::LayoutRemoveUnusedLength"); int ret = msgBox.exec(); Q_UNUSED(ret); } //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::LayoutMarginChanged() { // just for test purpuses, to be removed: QMessageBox msgBox; msgBox.setText("TODO PuzzleMainWindow::LayoutMarginChanged"); int ret = msgBox.exec(); Q_UNUSED(ret); } //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::LayoutFollowGrainlineChanged() { // just for test purpuses, to be removed: QMessageBox msgBox; msgBox.setText("TODO PuzzleMainWindow::LayoutFollowGrainlineChanged"); int ret = msgBox.exec(); Q_UNUSED(ret); } //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::LayoutPiecesGapChanged(double value) { // just for test purpuses, to be removed: QMessageBox msgBox; msgBox.setText("TODO PuzzleMainWindow::LayoutPieceGapChanged"); int ret = msgBox.exec(); Q_UNUSED(value); Q_UNUSED(ret); } //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::LayoutWarningPiecesSuperpositionChanged(bool checked) { // just for test purpuses, to be removed: QMessageBox msgBox; msgBox.setText("TODO PuzzleMainWindow::LayoutWarningPiecesSuperpositionChanged"); int ret = msgBox.exec(); Q_UNUSED(checked); Q_UNUSED(ret); } //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::LayoutWarningPiecesOutOfBoundChanged(bool checked) { // just for test purpuses, to be removed: QMessageBox msgBox; msgBox.setText("TODO PuzzleMainWindow::LayoutWarningPiecesOutOfBoundChanged"); int ret = msgBox.exec(); Q_UNUSED(checked); Q_UNUSED(ret); } //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::LayoutStickyEdgesChanged(bool checked) { // just for test purpuses, to be removed: QMessageBox msgBox; msgBox.setText("TODO PuzzleMainWindow::LayoutStickyEdgesChanged"); int ret = msgBox.exec(); Q_UNUSED(checked); Q_UNUSED(ret); } //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::LayoutExport() { // just for test purpuses, to be removed: QMessageBox msgBox; msgBox.setText("TODO PuzzleMainWindow::LayoutExport"); int ret = msgBox.exec(); Q_UNUSED(ret); }