From 3979d0e9dbfe7e786a17e94585560a4168ed8d32 Mon Sep 17 00:00:00 2001 From: Wren Turkal Date: Wed, 9 Jan 2019 00:13:54 -0800 Subject: [PATCH] Use qt-designer to setup action slots. Their are slots that are automatically connected when a .ui file is compiled. I have changed New, Save, SaveAs, and Open to use that method for connecting the slots. Also, I added Ctrl-O as a shortcut for Open while I was in there. --HG-- branch : develop --- src/app/valentina/mainwindow.cpp | 26 +++++++++++--------------- src/app/valentina/mainwindow.h | 8 ++++---- src/app/valentina/mainwindow.ui | 2 +- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index b725c5458..002d57d03 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -2668,10 +2668,10 @@ void MainWindow::ActionLayout(bool checked) //--------------------------------------------------------------------------------------------------------------------- /** - * @brief SaveAs save as pattern file. + * @brief on_actionSaveAs_triggered save as pattern file. * @return true for successes saving. */ -bool MainWindow::SaveAs() +bool MainWindow::on_actionSaveAs_triggered() { const QString oldFilePath = qApp->GetPatternPath(); QString filters(tr("Pattern files") + QLatin1String("(*.val)")); @@ -2792,14 +2792,14 @@ bool MainWindow::SaveAs() //--------------------------------------------------------------------------------------------------------------------- /** - * @brief Save save pattern file. + * @brief on_actionSave_triggered save pattern file. * @return true for successes saving. */ -bool MainWindow::Save() +bool MainWindow::on_actionSave_triggered() { if (qApp->GetPatternPath().isEmpty() || patternReadOnly) { - return SaveAs(); + return on_actionSaveAs_triggered(); } else { @@ -2878,9 +2878,9 @@ bool MainWindow::Save() //--------------------------------------------------------------------------------------------------------------------- /** - * @brief Open ask user select pattern file. + * @brief on_actionOpen_triggered ask user select pattern file. */ -void MainWindow::Open() +void MainWindow::on_actionOpen_triggered() { qCDebug(vMainWindow, "Openning new file."); const QString filter(tr("Pattern files") + QLatin1String(" (*.val)")); @@ -3394,9 +3394,9 @@ void MainWindow::UpdateSizesList(const QStringList &list) //--------------------------------------------------------------------------------------------------------------------- /** - * @brief NewPattern create new empty pattern. + * @brief on_actionNew_triggered create new empty pattern. */ -void MainWindow::New() +void MainWindow::on_actionNew_triggered() { if (comboBoxDraws->count() == 0) { @@ -3859,11 +3859,11 @@ bool MainWindow::MaybeSave() case QMessageBox::Yes: if (patternReadOnly) { - return SaveAs(); + return on_actionSaveAs_triggered(); } else { - return Save(); + return on_actionSave_triggered(); } case QMessageBox::No: return true; @@ -4253,10 +4253,6 @@ void MainWindow::CreateActions() AddPP(patternPieceName); }); - connect(ui->actionSaveAs, &QAction::triggered, this, &MainWindow::SaveAs); - connect(ui->actionSave, &QAction::triggered, this, &MainWindow::Save); - connect(ui->actionOpen, &QAction::triggered, this, &MainWindow::Open); - connect(ui->actionNew, &QAction::triggered, this, &MainWindow::New); connect(ui->actionExportIncrementsToCSV, &QAction::triggered, this, &MainWindow::ExportDataToCSV); connect(ui->actionExportFinalMeasurementsToCSV, &QAction::triggered, this, &MainWindow::ExportFMeasurementsToCSV); diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h index 498ceacc2..ddefb17c5 100644 --- a/src/app/valentina/mainwindow.h +++ b/src/app/valentina/mainwindow.h @@ -178,10 +178,10 @@ private slots: void ActionDetails(bool checked); void ActionLayout(bool checked); - void New(); - bool SaveAs(); - bool Save(); - void Open(); + void on_actionNew_triggered(); + bool on_actionSaveAs_triggered(); + bool on_actionSave_triggered(); + void on_actionOpen_triggered(); void ClosedDialogUnionDetails(int result); void ClosedDialogDuplicateDetail(int result); diff --git a/src/app/valentina/mainwindow.ui b/src/app/valentina/mainwindow.ui index 3ab5fefe9..7c0e852e3 100644 --- a/src/app/valentina/mainwindow.ui +++ b/src/app/valentina/mainwindow.ui @@ -2036,7 +2036,7 @@ Open file with pattern - + Ctrl+O QAction::NoRole