Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the save and record dialogs work the same way #64

Merged
merged 1 commit into from
Oct 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions rqt_bag/src/rqt_bag/bag_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,23 +249,21 @@ def _handle_record_clicked(self):

def _on_record_settings_selected(self, all_topics, selected_topics):
# TODO verify master is still running
filename = QFileDialog.getSaveFileName(
self, self.tr('Select prefix for new Bag File'), '.', self.tr('Bag files {.bag} (*.bag)'))
if filename[0] != '':
prefix = filename[0].strip()

# Get filename to record to
record_filename = time.strftime('%Y-%m-%d-%H-%M-%S.bag', time.localtime(time.time()))
if prefix.endswith('.bag'):
prefix = prefix[:-len('.bag')]
if prefix:
record_filename = '%s_%s' % (prefix, record_filename)
# Get the bag name to record to, prepopulating with a file name based on the current date/time
proposed_filename = time.strftime('%Y-%m-%d-%H-%M-%S', time.localtime(time.time()))
filename = QFileDialog.getSaveFileName(
self, self.tr('Select name for new bag'), proposed_filename, self.tr('Bag files {.bag} (*.bag)'))[0]

rospy.loginfo('Recording to %s.' % record_filename)
if filename != '':
filename = filename.strip()
if not filename.endswith('.bag'):
filename += ".bag"

# Begin recording
self.load_button.setEnabled(False)
self._recording = True
self._timeline.record_bag(record_filename, all_topics, selected_topics)
self._timeline.record_bag(filename, all_topics, selected_topics)

def _handle_load_clicked(self):
filenames = QFileDialog.getOpenFileNames(
Expand Down Expand Up @@ -317,10 +315,17 @@ def load_bag(self, filename):
# self clear loading filename

def _handle_save_clicked(self):
# Get the bag name to record to, prepopulating with a file name based on the current date/time
proposed_filename = time.strftime('%Y-%m-%d-%H-%M-%S', time.localtime(time.time()))
filename = QFileDialog.getSaveFileName(
self, self.tr('Save selected region to file...'), '.', self.tr('Bag files {.bag} (*.bag)'))
if filename[0] != '':
self._timeline.copy_region_to_bag(filename[0])
self, self.tr('Save selected region...'), proposed_filename, self.tr('Bag files {.bag} (*.bag)'))[0]
if filename != '':
filename = filename.strip()
if not filename.endswith('.bag'):
filename += '.bag'

# Copy the highlighted region
self._timeline.copy_region_to_bag(filename)

def _set_status_text(self, text):
if text:
Expand Down