Esempio n. 1
0
    def __init__(self, parent):
        """
        Construction

        :param parent:  The parent QWidget for this form
        """
        QtGui.QWidget.__init__(self, parent)

        self._current_file = None

        # create a single instance of the task manager that manages all
        # asynchrounous work/tasks.
        self._bg_task_manager = BackgroundTaskManager(self, max_threads=8)
        monitor_qobject_lifetime(self._bg_task_manager, "Main task manager")
        self._bg_task_manager.start_processing()

        shotgun_globals.register_bg_task_manager(self._bg_task_manager)

        # build the various models:
        self._my_tasks_model = self._build_my_tasks_model()
        self._entity_models = self._build_entity_models()
        self._file_model = self._build_file_model()

        # add refresh action with appropriate keyboard shortcut:
        refresh_action = QtGui.QAction("Refresh", self)
        refresh_action.setShortcut(QtGui.QKeySequence(QtGui.QKeySequence.Refresh))
        refresh_action.triggered.connect(self._on_refresh_triggered)
        self.addAction(refresh_action)

        # on OSX, also add support for F5 (the default for OSX is Cmd+R)
        if sys.platform == "darwin":
            osx_f5_refresh_action = QtGui.QAction("Refresh (F5)", self)
            osx_f5_refresh_action.setShortcut(QtGui.QKeySequence(QtCore.Qt.Key_F5))
            osx_f5_refresh_action.triggered.connect(self._on_refresh_triggered)
            self.addAction(osx_f5_refresh_action)
Esempio n. 2
0
    def __init__(self):
        """
        Constructor
        """
        # get app bundle
        self._app = sgtk.platform.current_bundle()
        # call the base class and let it do its thing.
        QtGui.QWidget.__init__(self)

        # # Set up our own logger (other than shotgun logger) for storing timestamp
        # self.set_logger(logging.INFO)
        # now load in the UI that was created in the UI designer
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)
        self.current_project = self._app.context.project['name']

        # create a background task manager
        self._task_manager = task_manager.BackgroundTaskManager(
            self, start_processing=True, max_threads=4)
        monitor_qobject_lifetime(self._task_manager, "Main task manager")
        self._task_manager.start_processing()

        # lastly, set up our very basic UI
        self.user = sgtk.util.get_current_user(self._app.sgtk)
        # self.ui.textBrowser.setText("Hello, %s!" % self.user['firstname'])
        # create my tasks form and my time form:
        self.createTasksForm()
        self.createManagementForm()
        self.createTimeForm()
        self.createTimelogTable()
        # time summary labels
        self._get_time_sum()
        self.ui.time_sum_label.setFont(QtGui.QFont("Arial", 80))

        # add refresh action with appropriate keyboard shortcut:
        refresh_action = QtGui.QAction("Refresh", self)
        refresh_action.setShortcut(
            QtGui.QKeySequence(QtGui.QKeySequence.Refresh))
        refresh_action.triggered.connect(self._on_refresh_triggered)
        self.addAction(refresh_action)
        # on OSX, also add support for F5 (the default for OSX is Cmd+R)
        if sys.platform == "darwin":
            osx_f5_refresh_action = QtGui.QAction("Refresh (F5)", self)
            osx_f5_refresh_action.setShortcut(
                QtGui.QKeySequence(QtCore.Qt.Key_F5))
            osx_f5_refresh_action.triggered.connect(self._on_refresh_triggered)
            self.addAction(osx_f5_refresh_action)
Esempio n. 3
0
    def __init__(self, parent=None):
        super(Console, self).__init__(parent)

        self.setWindowTitle('Shotgun Desktop Console')
        self.setWindowIcon(QtGui.QIcon(":/tk-desktop/default_systray_icon.png"))

        self.__logs = QtGui.QPlainTextEdit()
        self.__find = QtGui.QLineEdit()
        self.__find_label = QtGui.QLabel()
        layout = QtGui.QVBoxLayout()
        find_layout = QtGui.QHBoxLayout()
        layout.addWidget(self.__logs)
        layout.addLayout(find_layout)
        find_layout.addStretch()
        find_layout.addWidget(self.__find)
        find_layout.addWidget(self.__find_label)
        self.setLayout(layout)

        # configure the text widget
        self.__logs.setReadOnly(True)
        self.__logs.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.__logs.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)
        self.__logs.customContextMenuRequested.connect(self.on_logs_context_menu_request)
        self.__logs.setStyleSheet("QPlainTextEdit:focus { border: none; }")
        # configure the find area
        self.__find.setPlaceholderText("Find")
        self.__find_label.setText("No Results")
        self.__find_label.setFixedWidth(60)
        self.__find.returnPressed.connect(self.find)
        self.__pattern = ""
        self.__match_index = 0
        self.__matches = []
        # set shortcut
        find_shortcut = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+F"), self)
        find_shortcut.activated.connect(self.focus_find)
        # load up previous size
        self._settings_manager = settings.UserSettings(sgtk.platform.current_bundle())
        pos = self._settings_manager.retrieve("console.pos", self.pos(), self._settings_manager.SCOPE_GLOBAL)
        size = self._settings_manager.retrieve(
            "console.size", QtCore.QSize(800, 400), self._settings_manager.SCOPE_GLOBAL)

        self.move(pos)
        self.resize(size)

        self.__console_handler = ConsoleLogHandler(self)
        sgtk.LogManager().initialize_custom_handler(self.__console_handler)
Esempio n. 4
0
    def add_command_to_menu(self, menu):
        """
        Add a new QAction representing this AppCommand to a given QMenu.
        """
        from sgtk.platform.qt import QtGui
        action = menu.addAction(self.name)

        key_sequence = self.properties.get("hotkey")
        if key_sequence:
            action.setShortcut(QtGui.QKeySequence(key_sequence))

        icon_path = self.properties.get("icon")
        if icon_path:
            icon = QtGui.QIcon(icon_path)
            if not icon.isNull():
                action.setIcon(icon)

        # Wrap to avoid passing args
        action.triggered.connect(lambda: self.callback())
        return action
Esempio n. 5
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)

        self._ui = Ui_CrashDbgForm()
        self._ui.setupUi(self)

        refresh_action = QtGui.QAction("Refresh", self)
        refresh_action.setShortcut(
            QtGui.QKeySequence(QtGui.QKeySequence.Refresh))
        refresh_action.triggered.connect(self._on_refresh_triggered)
        self.addAction(refresh_action)

        # create model:
        self._model = QtGui.QStandardItemModel()
        self._ui.tree_view.setModel(self._model)
        self._ui.list_view.setModel(self._model)

        # create sg query threads:
        self._sg_runner_threads = []
        self._sg_runner_threads.append(SgRunner())
        self._sg_runner_threads.append(SgRunner())
        self._sg_runner_threads.append(SgRunner())
        for thread in self._sg_runner_threads:
            thread.start()
    def __init__(self, parent=None):
        """Initialize the input widget.

        :param echo: bool, echo input if True.
        :param parent: The parent widget.
        """

        super(PythonInputWidget, self).__init__(parent)

        # local symbol table for this input widget.
        self._locals = {}
        self._echo = True
        self._show_line_numbers = True

        # helps prevent unnecessary redraws of the line number area later.
        # See the Qt docs example for line numbers in text edit widgets:
        # http://doc.qt.io/qt-4.8/qt-widgets-codeeditor-example.html
        self._count_cache = {"blocks": None, "cursor_blocks": None}

        self.setTextInteractionFlags(QtCore.Qt.TextEditorInteraction)
        self.setWordWrapMode(QtGui.QTextOption.NoWrap)

        # action to trigger execution of the current code
        self.execute_action = QtGui.QAction('Execute', self)
        self.execute_action.setShortcut(QtGui.QKeySequence("Ctrl+Return"))
        self.addAction(self.execute_action)

        # these are used to redirect stdout/stderr to the signals
        self._stdout_redirect = StdoutRedirector()
        self._stderr_redirect = StderrRedirector()
        self._stdin_redirect = StdinRedirector(self._readline)

        self._syntax_highlighter = PythonSyntaxHighlighter(
            self.document(), self.palette())
        self._syntax_highlighter.setDocument(self.document())

        self._line_number_area = _LineNumberArea(self)

        # ---- connect signals/slots

        self.execute_action.triggered.connect(self.execute)

        # redirect any stdout to the output signal
        self._stdout_redirect.output.connect(self.output.emit)

        # redirect any stderr to the error signal
        self._stderr_redirect.error.connect(self.error.emit)

        # make sure the current line is always highlighted
        self.cursorPositionChanged.connect(self.highlight_current_line)

        self.cursorPositionChanged.connect(
            lambda: self.cursor_column_changed.emit(self.textCursor().
                                                    columnNumber() + 1))

        # keep line numbers updated
        self.blockCountChanged.connect(self._update_line_number_area_width)
        self.updateRequest.connect(self._update_line_number_area)

        # ---- initialize the state

        # go ahead and highlight the current line
        self.highlight_current_line()

        # initialize the line number area
        self._update_line_number_area_width(0)