コード例 #1
0
    def updateClientData(self):
        # set main label
        label = self.client.label if self.client.label else self.client.name
        self.ui.ClientName.setText(label)

        # set tool tip
        tool_tip = "<html><head/><body>"
        tool_tip += "<p><span style=\" font-weight:600;\">%s<br></span>" \
            % self.client.name
        tool_tip += "<span style=\" font-style:italic;\">%s</span></p>" \
            % self.client.description
        tool_tip += "<p></p>"
        tool_tip += "<p>%s : %s<br>" \
            % (_translate('client_slot', 'Executable'),
               self.client.executable_path)
        tool_tip += "%s : %s</p>" \
            % (_translate('client_slot', 'client id'), self.client.client_id)
        tool_tip += "</body></html>"

        self.ui.ClientName.setToolTip(tool_tip)

        # set icon
        self.icon_on = ray.getAppIcon(
            self.client.icon_name,
            self,
            addSearchPaths=self.client.icon_search_paths)
        self.icon_off = QIcon(self.icon_on.pixmap(32, 32, QIcon.Disabled))

        self.grayIcon(
            bool(self.client.status in (ray.ClientStatus.STOPPED,
                                        ray.ClientStatus.PRECOPY)))
コード例 #2
0
    def __init__(self, parent, client_data):
        ChildDialog.__init__(self, parent)
        self.ui = ui.client_trash.Ui_Dialog()
        self.ui.setupUi(self)

        self.client_data = client_data

        self.ui.labelPrettierName.setText(self.client_data.prettier_name())
        self.ui.labelDescription.setText(self.client_data.description)
        self.ui.labelExecutable.setText(self.client_data.executable_path)
        self.ui.labelId.setText(self.client_data.client_id)
        self.ui.toolButtonIcon.setIcon(QIcon.fromTheme(self.client_data.icon))

        self.ui.toolButtonAdvanced.clicked.connect(self._show_properties)
        self.ui.pushButtonRemove.clicked.connect(self._remove_client)
        self.ui.pushButtonCancel.setFocus()

        self._remove_client_message_box = QMessageBox(
            QMessageBox.Warning,
            _translate('trashed_client', 'Remove definitely'),
            _translate(
                'trashed_client',
                "Are you sure to want to remove definitely this client and all its files ?"
            ), QMessageBox.Ok | QMessageBox.Cancel, self)
        self._remove_client_message_box.setDefaultButton(QMessageBox.Cancel)
コード例 #3
0
    def makeItem(self, sub_type=GROUP_MAIN):
        display_text = ''

        if self.sub_type == GROUP_MAIN:
            return None

        if not self.date_time:
            display_text = self.text
        elif self.sub_type == GROUP_YEAR:
            display_text = self.date_time.toString('yyyy')
        elif self.sub_type == GROUP_MONTH:
            display_text = self.date_time.toString('MMMM yyyy')
        elif self.sub_type == GROUP_DAY:
            display_text = self.date_time.toString('dddd d MMMM yyyy')
            if self.isToday():
                display_text = _translate('snapshots', 'Today')
            elif self.isYesterday():
                display_text = _translate('snapshots', 'Yesterday')

        item = QTreeWidgetItem([display_text])

        for snapshot in self.snapshots:
            sub_item = snapshot.makeItem(self.sub_type)
            item.addChild(sub_item)

        # set this group item not selectable
        item.setFlags(item.flags() & ~Qt.ItemIsSelectable)

        return item
コード例 #4
0
 def __show_text_contents(self):
     """Display the decrypted data assuming that they are text
     """
     decrypted_contents = self.decrypted_data
     try:
         if self.combo_encoding.currentText() == "UTF-8":
             decrypted_contents = decrypted_contents.decode("utf-8")
         elif self.combo_encoding.currentText() == "ASCII":
             decrypted_contents = decrypted_contents.decode("ascii")
     except UnicodeDecodeError:
         decrypted_contents = _translate("Data do not seem to be text.\nMaybe try other file type?")
         decrypted_contents += "\n\n" + _translate(
             "An hexadecimal representation of the beginning of the file is shown below:\n\n")
         num_rows = 10
         num_cols = 8
         offset = 0
         for i in range(num_rows):
             for j in range(num_cols):
                 decrypted_contents += self.decrypted_data[offset].encode("hex") + " "
                 offset += 1
             offset -= num_cols
             decrypted_contents += "  |  "
             for j in range(num_cols):
                 try:
                     if 32 <= ord(self.decrypted_data[offset]) <= 128:
                         decrypted_contents += self.decrypted_data[offset] + " "
                     else:
                         decrypted_contents += ". "
                 except UnicodeDecodeError:
                     decrypted_contents += ". "
                 offset += 1
             decrypted_contents += "\n"
     self.textedit_contents.setText(decrypted_contents)
     self.frame_text_contents.setVisible(True)
コード例 #5
0
    def update_client_data(self):
        # set main label and main disposition
        self.update_disposition()

        # set tool tip
        tool_tip = "<html><head/><body>"
        tool_tip += "<p><span style=\" font-weight:600;\">%s<br></span>" \
            % self.client.name
        tool_tip += "<span style=\" font-style:italic;\">%s</span></p>" \
            % self.client.description
        tool_tip += "<p></p>"
        tool_tip += "<p>%s : %s<br>" \
            % (_translate('client_slot', 'Protocol'),
               ray.protocol_to_str(self.client.protocol))
        tool_tip += "%s : %s<br>" \
            % (_translate('client_slot', 'Executable'),
               self.client.executable_path)
        tool_tip += "%s : %s</p>" \
            % (_translate('client_slot', 'client id'), self.client.client_id)
        tool_tip += "</body></html>"

        self.ui.ClientName.setToolTip(tool_tip)

        # set icon
        self._icon_on = get_app_icon(self.client.icon, self)
        self._icon_off = QIcon(self._icon_on.pixmap(32, 32, QIcon.Disabled))
        self._gray_icon(False)
コード例 #6
0
    def setDaemonOptions(self, options):
        self.ui.actionBookmarkSessionFolder.setChecked(
            bool(options & ray.Option.BOOKMARK_SESSION))
        self.ui.actionDesktopsMemory.setChecked(
            bool(options & ray.Option.DESKTOPS_MEMORY))
        self.ui.actionAutoSnapshot.setChecked(
            bool(options & ray.Option.SNAPSHOTS))
        self.ui.actionSessionScripts.setChecked(
            bool(options & ray.Option.SESSION_SCRIPTS))

        has_wmctrl = bool(options & ray.Option.HAS_WMCTRL)
        self.ui.actionDesktopsMemory.setEnabled(has_wmctrl)
        if has_wmctrl:
            self.ui.actionDesktopsMemory.setText(
                _translate('actions', 'Desktops Memory'))

        has_git = bool(options & ray.Option.HAS_GIT)
        self.ui.actionAutoSnapshot.setEnabled(has_git)
        self.ui.actionReturnToAPreviousState.setVisible(has_git)
        self.ui.toolButtonSnapshots.setVisible(has_git)
        if has_git:
            self.ui.actionAutoSnapshot.setText(
                _translate('actions', 'Auto Snapshot at Save'))

        self.has_git = has_git
コード例 #7
0
    def update_client_data(self):
        # set main label and main disposition
        self.update_disposition()

        # set tool tip
        tool_tip = "<html><head/><body>"
        tool_tip += "<p><span style=\" font-weight:600;\">%s<br></span>" \
            % self.client.name
        tool_tip += "<span style=\" font-style:italic;\">%s</span></p>" \
            % self.client.description
        tool_tip += "<p></p>"
        tool_tip += "<p>%s : %s<br>" \
            % (_translate('client_slot', 'Protocol'),
               ray.protocol_to_str(self.client.protocol))
        tool_tip += "%s : %s<br>" \
            % (_translate('client_slot', 'Executable'),
               self.client.executable_path)
        tool_tip += "%s : %s</p>" \
            % (_translate('client_slot', 'client id'), self.client.client_id)
        tool_tip += "</body></html>"

        self.ui.ClientName.setToolTip(tool_tip)

        # set icon
        self._icon_on = get_app_icon(self.client.icon, self)
        self._icon_off = QIcon(self._icon_on.pixmap(32, 32, QIcon.Disabled))

        self._gray_icon(
            bool(self.client.status in (ray.ClientStatus.STOPPED,
                                        ray.ClientStatus.PRECOPY)))

        self.ui.toolButtonGUI.setVisible(
            bool(':optional-gui:' in self.client.capabilities))

        if self.client.executable_path in ('ray-proxy', 'nsm-proxy'):
            if is_dark_theme(self):
                self._icon_visible = QIcon()
                self._icon_visible.addPixmap(
                    QPixmap(':scalable/breeze-dark/emblem-symbolic-link'),
                    QIcon.Normal, QIcon.Off)
                self._icon_invisible = QIcon()
                self._icon_invisible.addPixmap(
                    QPixmap(':scalable/breeze-dark/link'), QIcon.Normal,
                    QIcon.Off)
                self._icon_invisible.addPixmap(
                    QPixmap(':scalable/breeze-dark/disabled/link'),
                    QIcon.Disabled, QIcon.Off)
            else:
                self._icon_visible = QIcon()
                self._icon_visible.addPixmap(
                    QPixmap(':scalable/breeze/emblem-symbolic-link'),
                    QIcon.Normal, QIcon.Off)
                self._icon_invisible = QIcon()
                self._icon_invisible.addPixmap(
                    QPixmap(':scalable/breeze/link'), QIcon.Normal, QIcon.Off)
                self._icon_invisible.addPixmap(
                    QPixmap(':scalable/breeze/disabled/link'), QIcon.Disabled,
                    QIcon.Off)
コード例 #8
0
    def ask_name_and_add_empty_folder(self):
        """Add a new folder in the luggage (user selects the name until it's valid or desists
        """
        # Choose the parent node under which the elements are inserted
        selected_nodes = self.get_selected_tree_nodes()
        if len(selected_nodes) == 0:
            parent_node = self.file_tree_root
        else:
            if len(selected_nodes) > 1:
                candidate_parents = []
                for node in selected_nodes:
                    if node.is_terminal:
                        candidate_parents.append(node.parent)
                    else:
                        candidate_parents.append(node)
                if len(set(candidate_parents)) > 1:
                    QMessageBox.information(
                        self,
                        "Too many items selected",
                        "Select only one item to indicate where the new folder should be created")
                    return
            parent_node = selected_nodes[0]
            if parent_node.is_terminal:
                parent_node = parent_node.parent

        questioning_user = True
        while questioning_user:
            input_text = ""
            ok = True
            while ok and input_text == "":
                input_text, ok = QtGui.QInputDialog.getText(
                    self,
                    _translate('Choose folder name'),
                    _translate('Choose a (non-empty) name for the new folder'))
                input_text = unicode(input_text).strip()

            if not ok:
                questioning_user = False
            else:
                if input_text in [c.name for c in parent_node.children]:
                    message_dialog = QtGui.QMessageBox()
                    message_dialog.setIcon(QMessageBox.Information)
                    message_dialog.setText(_translate("An element with the name '{}' already exists.".format(
                        input_text)))
                    message_dialog.setInformativeText(_translate("Please select another name."))
                    message_dialog.exec_()
                else:
                    folder_node = FolderNode(
                        parent_folder=parent_node,
                        name=input_text)
                    parent_node.children.append(folder_node)
                    self.__bg_save_file_tree(
                        message=_translate("Adding folder"),
                        target=folder_node.name)
                    self.luggage.save_file_tree()
                    self.__update_treewidget_contents()
                    self.set_selected_tree_nodes([folder_node])
                    questioning_user = False
コード例 #9
0
 def _update_menu(self):
     if self.is_luggage_shown:
         self.action_show_hide.setText(_translate("&Hide Luggage in System Tray"))
     else:
         self.action_show_hide.setText(_translate("&Restore Luggage from System Tray"))
     if self.is_open_luggage:
         self.setContextMenu(self.menu_opened_luggage)
     else:
         self.setContextMenu(self.menu_closed_luggage)
コード例 #10
0
    def __insert_paths_into_luggage(self, path_list):
        """Insert the files and directories passed as argument in the selected node if a FolderNode,
        or in its parent if a FileInfo is selected.
        """
        # Choose the parent node under which the elements are inserted
        selected_nodes = self.get_selected_tree_nodes()
        if len(selected_nodes) == 0:
            parent_node = self.file_tree_root
        else:
            candidate_parents = []
            for node in selected_nodes:
                if node.is_terminal:
                    candidate_parents.append(node.parent)
                else:
                    candidate_parents.append(node)
            if len(set(candidate_parents)) > 1:
                QMessageBox.information(
                    self,
                    "Too many items selected",
                    "Select only one item to indicate where the new file(s) should be created")
                return
            parent_node = selected_nodes[0]
            if parent_node.is_terminal:
                parent_node = parent_node.parent

        new_paths = []
        new_names = []
        for element_path in map(unicode, path_list):
            element_processed = False
            element_name = os.path.basename(element_path)
            while not element_processed:
                if element_name in [c.name for c in parent_node.children] + new_names:
                    # Name clash
                    input_text = ""
                    ok = True
                    while input_text == "" and ok:
                        input_text, ok = QtGui.QInputDialog.getText(
                            self,
                            _translate("Name clash"),
                            _translate("An element with name '{}' already exists. ¿Rename?").format(element_name))
                        input_text = unicode(input_text).strip()
                    if input_text != "":
                        element_name = input_text
                    if not ok:
                        element_processed = True
                else:
                    element_name = os.path.basename(element_path)
                    element_processed = True
            if not os.path.basename(element_path) in [c.name for c in parent_node.children] + new_names:
                if os.path.islink(element_path) and not self.pyluggage_config.follow_sym_links:
                    continue
                new_names.append(element_name)
                new_paths.append(element_path)

        self.__bg_insert_paths(
            parent_node=parent_node,
            paths_and_names_to_insert=zip(new_paths, new_names))
コード例 #11
0
    def __init__(self, parent, duplicate_window=False):
        ChildDialog.__init__(self, parent)
        self.ui = ui.new_session.Ui_DialogNewSession()
        self.ui.setupUi(self)

        self._is_duplicate = bool(duplicate_window)

        self.ui.currentSessionsFolder.setText(CommandLineArgs.session_root)
        self.ui.toolButtonFolder.clicked.connect(self._change_root_folder)
        self.ui.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
        self.ui.lineEdit.setFocus(Qt.OtherFocusReason)
        self.ui.lineEdit.textChanged.connect(self._text_changed)

        self.session_list = []
        self.template_list = []
        self.sub_folders = []

        self.signaler.server_status_changed.connect(
            self._server_status_changed)
        self.signaler.add_sessions_to_list.connect(self._add_sessions_to_list)
        self.signaler.session_template_found.connect(
            self._add_templates_to_list)
        self.signaler.root_changed.connect(self._root_changed)

        self.to_daemon('/ray/server/list_sessions', 1)

        if self._is_duplicate:
            self.ui.labelTemplate.setVisible(False)
            self.ui.comboBoxTemplate.setVisible(False)
            self.ui.labelOriginalSessionName.setText(
                self.session.get_short_path())
            self.ui.labelNewSessionName.setText(
                _translate('Duplicate', 'Duplicated session name :'))
            self.setWindowTitle(_translate('Duplicate', 'Duplicate Session'))
        else:
            self.ui.frameOriginalSession.setVisible(False)
            self.to_daemon('/ray/server/list_session_templates')

        if not self.daemon_manager.is_local:
            self.ui.toolButtonFolder.setVisible(False)
            self.ui.currentSessionsFolder.setVisible(False)
            self.ui.labelSessionsFolder.setVisible(False)

        self._init_templates_combo_box()
        self._set_last_template_selected()

        self._server_will_accept = False
        self._text_is_valid = False

        self._completer = QCompleter(self.sub_folders)
        self.ui.lineEdit.setCompleter(self._completer)

        self._server_status_changed(self.session.server_status)

        self._text_was_empty = True
コード例 #12
0
    def exit_app(self):
        # Refuse to exit if a progress is being run
        for w in QApplication.topLevelWidgets():
            if isinstance(w, ProgressDialog):
                QMessageBox.warning(
                    self,
                    _translate("Cannot exit"),
                    _translate("Cannot exit CryptoLuggage until the current action is completed."))
                return

        sys.exit(0)
コード例 #13
0
 def __show_image_contents(self, *args):
     """Show the frame for previewing image contents
     """
     self.frame_image_contents.setVisible(True)
     qimg = QImage.fromData(self.decrypted_data)
     if qimg.isNull():
         self.label_image_contents.setText(_translate("This file does not look like an image.\n")
                                           + _translate("Maybe try other file type below?"))
     else:
         pixmap = self.__scale_pixmap_to_screen_percentage(QPixmap.fromImage(qimg))
         self.label_image_contents.setPixmap(pixmap)
コード例 #14
0
 def verifyAndAccept(self):
     template_name = self.getTemplateName()
     if template_name in self.template_list:
         ret = QMessageBox.question(
             self, _translate('session template', 'Overwrite Template ?'),
             _translate(
                 'session_template',
                 'Template <strong>%s</strong> already exists.\nOverwrite it ?'
             ) % template_name)
         if ret == QMessageBox.No:
             return
     self.accept()
コード例 #15
0
    def showGuiButton(self):
        self.ui.toolButtonGUI.setVisible(True)
        if self.client.protocol == ray.Protocol.RAY_HACK:
            self.ui.toolButtonGUI.setText(_translate('client_slot', 'Hack'))
            self.ui.toolButtonGUI.setToolTip(
                _translate('client_slot',
                           'Display client Ray-Hack properties'))

        elif self.client.executable_path in ('nsm-proxy', 'ray-proxy'):
            self.ui.toolButtonGUI.setText(_translate('client_slot', 'proxy'))
            self.ui.toolButtonGUI.setToolTip(
                _translate('client_slot', 'Display proxy window'))
コード例 #16
0
    def renameSessionAction(self):
        if not self._session.is_renameable:
            QMessageBox.information(
                self, _translate("rename_session", "Rename Session"),
                _translate(
                    "rename_session",
                    "<p>In order to rename current session,<br>" +
                    "please first stop all clients.<br>" +
                    "then, double click on session name.</p>"))
            return

        self.ui.stackedWidgetSessionName.toggleEdit()
コード例 #17
0
    def ask_where_and_extract_selected_elements(self):
        """Ask the user for a destination folder and
        extract the selected elements to disk
        """
        try:
            selected_nodes = self.get_selected_tree_nodes()

            # Get the target directory from the user
            additional_dialog_options = 0
            if self.pyluggage_config.follow_sym_links:
                additional_dialog_options = QFileDialog.DontResolveSymlinks
            dialog = QFileDialog()
            selected_dir = dialog.getExistingDirectory(
                self,
                _translate("Select a folder where the {} selected items will be extracted".format(
                    len(selected_nodes))),
                "",
                QFileDialog.ShowDirsOnly | additional_dialog_options)
            selected_dir = unicode(selected_dir)
            if selected_dir == "":
                # The user cancelled
                return

            # Computed to give an accurate progress dialog only
            target_file_info_nodes = []
            for node in selected_nodes:
                if node.is_terminal:
                    target_file_info_nodes.append(node)
                else:
                    target_file_info_nodes += node.get_all_files_descendant()
            task_count = len(target_file_info_nodes)
            maximum_progress = sum([fileinfo.original_size_bytes for fileinfo in target_file_info_nodes])
            progress_dialog = ProgressDialog(
                parent=self,
                task_count=task_count,
                maximum_progress=maximum_progress,
                action_name=_translate("Extracting elements..."),
                cancelable=False,
                show_bar=True,
                show_task_count=True)
            progress_dialog.setVisible(True)

            worker = ExtractFilesToDiskWorker(
                files_frame=self,
                node_list=selected_nodes,
                target_path=selected_dir)
            worker.next_element.connect(progress_dialog.next_task)
            worker.finished.connect(progress_dialog.finish)
            worker.start()
            progress_dialog.exec_()
        finally:
            pass
コード例 #18
0
    def open_luggage_query_pass(self, luggage_path):
        """Query the user for a password and open the luggage.
        Emit luggage_opened when successful
        """
        # Query user for password
        try:
            if luggage_path is None or luggage_path == "":
                return
            dialog = QueryPasswordDialog(parent=self, luggage_path=luggage_path)
            dialog.exec_()
            if dialog.accepted_password is None:
                return
            password = unicode(dialog.accepted_password)
            if not luggage.Luggage.is_valid_password(password):
                return

            # Open in background
            progress_dialog = ProgressDialog(
                parent=self,
                action_name=_translate("Opening Luggage"),
                target_name=luggage_path,
                cancelable=False,
                show_bar=False,
                show_task_count=False,
            )
            progress_dialog.setVisible(True)

            worker = OpenLuggageWorker(
                parent=self, path=luggage_path, password=password, pyluggage_config=self.pyluggage_config
            )
            worker.finished.connect(progress_dialog.finish)
            worker.start()

            progress_dialog.exec_()

            if worker.open_luggage is None:
                if worker.error is not None:
                    raise worker.error
                else:
                    raise Exception(_translate("Unknown error opening Luggage"))
            else:
                self.luggage_opened.emit(worker.open_luggage)
        except Exception as ex:
            qmessage = QMessageBox(self)
            qmessage.critical(
                self,
                _translate("Error opening Luggage"),
                _translate(
                    "Error opening the Luggage at '{path}'.\n" "Is the password correct? Is the path valid?"
                ).format(path=luggage_path, message=ex.message),
            )
コード例 #19
0
 def reopen_luggage(self):
     """Handler of the reopen luggage button
     """
     selected_reopen_path = unicode(self.combo_reopen_path.currentText())
     if not os.path.exists(selected_reopen_path):
         dialog = QMessageBox(self)
         dialog.critical(
             self,
             _translate("Error opening Luggage"),
             _translate("Trying to re-open '{path}' but it does not exist!".format(path=selected_reopen_path)),
         )
         self.update_controls()
     else:
         self.open_luggage_query_pass(luggage_path=selected_reopen_path)
コード例 #20
0
    def _change_root_folder(self):
        # construct this here only because it can be quite long
        if self._root_folder_file_dialog is None:
            self._root_folder_file_dialog = QFileDialog(
                self,
                _translate("root_folder_dialogs",
                           "Choose root folder for sessions"),
                CommandLineArgs.session_root)
            self._root_folder_file_dialog.setFileMode(QFileDialog.Directory)
            self._root_folder_file_dialog.setOption(QFileDialog.ShowDirsOnly)
        else:
            self._root_folder_file_dialog.setDirectory(
                CommandLineArgs.session_root)

        self._root_folder_file_dialog.exec()
        if not self._root_folder_file_dialog.result():
            return

        selected_files = self._root_folder_file_dialog.selectedFiles()
        if not selected_files:
            return

        root_folder = selected_files[0]

        # Security, kde dialogs sends $HOME if user type a folder path
        # that doesn't already exists.
        if os.getenv('HOME') and root_folder == os.getenv('HOME'):
            return

        self._root_folder_message_box.setText(
            _translate(
                'root_folder_dialogs',
                "<p>You have no permissions for %s,<br>choose another directory !</p>"
            ) % root_folder)

        if not os.path.exists(root_folder):
            try:
                os.makedirs(root_folder)
            except:
                self._root_folder_message_box.exec()
                return

        if not os.access(root_folder, os.W_OK):
            self._root_folder_message_box.exec()
            return

        RS.settings.setValue('default_session_root', root_folder)
        self.to_daemon('/ray/server/change_root', root_folder)
コード例 #21
0
    def __init__(self, parent, duplicate_window=False):
        ChildDialog.__init__(self, parent)
        self.ui = ui_new_session.Ui_DialogNewSession()
        self.ui.setupUi(self)

        self.is_duplicate = bool(duplicate_window)

        self.ui.currentSessionsFolder.setText(CommandLineArgs.session_root)
        self.ui.toolButtonFolder.clicked.connect(self.changeRootFolder)
        self.ui.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
        self.ui.lineEdit.setFocus(Qt.OtherFocusReason)
        self.ui.lineEdit.textChanged.connect(self.textChanged)

        self.session_list = []
        self.template_list = []
        self.sub_folders = []

        self._signaler.server_status_changed.connect(self.serverStatusChanged)
        self._signaler.add_sessions_to_list.connect(self.addSessionsToList)
        self._signaler.session_template_found.connect(self.addTemplatesToList)
        self._signaler.root_changed.connect(self.rootChanged)

        self.toDaemon('/ray/server/list_sessions', 1)

        if self.is_duplicate:
            self.ui.labelTemplate.setVisible(False)
            self.ui.comboBoxTemplate.setVisible(False)
            self.ui.labelNewSessionName.setText(
                _translate('Duplicate', 'Duplicated session name :'))
            self.setWindowTitle(_translate('Duplicate', 'Duplicate Session'))
        else:
            self.toDaemon('/ray/server/list_session_templates')

        if not self._daemon_manager.is_local:
            self.ui.toolButtonFolder.setVisible(False)
            self.ui.currentSessionsFolder.setVisible(False)
            self.ui.labelSessionsFolder.setVisible(False)

        self.initTemplatesComboBox()
        self.setLastTemplateSelected()

        self.ui.labelSubFolder.setVisible(False)
        self.ui.comboBoxSubFolder.setVisible(False)

        self.server_will_accept = False
        self.text_is_valid = False

        self.serverStatusChanged(self._session.server_status)
コード例 #22
0
    def contextMenuEvent(self, event):
        if not self.itemAt(event.pos()):
            self.setCurrentRow(-1)

            if (self._session and not self._session.server_status
                    in (ray.ServerStatus.OFF, ray.ServerStatus.CLOSE,
                        ray.ServerStatus.OUT_SAVE, ray.ServerStatus.WAIT_USER,
                        ray.ServerStatus.OUT_SNAPSHOT)):
                menu = QMenu()
                fav_menu = QMenu(_translate('menu', 'Favorites'), menu)
                fav_menu.setIcon(QIcon(':scalable/breeze/star-yellow'))

                for favorite in self._session.favorite_list:
                    act_app = fav_menu.addAction(
                        ray.getAppIcon(favorite.icon, self), favorite.name)
                    act_app.setData([favorite.name, favorite.factory])
                    act_app.triggered.connect(self.launchFavorite)

                menu.addMenu(fav_menu)

                menu.addAction(self._session._main_win.ui.actionAddApplication)
                menu.addAction(self._session._main_win.ui.actionAddExecutable)

                act_selected = menu.exec(self.mapToGlobal(event.pos()))
            event.accept()
            return
コード例 #23
0
    def __init__(self,
                 parent, task_count=1, current_task=1,
                 current_progress=0, maximum_progress=0,
                 action_name=_translate("Processing..."), target_name="",
                 cancelable=True, show_bar=True, show_task_count=True):
        self._action_name = action_name
        self._target_name = target_name
        if self._target_name is None:
            self._target_name = ""
        self._task_count = task_count
        self._current_task = current_task
        self._current_progress = current_progress
        self._maximum_progress = maximum_progress
        self._is_cancelled = False
        self.cancelable = cancelable
        self.show_bar = show_bar
        self.show_task_count = show_task_count
        self.is_finished = False

        # Setup GUI
        HideableQDialog.__init__(self, parent)
        self.setupUi(self)
        self.__update_controls()
        self.button_cancel = self.buttonbox.button(QDialogButtonBox.Cancel)
        if not self.cancelable:
            self.button_cancel.setVisible(False)
        self.progressbar.setVisible(show_bar)
        self.label_task_n_of_m.setVisible(show_task_count)
        self.label_loading_icon.setMovie(QMovie(":/pyluggage/img/loading_cube.gif"))
        self.label_loading_icon.movie().start()
        self.adjustSize()
        self.setFixedSize(self.size())

        # Connections
        self.button_cancel.clicked.connect(self.cancel_progress)
コード例 #24
0
    def __update_tags_combo_model(self):
        """Reset and repopulate the tags combobox.
        The 'All tags' element is selected by default.
        """
        previous_selection = (unicode(self.combo_tags.currentText()))

        # Populate the tags combo
        all_tags = []
        for secret in self.secret_list:
            for tag in secret.tags:
                if tag.lower() not in map(unicode.lower, all_tags):
                    all_tags.append(tag)
        all_tags = [unicode(_translate("All tags"))] + sorted(all_tags, key=lambda x:x.lower())
        while self.combo_tags.count() > 0:
            self.combo_tags.removeItem(0)
        for tag in all_tags:
            self.combo_tags.addItem(tag)

        if previous_selection == "":
            self.combo_tags.setCurrentIndex(0)
        else:
            for i in range(self.combo_tags.count()):
                if previous_selection == unicode(self.combo_tags.itemText(i)):
                    self.combo_tags.setCurrentIndex(i)
                    break
コード例 #25
0
 def select_and_insert_folder(self):
     """Insert a new folder in the Luggage (the user selected the path)
     """
     selected_path = unicode(
         QFileDialog.getExistingDirectory(self, _translate("Select the folder to add to the Luggage")))
     if selected_path is not None and os.path.isdir(selected_path):
         self.__insert_paths_into_luggage([selected_path])
コード例 #26
0
    def _get_capacities_line(self):
        capas_en = [c for c in self.client.capabilities.split(':') if c]
        capas_tr = []
        for capa in capas_en:
            if capa == 'switch':
                capa_tr = _translate('capabilities', 'switch')
            elif capa == 'dirty':
                capa_tr = _translate('capabilities', 'dirty')
            elif capa == 'optional-gui':
                capa_tr = _translate('capabilities', 'optional-gui')
            else:
                capa_tr = capa

            capas_tr.append(capa_tr)

        return '\n'.join(capas_tr)
コード例 #27
0
    def _send_notes(self):
        notes = self.ui.plainTextEdit.toPlainText()
        if len(notes) >= 65000:
            self._message_box = QMessageBox(
                QMessageBox.Critical,
                _translate('session_notes', 'Too long notes'),
                _translate(
                    'session_notes',
                    "<p>Because notes are spread to the OSC server,<br>they can't be longer than 65000 characters.<br>Sorry !</p>"
                ), QMessageBox.Cancel, self)
            self._message_box.exec()
            self.ui.plainTextEdit.setPlainText(notes[:64999])
            return

        self.session.notes = notes
        self.to_daemon('/ray/session/set_notes', self.session.notes)
コード例 #28
0
    def __update_controls(self):
        """Display the contents of self.fileinfo_node
        """
        self.setWindowTitle(_translate("Contents of {element_name}").format(element_name=self.fileinfo_node.name))

        # Get the node path string
        path_string = self.fileinfo_node.get_path_string(separator="/", root_node=self.luggage.file_tree_root_node)
        path_string = "Luggage:/" + path_string
        self.label_node_path.setText(path_string)

        # Update the file type combo box
        self.combo_filetype.currentIndexChanged.disconnect(self.__update_filetype)
        filetype_combo_index = self.previewable_file_types.index(self.fileinfo_node.file_type)
        self.combo_filetype.setCurrentIndex(filetype_combo_index)
        self.combo_filetype.currentIndexChanged.connect(self.__update_filetype)

        # Hide all preview frames before showing the valid one
        self.frame_cannot_preview.setVisible(False)
        self.frame_text_contents.setVisible(False)
        self.frame_image_contents.setVisible(False)
        self.frame_pdf_contents.setVisible(False)
        self.frame_multimedia_contents.setVisible(False)

        # Select the correct preview frames and populate it
        global vlc_available
        if self.fileinfo_node.file_type == model.FileInfo.TEXT:
            self.__show_text_contents()
        elif self.fileinfo_node.file_type == model.FileInfo.IMAGE:
            self.__show_image_contents()
        elif self.fileinfo_node.file_type in [model.FileInfo.SOUND, model.FileInfo.VIDEO] and vlc_available:
            self.__show_multimedia_contents()
        elif self.fileinfo_node.file_type == model.FileInfo.PDF:
            self.__show_pdf_contents()
        else:
            self.__show_preview_not_possible()
コード例 #29
0
    def __init__(self, parent, icon_path=locked_icon_path):
        """Initialize the TrayIcon but don't show it
        """
        QSystemTrayIcon.__init__(self, parent)
        self.parent = parent
        self.icon_path = icon_path

        self.is_open_luggage = False
        self.is_luggage_shown = True

        # Populate the menus
        # Menu when a luggage is open
        self.menu_opened_luggage = QMenu(parent)
        self.action_show_hide = self.menu_opened_luggage.addAction("")
        # self.action_close_luggage = self.menu_opened_luggage.addAction(_translate("&Close Luggage"))
        self.action_exit = self.menu_opened_luggage.addAction(_translate("&Exit CryptoLuggage"))
        # Menu hen a luggage is closed
        self.menu_closed_luggage = QMenu(parent)
        self.menu_closed_luggage.addAction(self.action_show_hide)
        self.menu_closed_luggage.addAction(self.action_exit)
        self._update_menu()

        self.activated.connect(self.__process_activated)
        # self.action_show_hide.activated.connect(self.clicked.emit)
        # self.action_close_luggage.activated.connect(self.close_luggage_clicked)
        # self.action_exit.activated.connect(self.exit_clicked)
        self.action_show_hide.triggered.connect(self.clicked.emit)
        # self.action_close_luggage.triggered.connect(self.close_luggage_clicked)
        self.action_exit.triggered.connect(self.exit_clicked)
コード例 #30
0
    def __init__(self, parent, client_id):
        ChildDialog.__init__(self, parent)
        self.ui = ui_stop_client.Ui_Dialog()
        self.ui.setupUi(self)

        self.client_id = client_id
        self.wait_for_save = False

        self.client = self._session.getClient(client_id)

        if self.client:
            text = self.ui.label.text() % self.client.prettierName()

            if not self.client.has_dirty:
                minutes = int((time.time() - self.client.last_save) / 60)
                text = _translate(
                    'client_stop',
                    "<strong>%s</strong> seems to has not been saved for %i minute(s).<br />Do you really want to stop it ?") \
                        % (self.client.prettierName(), minutes)

            self.ui.label.setText(text)

            self.client.status_changed.connect(self.serverUpdatesClientStatus)

        self.ui.pushButtonSaveStop.clicked.connect(self.saveAndStop)
        self.ui.checkBox.stateChanged.connect(self.checkBoxClicked)
コード例 #31
0
    def __init__(self, pyluggage_config, target_path=None, version_string=None, minimize_when_open=False):
        QMainWindow.__init__(self)
        Ui_MainWindow.__init__(self)
        self.pyluggage_config = pyluggage_config
        self.version_string = version_string
        self.setupUi(self)
        gui_tools.center_widget(self)
        self.setWindowIcon(QIcon(":/pyluggage/img/cryptoluggage-logo.png"))

        self.frame_welcome = WelcomeFrame(pyluggage_config=pyluggage_config,  version_string=version_string)
        self.frame_luggage = LuggageFrame(pyluggage_config=pyluggage_config)
        self.verticalLayout.addWidget(self.frame_welcome)
        self.verticalLayout.addWidget(self.frame_luggage)
        self.frame_luggage.hide()

        self.frame_luggage.help_needed.connect(self._open_help)
        self.frame_welcome.luggage_opened.connect(self.display_luggage)
        self.frame_luggage.luggage_closed.connect(self.close_luggage)
        self.frame_welcome.help_needed.connect(self._open_help)

        self.setVisible(True)

        # If available, create a tray icon and a menu
        if QSystemTrayIcon.isSystemTrayAvailable():
            self.tray_icon = TrayIcon.LuggageTrayIcon(parent=self)
            self.tray_icon.clicked.connect(self.__process_tray_icon_click)
            self.tray_icon.close_luggage_clicked.connect(self.close_luggage)
            self.tray_icon.exit_clicked.connect(self.exit_app)
            self.tray_icon.show()
        else:
            self.tray_icon = None

        if target_path is not None:
            if not os.path.isfile(target_path):
                QMessageBox.critical(
                    self,
                    _translate("Luggage does not exist"),
                    _translate("The Luggage at {path} does not exist.\nPlease open manually.".format(
                        path=target_path)))
            else:
                self.frame_welcome.open_luggage_query_pass(luggage_path=target_path)
        else:
            self.close_luggage()

        if minimize_when_open:
            self.__process_tray_icon_click()
コード例 #32
0
 def select_luggage_path(self):
     try:
         selected_path = QFileDialog.getSaveFileName(
             parent=self,
             directory=os.path.expanduser("~"),
             caption=_translate("Where should the Luggage be saved?"),
             filter=_translate("Luggage Files (*{});;All Files (*.*)".format(
                 self.pyluggage_config.default_new_luggage_extension)))
         selected_path = unicode(selected_path)
         if "." not in selected_path:
             selected_path += self.pyluggage_config.default_new_luggage_extension
         if selected_path is not None and selected_path != "":
             self._selected_luggage_path = selected_path
             self.lineedit_password1.setFocus()
         self.update_controls()
     finally:
         self.lineedit_luggage_path.clearFocus()
コード例 #33
0
 def renameSession(self, session_name, session_path):
     if session_name:
         self.setWindowTitle('%s - %s' % (ray.APP_TITLE, session_name))
         self.ui.stackedWidgetSessionName.setText(session_name)
     else:
         self.setWindowTitle(ray.APP_TITLE)
         self.ui.stackedWidgetSessionName.setText(
             _translate('main view', 'No Session Loaded'))
コード例 #34
0
    def __items_moved(self, item_list, target_tree_item):
        # Get the model.TreeNodes contained in the items
        target_tree_node = target_tree_item.data(0, Qt.UserRole).toPyObject()
        if target_tree_node.is_terminal:
            target_tree_node = target_tree_node.parent
        source_items = [i.data(0, Qt.UserRole).toPyObject() for i in item_list]

        # Filter source dirs that are ascendant of the target node
        source_items = [item for item in source_items
                        if item.is_terminal or item not in target_tree_node.get_all_ascendants()]
        # Filter child items if the parent folder is being moved
        source_items = [item for item in source_items
                        if item.parent not in source_items]
        # Filter the target_tree_node
        source_items = [item for item in source_items
                        if item != target_tree_node]
        # Filter source elements that are not really being moved
        source_items = [item for item in source_items
                        if item.parent != target_tree_node]

        save_file_tree = False
        renamed_nodes_list = []
        for source_item in source_items:
            source_item.parent.children.remove(source_item)
            # Avoid name clash
            sibling_names = [c.name for c in target_tree_node.children]
            while source_item.name in sibling_names :
                source_item.name = _translate("moved_") + source_item.name
                if source_item not in renamed_nodes_list:
                    renamed_nodes_list.append(source_item)
            source_item.parent = target_tree_node
            source_item.parent.children.append(source_item)
            save_file_tree = True

        if save_file_tree:
            self.treewidget_files.clearSelection()
            self.__bg_save_file_tree()
            self.set_selected_tree_nodes(source_items)

        if len(renamed_nodes_list) > 0:
            QMessageBox.information(
                self,
                _translate("Renamed elements"),
                _translate("The following elements were renamed to avoid name clash:") + "\n" \
                + "\n".join(["- {}".format(node.name) for node in renamed_nodes_list]))
コード例 #35
0
    def __show_edit_secret_dialog(self):
        """Show the dialog that allows to modify the secret selected in the list.
        An exception is raised if no selection has been made or the selection
        does not correspond to any secret in self.secrets
        """
        selected_secret = self.get_selected_secret()
        if selected_secret is None:
            raise Exception("Could not find a valid selected secret in self.secrets "
                            "(this method should not have been called)")

        # A copy of the selected secret is passed to the dialog, so that changes can be reverted
        secret_copy = model.Secret.copy(selected_secret)
        dialog = EditSecretDialog(parent=self, pyluggage_config=self.pyluggage_config, previous_secret=secret_copy)
        dialog.setModal(True)
        result = dialog.exec_()
        if result == QDialog.Accepted:
            if secret_copy.has_same_data(selected_secret):
                # Don't need to save, no changes have been performed
                return

            # Check that the name did not exist
            if secret_copy.name != selected_secret.name:
                valid_name = False
                while not valid_name:
                    chosen_name = secret_copy.name.strip().lower()
                    matching_secrets = [s for s in self.secret_list if s.name.strip().lower() == chosen_name]
                    if len(matching_secrets) > 0:
                        message = _translate("A secret with the same name already exists.\nPlease provide a unique name:\n")
                        title = _translate("Duplicated secret name")
                        chosen_name, ok = QInputDialog.getText(self, title, message)
                        chosen_name = unicode(chosen_name).strip()
                        if chosen_name == "" or not ok:
                            chosen_name = selected_secret.name
                        if chosen_name == selected_secret.name:
                            valid_name = True
                        secret_copy.name = chosen_name
                    else:
                        valid_name = True

            model.Secret.copy(secret_copy, selected_secret)
            self.secret_list = sorted(self.secret_list, key=lambda s:s.name.lower())
            self.secrets_changed.emit()
            self.__update_tags_combo_model()
            self.__update_listwidget_contents()
            self.select_secret(dialog.accepted_secret)
コード例 #36
0
    def initTemplatesComboBox(self):
        self.ui.comboBoxTemplate.clear()
        self.ui.comboBoxTemplate.addItem(
            _translate('session_template', "empty"))
        self.ui.comboBoxTemplate.addItem(
            _translate('session_template', "with JACK patch memory"))
        self.ui.comboBoxTemplate.addItem(
            _translate('session_template', "with JACK config memory"))
        self.ui.comboBoxTemplate.addItem(
            _translate('session_template', "with basic scripts"))

        misscount = self.ui.comboBoxTemplate.count() - 1 - len(
            ray.factory_session_templates)
        for i in range(misscount):
            self.ui.comboBoxTemplate.addItem(ray.factory_session_templates[-i])

        self.ui.comboBoxTemplate.insertSeparator(
            len(ray.factory_session_templates) + 1)
コード例 #37
0
    def __show_confirm_delete_dialog(self):
        """Show a dialog asking for confirmation to delete the selected secret
        """
        selected_secret = self.get_selected_secret()
        if selected_secret is None:
            raise Exception("Could not find a valid selected secret in self.secrets "
                            "(this method should not have been called)")

        title = unicode(_translate("Delete secret?"))
        message = unicode(_translate("Are you sure that you want to delete the selected secret?<br/>"
                                    "This action cannot be undone."))
        result = QtGui.QMessageBox.question(
            self, title, message, QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No)
        if result == QtGui.QMessageBox.Yes:
            self.secret_list.remove(selected_secret)
            self.secrets_changed.emit()
            self.__update_listwidget_contents()
            self.__update_tags_combo_model()
コード例 #38
0
    def __init__(self, parent):
        ChildDialog.__init__(self, parent)
        self.ui = ui_new_executable.Ui_DialogNewExecutable()
        self.ui.setupUi(self)

        self.ui.groupBoxAdvanced.setVisible(False)
        self.resize(0, 0)
        self.ui.labelPrefixMode.setToolTip(
            self.ui.comboBoxPrefixMode.toolTip())
        self.ui.labelClientId.setToolTip(self.ui.lineEditClientId.toolTip())

        self.ui.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
        self.ui.lineEdit.setFocus(Qt.OtherFocusReason)
        self.ui.lineEdit.textChanged.connect(self.textChanged)

        self.ui.checkBoxProxy.stateChanged.connect(self.proxyStateChanged)

        self.ui.lineEditPrefix.setEnabled(False)
        self.ui.toolButtonAdvanced.clicked.connect(self.showAdvanced)

        self.ui.comboBoxPrefixMode.addItem(
            _translate('new_executable', 'Custom'))
        self.ui.comboBoxPrefixMode.addItem(
            _translate('new_executable', 'Client Name'))
        self.ui.comboBoxPrefixMode.addItem(
            _translate('new_executable', 'Session Name'))
        self.ui.comboBoxPrefixMode.setCurrentIndex(2)

        self.ui.comboBoxPrefixMode.currentIndexChanged.connect(
            self.prefixModeChanged)

        self._signaler.new_executable.connect(self.addExecutableToCompleter)
        self.toDaemon('/ray/server/list_path')

        self.exec_list = []

        self.completer = QCompleter(self.exec_list)
        self.ui.lineEdit.setCompleter(self.completer)

        self.ui.lineEdit.returnPressed.connect(self.closeNow)

        self.serverStatusChanged(self._session.server_status)

        self.text_will_accept = False
コード例 #39
0
    def _init_templates_combo_box(self):
        self.ui.comboBoxTemplate.clear()
        self.ui.comboBoxTemplate.addItem(
            _translate('session_template', "empty"))
        self.ui.comboBoxTemplate.addItem(
            _translate('session_template', "with JACK patch memory"))
        self.ui.comboBoxTemplate.addItem(
            _translate('session_template', "with JACK config memory"))
        self.ui.comboBoxTemplate.addItem(
            _translate('session_template', "with basic scripts"))

        misscount = self.ui.comboBoxTemplate.count() \
                    - 1 - len(ray.FACTORY_SESSION_TEMPLATES)

        for i in range(misscount):
            self.ui.comboBoxTemplate.addItem(ray.FACTORY_SESSION_TEMPLATES[-i])

        self.ui.comboBoxTemplate.insertSeparator(
            len(ray.FACTORY_SESSION_TEMPLATES) + 1)
コード例 #40
0
    def __init__(self, parent):
        ChildDialog.__init__(self, parent)
        self.ui = ui.save_template_session.Ui_DialogSaveTemplateSession()
        self.ui.setupUi(self)

        self._server_will_accept = False
        self._update_template_text = _translate("session template",
                                                "Update the template")
        self._create_template_text = self.ui.pushButtonAccept.text()
        self._overwrite_message_box = QMessageBox(
            QMessageBox.Question,
            _translate('session template', 'Overwrite Template ?'), '',
            QMessageBox.Yes | QMessageBox.No, self)

        self.template_list = []

        self.ui.lineEdit.textEdited.connect(self._text_edited)
        self.ui.pushButtonAccept.clicked.connect(self._verify_and_accept)
        self.ui.pushButtonAccept.setEnabled(False)
コード例 #41
0
 def announceTimerOut(self):
     if self.launched_before:
         self._signaler.daemon_url_request.emit(
             ErrDaemon.NO_ANNOUNCE, self.url)
     else:
         sys.stderr.write(
             _translate(
                 'error',
                 "No announce from ray-daemon. RaySession can't works. Sorry.\n"))
         QApplication.quit()
コード例 #42
0
    def initSubFolderCombobox(self):
        self.ui.comboBoxSubFolder.clear()
        self.ui.comboBoxSubFolder.addItem(_translate('new_session', 'none'))

        for sub_folder in self.sub_folders:
            self.ui.comboBoxSubFolder.addItem(QIcon.fromTheme('folder'),
                                              sub_folder)

        self.ui.labelSubFolder.setVisible(bool(self.sub_folders))
        self.ui.comboBoxSubFolder.setVisible(bool(self.sub_folders))
コード例 #43
0
ファイル: nsm_child.py プロジェクト: BrunoVernay/RaySession
    def announceToParent(self):
        serverNSM = nsm_client.NSMThread.instance()

        if serverNSM:
            serverNSM.announce(
                _translate('network_session', 'Network Session'),
                ':switch:optional-gui:ray-network:', 'ray-network')

            serverNSM.sendToDaemon('/nsm/client/network_properties',
                                   self._session._daemon_manager.url,
                                   self._session._daemon_manager.session_root)
コード例 #44
0
    def create_and_close(self):
        """Create the luggage in the specified path and close if successful
        """
        try:
            progress_dialog = ProgressDialog(
                parent=self,
                action_name=_translate("Creating Luggage..."),
                target_name=self._selected_luggage_path,
                cancelable=False,
                show_bar=False,
                show_task_count=False)
            progress_dialog.setVisible(True)

            password = unicode(self.lineedit_password1.text())
            worker = CreateLuggageWorker(
                parent=self,
                path=self._selected_luggage_path,
                password=password,
                pyluggage_config=self.pyluggage_config)
            worker.finished.connect(progress_dialog.finish)
            worker.start()

            progress_dialog.exec_()
            if worker.new_luggage is None:
                if worker.error is not None:
                    raise worker.error
                else:
                    raise Exception(_translate("Unknown error creating Luggage"))
            else:
                self.new_luggage = worker.new_luggage
                self.close()
        except Exception as ex:
            qmessage = QMessageBox(self)
            qmessage.critical(
                self,
                _translate("Error creating Luggage"),
                _translate(
                    "Error creating luggage at '{path}'.\n"
                    "Message: {message}.\n"
                    "Check that parent folder exists and can be written")
                .format(path=self._selected_luggage_path, message=ex.message))
コード例 #45
0
    def __init__(self, parent, template_name):
        ChildDialog.__init__(self, parent)
        self.ui = ui.remove_template.Ui_Dialog()
        self.ui.setupUi(self)

        self.ui.label.setText(
            _translate(
                'add_app_dialog',
                '<p>Are you sure to want to remove<br>the template "%s" and all its files ?</p>'
            ) % template_name)

        self.ui.pushButtonCancel.setFocus()
コード例 #46
0
    def __update_multimedia_controls(self):
        """Update the multimedia controls depending on whether media are being played or not
        """
        if self.vlc_mediaplayer.is_playing():
            self.button_play_pause.setIcon(QIcon(":/pyluggage/img/pause.png"))
            self.button_play_pause.setText(_translate("Pause"))
            self._timer_multimedia_update.start()
        else:
            self.button_play_pause.setIcon(QIcon(":/pyluggage/img/play.png"))
            self.button_play_pause.setText(_translate("Play"))
            if not self.vlc_mediaplayer.will_play():
                self._timer_multimedia_update.stop()

        if self.vlc_mediaplayer.get_position() <= 0:
            self.slider_multimedia_position.setVisible(False)
        else:
            self.slider_multimedia_position.setVisible(True)
            if not self.vlc_mediaplayer.will_play():
                self.slider_multimedia_position.setValue(self.slider_multimedia_position.minimum())
            else:
                self.slider_multimedia_position.setValue(
                    int(self.vlc_mediaplayer.get_position() * float(self.slider_multimedia_position.maximum())))
コード例 #47
0
    def updateContents(self):
        ClientPropertiesDialog.updateContents(self)
        self.nsmui.labelClientName.setText(self.client.name)
        self.nsmui.lineEditExecutable.setText(self.client.executable_path)
        self.nsmui.lineEditArguments.setText(self.client.arguments)

        capas_en = [c for c in self.client.capabilities.split(':') if c]
        capas_tr = []
        for capa in capas_en:
            if capa == 'switch':
                capa_tr = _translate('capabilities', 'switch')
            elif capa == 'dirty':
                capa_tr = _translate('capabilities', 'dirty')
            elif capa == 'optional-gui':
                capa_tr = _translate('capabilities', 'optional-gui')
            else:
                capa_tr = capa

            capas_tr.append(capa_tr)

        capa_line = '\n'.join(capas_tr)
        self.nsmui.labelCapabilities.setText(capa_line)
コード例 #48
0
 def __show_new_secret_dialog(self):
     """Show the dialog that allows to create a new secret
     """
     dialog = EditSecretDialog(parent=self, pyluggage_config=self.pyluggage_config)
     dialog.setModal(True)
     if self.combo_tags.currentIndex() != 0:
         dialog.lineedit_tags.setText(self.combo_tags.currentText())
     result = dialog.exec_()
     if result == QDialog.Accepted:
         matching_secrets = [s for s in self.secret_list
                             if s.name.strip().lower() == dialog.accepted_secret.name.strip().lower()]
         if len(matching_secrets) > 0:
             # A secret with the same name existed: merge or ignore
             message = _translate("A secret with the same name already exists.\nMerge into the existing secret or discard the new secret?")
             title = _translate("Duplicated secret name")
             reply = QMessageBox.question(
                 self, title, message,
                  QMessageBox.Save, QMessageBox.Discard)
             if reply == QMessageBox.Save:
                 matching_secrets[0].merge(dialog.accepted_secret)
                 self.__update_listwidget_contents()
                 self.__update_tags_combo_model()
                 self.select_secret(matching_secrets[0])
                 self.secrets_changed.emit()
             if len(matching_secrets) > 1:
                 raise Exception("Warning! More than one match for the new secret {} found: {}".format(
                     dialog.accepted_secret, map(str, matching_secrets)))
         else:
             # Add the secret to the list
             self.secret_list.append(dialog.accepted_secret)
             self.secret_list = sorted(self.secret_list, key=lambda s:s.name.strip().lower())
             self.secrets_changed.emit()
             self.__update_tags_combo_model()
             self.__update_listwidget_contents()
             try:
                 self.select_secret(dialog.accepted_secret)
             except KeyError:
                 # The new item was filtered out, no problem
                 pass
コード例 #49
0
    def _announce_to_parent(self):
        server_nsm = nsm_client.NSMThread.instance()

        if server_nsm:
            server_nsm.announce(
                _translate('network_session', 'Network Session'),
                ':switch:optional-gui:ray-network:', ray.RAYNET_BIN)

            server_nsm.sendToDaemon(
                '/nsm/client/network_properties',
                self.session.daemon_manager.url,
                self.session.daemon_manager.session_root)
        self.session.main_win.hide()
コード例 #50
0
 def select_luggage_and_open(self):
     """Handler of the open luggage button
     """
     selected_path = QFileDialog.getOpenFileName(
         parent=self,
         directory=os.path.expanduser("~"),
         caption=_translate("Open existing Luggage"),
         filter=_translate("Luggage Files (*.lug);;All Files (*.*)"),
     )
     if selected_path is not None and selected_path != "":
         selected_path = unicode(selected_path)
         try:
             if not os.path.exists(selected_path):
                 raise IOError(_translate("Path {} does not exist or cannot be read.").format(selected_path))
             self.open_luggage_query_pass(luggage_path=selected_path)
         except IOError as ex:
             qmessage = QMessageBox(self)
             qmessage.critical(
                 self,
                 _translate("Error opening Luggage"),
                 _translate("Could not open luggage at '{}'.\nCheck path and password.".format(selected_path)),
             )
コード例 #51
0
    def __init__(self, parent, client):
        ClientPropertiesDialog.__init__(self, parent, client)

        self.ray_hack_frame = QFrame()
        self.rhack = ui_ray_hack_properties.Ui_Frame()
        self.rhack.setupUi(self.ray_hack_frame)

        self.config_file = ""

        self.ui.verticalLayoutProtocol.addWidget(self.ray_hack_frame)

        self.ui.tabWidget.setTabText(1, 'Ray-Hack')
        self.rhack.labelWorkingDir.setText(self.getWorkDirBase())
        self.rhack.toolButtonBrowse.setEnabled(self._daemon_manager.is_local)

        self.rhack.toolButtonBrowse.clicked.connect(self.browseConfigFile)
        self.rhack.lineEditExecutable.textEdited.connect(
            self.lineEditExecutableEdited)
        self.rhack.lineEditArguments.textChanged.connect(
            self.lineEditArgumentsChanged)
        self.rhack.lineEditConfigFile.textChanged.connect(
            self.lineEditConfigFileChanged)

        self.rhack.pushButtonStart.clicked.connect(self.startClient)
        self.rhack.pushButtonStop.clicked.connect(self.stopClient)
        self.rhack.pushButtonSave.clicked.connect(self.saveClient)

        self.rhack.comboSaveSig.addItem(_translate('ray_hack', 'None'), 0)
        self.rhack.comboSaveSig.addItem('SIGUSR1', 10)
        self.rhack.comboSaveSig.addItem('SIGUSR2', 12)
        self.rhack.comboSaveSig.currentIndexChanged.connect(
            self.currentSaveSigChanged)

        self.rhack.comboStopSig.addItem('SIGTERM', 15)
        self.rhack.comboStopSig.addItem('SIGINT', 2)
        self.rhack.comboStopSig.addItem('SIGHUP', 1)
        self.rhack.comboStopSig.addItem('SIGKILL', 9)

        self.rhack.checkBoxTellUser.stateChanged.connect(
            self.rhack.checkBoxCloseGracefully.setEnabled)

        self.rhack.labelError.setVisible(False)
        self.rhack.pushButtonStart.setEnabled(False)
        self.rhack.pushButtonStop.setEnabled(False)
        self.rhack.pushButtonSave.setEnabled(False)

        self.rhack.groupBoxNoSave.setEnabled(False)

        self.rhack.groupBoxTestZone.setChecked(False)
        self.rhack.groupBoxTestZone.toggled.connect(
            self.rhack.frameTestZone.setEnabled)
コード例 #52
0
 def run_optimization_with_progress_dialog(parent, luggage, message=_translate("Compacting Luggage")):
     progress_dialog = ProgressDialog(
         parent=parent,
         task_count=1,
         maximum_progress=100,
         action_name=message,
         cancelable=False,
         show_bar=False,
         show_task_count=False)
     progress_dialog.setVisible(True)
     worker = CompactLuggageWorker(parent=parent, luggage=luggage)
     worker.finished.connect(progress_dialog.finish)
     worker.start()
     progress_dialog.exec_()
コード例 #53
0
    def __update_controls(self):
        """Update the contents of the controls according to the local variables
        """
        if self.cancelable and self.is_cancelled:
            self.button_cancel.setEnabled(False)
            self.button_cancel.setText(_translate("Cancelling..."))
            self.setWindowTitle(_translate("Cancelling..."))
            self.progressbar.setEnabled(False)
        else:
            title = self.action_name
            if self.show_bar:
                if self.maximum_progress == 0:
                    progress_percentage = 100*(self.current_task-1)/float(max(1, self.task_count))
                else:
                    progress_percentage = 100*(self.current_progress)/float(max(1, self.maximum_progress))
                title = "({:.0f}%) ".format(progress_percentage) + title
            if self.target_name.strip() != "":
                title += u" {}".format(self.target_name.strip())
            if self.show_task_count:
                title += " [Task {}/{}]".format(
                    min(self.task_count, self.current_task),
                    self.task_count)
            if not title.endswith("..."):
                title += "..."
            self.setWindowTitle(title)

        if self.maximum_progress == 0:
            self.progressbar.setMaximum(self.task_count)
            self.progressbar.setValue(self.current_task - 1)
        else:
            self.progressbar.setMaximum(self.maximum_progress)
            self.progressbar.setValue(self.current_progress)
        self.label_task_n_of_m.setText(_translate("Task {current}/{total}".format(
            current=min(self.task_count, self.current_task),
            total=self.task_count)))
        self.label_action.setText(self.action_name)
        self.label_target.setText(self.target_name)
コード例 #54
0
    def select_and_insert_file(self):
        """Insert a new file in the luggage (the user selects the path in a file selection widget)
        """
        dialog = QFileDialog(self)
        dialog.setFileMode(QFileDialog.ExistingFiles)
        dialog.setWindowTitle(_translate("Select files to insert"))
        dialog.exec_()

        selected_files = []
        for path in map(unicode, dialog.selectedFiles()):
            if os.path.islink(path) and not self.pyluggage_config.follow_sym_links:
                continue
            selected_files.append(path)

        self.__insert_paths_into_luggage(selected_files)
コード例 #55
0
    def _verify_and_accept(self):
        template_name = self.get_template_name()
        if template_name in self.template_list:
            self._overwrite_message_box.setText(
                _translate(
                    'session_template',
                    'Template <strong>%s</strong> already exists.\nOverwrite it ?'
                ) % template_name)

            self._overwrite_message_box.exec()

            if (self._overwrite_message_box.clickedButton() ==
                    self._overwrite_message_box.button(QMessageBox.No)):
                return
        self.accept()
コード例 #56
0
    def _update_history_save_configuration(self):
        """Called when the state of self.check_remember_history is changed,
        so that the pyluggage_config is updated
        """
        is_checked = self.check_remember_history.isChecked()

        # Confirm if there is a history to delete
        if not is_checked and len(self.pyluggage_config.opened_history) > 0:
            confirmed = (
                QMessageBox.question(
                    self,
                    _translate("Delete history?"),
                    _translate("Disabling the history of opened Luggages will delete it. Continue?"),
                    QMessageBox.Yes,
                    QMessageBox.No,
                )
                == QMessageBox.Yes
            )
            if not confirmed:
                self.check_remember_history.setChecked(True)
                return

        self.pyluggage_config.set_save_history(save_history=is_checked)
        self.update_controls()
コード例 #57
0
    def changeRootFolder(self):
        root_folder = QFileDialog.getExistingDirectory(
            self,
            _translate("root_folder_dialogs",
                       "Choose root folder for sessions"),
            CommandLineArgs.session_root, QFileDialog.ShowDirsOnly)

        if not root_folder:
            return

        # Security, kde dialogs sends $HOME if user type a folder path
        # that doesn't already exists.
        if os.getenv('HOME') and root_folder == os.getenv('HOME'):
            return

        errorDialog = QMessageBox(
            QMessageBox.Critical,
            _translate('root_folder_dialogs', 'unwritable dir'),
            _translate(
                'root_folder_dialogs',
                '<p>You have no permissions for %s,<br>' % root_folder \
                    + 'choose another directory !</p>'))

        if not os.path.exists(root_folder):
            try:
                os.makedirs(root_folder)
            except:
                errorDialog.exec()
                return

        if not os.access(root_folder, os.W_OK):
            errorDialog.exec()
            return

        RS.settings.setValue('default_session_root', root_folder)
        self.toDaemon('/ray/server/change_root', root_folder)
コード例 #58
0
    def preview_selected_elements(self):
        """Preview the fileinfo element(s) selected in the TreeWidget.ç
        Note: any folder node is ignored
        """
        selected_files = self.get_selected_files()

        # Avoid showing too many dialogs
        if len(selected_files) > self.pyluggage_config.maximum_unconfirmed_elements_to_show \
                and self.pyluggage_config.maximum_unconfirmed_elements_to_show >= 0:
            response = QMessageBox.question(self,
                                            _translate("Show {element_count} elements?").format(
                                                element_count=len(selected_files)),
                                            _translate(
                                                "Are you sure you want to preview {element_count} elements?\nIt may take a while...".format(
                                                    element_count=len(selected_files))),
                                            QMessageBox.Yes, QMessageBox.No)
            if response == QMessageBox.No:
                return

        # Let the dialog handle how the items should be displayed
        need_to_save_filetree = False
        for node in selected_files:
            dialog = DialogShowContents(parent=self, fileinfo_node=node, luggage=self.luggage)
            dialog.setModal(True)
            dialog.exec_()
            need_to_save_filetree = need_to_save_filetree or dialog.is_metainfo_modified
            if dialog.are_contents_modified:
                need_to_save_filetree = True
                # TODO: Implement the possibility of editing contents within the preview dialog
                print "[FilesFrame.preview_selected_elements] some contents were modified, " \
                      "but content updating is not supported yet."
            dialog.close()
            del(dialog)
        if need_to_save_filetree:
            self.luggage.save_file_tree()
            self.treewidget_files.clearSelection()
コード例 #59
0
 def getInstanceAndMediaPlayerWithProgressDialog(parent):
     progress_dialog = ProgressDialog(
         parent=parent,
         task_count=1,
         maximum_progress=100,
         action_name=_translate("Loading Multimedia Player"),
         cancelable=False,
         show_bar=False,
         show_task_count=False)
     progress_dialog.setVisible(True)
     worker = WorkerGetVLCInstance()
     worker.finished.connect(progress_dialog.finish)
     worker.start()
     progress_dialog.exec_()
     return worker.vlc_instance, worker.vlc_mediaplayer
コード例 #60
0
 def getQImageListFromPDFWithProgressDialog(parent, pdf_data):
     """Obtain a list of QImage instances, one per page of the pdf_data (byte string) as argument
     """
     progress_dialog = ProgressDialog(
         parent=parent,
         action_name=_translate("Loading PDF Contents"),
         cancelable=False,
         show_bar=False,
         show_task_count=False)
     progress_dialog.setVisible(True)
     worker = WorkerGetQImageListFromPDF(pdf_data)
     worker.finished.connect(progress_dialog.finish)
     worker.start()
     progress_dialog.exec_()
     return worker.pdf_image_list