Refactoring. Use lambda for small slots. Move slots declaration in appropriate

place.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-07-18 18:09:15 +03:00
parent bbaa7636fc
commit 47f12c80f8
33 changed files with 530 additions and 792 deletions

View File

@ -49,13 +49,10 @@ TapeConfigurationPage::TapeConfigurationPage(QWidget *parent)
langCombo(nullptr), langCombo(nullptr),
systemCombo(nullptr), systemCombo(nullptr),
labelCombo(nullptr), labelCombo(nullptr),
unitCombo(nullptr),
osOptionCheck(nullptr), osOptionCheck(nullptr),
langChanged(false), langChanged(false),
systemChanged(false), systemChanged(false),
defGradationChanged(false), defGradationChanged(false),
unitChanged(false),
labelLangChanged(false),
sendReportCheck(nullptr), sendReportCheck(nullptr),
askPointDeletionCheck(nullptr), askPointDeletionCheck(nullptr),
toolBarStyleCheck(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) void TapeConfigurationPage::changeEvent(QEvent *event)
{ {
@ -219,8 +173,10 @@ QGroupBox *TapeConfigurationPage::LangGroup()
{ {
langCombo->setCurrentIndex(index); langCombo->setCurrentIndex(index);
} }
connect(langCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, connect(langCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [this]()
&TapeConfigurationPage::LangChanged); {
langChanged = true;
});
QFormLayout *langLayout = new QFormLayout; QFormLayout *langLayout = new QFormLayout;
langLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); langLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
@ -267,8 +223,23 @@ QGroupBox *TapeConfigurationPage::PMSystemGroup()
pmSystemLayout->addRow(systemBookLabel, systemBookValueLabel); pmSystemLayout->addRow(systemBookLabel, systemBookValueLabel);
connect(systemCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, connect(systemCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [this]()
&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);
});
// set default pattern making system // set default pattern making system
const VTapeSettings *settings = qApp->TapeSettings(); const VTapeSettings *settings = qApp->TapeSettings();
@ -300,8 +271,14 @@ QGroupBox *TapeConfigurationPage::GradationGroup()
{ {
defHeightCombo->setCurrentIndex(index); defHeightCombo->setCurrentIndex(index);
} }
connect(defHeightCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&TapeConfigurationPage::DefGradationChanged); auto DefGradationChanged = [this]()
{
defGradationChanged = true;
};
connect(defHeightCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
DefGradationChanged);
gradationLayout->addRow(defHeightLabel, defHeightCombo); gradationLayout->addRow(defHeightLabel, defHeightCombo);
@ -314,7 +291,7 @@ QGroupBox *TapeConfigurationPage::GradationGroup()
defSizeCombo->setCurrentIndex(index); defSizeCombo->setCurrentIndex(index);
} }
connect(defHeightCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, connect(defHeightCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&TapeConfigurationPage::DefGradationChanged); DefGradationChanged);
gradationLayout->addRow(defSizeLabel, defSizeCombo); gradationLayout->addRow(defSizeLabel, defSizeCombo);
gradationGroup->setLayout(gradationLayout); gradationGroup->setLayout(gradationLayout);

View File

@ -45,12 +45,6 @@ class TapeConfigurationPage : public QWidget
public: public:
explicit TapeConfigurationPage(QWidget *parent = nullptr); explicit TapeConfigurationPage(QWidget *parent = nullptr);
void Apply(); void Apply();
public slots:
void LangChanged();
void SystemChanged();
void DefGradationChanged();
void UnitChanged();
void LabelLangChanged();
protected: protected:
virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
private: private:
@ -58,13 +52,10 @@ private:
QComboBox *langCombo; QComboBox *langCombo;
QComboBox *systemCombo; QComboBox *systemCombo;
QComboBox *labelCombo; QComboBox *labelCombo;
QComboBox *unitCombo;
QCheckBox *osOptionCheck; QCheckBox *osOptionCheck;
bool langChanged; bool langChanged;
bool systemChanged; bool systemChanged;
bool defGradationChanged; bool defGradationChanged;
bool unitChanged;
bool labelLangChanged;
QCheckBox *sendReportCheck; QCheckBox *sendReportCheck;
QCheckBox *askPointDeletionCheck; QCheckBox *askPointDeletionCheck;
QCheckBox *toolBarStyleCheck; QCheckBox *toolBarStyleCheck;

View File

@ -71,16 +71,6 @@ void TapePathPage::Apply()
settings->SetPathTemplate(pathTable->item(2, 1)->text()); 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() void TapePathPage::DefaultPath()
{ {
@ -129,8 +119,8 @@ void TapePathPage::EditPath()
default: default:
break; break;
} }
QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), path, const QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), path,
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
if (dir.isEmpty()) if (dir.isEmpty())
{ {
DefaultPath(); DefaultPath();
@ -223,7 +213,14 @@ void TapePathPage::InitTable()
pathTable->resizeRowsToContents(); pathTable->resizeRowsToContents();
pathTable->horizontalHeader()->setStretchLastSection(true); 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);
});
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -42,12 +42,11 @@ class TapePathPage : public QWidget
public: public:
explicit TapePathPage(QWidget *parent = nullptr); explicit TapePathPage(QWidget *parent = nullptr);
void Apply(); void Apply();
public slots:
void TableActivated();
void DefaultPath();
void EditPath();
protected: protected:
virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
private slots:
void DefaultPath();
void EditPath();
private: private:
Q_DISABLE_COPY(TapePathPage) Q_DISABLE_COPY(TapePathPage)
QPushButton *defaultButton; QPushButton *defaultButton;

View File

@ -57,7 +57,13 @@ DialogExportToCSV::DialogExportToCSV(QWidget *parent)
QPushButton *bDefaults = ui->buttonBox->button(QDialogButtonBox::RestoreDefaults); QPushButton *bDefaults = ui->buttonBox->button(QDialogButtonBox::RestoreDefaults);
SCASSERT(bDefaults != nullptr); 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 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) void DialogExportToCSV::SetSeparator(const QChar &separator)
{ {

View File

@ -51,9 +51,6 @@ protected:
virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
private slots:
void RestoreDefaults();
private: private:
Q_DISABLE_COPY(DialogExportToCSV) Q_DISABLE_COPY(DialogExportToCSV)
Ui::DialogExportToCSV *ui; Ui::DialogExportToCSV *ui;

View File

@ -70,7 +70,15 @@ TapeConfigDialog::TapeConfigDialog(QWidget *parent)
okButton = new QPushButton(tr("&Ok")); okButton = new QPushButton(tr("&Ok"));
createIcons(); 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); contentsWidget->setCurrentRow(0);
connect(cancelButton, &QPushButton::clicked, this, &TapeConfigDialog::close); 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)); 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) void TapeConfigDialog::closeEvent(QCloseEvent *event)
{ {

View File

@ -42,15 +42,13 @@ class TapeConfigDialog : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit TapeConfigDialog(QWidget *parent = nullptr); explicit TapeConfigDialog(QWidget *parent = nullptr);
public slots:
void changePage(QListWidgetItem *current, QListWidgetItem *previous);
signals: signals:
void UpdateProperties(); void UpdateProperties();
protected: protected:
virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
virtual void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; virtual void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
private: private:
Q_DISABLE_COPY(TapeConfigDialog) Q_DISABLE_COPY(TapeConfigDialog)
QListWidget *contentsWidget; QListWidget *contentsWidget;

View File

@ -760,12 +760,6 @@ void MApplication::ProcessCMD()
ParseCommandLine(SocketConnection::Client, arguments()); ParseCommandLine(SocketConnection::Client, arguments());
} }
//---------------------------------------------------------------------------------------------------------------------
void MApplication::OpenFile(const QString &path)
{
MainWindow()->LoadFile(path);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MApplication::NewLocalSocketConnection() void MApplication::NewLocalSocketConnection()
{ {

View File

@ -60,6 +60,7 @@ public:
virtual bool IsAppInGUIMode() const Q_DECL_OVERRIDE; virtual bool IsAppInGUIMode() const Q_DECL_OVERRIDE;
TMainWindow *MainWindow(); TMainWindow *MainWindow();
QList<TMainWindow*> MainWindows(); QList<TMainWindow*> MainWindows();
TMainWindow *NewMainWindow();
void InitOptions(); void InitOptions();
@ -77,7 +78,6 @@ public:
void ParseCommandLine(const SocketConnection &connection, const QStringList &arguments); void ParseCommandLine(const SocketConnection &connection, const QStringList &arguments);
public slots: public slots:
TMainWindow *NewMainWindow();
void ProcessCMD(); void ProcessCMD();
protected: protected:
@ -85,7 +85,6 @@ protected:
virtual bool event(QEvent *e) Q_DECL_OVERRIDE; virtual bool event(QEvent *e) Q_DECL_OVERRIDE;
private slots: private slots:
void OpenFile(const QString &path);
void NewLocalSocketConnection(); void NewLocalSocketConnection();
private: private:

View File

@ -750,7 +750,7 @@ void TMainWindow::AboutToShowWindowMenu()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TMainWindow::ShowWindow() void TMainWindow::ShowWindow() const
{ {
if (QAction *action = qobject_cast<QAction*>(sender())) if (QAction *action = qobject_cast<QAction*>(sender()))
{ {
@ -758,27 +758,13 @@ void TMainWindow::ShowWindow()
if (v.canConvert<int>()) if (v.canConvert<int>())
{ {
const int offset = qvariant_cast<int>(v); const int offset = qvariant_cast<int>(v);
QList<TMainWindow*> windows = qApp->MainWindows(); const QList<TMainWindow*> windows = qApp->MainWindows();
windows.at(offset)->raise(); windows.at(offset)->raise();
windows.at(offset)->activateWindow(); 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) #if defined(Q_OS_MAC)
void TMainWindow::AboutToShowDockMenu() 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) void TMainWindow::PatternUnitChanged(int index)
{ {
@ -1762,7 +1734,11 @@ void TMainWindow::SetupMenu()
connect(ui->actionExportToCSV, &QAction::triggered, this, &TMainWindow::ExportToCSV); connect(ui->actionExportToCSV, &QAction::triggered, this, &TMainWindow::ExportToCSV);
connect(ui->actionReadOnly, &QAction::triggered, this, &TMainWindow::ReadOnly); 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) for (int i = 0; i < MaxRecentFiles; ++i)
{ {
@ -1798,8 +1774,13 @@ void TMainWindow::SetupMenu()
AboutToShowWindowMenu(); AboutToShowWindowMenu();
// Help // Help
connect(ui->actionAboutQt, &QAction::triggered, this, &TMainWindow::AboutQt); connect(ui->actionAboutQt, &QAction::triggered, [this](){QMessageBox::aboutQt(this, tr("About Qt"));});
connect(ui->actionAboutTape, &QAction::triggered, this, &TMainWindow::AboutApplication); 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. //Actions for recent files loaded by a tape window application.
UpdateRecentFileActions(); UpdateRecentFileActions();
@ -2765,11 +2746,16 @@ void TMainWindow::CreateWindowMenu(QMenu *menu)
{ {
SCASSERT(menu != nullptr); 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); action->setMenuRole(QAction::NoRole);
menu->addSeparator(); menu->addSeparator();
QList<TMainWindow*> windows = qApp->MainWindows(); const QList<TMainWindow*> windows = qApp->MainWindows();
for (int i = 0; i < windows.count(); ++i) for (int i = 0; i < windows.count(); ++i)
{ {
TMainWindow *window = windows.at(i); TMainWindow *window = windows.at(i);

View File

@ -62,14 +62,7 @@ public:
void SetBaseMSize(int size); void SetBaseMSize(int size);
void SetPUnit(Unit unit); void SetPUnit(Unit unit);
public slots:
bool LoadFile(const QString &path); bool LoadFile(const QString &path);
void FileNew();
void OpenIndividual();
void OpenStandard();
void OpenTemplate();
void CreateFromExisting();
void OpenRecentFile();
protected: protected:
virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
@ -77,13 +70,18 @@ protected:
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
private slots: private slots:
void FileNew();
void OpenIndividual();
void OpenStandard();
void OpenTemplate();
void CreateFromExisting();
void OpenRecentFile();
void FileSave(); void FileSave();
void FileSaveAs(); void FileSaveAs();
void ExportToCSV(); void ExportToCSV();
void AboutToShowWindowMenu(); void AboutToShowWindowMenu();
void ShowWindow(); void ShowWindow() const;
void AboutApplication();
void AboutQt();
#if defined(Q_OS_MAC) #if defined(Q_OS_MAC)
void AboutToShowDockMenu(); void AboutToShowDockMenu();
@ -125,8 +123,6 @@ private slots:
void SaveMDescription(); void SaveMDescription();
void SaveMFullName(); void SaveMFullName();
void NewWindow();
void Preferences();
void PatternUnitChanged(int index); void PatternUnitChanged(int index);
private: private:

View File

@ -49,9 +49,10 @@ public:
void ClearPropertyBrowser(); void ClearPropertyBrowser();
public slots: public slots:
void itemClicked(QGraphicsItem *item); void itemClicked(QGraphicsItem *item);
void userChangedData(VPE::VProperty* property);
void UpdateOptions(); void UpdateOptions();
void RefreshOptions(); void RefreshOptions();
private slots:
void userChangedData(VPE::VProperty* property);
private: private:
Q_DISABLE_COPY(VToolOptionsPropertyBrowser) Q_DISABLE_COPY(VToolOptionsPropertyBrowser)

View File

@ -97,16 +97,6 @@ ConfigDialog::ConfigDialog(QWidget *parent) :
qApp->Settings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C)); 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) void ConfigDialog::closeEvent(QCloseEvent *event)
{ {
@ -177,7 +167,15 @@ void ConfigDialog::createIcons()
createIcon("://icon/community_config.png", tr("Community")); createIcon("://icon/community_config.png", tr("Community"));
createIcon("://icon/path_config.png", tr("Paths")); 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));
});
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -41,15 +41,13 @@ class ConfigDialog : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit ConfigDialog(QWidget *parent = nullptr); explicit ConfigDialog(QWidget *parent = nullptr);
public slots:
void changePage(QListWidgetItem *current, QListWidgetItem *previous);
signals: signals:
void UpdateProperties(); void UpdateProperties();
protected: protected:
virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
virtual void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; virtual void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
private: private:
Q_DISABLE_COPY(ConfigDialog) Q_DISABLE_COPY(ConfigDialog)
QListWidget *contentsWidget; QListWidget *contentsWidget;

View File

@ -70,16 +70,6 @@ void PathPage::Apply()
settings->SetPathTemplate(pathTable->item(4, 1)->text()); 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() void PathPage::DefaultPath()
{ {
@ -243,7 +233,14 @@ void PathPage::InitTable()
pathTable->resizeRowsToContents(); pathTable->resizeRowsToContents();
pathTable->horizontalHeader()->setStretchLastSection(true); 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);
});
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -42,12 +42,11 @@ class PathPage : public QWidget
public: public:
explicit PathPage(QWidget *parent = nullptr); explicit PathPage(QWidget *parent = nullptr);
void Apply(); void Apply();
public slots:
void TableActivated();
void DefaultPath();
void EditPath();
protected: protected:
virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
private slots:
void DefaultPath();
void EditPath();
private: private:
Q_DISABLE_COPY(PathPage) Q_DISABLE_COPY(PathPage)
QPushButton *defaultButton; QPushButton *defaultButton;

View File

@ -122,17 +122,16 @@ public:
protected: protected:
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
public slots: public slots:
void DialogAccepted();
private slots:
void ConvertPaperSize(); void ConvertPaperSize();
void ConvertLayoutSize(); void ConvertLayoutSize();
void TemplateSelected(); void TemplateSelected();
void FindTemplate(); void FindTemplate();
void PaperSizeChanged(); void PaperSizeChanged();
void Swap(bool checked); void Swap(bool checked);
void DialogAccepted();
void RestoreDefaults(); void RestoreDefaults();
private slots:
void CorrectMaxFileds(); void CorrectMaxFileds();
void IgnoreAllFields(int state); void IgnoreAllFields(int state);
private: private:

View File

@ -45,13 +45,13 @@ class DialogNewPattern : public QDialog
Q_OBJECT Q_OBJECT
public: public:
DialogNewPattern(VContainer *data, const QString &patternPieceName, QWidget *parent = nullptr); DialogNewPattern(VContainer *data, const QString &patternPieceName, QWidget *parent = nullptr);
~DialogNewPattern(); virtual ~DialogNewPattern();
QString name() const; QString name() const;
Unit PatternUnit() const; Unit PatternUnit() const;
public slots:
void CheckState();
protected: protected:
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
private slots:
void CheckState();
private: private:
Q_DISABLE_COPY(DialogNewPattern) Q_DISABLE_COPY(DialogNewPattern)
Ui::DialogNewPattern *ui; Ui::DialogNewPattern *ui;

View File

@ -133,22 +133,27 @@ DialogPatternProperties::DialogPatternProperties(const QString &filePath, VPatte
const QString size = QString().setNum(doc->GetDefCustomSize()); const QString size = QString().setNum(doc->GetDefCustomSize());
SetDefaultSize(size); SetDefaultSize(size);
connect(ui->radioButtonDefFromP, &QRadioButton::toggled, this, &DialogPatternProperties::ToggleComboBox); connect(ui->radioButtonDefFromP, &QRadioButton::toggled, [this]()
connect(ui->radioButtonDefFromP, &QRadioButton::toggled, this, &DialogPatternProperties::DefValueChanged); {
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()); ui->radioButtonDefFromP->setChecked(doc->IsDefCustom());
connect(ui->comboBoxHeight, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, connect(ui->comboBoxHeight, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
&DialogPatternProperties::DefValueChanged); DefValueChanged);
connect(ui->comboBoxSize, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, connect(ui->comboBoxSize, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), DefValueChanged);
&DialogPatternProperties::DefValueChanged);
const bool readOnly = doc->IsReadOnly(); const bool readOnly = doc->IsReadOnly();
ui->checkBoxPatternReadOnly->setChecked(readOnly); ui->checkBoxPatternReadOnly->setChecked(readOnly);
if (not readOnly) if (not readOnly)
{ {
connect(ui->checkBoxPatternReadOnly, &QRadioButton::toggled, this, connect(ui->checkBoxPatternReadOnly, &QRadioButton::toggled, [this](){securityChanged = true;});
&DialogPatternProperties::SecurityValueChanged);
} }
else else
{ {
@ -359,25 +364,6 @@ void DialogPatternProperties::DescEdited()
descriptionChanged = true; 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) void DialogPatternProperties::SetHeightsChecked(bool enabled)
{ {
@ -642,17 +628,41 @@ void DialogPatternProperties::InitImage()
{ {
ui->imageLabel->setContextMenuPolicy(Qt::CustomContextMenu); ui->imageLabel->setContextMenuPolicy(Qt::CustomContextMenu);
ui->imageLabel->setScaledContents(true); 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); deleteAction = new QAction(tr("Delete image"), this);
changeImageAction = new QAction(tr("Change image"), this); changeImageAction = new QAction(tr("Change image"), this);
saveImageAction = new QAction(tr("Save image to file"), this); saveImageAction = new QAction(tr("Save image to file"), this);
showImageAction = new QAction(tr("Show image"), 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(changeImageAction, &QAction::triggered, this, &DialogPatternProperties::ChangeImage);
connect(saveImageAction, &QAction::triggered, this, &DialogPatternProperties::SaveImage); 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(); const QImage image = GetImage();
if (not image.isNull()) 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() 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();
}

View File

@ -50,23 +50,16 @@ public:
QWidget *parent = nullptr); QWidget *parent = nullptr);
virtual ~DialogPatternProperties() Q_DECL_OVERRIDE; virtual ~DialogPatternProperties() Q_DECL_OVERRIDE;
signals: signals:
void UpdateGradation(); 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();
private slots: private slots:
void ToggleComboBox(); void Apply();
void DefValueChanged(); void Ok();
void SecurityValueChanged(); void SelectAll(int state);
void DeleteImage(); void CheckStateHeight(int state);
void CheckStateSize(int state);
void DescEdited();
void ChangeImage();
void SaveImage(); void SaveImage();
void ShowImage();
private: private:
Q_DISABLE_COPY(DialogPatternProperties) Q_DISABLE_COPY(DialogPatternProperties)
Ui::DialogPatternProperties *ui; Ui::DialogPatternProperties *ui;

View File

@ -90,10 +90,17 @@ DialogSaveLayout::DialogSaveLayout(int count, const QString &fileName, QWidget *
ui->comboBoxFormat->addItem(v.first, QVariant(v.second)); ui->comboBoxFormat->addItem(v.first, QVariant(v.second));
} }
connect(bOk, &QPushButton::clicked, this, &DialogSaveLayout::Save); connect(bOk, &QPushButton::clicked, this, &DialogSaveLayout::Save);
connect(ui->lineEditFileName, &QLineEdit::textChanged, this, &DialogSaveLayout::ShowExample);
connect(ui->comboBoxFormat, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, auto ShowExample = [this](){ui->labelExample->setText(tr("Example:") + FileName() + "1" + Formate());};
&DialogSaveLayout::ShowExample);
connect(ui->pushButtonBrowse, &QPushButton::clicked, this, &DialogSaveLayout::Browse); connect(ui->lineEditFileName, &QLineEdit::textChanged, ShowExample);
connect(ui->comboBoxFormat, static_cast<void (QComboBox::*)(int)>(&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); connect(ui->lineEditPath, &QLineEdit::textChanged, this, &DialogSaveLayout::PathChanged);
ui->lineEditPath->setText(qApp->ValentinaSettings()->GetPathLayout()); ui->lineEditPath->setText(qApp->ValentinaSettings()->GetPathLayout());
@ -210,20 +217,6 @@ void DialogSaveLayout::Save()
accept(); 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) void DialogSaveLayout::PathChanged(const QString &text)
{ {

View File

@ -57,13 +57,11 @@ public:
void SelectFormate(const int formate); void SelectFormate(const int formate);
static QString MakeHelpFormatList(); static QString MakeHelpFormatList();
void SetDestinationPath(const QString& cmdDestinationPath); void SetDestinationPath(const QString& cmdDestinationPath);
public slots:
void Save();
void ShowExample();
void Browse();
void PathChanged(const QString &text);
protected: protected:
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
private slots:
void Save();
void PathChanged(const QString &text);
private: private:
Q_DISABLE_COPY(DialogSaveLayout) Q_DISABLE_COPY(DialogSaveLayout)
Ui::DialogSaveLAyout *ui; Ui::DialogSaveLAyout *ui;

View File

@ -137,7 +137,7 @@ MainWindow::MainWindow(QWidget *parent)
doc = new VPattern(pattern, &mode, sceneDraw, sceneDetails); doc = new VPattern(pattern, &mode, sceneDraw, sceneDetails);
connect(doc, &VPattern::ClearMainWindow, this, &MainWindow::Clear); 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::UndoCommand, this, &MainWindow::FullParseFile);
connect(doc, &VPattern::SetEnabledGUI, this, &MainWindow::SetEnabledGUI); connect(doc, &VPattern::SetEnabledGUI, this, &MainWindow::SetEnabledGUI);
connect(doc, &VPattern::CheckLayout, [this](){ connect(doc, &VPattern::CheckLayout, [this](){
@ -163,7 +163,7 @@ MainWindow::MainWindow(QWidget *parent)
ToolBarTools(); ToolBarTools();
connect(qApp->getUndoStack(), &QUndoStack::cleanChanged, this, &MainWindow::PatternWasModified); connect(qApp->getUndoStack(), &QUndoStack::cleanChanged, this, &MainWindow::PatternChangesWereSaved);
InitAutoSave(); InitAutoSave();
@ -178,7 +178,27 @@ MainWindow::MainWindow(QWidget *parent)
ui->dockWidgetLayoutPages->setVisible(false); ui->dockWidgetLayoutPages->setVisible(false);
connect(watcher, &QFileSystemWatcher::fileChanged, this, &MainWindow::MeasurementsChanged); 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) #if defined(Q_OS_MAC)
// On Mac deafault icon size is 32x32. // On Mac deafault icon size is 32x32.
@ -215,28 +235,6 @@ MainWindow::MainWindow(QWidget *parent)
#endif //defined(Q_OS_MAC) #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) void MainWindow::AddPP(const QString &PPName)
{ {
@ -335,7 +333,7 @@ void MainWindow::InitScenes()
connect(this, &MainWindow::EnableSplineHover, sceneDraw, &VMainGraphicsScene::ToggleSplineHover); connect(this, &MainWindow::EnableSplineHover, sceneDraw, &VMainGraphicsScene::ToggleSplineHover);
connect(this, &MainWindow::EnableSplinePathHover, sceneDraw, &VMainGraphicsScene::ToggleSplinePathHover); connect(this, &MainWindow::EnableSplinePathHover, sceneDraw, &VMainGraphicsScene::ToggleSplinePathHover);
connect(sceneDraw, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove); connect(sceneDraw, &VMainGraphicsScene::mouseMove, this, &MainWindow::MouseMove);
sceneDetails = new VMainGraphicsScene(); sceneDetails = new VMainGraphicsScene();
connect(this, &MainWindow::EnableItemMove, sceneDetails, &VMainGraphicsScene::EnableItemMove); connect(this, &MainWindow::EnableItemMove, sceneDetails, &VMainGraphicsScene::EnableItemMove);
@ -348,7 +346,7 @@ void MainWindow::InitScenes()
connect(this, &MainWindow::EnableNodePointHover, sceneDetails, &VMainGraphicsScene::ToggleNodePointHover); connect(this, &MainWindow::EnableNodePointHover, sceneDetails, &VMainGraphicsScene::ToggleNodePointHover);
connect(this, &MainWindow::EnableDetailHover, sceneDetails, &VMainGraphicsScene::ToggleDetailHover); 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); ui->view->setScene(currentScene);
@ -525,22 +523,6 @@ bool MainWindow::UpdateMeasurements(const QString &path, int size, int height)
return true; 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. * @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::DialogClosed, this, closeDialogSlot);
connect(dialogTool.data(), &DialogTool::DialogApplied, this, applyDialogSlot); connect(dialogTool.data(), &DialogTool::DialogApplied, this, applyDialogSlot);
connect(dialogTool.data(), &DialogTool::ToolTip, this, &MainWindow::ShowToolTip); 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); ui->view->itemClicked(nullptr);
} }
else else
@ -1200,26 +1182,6 @@ void MainWindow::ToolTrueDarts(bool checked)
&MainWindow::ApplyDialog<VToolTrueDarts>); &MainWindow::ApplyDialog<VToolTrueDarts>);
} }
//---------------------------------------------------------------------------------------------------------------------
/**
* @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. * @brief ShowTool highlight tool.Tip show tools tooltip.
@ -1230,36 +1192,6 @@ void MainWindow::ShowToolTip(const QString &toolTip)
helpLabel->setText(toolTip); helpLabel->setText(toolTip);
} }
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::OpenRecentFile()
{
QAction *action = qobject_cast<QAction *>(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. * @brief showEvent handle after show window.
@ -1379,7 +1311,7 @@ void MainWindow::LoadIndividual()
ui->actionUnloadMeasurements->setEnabled(true); ui->actionUnloadMeasurements->setEnabled(true);
doc->SetPath(RelativeMPath(curFile, mPath)); doc->SetPath(RelativeMPath(curFile, mPath));
watcher->addPath(mPath); watcher->addPath(mPath);
PatternWasModified(false); PatternChangesWereSaved(false);
ui->actionShowM->setEnabled(true); ui->actionShowM->setEnabled(true);
helpLabel->setText(tr("Measurements loaded")); helpLabel->setText(tr("Measurements loaded"));
doc->LiteParseTree(Document::LiteParse); doc->LiteParseTree(Document::LiteParse);
@ -1419,7 +1351,7 @@ void MainWindow::LoadStandard()
ui->actionUnloadMeasurements->setEnabled(true); ui->actionUnloadMeasurements->setEnabled(true);
doc->SetPath(RelativeMPath(curFile, mPath)); doc->SetPath(RelativeMPath(curFile, mPath));
watcher->addPath(mPath); watcher->addPath(mPath);
PatternWasModified(false); PatternChangesWereSaved(false);
ui->actionShowM->setEnabled(true); ui->actionShowM->setEnabled(true);
helpLabel->setText(tr("Measurements loaded")); helpLabel->setText(tr("Measurements loaded"));
doc->LiteParseTree(Document::LiteParse); doc->LiteParseTree(Document::LiteParse);
@ -1455,7 +1387,7 @@ void MainWindow::UnloadMeasurements()
{ {
watcher->removePath(AbsoluteMPath(curFile, doc->MPath())); watcher->removePath(AbsoluteMPath(curFile, doc->MPath()));
doc->SetPath(QString()); doc->SetPath(QString());
PatternWasModified(false); PatternChangesWereSaved(false);
ui->actionShowM->setEnabled(false); ui->actionShowM->setEnabled(false);
ui->actionUnloadMeasurements->setDisabled(true); ui->actionUnloadMeasurements->setDisabled(true);
helpLabel->setText(tr("Measurements unloaded")); 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() 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) #if defined(Q_OS_MAC)
void MainWindow::OpenAt(QAction *where) void MainWindow::OpenAt(QAction *where)
@ -1709,9 +1610,19 @@ void MainWindow::ToolBarDraws()
comboBoxDraws->setSizeAdjustPolicy(QComboBox::AdjustToContents); comboBoxDraws->setSizeAdjustPolicy(QComboBox::AdjustToContents);
comboBoxDraws->setEnabled(false); comboBoxDraws->setEnabled(false);
connect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), connect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&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() void MainWindow::ToolBarTools()
@ -1800,30 +1711,19 @@ void MainWindow::InitToolButtons()
connect(ui->toolButtonMidpoint, &QToolButton::clicked, this, &MainWindow::ToolMidpoint); 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. * @brief mouseMove save mouse position and show user.
* @param scenePos position mouse. * @param scenePos position mouse.
*/ */
void MainWindow::mouseMove(const QPointF &scenePos) void MainWindow::MouseMove(const QPointF &scenePos)
{ {
//: Coords in status line: "X, Y (units)" if (mouseCoordinate)
QString string = QString(tr("%1, %2 (%3)")).arg(static_cast<qint32>(qApp->fromPixel(scenePos.x())))
.arg(static_cast<qint32>(qApp->fromPixel(scenePos.y())))
.arg(doc->UnitsToStr(qApp->patternUnit(), true));
if (mouseCoordinate != nullptr)
{ {
mouseCoordinate->setText(string); //: Coords in status line: "X, Y (units)"
mouseCoordinate->setText(QString("%1, %2 (%3)").arg(static_cast<qint32>(qApp->fromPixel(scenePos.x())))
.arg(static_cast<qint32>(qApp->fromPixel(scenePos.y())))
.arg(doc->UnitsToStr(qApp->patternUnit(), true)));
} }
} }
@ -2497,36 +2397,6 @@ void MainWindow::Open()
LoadPattern(filePath); 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. * @brief Clear reset to default window.
@ -2607,20 +2477,6 @@ void MainWindow::FileClosedCorrect()
qCDebug(vMainWindow, "File %s closed correct.", qUtf8Printable(curFile)); qCDebug(vMainWindow, "File %s closed correct.", qUtf8Printable(curFile));
} }
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ResetWindow()
{
if (MaybeSave())
{
FileClosedCorrect();
}
else
{
return;
}
Clear();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::FullParseFile() void MainWindow::FullParseFile()
{ {
@ -2840,19 +2696,6 @@ void MainWindow::SetEnableWidgets(bool enable)
ui->view->setEnabled(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) void MainWindow::UpdateHeightsList(const QStringList &list)
{ {
@ -2948,7 +2791,7 @@ void MainWindow::New()
/** /**
* @brief haveChange enable action save if we have unsaved change. * @brief haveChange enable action save if we have unsaved change.
*/ */
void MainWindow::PatternWasModified(bool saved) void MainWindow::PatternChangesWereSaved(bool saved)
{ {
if (guiEnabled) if (guiEnabled)
{ {
@ -3055,78 +2898,6 @@ void MainWindow::SetDefaultSize()
pattern->SetSize(gradationSizes->currentText().toInt()); 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. * @brief SetEnableTool enable button.
@ -3253,7 +3024,7 @@ bool MainWindow::SavePattern(const QString &fileName, QString &error)
setCurrentFile(fileName); setCurrentFile(fileName);
helpLabel->setText(tr("File saved")); helpLabel->setText(tr("File saved"));
qCDebug(vMainWindow, "File %s saved.", qUtf8Printable(fileName)); qCDebug(vMainWindow, "File %s saved.", qUtf8Printable(fileName));
PatternWasModified(result); PatternChangesWereSaved(result);
} }
} }
else else
@ -3701,28 +3472,156 @@ void MainWindow::CreateActions()
connect(ui->actionDraw, &QAction::triggered, this, &MainWindow::ActionDraw); connect(ui->actionDraw, &QAction::triggered, this, &MainWindow::ActionDraw);
connect(ui->actionDetails, &QAction::triggered, this, &MainWindow::ActionDetails); connect(ui->actionDetails, &QAction::triggered, this, &MainWindow::ActionDetails);
connect(ui->actionLayout, &QAction::triggered, this, &MainWindow::ActionLayout); 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->actionSaveAs, &QAction::triggered, this, &MainWindow::SaveAs);
connect(ui->actionSave, &QAction::triggered, this, &MainWindow::Save); connect(ui->actionSave, &QAction::triggered, this, &MainWindow::Save);
connect(ui->actionOpen, &QAction::triggered, this, &MainWindow::Open); connect(ui->actionOpen, &QAction::triggered, this, &MainWindow::Open);
connect(ui->actionNew, &QAction::triggered, this, &MainWindow::New); 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->actionTable, &QAction::triggered, [this](bool checked)
connect(ui->actionAbout_Valentina, &QAction::triggered, this, &MainWindow::About); {
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->actionExit, &QAction::triggered, this, &MainWindow::close);
connect(ui->actionPreferences, &QAction::triggered, this, &MainWindow::Preferences);
connect(ui->actionReportBug, &QAction::triggered, this, &MainWindow::RepotBug); connect(ui->actionPreferences, &QAction::triggered, [this]()
connect(ui->actionOnlineHelp, &QAction::triggered, this, &MainWindow::OnlineHelp); {
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->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); ui->actionPattern_properties->setEnabled(false);
connect(ui->actionEdit_pattern_code, &QAction::triggered, this, &MainWindow::EditPatternCode); connect(ui->actionEdit_pattern_code, &QAction::triggered, [this]()
connect(ui->actionClosePattern, &QAction::triggered, this, &MainWindow::ResetWindow); {
connect(ui->actionShowCurveDetails, &QAction::triggered, this, &MainWindow::ActionCurveDetailsMode); 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->actionLoadIndividual, &QAction::triggered, this, &MainWindow::LoadIndividual);
connect(ui->actionLoadStandard, &QAction::triggered, this, &MainWindow::LoadStandard); 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->actionShowM, &QAction::triggered, this, &MainWindow::ShowMeasurements);
connect(ui->actionExportAs, &QAction::triggered, this, &MainWindow::ExportLayoutAs); connect(ui->actionExportAs, &QAction::triggered, this, &MainWindow::ExportLayoutAs);
connect(ui->actionPrintPreview, &QAction::triggered, this, &MainWindow::PrintPreviewOrigin); connect(ui->actionPrintPreview, &QAction::triggered, this, &MainWindow::PrintPreviewOrigin);
@ -3737,7 +3636,18 @@ void MainWindow::CreateActions()
{ {
recentFileActs[i] = new QAction(this); recentFileActs[i] = new QAction(this);
recentFileActs[i]->setVisible(false); recentFileActs[i]->setVisible(false);
connect(recentFileActs[i], &QAction::triggered, this, &MainWindow::OpenRecentFile); connect(recentFileActs[i], &QAction::triggered, [this]()
{
QAction *action = qobject_cast<QAction *>(sender());
if (action)
{
const QString filePath = action->data().toString();
if (not filePath.isEmpty())
{
LoadPattern(filePath);
}
}
});
} }
connect(ui->actionSyncMeasurements, &QAction::triggered, this, &MainWindow::SyncMeasurements); 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)); doc->SetPath(RelativeMPath(patternPath, mPath));
PatternWasModified(false); PatternChangesWereSaved(false);
qApp->setPatternType(patternType); qApp->setPatternType(patternType);
return mPath; return mPath;
} }

View File

@ -62,151 +62,117 @@ public:
explicit MainWindow(QWidget *parent = nullptr); explicit MainWindow(QWidget *parent = nullptr);
virtual ~MainWindow() Q_DECL_OVERRIDE; 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: 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: signals:
void RefreshHistory(); void RefreshHistory();
void EnableItemMove(bool move); void EnableItemMove(bool move);
void ItemsSelection(SelectionType type) const; void ItemsSelection(SelectionType type) const;
void EnableLabelSelection(bool enable) const; void EnableLabelSelection(bool enable) const;
void EnablePointSelection(bool enable) const; void EnablePointSelection(bool enable) const;
void EnableLineSelection(bool enable) const; void EnableLineSelection(bool enable) const;
void EnableArcSelection(bool enable) const; void EnableArcSelection(bool enable) const;
void EnableSplineSelection(bool enable) const; void EnableSplineSelection(bool enable) const;
void EnableSplinePathSelection(bool enable) const; void EnableSplinePathSelection(bool enable) const;
void EnableNodeLabelSelection(bool enable) const; void EnableNodeLabelSelection(bool enable) const;
void EnableNodePointSelection(bool enable) const; void EnableNodePointSelection(bool enable) const;
void EnableDetailSelection(bool enable) const; void EnableDetailSelection(bool enable) const;
void EnableLabelHover(bool enable) const; void EnableLabelHover(bool enable) const;
void EnablePointHover(bool enable) const; void EnablePointHover(bool enable) const;
void EnableLineHover(bool enable) const; void EnableLineHover(bool enable) const;
void EnableArcHover(bool enable) const; void EnableArcHover(bool enable) const;
void EnableSplineHover(bool enable) const; void EnableSplineHover(bool enable) const;
void EnableSplinePathHover(bool enable) const; void EnableSplinePathHover(bool enable) const;
void EnableNodeLabelHover(bool enable) const; void EnableNodeLabelHover(bool enable) const;
void EnableNodePointHover(bool enable) const; void EnableNodePointHover(bool enable) const;
void EnableDetailHover(bool enable) const; void EnableDetailHover(bool enable) const;
protected: protected:
virtual void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE; virtual void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
virtual void customEvent(QEvent * event) Q_DECL_OVERRIDE; virtual void customEvent(QEvent * event) Q_DECL_OVERRIDE;
virtual void CleanLayout() Q_DECL_OVERRIDE; virtual void CleanLayout() Q_DECL_OVERRIDE;
virtual void PrepareSceneList() Q_DECL_OVERRIDE; virtual void PrepareSceneList() Q_DECL_OVERRIDE;
private slots: 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 LoadIndividual();
void LoadStandard(); void LoadStandard();
void UnloadMeasurements(); void UnloadMeasurements();
void CreateMeasurements();
void ShowMeasurements(); void ShowMeasurements();
void MeasurementsChanged(const QString &path); void MeasurementsChanged(const QString &path);
void SyncMeasurements(); void SyncMeasurements();
void OnWindowFocusChanged(QWidget* old, QWidget* now);
#if defined(Q_OS_MAC) #if defined(Q_OS_MAC)
void OpenAt(QAction *where); void OpenAt(QAction *where);
#endif //defined(Q_OS_MAC) #endif //defined(Q_OS_MAC)
void ChangedSize(const QString &text); void ChangedSize(const QString &text);
void ChangedHeight(const QString & text); void ChangedHeight(const QString &text);
private: private:
Q_DISABLE_COPY(MainWindow) Q_DISABLE_COPY(MainWindow)
@ -242,9 +208,9 @@ private:
bool patternReadOnly; bool patternReadOnly;
DialogIncrements *dialogTable; QPointer<DialogIncrements> dialogTable;
QPointer<DialogTool> dialogTool; QPointer<DialogTool> dialogTool;
QPointer<DialogHistory> dialogHistory; QPointer<DialogHistory> dialogHistory;
/** @brief comboBoxDraws comboc who show name of pattern peaces. */ /** @brief comboBoxDraws comboc who show name of pattern peaces. */
QComboBox *comboBoxDraws; QComboBox *comboBoxDraws;

View File

@ -54,12 +54,10 @@ public slots:
void ToolLayoutSettings(bool checked); void ToolLayoutSettings(bool checked);
void ExportLayoutAs(); void ExportLayoutAs();
void SaveAsTiledPDF(); void SaveAsTiledPDF();
void PrintPages (QPrinter *printer);
void PrintPreviewOrigin(); void PrintPreviewOrigin();
void PrintPreviewTiled(); void PrintPreviewTiled();
void PrintOrigin(); void PrintOrigin();
void PrintTiled(); void PrintTiled();
void ErrorConsoleMode(const LayoutErrors &state);
protected: protected:
QVector<VLayoutDetail> listDetails; QVector<VLayoutDetail> listDetails;
@ -99,6 +97,9 @@ protected:
virtual void PrepareSceneList()=0; virtual void PrepareSceneList()=0;
QIcon ScenePreview(int i) const; QIcon ScenePreview(int i) const;
bool LayoutSettings(VLayoutGenerator& lGenerator); bool LayoutSettings(VLayoutGenerator& lGenerator);
private slots:
void PrintPages (QPrinter *printer);
void ErrorConsoleMode(const LayoutErrors &state);
private: private:
Q_DISABLE_COPY(MainWindowsNoGUI) Q_DISABLE_COPY(MainWindowsNoGUI)

View File

@ -261,8 +261,24 @@ void FvUpdater::startDownloadFeed(const QUrl &url)
m_reply = m_qnam.get(request); m_reply = m_qnam.get(request);
connect(m_reply, &QNetworkReply::readyRead, this, &FvUpdater::httpFeedReadyRead); connect(m_reply, &QNetworkReply::readyRead, [this]()
connect(m_reply, &QNetworkReply::downloadProgress, this, &FvUpdater::httpFeedUpdateDataReadProgress); {
// 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); 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() void FvUpdater::httpFeedDownloadFinished()
{ {

View File

@ -70,8 +70,6 @@ protected slots:
void UpdateInstallationConfirmed(); void UpdateInstallationConfirmed();
private slots: private slots:
void httpFeedReadyRead();
void httpFeedUpdateDataReadProgress(qint64 bytesRead, qint64 totalBytes);
void httpFeedDownloadFinished(); void httpFeedDownloadFinished();
private: private:

View File

@ -52,7 +52,7 @@ public:
QmuParserTester(QObject *parent = nullptr); QmuParserTester(QObject *parent = nullptr);
public slots: private slots:
void Run(); void Run();
private: private:

View File

@ -72,7 +72,13 @@ VAbstractApplication::VAbstractApplication(int &argc, char **argv)
// Enable support for HiDPI bitmap resources // Enable support for HiDPI bitmap resources
setAttribute(Qt::AA_UseHighDpiPixmaps); 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); 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) void VAbstractApplication::LoadTranslation(const QString &locale)
{ {

View File

@ -96,9 +96,6 @@ public:
virtual bool IsAppInGUIMode()const =0; virtual bool IsAppInGUIMode()const =0;
protected slots:
void SyncSettings();
protected: protected:
QUndoStack *undoStack; QUndoStack *undoStack;

View File

@ -48,9 +48,17 @@ DialogUndo::DialogUndo(QWidget *parent)
} }
else 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); connect(ui->pushButtonCancel, &QPushButton::clicked, this, &DialogUndo::Cancel);
setCursor(Qt::ArrowCursor); setCursor(Qt::ArrowCursor);
@ -62,20 +70,6 @@ DialogUndo::~DialogUndo()
delete ui; delete ui;
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogUndo::Undo()
{
result = UndoButton::Undo;
accept();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogUndo::Fix()
{
result = UndoButton::Fix;
accept();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogUndo::Cancel() void DialogUndo::Cancel()
{ {

View File

@ -42,15 +42,13 @@ class DialogUndo : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DialogUndo(QWidget *parent = 0); explicit DialogUndo(QWidget *parent = nullptr);
UndoButton Result() const; UndoButton Result() const;
virtual ~DialogUndo() Q_DECL_OVERRIDE; virtual ~DialogUndo() Q_DECL_OVERRIDE;
public slots:
void Undo();
void Fix();
void Cancel();
protected: protected:
virtual void closeEvent ( QCloseEvent * event ) Q_DECL_OVERRIDE; virtual void closeEvent ( QCloseEvent *event ) Q_DECL_OVERRIDE;
private slots:
void Cancel();
private: private:
Q_DISABLE_COPY(DialogUndo) Q_DISABLE_COPY(DialogUndo)
Ui::DialogUndo *ui; Ui::DialogUndo *ui;