def setup_message_box_layout(self): container_layout = QtWidgets.QHBoxLayout() text_area_layout = QtWidgets.QVBoxLayout() if self.chat_window.user["username"] == self.username: text_area_layout.addWidget(self.messageBox) self.textArea.setLayout(text_area_layout) container_layout.addStretch() container_layout.addWidget(self.textArea) else: username_label = QtWidgets.QLabel(f"{self.username}") username_label.setContentsMargins(5, 5, 5, 0) label_font = QtGui.QFont() label_font.setBold(True) username_label.setFont(label_font) text_area_layout.addWidget(username_label) text_area_layout.addWidget(self.messageBox) self.textArea.setLayout(text_area_layout) container_layout.addWidget(self.textArea) container_layout.addStretch() for reply in self.replies: self.add_message_reply(reply) self.textArea.layout().setSpacing(0) self.textArea.layout().setContentsMargins(0, 0, 0, 0) container_layout.setSpacing(0) container_layout.setContentsMargins(5, 5, 5, 5) self.set_message_style() self.setLayout(container_layout)
def add_message_reply(self, reply): if self.replyArea is None: self.insert_reply_area() reply_username_label = QtWidgets.QLabel(f'{reply["username"]}:') label_font = QtGui.QFont() label_font.setBold(True) reply_username_label.setFont(label_font) reply_message_box = self.get_text_browser(reply["text"]) self.replyArea.layout().addRow(reply_username_label, reply_message_box)
def set_active_pid(self, item): if item.p_id == self.active_pid: return # close all hanging window self.force_close_view_windows() self.close_external_windows() # Turn off work locally toggle self.workLocallyCheckBox.blockSignals(True) self.workLocallyCheckBox.setChecked(False) self.workLocallyCheckBox.blockSignals(False) self.save_ft.setEnabled(False) self.fetch_ft.setEnabled(False) # set active_pid here self.active_pid = item.p_id self.access_level = item.access_level self.active_project_name = item.text().split("-")[0].strip() self.waypoints_model = None # set active flightpath here self.load_wps_from_server() # enable project specific buttons self.helperTextLabel.setVisible(True) self.helperTextLabel.setText(self.tr("Working On: Shared File. All your changes will be shared with everyone." "Turn on work locally to work on local flight track file")) self.importBtn.setEnabled(True) self.exportBtn.setEnabled(True) self.topview.setEnabled(True) self.sideview.setEnabled(True) self.tableview.setEnabled(True) self.workLocallyCheckBox.setEnabled(True) if self.access_level == "viewer" or self.access_level == "collaborator": if self.access_level == "viewer": self.chatWindowBtn.setEnabled(False) else: self.chatWindowBtn.setEnabled(True) self.adminWindowBtn.setEnabled(False) self.versionHistoryBtn.setEnabled(False) else: self.adminWindowBtn.setEnabled(True) self.chatWindowBtn.setEnabled(True) self.versionHistoryBtn.setEnabled(True) if self.access_level == "creator": self.deleteProjectBtn.setEnabled(True) else: self.deleteProjectBtn.setEnabled(False) # change font style for selected font = QtGui.QFont() for i in range(self.listProjects.count()): self.listProjects.item(i).setFont(font) font.setBold(True) item.setFont(font)
def activate_flight_track(self, item): """Set the currently selected flight track to be the active one, i.e. the one that is displayed in the views (only one flight track can be displayed at a time). """ self.active_flight_track = item.flighttrack_model for i in range(self.listViews.count()): view_item = self.listViews.item(i) view_item.window.setFlightTrackModel(self.active_flight_track) font = QtGui.QFont() for i in range(self.listFlightTracks.count()): self.listFlightTracks.item(i).setFont(font) font.setBold(True) item.setFont(font)
def preview_change(self, current_item, previous_item): font = QtGui.QFont() if previous_item is not None: previous_item.setFont(font) if current_item is None: self.changePreviewTable.setModel(None) self.deleteVersionNameBtn.setVisible(False) self.toggle_version_buttons(False) return font.setBold(True) current_item.setFont(font) data = {"token": self.token, "ch_id": current_item.id} url = url_join(self.mscolab_server_url, 'get_change_content') res = requests.get(url, data=data).json() waypoint_model = WaypointsTableModel(xml_content=res["content"]) self.changePreviewTable.setModel(waypoint_model) if current_item.version_name is not None: self.deleteVersionNameBtn.setVisible(True) else: self.deleteVersionNameBtn.setVisible(False) self.toggle_version_buttons(True)