From 47f12c80f80fba57451d41a076ad843a18fdcf3f Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 18 Jul 2016 18:09:15 +0300 Subject: [PATCH] Refactoring. Use lambda for small slots. Move slots declaration in appropriate place. --HG-- branch : develop --- .../configpages/tapeconfigurationpage.cpp | 83 ++- .../configpages/tapeconfigurationpage.h | 9 - .../tape/dialogs/configpages/tapepathpage.cpp | 23 +- .../tape/dialogs/configpages/tapepathpage.h | 7 +- src/app/tape/dialogs/dialogexporttocsv.cpp | 17 +- src/app/tape/dialogs/dialogexporttocsv.h | 3 - src/app/tape/dialogs/tapeconfigdialog.cpp | 20 +- src/app/tape/dialogs/tapeconfigdialog.h | 12 +- src/app/tape/mapplication.cpp | 6 - src/app/tape/mapplication.h | 3 +- src/app/tape/tmainwindow.cpp | 56 +- src/app/tape/tmainwindow.h | 20 +- .../core/vtooloptionspropertybrowser.h | 3 +- src/app/valentina/dialogs/configdialog.cpp | 20 +- src/app/valentina/dialogs/configdialog.h | 12 +- .../dialogs/configpages/pathpage.cpp | 19 +- .../valentina/dialogs/configpages/pathpage.h | 7 +- .../valentina/dialogs/dialoglayoutsettings.h | 7 +- src/app/valentina/dialogs/dialognewpattern.h | 6 +- .../dialogs/dialogpatternproperties.cpp | 102 ++-- .../dialogs/dialogpatternproperties.h | 23 +- .../valentina/dialogs/dialogsavelayout.cpp | 29 +- src/app/valentina/dialogs/dialogsavelayout.h | 8 +- src/app/valentina/mainwindow.cpp | 496 +++++++----------- src/app/valentina/mainwindow.h | 224 ++++---- src/app/valentina/mainwindowsnogui.h | 5 +- src/libs/fervor/fvupdater.cpp | 42 +- src/libs/fervor/fvupdater.h | 2 - src/libs/qmuparser/qmuparsertest.h | 2 +- src/libs/vmisc/vabstractapplication.cpp | 17 +- src/libs/vmisc/vabstractapplication.h | 3 - .../vtools/dialogs/support/dialogundo.cpp | 26 +- src/libs/vtools/dialogs/support/dialogundo.h | 10 +- 33 files changed, 530 insertions(+), 792 deletions(-) diff --git a/src/app/tape/dialogs/configpages/tapeconfigurationpage.cpp b/src/app/tape/dialogs/configpages/tapeconfigurationpage.cpp index c218ba4d4..c34398fbd 100644 --- a/src/app/tape/dialogs/configpages/tapeconfigurationpage.cpp +++ b/src/app/tape/dialogs/configpages/tapeconfigurationpage.cpp @@ -49,13 +49,10 @@ TapeConfigurationPage::TapeConfigurationPage(QWidget *parent) langCombo(nullptr), systemCombo(nullptr), labelCombo(nullptr), - unitCombo(nullptr), osOptionCheck(nullptr), langChanged(false), systemChanged(false), defGradationChanged(false), - unitChanged(false), - labelLangChanged(false), sendReportCheck(nullptr), askPointDeletionCheck(nullptr), toolBarStyleCheck(nullptr), @@ -118,49 +115,6 @@ void TapeConfigurationPage::Apply() } } -//--------------------------------------------------------------------------------------------------------------------- -void TapeConfigurationPage::LangChanged() -{ - langChanged = true; -} - -//--------------------------------------------------------------------------------------------------------------------- -void TapeConfigurationPage::SystemChanged() -{ - systemChanged = true; -#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0) - QString text = qApp->TrVars()->PMSystemAuthor(systemCombo->itemData(systemCombo->currentIndex()).toString()); -#else - QString text = qApp->TrVars()->PMSystemAuthor(systemCombo->currentData().toString()); -#endif - systemAuthorValueLabel->setText(text); - systemAuthorValueLabel->setToolTip(text); -#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0) - text = qApp->TrVars()->PMSystemBook(systemCombo->itemData(systemCombo->currentIndex()).toString()); -#else - text = qApp->TrVars()->PMSystemBook(systemCombo->currentData().toString()); -#endif - systemBookValueLabel->setPlainText(text); -} - -//--------------------------------------------------------------------------------------------------------------------- -void TapeConfigurationPage::DefGradationChanged() -{ - defGradationChanged = true; -} - -//--------------------------------------------------------------------------------------------------------------------- -void TapeConfigurationPage::UnitChanged() -{ - this->unitChanged = true; -} - -//--------------------------------------------------------------------------------------------------------------------- -void TapeConfigurationPage::LabelLangChanged() -{ - labelLangChanged = true; -} - //--------------------------------------------------------------------------------------------------------------------- void TapeConfigurationPage::changeEvent(QEvent *event) { @@ -219,8 +173,10 @@ QGroupBox *TapeConfigurationPage::LangGroup() { langCombo->setCurrentIndex(index); } - connect(langCombo, static_cast(&QComboBox::currentIndexChanged), this, - &TapeConfigurationPage::LangChanged); + connect(langCombo, static_cast(&QComboBox::currentIndexChanged), [this]() + { + langChanged = true; + }); QFormLayout *langLayout = new QFormLayout; langLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); @@ -267,8 +223,23 @@ QGroupBox *TapeConfigurationPage::PMSystemGroup() pmSystemLayout->addRow(systemBookLabel, systemBookValueLabel); - connect(systemCombo, static_cast(&QComboBox::currentIndexChanged), this, - &TapeConfigurationPage::SystemChanged); + connect(systemCombo, static_cast(&QComboBox::currentIndexChanged), [this]() + { + systemChanged = true; + #if QT_VERSION < QT_VERSION_CHECK(5, 2, 0) + QString text = qApp->TrVars()->PMSystemAuthor(systemCombo->itemData(systemCombo->currentIndex()).toString()); + #else + QString text = qApp->TrVars()->PMSystemAuthor(systemCombo->currentData().toString()); + #endif + systemAuthorValueLabel->setText(text); + systemAuthorValueLabel->setToolTip(text); + #if QT_VERSION < QT_VERSION_CHECK(5, 2, 0) + text = qApp->TrVars()->PMSystemBook(systemCombo->itemData(systemCombo->currentIndex()).toString()); + #else + text = qApp->TrVars()->PMSystemBook(systemCombo->currentData().toString()); + #endif + systemBookValueLabel->setPlainText(text); + }); // set default pattern making system const VTapeSettings *settings = qApp->TapeSettings(); @@ -300,8 +271,14 @@ QGroupBox *TapeConfigurationPage::GradationGroup() { defHeightCombo->setCurrentIndex(index); } - connect(defHeightCombo, static_cast(&QComboBox::currentIndexChanged), this, - &TapeConfigurationPage::DefGradationChanged); + + auto DefGradationChanged = [this]() + { + defGradationChanged = true; + }; + + connect(defHeightCombo, static_cast(&QComboBox::currentIndexChanged), + DefGradationChanged); gradationLayout->addRow(defHeightLabel, defHeightCombo); @@ -314,7 +291,7 @@ QGroupBox *TapeConfigurationPage::GradationGroup() defSizeCombo->setCurrentIndex(index); } connect(defHeightCombo, static_cast(&QComboBox::currentIndexChanged), this, - &TapeConfigurationPage::DefGradationChanged); + DefGradationChanged); gradationLayout->addRow(defSizeLabel, defSizeCombo); gradationGroup->setLayout(gradationLayout); diff --git a/src/app/tape/dialogs/configpages/tapeconfigurationpage.h b/src/app/tape/dialogs/configpages/tapeconfigurationpage.h index b21760a67..f2aa0083c 100644 --- a/src/app/tape/dialogs/configpages/tapeconfigurationpage.h +++ b/src/app/tape/dialogs/configpages/tapeconfigurationpage.h @@ -45,12 +45,6 @@ class TapeConfigurationPage : public QWidget public: explicit TapeConfigurationPage(QWidget *parent = nullptr); void Apply(); -public slots: - void LangChanged(); - void SystemChanged(); - void DefGradationChanged(); - void UnitChanged(); - void LabelLangChanged(); protected: virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; private: @@ -58,13 +52,10 @@ private: QComboBox *langCombo; QComboBox *systemCombo; QComboBox *labelCombo; - QComboBox *unitCombo; QCheckBox *osOptionCheck; bool langChanged; bool systemChanged; bool defGradationChanged; - bool unitChanged; - bool labelLangChanged; QCheckBox *sendReportCheck; QCheckBox *askPointDeletionCheck; QCheckBox *toolBarStyleCheck; diff --git a/src/app/tape/dialogs/configpages/tapepathpage.cpp b/src/app/tape/dialogs/configpages/tapepathpage.cpp index 389f81451..0aff9cf42 100644 --- a/src/app/tape/dialogs/configpages/tapepathpage.cpp +++ b/src/app/tape/dialogs/configpages/tapepathpage.cpp @@ -71,16 +71,6 @@ void TapePathPage::Apply() settings->SetPathTemplate(pathTable->item(2, 1)->text()); } -//--------------------------------------------------------------------------------------------------------------------- -void TapePathPage::TableActivated() -{ - defaultButton->setEnabled(true); - defaultButton->setDefault(false); - - editButton->setEnabled(true); - editButton->setDefault(true); -} - //--------------------------------------------------------------------------------------------------------------------- void TapePathPage::DefaultPath() { @@ -129,8 +119,8 @@ void TapePathPage::EditPath() default: break; } - QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), path, - QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + const QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), path, + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); if (dir.isEmpty()) { DefaultPath(); @@ -223,7 +213,14 @@ void TapePathPage::InitTable() pathTable->resizeRowsToContents(); pathTable->horizontalHeader()->setStretchLastSection(true); - connect(pathTable, &QTableWidget::itemSelectionChanged, this, &TapePathPage::TableActivated); + connect(pathTable, &QTableWidget::itemSelectionChanged, [this] + { + defaultButton->setEnabled(true); + defaultButton->setDefault(false); + + editButton->setEnabled(true); + editButton->setDefault(true); + }); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tape/dialogs/configpages/tapepathpage.h b/src/app/tape/dialogs/configpages/tapepathpage.h index d6a2b75fe..89771d2a2 100644 --- a/src/app/tape/dialogs/configpages/tapepathpage.h +++ b/src/app/tape/dialogs/configpages/tapepathpage.h @@ -42,12 +42,11 @@ class TapePathPage : public QWidget public: explicit TapePathPage(QWidget *parent = nullptr); void Apply(); -public slots: - void TableActivated(); - void DefaultPath(); - void EditPath(); protected: virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; +private slots: + void DefaultPath(); + void EditPath(); private: Q_DISABLE_COPY(TapePathPage) QPushButton *defaultButton; diff --git a/src/app/tape/dialogs/dialogexporttocsv.cpp b/src/app/tape/dialogs/dialogexporttocsv.cpp index eb11edb7c..b00b67bf1 100644 --- a/src/app/tape/dialogs/dialogexporttocsv.cpp +++ b/src/app/tape/dialogs/dialogexporttocsv.cpp @@ -57,7 +57,13 @@ DialogExportToCSV::DialogExportToCSV(QWidget *parent) QPushButton *bDefaults = ui->buttonBox->button(QDialogButtonBox::RestoreDefaults); SCASSERT(bDefaults != nullptr); - connect(bDefaults, &QPushButton::clicked, this, &DialogExportToCSV::RestoreDefaults); + connect(bDefaults, &QPushButton::clicked, [this]() + { + ui->checkBoxWithHeader->setChecked(qApp->TapeSettings()->GetDefCSVWithHeader()); + ui->comboBoxCodec->setCurrentIndex(ui->comboBoxCodec->findData(qApp->TapeSettings()->GetDefCSVCodec())); + + SetSeparator(qApp->TapeSettings()->GetDefCSVSeparator()); + }); } //--------------------------------------------------------------------------------------------------------------------- @@ -137,15 +143,6 @@ void DialogExportToCSV::showEvent(QShowEvent *event) isInitialized = true;//first show windows are held } -//--------------------------------------------------------------------------------------------------------------------- -void DialogExportToCSV::RestoreDefaults() -{ - ui->checkBoxWithHeader->setChecked(qApp->TapeSettings()->GetDefCSVWithHeader()); - ui->comboBoxCodec->setCurrentIndex(ui->comboBoxCodec->findData(qApp->TapeSettings()->GetDefCSVCodec())); - - SetSeparator(qApp->TapeSettings()->GetDefCSVSeparator()); -} - //--------------------------------------------------------------------------------------------------------------------- void DialogExportToCSV::SetSeparator(const QChar &separator) { diff --git a/src/app/tape/dialogs/dialogexporttocsv.h b/src/app/tape/dialogs/dialogexporttocsv.h index 3630ab57f..5c684d934 100644 --- a/src/app/tape/dialogs/dialogexporttocsv.h +++ b/src/app/tape/dialogs/dialogexporttocsv.h @@ -51,9 +51,6 @@ protected: virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; -private slots: - void RestoreDefaults(); - private: Q_DISABLE_COPY(DialogExportToCSV) Ui::DialogExportToCSV *ui; diff --git a/src/app/tape/dialogs/tapeconfigdialog.cpp b/src/app/tape/dialogs/tapeconfigdialog.cpp index cf60198e1..ca20cd121 100644 --- a/src/app/tape/dialogs/tapeconfigdialog.cpp +++ b/src/app/tape/dialogs/tapeconfigdialog.cpp @@ -70,7 +70,15 @@ TapeConfigDialog::TapeConfigDialog(QWidget *parent) okButton = new QPushButton(tr("&Ok")); createIcons(); - connect(contentsWidget, &QListWidget::currentItemChanged, this, &TapeConfigDialog::changePage); + connect(contentsWidget, &QListWidget::currentItemChanged, + [this](QListWidgetItem *current, QListWidgetItem *previous) + { + if (current == nullptr) + { + current = previous; + } + pagesWidget->setCurrentIndex(contentsWidget->row(current)); + }); contentsWidget->setCurrentRow(0); connect(cancelButton, &QPushButton::clicked, this, &TapeConfigDialog::close); @@ -100,16 +108,6 @@ TapeConfigDialog::TapeConfigDialog(QWidget *parent) qApp->TapeSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C)); } -//--------------------------------------------------------------------------------------------------------------------- -void TapeConfigDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous) -{ - if (current == nullptr) - { - current = previous; - } - pagesWidget->setCurrentIndex(contentsWidget->row(current)); -} - //--------------------------------------------------------------------------------------------------------------------- void TapeConfigDialog::closeEvent(QCloseEvent *event) { diff --git a/src/app/tape/dialogs/tapeconfigdialog.h b/src/app/tape/dialogs/tapeconfigdialog.h index 54e2f6ac8..b7367f216 100644 --- a/src/app/tape/dialogs/tapeconfigdialog.h +++ b/src/app/tape/dialogs/tapeconfigdialog.h @@ -42,15 +42,13 @@ class TapeConfigDialog : public QDialog Q_OBJECT public: explicit TapeConfigDialog(QWidget *parent = nullptr); -public slots: - void changePage(QListWidgetItem *current, QListWidgetItem *previous); signals: - void UpdateProperties(); + void UpdateProperties(); protected: - virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; - virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; - virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; - virtual void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; + virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; + virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; + virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; + virtual void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(TapeConfigDialog) QListWidget *contentsWidget; diff --git a/src/app/tape/mapplication.cpp b/src/app/tape/mapplication.cpp index a01addf1b..0f35cfabe 100644 --- a/src/app/tape/mapplication.cpp +++ b/src/app/tape/mapplication.cpp @@ -760,12 +760,6 @@ void MApplication::ProcessCMD() ParseCommandLine(SocketConnection::Client, arguments()); } -//--------------------------------------------------------------------------------------------------------------------- -void MApplication::OpenFile(const QString &path) -{ - MainWindow()->LoadFile(path); -} - //--------------------------------------------------------------------------------------------------------------------- void MApplication::NewLocalSocketConnection() { diff --git a/src/app/tape/mapplication.h b/src/app/tape/mapplication.h index 17cd27d84..af2d47641 100644 --- a/src/app/tape/mapplication.h +++ b/src/app/tape/mapplication.h @@ -60,6 +60,7 @@ public: virtual bool IsAppInGUIMode() const Q_DECL_OVERRIDE; TMainWindow *MainWindow(); QList MainWindows(); + TMainWindow *NewMainWindow(); void InitOptions(); @@ -77,7 +78,6 @@ public: void ParseCommandLine(const SocketConnection &connection, const QStringList &arguments); public slots: - TMainWindow *NewMainWindow(); void ProcessCMD(); protected: @@ -85,7 +85,6 @@ protected: virtual bool event(QEvent *e) Q_DECL_OVERRIDE; private slots: - void OpenFile(const QString &path); void NewLocalSocketConnection(); private: diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index 1ab6241e6..cfae1b38e 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -750,7 +750,7 @@ void TMainWindow::AboutToShowWindowMenu() } //--------------------------------------------------------------------------------------------------------------------- -void TMainWindow::ShowWindow() +void TMainWindow::ShowWindow() const { if (QAction *action = qobject_cast(sender())) { @@ -758,27 +758,13 @@ void TMainWindow::ShowWindow() if (v.canConvert()) { const int offset = qvariant_cast(v); - QList windows = qApp->MainWindows(); + const QList windows = qApp->MainWindows(); windows.at(offset)->raise(); windows.at(offset)->activateWindow(); } } } -//--------------------------------------------------------------------------------------------------------------------- -void TMainWindow::AboutApplication() -{ - DialogAboutTape * aboutDialog = new DialogAboutTape(this); - aboutDialog->setAttribute(Qt::WA_DeleteOnClose, true); - aboutDialog->show(); -} - -//--------------------------------------------------------------------------------------------------------------------- -void TMainWindow::AboutQt() -{ - QMessageBox::aboutQt(this, tr("About Qt")); -} - //--------------------------------------------------------------------------------------------------------------------- #if defined(Q_OS_MAC) void TMainWindow::AboutToShowDockMenu() @@ -1720,20 +1706,6 @@ void TMainWindow::SaveMFullName() } } -//--------------------------------------------------------------------------------------------------------------------- -void TMainWindow::NewWindow() -{ - qApp->NewMainWindow(); - qApp->MainWindow()->activateWindow(); -} - -//--------------------------------------------------------------------------------------------------------------------- -void TMainWindow::Preferences() -{ - TapeConfigDialog dlg(this); - dlg.exec(); -} - //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::PatternUnitChanged(int index) { @@ -1762,7 +1734,11 @@ void TMainWindow::SetupMenu() connect(ui->actionExportToCSV, &QAction::triggered, this, &TMainWindow::ExportToCSV); connect(ui->actionReadOnly, &QAction::triggered, this, &TMainWindow::ReadOnly); - connect(ui->actionPreferences, &QAction::triggered, this, &TMainWindow::Preferences); + connect(ui->actionPreferences, &QAction::triggered, [this]() + { + TapeConfigDialog dlg(this); + dlg.exec(); + }); for (int i = 0; i < MaxRecentFiles; ++i) { @@ -1798,8 +1774,13 @@ void TMainWindow::SetupMenu() AboutToShowWindowMenu(); // Help - connect(ui->actionAboutQt, &QAction::triggered, this, &TMainWindow::AboutQt); - connect(ui->actionAboutTape, &QAction::triggered, this, &TMainWindow::AboutApplication); + connect(ui->actionAboutQt, &QAction::triggered, [this](){QMessageBox::aboutQt(this, tr("About Qt"));}); + connect(ui->actionAboutTape, &QAction::triggered, [this]() + { + DialogAboutTape *aboutDialog = new DialogAboutTape(this); + aboutDialog->setAttribute(Qt::WA_DeleteOnClose, true); + aboutDialog->show(); + }); //Actions for recent files loaded by a tape window application. UpdateRecentFileActions(); @@ -2765,11 +2746,16 @@ void TMainWindow::CreateWindowMenu(QMenu *menu) { SCASSERT(menu != nullptr); - QAction *action = menu->addAction(tr("&New Window"), this, SLOT(NewWindow())); + QAction *action = menu->addAction(tr("&New Window")); + connect(action, &QAction::triggered, [this]() + { + qApp->NewMainWindow(); + qApp->MainWindow()->activateWindow(); + }); action->setMenuRole(QAction::NoRole); menu->addSeparator(); - QList windows = qApp->MainWindows(); + const QList windows = qApp->MainWindows(); for (int i = 0; i < windows.count(); ++i) { TMainWindow *window = windows.at(i); diff --git a/src/app/tape/tmainwindow.h b/src/app/tape/tmainwindow.h index 93fd342e5..c7dff2a39 100644 --- a/src/app/tape/tmainwindow.h +++ b/src/app/tape/tmainwindow.h @@ -62,14 +62,7 @@ public: void SetBaseMSize(int size); void SetPUnit(Unit unit); -public slots: bool LoadFile(const QString &path); - void FileNew(); - void OpenIndividual(); - void OpenStandard(); - void OpenTemplate(); - void CreateFromExisting(); - void OpenRecentFile(); protected: virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; @@ -77,13 +70,18 @@ protected: virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; private slots: + void FileNew(); + void OpenIndividual(); + void OpenStandard(); + void OpenTemplate(); + void CreateFromExisting(); + void OpenRecentFile(); + void FileSave(); void FileSaveAs(); void ExportToCSV(); void AboutToShowWindowMenu(); - void ShowWindow(); - void AboutApplication(); - void AboutQt(); + void ShowWindow() const; #if defined(Q_OS_MAC) void AboutToShowDockMenu(); @@ -125,8 +123,6 @@ private slots: void SaveMDescription(); void SaveMFullName(); - void NewWindow(); - void Preferences(); void PatternUnitChanged(int index); private: diff --git a/src/app/valentina/core/vtooloptionspropertybrowser.h b/src/app/valentina/core/vtooloptionspropertybrowser.h index e8ba646e1..2c69b5513 100644 --- a/src/app/valentina/core/vtooloptionspropertybrowser.h +++ b/src/app/valentina/core/vtooloptionspropertybrowser.h @@ -49,9 +49,10 @@ public: void ClearPropertyBrowser(); public slots: void itemClicked(QGraphicsItem *item); - void userChangedData(VPE::VProperty* property); void UpdateOptions(); void RefreshOptions(); +private slots: + void userChangedData(VPE::VProperty* property); private: Q_DISABLE_COPY(VToolOptionsPropertyBrowser) diff --git a/src/app/valentina/dialogs/configdialog.cpp b/src/app/valentina/dialogs/configdialog.cpp index 5ae67a90a..339107245 100644 --- a/src/app/valentina/dialogs/configdialog.cpp +++ b/src/app/valentina/dialogs/configdialog.cpp @@ -97,16 +97,6 @@ ConfigDialog::ConfigDialog(QWidget *parent) : qApp->Settings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C)); } -//--------------------------------------------------------------------------------------------------------------------- -void ConfigDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous) -{ - if (current == nullptr) - { - current = previous; - } - pagesWidget->setCurrentIndex(contentsWidget->row(current)); -} - //--------------------------------------------------------------------------------------------------------------------- void ConfigDialog::closeEvent(QCloseEvent *event) { @@ -177,7 +167,15 @@ void ConfigDialog::createIcons() createIcon("://icon/community_config.png", tr("Community")); createIcon("://icon/path_config.png", tr("Paths")); - connect(contentsWidget, &QListWidget::currentItemChanged, this, &ConfigDialog::changePage); + connect(contentsWidget, &QListWidget::currentItemChanged, + [this](QListWidgetItem *current, QListWidgetItem *previous) + { + if (current == nullptr) + { + current = previous; + } + pagesWidget->setCurrentIndex(contentsWidget->row(current)); + }); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/valentina/dialogs/configdialog.h b/src/app/valentina/dialogs/configdialog.h index f64321588..7f289a5e8 100644 --- a/src/app/valentina/dialogs/configdialog.h +++ b/src/app/valentina/dialogs/configdialog.h @@ -41,15 +41,13 @@ class ConfigDialog : public QDialog Q_OBJECT public: explicit ConfigDialog(QWidget *parent = nullptr); -public slots: - void changePage(QListWidgetItem *current, QListWidgetItem *previous); signals: - void UpdateProperties(); + void UpdateProperties(); protected: - virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; - virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; - virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; - virtual void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; + virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; + virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; + virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; + virtual void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(ConfigDialog) QListWidget *contentsWidget; diff --git a/src/app/valentina/dialogs/configpages/pathpage.cpp b/src/app/valentina/dialogs/configpages/pathpage.cpp index d72a5c316..97128b929 100644 --- a/src/app/valentina/dialogs/configpages/pathpage.cpp +++ b/src/app/valentina/dialogs/configpages/pathpage.cpp @@ -70,16 +70,6 @@ void PathPage::Apply() settings->SetPathTemplate(pathTable->item(4, 1)->text()); } -//--------------------------------------------------------------------------------------------------------------------- -void PathPage::TableActivated() -{ - defaultButton->setEnabled(true); - defaultButton->setDefault(false); - - editButton->setEnabled(true); - editButton->setDefault(true); -} - //--------------------------------------------------------------------------------------------------------------------- void PathPage::DefaultPath() { @@ -243,7 +233,14 @@ void PathPage::InitTable() pathTable->resizeRowsToContents(); pathTable->horizontalHeader()->setStretchLastSection(true); - connect(pathTable, &QTableWidget::itemSelectionChanged, this, &PathPage::TableActivated); + connect(pathTable, &QTableWidget::itemSelectionChanged, [this]() + { + defaultButton->setEnabled(true); + defaultButton->setDefault(false); + + editButton->setEnabled(true); + editButton->setDefault(true); + }); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/valentina/dialogs/configpages/pathpage.h b/src/app/valentina/dialogs/configpages/pathpage.h index 9145a82aa..9bcedd9e5 100644 --- a/src/app/valentina/dialogs/configpages/pathpage.h +++ b/src/app/valentina/dialogs/configpages/pathpage.h @@ -42,12 +42,11 @@ class PathPage : public QWidget public: explicit PathPage(QWidget *parent = nullptr); void Apply(); -public slots: - void TableActivated(); - void DefaultPath(); - void EditPath(); protected: virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; +private slots: + void DefaultPath(); + void EditPath(); private: Q_DISABLE_COPY(PathPage) QPushButton *defaultButton; diff --git a/src/app/valentina/dialogs/dialoglayoutsettings.h b/src/app/valentina/dialogs/dialoglayoutsettings.h index a3684a00b..c5d2ca605 100644 --- a/src/app/valentina/dialogs/dialoglayoutsettings.h +++ b/src/app/valentina/dialogs/dialoglayoutsettings.h @@ -122,17 +122,16 @@ public: protected: virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; public slots: + void DialogAccepted(); +private slots: void ConvertPaperSize(); void ConvertLayoutSize(); - void TemplateSelected(); void FindTemplate(); void PaperSizeChanged(); void Swap(bool checked); - - void DialogAccepted(); void RestoreDefaults(); -private slots: + void CorrectMaxFileds(); void IgnoreAllFields(int state); private: diff --git a/src/app/valentina/dialogs/dialognewpattern.h b/src/app/valentina/dialogs/dialognewpattern.h index aeb171b74..aeb81563f 100644 --- a/src/app/valentina/dialogs/dialognewpattern.h +++ b/src/app/valentina/dialogs/dialognewpattern.h @@ -45,13 +45,13 @@ class DialogNewPattern : public QDialog Q_OBJECT public: DialogNewPattern(VContainer *data, const QString &patternPieceName, QWidget *parent = nullptr); - ~DialogNewPattern(); + virtual ~DialogNewPattern(); QString name() const; Unit PatternUnit() const; -public slots: - void CheckState(); protected: virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; +private slots: + void CheckState(); private: Q_DISABLE_COPY(DialogNewPattern) Ui::DialogNewPattern *ui; diff --git a/src/app/valentina/dialogs/dialogpatternproperties.cpp b/src/app/valentina/dialogs/dialogpatternproperties.cpp index ed57b6819..373158a44 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.cpp +++ b/src/app/valentina/dialogs/dialogpatternproperties.cpp @@ -133,22 +133,27 @@ DialogPatternProperties::DialogPatternProperties(const QString &filePath, VPatte const QString size = QString().setNum(doc->GetDefCustomSize()); SetDefaultSize(size); - connect(ui->radioButtonDefFromP, &QRadioButton::toggled, this, &DialogPatternProperties::ToggleComboBox); - connect(ui->radioButtonDefFromP, &QRadioButton::toggled, this, &DialogPatternProperties::DefValueChanged); + connect(ui->radioButtonDefFromP, &QRadioButton::toggled, [this]() + { + ui->comboBoxHeight->setEnabled(ui->radioButtonDefFromP->isChecked()); + ui->comboBoxSize->setEnabled(ui->radioButtonDefFromP->isChecked()); + }); + + auto DefValueChanged = [this](){defaultChanged = true;}; + + connect(ui->radioButtonDefFromP, &QRadioButton::toggled, DefValueChanged); ui->radioButtonDefFromP->setChecked(doc->IsDefCustom()); - connect(ui->comboBoxHeight, static_cast(&QComboBox::currentIndexChanged), this, - &DialogPatternProperties::DefValueChanged); - connect(ui->comboBoxSize, static_cast(&QComboBox::currentIndexChanged), this, - &DialogPatternProperties::DefValueChanged); + connect(ui->comboBoxHeight, static_cast(&QComboBox::currentIndexChanged), + DefValueChanged); + connect(ui->comboBoxSize, static_cast(&QComboBox::currentIndexChanged), DefValueChanged); const bool readOnly = doc->IsReadOnly(); ui->checkBoxPatternReadOnly->setChecked(readOnly); if (not readOnly) { - connect(ui->checkBoxPatternReadOnly, &QRadioButton::toggled, this, - &DialogPatternProperties::SecurityValueChanged); + connect(ui->checkBoxPatternReadOnly, &QRadioButton::toggled, [this](){securityChanged = true;}); } else { @@ -359,25 +364,6 @@ void DialogPatternProperties::DescEdited() descriptionChanged = true; } -//--------------------------------------------------------------------------------------------------------------------- -void DialogPatternProperties::ToggleComboBox() -{ - ui->comboBoxHeight->setEnabled(ui->radioButtonDefFromP->isChecked()); - ui->comboBoxSize->setEnabled(ui->radioButtonDefFromP->isChecked()); -} - -//--------------------------------------------------------------------------------------------------------------------- -void DialogPatternProperties::DefValueChanged() -{ - defaultChanged = true; -} - -//--------------------------------------------------------------------------------------------------------------------- -void DialogPatternProperties::SecurityValueChanged() -{ - securityChanged = true; -} - //--------------------------------------------------------------------------------------------------------------------- void DialogPatternProperties::SetHeightsChecked(bool enabled) { @@ -642,17 +628,41 @@ void DialogPatternProperties::InitImage() { ui->imageLabel->setContextMenuPolicy(Qt::CustomContextMenu); ui->imageLabel->setScaledContents(true); - connect(ui->imageLabel, &QWidget::customContextMenuRequested, this, &DialogPatternProperties::ShowContextMenu); + connect(ui->imageLabel, &QWidget::customContextMenuRequested, [this]() + { + QMenu menu(this); + menu.addAction(deleteAction); + menu.addAction(changeImageAction); + menu.addAction(saveImageAction); + menu.addAction(showImageAction); + menu.exec(QCursor::pos()); + menu.show(); + }); deleteAction = new QAction(tr("Delete image"), this); changeImageAction = new QAction(tr("Change image"), this); saveImageAction = new QAction(tr("Save image to file"), this); showImageAction = new QAction(tr("Show image"), this); - connect(deleteAction, &QAction::triggered, this, &DialogPatternProperties::DeleteImage); + connect(deleteAction, &QAction::triggered, [this]() + { + doc->DeleteImage(); + ui->imageLabel->setText(tr("Change image")); + deleteAction->setEnabled(false); + saveImageAction->setEnabled(false); + showImageAction->setEnabled(false); + }); + connect(changeImageAction, &QAction::triggered, this, &DialogPatternProperties::ChangeImage); connect(saveImageAction, &QAction::triggered, this, &DialogPatternProperties::SaveImage); - connect(showImageAction, &QAction::triggered, this, &DialogPatternProperties::ShowImage); + connect(showImageAction, &QAction::triggered, [this]() + { + QLabel *label = new QLabel(this, Qt::Window); + const QImage image = GetImage(); + label->setPixmap(QPixmap::fromImage(image)); + label->setGeometry(QRect(QCursor::pos(), image.size())); + label->show(); + }); const QImage image = GetImage(); if (not image.isNull()) @@ -708,16 +718,6 @@ void DialogPatternProperties::ChangeImage() } } -//--------------------------------------------------------------------------------------------------------------------- -void DialogPatternProperties::DeleteImage() -{ - doc->DeleteImage(); - ui->imageLabel->setText(tr("Change image")); - deleteAction->setEnabled(false); - saveImageAction->setEnabled(false); - showImageAction->setEnabled(false); -} - //--------------------------------------------------------------------------------------------------------------------- void DialogPatternProperties::SaveImage() { @@ -741,25 +741,3 @@ void DialogPatternProperties::SaveImage() } } } - -//--------------------------------------------------------------------------------------------------------------------- -void DialogPatternProperties::ShowImage() -{ - QLabel *label = new QLabel(this, Qt::Window); - const QImage image = GetImage(); - label->setPixmap(QPixmap::fromImage(image)); - label->setGeometry(QRect(QCursor::pos(), image.size())); - label->show(); -} - -//--------------------------------------------------------------------------------------------------------------------- -void DialogPatternProperties::ShowContextMenu() -{ - QMenu menu(this); - menu.addAction(deleteAction); - menu.addAction(changeImageAction); - menu.addAction(saveImageAction); - menu.addAction(showImageAction); - menu.exec(QCursor::pos()); - menu.show(); -} diff --git a/src/app/valentina/dialogs/dialogpatternproperties.h b/src/app/valentina/dialogs/dialogpatternproperties.h index 9cac4d3fc..b3e2cc731 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.h +++ b/src/app/valentina/dialogs/dialogpatternproperties.h @@ -50,23 +50,16 @@ public: QWidget *parent = nullptr); virtual ~DialogPatternProperties() Q_DECL_OVERRIDE; signals: - void UpdateGradation(); -public slots: - void Apply(); - void Ok(); - void SelectAll(int state); - void CheckStateHeight(int state); - void CheckStateSize(int state); - void DescEdited(); - void ChangeImage(); - void ShowContextMenu(); + void UpdateGradation(); private slots: - void ToggleComboBox(); - void DefValueChanged(); - void SecurityValueChanged(); - void DeleteImage(); + void Apply(); + void Ok(); + void SelectAll(int state); + void CheckStateHeight(int state); + void CheckStateSize(int state); + void DescEdited(); + void ChangeImage(); void SaveImage(); - void ShowImage(); private: Q_DISABLE_COPY(DialogPatternProperties) Ui::DialogPatternProperties *ui; diff --git a/src/app/valentina/dialogs/dialogsavelayout.cpp b/src/app/valentina/dialogs/dialogsavelayout.cpp index e02c06fa1..380067988 100644 --- a/src/app/valentina/dialogs/dialogsavelayout.cpp +++ b/src/app/valentina/dialogs/dialogsavelayout.cpp @@ -90,10 +90,17 @@ DialogSaveLayout::DialogSaveLayout(int count, const QString &fileName, QWidget * ui->comboBoxFormat->addItem(v.first, QVariant(v.second)); } connect(bOk, &QPushButton::clicked, this, &DialogSaveLayout::Save); - connect(ui->lineEditFileName, &QLineEdit::textChanged, this, &DialogSaveLayout::ShowExample); - connect(ui->comboBoxFormat, static_cast(&QComboBox::currentIndexChanged), this, - &DialogSaveLayout::ShowExample); - connect(ui->pushButtonBrowse, &QPushButton::clicked, this, &DialogSaveLayout::Browse); + + auto ShowExample = [this](){ui->labelExample->setText(tr("Example:") + FileName() + "1" + Formate());}; + + connect(ui->lineEditFileName, &QLineEdit::textChanged, ShowExample); + connect(ui->comboBoxFormat, static_cast(&QComboBox::currentIndexChanged), ShowExample); + connect(ui->pushButtonBrowse, &QPushButton::clicked, [this]() + { + const QString dir = QFileDialog::getExistingDirectory(this, tr("Select folder"), QDir::homePath(), + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + ui->lineEditPath->setText(dir); + }); connect(ui->lineEditPath, &QLineEdit::textChanged, this, &DialogSaveLayout::PathChanged); ui->lineEditPath->setText(qApp->ValentinaSettings()->GetPathLayout()); @@ -210,20 +217,6 @@ void DialogSaveLayout::Save() accept(); } -//--------------------------------------------------------------------------------------------------------------------- -void DialogSaveLayout::ShowExample() -{ - ui->labelExample->setText(tr("Example:") + FileName() + "1" + Formate()); -} - -//--------------------------------------------------------------------------------------------------------------------- -void DialogSaveLayout::Browse() -{ - const QString dir = QFileDialog::getExistingDirectory(this, tr("Select folder"), QDir::homePath(), - QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); - ui->lineEditPath->setText(dir); -} - //--------------------------------------------------------------------------------------------------------------------- void DialogSaveLayout::PathChanged(const QString &text) { diff --git a/src/app/valentina/dialogs/dialogsavelayout.h b/src/app/valentina/dialogs/dialogsavelayout.h index 2d384e4b9..9a3739bb8 100644 --- a/src/app/valentina/dialogs/dialogsavelayout.h +++ b/src/app/valentina/dialogs/dialogsavelayout.h @@ -57,13 +57,11 @@ public: void SelectFormate(const int formate); static QString MakeHelpFormatList(); void SetDestinationPath(const QString& cmdDestinationPath); -public slots: - void Save(); - void ShowExample(); - void Browse(); - void PathChanged(const QString &text); protected: virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; +private slots: + void Save(); + void PathChanged(const QString &text); private: Q_DISABLE_COPY(DialogSaveLayout) Ui::DialogSaveLAyout *ui; diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 015887aff..ee9a8afa8 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -137,7 +137,7 @@ MainWindow::MainWindow(QWidget *parent) doc = new VPattern(pattern, &mode, sceneDraw, sceneDetails); connect(doc, &VPattern::ClearMainWindow, this, &MainWindow::Clear); - connect(doc, &VPattern::patternChanged, this, &MainWindow::PatternWasModified); + connect(doc, &VPattern::patternChanged, this, &MainWindow::PatternChangesWereSaved); connect(doc, &VPattern::UndoCommand, this, &MainWindow::FullParseFile); connect(doc, &VPattern::SetEnabledGUI, this, &MainWindow::SetEnabledGUI); connect(doc, &VPattern::CheckLayout, [this](){ @@ -163,7 +163,7 @@ MainWindow::MainWindow(QWidget *parent) ToolBarTools(); - connect(qApp->getUndoStack(), &QUndoStack::cleanChanged, this, &MainWindow::PatternWasModified); + connect(qApp->getUndoStack(), &QUndoStack::cleanChanged, this, &MainWindow::PatternChangesWereSaved); InitAutoSave(); @@ -178,7 +178,27 @@ MainWindow::MainWindow(QWidget *parent) ui->dockWidgetLayoutPages->setVisible(false); connect(watcher, &QFileSystemWatcher::fileChanged, this, &MainWindow::MeasurementsChanged); - connect(qApp, &QApplication::focusChanged, this, &MainWindow::OnWindowFocusChanged); + connect(qApp, &QApplication::focusChanged, [this](QWidget *old, QWidget *now) + { + if (old == nullptr && isAncestorOf(now) == true) + {// focus IN + if (mChanges && not mChangesAsked) + { + mChangesAsked = true; + const auto answer = QMessageBox::question(this, tr("Measurements"), + tr("Measurements was changed. Do you want to sync measurements now?"), + QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes); + if (answer == QMessageBox::Yes) + { + SyncMeasurements(); + } + } + } + + // In case we will need it + // else if (isAncestorOf(old) == true && now == nullptr) + // focus OUT + }); #if defined(Q_OS_MAC) // On Mac deafault icon size is 32x32. @@ -215,28 +235,6 @@ MainWindow::MainWindow(QWidget *parent) #endif //defined(Q_OS_MAC) } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief ActionNewPP add to scene new pattern piece. - */ -void MainWindow::NewPP() -{ - qCDebug(vMainWindow, "New PP."); - QString patternPieceName = QString(tr("Pattern piece %1")).arg(comboBoxDraws->count()+1); - qCDebug(vMainWindow, "Generated PP name: %s", qUtf8Printable(patternPieceName)); - - qCDebug(vMainWindow, "PP count %d", comboBoxDraws->count()); - patternPieceName = PatternPieceName(patternPieceName); - qCDebug(vMainWindow, "PP name: %s", qUtf8Printable(patternPieceName)); - if (patternPieceName.isEmpty()) - { - qCDebug(vMainWindow, "Name empty."); - return; - } - - AddPP(patternPieceName); -} - //--------------------------------------------------------------------------------------------------------------------- void MainWindow::AddPP(const QString &PPName) { @@ -335,7 +333,7 @@ void MainWindow::InitScenes() connect(this, &MainWindow::EnableSplineHover, sceneDraw, &VMainGraphicsScene::ToggleSplineHover); connect(this, &MainWindow::EnableSplinePathHover, sceneDraw, &VMainGraphicsScene::ToggleSplinePathHover); - connect(sceneDraw, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove); + connect(sceneDraw, &VMainGraphicsScene::mouseMove, this, &MainWindow::MouseMove); sceneDetails = new VMainGraphicsScene(); connect(this, &MainWindow::EnableItemMove, sceneDetails, &VMainGraphicsScene::EnableItemMove); @@ -348,7 +346,7 @@ void MainWindow::InitScenes() connect(this, &MainWindow::EnableNodePointHover, sceneDetails, &VMainGraphicsScene::ToggleNodePointHover); connect(this, &MainWindow::EnableDetailHover, sceneDetails, &VMainGraphicsScene::ToggleDetailHover); - connect(sceneDetails, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove); + connect(sceneDetails, &VMainGraphicsScene::mouseMove, this, &MainWindow::MouseMove); ui->view->setScene(currentScene); @@ -525,22 +523,6 @@ bool MainWindow::UpdateMeasurements(const QString &path, int size, int height) return true; } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief OptionDraw help change name of pattern piece. - */ -void MainWindow::DrawOption() -{ - const QString activDraw = doc->GetNameActivPP(); - const QString nameDraw = PatternPieceName(activDraw); - if (nameDraw.isEmpty()) - { - return; - } - RenamePP *renamePP = new RenamePP(doc, nameDraw, comboBoxDraws); - qApp->getUndoStack()->push(renamePP); -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief SetToolButton set tool and show dialog. @@ -633,7 +615,7 @@ void MainWindow::SetToolButtonWithApply(bool checked, Tool t, const QString &cur connect(dialogTool.data(), &DialogTool::DialogClosed, this, closeDialogSlot); connect(dialogTool.data(), &DialogTool::DialogApplied, this, applyDialogSlot); connect(dialogTool.data(), &DialogTool::ToolTip, this, &MainWindow::ShowToolTip); - connect(ui->view, &VMainGraphicsView::MouseRelease, this, &MainWindow::ClickEndVisualization); + connect(ui->view, &VMainGraphicsView::MouseRelease, [this](){EndVisualization(true);}); ui->view->itemClicked(nullptr); } else @@ -1200,26 +1182,6 @@ void MainWindow::ToolTrueDarts(bool checked) &MainWindow::ApplyDialog); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief About show widows about. - */ -void MainWindow::About() -{ - DialogAboutApp * about_dialog = new DialogAboutApp(this); - about_dialog->setAttribute(Qt::WA_DeleteOnClose, true); - about_dialog->show(); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief AboutQt show widows aboutQt. - */ -void MainWindow::AboutQt() -{ - QMessageBox::aboutQt(this, tr("About Qt")); -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief ShowTool highlight tool.Tip show tools tooltip. @@ -1230,36 +1192,6 @@ void MainWindow::ShowToolTip(const QString &toolTip) helpLabel->setText(toolTip); } -//--------------------------------------------------------------------------------------------------------------------- -void MainWindow::OpenRecentFile() -{ - QAction *action = qobject_cast(sender()); - if (action) - { - const QString filePath = action->data().toString(); - if (filePath.isEmpty() == false) - { - LoadPattern(filePath); - } - } -} - -//--------------------------------------------------------------------------------------------------------------------- -void MainWindow::PatternProperties() -{ - DialogPatternProperties proper(curFile, doc, pattern, this); - connect(&proper, &DialogPatternProperties::UpdateGradation, this, &MainWindow::UpdateGradation); - proper.exec(); -} - -//--------------------------------------------------------------------------------------------------------------------- -void MainWindow::EditPatternCode() -{ - DialogPatternXmlEdit *Pattern = new DialogPatternXmlEdit (this, doc); - Pattern->setAttribute(Qt::WA_DeleteOnClose, true); - Pattern->show(); -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief showEvent handle after show window. @@ -1379,7 +1311,7 @@ void MainWindow::LoadIndividual() ui->actionUnloadMeasurements->setEnabled(true); doc->SetPath(RelativeMPath(curFile, mPath)); watcher->addPath(mPath); - PatternWasModified(false); + PatternChangesWereSaved(false); ui->actionShowM->setEnabled(true); helpLabel->setText(tr("Measurements loaded")); doc->LiteParseTree(Document::LiteParse); @@ -1419,7 +1351,7 @@ void MainWindow::LoadStandard() ui->actionUnloadMeasurements->setEnabled(true); doc->SetPath(RelativeMPath(curFile, mPath)); watcher->addPath(mPath); - PatternWasModified(false); + PatternChangesWereSaved(false); ui->actionShowM->setEnabled(true); helpLabel->setText(tr("Measurements loaded")); doc->LiteParseTree(Document::LiteParse); @@ -1455,7 +1387,7 @@ void MainWindow::UnloadMeasurements() { watcher->removePath(AbsoluteMPath(curFile, doc->MPath())); doc->SetPath(QString()); - PatternWasModified(false); + PatternChangesWereSaved(false); ui->actionShowM->setEnabled(false); ui->actionUnloadMeasurements->setDisabled(true); helpLabel->setText(tr("Measurements unloaded")); @@ -1469,14 +1401,6 @@ void MainWindow::UnloadMeasurements() } } -//--------------------------------------------------------------------------------------------------------------------- -void MainWindow::CreateMeasurements() -{ - const QString tape = qApp->TapeFilePath(); - const QString workingDirectory = QFileInfo(tape).absoluteDir().absolutePath(); - QProcess::startDetached(tape, QStringList(), workingDirectory); -} - //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ShowMeasurements() { @@ -1572,29 +1496,6 @@ void MainWindow::SyncMeasurements() } } -//--------------------------------------------------------------------------------------------------------------------- -void MainWindow::OnWindowFocusChanged(QWidget *old, QWidget *now) -{ - if (old == nullptr && isAncestorOf(now) == true) - {// focus IN - if (mChanges && not mChangesAsked) - { - mChangesAsked = true; - const auto answer = QMessageBox::question(this, tr("Measurements"), - tr("Measurements was changed. Do you want to sync measurements now?"), - QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes); - if (answer == QMessageBox::Yes) - { - SyncMeasurements(); - } - } - } - - // In case we will need it - // else if (isAncestorOf(old) == true && now == nullptr) - // focus OUT -} - //--------------------------------------------------------------------------------------------------------------------- #if defined(Q_OS_MAC) void MainWindow::OpenAt(QAction *where) @@ -1709,9 +1610,19 @@ void MainWindow::ToolBarDraws() comboBoxDraws->setSizeAdjustPolicy(QComboBox::AdjustToContents); comboBoxDraws->setEnabled(false); connect(comboBoxDraws, static_cast(&QComboBox::currentIndexChanged), - this, &MainWindow::currentPPChanged); + [this](int index){ChangePP(index);}); - connect(ui->actionOptionDraw, &QAction::triggered, this, &MainWindow::DrawOption); + connect(ui->actionOptionDraw, &QAction::triggered, [this]() + { + const QString activDraw = doc->GetNameActivPP(); + const QString nameDraw = PatternPieceName(activDraw); + if (nameDraw.isEmpty()) + { + return; + } + RenamePP *renamePP = new RenamePP(doc, nameDraw, comboBoxDraws); + qApp->getUndoStack()->push(renamePP); + }); } void MainWindow::ToolBarTools() @@ -1800,30 +1711,19 @@ void MainWindow::InitToolButtons() connect(ui->toolButtonMidpoint, &QToolButton::clicked, this, &MainWindow::ToolMidpoint); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief currentPPChanged change active pattern piece. - * @param index index in combobox. - */ -void MainWindow::currentPPChanged(int index) -{ - ChangePP(index); -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief mouseMove save mouse position and show user. * @param scenePos position mouse. */ -void MainWindow::mouseMove(const QPointF &scenePos) +void MainWindow::MouseMove(const QPointF &scenePos) { - //: Coords in status line: "X, Y (units)" - QString string = QString(tr("%1, %2 (%3)")).arg(static_cast(qApp->fromPixel(scenePos.x()))) - .arg(static_cast(qApp->fromPixel(scenePos.y()))) - .arg(doc->UnitsToStr(qApp->patternUnit(), true)); - if (mouseCoordinate != nullptr) + if (mouseCoordinate) { - mouseCoordinate->setText(string); + //: Coords in status line: "X, Y (units)" + mouseCoordinate->setText(QString("%1, %2 (%3)").arg(static_cast(qApp->fromPixel(scenePos.x()))) + .arg(static_cast(qApp->fromPixel(scenePos.y()))) + .arg(doc->UnitsToStr(qApp->patternUnit(), true))); } } @@ -2497,36 +2397,6 @@ void MainWindow::Open() LoadPattern(filePath); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief Preferences config dialog. - */ -void MainWindow::Preferences() -{ - ConfigDialog dlg(this); - connect(&dlg, &ConfigDialog::UpdateProperties, this, &MainWindow::WindowsLocale); // Must be first - connect(&dlg, &ConfigDialog::UpdateProperties, toolOptions, &VToolOptionsPropertyBrowser::RefreshOptions); - connect(&dlg, &ConfigDialog::UpdateProperties, this, &MainWindow::ToolBarStyles); - if (dlg.exec() == QDialog::Accepted) - { - InitAutoSave(); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -void MainWindow::RepotBug() -{ - qCDebug(vMainWindow, "Reporting bug"); - QDesktopServices::openUrl(QUrl("https://bitbucket.org/dismine/valentina/issues/new")); -} - -//--------------------------------------------------------------------------------------------------------------------- -void MainWindow::OnlineHelp() -{ - qCDebug(vMainWindow, "Showing online help"); - QDesktopServices::openUrl(QUrl("https://bitbucket.org/dismine/valentina/wiki/manual/Content")); -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief Clear reset to default window. @@ -2607,20 +2477,6 @@ void MainWindow::FileClosedCorrect() qCDebug(vMainWindow, "File %s closed correct.", qUtf8Printable(curFile)); } -//--------------------------------------------------------------------------------------------------------------------- -void MainWindow::ResetWindow() -{ - if (MaybeSave()) - { - FileClosedCorrect(); - } - else - { - return; - } - Clear(); -} - //--------------------------------------------------------------------------------------------------------------------- void MainWindow::FullParseFile() { @@ -2840,19 +2696,6 @@ void MainWindow::SetEnableWidgets(bool enable) ui->view->setEnabled(enable); } -//--------------------------------------------------------------------------------------------------------------------- -void MainWindow::ClickEndVisualization() -{ - EndVisualization(true); -} - -//--------------------------------------------------------------------------------------------------------------------- -void MainWindow::UpdateGradation() -{ - UpdateHeightsList(VMeasurement::ListHeights(doc->GetGradationHeights(), qApp->patternUnit())); - UpdateSizesList(VMeasurement::ListSizes(doc->GetGradationSizes(), qApp->patternUnit())); -} - //--------------------------------------------------------------------------------------------------------------------- void MainWindow::UpdateHeightsList(const QStringList &list) { @@ -2948,7 +2791,7 @@ void MainWindow::New() /** * @brief haveChange enable action save if we have unsaved change. */ -void MainWindow::PatternWasModified(bool saved) +void MainWindow::PatternChangesWereSaved(bool saved) { if (guiEnabled) { @@ -3055,78 +2898,6 @@ void MainWindow::SetDefaultSize() pattern->SetSize(gradationSizes->currentText().toInt()); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief ActionTable show table with variables. - * @param checked true - button checked. - */ -void MainWindow::ActionTable(bool checked) -{ - if (checked) - { - dialogTable = new DialogIncrements(pattern, doc, this); - connect(dialogTable, &DialogIncrements::DialogClosed, this, &MainWindow::ClosedActionTable); - dialogTable->show(); - } - else - { - ui->actionTable->setChecked(true); - dialogTable->activateWindow(); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief ClosedActionTable actions after closing table with variables. - */ -void MainWindow::ClosedActionTable() -{ - ui->actionTable->setChecked(false); - delete dialogTable; - dialogTable = nullptr; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief ActionHistory show tool history. - * @param checked true - button checked. - */ -void MainWindow::ActionHistory(bool checked) -{ - if (checked) - { - dialogHistory = new DialogHistory(pattern, doc, this); - dialogHistory->setWindowFlags(Qt::Window); - connect(this, &MainWindow::RefreshHistory, dialogHistory.data(), &DialogHistory::UpdateHistory); - connect(dialogHistory.data(), &DialogHistory::DialogClosed, this, &MainWindow::ClosedActionHistory); - // Fix issue #526. Dialog Detail is not on top after selection second object on Mac. - dialogHistory->setWindowFlags(dialogHistory->windowFlags() | Qt::WindowStaysOnTopHint); - dialogHistory->show(); - } - else - { - ui->actionHistory->setChecked(true); - dialogHistory->activateWindow(); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -void MainWindow::ActionCurveDetailsMode(bool checked) -{ - ui->view->itemClicked(nullptr); - sceneDraw->EnableDetailsMode(checked); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief ClosedActionHistory actions after closing history window with variables. - */ -void MainWindow::ClosedActionHistory() -{ - ui->actionHistory->setChecked(false); - delete dialogHistory; -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief SetEnableTool enable button. @@ -3253,7 +3024,7 @@ bool MainWindow::SavePattern(const QString &fileName, QString &error) setCurrentFile(fileName); helpLabel->setText(tr("File saved")); qCDebug(vMainWindow, "File %s saved.", qUtf8Printable(fileName)); - PatternWasModified(result); + PatternChangesWereSaved(result); } } else @@ -3701,28 +3472,156 @@ void MainWindow::CreateActions() connect(ui->actionDraw, &QAction::triggered, this, &MainWindow::ActionDraw); connect(ui->actionDetails, &QAction::triggered, this, &MainWindow::ActionDetails); connect(ui->actionLayout, &QAction::triggered, this, &MainWindow::ActionLayout); - connect(ui->actionHistory, &QAction::triggered, this, &MainWindow::ActionHistory); - connect(ui->actionNewDraw, &QAction::triggered, this, &MainWindow::NewPP); + + connect(ui->actionHistory, &QAction::triggered, [this](bool checked) + { + if (checked) + { + dialogHistory = new DialogHistory(pattern, doc, this); + dialogHistory->setWindowFlags(Qt::Window); + connect(this, &MainWindow::RefreshHistory, dialogHistory.data(), &DialogHistory::UpdateHistory); + connect(dialogHistory.data(), &DialogHistory::DialogClosed, [this]() + { + ui->actionHistory->setChecked(false); + delete dialogHistory; + }); + // Fix issue #526. Dialog Detail is not on top after selection second object on Mac. + dialogHistory->setWindowFlags(dialogHistory->windowFlags() | Qt::WindowStaysOnTopHint); + dialogHistory->show(); + } + else + { + ui->actionHistory->setChecked(true); + dialogHistory->activateWindow(); + } + }); + + connect(ui->actionNewDraw, &QAction::triggered, [this]() + { + qCDebug(vMainWindow, "New PP."); + QString patternPieceName = QString(tr("Pattern piece %1")).arg(comboBoxDraws->count()+1); + qCDebug(vMainWindow, "Generated PP name: %s", qUtf8Printable(patternPieceName)); + + qCDebug(vMainWindow, "PP count %d", comboBoxDraws->count()); + patternPieceName = PatternPieceName(patternPieceName); + qCDebug(vMainWindow, "PP name: %s", qUtf8Printable(patternPieceName)); + if (patternPieceName.isEmpty()) + { + qCDebug(vMainWindow, "Name empty."); + return; + } + + 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->actionTable, &QAction::triggered, this, &MainWindow::ActionTable); - connect(ui->actionAbout_Qt, &QAction::triggered, this, &MainWindow::AboutQt); - connect(ui->actionAbout_Valentina, &QAction::triggered, this, &MainWindow::About); + + connect(ui->actionTable, &QAction::triggered, [this](bool checked) + { + if (checked) + { + dialogTable = new DialogIncrements(pattern, doc, this); + connect(dialogTable.data(), &DialogIncrements::DialogClosed, [this]() + { + ui->actionTable->setChecked(false); + delete dialogTable; + }); + dialogTable->show(); + } + else + { + ui->actionTable->setChecked(true); + dialogTable->activateWindow(); + } + }); + + connect(ui->actionAbout_Qt, &QAction::triggered, [this]() + { + QMessageBox::aboutQt(this, tr("About Qt")); + }); + + connect(ui->actionAbout_Valentina, &QAction::triggered, [this]() + { + DialogAboutApp *aboutDialog = new DialogAboutApp(this); + aboutDialog->setAttribute(Qt::WA_DeleteOnClose, true); + aboutDialog->show(); + }); + connect(ui->actionExit, &QAction::triggered, this, &MainWindow::close); - connect(ui->actionPreferences, &QAction::triggered, this, &MainWindow::Preferences); - connect(ui->actionReportBug, &QAction::triggered, this, &MainWindow::RepotBug); - connect(ui->actionOnlineHelp, &QAction::triggered, this, &MainWindow::OnlineHelp); + + connect(ui->actionPreferences, &QAction::triggered, [this]() + { + ConfigDialog dlg(this); + connect(&dlg, &ConfigDialog::UpdateProperties, this, &MainWindow::WindowsLocale); // Must be first + connect(&dlg, &ConfigDialog::UpdateProperties, toolOptions, &VToolOptionsPropertyBrowser::RefreshOptions); + connect(&dlg, &ConfigDialog::UpdateProperties, this, &MainWindow::ToolBarStyles); + if (dlg.exec() == QDialog::Accepted) + { + InitAutoSave(); + } + }); + + connect(ui->actionReportBug, &QAction::triggered, [this]() + { + qCDebug(vMainWindow, "Reporting bug"); + QDesktopServices::openUrl(QUrl(QStringLiteral("https://bitbucket.org/dismine/valentina/issues/new"))); + }); + + connect(ui->actionOnlineHelp, &QAction::triggered, [this]() + { + qCDebug(vMainWindow, "Showing online help"); + QDesktopServices::openUrl(QUrl(QStringLiteral("https://bitbucket.org/dismine/valentina/wiki/manual/Content"))); + }); + connect(ui->actionLast_tool, &QAction::triggered, this, &MainWindow::LastUsedTool); - connect(ui->actionPattern_properties, &QAction::triggered, this, &MainWindow::PatternProperties); + + connect(ui->actionPattern_properties, &QAction::triggered, [this]() + { + DialogPatternProperties proper(curFile, doc, pattern, this); + connect(&proper, &DialogPatternProperties::UpdateGradation, [this]() + { + UpdateHeightsList(VMeasurement::ListHeights(doc->GetGradationHeights(), qApp->patternUnit())); + UpdateSizesList(VMeasurement::ListSizes(doc->GetGradationSizes(), qApp->patternUnit())); + }); + proper.exec(); + }); + ui->actionPattern_properties->setEnabled(false); - connect(ui->actionEdit_pattern_code, &QAction::triggered, this, &MainWindow::EditPatternCode); - connect(ui->actionClosePattern, &QAction::triggered, this, &MainWindow::ResetWindow); - connect(ui->actionShowCurveDetails, &QAction::triggered, this, &MainWindow::ActionCurveDetailsMode); + connect(ui->actionEdit_pattern_code, &QAction::triggered, [this]() + { + DialogPatternXmlEdit *pattern = new DialogPatternXmlEdit (this, doc); + pattern->setAttribute(Qt::WA_DeleteOnClose, true); + pattern->show(); + }); + + connect(ui->actionClosePattern, &QAction::triggered, [this]() + { + if (MaybeSave()) + { + FileClosedCorrect(); + Clear(); + } + }); + + connect(ui->actionShowCurveDetails, &QAction::triggered, [this](bool checked) + { + ui->view->itemClicked(nullptr); + sceneDraw->EnableDetailsMode(checked); + }); + connect(ui->actionLoadIndividual, &QAction::triggered, this, &MainWindow::LoadIndividual); connect(ui->actionLoadStandard, &QAction::triggered, this, &MainWindow::LoadStandard); - connect(ui->actionCreateNew, &QAction::triggered, this, &MainWindow::CreateMeasurements); + + connect(ui->actionCreateNew, &QAction::triggered, [this]() + { + const QString tape = qApp->TapeFilePath(); + const QString workingDirectory = QFileInfo(tape).absoluteDir().absolutePath(); + QProcess::startDetached(tape, QStringList(), workingDirectory); + }); + connect(ui->actionShowM, &QAction::triggered, this, &MainWindow::ShowMeasurements); connect(ui->actionExportAs, &QAction::triggered, this, &MainWindow::ExportLayoutAs); connect(ui->actionPrintPreview, &QAction::triggered, this, &MainWindow::PrintPreviewOrigin); @@ -3737,7 +3636,18 @@ void MainWindow::CreateActions() { recentFileActs[i] = new QAction(this); recentFileActs[i]->setVisible(false); - connect(recentFileActs[i], &QAction::triggered, this, &MainWindow::OpenRecentFile); + connect(recentFileActs[i], &QAction::triggered, [this]() + { + QAction *action = qobject_cast(sender()); + if (action) + { + const QString filePath = action->data().toString(); + if (not filePath.isEmpty()) + { + LoadPattern(filePath); + } + } + }); } connect(ui->actionSyncMeasurements, &QAction::triggered, this, &MainWindow::SyncMeasurements); @@ -4228,7 +4138,7 @@ QString MainWindow::CheckPathToMeasurements(const QString &patternPath, const QS } doc->SetPath(RelativeMPath(patternPath, mPath)); - PatternWasModified(false); + PatternChangesWereSaved(false); qApp->setPatternType(patternType); return mPath; } diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h index 10d5d5a4c..11bf1f229 100644 --- a/src/app/valentina/mainwindow.h +++ b/src/app/valentina/mainwindow.h @@ -62,151 +62,117 @@ public: explicit MainWindow(QWidget *parent = nullptr); virtual ~MainWindow() Q_DECL_OVERRIDE; - bool LoadPattern(const QString &curFile, const QString &customMeasureFile = QString()); + bool LoadPattern(const QString &curFile, const QString &customMeasureFile = QString()); public slots: - void ProcessCMD(); + void ProcessCMD(); + void ShowToolTip(const QString &toolTip); - void mouseMove(const QPointF &scenePos); - void ArrowTool(); - - void ActionDraw(bool checked); - void ActionDetails(bool checked); - void ActionLayout(bool checked); - - void ActionTable(bool checked); - void ActionHistory(bool checked); - void ActionCurveDetailsMode(bool checked); - void DrawOption(); - - void ClosedActionTable(); - void ClosedActionHistory(); - - void New(); - bool SaveAs(); - bool Save(); - void Open(); - void NewPP(); - - void Preferences(); - void RepotBug(); - void OnlineHelp(); - void About(); - void AboutQt(); - void PatternProperties(); - void ShowToolTip(const QString &toolTip); - void OpenRecentFile(); - void Clear(); - void ResetWindow(); - - void currentPPChanged(int index); - - void PatternWasModified(bool saved); - - void ToolEndLine(bool checked); - void ToolLine(bool checked); - void ToolAlongLine(bool checked); - void ToolMidpoint(bool checked); - void ToolShoulderPoint(bool checked); - void ToolNormal(bool checked); - void ToolBisector(bool checked); - void ToolLineIntersect(bool checked); - void ToolSpline(bool checked); - void ToolCubicBezier(bool checked); - void ToolCutSpline(bool checked); - void ToolArc(bool checked); - void ToolSplinePath(bool checked); - void ToolCubicBezierPath(bool checked); - void ToolCutSplinePath(bool checked); - void ToolPointOfContact(bool checked); - void ToolDetail(bool checked); - void ToolHeight(bool checked); - void ToolTriangle(bool checked); - void ToolPointOfIntersection(bool checked); - void ToolUnionDetails(bool checked); - void ToolGroup(bool checked); - void ToolRotation(bool checked); - void ToolCutArc(bool checked); - void ToolLineIntersectAxis(bool checked); - void ToolCurveIntersectAxis(bool checked); - void ToolArcIntersectAxis(bool checked); - void ToolPointOfIntersectionArcs(bool checked); - void ToolPointOfIntersectionCircles(bool checked); - void ToolPointOfIntersectionCurves(bool checked); - void ToolPointFromCircleAndTangent(bool checked); - void ToolPointFromArcAndTangent(bool checked); - void ToolArcWithLength(bool checked); - void ToolTrueDarts(bool checked); - - void ClosedDialogDetail(int result); - void ClosedDialogUnionDetails(int result); - void ClosedDialogGroup(int result); - -//tmp - void LastUsedTool(); - - /** - * @brief Edit XML code of pattern - */ - void EditPatternCode(); - void FullParseFile(); - - void SetEnabledGUI(bool enabled); - - void ClickEndVisualization(); - void UpdateGradation(); - void GlobalChangePP(const QString &patternPiece); - void WindowsLocale(); - void ToolBarStyles(); - - void ShowPaper(int index); signals: - void RefreshHistory(); - void EnableItemMove(bool move); - void ItemsSelection(SelectionType type) const; + void RefreshHistory(); + void EnableItemMove(bool move); + void ItemsSelection(SelectionType type) const; - void EnableLabelSelection(bool enable) const; - void EnablePointSelection(bool enable) const; - void EnableLineSelection(bool enable) const; - void EnableArcSelection(bool enable) const; - void EnableSplineSelection(bool enable) const; - void EnableSplinePathSelection(bool enable) const; - void EnableNodeLabelSelection(bool enable) const; - void EnableNodePointSelection(bool enable) const; - void EnableDetailSelection(bool enable) const; + void EnableLabelSelection(bool enable) const; + void EnablePointSelection(bool enable) const; + void EnableLineSelection(bool enable) const; + void EnableArcSelection(bool enable) const; + void EnableSplineSelection(bool enable) const; + void EnableSplinePathSelection(bool enable) const; + void EnableNodeLabelSelection(bool enable) const; + void EnableNodePointSelection(bool enable) const; + void EnableDetailSelection(bool enable) const; - void EnableLabelHover(bool enable) const; - void EnablePointHover(bool enable) const; - void EnableLineHover(bool enable) const; - void EnableArcHover(bool enable) const; - void EnableSplineHover(bool enable) const; - void EnableSplinePathHover(bool enable) const; - void EnableNodeLabelHover(bool enable) const; - void EnableNodePointHover(bool enable) const; - void EnableDetailHover(bool enable) const; + void EnableLabelHover(bool enable) const; + void EnablePointHover(bool enable) const; + void EnableLineHover(bool enable) const; + void EnableArcHover(bool enable) const; + void EnableSplineHover(bool enable) const; + void EnableSplinePathHover(bool enable) const; + void EnableNodeLabelHover(bool enable) const; + void EnableNodePointHover(bool enable) const; + void EnableDetailHover(bool enable) const; protected: - virtual void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE; - virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; - virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; - virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; - virtual void customEvent(QEvent * event) Q_DECL_OVERRIDE; - virtual void CleanLayout() Q_DECL_OVERRIDE; - virtual void PrepareSceneList() Q_DECL_OVERRIDE; + virtual void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE; + virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; + virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; + virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; + virtual void customEvent(QEvent * event) Q_DECL_OVERRIDE; + virtual void CleanLayout() Q_DECL_OVERRIDE; + virtual void PrepareSceneList() Q_DECL_OVERRIDE; private slots: + void MouseMove(const QPointF &scenePos); + void Clear(); + void PatternChangesWereSaved(bool saved); + void LastUsedTool(); + void FullParseFile(); + void SetEnabledGUI(bool enabled); + void GlobalChangePP(const QString &patternPiece); + void WindowsLocale(); + void ToolBarStyles(); + void ShowPaper(int index); + + void ArrowTool(); + void ToolEndLine(bool checked); + void ToolLine(bool checked); + void ToolAlongLine(bool checked); + void ToolMidpoint(bool checked); + void ToolShoulderPoint(bool checked); + void ToolNormal(bool checked); + void ToolBisector(bool checked); + void ToolLineIntersect(bool checked); + void ToolSpline(bool checked); + void ToolCubicBezier(bool checked); + void ToolCutSpline(bool checked); + void ToolArc(bool checked); + void ToolSplinePath(bool checked); + void ToolCubicBezierPath(bool checked); + void ToolCutSplinePath(bool checked); + void ToolPointOfContact(bool checked); + void ToolDetail(bool checked); + void ToolHeight(bool checked); + void ToolTriangle(bool checked); + void ToolPointOfIntersection(bool checked); + void ToolUnionDetails(bool checked); + void ToolGroup(bool checked); + void ToolRotation(bool checked); + void ToolCutArc(bool checked); + void ToolLineIntersectAxis(bool checked); + void ToolCurveIntersectAxis(bool checked); + void ToolArcIntersectAxis(bool checked); + void ToolPointOfIntersectionArcs(bool checked); + void ToolPointOfIntersectionCircles(bool checked); + void ToolPointOfIntersectionCurves(bool checked); + void ToolPointFromCircleAndTangent(bool checked); + void ToolPointFromArcAndTangent(bool checked); + void ToolArcWithLength(bool checked); + void ToolTrueDarts(bool checked); + + void ActionDraw(bool checked); + void ActionDetails(bool checked); + void ActionLayout(bool checked); + + void New(); + bool SaveAs(); + bool Save(); + void Open(); + + void ClosedDialogDetail(int result); + void ClosedDialogUnionDetails(int result); + void ClosedDialogGroup(int result); + void LoadIndividual(); void LoadStandard(); void UnloadMeasurements(); - void CreateMeasurements(); void ShowMeasurements(); void MeasurementsChanged(const QString &path); void SyncMeasurements(); - void OnWindowFocusChanged(QWidget* old, QWidget* now); #if defined(Q_OS_MAC) void OpenAt(QAction *where); #endif //defined(Q_OS_MAC) void ChangedSize(const QString &text); - void ChangedHeight(const QString & text); + void ChangedHeight(const QString &text); private: Q_DISABLE_COPY(MainWindow) @@ -242,9 +208,9 @@ private: bool patternReadOnly; - DialogIncrements *dialogTable; - QPointer dialogTool; - QPointer dialogHistory; + QPointer dialogTable; + QPointer dialogTool; + QPointer dialogHistory; /** @brief comboBoxDraws comboc who show name of pattern peaces. */ QComboBox *comboBoxDraws; diff --git a/src/app/valentina/mainwindowsnogui.h b/src/app/valentina/mainwindowsnogui.h index dbff87c6c..e1c4f41e4 100644 --- a/src/app/valentina/mainwindowsnogui.h +++ b/src/app/valentina/mainwindowsnogui.h @@ -54,12 +54,10 @@ public slots: void ToolLayoutSettings(bool checked); void ExportLayoutAs(); void SaveAsTiledPDF(); - void PrintPages (QPrinter *printer); void PrintPreviewOrigin(); void PrintPreviewTiled(); void PrintOrigin(); void PrintTiled(); - void ErrorConsoleMode(const LayoutErrors &state); protected: QVector listDetails; @@ -99,6 +97,9 @@ protected: virtual void PrepareSceneList()=0; QIcon ScenePreview(int i) const; bool LayoutSettings(VLayoutGenerator& lGenerator); +private slots: + void PrintPages (QPrinter *printer); + void ErrorConsoleMode(const LayoutErrors &state); private: Q_DISABLE_COPY(MainWindowsNoGUI) diff --git a/src/libs/fervor/fvupdater.cpp b/src/libs/fervor/fvupdater.cpp index 17a6bcef7..946412ab0 100644 --- a/src/libs/fervor/fvupdater.cpp +++ b/src/libs/fervor/fvupdater.cpp @@ -261,8 +261,24 @@ void FvUpdater::startDownloadFeed(const QUrl &url) m_reply = m_qnam.get(request); - connect(m_reply, &QNetworkReply::readyRead, this, &FvUpdater::httpFeedReadyRead); - connect(m_reply, &QNetworkReply::downloadProgress, this, &FvUpdater::httpFeedUpdateDataReadProgress); + connect(m_reply, &QNetworkReply::readyRead, [this]() + { + // this slot gets called every time the QNetworkReply has new data. + // We read all of its new data and write it into the file. + // That way we use less RAM than when reading it at the finished() + // signal of the QNetworkReply + m_xml.addData(m_reply->readAll()); + }); + connect(m_reply, &QNetworkReply::downloadProgress, [this](qint64 bytesRead, qint64 totalBytes) + { + Q_UNUSED(bytesRead); + Q_UNUSED(totalBytes); + + if (m_httpRequestAborted) + { + return; + } + }); connect(m_reply, &QNetworkReply::finished, this, &FvUpdater::httpFeedDownloadFinished); } @@ -276,28 +292,6 @@ void FvUpdater::cancelDownloadFeed() } } -//--------------------------------------------------------------------------------------------------------------------- -void FvUpdater::httpFeedReadyRead() -{ - // this slot gets called every time the QNetworkReply has new data. - // We read all of its new data and write it into the file. - // That way we use less RAM than when reading it at the finished() - // signal of the QNetworkReply - m_xml.addData(m_reply->readAll()); -} - -//--------------------------------------------------------------------------------------------------------------------- -void FvUpdater::httpFeedUpdateDataReadProgress(qint64 bytesRead, qint64 totalBytes) -{ - Q_UNUSED(bytesRead); - Q_UNUSED(totalBytes); - - if (m_httpRequestAborted) - { - return; - } -} - //--------------------------------------------------------------------------------------------------------------------- void FvUpdater::httpFeedDownloadFinished() { diff --git a/src/libs/fervor/fvupdater.h b/src/libs/fervor/fvupdater.h index f6021f25b..47879dc13 100644 --- a/src/libs/fervor/fvupdater.h +++ b/src/libs/fervor/fvupdater.h @@ -70,8 +70,6 @@ protected slots: void UpdateInstallationConfirmed(); private slots: - void httpFeedReadyRead(); - void httpFeedUpdateDataReadProgress(qint64 bytesRead, qint64 totalBytes); void httpFeedDownloadFinished(); private: diff --git a/src/libs/qmuparser/qmuparsertest.h b/src/libs/qmuparser/qmuparsertest.h index 220de68fe..46b0711c1 100644 --- a/src/libs/qmuparser/qmuparsertest.h +++ b/src/libs/qmuparser/qmuparsertest.h @@ -52,7 +52,7 @@ public: QmuParserTester(QObject *parent = nullptr); -public slots: +private slots: void Run(); private: diff --git a/src/libs/vmisc/vabstractapplication.cpp b/src/libs/vmisc/vabstractapplication.cpp index 4fdc30c88..14f52abb0 100644 --- a/src/libs/vmisc/vabstractapplication.cpp +++ b/src/libs/vmisc/vabstractapplication.cpp @@ -72,7 +72,13 @@ VAbstractApplication::VAbstractApplication(int &argc, char **argv) // Enable support for HiDPI bitmap resources setAttribute(Qt::AA_UseHighDpiPixmaps); - connect(this, &QApplication::aboutToQuit, this, &VAbstractApplication::SyncSettings); + connect(this, &QApplication::aboutToQuit, [this]() + { + // If try to use the method QApplication::exit program can't sync settings and show warning about QApplication + // instance. Solution is to call sync() before quit. + // Connect this slot with VApplication::aboutToQuit. + Settings()->sync(); + }); } //--------------------------------------------------------------------------------------------------------------------- @@ -256,15 +262,6 @@ double VAbstractApplication::fromPixel(double pix) const return FromPixel(pix, _patternUnit); } -//--------------------------------------------------------------------------------------------------------------------- -void VAbstractApplication::SyncSettings() -{ - // If try to use the method QApplication::exit program can't sync settings and show warning about QApplication - // instance. Solution is to call sync() before quit. - // Connect this slot with VApplication::aboutToQuit. - Settings()->sync(); -} - //--------------------------------------------------------------------------------------------------------------------- void VAbstractApplication::LoadTranslation(const QString &locale) { diff --git a/src/libs/vmisc/vabstractapplication.h b/src/libs/vmisc/vabstractapplication.h index f8b02e013..13dbbaf05 100644 --- a/src/libs/vmisc/vabstractapplication.h +++ b/src/libs/vmisc/vabstractapplication.h @@ -96,9 +96,6 @@ public: virtual bool IsAppInGUIMode()const =0; -protected slots: - void SyncSettings(); - protected: QUndoStack *undoStack; diff --git a/src/libs/vtools/dialogs/support/dialogundo.cpp b/src/libs/vtools/dialogs/support/dialogundo.cpp index f915051be..4b858a632 100644 --- a/src/libs/vtools/dialogs/support/dialogundo.cpp +++ b/src/libs/vtools/dialogs/support/dialogundo.cpp @@ -48,9 +48,17 @@ DialogUndo::DialogUndo(QWidget *parent) } else { - connect(ui->pushButtonUndo, &QPushButton::clicked, this, &DialogUndo::Undo); + connect(ui->pushButtonUndo, &QPushButton::clicked, [this]() + { + result = UndoButton::Undo; + accept(); + }); } - connect(ui->pushButtonFix, &QPushButton::clicked, this, &DialogUndo::Fix); + connect(ui->pushButtonFix, &QPushButton::clicked, [this]() + { + result = UndoButton::Fix; + accept(); + }); connect(ui->pushButtonCancel, &QPushButton::clicked, this, &DialogUndo::Cancel); setCursor(Qt::ArrowCursor); @@ -62,20 +70,6 @@ DialogUndo::~DialogUndo() delete ui; } -//--------------------------------------------------------------------------------------------------------------------- -void DialogUndo::Undo() -{ - result = UndoButton::Undo; - accept(); -} - -//--------------------------------------------------------------------------------------------------------------------- -void DialogUndo::Fix() -{ - result = UndoButton::Fix; - accept(); -} - //--------------------------------------------------------------------------------------------------------------------- void DialogUndo::Cancel() { diff --git a/src/libs/vtools/dialogs/support/dialogundo.h b/src/libs/vtools/dialogs/support/dialogundo.h index ccb20873d..be9ef5c34 100644 --- a/src/libs/vtools/dialogs/support/dialogundo.h +++ b/src/libs/vtools/dialogs/support/dialogundo.h @@ -42,15 +42,13 @@ class DialogUndo : public QDialog { Q_OBJECT public: - explicit DialogUndo(QWidget *parent = 0); + explicit DialogUndo(QWidget *parent = nullptr); UndoButton Result() const; virtual ~DialogUndo() Q_DECL_OVERRIDE; -public slots: - void Undo(); - void Fix(); - void Cancel(); protected: - virtual void closeEvent ( QCloseEvent * event ) Q_DECL_OVERRIDE; + virtual void closeEvent ( QCloseEvent *event ) Q_DECL_OVERRIDE; +private slots: + void Cancel(); private: Q_DISABLE_COPY(DialogUndo) Ui::DialogUndo *ui;