# HG changeset patch # User Teemu Piippo # Date 1440895923 -10800 # Node ID 429c7ed3cc5475b6fc1e20760c2a5402dead363f # Parent 2af18ba2665f766f3aa24825088a3d4dd0d05447 Refactor OpenProgressDialog out of dialogs.cpp diff -r 2af18ba2665f -r 429c7ed3cc54 CMakeLists.txt --- 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 diff -r 2af18ba2665f -r 429c7ed3cc54 src/dialogs.cpp --- 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) diff -r 2af18ba2665f -r 429c7ed3cc54 src/dialogs.h --- 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 diff -r 2af18ba2665f -r 429c7ed3cc54 src/dialogs/openprogressdialog.cpp --- /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 . + */ + +#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 diff -r 2af18ba2665f -r 429c7ed3cc54 src/dialogs/openprogressdialog.h --- /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 . + */ + +#pragma once +#include + +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 diff -r 2af18ba2665f -r 429c7ed3cc54 src/dialogs/openprogressdialog.ui --- /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 @@ + + + OpenProgressUI + + + + 0 + 0 + 400 + 89 + + + + Opening + + + + + + [[ Progress text ]] + + + + + + + 24 + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel + + + + + + + + + buttonBox + accepted() + OpenProgressUI + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + OpenProgressUI + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff -r 2af18ba2665f -r 429c7ed3cc54 src/ldDocument.cpp --- 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. diff -r 2af18ba2665f -r 429c7ed3cc54 ui/openprogress.ui --- 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 @@ - - - OpenProgressUI - - - - 0 - 0 - 400 - 89 - - - - Opening - - - - - - [[ Progress text ]] - - - - - - - 24 - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel - - - - - - - - - buttonBox - accepted() - OpenProgressUI - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - OpenProgressUI - reject() - - - 316 - 260 - - - 286 - 274 - - - - -