diff --git a/openscad.pro b/openscad.pro index 92f1b720..d9b99c73 100644 --- a/openscad.pro +++ b/openscad.pro @@ -556,7 +556,3 @@ INSTALLS += icons man.path = $$PREFIX/share/man/man1 man.extra = cp -f doc/openscad.1 \"\$(INSTALL_ROOT)$${man.path}/$${FULLNAME}.1\" INSTALLS += man - -CONFIG(winconsole) { - include(winconsole.pri) -} diff --git a/scripts/release-common.sh b/scripts/release-common.sh index f9faf8a6..709d508a 100755 --- a/scripts/release-common.sh +++ b/scripts/release-common.sh @@ -254,8 +254,8 @@ case $OS in echo "cant find $TARGET/openscad.exe. build failed. stopping." exit fi - # make console pipe-able openscad.com - see winconsole.pri for info - qmake CONFIG+=winconsole ../openscad.pro + # make console pipe-able openscad.com - see winconsole.pro for info + qmake ../winconsole.pro make if [ ! -e $TARGET/openscad.com ]; then echo "cant find $TARGET/openscad.com. build failed. stopping." diff --git a/src/MainWindow.h b/src/MainWindow.h index 5d415734..50d4bb6d 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -71,6 +71,7 @@ public: QAction *actionRecentFile[UIUtils::maxRecentFiles]; QMap knownFileExtensions; + QLabel *versionLabel; QWidget *editorDockTitleWidget; QWidget *consoleDockTitleWidget; @@ -116,6 +117,7 @@ private: void show_examples(); void setDockWidgetTitle(QDockWidget *dockWidget, QString prefix, bool topLevel); void addKeyboardShortCut(const QList &actions); + void updateStatusBar(class ProgressWidget *progressWidget); EditorInterface *editor; diff --git a/src/mainwin.cc b/src/mainwin.cc index 620d9fec..8841349a 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -125,8 +125,6 @@ QSet *MainWindow::getWindows() // Global application state unsigned int GuiLocker::gui_locked = 0; -static std::string helptitle = openscad_version + "\nhttp://www.openscad.org\n\n"; - static char copyrighttext[] = "Copyright (C) 2009-2014 The OpenSCAD Developers\n" "\n" @@ -183,8 +181,8 @@ MainWindow::MainWindow(const QString &filename) this->consoleDock->setConfigKey("view/hideConsole"); this->consoleDock->setAction(this->viewActionHideConsole); - QLabel *versionLabel = new QLabel(openscad_version.c_str()); - this->statusbar->addPermanentWidget(versionLabel); + this->versionLabel = NULL; // must be initialized before calling updateStatusBar() + updateStatusBar(NULL); QSettings settings; editortype = settings.value("editor/editortype").toString(); @@ -404,6 +402,7 @@ MainWindow::MainWindow(const QString &filename) setCurrentOutput(); + std::string helptitle = openscad_version + "\nhttp://www.openscad.org\n\n"; PRINT(helptitle); PRINT(copyrighttext); PRINT(""); @@ -684,7 +683,7 @@ MainWindow::~MainWindow() void MainWindow::showProgress() { - this->statusBar()->addPermanentWidget(qobject_cast(sender())); + updateStatusBar(qobject_cast(sender())); } void MainWindow::report_func(const class AbstractNode*, void *vp, int mark) @@ -1057,9 +1056,7 @@ void MainWindow::compileCSG(bool procevents) PRINT("CSG generation cancelled."); } progress_report_fin(); - this->statusBar()->removeWidget(this->progresswidget); - delete this->progresswidget; - this->progresswidget = NULL; + updateStatusBar(NULL); PRINT("Compiling design (CSG Products normalization)..."); if (procevents) QApplication::processEvents(); @@ -1797,15 +1794,47 @@ void MainWindow::actionRenderDone(shared_ptr root_geom) PRINT("WARNING: No top level geometry to render"); } - this->statusBar()->removeWidget(this->progresswidget); - delete this->progresswidget; - this->progresswidget = NULL; + updateStatusBar(NULL); + this->contentschanged = false; compileEnded(); } #endif /* ENABLE_CGAL */ +/** + * Switch version label and progress widget. When switching to the progress + * widget, the new instance is passed by the caller. + * In case of resetting back to the version label, NULL will be passed and + * multiple calls can happen. So this method must guard against adding the + * version label multiple times. + * + * @param progressWidget a pointer to the progress widget to show or NULL in + * case the display should switch back to the version label. + */ +void MainWindow::updateStatusBar(ProgressWidget *progressWidget) +{ + QStatusBar *sb = this->statusBar(); + if (progressWidget == NULL) { + if (this->progresswidget != NULL) { + sb->removeWidget(this->progresswidget); + delete this->progresswidget; + this->progresswidget = NULL; + } + if (versionLabel == NULL) { + versionLabel = new QLabel(openscad_version.c_str()); + sb->addPermanentWidget(this->versionLabel); + } + } else { + if (this->versionLabel != NULL) { + sb->removeWidget(this->versionLabel); + delete this->versionLabel; + this->versionLabel = NULL; + } + sb->addPermanentWidget(progressWidget); + } +} + void MainWindow::actionDisplayAST() { setCurrentOutput(); @@ -2400,7 +2429,6 @@ void MainWindow::helpAbout() qApp->setWindowIcon(QApplication::windowIcon()); AboutDialog *dialog = new AboutDialog(this); dialog->exec(); - //QMessageBox::information(this, "About OpenSCAD", QString(helptitle) + QString(copyrighttext)); } void MainWindow::helpHomepage() diff --git a/winconsole.pri b/winconsole.pri deleted file mode 100644 index a3991ae7..00000000 --- a/winconsole.pri +++ /dev/null @@ -1,28 +0,0 @@ -# Windows console issues workaround stub. -# -# Usage: put at the end of .pro file, then run qmake CONFIG+=winconsole -# -# This attempts to solve the problem of piping OpenSCAD under windows -# command line (GUI mode programs in Windows dont allow this). We use -# the 'devenv' solution, which means building two binaries: -# openscad.exe, and openscad.com, the latter being a wrapper for the -# former. See src/winconsole.c for more details. -# -# Qmake doesn't like building two binaries in the same directory so we -# depend on release-common.sh to call qmake twice and package the file properly - -CONFIG(winconsole) { - TEMPLATE = app - TARGET = openscad_winconsole - FORMS = - HEADERS = - FLEXSOURCES = - BISONSOURCES = - RESOURCES = - SOURCES = src/winconsole.c - CONFIG += console # sets IMAGE_SUBSYSTEM_WINDOWS_CUI in binary - LIBS -= $$LIBS - RC_FILE -= $$RC_FILE - QMAKE_POST_LINK = cd $(DESTDIR) && mv openscad_winconsole.exe openscad.com -} - diff --git a/winconsole.pro b/winconsole.pro new file mode 100644 index 00000000..11078f36 --- /dev/null +++ b/winconsole.pro @@ -0,0 +1,23 @@ +# Windows console issues workaround stub. +# +# This attempts to solve the problem of piping OpenSCAD under windows +# command line (GUI mode programs in Windows dont allow this). We use +# the 'devenv' solution, which means building two binaries: +# openscad.exe, and openscad.com, the latter being a wrapper for the +# former. See src/winconsole.c for more details. +# +# Qmake doesn't like building two binaries in the same directory so we +# depend on release-common.sh to call qmake twice and package the file +# properly + +TEMPLATE = app +TARGET = openscad_winconsole +FORMS = +HEADERS = +FLEXSOURCES = +BISONSOURCES = +RESOURCES = +SOURCES = src/winconsole.c +CONFIG -= qt +CONFIG += console # sets IMAGE_SUBSYSTEM_WINDOWS_CUI in binary +QMAKE_POST_LINK = cd $(DESTDIR) && mv openscad_winconsole.exe openscad.com