Skip to content

Commit

Permalink
WIP #598
Browse files Browse the repository at this point in the history
- improve options dialog sartopo fields callback logic: disconnect when checkboxes are unchecked, reconnect when checkboxes are rechecked if URL field is not blank; disconnect if URL field is blank
  • Loading branch information
caver456 committed Dec 6, 2022
1 parent 2d80876 commit 1f3de45
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 20 deletions.
14 changes: 10 additions & 4 deletions designer/options.ui
Original file line number Diff line number Diff line change
Expand Up @@ -327,19 +327,25 @@
<widget class="QLineEdit" name="sartopoMapURLField"/>
</item>
<item>
<widget class="QLineEdit" name="sartopoLinkStatusField">
<widget class="QLineEdit" name="sartopoLinkIndicator">
<property name="minimumSize">
<size>
<width>40</width>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color:#aaaaaa</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
Expand Down
48 changes: 37 additions & 11 deletions radiolog.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,12 @@ def __init__(self,parent):
self.incidentStartDate=time.strftime("%a %b %d, %Y")
self.isContinuedIncident=False

self.sts=None
self.sartopoURL=''
self.sartopoLink=None
self.radioMarkerDict={}
self.radioMarkerFID=None

self.optionsDialog=optionsDialog(self)
self.optionsDialog.accepted.connect(self.optionsAccepted)

Expand Down Expand Up @@ -1020,12 +1026,6 @@ def __init__(self,parent):
self.comPortScanInProgress=False
self.comPortTryList=[]

self.sts=None
self.sartopoURL=''
self.sartopoLink=None
self.radioMarkerDict={}
self.radioMarkerFID=None

## if develMode:
## self.comPortTryList=[serial.Serial("\\\\.\\CNCB0")] # DEVEL
self.fsBuffer=""
Expand Down Expand Up @@ -5025,15 +5025,15 @@ def createSTS(self):
rprint('createSTS called:')
if self.sts is not None: # close out any previous session
print('Closing previous SartopoSession')
self.sts=None
self.closeSTS()
# self.ui.linkIndicator.setText("")
# self.updateLinkIndicator()
# self.link=-1
# self.updateFeatureList("Folder")
# self.updateFeatureList("Marker")
if self.optionsDialog.ui.sartopoMapURLField.text():
u=self.optionsDialog.ui.sartopoMapURLField.text()
if u==self.sartopoURL: # url has not changed; keep the existing link and folder list
if u==self.sartopoURL and self.sts: # url has not changed; keep the existing link and folder list
return
self.sartopoURL=u
if self.sartopoURL.endswith("#"): # pound sign at end of URL causes crash; brute force fix it here
Expand All @@ -5054,6 +5054,7 @@ def createSTS(self):
# self.sts=SartopoSession(domainAndPort=domainAndPort,mapID=mapID,sync=False,syncTimeout=0.001)
self.sartopoLink=self.sts.apiVersion
print("link status:"+str(self.sartopoLink))
self.updateSartopoLinkIndicator()
# self.updateLinkIndicator()
# if self.link>0:
# self.ui.linkIndicator.setText(self.sts.mapID)
Expand All @@ -5068,6 +5069,23 @@ def createSTS(self):
id=self.sts.addMarker(val[2],val[3],key,val[1],folderId=self.radioMarkerFID)
self.radioMarkerDict[key][0]=id

def closeSTS(self):
rprint('closeSTS called')
if self.sts:
del self.sts
self.sts=None
self.sartopoLink=0
self.updateSartopoLinkIndicator()

def updateSartopoLinkIndicator(self):
rprint('updateSartopoLinkIndcator called: sartopoLink='+str(self.sartopoLink))
if self.sartopoLink==1:
self.optionsDialog.ui.sartopoLinkIndicator.setStyleSheet("background-color:#00ff00")
elif self.sartopoLink==-1:
self.optionsDialog.ui.sartopoLinkIndicator.setStyleSheet("background-color:#ff0000")
else:
self.optionsDialog.ui.sartopoLinkIndicator.setStyleSheet("background-color:#aaaaaa")

class helpWindow(QDialog,Ui_Help):
def __init__(self, *args):
QDialog.__init__(self)
Expand Down Expand Up @@ -5103,7 +5121,6 @@ def __init__(self,parent):
self.ui.formatField.setEnabled(False) # since convert menu is not working yet, TMG 4-8-15
self.setFixedSize(self.size())
self.secondWorkingDirCB()
self.sartopoEnabledCB()

def showEvent(self,event):
# clear focus from all fields, otherwise previously edited field gets focus on next show,
Expand All @@ -5113,6 +5130,7 @@ def showEvent(self,event):
self.ui.formatField.clearFocus()
self.ui.timeoutField.clearFocus()
self.ui.secondWorkingDirCheckBox.clearFocus()
self.sartopoEnabledCB()

def displayTimeout(self):
self.ui.timeoutLabel.setText("Timeout: "+timeoutDisplayList[self.ui.timeoutField.value()][0])
Expand All @@ -5137,20 +5155,28 @@ def toggleShow(self):
self.show()
self.raise_()

def sartopoEnabledCB(self):
def sartopoEnabledCB(self): # called from stateChanged of group box AND of radio markers checkbox
a=self.ui.sartopoGroupBox.isChecked()
radios=self.ui.sartopoRadioMarkersCheckBox.isChecked()
self.ui.sartopoLocationUpdatesCheckBox.setEnabled(a)
self.ui.sartopoRadioMarkersCheckBox.setEnabled(a)
enableMapFields=a and radios
self.ui.sartopoMapURLField.setEnabled(enableMapFields)
self.ui.sartopoLinkStatusField.setEnabled(enableMapFields)
self.ui.sartopoLinkIndicator.setEnabled(enableMapFields)
self.ui.sartopoMapURLLabel.setEnabled(enableMapFields)
self.ui.sartopoMapNameLabel.setEnabled(enableMapFields)
if enableMapFields:
self.sartopoURLCB() # try to reconnect if mapURL is not blank
else:
self.parent.closeSTS()

def sartopoURLCB(self):
if self.ui.sartopoMapURLField.text()=='':
self.parent.closeSTS()
return
self.parent.createSTS()


class printDialog(QDialog,Ui_printDialog):
def __init__(self,parent):
QDialog.__init__(self)
Expand Down
12 changes: 7 additions & 5 deletions ui/options_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,13 @@ def setupUi(self, optionsDialog):
self.sartopoMapURLField = QtWidgets.QLineEdit(self.sartopoGroupBox)
self.sartopoMapURLField.setObjectName("sartopoMapURLField")
self.horizontalLayout_3.addWidget(self.sartopoMapURLField)
self.sartopoLinkStatusField = QtWidgets.QLineEdit(self.sartopoGroupBox)
self.sartopoLinkStatusField.setMinimumSize(QtCore.QSize(40, 0))
self.sartopoLinkStatusField.setMaximumSize(QtCore.QSize(16777215, 30))
self.sartopoLinkStatusField.setObjectName("sartopoLinkStatusField")
self.horizontalLayout_3.addWidget(self.sartopoLinkStatusField)
self.sartopoLinkIndicator = QtWidgets.QLineEdit(self.sartopoGroupBox)
self.sartopoLinkIndicator.setMinimumSize(QtCore.QSize(20, 0))
self.sartopoLinkIndicator.setMaximumSize(QtCore.QSize(20, 20))
self.sartopoLinkIndicator.setStyleSheet("background-color:#aaaaaa")
self.sartopoLinkIndicator.setReadOnly(True)
self.sartopoLinkIndicator.setObjectName("sartopoLinkIndicator")
self.horizontalLayout_3.addWidget(self.sartopoLinkIndicator)
self.horizontalLayout_3.setStretch(0, 20)
self.horizontalLayout_3.setStretch(1, 1)
self.gridLayout_2.addLayout(self.horizontalLayout_3, 2, 1, 1, 1)
Expand Down

0 comments on commit 1f3de45

Please sign in to comment.