11/*
22 * Copyright (C) 2006-2018 by Artur Kozioł, artkoz78@gmail.com
3- * Copyright (C) 2023 Nick Egorrov, nicegorov@yandex.ru
3+ * Copyright (C) 2023-2025 Nick Egorrov, nicegorov@yandex.ru
44 *
55 * This file is part of GCodeWorkShop.
66 *
1818 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1919 */
2020
21+ #include < functional> // for function
22+
2123#include < QDialog> // for QDialog, QDialog::Accepted
2224#include < QString> // for QString
2325#include < QWidget> // for QWidget
2426
27+ #include < ui/longjobhelper.h> // for LongJobHelper, LongJobHelper::CANCEL
28+
2529#include " addons-swapaxes.h"
2630#include " swapaxesdialog.h" // for SwapAxesDialog
2731#include " swapaxesoptions.h" // for SwapAxesOptions
2832#include " utils-swapaxes.h" // for swapAxes, COMMENT_ID_UNKNOWN
2933
3034
31- int Addons::doSwapAxes (QWidget* parent, QSettings* settings, QPlainTextEdit* textEdit )
35+ bool Addons::doSwapAxes (QWidget* parent, QSettings* settings, QString& text )
3236{
33- int result = 0 ;
3437 QString key = " SwapAxesDialog" ;
3538 SwapAxesDialog* dlg;
3639 dlg = parent->findChild <SwapAxesDialog*>(key);
@@ -41,10 +44,19 @@ int Addons::doSwapAxes(QWidget* parent, QSettings* settings, QPlainTextEdit* tex
4144 dlg->loadSettings (SwapAxesOptions ());
4245 }
4346
44- if (dlg->exec () = = QDialog::Accepted) {
45- Utils::swapAxes (textEdit, false , 40000 , COMMENT_ID_UNKNOWN, dlg-> options ()) ;
47+ if (dlg->exec () ! = QDialog::Accepted) {
48+ return false ;
4649 }
4750
51+
52+ LongJobHelper helper{parent};
53+ helper.begin (text.length (), QCoreApplication::translate (" Addons::Actions" , " Axis exchange" ), 20 );
54+
55+ bool changed = Utils::swapAxes (text, dlg->options (), [&helper](int pos) -> bool {
56+ return helper.check (pos) == LongJobHelper::CANCEL;
57+ });
58+
59+ helper.end ();
4860 dlg->deleteLater ();
49- return result ;
61+ return changed ;
5062}
0 commit comments