Sun, 30 Aug 2015 03:52:03 +0300
Refactor OpenProgressDialog out of dialogs.cpp
CMakeLists.txt | file | annotate | diff | comparison | revisions | |
src/dialogs.cpp | file | annotate | diff | comparison | revisions | |
src/dialogs.h | file | annotate | diff | comparison | revisions | |
src/dialogs/openprogressdialog.cpp | file | annotate | diff | comparison | revisions | |
src/dialogs/openprogressdialog.h | file | annotate | diff | comparison | revisions | |
src/dialogs/openprogressdialog.ui | file | annotate | diff | comparison | revisions | |
src/ldDocument.cpp | file | annotate | diff | comparison | revisions | |
ui/openprogress.ui | file | annotate | diff | comparison | revisions |
--- a/CMakeLists.txt Sun Aug 30 03:04:39 2015 +0300 +++ b/CMakeLists.txt Sun Aug 30 03:52:03 2015 +0300 @@ -63,6 +63,7 @@ src/dialogs/colorselector.cpp src/dialogs/ldrawpathdialog.cpp src/dialogs/newpartdialog.cpp + src/dialogs/openprogressdialog.cpp src/editmodes/abstractEditMode.cpp src/editmodes/circleMode.cpp src/editmodes/drawMode.cpp @@ -101,6 +102,7 @@ src/dialogs/colorselector.h src/dialogs/ldrawpathdialog.h src/dialogs/newpartdialog.h + src/dialogs/openprogressdialog.h src/editmodes/abstractEditMode.h src/editmodes/circleMode.h src/editmodes/drawMode.h @@ -125,7 +127,6 @@ ui/isecalc.ui ui/ldforge.ui ui/makeprim.ui - ui/openprogress.ui ui/overlay.ui ui/rectifier.ui ui/replcoords.ui @@ -134,6 +135,7 @@ src/dialogs/colorselector.ui src/dialogs/ldrawpathdialog.ui src/dialogs/newpartdialog.ui + src/dialogs/openprogressdialog.ui ) add_custom_target (codegeneration ALL
--- a/src/dialogs.cpp Sun Aug 30 03:04:39 2015 +0300 +++ b/src/dialogs.cpp Sun Aug 30 03:52:03 2015 +0300 @@ -38,7 +38,6 @@ #include "ldDocument.h" #include "dialogs.h" #include "ui_overlay.h" -#include "ui_openprogress.h" #include "ui_extprogpath.h" #include "ui_about.h" #include "ui_bombbox.h" @@ -159,49 +158,6 @@ // ============================================================================= // ============================================================================= -OpenProgressDialog::OpenProgressDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) -{ - ui = new Ui_OpenProgressUI; - ui->setupUi (this); - ui->progressText->setText ("Parsing..."); - setNumLines (0); - m_progress = 0; -} - -// ============================================================================= -// ============================================================================= -OpenProgressDialog::~OpenProgressDialog() -{ - delete ui; -} - -// ============================================================================= -// ============================================================================= -void OpenProgressDialog::setNumLines (int const& a) -{ - m_numLines = a; - ui->progressBar->setRange (0, numLines()); - updateValues(); -} - -// ============================================================================= -// ============================================================================= -void OpenProgressDialog::updateValues() -{ - ui->progressText->setText (format ("Parsing... %1 / %2", progress(), numLines())); - ui->progressBar->setValue (progress()); -} - -// ============================================================================= -// ============================================================================= -void OpenProgressDialog::updateProgress (int progress) -{ - setProgress (progress); - updateValues(); -} - -// ============================================================================= -// ============================================================================= ExtProgPathPrompt::ExtProgPathPrompt (QString progName, QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f), ui (new Ui_ExtProgPath)
--- a/src/dialogs.h Sun Aug 30 03:04:39 2015 +0300 +++ b/src/dialogs.h Sun Aug 30 03:52:03 2015 +0300 @@ -65,26 +65,6 @@ }; // ============================================================================= -class OpenProgressDialog : public QDialog -{ - Q_OBJECT - PROPERTY (public, int, progress, setProgress, STOCK_WRITE) - PROPERTY (public, int, numLines, setNumLines, CUSTOM_WRITE) - -public: - explicit OpenProgressDialog (QWidget* parent = null, Qt::WindowFlags f = 0); - virtual ~OpenProgressDialog(); - -public slots: - void updateProgress (int progress); - -private: - Ui_OpenProgressUI* ui; - - void updateValues(); -}; - -// ============================================================================= class ExtProgPathPrompt : public QDialog { Q_OBJECT
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/dialogs/openprogressdialog.cpp Sun Aug 30 03:52:03 2015 +0300 @@ -0,0 +1,55 @@ +/* + * LDForge: LDraw parts authoring CAD + * Copyright (C) 2013, 2014 Teemu Piippo + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "openprogressdialog.h" +#include "ui_openprogress.h" +#include "../main.h" + +OpenProgressDialog::OpenProgressDialog (QWidget* parent, Qt::WindowFlags f) : + QDialog (parent, f), + ui (*new Ui_OpenProgressUI), + m_progress (0), + m_numLines (0) +{ + ui.setupUi (this); + ui.progressText->setText ("Parsing..."); +} + +OpenProgressDialog::~OpenProgressDialog() +{ + delete &ui; +} + +void OpenProgressDialog::setNumLines (int a) +{ + m_numLines = a; + ui.progressBar->setRange (0, numLines()); + updateValues(); +} + +void OpenProgressDialog::updateValues() +{ + ui.progressText->setText (format ("Parsing... %1 / %2", progress(), numLines())); + ui.progressBar->setValue (progress()); +} + +void OpenProgressDialog::setProgress (int progress) +{ + m_progress = progress; + updateValues(); +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/dialogs/openprogressdialog.h Sun Aug 30 03:52:03 2015 +0300 @@ -0,0 +1,43 @@ +/* + * LDForge: LDraw parts authoring CAD + * Copyright (C) 2013, 2014 Teemu Piippo + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#pragma once +#include <QDialog> + +class OpenProgressDialog : public QDialog +{ + Q_OBJECT + +public: + OpenProgressDialog (QWidget* parent = nullptr, Qt::WindowFlags f = 0); + virtual ~OpenProgressDialog(); + + int progress() const { return m_progress; } + int numLines() const { return m_numLines; } + void setNumLines (int value); + +public slots: + void setProgress (int progress); + +private: + class Ui_OpenProgressUI& ui; + int m_progress; + int m_numLines; + + void updateValues(); +}; \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/dialogs/openprogressdialog.ui Sun Aug 30 03:52:03 2015 +0300 @@ -0,0 +1,78 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>OpenProgressUI</class> + <widget class="QDialog" name="OpenProgressUI"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>89</height> + </rect> + </property> + <property name="windowTitle"> + <string>Opening</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="progressText"> + <property name="text"> + <string>[[ Progress text ]]</string> + </property> + </widget> + </item> + <item> + <widget class="QProgressBar" name="progressBar"> + <property name="value"> + <number>24</number> + </property> + </widget> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>OpenProgressUI</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>OpenProgressUI</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui>
--- a/src/ldDocument.cpp Sun Aug 30 03:04:39 2015 +0300 +++ b/src/ldDocument.cpp Sun Aug 30 03:52:03 2015 +0300 @@ -31,7 +31,7 @@ #include "glCompiler.h" #include "partDownloader.h" #include "ldpaths.h" -#include "dialogs.h" +#include "dialogs/openprogressdialog.h" CFGENTRY (List, RecentFiles, {}) CFGENTRY (Bool, TryDownloadMissingFiles, false) @@ -349,8 +349,8 @@ setProgress (i); // If we have a dialog pointer, update the progress now - if (isOnForeground()) - dlg->updateProgress (i); + if (dlg) + dlg->setProgress (i); } // If we're done now, tell the environment we're done and stop.
--- a/ui/openprogress.ui Sun Aug 30 03:04:39 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>OpenProgressUI</class> - <widget class="QDialog" name="OpenProgressUI"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>400</width> - <height>89</height> - </rect> - </property> - <property name="windowTitle"> - <string>Opening</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QLabel" name="progressText"> - <property name="text"> - <string>[[ Progress text ]]</string> - </property> - </widget> - </item> - <item> - <widget class="QProgressBar" name="progressBar"> - <property name="value"> - <number>24</number> - </property> - </widget> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel</set> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>OpenProgressUI</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>248</x> - <y>254</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>OpenProgressUI</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>316</x> - <y>260</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - </connections> -</ui>