| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- /**
- * Copyright (c) 2011-2018 by Andrew Mustun. All rights reserved.
- *
- * This file is part of the QCAD project.
- *
- * QCAD 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.
- *
- * QCAD 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 QCAD.
- */
- include("scripts/WidgetFactory.js");
- include("scripts/Widgets/StatusBar/StatusBar.js");
- function ProgressBar() {
- ProgressBar.progressBar = undefined;
- ProgressBar.text = "";
- }
- /**
- * Progress bar widget in status bar.
- */
- ProgressBar.postInit = function(basePath) {
- var widget = WidgetFactory.createWidget(basePath, "ProgressBar.ui");
- StatusBar.addWidget(widget, 1000, RSettings.getBoolValue("StatusBar/ProgressDisplay", true));
- ProgressBar.prepare();
- if (!isNull(ProgressBar.progressBar)) {
- ProgressBar.progressBar.visible = false;
- }
- var appWin = EAction.getMainWindow();
- appWin.progressText.connect(this, this.setProgressText);
- appWin.progress.connect(this, this.progress);
- appWin.progressEnd.connect(this, this.progressEnd);
- };
- ProgressBar.prepare = function() {
- var appWin = EAction.getMainWindow();
- var statusBar = appWin.findChild("StatusBar");
- ProgressBar.progressLabel = statusBar.findChild("ProgressText");
- ProgressBar.progressBar = statusBar.findChild("ProgressBar");
- ProgressBar.progressDialog = appWin.findChild("ProgressDialog");
- ProgressBar.dialogMode = RSettings.getBoolValue("Appearance/ShowProgressDialog", false);
- };
- ProgressBar.setProgressText = function(text) {
- ProgressBar.prepare();
- if (ProgressBar.dialogMode===true) {
- if (!isNull(ProgressBar.progressDialog)) {
- ProgressBar.progressDialog.labelText = text;
- }
- else {
- ProgressBar.text = text;
- }
- }
- else {
- if (!isNull(ProgressBar.progressLabel)) {
- ProgressBar.progressLabel.text = text;
- }
- }
- };
- ProgressBar.progress = function(value) {
- ProgressBar.prepare();
- if (ProgressBar.dialogMode===true) {
- if (isNull(ProgressBar.progressDialog)) {
- ProgressBar.progressDialog = new QProgressDialog(ProgressBar.text, "", 0, 100, EAction.getMainWindow());
- ProgressBar.progressDialog.objectName = "ProgressDialog";
- ProgressBar.progressDialog.windowModality = Qt.ApplicationModal;
- ProgressBar.progressDialog.minimumDuration = 500;
- ProgressBar.progressDialog.setCancelButton(0);
- }
- ProgressBar.progressDialog.value = value;
- // don't process events if modal dialog does not block user from doing something:
- if (ProgressBar.progressDialog.visible) {
- QCoreApplication.processEvents();
- }
- }
- else {
- if (!isNull(ProgressBar.progressBar)) {
- if (!RSettings.getOriginalArguments().contains("-no-show")) {
- ProgressBar.progressBar.visible = true;
- }
- ProgressBar.progressBar.value = value;
- }
- }
- var appWin = EAction.getMainWindow();
- if (appWin.enabled) {
- appWin.disable();
- }
- };
- ProgressBar.progressEnd = function() {
- ProgressBar.prepare();
- if (ProgressBar.dialogMode===true) {
- if (!isNull(ProgressBar.progressDialog)) {
- ProgressBar.progressDialog.setValue(100);
- }
- }
- else {
- if (!isNull(ProgressBar.progressBar)) {
- ProgressBar.progressBar.reset();
- ProgressBar.setProgressText("");
- ProgressBar.progressBar.visible = false;
- }
- }
- var appWin = EAction.getMainWindow();
- if (!appWin.enabled) {
- appWin.enable();
- }
- };
|