Skip to content

Commit fa70cb7

Browse files
committed
LP-597 Progress bar for GCS log replay - Resize playPause and stop buttons according to the available space for the widget.
- also make pretty
1 parent d540c2a commit fa70cb7

4 files changed

Lines changed: 133 additions & 40 deletions

File tree

ground/gcs/src/libs/utils/logfile.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ void LogFile::timerFired()
165165
/*
166166
This code generates an advancing playback window. All samples that fit the window
167167
are replayed. The window is about the size of the timer interval: 10 ms.
168-
168+
169169
Description of used variables:
170170
171171
time : real-time interval since start of playback (in ms) - now()
@@ -176,8 +176,7 @@ void LogFile::timerFired()
176176
177177
*/
178178

179-
while ( m_nextTimeStamp < (m_lastPlayed + (double)(time - m_timeOffset) * m_playbackSpeed) ) {
180-
179+
while (m_nextTimeStamp < (m_lastPlayed + (double)(time - m_timeOffset) * m_playbackSpeed)) {
181180
// advance the replay window for the next time period
182181
m_lastPlayed += ((double)(time - m_timeOffset) * m_playbackSpeed);
183182

@@ -344,12 +343,11 @@ bool LogFile::resumeReplay(quint32 desiredPosition)
344343
Looking for the next log timestamp after the desired position
345344
has the advantage that it skips over parts of the log
346345
where data might be missing.
347-
*/
346+
*/
348347
for (int i = 0; i < m_timeStamps.size(); i++) {
349348
if (m_timeStamps.at(i) >= desiredPosition) {
350-
351349
int bytesToSkip = m_timeStampPositions.at(i);
352-
bool seek_ok = m_file.seek(bytesToSkip);
350+
bool seek_ok = m_file.seek(bytesToSkip);
353351
if (!seek_ok) {
354352
qWarning() << "LogFile resumeReplay - an error occurred while seeking through the logfile.";
355353
}
@@ -365,7 +363,7 @@ bool LogFile::resumeReplay(quint32 desiredPosition)
365363

366364
// Set the real-time interval to 0 to start with:
367365
m_myTime.restart();
368-
m_timeOffset = 0;
366+
m_timeOffset = 0;
369367

370368
m_replayStatus = PLAYING;
371369

@@ -409,7 +407,7 @@ bool LogFile::pauseAndResetPosition()
409407
}
410408
qDebug() << "LogFile - pauseAndResetPosition";
411409
m_timer.stop();
412-
m_replayStatus = STOPPED;
410+
m_replayStatus = STOPPED;
413411

414412
m_timeOffset = 0;
415413
m_lastPlayed = m_timeStamps.at(0);
@@ -467,10 +465,10 @@ bool LogFile::buildIndex()
467465
}
468466
m_timeStamps.append(timeStamp);
469467
m_timeStampPositions.append(readPointer);
470-
readPointer += TIMESTAMP_SIZE_BYTES;
468+
readPointer += TIMESTAMP_SIZE_BYTES;
471469
index++;
472470
m_beginTimeStamp = timeStamp;
473-
m_endTimeStamp = timeStamp;
471+
m_endTimeStamp = timeStamp;
474472
}
475473

476474
while (true) {
@@ -511,7 +509,7 @@ bool LogFile::buildIndex()
511509
if (bytesRead != TIMESTAMP_SIZE_BYTES) {
512510
qWarning() << "LogFile buildIndex - read timeStamp, readRawData returned unexpected number of bytes:" << bytesRead << "at position" << readPointer << "\n";
513511
return false;
514-
}
512+
}
515513

516514
// some validity checks
517515
if (timeStamp < m_endTimeStamp // logfile goes back in time
@@ -522,7 +520,7 @@ bool LogFile::buildIndex()
522520

523521
m_timeStamps.append(timeStamp);
524522
m_timeStampPositions.append(readPointer);
525-
readPointer += TIMESTAMP_SIZE_BYTES;
523+
readPointer += TIMESTAMP_SIZE_BYTES;
526524
index++;
527525
m_endTimeStamp = timeStamp;
528526
} else {

ground/gcs/src/plugins/logging/logging.ui

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
<item>
3737
<widget class="QPushButton" name="playPauseButton">
3838
<property name="sizePolicy">
39-
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
40-
<horstretch>0</horstretch>
39+
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
40+
<horstretch>80</horstretch>
4141
<verstretch>0</verstretch>
4242
</sizepolicy>
4343
</property>
@@ -47,11 +47,17 @@
4747
<height>0</height>
4848
</size>
4949
</property>
50+
<property name="maximumSize">
51+
<size>
52+
<width>80</width>
53+
<height>16777215</height>
54+
</size>
55+
</property>
5056
<property name="text">
5157
<string> Play</string>
5258
</property>
5359
<property name="icon">
54-
<iconset resource="../logging/res.qrc">
60+
<iconset resource="res.qrc">
5561
<normaloff>:/logging/images/play.png</normaloff>:/logging/images/play.png</iconset>
5662
</property>
5763
<property name="iconSize">
@@ -65,8 +71,8 @@
6571
<item>
6672
<widget class="QPushButton" name="stopButton">
6773
<property name="sizePolicy">
68-
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
69-
<horstretch>0</horstretch>
74+
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
75+
<horstretch>80</horstretch>
7076
<verstretch>0</verstretch>
7177
</sizepolicy>
7278
</property>
@@ -76,11 +82,17 @@
7682
<height>0</height>
7783
</size>
7884
</property>
85+
<property name="maximumSize">
86+
<size>
87+
<width>80</width>
88+
<height>16777215</height>
89+
</size>
90+
</property>
7991
<property name="text">
8092
<string> Stop</string>
8193
</property>
8294
<property name="icon">
83-
<iconset resource="../logging/res.qrc">
95+
<iconset resource="res.qrc">
8496
<normaloff>:/logging/images/stop.png</normaloff>:/logging/images/stop.png</iconset>
8597
</property>
8698
<property name="iconSize">
@@ -113,6 +125,12 @@
113125
</item>
114126
<item>
115127
<widget class="QDoubleSpinBox" name="playbackSpeed">
128+
<property name="sizePolicy">
129+
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
130+
<horstretch>0</horstretch>
131+
<verstretch>0</verstretch>
132+
</sizepolicy>
133+
</property>
116134
<property name="decimals">
117135
<number>1</number>
118136
</property>
@@ -203,6 +221,12 @@
203221
<verstretch>0</verstretch>
204222
</sizepolicy>
205223
</property>
224+
<property name="minimumSize">
225+
<size>
226+
<width>40</width>
227+
<height>0</height>
228+
</size>
229+
</property>
206230
<property name="text">
207231
<string/>
208232
</property>
@@ -229,6 +253,12 @@
229253
<verstretch>0</verstretch>
230254
</sizepolicy>
231255
</property>
256+
<property name="minimumSize">
257+
<size>
258+
<width>40</width>
259+
<height>0</height>
260+
</size>
261+
</property>
232262
<property name="text">
233263
<string/>
234264
</property>
@@ -255,6 +285,12 @@
255285
<verstretch>0</verstretch>
256286
</sizepolicy>
257287
</property>
288+
<property name="minimumSize">
289+
<size>
290+
<width>40</width>
291+
<height>0</height>
292+
</size>
293+
</property>
258294
<property name="text">
259295
<string/>
260296
</property>
@@ -283,7 +319,7 @@
283319
</layout>
284320
</widget>
285321
<resources>
286-
<include location="../logging/res.qrc"/>
322+
<include location="res.qrc"/>
287323
</resources>
288324
<connections/>
289325
</ui>

0 commit comments

Comments
 (0)