Skip to content

Commit 7a1fc47

Browse files
committed
v1.12, Bug #14545 Add percentage to scripting form, Bug #14547 Remember last directory for scripting form, Bug #15702 Update sever address to new domain, Bug #15704 Add text and background colour selection options, Bug #15705 Add scrolling support to automation window, Bug #15706 Update links and add new devices, Bug #15701 Fix edit externally opening the wrong file, Bug #15703 Fix bug whereby pasting \r\n could duplicate \n characters
1 parent a526edb commit 7a1fc47

7 files changed

Lines changed: 328 additions & 95 deletions

File tree

UwxMainWindow.cpp

Lines changed: 209 additions & 54 deletions
Large diffs are not rendered by default.

UwxMainWindow.h

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/******************************************************************************
2-
** Copyright (C) 2015-2018 Laird
2+
** Copyright (C) 2015-2020 Laird Connectivity
33
**
44
** Project: UwTerminalX
55
**
@@ -40,6 +40,7 @@
4040
#include <QStringList>
4141
#include <QMessageBox>
4242
#include <QFile>
43+
#include <QColorDialog>
4344
#include <QKeyEvent>
4445
#include <QFontDialog>
4546
#include <QSettings>
@@ -113,8 +114,9 @@
113114
/******************************************************************************/
114115
// Constants
115116
/******************************************************************************/
116-
const QString OldServerHost = "uwterminalx.no-ip.org"; //Old hostname/IP of online xcompile server which is set to be removed
117-
const QString ServerHost = "uwterminalx.lairdtech.com"; //Hostname/IP of online xcompile server
117+
const QString OldOldServerHost = "uwterminalx.no-ip.org"; //Very old hostname/IP of online xcompile server which is set to be removed
118+
const QString OldServerHost = "uwterminalx.lairdtech.com"; //Old hostname/IP of online xcompile server which is set to be removed
119+
const QString ServerHost = "uwterminalx.lairdconnect.com"; //Hostname/IP of online xcompile server
118120
//Constants for various file download functions
119121
const qint8 MODE_COMPILE = 1;
120122
const qint8 MODE_COMPILE_LOAD = 2;
@@ -130,7 +132,7 @@ const qint8 MODE_UPDATE_ERROR_CODE = 16;
130132
const qint8 MODE_CHECK_FIRMWARE_VERSIONS = 17;
131133
const qint8 MODE_CHECK_FIRMWARE_SUPPORT = 18;
132134
//Constants for version and functions
133-
const QString UwVersion = "1.11"; //Version string
135+
const QString UwVersion = "1.12"; //Version string
134136
//Constants for timeouts and streaming
135137
const qint16 FileReadBlock = 512; //Number of bytes to read per block when streaming files
136138
const qint16 StreamProgress = 10000; //Number of bytes between streaming progress updates
@@ -177,7 +179,8 @@ const QString URLLinuxNonRootSetup = "https://github.com/LairdCP/UwTerminalX/wik
177179
const QString WebProtocol = "http";
178180
#endif
179181
const qint8 FilenameIndexApplication = 0;
180-
const qint8 FilenameIndexOthers = 1;
182+
const qint8 FilenameIndexScripting = 1;
183+
const qint8 FilenameIndexOthers = 2;
181184
//Constants for right click menu options
182185
const qint8 MenuActionXCompile = 1;
183186
const qint8 MenuActionXCompileLoad = 2;
@@ -198,17 +201,19 @@ const qint8 MenuActionClearFilesystem = 16;
198201
const qint8 MenuActionMultiDataFile = 17;
199202
const qint8 MenuActionStreamFile = 18;
200203
const qint8 MenuActionFont = 19;
201-
const qint8 MenuActionRun2 = 20;
202-
const qint8 MenuActionAutomation = 21;
203-
const qint8 MenuActionScripting = 22;
204-
const qint8 MenuActionBatch = 23;
205-
const qint8 MenuActionClearModule = 24;
206-
const qint8 MenuActionClearDisplay = 25;
207-
const qint8 MenuActionClearRxTx = 26;
208-
const qint8 MenuActionCopy = 27;
209-
const qint8 MenuActionCopyAll = 28;
210-
const qint8 MenuActionPaste = 29;
211-
const qint8 MenuActionSelectAll = 30;
204+
const qint8 MenuActionTextColour = 20;
205+
const qint8 MenuActionBackground = 21;
206+
const qint8 MenuActionRun2 = 22;
207+
const qint8 MenuActionAutomation = 23;
208+
const qint8 MenuActionScripting = 24;
209+
const qint8 MenuActionBatch = 25;
210+
const qint8 MenuActionClearModule = 26;
211+
const qint8 MenuActionClearDisplay = 27;
212+
const qint8 MenuActionClearRxTx = 28;
213+
const qint8 MenuActionCopy = 29;
214+
const qint8 MenuActionCopyAll = 30;
215+
const qint8 MenuActionPaste = 31;
216+
const qint8 MenuActionSelectAll = 32;
212217
//Constants for balloon (notification area) icon options
213218
const qint8 BalloonActionShow = 1;
214219
const qint8 BalloonActionExit = 2;
@@ -716,6 +721,10 @@ private slots:
716721
on_check_EnableModuleFirmwareCheck_stateChanged(
717722
int
718723
);
724+
void
725+
ScriptingFileSelected(
726+
const QString *strFilepath
727+
);
719728

720729
private:
721730
Ui::MainWindow *ui;
@@ -855,6 +864,7 @@ private slots:
855864
QMenu *gpSMenu1; //Submenu 1
856865
QMenu *gpSMenu2; //Submenu 2
857866
QMenu *gpSMenu3; //Submenu 3
867+
QMenu *gpSMenu4; //Submenu 4
858868
QMenu *gpBalloonMenu; //Balloon menu
859869
#if SKIPSPEEDTEST != 1
860870
QMenu *gpSpeedMenu; //Speed testing menu
@@ -884,7 +894,7 @@ private slots:
884894
QNetworkReply *gnmrReply; //Network reply
885895
QString gstrDeviceID; //What the server compiler ID is
886896
bool gbFileOpened; //True when a file on the module has been opened
887-
QString gstrLastFilename[2]; //Holds the filenames of the last selected files
897+
QString gstrLastFilename[(FilenameIndexOthers+1)]; //Holds the filenames of the last selected files
888898
QString gstrResolvedServer; //Holds the resolved hostname of the XCompile server
889899
bool gbEditFileModified; //True if the file in the editor pane has been modified, otherwise false
890900
int giEditFileType; //Type of file currently open in the editor

UwxMainWindow.ui

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3308,7 +3308,7 @@ As more error codes get added, newer releases of the error code lookup file will
33083308
</font>
33093309
</property>
33103310
<property name="text">
3311-
<string>UwTerminalX is an open source application developed by Laird, the source code is available for download/modification from the Github project page linked below.
3311+
<string>UwTerminalX is an open source application developed by Laird Connectivity, the source code is available for download/modification from the Github project page linked below.
33123312

33133313
You can also use the button below to check if there is a newer version of UwTerminalX available.</string>
33143314
</property>
@@ -3406,7 +3406,7 @@ You can also use the button below to check if there is a newer version of UwTerm
34063406
</font>
34073407
</property>
34083408
<property name="text">
3409-
<string>Laird provides sample applications for its Bluetooth modules, all of which is freely available on Github which can be opened below. Additional information can also be found on the Laird Bluetooth modules website.</string>
3409+
<string>Laird Connectivity provides sample applications for its Bluetooth modules, all of which is freely available on Github which can be opened below. Additional information can also be found on the Laird Connectivity modules website.</string>
34103410
</property>
34113411
<property name="alignment">
34123412
<set>Qt::AlignJustify|Qt::AlignVCenter</set>
@@ -3439,6 +3439,16 @@ You can also use the button below to check if there is a newer version of UwTerm
34393439
<string>BL652</string>
34403440
</property>
34413441
</item>
3442+
<item>
3443+
<property name="text">
3444+
<string>Pinnacle 100 OOB Demo</string>
3445+
</property>
3446+
</item>
3447+
<item>
3448+
<property name="text">
3449+
<string>Bluegrass demo site</string>
3450+
</property>
3451+
</item>
34423452
<item>
34433453
<property name="text">
34443454
<string>RM186/RM191</string>
@@ -3461,12 +3471,12 @@ You can also use the button below to check if there is a newer version of UwTerm
34613471
</item>
34623472
<item>
34633473
<property name="text">
3464-
<string>Laird Bluetooth Modules</string>
3474+
<string>Laird Connectivity Modules</string>
34653475
</property>
34663476
</item>
34673477
<item>
34683478
<property name="text">
3469-
<string>Laird EWS Support</string>
3479+
<string>UwFlashX</string>
34703480
</property>
34713481
</item>
34723482
</widget>
@@ -3495,7 +3505,7 @@ You can also use the button below to check if there is a newer version of UwTerm
34953505
</font>
34963506
</property>
34973507
<property name="text">
3498-
<string>The current firmware version of Laird modules can be retrieved below.</string>
3508+
<string>The current firmware version of Laird Connectivity modules can be retrieved below. UwFlashX is a new cross-platform firmware upgrade utility for Laird Connectivity modules, information can be found by selecting 'UwFlashX' above.</string>
34993509
</property>
35003510
<property name="alignment">
35013511
<set>Qt::AlignJustify|Qt::AlignVCenter</set>
@@ -3524,26 +3534,26 @@ You can also use the button below to check if there is a newer version of UwTerm
35243534
</property>
35253535
<layout class="QVBoxLayout" name="verticalLayout_3">
35263536
<property name="spacing">
3527-
<number>2</number>
3537+
<number>1</number>
35283538
</property>
35293539
<property name="leftMargin">
3530-
<number>2</number>
3540+
<number>1</number>
35313541
</property>
35323542
<property name="topMargin">
3533-
<number>2</number>
3543+
<number>1</number>
35343544
</property>
35353545
<property name="rightMargin">
3536-
<number>2</number>
3546+
<number>1</number>
35373547
</property>
35383548
<property name="bottomMargin">
3539-
<number>2</number>
3549+
<number>1</number>
35403550
</property>
35413551
<item>
35423552
<widget class="QScrollArea" name="scrollArea">
35433553
<property name="minimumSize">
35443554
<size>
35453555
<width>0</width>
3546-
<height>80</height>
3556+
<height>40</height>
35473557
</size>
35483558
</property>
35493559
<property name="maximumSize">
@@ -3566,8 +3576,8 @@ You can also use the button below to check if there is a newer version of UwTerm
35663576
<rect>
35673577
<x>0</x>
35683578
<y>0</y>
3569-
<width>202</width>
3570-
<height>80</height>
3579+
<width>204</width>
3580+
<height>43</height>
35713581
</rect>
35723582
</property>
35733583
<property name="sizePolicy">
@@ -3766,7 +3776,7 @@ check for the latest firmware</string>
37663776
<bool>true</bool>
37673777
</property>
37683778
<property name="plainText">
3769-
<string>This application is provided by Laird without warranty. You are welcome to check our website for the latest version. This version is UTF-8 compliant.
3779+
<string>This application is provided by Laird Connectivity without warranty. You are welcome to check our website for the latest version. This version is UTF-8 compliant.
37703780

37713781
This message is displayed EITHER because &quot;accept&quot; is not specified in the command line OR at least one command line option has been specified with an invalid parameter.
37723782

@@ -3841,7 +3851,7 @@ This function is enabled/disabled in the Automation and Speed Test features by c
38413851
For example: \00 can be used to represent a null character and \4C can be used to represent an 'L' ASCII character.
38423852

38433853

3844-
Copyright © Laird Technologies 2015-2017
3854+
Copyright © Laird Connectivity 2015-2020
38453855
For updates and source code licensed under GPLv3, check https://github.com/LairdCP/UwTerminalX or the 'Update' tab.
38463856
Plus and Minus images obtained from http://www.clker.com
38473857

UwxPopup.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</rect>
1515
</property>
1616
<property name="sizePolicy">
17-
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
17+
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
1818
<horstretch>1</horstretch>
1919
<verstretch>0</verstretch>
2020
</sizepolicy>

UwxScripting.cpp

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,14 @@ UwxScripting::on_btn_Load_clicked(
187187
)
188188
{
189189
//Load buffer from file
190-
QString strLoadFile = QFileDialog::getOpenFileName(this, tr("Open File"), "", "Text files (*.txt)");
190+
QString strLoadFile = QFileDialog::getOpenFileName(this, tr("Open File"), strLastScriptFile, "Text files (*.txt)");
191191

192-
if (strLoadFile.length() > 1)
192+
if (!strLoadFile.isNull() && !strLoadFile.isEmpty())
193193
{
194194
//File was selected
195195
LoadScriptFile(&strLoadFile);
196+
emit UpdateScriptLastDirectory(&strLoadFile);
197+
strLastScriptFile = strLoadFile;
196198
}
197199
}
198200

@@ -314,6 +316,7 @@ UwxScripting::on_btn_Run_clicked(
314316
{
315317
//Compile successful, check if main form is busy
316318
mnRepeats = 0;
319+
mnScriptLines = ui->edit_Script->blockCount();
317320
msbStatusBar->showMessage("Script execution request pending...");
318321
emit ScriptStartRequest();
319322
}
@@ -442,6 +445,9 @@ UwxScripting::on_btn_Stop_clicked(
442445
gtmrScriptTimer.invalidate();
443446
ui->edit_Script->SetExecutionLineStatus(true);
444447

448+
//Return window title
449+
setWindowTitle("Scripting");
450+
445451
//Notify main form that script is no longer executing
446452
emit ScriptFinished();
447453
}
@@ -686,8 +692,12 @@ UwxScripting::AdvanceLine(
686692
strRepeatText.append(QString::number(fElapsed/(double)mnRepeats, 'f', 1)).append(" seconds/loop");
687693
}
688694
msbStatusBar->showMessage(QString("Script complete after ~").append(QString::number(((double)gtmrScriptTimer.elapsed()/1000.0), 'f', 1)).append(" seconds").append(strRepeatText));
695+
ui->progress_Complete->setValue(ui->progress_Complete->maximum());
689696
gtmrScriptTimer.invalidate();
690697

698+
//Return window title
699+
setWindowTitle("Scripting");
700+
691701
//Notify main form that script is no longer executing
692702
emit ScriptFinished();
693703
}
@@ -833,6 +843,9 @@ UwxScripting::UpdateStatusBar(
833843
)
834844
{
835845
//Updates status bar with current action
846+
ui->progress_Complete->setValue((mintCLine-1)*100/mnScriptLines);
847+
QString strPercent = QString::number(ui->progress_Complete->value()).append("%");
848+
setWindowTitle(QString("Scripting (Running... ").append(strPercent).append(")"));
836849
if (ucLastAct == ScriptingActionDataIn)
837850
{
838851
//Receiving data
@@ -843,11 +856,12 @@ UwxScripting::UpdateStatusBar(
843856
on_btn_Stop_clicked();
844857
msbStatusBar->showMessage(QString("Script failed (expected data not found after ").append(ui->spin_MaxRecTime->text()).append(" seconds).").append((mnRepeats > 0 ? QString(" on repeat #").append(QString::number(mnRepeats)) : "")));
845858
ui->edit_Script->SetExecutionLineStatus(true);
859+
setWindowTitle("Scripting");
846860
}
847861
else
848862
{
849863
//Time left
850-
msbStatusBar->showMessage(QString("#").append(QString::number(mintCLine+1)).append(": Waiting to receive data (").append(QString::number(mbaRecvData.length())).append(" bytes received in ").append(QString::number(dblRecTimeSec, 'f', 1)).append(" seconds)").append((mnRepeats > 0 ? QString(" with ").append(QString::number(mnRepeats)).append(" repeat").append(mnRepeats == 1 ? "" : "s") : "").append("...")));
864+
msbStatusBar->showMessage(QString("#").append(QString::number(mintCLine+1)).append(": Waiting to receive data (").append(QString::number(mbaRecvData.length())).append(" bytes received in ").append(QString::number(dblRecTimeSec, 'f', 1)).append(" seconds)").append((mnRepeats > 0 ? QString(" with ").append(QString::number(mnRepeats)).append(" repeat").append(mnRepeats == 1 ? "" : "s") : "").append("... (").append(strPercent).append(")")));
851865
}
852866
}
853867
else if (ucLastAct == ScriptingActionDataOut)
@@ -856,23 +870,23 @@ UwxScripting::UpdateStatusBar(
856870
if (ui->check_WaitForWrite->isChecked() == true)
857871
{
858872
//Sending data and waiting for it to be flushed
859-
msbStatusBar->showMessage(QString("#").append(QString::number(mintCLine+1)).append(": Waiting to data to be flushed (").append(QString::number(mbBytesWriteRemain)).append(" bytes remaining)").append((mnRepeats > 0 ? QString(" with ").append(QString::number(mnRepeats)).append(" repeat").append(mnRepeats == 1 ? "" : "s") : "").append("...")));
873+
msbStatusBar->showMessage(QString("#").append(QString::number(mintCLine+1)).append(": Waiting to data to be flushed (").append(QString::number(mbBytesWriteRemain)).append(" bytes remaining)").append((mnRepeats > 0 ? QString(" with ").append(QString::number(mnRepeats)).append(" repeat").append(mnRepeats == 1 ? "" : "s") : "").append("... (").append(strPercent).append(")")));
860874
}
861875
else
862876
{
863877
//Sending data
864-
msbStatusBar->showMessage(QString("#").append(QString::number(mintCLine+1)).append(": Outputting data..."));
878+
msbStatusBar->showMessage(QString("#").append(QString::number(mintCLine+1)).append(": Outputting data... (").append(strPercent).append(")"));
865879
}
866880
}
867881
else if (ucLastAct == ScriptingActionWaitTime)
868882
{
869883
//Wait period
870-
msbStatusBar->showMessage(QString("#").append(QString::number(mintCLine)).append(": Wait period ").append(QString::number(mtmrPauseTimer.interval())).append("ms (").append(QString::number(mtmrPauseTimer.remainingTime())).append("ms left)").append((mnRepeats > 0 ? QString(" with ").append(QString::number(mnRepeats)).append(" repeat").append(mnRepeats == 1 ? "" : "s") : "").append("...")));
884+
msbStatusBar->showMessage(QString("#").append(QString::number(mintCLine)).append(": Wait period ").append(QString::number(mtmrPauseTimer.interval())).append("ms (").append(QString::number(mtmrPauseTimer.remainingTime())).append("ms left)").append((mnRepeats > 0 ? QString(" with ").append(QString::number(mnRepeats)).append(" repeat").append(mnRepeats == 1 ? "" : "s") : "").append("... (").append(strPercent).append(")")));
871885
}
872886
else
873887
{
874888
//Comment or blank line
875-
msbStatusBar->showMessage(QString("#").append(QString::number(mintCLine+1)).append(": Comment/Unknown line"));
889+
msbStatusBar->showMessage(QString("#").append(QString::number(mintCLine+1)).append(": Comment/Unknown line (").append(strPercent).append(")"));
876890
}
877891
}
878892

@@ -1062,6 +1076,17 @@ UwxScripting::LoadScriptFile(
10621076
}
10631077
}
10641078

1079+
//=============================================================================
1080+
//=============================================================================
1081+
void
1082+
UwxScripting::SetScriptLastDirectory(
1083+
const QString *strDirectory
1084+
)
1085+
{
1086+
//Sets the last opened directory
1087+
strLastScriptFile = *strDirectory;
1088+
}
1089+
10651090
/******************************************************************************/
10661091
// END OF FILE
10671092
/******************************************************************************/

0 commit comments

Comments
 (0)