Esempio n. 1
0
 def sizeHint(self):
     # pylint: disable=invalid-name,missing-docstring
     return QSize(self.code_editor.line_number_area_width(), 0)
Esempio n. 2
0
 def sizeHint(self):
     w, h = self.get_width_height()
     return QSize(w, h)
Esempio n. 3
0
    def __init__(self, myserver, status_bar, scan_root_dir, sim_name):
        QWidget.__init__(self)
        self.main_vbox = QVBoxLayout()

        self.tokens = tokens()
        self.sim_name = sim_name
        self.myserver = myserver
        self.status_bar = status_bar
        self.param_list = scan_items_get_list()
        #self.tab_label=tab_label

        self.sim_dir = os.path.join(scan_root_dir, sim_name)

        toolbar = QToolBar()
        toolbar.setIconSize(QSize(32, 32))

        self.tb_add = QAction(icon_get("list-add"), _("Add parameter to scan"),
                              self)
        self.tb_add.triggered.connect(self.callback_add_item)
        toolbar.addAction(self.tb_add)

        self.tb_minus = QAction(icon_get("list-remove"), _("Delete item"),
                                self)
        self.tb_minus.triggered.connect(self.callback_delete_item)
        toolbar.addAction(self.tb_minus)

        self.tb_down = QAction(icon_get("go-down"), _("Move down"), self)
        self.tb_down.triggered.connect(self.callback_move_down)
        toolbar.addAction(self.tb_down)

        self.tb_up = QAction(icon_get("go-up"), _("Move up"), self)
        self.tb_up.triggered.connect(self.callback_move_up)
        toolbar.addAction(self.tb_up)

        #self.tb_notes = QAction(icon_get("go-down.png"), _("Notes"), self)
        #self.tb_notes.triggered.connect(self.callback_notes)
        #toolbar.addAction(self.tb_notes)

        #self.tb_notes = QAction(icon_get("select"), _("Select parameter to change"), self)
        #self.tb_notes.triggered.connect(self.callback_show_list)
        #toolbar.addAction(self.tb_notes)

        self.tb_command = QAction(icon_get("utilities-terminal"),
                                  _("Insert python command"), self)
        self.tb_command.triggered.connect(self.callback_insert_command)
        toolbar.addAction(self.tb_command)

        self.main_vbox.addWidget(toolbar)

        self.tab = QTableWidget()
        #self.tab.resizeColumnsToContents()

        self.tab.verticalHeader().setVisible(False)

        self.tab.setColumnCount(5)
        #if enable_betafeatures()==False:
        #	self.tab.setColumnHidden(0, True)
        #	self.tab.setColumnHidden(1, True)

        self.tab.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.tab.setColumnWidth(2, 300)
        self.tab.setColumnWidth(3, 200)
        self.load()

        self.tab.cellChanged.connect(self.tab_changed)

        self.main_vbox.addWidget(self.tab)

        self.popMenu = QMenu(self)

        #self.mp_show_list=QAction(_("Select parameter to scan"), self)
        #self.mp_show_list.triggered.connect(self.callback_show_list)
        #self.popMenu.addAction(self.mp_show_list)

        self.popMenu.addSeparator()

        self.mp_delete = QAction(_("Delete item"), self)
        self.mp_delete.triggered.connect(self.callback_delete_item)
        self.popMenu.addAction(self.mp_delete)

        self.mp_copy = QAction(_("Copy"), self)
        self.mp_copy.triggered.connect(self.callback_copy_item)
        self.popMenu.addAction(self.mp_copy)

        self.mp_paste = QAction(_("Paste"), self)
        self.mp_paste.triggered.connect(self.callback_paste_item)
        self.popMenu.addAction(self.mp_paste)

        self.popMenu.addSeparator()

        self.mp_add = QAction(_("Add item"), self)
        self.mp_add.triggered.connect(self.callback_add_item)
        self.popMenu.addAction(self.mp_add)

        self.mp_down = QAction(_("Move down"), self)
        self.mp_down.triggered.connect(self.callback_move_down)
        self.popMenu.addAction(self.mp_down)

        self.mp_down = QAction(_("Move down"), self)
        self.mp_down.triggered.connect(self.callback_move_down)
        self.popMenu.addAction(self.mp_down)

        self.popMenu.addSeparator()
        self.setMinimumSize(700, 500)

        self.setLayout(self.main_vbox)
Esempio n. 4
0
 def sizeHint(self, option, index):
     return QSize(self.pixelSize, self.pixelSize)
Esempio n. 5
0
    def initUI(self):
        self.centralFrame = QFrame(self)
        self.centralFrame.setFrameShape(QFrame.NoFrame)
        self.centralFrame.setFrameShadow(QFrame.Raised)
        self.centralFrame.setMinimumSize(QSize(0, 25))
        self.centralFrame.setMaximumSize(QSize(16777215, 25))
        self.centralFrame.setContentsMargins(0, 0, 0, 0)
        self.centralFrame.setStyleSheet(u"background-color: rgb(27, 29, 35);")

        self.labelsFrame = QFrame(self.centralFrame)
        self.labelsFrame.setFrameShape(QFrame.NoFrame)
        self.labelsFrame.setFrameShadow(QFrame.Raised)
        self.labelsFrame.setContentsMargins(0, 0, 0, 0)
        self.labelsFrame.setStyleSheet("border: none;")

        self.developerLabel = Label(self.labelsFrame)
        self.developerLabel.setText("Ashwin Sakhare")

        self.instituteLabel = Label(self.labelsFrame)
        self.instituteLabel.setText(
            "Stevens Neuroimaging and Informatics Institute")

        self.universityLabel = Label(self.labelsFrame)
        self.universityLabel.setText("University of Southern California")

        self.labelsLayout = QHBoxLayout(self.labelsFrame)
        self.labelsLayout.addWidget(self.developerLabel)
        self.labelsLayout.addWidget(self.instituteLabel)
        self.labelsLayout.addWidget(self.universityLabel)
        self.labelsLayout.setSpacing(50)
        self.labelsLayout.setContentsMargins(10, 0, 0, 0)

        self.labelsLayout.setAlignment(Qt.AlignLeft)

        self.versionFrame = QFrame(self.centralFrame)
        self.versionFrame.setFrameShape(QFrame.NoFrame)
        self.versionFrame.setFrameShadow(QFrame.Raised)
        self.versionFrame.setContentsMargins(0, 0, 0, 0)
        self.versionFrame.setStyleSheet("border: none;")

        self.versionLabel = Label(self.labelsFrame)
        self.versionLabel.setText("v1.0.0 alpha")

        self.versionLayout = QHBoxLayout(self.versionFrame)
        self.versionLayout.addWidget(self.versionLabel)
        self.versionLayout.setAlignment(Qt.AlignRight)
        self.versionLayout.setContentsMargins(0, 0, 20, 0)

        self.gripFrame = QFrame(self.centralFrame)
        self.gripFrame.setFrameShape(QFrame.NoFrame)
        self.gripFrame.setFrameShadow(QFrame.Raised)
        self.gripFrame.setMaximumSize(QSize(20, 20))
        self.gripFrame.setContentsMargins(0, 0, 0, 0)

        # path = resource_path('icons/cil-size-grip.png')
        # self.gripFrame.setStyleSheet("background-image: url(" + str(path) + "); \n"
        #                              "background-position: center; \n"
        #                              "background-repeat: no repeat")

        self.ui_sizeGrip = QSizeGrip(self.gripFrame)
        self.ui_sizeGrip.setStyleSheet(
            "width: 20px; height: 20px; margin 0px; padding: 0px;")

        self.gripLabel = QLabel(self.gripFrame)
        self.pixmap = QPixmap(resource_path('icons/cil-size-grip.png'))
        self.gripLabel.setPixmap(self.pixmap)

        self.gripLayout = QHBoxLayout(self.gripFrame)
        self.gripLayout.addWidget(self.gripLabel)
        self.gripLayout.setAlignment(Qt.AlignCenter)
        self.gripLayout.setContentsMargins(0, 0, 0, 0)

        self.centralLayout = QHBoxLayout(self.centralFrame)
        self.centralLayout.addWidget(self.labelsFrame)
        self.centralLayout.addWidget(self.versionFrame)
        self.centralLayout.addWidget(self.gripFrame)
        self.centralLayout.setSpacing(0)
        self.centralLayout.setContentsMargins(0, 0, 0, 0)

        self.uiLayout = QHBoxLayout(self)
        self.uiLayout.addWidget(self.centralFrame)
        self.uiLayout.setContentsMargins(0, 0, 0, 0)

        self.setLayout(self.uiLayout)
Esempio n. 6
0
 def sizeHint(self):
     return QSize(self.codeEditor.lineNumberAreaWidth(), 0)
Esempio n. 7
0
    def __init__(self, parent=None):
        super(Window, self).__init__(parent)

        languages = googletrans.LANGUAGES.copy()
        languages['zh-cn'] = '中文(简体)'
        languages['zh-tw'] = '中文(繁体)'
        self.langcodes = dict(map(reversed, languages.items()))
        self.langlist = [k.capitalize() for k in self.langcodes.keys()]

        self.browseButton = self.createButton("&浏览...", self.browse)
        self.transButton = self.createButton("&翻译", self.translate)

        self.lang_srcComboBox = self.createComboBox()
        srcIndex = self.langlist.index('English')
        self.lang_srcComboBox.setCurrentIndex(srcIndex)
        self.lang_dstComboBox = self.createComboBox()
        dstIndex = self.langlist.index('中文(简体)')
        self.lang_dstComboBox.setCurrentIndex(dstIndex)
        self.fileComboBox = self.createComboBox('file')

        srcLabel = QtWidgets.QLabel("文档语言:")
        dstLabel = QtWidgets.QLabel("目标语言:")
        docLabel = QtWidgets.QLabel("选择文档:")
        self.filesFoundLabel = QtWidgets.QLabel()

        self.logPlainText = QtWidgets.QPlainTextEdit()
        self.logPlainText.setReadOnly(True)

        buttonsLayout = QtWidgets.QHBoxLayout()
        buttonsLayout.addStretch()
        buttonsLayout.addWidget(self.transButton)

        mainLayout = QtWidgets.QGridLayout()
        mainLayout.addWidget(srcLabel, 0, 0)
        mainLayout.addWidget(self.lang_srcComboBox, 0, 1, 1, 2)
        mainLayout.addWidget(dstLabel, 1, 0)
        mainLayout.addWidget(self.lang_dstComboBox, 1, 1, 1, 2)
        mainLayout.addWidget(docLabel, 2, 0)
        mainLayout.addWidget(self.fileComboBox, 2, 1)
        mainLayout.addWidget(self.browseButton, 2, 2)
        # mainLayout.addWidget(self.filesTable, 3, 0, 1, 3)
        mainLayout.addWidget(self.logPlainText, 3, 0, 1, 3)
        mainLayout.addWidget(self.filesFoundLabel, 4, 0)
        mainLayout.addLayout(buttonsLayout, 5, 0, 1, 3)
        self.setLayout(mainLayout)

        app_icon = QIcon()  #icon = https://imgur.com/NV7Ugfd
        app_icon.addFile('icon.png', QSize(16, 16))
        app_icon.addFile('icon.png', QSize(24, 24))
        app_icon.addFile('icon.png', QSize(32, 32))
        app_icon.addFile('icon.png', QSize(48, 48))
        app_icon.addFile('icon.png', QSize(256, 256))
        self.setWindowIcon(app_icon)

        self.setWindowTitle("文档翻译")
        self.resize(800, 600)

        # translate
        self.logger = LogHandler()
        self.logger.show.connect(self.onLog)
        docxtr.g_log = self.logger
        self.task = TranslateTask()
        self.task.done.connect(self.onLog)
Esempio n. 8
0
 def sizeHint(self):
     return QSize(1270, 800)
Esempio n. 9
0
    def __init__(self, parent=None):
        super().__init__()
        self.parent = parent
        self.setWindowTitle(self.tr("Welcome"))

        self.setLayout(QVBoxLayout())
        self.layout().setAlignment(Qt.AlignCenter)

        titleLabel = QLabel()
        titleLabel.setAlignment(Qt.AlignCenter)
        titleLabel.setText(self.tr("<h1>Welcome to Lime GNU/Linux System Installer.</h1>"))
        self.layout().addWidget(titleLabel)

        descLabel = QLabel()
        descLabel.setAlignment(Qt.AlignCenter)
        descLabel.setText(self.tr("This program is going to ask you some questions and then will install the Lime GNU/Linux to your device."))
        self.layout().addWidget(descLabel)

        lLayout = QHBoxLayout()
        lLayout.setAlignment(Qt.AlignCenter)
        self.layout().addLayout(lLayout)

        imageLabel = QLabel()
        imageLabel.setPixmap(QPixmap(":/images/welcome.svg"))
        imageLabel.setScaledContents(True)
        imageLabel.setFixedSize(256, 256)
        lLayout.addWidget(imageLabel)

        langLayout = QHBoxLayout()
        langLayout.setAlignment(Qt.AlignCenter)
        self.layout().addLayout(langLayout)

        langLabel = QLabel()
        langLabel.setText(self.tr("Language:"))
        langLayout.addWidget(langLabel)

        langComboBox = QComboBox()
        langComboBox.setFixedWidth(250)
        langLayout.addWidget(langComboBox)

        linkLayout = QHBoxLayout()
        linkLayout.setAlignment(Qt.AlignCenter)
        self.layout().addLayout(linkLayout)

        aboutButton = QPushButton()
        aboutButton.setFlat(True)
        aboutButton.setText(self.tr("About"))
        aboutButton.setIcon(QIcon(":/images/about.svg"))
        aboutButton.setIconSize(QSize(18, 18))
        linkLayout.addWidget(aboutButton)

        bugButton = QPushButton()
        bugButton.setFlat(True)
        bugButton.setText(self.tr("Found Bugs"))
        bugButton.setIcon(QIcon(":/images/bug.svg"))
        bugButton.setIconSize(QSize(18, 18))
        linkLayout.addWidget(bugButton)

        releaseButton = QPushButton()
        releaseButton.setFlat(True)
        releaseButton.setText(self.tr("Release Notes"))
        releaseButton.setIcon(QIcon(":/images/release-note.svg"))
        releaseButton.setIconSize(QSize(18, 18))
        linkLayout.addWidget(releaseButton)

        langComboBox.addItems(["Català", "Deutsch", "English (US)", "Español", "Français", "Magyar", "Italiano",
                               "Nederlands", "Polski", "Português (Brasil)", "Pусский", "Svenska", "Türkçe"])

        for k, v in self.lang_list.items():
            if QLocale.system().name()+".UTF-8" == k:
                langComboBox.setCurrentText(v)
                self.parent.lilii_settings["lang"] = k

        langComboBox.currentTextChanged.connect(self.langSelect)
        aboutButton.clicked.connect(self.aboutDialog)
        bugButton.clicked.connect(self.bugAdressConnect)
        releaseButton.clicked.connect(self.releaseInfoConnect)
Esempio n. 10
0
    def Populate(self, filter=""):
        """Populate all preferences and tabs"""

        # get translations
        app = get_app()
        _ = app._tr

        # Delete all tabs and widgets
        self.DeleteAllTabs()

        self.category_names = {}
        self.category_tabs = {}
        self.category_sort = {}
        self.visible_category_names = {}

        # Loop through settings and find all unique categories
        for item in self.settings_data:
            category = item.get("category")
            setting_type = item.get("type")
            sort_category = item.get("sort")

            # Indicate sorted category
            if sort_category:
                self.category_sort[category] = sort_category

            if setting_type != "hidden":
                # Load setting
                if category not in self.category_names:
                    self.category_names[category] = []

                    # Create scrollarea
                    scroll_area = QScrollArea(self)
                    scroll_area.setWidgetResizable(True)
                    scroll_area.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
                    scroll_area.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
                    scroll_area.setMinimumSize(675, 100)

                    # Create tab widget and layout
                    layout = QVBoxLayout()
                    tabWidget = QWidget(self)
                    tabWidget.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
                    tabWidget.setLayout(layout)
                    scroll_area.setWidget(tabWidget)

                    # Add tab
                    self.tabCategories.addTab(scroll_area, _(category))
                    self.category_tabs[category] = tabWidget

                # Append translated title
                item["title_tr"] = _(item.get("title"))

                # Append settings into correct category
                self.category_names[category].append(item)

        # Loop through each category setting, and add them to the tabs
        for category in dict(self.category_tabs).keys():
            tabWidget = self.category_tabs[category]
            filterFound = False

            # Get list of items in category
            params = self.category_names[category]
            if self.category_sort.get(category):
                # Sort this category by translated title
                params.sort(key=operator.itemgetter("title_tr"))

            # Loop through settings for each category
            for param in params:
                # Is filter found?
                if filter and (filter.lower() in _(param["title"]).lower() or filter.lower() in _(category).lower()):
                    filterFound = True
                elif not filter:
                    filterFound = True
                else:
                    filterFound = False

                # Visible Category
                if filterFound:
                    self.visible_category_names[category] = tabWidget

                # Create Label
                widget = None
                extraWidget = None
                label = QLabel()
                label.setText(_(param["title"]))
                label.setToolTip(_(param["title"]))

                if param["type"] == "spinner":
                    # create QDoubleSpinBox
                    widget = QDoubleSpinBox()
                    widget.setMinimum(float(param["min"]))
                    widget.setMaximum(float(param["max"]))
                    widget.setValue(float(param["value"]))
                    widget.setSingleStep(1.0)
                    widget.setToolTip(param["title"])
                    widget.valueChanged.connect(functools.partial(self.spinner_value_changed, param))

                if param["type"] == "spinner-int":
                    # create QDoubleSpinBox
                    widget = QSpinBox()
                    widget.setMinimum(int(param["min"]))
                    widget.setMaximum(int(param["max"]))
                    widget.setValue(int(param["value"]))
                    widget.setSingleStep(1)
                    widget.setToolTip(param["title"])
                    widget.valueChanged.connect(functools.partial(self.spinner_value_changed, param))

                elif param["type"] == "text" or param["type"] == "browse":
                    # create QLineEdit
                    widget = QLineEdit()
                    widget.setText(_(param["value"]))
                    widget.textChanged.connect(functools.partial(self.text_value_changed, widget, param))

                    if param["type"] == "browse":
                        # Add filesystem browser button
                        extraWidget = QPushButton(_("Browse..."))
                        extraWidget.clicked.connect(functools.partial(self.selectExecutable, widget, param))

                elif param["type"] == "bool":
                    # create spinner
                    widget = QCheckBox()
                    if param["value"] is True:
                        widget.setCheckState(Qt.Checked)
                    else:
                        widget.setCheckState(Qt.Unchecked)
                    widget.stateChanged.connect(functools.partial(self.bool_value_changed, widget, param))

                elif param["type"] == "dropdown":

                    # create spinner
                    widget = QComboBox()

                    # Get values
                    value_list = param["values"]
                    # Overwrite value list (for profile dropdown)
                    if param["setting"] == "default-profile":
                        value_list = []
                        # Loop through profiles
                        for profile_folder in [info.USER_PROFILES_PATH, info.PROFILES_PATH]:
                            for file in os.listdir(profile_folder):
                                # Load Profile and append description
                                profile_path = os.path.join(profile_folder, file)
                                profile = openshot.Profile(profile_path)
                                value_list.append({
                                    "name": profile.info.description,
                                    "value": profile.info.description
                                    })
                        # Sort profile list
                        value_list.sort(key=operator.itemgetter("name"))

                    # Overwrite value list (for audio device list dropdown)
                    if param["setting"] == "playback-audio-device":
                        value_list = []
                        # Loop through audio devices
                        value_list.append({"name": "Default", "value": ""})
                        for audio_device in get_app().window.preview_thread.player.GetAudioDeviceNames():
                            value_list.append({
                                "name": "%s: %s" % (
                                    audio_device.type, audio_device.name),
                                "value": audio_device.name,
                                })

                    # Overwrite value list (for language dropdown)
                    if param["setting"] == "default-language":
                        value_list = []
                        # Loop through languages
                        for locale, language, country in get_all_languages():
                            # Load Profile and append description
                            if language:
                                lang_name = "%s (%s)" % (language, locale)
                                value_list.append({
                                    "name": lang_name,
                                    "value": locale
                                    })
                        # Sort profile list
                        value_list.sort(key=operator.itemgetter("name"))
                        # Add Default to top of list
                        value_list.insert(0, {
                            "name": _("Default"),
                            "value": "Default"
                            })

                    # Overwrite value list (for hardware acceleration modes)
                    os_platform = platform.system()
                    if param["setting"] == "hw-decoder":
                        for value_item in list(value_list):
                            v = value_item["value"]
                            # Remove items that are operating system specific
                            if os_platform == "Darwin" and v not in ("0", "5", "2"):
                                value_list.remove(value_item)
                            elif os_platform == "Windows" and v not in ("0", "3", "4"):
                                value_list.remove(value_item)
                            elif os_platform == "Linux" and v not in ("0", "1", "2", "6"):
                                value_list.remove(value_item)

                        # Remove hardware mode items which cannot decode the example video
                        log.debug("Preparing to test hardware decoding: %s" % (value_list))
                        for value_item in list(value_list):
                            v = value_item["value"]
                            if (not self.testHardwareDecode(value_list, v, 0)
                               and not self.testHardwareDecode(value_list, v, 1)):
                                value_list.remove(value_item)
                        log.debug("Completed hardware decoding testing")

                    # Replace %s dropdown values for hardware acceleration
                    if param["setting"] in ("graca_number_en", "graca_number_de"):
                        for card_index in range(0, 3):
                            # Test each graphics card, and only include valid ones
                            if card_index in self.hardware_tests_cards and self.hardware_tests_cards.get(card_index):
                                # Loop through valid modes supported by this card
                                for mode in self.hardware_tests_cards.get(card_index):
                                    # Add supported graphics card for each mode (duplicates are okay)
                                    if mode == 0:
                                        # cpu only
                                        value_list.append({
                                            "value": card_index,
                                            "name": _("No acceleration"),
                                            "icon": mode
                                            })
                                    else:
                                        # hardware accelerated
                                        value_list.append({
                                            "value": card_index,
                                            "name": _("Graphics Card %s") % (card_index + 1),
                                            "icon": mode
                                            })

                        if os_platform in ["Darwin", "Windows"]:
                            # Disable graphics card selection for Mac and Windows (since libopenshot
                            # only supports device selection on Linux)
                            widget.setEnabled(False)
                            widget.setToolTip(_("Graphics card selection not supported in %s") % os_platform)

                    # Add normal values
                    box_index = 0
                    for value_item in value_list:
                        k = value_item["name"]
                        v = value_item["value"]
                        i = value_item.get("icon", None)

                        # Override icons for certain values
                        # TODO: Find a more elegant way to do this
                        icon = None
                        if k == "Linux VA-API" or i == 1:
                            icon = QIcon(":/hw/hw-accel-vaapi.svg")
                        elif k == "Nvidia NVDEC" or i == 2:
                            icon = QIcon(":/hw/hw-accel-nvdec.svg")
                        elif k == "Linux VDPAU" or i == 6:
                            icon = QIcon(":/hw/hw-accel-vdpau.svg")
                        elif k == "Windows D3D9" or i == 3:
                            icon = QIcon(":/hw/hw-accel-dx.svg")
                        elif k == "Windows D3D11" or i == 4:
                            icon = QIcon(":/hw/hw-accel-dx.svg")
                        elif k == "MacOS" or i == 5:
                            icon = QIcon(":/hw/hw-accel-vtb.svg")
                        elif k == "Intel QSV" or i == 7:
                            icon = QIcon(":/hw/hw-accel-qsv.svg")
                        elif k == "No acceleration" or i == 0:
                            icon = QIcon(":/hw/hw-accel-none.svg")

                        # add dropdown item
                        if icon:
                            widget.setIconSize(QSize(60, 18))
                            widget.addItem(icon, _(k), v)
                        else:
                            widget.addItem(_(k), v)

                        # select dropdown (if default)
                        if v == param["value"]:
                            widget.setCurrentIndex(box_index)
                        box_index = box_index + 1

                    widget.currentIndexChanged.connect(functools.partial(self.dropdown_index_changed, widget, param))

                # Add Label and Widget to the form
                if (widget and label and filterFound):
                    # Add minimum size
                    label.setMinimumWidth(180)
                    label.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
                    widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)

                    # Create HBox layout
                    layout_hbox = QHBoxLayout()
                    layout_hbox.addWidget(label)
                    layout_hbox.addWidget(widget)

                    if (extraWidget):
                        layout_hbox.addWidget(extraWidget)

                    # Add widget to layout
                    tabWidget.layout().addLayout(layout_hbox)
                elif (label and filterFound):
                    # Add widget to layout
                    tabWidget.layout().addWidget(label)

            # Add stretch to bottom of layout
            tabWidget.layout().addStretch()

        # Delete all tabs and widgets
        self.DeleteAllTabs(onlyInVisible=True)
Esempio n. 11
0
    def blocks(self):
        mapTo3d = self.settings.mapTo3d()
        baseExtent = self.settings.baseExtent
        center = baseExtent.center()
        rotation = baseExtent.rotation()
        base_grid_size = self.prop.demSize(
            self.settings.mapSettings.outputSize())

        # clipping
        clip_geometry = None
        clip_option = self.properties.get("checkBox_Clip", False)
        if clip_option:
            clip_layerId = self.properties.get("comboBox_ClipLayer")
            clip_layer = QgsProject.instance().mapLayer(
                clip_layerId) if clip_layerId else None
            if clip_layer:
                clip_geometry = dissolvePolygonsOnCanvas(
                    self.settings, clip_layer)

        # surroundings
        surroundings = self.properties.get(
            "checkBox_Surroundings",
            False)  #TODO: if prop.layerId else False   (GSIElevProvider?)
        roughening = self.properties[
            "spinBox_Roughening"] if surroundings else 1
        size = self.properties["spinBox_Size"] if surroundings else 1
        size2 = size * size

        blks = []
        for i in range(size2):
            sx = i % size - (size - 1) // 2
            sy = i // size - (size - 1) // 2
            dist2 = sx * sx + sy * sy
            blks.append([dist2, i, sx, sy])

        for dist2, blockIndex, sx, sy in sorted(blks):
            #self.progress(20 * i / size2 + 10)
            is_center = (sx == 0 and sy == 0)

            if is_center:
                extent = baseExtent
                grid_size = base_grid_size
            else:
                block_center = QgsPoint(center.x() + sx * baseExtent.width(),
                                        center.y() + sy * baseExtent.height())
                extent = RotatedRect(block_center, baseExtent.width(),
                                     baseExtent.height()).rotate(
                                         rotation, center)
                grid_size = QSize(
                    max(2, (base_grid_size.width() - 1) // roughening + 1),
                    max(2, (base_grid_size.height() - 1) // roughening + 1))

            block = DEMBlockExporter(
                self.settings,
                self.imageManager,
                self.layer,
                blockIndex,
                self.provider,
                grid_size,
                extent,
                mapTo3d.planeWidth,
                mapTo3d.planeHeight,
                offsetX=mapTo3d.planeWidth * sx,
                offsetY=mapTo3d.planeHeight * sy,
                edgeRougheness=roughening if is_center else 1,
                clip_geometry=clip_geometry if is_center else None,
                pathRoot=self.pathRoot,
                urlRoot=self.urlRoot)
            yield block
Esempio n. 12
0
    def init_ui(self):
        desktop = QApplication.desktop()
        self.main_window.move(desktop.width() * 0.4, 0)
        self.main_window.setWindowTitle("Ass")
        self.main_window.setWindowIcon(QIcon("images/icon.png"))
        # https://www.easyicon.net/1188455-Fingerprint_icon.html
        self.main_window.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint
                                        | Qt.Tool)
        # self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
        # dialog.setWindowFlags(QtCore.Qt.Widget)  # 取消置顶
        self.main_window.setWindowOpacity(0.8)  # 设置窗口透明度
        self.main_window.setAttribute(
            QtCore.Qt.WA_TranslucentBackground)  # 设置窗口背景透明
        self.main_window.setWindowFlag(QtCore.Qt.FramelessWindowHint)  # 隐藏边框

        self.app_list_widget = FatherQListWidget(self, self.centralWidget)
        self.app_list_widget.setObjectName("app_list_widget")
        self.app_list_widget.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.app_list_widget.setHorizontalScrollBarPolicy(
            Qt.ScrollBarAlwaysOff)
        self.app_list_widget.setFocusPolicy(Qt.NoFocus)
        self.app_list_widget.setFlow(QListWidget.LeftToRight)
        self.app_list_widget.setIconSize(QSize(icon_width, icon_width))
        self.app_list_widget.setFrameShape(QListWidget.NoFrame)

        self.app_list_widget.doubleClicked.connect(
            lambda: self.double_clicked())

        for index in self.app_info_dict:
            app_info = self.app_info_dict[index]
            item = FatherQListWidgetItem()
            item.setSizeHint(QSize(icon_width, icon_height))
            if self.app_setting.use_rgb:
                item.setIcon(QIcon(app_info.icon_path))
            else:
                item.setIcon(QIcon(app_info.icon_gray_path))
            item.setWhatsThis(app_info.name)
            self.app_list_widget.addItem(item)

        self.setting = Setting(self.app_setting)
        self.setting.before_close_signal.connect(self.echo)

        self.message_label = QLabel("QQ:\n小冰:晚饭吃什么啊?", self.centralWidget)
        self.message_label.setGeometry(
            QRect(5, 2, message_window_width, message_window_height))
        self.message_label.setObjectName("message_label")

        self.drag_label = FatherQLabel("Input", self, self.centralWidget)
        self.drag_label.setGeometry(
            QRect(5 + message_window_width + 5, 2, input_window_width,
                  input_window_height))
        self.drag_label.setObjectName("drag_label")

        if len(self.app_info_dict) == 0:
            self.main_window.resize(
                5 + message_window_width + 5 + input_window_width + 5 +
                icon_width + 5, window_height)
            self.app_list_widget.setGeometry(
                QRect(5 + message_window_width + 5 + input_window_width + 5, 2,
                      icon_width, icon_height))
        else:
            self.main_window.resize(
                5 + message_window_width + 5 + input_window_width + 5 +
                icon_width * len(self.app_info_dict) + 5, window_height)
            self.app_list_widget.setGeometry(
                QRect(5 + message_window_width + 5 + input_window_width + 5, 2,
                      icon_width * len(self.app_info_dict), icon_height))
        # self.main_layout.removeWidget(self.app_list_widget)
        """
            测试布局时使用:
            QListView#app_list_widget{
                color:black;
                background-color:rgb(255, 255, 0);
            }
            QLabel#message_label{
                color:black;
                background-color:rgb(255, 0, 255);
            }
            FatherQLabel#drag_label{
                color:black;
                background-color:rgb(0, 255, 255);
            }
        """

        self.main_window.setStyleSheet('''
            QListView::item:selected{
                color:black;
                background-color:rgba(255, 0, 0, 0);
            }
            QWidget#centralWidget{
                color:#232C51;
                background:white;
                border-top:1px solid darkGray;
                border-bottom:1px solid darkGray;
                border-right:1px solid darkGray;
                border-left:1px solid darkGray;
                border-top-right-radius:10px;
                border-top-left-radius:10px;
                border-bottom-right-radius:10px;
                border-bottom-left-radius:10px;
            }
        ''')
Esempio n. 13
0
 def __init__(self, main_client_window):
     main_client_window.setObjectName("MainClientWindow")
     main_client_window.resize(756, 534)
     main_client_window.setMinimumSize(QSize(756, 534))
     self.centralwidget = QWidget(main_client_window)
     self.centralwidget.setObjectName("centralwidget")
     self.label_contacts = QLabel(self.centralwidget)
     self.label_contacts.setGeometry(QRect(10, 0, 101, 16))
     self.label_contacts.setObjectName("label_contacts")
     self.btn_add_contact = QPushButton(self.centralwidget)
     self.btn_add_contact.setGeometry(QRect(10, 450, 121, 31))
     self.btn_add_contact.setObjectName("btn_add_contact")
     self.btn_remove_contact = QPushButton(self.centralwidget)
     self.btn_remove_contact.setGeometry(QRect(140, 450, 121, 31))
     self.btn_remove_contact.setObjectName("btn_remove_contact")
     self.label_history = QLabel(self.centralwidget)
     self.label_history.setGeometry(QRect(300, 0, 391, 21))
     self.label_history.setObjectName("label_history")
     self.text_message = QTextEdit(self.centralwidget)
     self.text_message.setGeometry(QRect(300, 360, 441, 71))
     self.text_message.setObjectName("text_message")
     self.label_new_message = QLabel(self.centralwidget)
     self.label_new_message.setGeometry(QRect(300, 270, 450, 76))
     self.label_new_message.setObjectName("label_new_message")
     self.text_menu = QMenuBar(self.label_new_message)
     self.text_menu.move(0, 51)
     self.action_bold = QAction(QIcon(os.path.join(STATIC, 'img/b.jpg')),
                                'Bold', self.text_message)
     self.action_italic = QAction(QIcon(os.path.join(STATIC, 'img/i.jpg')),
                                  'Italic', self.text_message)
     self.action_underlined = QAction(
         QIcon(os.path.join(STATIC, 'img/u.jpg')), 'Underlined',
         self.text_message)
     self.action_smile = QAction(
         QIcon(os.path.join(STATIC, 'img/smile.gif')), 'smile',
         self.text_message)
     self.list_contacts = QListView(self.centralwidget)
     self.list_contacts.setGeometry(QRect(10, 20, 251, 411))
     self.list_contacts.setObjectName("list_contacts")
     self.list_messages = QListView(self.centralwidget)
     self.list_messages.setGeometry(QRect(300, 20, 441, 271))
     self.list_messages.setObjectName("list_messages")
     self.btn_send = QPushButton(self.centralwidget)
     self.btn_send.setGeometry(QRect(610, 450, 131, 31))
     self.btn_send.setObjectName("btn_send")
     self.btn_clear = QPushButton(self.centralwidget)
     self.btn_clear.setGeometry(QRect(460, 450, 131, 31))
     self.btn_clear.setObjectName("btn_clear")
     main_client_window.setCentralWidget(self.centralwidget)
     self.menubar = QMenuBar(main_client_window)
     self.menubar.setGeometry(QRect(0, 0, 756, 21))
     self.menubar.setObjectName("menubar")
     self.menu_file = QMenu(self.menubar)
     self.menu_file.setObjectName("file")
     self.menu_contacts = QMenu(self.menubar)
     self.menu_contacts.setObjectName("contacts")
     self.menu_profile = QMenu(self.menubar)
     self.menu_profile.setObjectName("profile")
     main_client_window.setMenuBar(self.menubar)
     self.statusBar = QStatusBar(main_client_window)
     self.statusBar.setObjectName("statusBar")
     main_client_window.setStatusBar(self.statusBar)
     self.menu_exit = QAction(main_client_window)
     self.menu_exit.setObjectName("menu_exit")
     self.menu_add_contact = QAction(main_client_window)
     self.menu_add_contact.setObjectName("menu_add_contact")
     self.menu_del_contact = QAction(main_client_window)
     self.menu_del_contact.setObjectName("menu_del_contact")
     self.menu_file.addAction(self.menu_exit)
     self.menu_contacts.addAction(self.menu_add_contact)
     self.menu_contacts.addAction(self.menu_del_contact)
     self.menu_contacts.addSeparator()
     self.menu_profile_avatar = QAction(main_client_window)
     self.menu_profile_avatar.setObjectName("menu_profile_avatar")
     self.menu_profile.addAction(self.menu_profile_avatar)
     self.menu_profile.addSeparator()
     self.menubar.addAction(self.menu_file.menuAction())
     self.menubar.addAction(self.menu_contacts.menuAction())
     self.menubar.addAction(self.menu_profile.menuAction())
     self.retranslate_ui(main_client_window)
     self.btn_clear.clicked.connect(self.text_message.clear)
     QMetaObject.connectSlotsByName(main_client_window)
Esempio n. 14
0
 def tabSizeHint(self, index):
     s = QTabBar.tabSizeHint(self, index)
     s.transpose()
     return QSize(max(s.width(),
                      self.data_w.sizeHint().width()), s.height())
Esempio n. 15
0
    def __init__(self, mainWindow):
        QWidget.__init__(self)
        self.setupUi(self)
        self.mw = mainWindow

        # UI
        for l in [
                self.lblTitleGeneral,
                self.lblTitleGeneral_2,
                self.lblTitleViews,
                self.lblTitleLabels,
                self.lblTitleStatus,
                self.lblTitleFullscreen,
        ]:
            l.setStyleSheet(S.titleLabelSS())

        icons = [
            QIcon.fromTheme("configure"),
            QIcon.fromTheme("history-view"),
            QIcon.fromTheme("gnome-settings"),
            themeIcon("label"),
            themeIcon("status"),
            QIcon.fromTheme("preferences-desktop-theme")
        ]
        for i in range(self.lstMenu.count()):
            item = self.lstMenu.item(i)
            item.setSizeHint(QSize(item.sizeHint().width(), 42))
            item.setTextAlignment(Qt.AlignCenter)
            if icons[i]:
                item.setIcon(icons[i])
        self.lstMenu.setMaximumWidth(140)
        self.lstMenu.setMinimumWidth(140)

        # General
        self.cmbStyle.addItems(list(QStyleFactory.keys()))
        self.cmbStyle.setCurrentIndex([
            i.lower() for i in list(QStyleFactory.keys())
        ].index(qApp.style().objectName()))
        self.cmbStyle.currentIndexChanged[str].connect(self.setStyle)

        self.cmbTranslation.clear()
        tr = OrderedDict()
        tr["English"] = ""
        tr["Français"] = "manuskript_fr.qm"
        tr["Español"] = "manuskript_es.qm"
        tr["Deutsch"] = "manuskript_de.qm"
        tr["Svenska"] = "manuskript_sv.qm"

        for name in tr:
            self.cmbTranslation.addItem(name, tr[name])

        sttgs = QSettings(qApp.organizationName(), qApp.applicationName())
        if sttgs.contains("applicationTranslation") and sttgs.value(
                "applicationTranslation") in tr.values():
            self.cmbTranslation.setCurrentText([
                i for i in tr if tr[i] == sttgs.value("applicationTranslation")
            ][0])

        self.cmbTranslation.currentIndexChanged.connect(self.setTranslation)

        self.txtAutoSave.setValidator(QIntValidator(0, 999, self))
        self.txtAutoSaveNoChanges.setValidator(QIntValidator(0, 999, self))
        self.chkAutoSave.setChecked(settings.autoSave)
        self.chkAutoSaveNoChanges.setChecked(settings.autoSaveNoChanges)
        self.txtAutoSave.setText(str(settings.autoSaveDelay))
        self.txtAutoSaveNoChanges.setText(str(settings.autoSaveNoChangesDelay))
        self.chkSaveOnQuit.setChecked(settings.saveOnQuit)
        self.chkSaveToZip.setChecked(settings.saveToZip)
        self.chkAutoSave.stateChanged.connect(self.saveSettingsChanged)
        self.chkAutoSaveNoChanges.stateChanged.connect(
            self.saveSettingsChanged)
        self.chkSaveOnQuit.stateChanged.connect(self.saveSettingsChanged)
        self.chkSaveToZip.stateChanged.connect(self.saveSettingsChanged)
        self.txtAutoSave.textEdited.connect(self.saveSettingsChanged)
        self.txtAutoSaveNoChanges.textEdited.connect(self.saveSettingsChanged)
        autoLoad, last = self.mw.welcome.getAutoLoadValues()
        self.chkAutoLoad.setChecked(autoLoad)
        self.chkAutoLoad.stateChanged.connect(self.saveSettingsChanged)

        # Revisions
        opt = settings.revisions
        self.chkRevisionsKeep.setChecked(opt["keep"])
        self.chkRevisionsKeep.stateChanged.connect(
            self.revisionsSettingsChanged)
        self.chkRevisionRemove.setChecked(opt["smartremove"])
        self.chkRevisionRemove.toggled.connect(self.revisionsSettingsChanged)
        self.spnRevisions10Mn.setValue(60 / opt["rules"][10 * 60])
        self.spnRevisions10Mn.valueChanged.connect(
            self.revisionsSettingsChanged)
        self.spnRevisionsHour.setValue(60 * 10 / opt["rules"][60 * 60])
        self.spnRevisionsHour.valueChanged.connect(
            self.revisionsSettingsChanged)
        self.spnRevisionsDay.setValue(60 * 60 / opt["rules"][60 * 60 * 24])
        self.spnRevisionsDay.valueChanged.connect(
            self.revisionsSettingsChanged)
        self.spnRevisionsMonth.setValue(60 * 60 * 24 /
                                        opt["rules"][60 * 60 * 24 * 30])
        self.spnRevisionsMonth.valueChanged.connect(
            self.revisionsSettingsChanged)
        self.spnRevisionsEternity.setValue(60 * 60 * 24 * 7 /
                                           opt["rules"][None])
        self.spnRevisionsEternity.valueChanged.connect(
            self.revisionsSettingsChanged)

        # Views
        self.tabViews.setCurrentIndex(0)
        lst = ["Nothing", "POV", "Label", "Progress", "Compile"]
        for cmb in self.viewSettingsDatas():
            item, part = self.viewSettingsDatas()[cmb]
            cmb.setCurrentIndex(lst.index(settings.viewSettings[item][part]))
            cmb.currentIndexChanged.connect(self.viewSettingsChanged)

        for chk in self.outlineColumnsData():
            col = self.outlineColumnsData()[chk]
            chk.setChecked(col in settings.outlineViewColumns)
            chk.stateChanged.connect(self.outlineColumnsChanged)

        self.chkOutlinePOV.setVisible(
            settings.viewMode !=
            "simple")  #  Hides checkbox if non-fiction view mode

        for item, what, value in [
            (self.rdoTreeItemCount, "InfoFolder", "Count"),
            (self.rdoTreeWC, "InfoFolder", "WC"),
            (self.rdoTreeProgress, "InfoFolder", "Progress"),
            (self.rdoTreeSummary, "InfoFolder", "Summary"),
            (self.rdoTreeNothing, "InfoFolder", "Nothing"),
            (self.rdoTreeTextWC, "InfoText", "WC"),
            (self.rdoTreeTextProgress, "InfoText", "Progress"),
            (self.rdoTreeTextSummary, "InfoText", "Summary"),
            (self.rdoTreeTextNothing, "InfoText", "Nothing"),
        ]:
            item.setChecked(settings.viewSettings["Tree"][what] == value)
            item.toggled.connect(self.treeViewSettignsChanged)

        self.sldTreeIconSize.valueChanged.connect(self.treeViewSettignsChanged)
        self.sldTreeIconSize.valueChanged.connect(
            lambda v: self.lblTreeIconSize.setText("{}x{}".format(v, v)))
        self.sldTreeIconSize.setValue(
            settings.viewSettings["Tree"]["iconSize"])

        self.rdoCorkOldStyle.setChecked(settings.corkStyle == "old")
        self.rdoCorkNewStyle.setChecked(settings.corkStyle == "new")
        self.rdoCorkNewStyle.toggled.connect(self.setCorkStyle)
        self.rdoCorkOldStyle.toggled.connect(self.setCorkStyle)

        self.populatesCmbBackgrounds(self.cmbCorkImage)
        self.setCorkImageDefault()
        self.updateCorkColor()
        self.cmbCorkImage.currentIndexChanged.connect(self.setCorkBackground)
        self.btnCorkColor.clicked.connect(self.setCorkColor)

        # Text editor
        opt = settings.textEditor
        # Font
        self.setButtonColor(self.btnEditorFontColor, opt["fontColor"])
        self.btnEditorFontColor.clicked.connect(self.choseEditorFontColor)
        self.setButtonColor(self.btnEditorMisspelledColor, opt["misspelled"])
        self.btnEditorMisspelledColor.clicked.connect(
            self.choseEditorMisspelledColor)
        self.setButtonColor(self.btnEditorBackgroundColor, opt["background"])
        self.btnEditorBackgroundColor.clicked.connect(
            self.choseEditorBackgroundColor)
        self.chkEditorBackgroundTransparent.setChecked(
            opt["backgroundTransparent"])
        self.chkEditorBackgroundTransparent.stateChanged.connect(
            self.updateEditorSettings)
        self.btnEditorColorDefault.clicked.connect(self.restoreEditorColors)
        f = QFont()
        f.fromString(opt["font"])
        self.cmbEditorFontFamily.setCurrentFont(f)
        self.cmbEditorFontFamily.currentFontChanged.connect(
            self.updateEditorSettings)
        self.spnEditorFontSize.setValue(f.pointSize())
        self.spnEditorFontSize.valueChanged.connect(self.updateEditorSettings)
        # Cursor
        self.chkEditorCursorWidth.setChecked(opt["cursorWidth"] != 1)
        self.chkEditorCursorWidth.stateChanged.connect(
            self.updateEditorSettings)
        self.spnEditorCursorWidth.setValue(
            opt["cursorWidth"] if opt["cursorWidth"] != 1 else 9)
        self.spnEditorCursorWidth.valueChanged.connect(
            self.updateEditorSettings)
        self.spnEditorCursorWidth.setEnabled(opt["cursorWidth"] != 1)
        self.chkEditorNoBlinking.setChecked(opt["cursorNotBlinking"])
        self.chkEditorNoBlinking.stateChanged.connect(
            self.setApplicationCursorBlinking)
        # Text areas
        self.chkEditorMaxWidth.setChecked(opt["maxWidth"] != 0)
        self.chkEditorMaxWidth.stateChanged.connect(self.updateEditorSettings)
        self.spnEditorMaxWidth.setEnabled(opt["maxWidth"] != 0)
        self.spnEditorMaxWidth.setValue(500 if opt["maxWidth"] ==
                                        0 else opt["maxWidth"])
        self.spnEditorMaxWidth.valueChanged.connect(self.updateEditorSettings)
        self.spnEditorMarginsLR.setValue(opt["marginsLR"])
        self.spnEditorMarginsLR.valueChanged.connect(self.updateEditorSettings)
        self.spnEditorMarginsTB.setValue(opt["marginsTB"])
        self.spnEditorMarginsTB.valueChanged.connect(self.updateEditorSettings)
        # Paragraphs
        self.cmbEditorAlignment.setCurrentIndex(opt["textAlignment"])
        self.cmbEditorAlignment.currentIndexChanged.connect(
            self.updateEditorSettings)
        self.cmbEditorLineSpacing.setCurrentIndex(
            0 if opt["lineSpacing"] == 100 else 1 if opt["lineSpacing"] ==
            150 else 2 if opt["lineSpacing"] == 200 else 3)
        self.cmbEditorLineSpacing.currentIndexChanged.connect(
            self.updateEditorSettings)
        self.spnEditorLineSpacing.setValue(opt["lineSpacing"])
        self.spnEditorLineSpacing.valueChanged.connect(
            self.updateEditorSettings)
        self.spnEditorLineSpacing.setEnabled(
            opt["lineSpacing"] not in [100, 150, 200])
        self.spnEditorLineSpacing.valueChanged.connect(
            self.updateEditorSettings)
        self.spnEditorTabWidth.setValue(opt["tabWidth"])
        self.spnEditorTabWidth.valueChanged.connect(self.updateEditorSettings)
        self.chkEditorIndent.setChecked(opt["indent"])
        self.chkEditorIndent.stateChanged.connect(self.updateEditorSettings)
        self.spnEditorParaAbove.setValue(opt["spacingAbove"])
        self.spnEditorParaAbove.valueChanged.connect(self.updateEditorSettings)
        self.spnEditorParaBelow.setValue(opt["spacingBelow"])
        self.spnEditorParaBelow.valueChanged.connect(self.updateEditorSettings)
        self.timerUpdateWidgets = QTimer()
        self.timerUpdateWidgets.setSingleShot(True)
        self.timerUpdateWidgets.setInterval(250)
        self.timerUpdateWidgets.timeout.connect(self.updateAllWidgets)

        # Labels
        self.lstLabels.setModel(self.mw.mdlLabels)
        self.lstLabels.setRowHidden(0, True)
        self.lstLabels.clicked.connect(self.updateLabelColor)
        self.btnLabelAdd.clicked.connect(self.addLabel)
        self.btnLabelRemove.clicked.connect(self.removeLabel)
        self.btnLabelColor.clicked.connect(self.setLabelColor)

        # Statuses
        self.lstStatus.setModel(self.mw.mdlStatus)
        self.lstStatus.setRowHidden(0, True)
        self.btnStatusAdd.clicked.connect(self.addStatus)
        self.btnStatusRemove.clicked.connect(self.removeStatus)

        # Fullscreen
        self._editingTheme = None
        self.btnThemeEditOK.setIcon(qApp.style().standardIcon(
            QStyle.SP_DialogApplyButton))
        self.btnThemeEditOK.clicked.connect(self.saveTheme)
        self.btnThemeEditCancel.setIcon(qApp.style().standardIcon(
            QStyle.SP_DialogCancelButton))
        self.btnThemeEditCancel.clicked.connect(self.cancelEdit)
        self.cmbThemeEdit.currentIndexChanged.connect(
            self.themeEditStack.setCurrentIndex)
        self.cmbThemeEdit.setCurrentIndex(0)
        self.cmbThemeEdit.currentIndexChanged.emit(0)
        self.themeStack.setCurrentIndex(0)
        self.lstThemes.currentItemChanged.connect(self.themeSelected)
        self.populatesThemesList()
        self.btnThemeAdd.clicked.connect(self.newTheme)
        self.btnThemeEdit.clicked.connect(self.editTheme)
        self.btnThemeRemove.clicked.connect(self.removeTheme)
        self.timerUpdateFSPreview = QTimer()
        self.timerUpdateFSPreview.setSingleShot(True)
        self.timerUpdateFSPreview.setInterval(250)
        self.timerUpdateFSPreview.timeout.connect(self.updatePreview)
Esempio n. 16
0
    def start(self, device_list, send_type):
        self.send_type = send_type
        self.sec = 1
        self.timer.start(1000)
        print(len(device_list))

        for one_device in device_list:
            print(one_device)
            one_device = json.loads(one_device)
            item = QListWidgetItem(self.device_list_widget)
            item.setSizeHint(QSize(device_select_item_width, device_select_item_height))
            item.setText(one_device['name'][0:3] + '.')
            item.setWhatsThis(one_device['name'])
            self.device_list_widget.addItem(item)
        #

        self.device_list_widget.setGeometry(30, 10, len(device_list) * device_select_item_width, device_select_height)
        # self.send_message_btn.setGeometry(30 + len(device_list) * device_select_item_width, 10, 40, 40)
        self.resize(50 + len(device_list) * device_select_item_width, 60)

        self.setStyleSheet('''
                    QPushButton#close_btn{
                        background:red;
                        border:1px solid darkGray;
                        border-top-right-radius:10px;
                        border-top-left-radius:10px;
                        border-bottom-right-radius:10px;
                        border-bottom-left-radius:10px;
                        color:white;
                    }
                    QPushButton#close_btn:hover{
                        color:red;
                        background:white;
                    }
                    QListWidget{
                        text-transform: uppercase;
                        text-align: center;
                    }
                    QListWidget::Item{
                        border:2px solid white;
                        border-top-right-radius:20px;
                        border-top-left-radius:20px;
                        border-bottom-right-radius:20px;
                        border-bottom-left-radius:20px;
                        background:yellow;
                        margin-left: 5px;
                        margin-right: 5px;
                    }
                    QListWidget::Item:hover{
                        background:skyblue;
                        color:white;
                    }
                    DeviceSelectWindow{
                        border:2px solid darkGray;
                        border-top-right-radius:15px;
                        border-top-left-radius:15px;
                        border-bottom-right-radius:15px;
                        border-bottom-left-radius:15px;
                        background:white;
                    }
                ''')
        desktop = QApplication.desktop()
        self.move(desktop.width() * 0.6, desktop.height() * 0.4)
        """
    def __init__(self, tipo):
        super(VistaPrenotazione, self).__init__()
        self.tipo = tipo
        self.controller = ControllerListaPrenotazioni()
        self.controller_clienti = ControllerListaClienti()

        # Inserisce il 'lista_orari' le informazioni contenute nel file 'lista_prenotazioni.pickle'.
        self.lista_orari = self.controller.get_lista_prenotazioni()

        self.stylesheet_frame = """
                   QFrame{
                       background-color: white;
                       border: 1px solid grey;
                   }
               """

        self.stylesheet_window = """
                   QWidget{
                       background-color: #efefef;
                   }
               """

        self.stylesheet_label = """
                   QLabel{
                       background-color: white;
                   }

                   QLineEdit{
                       background-color: white;
                       border: 2px solid #dfdfdf
                   }

                   QComboBox{
                       background-color: white;
                       border: 1px solid grey;
                       color: black;
                   }

               """

        self.stylesheet_button_back = """
                   QPushButton{
                       background-color: transparent;
                       border-radius: 15px;
                   }

                   QPushButton::Pressed{
                       background-color: grey;
                   }        
               """

        self.stylesheet_button = """
                   QPushButton{
                       background-color: #cc3234;
                       color: white;
                       border-radius: 15px;
                   }

                   QPushButton::Pressed{
                       background-color: grey
                   }        
               """

        self.stylesheet_calendar = """
                    QCalendarWidget QToolButton{
                        background-color : lightblue;
                    }
                    QCalendarWidget QWidget{
                        background-color : lightblue;
                    }
        """

        # Inserimento e impostazioni grafiche dell'immagine dello sfondo della finestra.
        self.imagePath = "Image/foto.png"
        self.image = QImage(self.imagePath)
        self.label = QLabel(self)
        self.label.setPixmap(QPixmap.fromImage(self.image))
        self.label.setScaledContents(True)
        self.label.setGeometry(0, 0, 1000, 550)

        # Inserimento e impostazioni grafiche dell'etichetta 'Nuova Prenotazione'.
        self.label = QLabel(self)
        self.font = QFont("Arial", 18, QFont.Bold)
        self.label.setText("Nuova Prenotazione")
        self.label.setFont(self.font)
        self.label.setGeometry(50, 55, 350, 40)
        self.label.setStyleSheet('background-color: transparent')

        # Inserimento e impostazioni grafiche del frame nella finestra.
        self.frame = QFrame(self)
        self.frame.setStyleSheet(self.stylesheet_frame)
        self.frame.setGeometry(50, 100, 900, 280)

        # Usa la funzione 'create_label1' per creare due etichette.
        self.create_label1("Cliente", 150)
        self.create_label1("Tipo", 250)

        # Inserimento e impostazioni grafiche dell'etichetta 'Data'.
        self.label_edit = QLabel(self)
        self.label_edit.setText("Data")
        self.label_edit.setGeometry(500, 150, 100, 20)
        self.label_edit.setStyleSheet(self.stylesheet_label)
        self.font_label1 = QFont("Times", 9)
        self.label_edit.setFont(self.font_label1)

        # Inserimento e impostazioni grafiche del menù a tendina contenente la lista dei cliente
        # che non hanno effettuato alcuna prenotazione.
        self.edit_cliente = QComboBox(self)
        for cliente in self.controller_clienti.get_lista_clienti():
            self.controller_cliente = ControllerCliente(cliente)
            if self.controller_cliente.get_esame_teorico() == "None" or \
                    self.controller_cliente.get_esame_pratico() == "None":
                if self.controller_cliente.get_id() != "None":
                    self.edit_cliente.addItem(self.controller_cliente.get_nome() + " " + \
                                              self.controller_cliente.get_cognome())
        self.edit_cliente.setGeometry(250, 150, 200, 30)
        self.edit_cliente.setStyleSheet(self.stylesheet_label)

        # Inserimento e impostazioni grafiche del menù a tendina contenente la lista dei servizi
        # per cui è possibile effettuare un pagamento.
        self.edit_tipo = QComboBox(self)
        self.edit_tipo.addItem("Lezione", self.get_data("Lezione"))
        self.edit_tipo.addItem("Esame teorico", self.get_data("Esame teorico"))
        self.edit_tipo.addItem("Lezione guida", self.get_data("Lezione guida"))
        self.edit_tipo.addItem("Esame pratico", self.get_data("Esame pratico"))
        self.edit_tipo.setGeometry(250, 250, 200, 30)
        self.edit_tipo.setStyleSheet(self.stylesheet_label)

        # Inserimento e impostazioni grafiche del menù a tendina contenente le dati per cui
        # è possibile prenotarsi.
        self.edit_data = QComboBox(self)
        self.edit_data.setStyleSheet(self.stylesheet_label)
        self.edit_data.setGeometry(600, 150, 200, 30)

        # In base al servizio scelto vengono cambiate le dati per cui è possibile prenotarsi.
        self.edit_tipo.currentIndexChanged.connect(self.update_data)
        self.update_data(self.edit_tipo.currentIndex())

        # Inserimento e impostazioni grafiche del bottone per tornare alla vista precedente.
        self.button_back = QPushButton(self)
        self.button_back.setIcon(QIcon('Image/back.png'))
        self.button_back.setIconSize(QSize(90, 90))
        self.button_back.setGeometry(50, 420, 90, 90)
        self.button_back.setStyleSheet(self.stylesheet_button_back)
        self.button_back.clicked.connect(self.go_back)

        # Inserimento e impostazioni grafiche del bottone che permette di confermare la prenotazione.
        self.button_new_prenotazione = QPushButton(self)
        self.button_new_prenotazione.setText("Salva")
        self.font_button = QFont("Arial", 11)
        self.button_new_prenotazione.setFont(self.font_button)
        self.button_new_prenotazione.setGeometry(800, 440, 120, 50)
        self.button_new_prenotazione.setStyleSheet(self.stylesheet_button)
        self.button_new_prenotazione.clicked.connect(self.salva_prenotazione)

        # Impostazioni grafiche generali della finestra del programma.
        self.setWindowTitle("Nuova Prenotazione")
        self.setStyleSheet(self.stylesheet_window)
        self.resize(1000, 550)
        self.setFixedSize(self.size())
Esempio n. 18
0
 def sizeHint(self):
     return QSize(0, 100)
Esempio n. 19
0
 def minimumSizeHint(self):
     """Return a sensible size."""
     return QSize(8, 8)
Esempio n. 20
0
 def __init__(self, icon, *args, **kargs):
     super(QToolButtonVRectSmall, self).__init__(icon, QSize(8, 20), *args,
                                                 **kargs)
Esempio n. 21
0
    def __init__(self, configDict, parent=None):
        super(directConnectDlg, self).__init__(parent)
        if 'Conexiones' in configDict:
            self.confData = ambito = configDict['Conexiones']
        else:
            exit()

        self.listConnections = [name for name in ambito]
        self.conn = None

        self.etiqueta = QLabel("Eliga una conexion")
        self.lista = QComboBox()
        self.lista.addItems([
            'Eliga una conexión',
        ] + self.listConnections)

        self.buttonBox = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal)
        context = ((
            "Driver ",
            QComboBox,
            None,
            DRIVERS,
        ), (
            "DataBase Name",
            QLineEdit,
            None,
            None,
        ), (
            "Host",
            QLineEdit,
            None,
            None,
        ), (
            "User",
            QLineEdit,
            None,
            None,
        ), (
            "Password",
            QLineEdit,
            {
                'setEchoMode': QLineEdit.Password
            },
            None,
        ), (
            "Port",
            QLineEdit,
            None,
            None,
        ), (
            "Debug",
            QCheckBox,
            None,
            None,
        ))
        data = [None for k in range(len(context))]

        self.sheet = WPropertySheet(context, data)
        self.msgLine = QLabel('')
        self.msgLine.setWordWrap(True)

        meatLayout = QGridLayout()
        buttonLayout = QHBoxLayout()
        buttonLayout.addWidget(self.buttonBox)

        meatLayout.addWidget(self.etiqueta, 0, 0)
        meatLayout.addWidget(self.lista, 0, 1)
        meatLayout.addWidget(self.sheet, 1, 0, 6, 2)
        meatLayout.addWidget(self.msgLine, 7, 0)
        meatLayout.addLayout(buttonLayout, 8, 0)

        self.setLayout(meatLayout)
        self.setMinimumSize(QSize(382, 382))
        self.setWindowTitle("Seleccione la conexión a utilizar")

        self.sheet.hide()
        self.buttonBox.hide()

        self.lista.currentIndexChanged[int].connect(self.selecConn)
        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)
Esempio n. 22
0
    def save_thumbnail(
        self,
        full_file_name: str,
        size: int,
        modification_time: Union[float, int],
        generation_failed: bool,
        thumbnail: QImage,
        camera_model: str = None,
        free_desktop_org: bool = True,
    ) -> Optional[str]:
        """
        Save a thumbnail in the thumbnail cache.

        :param full_file_name: full path of the file (including file
         name). If the path contains symbolic links, two thumbnails will be
         saved: the canonical path (without symlinks), and the path as
         passed.
        :param size: size of the file in bytes
        :param modification_time: file modification time, to be turned
         into a float if it's not already
        :param generation_failed: True if the thumbnail is meant to
         signify the application failed to generate the thumbnail. If
         so, it will be saved as an empty PNG in the application
         subdirectory in the fail cache directory.
        :param thumbnail: the thumbnail to be saved. Will not be
         resized. Will be ignored if generation_failed is True.
        :param camera_model: optional camera model. If the thumbnail is
         not from a camera, then should be None.
        :param free_desktop_org: if True, then image will be convereted
         to 8bit mode if necessary
        :return the md5_name of the saved file, else None if operation
        failed
        """

        if not self.valid:
            return None

        # Save to both the real path and the path passed, which may include
        # symbolic links
        full_file_name_real_path = os.path.realpath(full_file_name)
        if full_file_name_real_path != full_file_name:
            self.save_thumbnail(
                full_file_name_real_path,
                size,
                modification_time,
                generation_failed,
                thumbnail,
                camera_model,
                free_desktop_org,
            )

        md5_name, uri = self.md5.md5_hash_name(full_file_name, camera_model)
        if generation_failed:
            thumbnail = QImage(QSize(1, 1), QImage.Format_Indexed8)
            save_dir = self.failure_dir
        else:
            save_dir = self.cache_dir
        path = os.path.join(save_dir, md5_name)

        thumbnail.setText("Thumb::URI", uri)
        thumbnail.setText("Thumb::MTime", str(float(modification_time)))
        thumbnail.setText("Thumb::Size", str(size))

        if free_desktop_org and not generation_failed:
            if thumbnail.depth() != 8:
                thumbnail = thumbnail.convertToFormat(QImage.Format_Indexed8)

        temp_path = os.path.join(save_dir,
                                 self.random_filename.name(extension="png"))
        if thumbnail.save(temp_path):
            os.rename(temp_path, path)
            os.chmod(path, 0o600)
            if generation_failed:
                logging.debug("Wrote {}x{} thumbnail {} for {}".format(
                    thumbnail.width(), thumbnail.height(), path, uri))
            return md5_name
        else:
            return None
Esempio n. 23
0
    def headerData(self, section, orientation, role):
        if role == Qt.SizeHintRole:
            return QSize(1, 1)

        return None
Esempio n. 24
0
 def sizeHint(self):
     return QSize(self.windowWidth*self.widthRatio,
                  self.windowHeight*self.heightRatio)
Esempio n. 25
0
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QSize, QCoreApplication
from legionarek.parser import Parser
from legionarek.canvas import Canvas
from legionarek.constants import CANVAS_HEIGHT, CANVAS_WIDTH
from legionarek.gui import CardsOnTable

if __name__ == '__main__':
    parser = Parser()
    parser.parse()
    canvas = Canvas(CANVAS_WIDTH, CANVAS_HEIGHT, parser.cards)
    rendered_cards = canvas.render()
    app = QApplication([])
    card_gallery = CardsOnTable()
    card_gallery.populate(rendered_cards, QSize(50, 50))

    card_gallery.show()
    app.exec()
Esempio n. 26
0
 def data(self, index, role):
     value = super(Model, self).data(index, role)
     if role == Qt.SizeHintRole:
         return QSize(0, 30)
     return value
Esempio n. 27
0
    def __init__(self):
        super(ParameterDialog, self).__init__()

        self.parameter_dialog = QtWidgets.QDialog()
        self.parameter_dialog.setObjectName("parameter_dialog")
        self.parameter_dialog.resize(610, 500)
        self.parameter_dialog.setWindowTitle(LG("camera parameters"))
        self.parameter_dialog.setWindowIcon(
            QIcon(utils.get_path(["iconImages", "PyroVision.png"])))

        self.mainLayout = QtWidgets.QVBoxLayout(self.parameter_dialog)
        self.mainLayout.setObjectName("mainLayout")

        ########Full text label: rolling shutter########
        self.textExplain1 = QtWidgets.QTextEdit(self.parameter_dialog)
        self.textExplain1.setObjectName("textExplain1")
        self.textExplain1.setText(LG("camera text"))
        self.textExplain1.setMinimumSize(QSize(605, 80))
        self.textExplain1.setMaximumSize(QSize(605, 80))
        self.textExplain1.setReadOnly(True)
        self.textExplain1.setStyleSheet(
            "QTextEdit {background-color: rgb(240, 240, 240);}")
        self.mainLayout.addWidget(self.textExplain1)

        ########selected calibration########
        # self.calibrationObject = subject_found[0]
        # self.calibrationMethod = QtWidgets.QLabel(self.calibration_dialog)
        # self.calibrationMethod.setObjectName("calibrationMethod")
        # self.calibrationMethod.setText("calibration method: " + self.calibrationObject.name + " 2D calibration")
        # self.calibrationMethod.setFont(QFont('MS Shell Dlg 2', 10))
        # self.calibrationMethod.setAlignment(Qt.AlignCenter)
        # self.mainLayout.addWidget(self.calibrationMethod)

        ########cmo rolling shutter parameters########

        ########Scan Direction###########
        self.rollingType = QtWidgets.QHBoxLayout()
        self.rollingType.setObjectName("rollingType")

        #Description for combo box
        self.typeLabel = QtWidgets.QLabel(self.parameter_dialog)
        self.typeLabel.setObjectName("typeLabel")
        self.typeLabel.setText(LG("choose scan direction"))
        self.typeLabel.setMinimumSize(QSize(480, 32))
        self.typeLabel.setMaximumSize(QSize(480, 32))
        self.rollingType.addWidget(self.typeLabel)

        # #spacer
        # spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        # self.rollingType.addItem(spacerItem1)

        #combo box
        self.typeComboBox = QtWidgets.QComboBox(self.parameter_dialog)
        self.typeComboBox.setMinimumSize(QSize(125, 26))
        self.typeComboBox.setMaximumSize(QSize(125, 26))
        self.typeComboBox.setObjectName("typeComboBox")
        self.typeComboBox.addItems([
            "top to bottom", "left to right", "bottom to top", "right to left"
        ])
        #self.typeComboBox.activated[str].connect(self.ComboMode)
        self.rollingType.addWidget(self.typeComboBox)

        self.mainLayout.addLayout(self.rollingType)

        ###########Time to scan##########
        self.scanTime = QtWidgets.QHBoxLayout()
        self.scanTime.setObjectName("scanTime")

        #Description for text edit 1
        self.editLabel1 = QtWidgets.QLabel(self.parameter_dialog)
        self.editLabel1.setObjectName("editLabel1")
        self.editLabel1.setText(LG("scanning duration"))
        self.editLabel1.setMinimumSize(QSize(480, 32))
        self.editLabel1.setMaximumSize(QSize(480, 32))
        self.scanTime.addWidget(self.editLabel1)

        # #spacer
        # spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        # self.scanTime.addItem(spacerItem2)

        #Text edit for scan time
        self.scanTimeText = QtWidgets.QPlainTextEdit(self.parameter_dialog)
        self.scanTimeText.setMinimumSize(QSize(80, 28))
        self.scanTimeText.setMaximumSize(QSize(80, 28))
        self.scanTimeText.setObjectName("scanTimeText")
        self.scanTimeText.appendPlainText(
            str(round(GlobalData.cmoParameter["scanDuration"] * 1000, 3)))
        self.scanTime.addWidget(self.scanTimeText)
        #self.stickLength.setEnabled(False)

        #Unit label for text edit 1
        self.editUnit1 = QtWidgets.QLabel(self.parameter_dialog)
        self.editUnit1.setObjectName("editUnit1")
        self.editUnit1.setText("ms")
        self.editUnit1.setMinimumSize(QSize(40, 32))
        self.editUnit1.setMaximumSize(QSize(40, 32))
        self.scanTime.addWidget(self.editUnit1)

        self.mainLayout.addLayout(self.scanTime)

        ########Time between scan########
        self.gapTime = QtWidgets.QHBoxLayout()
        self.gapTime.setObjectName("gapTime")

        #Description for time between scan
        self.editLabel2 = QtWidgets.QLabel(self.parameter_dialog)
        self.editLabel2.setMinimumSize(QSize(480, 32))
        self.editLabel2.setMaximumSize(QSize(480, 32))
        self.editLabel2.setObjectName("editLabel2")
        self.gapTime.addWidget(self.editLabel2)
        self.editLabel2.setText(LG("scanning gap"))

        # #spacer
        # spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        # self.gapTime.addItem(spacerItem3)

        #Text edit for gap time
        self.gapTimeEdit = QtWidgets.QPlainTextEdit(self.parameter_dialog)
        self.gapTimeEdit.setMinimumSize(QSize(80, 28))
        self.gapTimeEdit.setMaximumSize(QSize(80, 28))
        self.gapTimeEdit.setObjectName("gapTimeEdit")
        self.gapTimeEdit.appendPlainText(
            str(round(GlobalData.cmoParameter["scanGap"] * 1000, 3)))
        self.gapTime.addWidget(self.gapTimeEdit)
        #self.blCoordinateX.setEnabled(False)

        #Unit label for gap time
        self.editUnit2 = QtWidgets.QLabel(self.parameter_dialog)
        self.editUnit2.setObjectName("editUnit2")
        self.editUnit2.setText("ms")
        self.editUnit2.setMinimumSize(QSize(40, 32))
        self.editUnit2.setMaximumSize(QSize(40, 32))
        self.gapTime.addWidget(self.editUnit2)

        self.mainLayout.addLayout(self.gapTime)

        ########spacing#########
        spacerItem = QtWidgets.QSpacerItem(20, 40,
                                           QtWidgets.QSizePolicy.Minimum,
                                           QtWidgets.QSizePolicy.Expanding)
        self.mainLayout.addItem(spacerItem)

        ########save calibration or quit dialog#######
        self.buttonsLayout = QtWidgets.QHBoxLayout()
        self.buttonsLayout.setObjectName("buttonsLayout")
        self.saveBtn = QtWidgets.QPushButton(self.parameter_dialog)
        self.saveBtn.setMinimumSize(QSize(300, 28))
        self.saveBtn.setMaximumSize(QSize(300, 28))
        self.saveBtn.setObjectName("saveBtn")
        self.saveBtn.clicked.connect(self.saveSettings)
        self.saveBtn.setText(LG("save"))
        self.buttonsLayout.addWidget(self.saveBtn)

        self.cancelBtn = QtWidgets.QPushButton(self.parameter_dialog)
        self.cancelBtn.setMinimumSize(QSize(300, 28))
        self.cancelBtn.setMaximumSize(QSize(300, 28))
        self.cancelBtn.setObjectName("cancelBtn")
        self.cancelBtn.clicked.connect(self.cancel_Btn)
        self.cancelBtn.setText(LG("cancel"))
        self.buttonsLayout.addWidget(self.cancelBtn)
        self.mainLayout.addLayout(self.buttonsLayout)
Esempio n. 28
0
 def sizeHint(self):
     return QSize(900, 560)
Esempio n. 29
0
 def minimumSizeHint(self):
     return QSize(50, 50)
Esempio n. 30
0
 def minimumSizeHint(self):
     return QSize(1, self.fontMetrics().height())