def doubleClickedCB(self, model_index):
        """Double click handler for the property table"""

        # Get translation object
        _ = get_app()._tr

        # Get data model and selection
        model = self.clip_properties_model.model

        row = model_index.row()
        selected_label = model.item(row, 0)
        self.selected_item = model.item(row, 1)

        if selected_label:
            cur_property = selected_label.data()
            property_type = cur_property[1]["type"]

            if property_type == "color":
                # Get current value of color
                red = cur_property[1]["red"]["value"]
                green = cur_property[1]["green"]["value"]
                blue = cur_property[1]["blue"]["value"]

                # Show color dialog
                currentColor = QColor(red, green, blue)
                log.debug("Launching ColorPicker for %s", currentColor.name())
                ColorPicker(
                    currentColor, parent=self, title=_("Select a Color"),
                    callback=self.color_callback)
                return

            elif property_type == "font":
                # Get font from user
                current_font_name = cur_property[1].get("memo", "sans")
                current_font = QFont(current_font_name)
                font, ok = QFontDialog.getFont(current_font, caption=("Change Font"))

                # Update font
                if ok and font:
                    fontinfo = QFontInfo(font)
                    # TODO: pass font details to value_updated so we can set multiple values
                    font_details = { "font_family": fontinfo.family(),
                                     "font_style": fontinfo.styleName(),
                                     "font_weight": fontinfo.weight(),
                                     "font_size_pixel": fontinfo.pixelSize() }
                    self.clip_properties_model.value_updated(self.selected_item, value=fontinfo.family())
Beispiel #2
0
 def reportCodeViewerProperties(self, font):
     wposition = self.pos()
     font_info = QFontInfo(font)
     print("---------- Code Viewer Report ----------")
     print("Size: width: %d, height: %d" % (self.width, self.height))
     print("Top-Left position in screen: (%d, %d)" %
           (wposition.x(), wposition.y()))
     print("Top-Right position in screen: (%d, %d)" %
           (wposition.x() + self.width, wposition.y()))
     print("Bottom-Left position in screen: (%d, %d)" %
           (wposition.x(), wposition.y() + self.height))
     print("Bottom-Right position in screen: (%d, %d)" %
           (wposition.x() + self.width, wposition.y() + self.height))
     print("---------- Side Bar    Report ----------")
     print("Size: width: %d, height: %d" %
           (self.listWidth, self.editorHeight))
     print("Top-Left position in screen: (%d, %d)" %
           (wposition.x(), wposition.y()))
     print("Top-Right position in screen: (%d, %d)" %
           (wposition.x() + self.listWidth, wposition.y()))
     print("Bottom-Left position in screen: (%d, %d)" %
           (wposition.x(), wposition.y() + self.editorHeight))
     print("Bottom-Right position in screen: (%d, %d)" %
           (wposition.x() + self.listWidth,
            wposition.y() + self.editorHeight))
     print("---------- Code Editor Report ----------")
     print("Size: width: %d, height: %d" %
           (self.editorWidth, self.editorHeight))
     print("Margins: %f pixels" % self.editor.document().documentMargin())
     print("Top-Left position in screen: (%d, %d)" %
           (wposition.x() + self.listWidth, wposition.y()))
     print(
         "Top-Right position in screen: (%d, %d)" %
         (wposition.x() + self.listWidth + self.editorWidth, wposition.y()))
     print("Bottom-Left position in screen: (%d, %d)" %
           (wposition.x() + self.listWidth,
            wposition.y() + self.editorHeight))
     print("Bottom-Right position in screen: (%d, %d)" %
           (wposition.x() + self.listWidth + self.editorWidth,
            wposition.y() + self.editorHeight))
     print("Padding: left: %d, top: %d, bottom: %d, right: %d" %
           (self.padding_left, self.padding_top, self.padding_bottom,
            self.padding_right))
     print("---------- Font report (font) ----------")
     print("font family: %s" % font.family())
     print("font pixelSize: %f" % font.pixelSize())
     print("font pointSize: %f" % font.pointSize())
     print("font pointSizeF: %f" % font.pointSizeF())
     print("QFont.pixelSize(): %f" % font.pixelSize())
     print("---------- QFontInfo   (font) ----------")
     print("family(): %s" % font_info.family())
     print("pixelSize(): %f" % font_info.pixelSize())
     print("pointSize(): %f" % font_info.pointSize())
     print("pointSizeF(): %f" % font_info.pointSizeF())
     print("QFontInfo.pixelSize(): %d" % font_info.pixelSize())
     print("---------- QFontMetrics (font) ---------")
     print("QFontMetrics.lineSpacing(): %f" %
           QFontMetrics(font).lineSpacing())
     print("QFontMetrics.leading(): %f" % QFontMetrics(font).leading())
     print("QFontMetrics.height(): %f" % QFontMetrics(font).height())
     print("---------- Eye tracking area  ----------")
     x1 = wposition.x() + self.listWidth + self.padding_left
     y1 = wposition.y() + self.padding_top
     x2 = wposition.x(
     ) + self.listWidth + self.editorWidth - self.padding_right
     y2 = wposition.y() + self.editorHeight - self.padding_bottom
     self.editor.x_offset = x1  # For the eye tracker, as it uses the entire screen
     self.editor.y_offset = y1  # For the eye tracker, as it uses the entire screen
     self.editor.most_right_x = x2
     self.editor.most_bottom_y = y2
     print("Size: width: %d, height: %d" % (x2 - x1, y2 - y1))
     print("Top-Left position in screen: (%d, %d)" % (x1, y1))
     print("Top-Right position in screen: (%d, %d)" % (x2, y1))
     print("Bottom-Left position in screen: (%d, %d)" % (x1, y2))
     print("Bottom-Right position in screen: (%d, %d)" % (x2, y2))
     print("x_offset = %d" % x1)
     print("y_offset = %d" % y1)
     print("---------- Status Bar  Report ----------")
     print("Size: width: %d, height: %d" %
           (self.width, self.status_bar_height))
     print("Top-Left position in screen: (%d, %d)" %
           (wposition.x(), wposition.y() + self.editorHeight))
     print("Top-Right position in screen: (%d, %d)" %
           (wposition.x() + self.width, wposition.y() + self.editorHeight))
     print("Bottom-Left position in screen: (%d, %d)" %
           (wposition.x(),
            wposition.y() + self.editorHeight + self.status_bar_height))
     print("Bottom-Right position in screen: (%d, %d)" %
           (wposition.x() + self.width,
            wposition.y() + self.editorHeight + self.status_bar_height))
     print("----------------------------------------")