From d2862b9e503b8680fa3e0231b085e161d7b3a18e Mon Sep 17 00:00:00 2001 From: Karl Robillard Date: Sun, 29 Dec 2019 13:18:43 -0500 Subject: [PATCH 1/4] docs/builds.rst: Add build commands for Fedora 30. --- docs/builds.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/builds.rst b/docs/builds.rst index 578d2879..cead9ba8 100644 --- a/docs/builds.rst +++ b/docs/builds.rst @@ -67,3 +67,14 @@ Here is the snapshot of the command line of one build, you may use different def $ qmake -qt=5 -makefile $ make $ ./dust3d + +* Fedora + +.. code-block:: sh + + $ sudo dnf install qt5-qtbase-devel CGAL-devel + $ git clone https://github.com/huxingyi/dust3d.git + $ cd dust3d + $ qmake-qt5 -makefile + $ make + $ ./dust3d From d02331d1e7f39687a1002fa29d8f692d9ba7ba32 Mon Sep 17 00:00:00 2001 From: Karl Robillard Date: Sun, 29 Dec 2019 13:40:58 -0500 Subject: [PATCH 2/4] documentwindow: Add Quit menu item. --- src/documentwindow.cpp | 4 ++++ src/documentwindow.h | 1 + 2 files changed, 5 insertions(+) diff --git a/src/documentwindow.cpp b/src/documentwindow.cpp index 0c3ca330..f6166e6c 100644 --- a/src/documentwindow.cpp +++ b/src/documentwindow.cpp @@ -506,6 +506,10 @@ DocumentWindow::DocumentWindow() : m_fileMenu->addSeparator(); + m_quitAction = m_fileMenu->addAction(tr("&Quit"), + this, &DocumentWindow::close, + QKeySequence::Quit); + connect(m_fileMenu, &QMenu::aboutToShow, [=]() { m_exportAsObjAction->setEnabled(m_graphicsWidget->hasItems()); //m_exportAsObjPlusMaterialsAction->setEnabled(m_graphicsWidget->hasItems()); diff --git a/src/documentwindow.h b/src/documentwindow.h index 6073f4a6..4c051aab 100644 --- a/src/documentwindow.h +++ b/src/documentwindow.h @@ -118,6 +118,7 @@ private: QAction *m_showPreferencesAction; QMenu *m_exportMenu; QAction *m_changeTurnaroundAction; + QAction *m_quitAction; QAction *m_exportAsObjAction; QAction *m_exportAsObjPlusMaterialsAction; From f60bf65837af75429debd331438e21294c5d82eb Mon Sep 17 00:00:00 2001 From: Karl Robillard Date: Sun, 29 Dec 2019 14:00:29 -0500 Subject: [PATCH 3/4] dust3d.pro: Put object & moc files in their own directories to cleanup build. --- dust3d.pro | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dust3d.pro b/dust3d.pro index f1308e95..a08a0418 100644 --- a/dust3d.pro +++ b/dust3d.pro @@ -6,6 +6,9 @@ RESOURCES += resources.qrc LANGUAGES = zh_CN +OBJECTS_DIR=obj +MOC_DIR=moc + ############## Generate .qm from .ts ####################### # parameters: var, prepend, append From fc85ded3239cc974273193643821f6436c55f16c Mon Sep 17 00:00:00 2001 From: Karl Robillard Date: Sun, 29 Dec 2019 14:35:53 -0500 Subject: [PATCH 4/4] Save documentWindowSize in settings to preserve window size between runs. --- src/documentwindow.cpp | 38 +++++++++++++++++++++++++------------- src/preferences.cpp | 10 ++++++++++ src/preferences.h | 3 +++ 3 files changed, 38 insertions(+), 13 deletions(-) diff --git a/src/documentwindow.cpp b/src/documentwindow.cpp index f6166e6c..489c4cf5 100644 --- a/src/documentwindow.cpp +++ b/src/documentwindow.cpp @@ -1178,26 +1178,38 @@ DocumentWindow *DocumentWindow::createDocumentWindow() { DocumentWindow *documentWindow = new DocumentWindow(); documentWindow->setAttribute(Qt::WA_DeleteOnClose); - documentWindow->showMaximized(); + + QSize size = Preferences::instance().documentWindowSize(); + if (size.isValid()) { + documentWindow->resize(size); + documentWindow->show(); + } else { + documentWindow->showMaximized(); + } + return documentWindow; } void DocumentWindow::closeEvent(QCloseEvent *event) { - if (m_documentSaved) { - event->accept(); - return; + if (! m_documentSaved) { + QMessageBox::StandardButton answer = QMessageBox::question(this, + APP_NAME, + tr("Do you really want to close while there are unsaved changes?"), + QMessageBox::Yes | QMessageBox::No, + QMessageBox::No); + if (answer == QMessageBox::No) { + event->ignore(); + return; + } } - QMessageBox::StandardButton answer = QMessageBox::question(this, - APP_NAME, - tr("Do you really want to close while there are unsaved changes?"), - QMessageBox::Yes | QMessageBox::No, - QMessageBox::No); - if (answer == QMessageBox::Yes) - event->accept(); - else - event->ignore(); + QSize saveSize; + if (!isMaximized()) + saveSize = size(); + Preferences::instance().setDocumentWindowSize(saveSize); + + event->accept(); } void DocumentWindow::setCurrentFilename(const QString &filename) diff --git a/src/preferences.cpp b/src/preferences.cpp index d67b93f4..ed007771 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -81,6 +81,16 @@ void Preferences::setFlatShading(bool flatShading) emit flatShadingChanged(); } +QSize Preferences::documentWindowSize() const +{ + return m_settings.value("documentWindowSize", QSize()).toSize(); +} + +void Preferences::setDocumentWindowSize(const QSize& size) +{ + m_settings.setValue("documentWindowSize", size); +} + void Preferences::reset() { m_settings.clear(); diff --git a/src/preferences.h b/src/preferences.h index 4d5120c5..d558e9e3 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -2,6 +2,7 @@ #define PREFERENCES_H #include #include +#include #include "combinemode.h" class Preferences : public QObject @@ -13,6 +14,8 @@ public: CombineMode componentCombineMode() const; const QColor &partColor() const; bool flatShading() const; + QSize documentWindowSize() const; + void setDocumentWindowSize(const QSize&); signals: void componentCombineModeChanged(); void partColorChanged();