Пример #1
0
    def __init__(self, page_width, page_height, margin_width=0):
        self.page_width = page_width
        self.page_height = page_height
        self.margin_width = margin_width
        self.include_crop_marks = bool(margin_width)

        QApplication(['my-q-application'])
        f = QFontDatabase.addApplicationFont('OldStandard-Regular.ttf')
        f = QFontDatabase.addApplicationFont('OldStandard-Italic.ttf')
        f = QFontDatabase.addApplicationFont('OldStandard-Bold.ttf')
        names = QFontDatabase.applicationFontFamilies(f)
        print(names)
        self.writer = QPdfWriter('book.pdf')
        size = QSizeF((2 * margin_width + page_width) * mm,
                      (2 * margin_width + page_height) * mm)
        self.writer.setPageSizeMM(size)
        margins = QMarginsF(margin_width, margin_width,
                            margin_width, margin_width)
        self.writer.setPageMargins(margins)
        self.painter = QPainter(self.writer)
        if self.include_crop_marks:
            self.draw_crop_marks()
Пример #2
0
class WidgetMainMenu(QWidget):
    def __init__(self):
        QWidget.__init__(self)
        self.a = QFontDatabase()
        print(self.a.families())
        print(self.a.writingSystemSample(QFontDatabase.Arabic))

        #focus qeuee
        #Texts
        #Margin
        #child widget access
        #Top Bar
        #multiple windows handling (one open, main close all close,
        #nice Layouts
        #Rights
        #emoji and other langs (encoding)

        self.MainToolbar = QToolBar()
        self.DonateButton = QPushButton()

        self.DonateButton.setStatusTip("F*****G")
        # self.DonateButton.setBackgroundRole(QIcon(QPixmap(":/Bitcoin.png")))
        self.DonateButton.setFont(QFont("Vazir"))
        self.DonateButton.setMinimumSize(50, 100)
        self.DonateButton.setText("test")

        self.MainToolbar.addWidget(self.DonateButton)

        self.ActiveSessionShortCutGroup = QGroupBox()
        # self.ActiveSessionShortCutGroup
        self.ActiveSessionShortCutGroup.setTitle("Shortcuts")
        self.ActiveSessionShortCutGroupVBox = QVBoxLayout()
        self.ActiveSessionShortCutGroupVBox.setContentsMargins(15, 15, 15, 15)

        def ShortCutVBox(text):
            ShortCutInputButton = QPushButton()
            ShortCutResetButton = QPushButton("Reset")
            ShortCutText = QLabel(text)
            ShortCutResetButton.setMaximumWidth(100)
            ShortCutButtonsHBox = QHBoxLayout()
            ShortCutButtonsHBox.setContentsMargins(10, 10, 10, 10)
            ShortCutButtonsHBox.addWidget(ShortCutInputButton)
            ShortCutButtonsHBox.addWidget(ShortCutResetButton)
            ShortCutBlockVBox = QVBoxLayout()
            ShortCutBlockVBox.addWidget(ShortCutText)
            ShortCutBlockVBox.addLayout(ShortCutButtonsHBox)
            return ShortCutBlockVBox

        CipherShortCutBlockVBox = ShortCutVBox(
            "Enter Ciphering ShortCut (Also Decode in Smart Mode)")
        DecipherShortCutBlockVBox = ShortCutVBox(
            "Enter Deciphering ShortCut (Also Code in Smart Mode - could be left empty)"
        )

        self.ActiveSessionShortCutGroupVBox.addLayout(CipherShortCutBlockVBox)
        self.ActiveSessionShortCutGroupVBox.addLayout(
            DecipherShortCutBlockVBox)
        self.ActiveSessionShortCutGroup.setLayout(
            self.ActiveSessionShortCutGroupVBox)

        self.SettingsGroup = QGroupBox()
        self.SettingsGroupVBox = QVBoxLayout()

        self.OnOffDeamonBox = QCheckBox(
            "Start This service and Open Angel Gates to your Privacy, KINDA! :)"
        )
        self.StartUpDeamonBox = QCheckBox(
            "Start CryptoCut Deamon at the System Boot up")
        self.EncryptNotifBox = QCheckBox(
            "Show a Notification After (De/En)crpt of Texts And Show its Successful or Not"
        )
        self.VirtualKeyboardBox = QCheckBox(
            "Open Virtual Keyboard for Keylogger Suspection Situations")
        self.SaftyTweaksBox = QCheckBox(
            "Our Small Tweaks would be Applied on Standard Methods to Make them even better"
        )
        self.SuperSafeModeBox = QCheckBox(
            "Open a Box with Password Input Mode to write text in and Paste in last Focused Region"
        )
        self.RapidModeBox = QCheckBox(
            "Paste Text Back in place and Delete the text")
        self.TrayDeamonBox = QCheckBox(
            "Show Application Icon in Tray for Ease of Access")
        self.SmartModeBox = QCheckBox(
            "Automatically Detect Its a Cipher or a Normal Text and Work with one Shortcut"
        )

        self.SettingsGroupVBox.addWidget(self.OnOffDeamonBox)
        self.SettingsGroupVBox.addWidget(self.StartUpDeamonBox)
        self.SettingsGroupVBox.addWidget(self.EncryptNotifBox)
        self.SettingsGroupVBox.addWidget(self.VirtualKeyboardBox)
        self.SettingsGroupVBox.addWidget(self.SaftyTweaksBox)
        self.SettingsGroupVBox.addWidget(self.SuperSafeModeBox)
        self.SettingsGroupVBox.addWidget(self.RapidModeBox)
        self.SettingsGroupVBox.addWidget(self.TrayDeamonBox)
        self.SettingsGroupVBox.addWidget(self.SmartModeBox)

        self.SettingsGroup.setTitle("Settings")
        self.SettingsGroup.setLayout(self.SettingsGroupVBox)

        self.apply = QPushButton("Apply Setting")
        self.reset = QPushButton("Reset to Default")
        self.apply.setMinimumWidth(150)
        self.reset.setMinimumWidth(150)
        self.apply.setMinimumHeight(35)
        self.reset.setMinimumHeight(35)

        self.Container = QHBoxLayout()

        self.Container.addWidget(self.apply)
        self.Container.addWidget(self.reset)
        self.Container.minimumHeightForWidth(20)

        self.Main = QVBoxLayout()
        self.Main.setMargin(10)
        self.Main.addWidget(self.MainToolbar)
        self.Main.addWidget(self.ActiveSessionShortCutGroup)
        self.Main.addWidget(self.SettingsGroup)
        self.TestPlainTextEdit = QPlainTextEdit("Test CryptoCut HERE")
        self.TestPlainTextEdit.setMinimumHeight(200)
        self.Main.addWidget(self.TestPlainTextEdit)
        self.Main.addLayout(self.Container)
        #self.table_view.setSizePolicy(size)
        # Set the layout to the QWidget
        self.setLayout(self.Main)

        # Signals and Slots
        # self.add.clicked.connect(self.add_element)
        # self.quit.clicked.connect(self.quit_application)
        # self.clear.clicked.connect(self.clear_table)
        # self.description.textChanged[str].connect(self.check_disable)
        # self.price.textChanged[str].connect(self.check_disable)

    @Slot()
    def add_element(self):
        des = self.description.text()
        price = self.price.text()

        self.table.insertRow(self.items)
        description_item = QTableWidgetItem(des)
        price_item = QTableWidgetItem("{:.2f}".format(float(price)))
        price_item.setTextAlignment(Qt.AlignRight)

        self.table.setItem(self.items, 0, description_item)
        self.table.setItem(self.items, 1, price_item)

        self.description.setText("")
        self.price.setText("")

        self.items += 1

    @Slot()
    def check_disable(self, s):
        if not self.description.text() or not self.price.text():
            self.add.setEnabled(False)
        else:
            self.add.setEnabled(True)

    @Slot()
    def plot_data(self):
        # Get table information
        series = QtCharts.QPieSeries()
        for i in range(self.table.rowCount()):
            text = self.table.item(i, 0).text()
            number = float(self.table.item(i, 1).text())
            series.append(text, number)

        chart = QtCharts.QChart()
        chart.addSeries(series)
        chart.legend().setAlignment(Qt.AlignLeft)
        self.chart_view.setChart(chart)

    @Slot()
    def quit_application(self):
        QApplication.quit()

    def fill_table(self, data=None):
        data = self._data if not data else data
        for desc, price in data.items():
            description_item = QTableWidgetItem(desc)
            price_item = QTableWidgetItem("{:.2f}".format(price))
            price_item.setTextAlignment(Qt.AlignRight)
            self.table.insertRow(self.items)
            self.table.setItem(self.items, 0, description_item)
            self.table.setItem(self.items, 1, price_item)
            self.items += 1

    @Slot()
    def clear_table(self):
        self.table.setRowCount(0)
        self.items = 0
Пример #3
0
    def __init__(self):
        QWidget.__init__(self)
        self.a = QFontDatabase()
        print(self.a.families())
        print(self.a.writingSystemSample(QFontDatabase.Arabic))

        #focus qeuee
        #Texts
        #Margin
        #child widget access
        #Top Bar
        #multiple windows handling (one open, main close all close,
        #nice Layouts
        #Rights
        #emoji and other langs (encoding)

        self.MainToolbar = QToolBar()
        self.DonateButton = QPushButton()

        self.DonateButton.setStatusTip("F*****G")
        # self.DonateButton.setBackgroundRole(QIcon(QPixmap(":/Bitcoin.png")))
        self.DonateButton.setFont(QFont("Vazir"))
        self.DonateButton.setMinimumSize(50, 100)
        self.DonateButton.setText("test")

        self.MainToolbar.addWidget(self.DonateButton)

        self.ActiveSessionShortCutGroup = QGroupBox()
        # self.ActiveSessionShortCutGroup
        self.ActiveSessionShortCutGroup.setTitle("Shortcuts")
        self.ActiveSessionShortCutGroupVBox = QVBoxLayout()
        self.ActiveSessionShortCutGroupVBox.setContentsMargins(15, 15, 15, 15)

        def ShortCutVBox(text):
            ShortCutInputButton = QPushButton()
            ShortCutResetButton = QPushButton("Reset")
            ShortCutText = QLabel(text)
            ShortCutResetButton.setMaximumWidth(100)
            ShortCutButtonsHBox = QHBoxLayout()
            ShortCutButtonsHBox.setContentsMargins(10, 10, 10, 10)
            ShortCutButtonsHBox.addWidget(ShortCutInputButton)
            ShortCutButtonsHBox.addWidget(ShortCutResetButton)
            ShortCutBlockVBox = QVBoxLayout()
            ShortCutBlockVBox.addWidget(ShortCutText)
            ShortCutBlockVBox.addLayout(ShortCutButtonsHBox)
            return ShortCutBlockVBox

        CipherShortCutBlockVBox = ShortCutVBox(
            "Enter Ciphering ShortCut (Also Decode in Smart Mode)")
        DecipherShortCutBlockVBox = ShortCutVBox(
            "Enter Deciphering ShortCut (Also Code in Smart Mode - could be left empty)"
        )

        self.ActiveSessionShortCutGroupVBox.addLayout(CipherShortCutBlockVBox)
        self.ActiveSessionShortCutGroupVBox.addLayout(
            DecipherShortCutBlockVBox)
        self.ActiveSessionShortCutGroup.setLayout(
            self.ActiveSessionShortCutGroupVBox)

        self.SettingsGroup = QGroupBox()
        self.SettingsGroupVBox = QVBoxLayout()

        self.OnOffDeamonBox = QCheckBox(
            "Start This service and Open Angel Gates to your Privacy, KINDA! :)"
        )
        self.StartUpDeamonBox = QCheckBox(
            "Start CryptoCut Deamon at the System Boot up")
        self.EncryptNotifBox = QCheckBox(
            "Show a Notification After (De/En)crpt of Texts And Show its Successful or Not"
        )
        self.VirtualKeyboardBox = QCheckBox(
            "Open Virtual Keyboard for Keylogger Suspection Situations")
        self.SaftyTweaksBox = QCheckBox(
            "Our Small Tweaks would be Applied on Standard Methods to Make them even better"
        )
        self.SuperSafeModeBox = QCheckBox(
            "Open a Box with Password Input Mode to write text in and Paste in last Focused Region"
        )
        self.RapidModeBox = QCheckBox(
            "Paste Text Back in place and Delete the text")
        self.TrayDeamonBox = QCheckBox(
            "Show Application Icon in Tray for Ease of Access")
        self.SmartModeBox = QCheckBox(
            "Automatically Detect Its a Cipher or a Normal Text and Work with one Shortcut"
        )

        self.SettingsGroupVBox.addWidget(self.OnOffDeamonBox)
        self.SettingsGroupVBox.addWidget(self.StartUpDeamonBox)
        self.SettingsGroupVBox.addWidget(self.EncryptNotifBox)
        self.SettingsGroupVBox.addWidget(self.VirtualKeyboardBox)
        self.SettingsGroupVBox.addWidget(self.SaftyTweaksBox)
        self.SettingsGroupVBox.addWidget(self.SuperSafeModeBox)
        self.SettingsGroupVBox.addWidget(self.RapidModeBox)
        self.SettingsGroupVBox.addWidget(self.TrayDeamonBox)
        self.SettingsGroupVBox.addWidget(self.SmartModeBox)

        self.SettingsGroup.setTitle("Settings")
        self.SettingsGroup.setLayout(self.SettingsGroupVBox)

        self.apply = QPushButton("Apply Setting")
        self.reset = QPushButton("Reset to Default")
        self.apply.setMinimumWidth(150)
        self.reset.setMinimumWidth(150)
        self.apply.setMinimumHeight(35)
        self.reset.setMinimumHeight(35)

        self.Container = QHBoxLayout()

        self.Container.addWidget(self.apply)
        self.Container.addWidget(self.reset)
        self.Container.minimumHeightForWidth(20)

        self.Main = QVBoxLayout()
        self.Main.setMargin(10)
        self.Main.addWidget(self.MainToolbar)
        self.Main.addWidget(self.ActiveSessionShortCutGroup)
        self.Main.addWidget(self.SettingsGroup)
        self.TestPlainTextEdit = QPlainTextEdit("Test CryptoCut HERE")
        self.TestPlainTextEdit.setMinimumHeight(200)
        self.Main.addWidget(self.TestPlainTextEdit)
        self.Main.addLayout(self.Container)
        #self.table_view.setSizePolicy(size)
        # Set the layout to the QWidget
        self.setLayout(self.Main)
Пример #4
0
class Mainwindow(QWindow):
    Logger.log.info("Instantiating {} class...".format(__qualname__))
    guiname = None

    def __init__(self, commander, codegen, config, logger, support, securitylevel, *args, **kwargs):
        super().__init__(*args, **kwargs)
        Logger.log.debug('{} initializing....'.format(__name__))
        self.window = None
        self.config = config
        self.logger = logger
        self.support = support
        self.log = Logger.log
        self.commander = commander
        self.securitylevel = securitylevel
        self.startup_processes()
        self.guicode = Guicoderate(window=self.window, codegen=codegen, config=config, logger=logger)
        self.freqcode = GuiFrequencies(window=self.window, codegen=codegen, config=config, logger=logger)
        self.signaling = Signaling(window=self.window, commander=self.commander, config=self.config, logger=self.logger,
                                   support=self.support)
        self.log.debug("{} init complete...".format(__name__))

    # *****************************************************************************
    def startup_processes(self):
        self.config_file_load()
        self.loadscreen()
        self.screen_fullscreen()
        self.fonts_list()
        self.securitylevel.index_tab_pages(self.window)
        self.securitylevel.set_security_level("technician")
        self.securitylevel.update_gui(self.window)

    # *****************************************************************************
    def fonts_list(self):
        """
        list available fonts
        """
        self.fontDB = QFontDatabase()
        self.fontDB.addApplicationFont(":/FONTS/FONTS/digital-7.ttf")
        self.fontDB.addApplicationFont(":/FONTS/FONTS/SiemensSlab_Prof_BlackItalic.ttf")
        self.siemensslab = QFont("Siemens Slab", 64, 1)
        self.digital7font = QFont("Digital-7", 64, 1)
        self.window.LBL_loop_current.setFont(self.digital7font)

    # *****************************************************************************
    def screen_fullscreen(self, fullscreen=None):
        if self.support.ostype == 'rpi' or fullscreen:
            self.window.showFullScreen()
            self.log.debug("Window set to fullscreen...")
        else:
            self.window.showNormal()

    # ******************************************************************************
    def config_file_load(self):
        Mainwindow.display_brightness = self.config.display_brightness
        Mainwindow.guiname = self.config.guiname
        Mainwindow.screen_brightness_max = self.config.screen_brightness_max
        Mainwindow.screen_brightness_min = self.config.screen_brightness_min

    # ******************************************************************************
    def loadscreen(self):
        try:
            ui_file = QFile(Mainwindow.guiname)
            ui_file.open(QFile.ReadOnly)
            loader = QUiLoader()
            self.window = loader.load(ui_file)
            ui_file.close()
            self.window.show()
            self.log.debug('Loading screen ' + self.guiname)
        except FileNotFoundError:
            self.log.debug("Could not find {}".format(self.guiname))  # CATCHES EXIT SHUTDOWN
Пример #5
0
from PySide2.QtCore import QFile, QTextStream, QSettings, QStandardPaths
from PySide2.QtGui import QFontDatabase, QIcon
from hichess_gui import HichessGui
from dialogs import SettingsDialog
import logging
import sys

import resources
import qbreezercc

if __name__ == "__main__":
    logging.basicConfig(level=logging.DEBUG)

    app = QApplication(sys.argv)

    QFontDatabase.addApplicationFont(":/font/bahnschrift.ttf")
    app.setWindowIcon(QIcon(":/images/chessboard.png"))

    app.setApplicationDisplayName("HiChess")
    app.setOrganizationName("Zneigras")
    app.setOrganizationDomain("https://github.com/H-a-y-k/Hichess")

    breeze = QFile(":qbreeze/dark.qss")
    main = QFile(":/style/styles.css")

    # stylesheet as string
    breezeQss = ""
    mainQss = ""

    if breeze.open(QFile.ReadOnly):
        textstream = QTextStream(breeze)
Пример #6
0
class DigitalGauge(QWidget):
    def __init__(self, parent, config):
        super(DigitalGauge, self).__init__(parent)

        self.config = config
        self.value = config["min"]

        self.font_db = QFontDatabase()
        self.font_id = self.font_db.addApplicationFont("fonts/DS-DIGI.TTF")
        self.families = self.font_db.applicationFontFamilies(self.font_id)
        #print [str(f) for f in self.families] #DS-Digital

        self.font = QFont("DS-Digital")
        self.note_font = QFont("DS-Digital")
        self.title_font = QFont("DS-Digital")
        self.color = QColor(config["color"])
        self.pen_color = QColor(Qt.black)
        self.red_color = QColor(config["redline_color"])
        self.brush = QBrush(self.color)
        self.brush_bg = QBrush(QColor("#555555"))
        self.brush_red = QBrush(self.red_color)
        self.brush_red_bg = QBrush(self.red_color)
        self.pen = QPen(self.pen_color)
        self.red_pen = QPen(self.red_color)
        self.indicator_color = QColor(config["indicator_color"])
        self.text_pen = QPen(self.color)
        self.indicator_pen = QPen(self.indicator_color)

        self.font.setPixelSize(self.config["font_size"])

        self.pen.setWidth(1)
        self.red_pen.setWidth(1)

        # TODO: make 80 configurable
        s = scale(config["min"], config["max"],
                  float(config["max"] - config["min"]) / 80)

        self.angles = map_scale(s, 0, 270)
        self.str_scale, self.multiplier = str_scale(s, config["scale_mult"])

        self.red_angle = 270
        if config["redline"] is not None:
            self.red_angle = map_value(config["redline"], config["min"],
                                       config["max"], 0, 270)

    def render(self, response):
        # approach the value
        self.value += (response.value.magnitude - self.value) / 8
        self.update()

    def sizeHint(self):
        return QSize(350, 300)

    def paintEvent(self, e):

        r = min(self.width(), self.height()) / 2
        self.__text_r = r - (r / 10)  # radius of the text
        self.__tick_r = r - (r / 8)  # outer radius of the tick marks
        self.__tick_l = (r / 6)  # length of each tick, extending inwards
        self.__needle_l = (r / 5) * 3  # length of the needle

        self.font.setPixelSize(int(max(self.width(), self.height()) / 3))
        self.note_font.setPixelSize(int(max(self.width(), self.height()) / 30))
        self.title_font.setPixelSize(int(
            max(self.width(), self.height()) / 12))

        painter = QPainter()
        painter.begin(self)

        painter.setFont(self.font)
        painter.setPen(self.pen)
        painter.setBrush(self.brush)
        painter.setRenderHint(QPainter.Antialiasing)

        self.draw_title(painter)
        self.draw_value(painter)
        if self.config["numerals"]:
            self.draw_multiplier(painter)
        self.draw_marks(painter)

        painter.end()

    def draw_marks(self, painter):
        painter.save()

        painter.translate(self.width() / 2, self.height() / 2)

        # draw the ticks

        end = self.__tick_r - self.__tick_l
        yTopOffset = int(2 * self.__tick_r *
                         math.sin(math.radians(self.angles[1] / 2)) / 2)  #- 1
        yBottomOffset = int(
            2 * end * math.sin(math.radians(self.angles[1] / 2)) / 2)  #- 1

        angle = map_value(self.value, self.config["min"], self.config["max"],
                          0, 270)
        angle = min(angle, 270)

        for a in self.angles:
            painter.save()
            painter.rotate(90 + 45 + a)

            if a > self.red_angle and a <= angle:
                painter.setBrush(self.brush_red)
            elif a <= angle:
                painter.setBrush(self.brush)
            elif a > self.red_angle:
                painter.setBrush(self.brush_red_bg)
            else:
                painter.setBrush(self.brush_bg)

            path = QPainterPath()
            path.moveTo(end, -yBottomOffset)
            path.lineTo(self.__tick_r, -yTopOffset)
            path.lineTo(self.__tick_r, yTopOffset)
            path.lineTo(end, yBottomOffset)
            path.lineTo(end, -yBottomOffset)

            painter.drawPath(path)

            painter.restore()
        painter.restore()

    def draw_title(self, painter):
        painter.save()
        painter.setPen(self.text_pen)
        painter.setFont(self.title_font)

        font_offset = int(self.height() / 8)

        r_height = self.config["font_size"] + font_offset
        r = QRect(0, self.height() - r_height, self.width(), r_height)
        painter.drawText(r, Qt.AlignHCenter | Qt.AlignVCenter,
                         self.config["title"])

        painter.restore()

    def draw_value(self, painter):
        painter.save()
        painter.setPen(self.indicator_pen)
        painter.setFont(self.font)

        r_height = self.height() / 2 + 20
        #r = QRect(0, self.height()/2 - r_height/2, self.width(), self.height()/2 + r_height/2)
        r = QRect(0, 0, self.width(), self.height())
        painter.drawText(r, Qt.AlignHCenter | Qt.AlignVCenter,
                         str(int(self.value // self.multiplier)))
        #painter.drawText(r, Qt.AlignHCenter | Qt.AlignVCenter, "TEST")

        painter.restore()

    def draw_multiplier(self, painter):
        if self.multiplier > 1:
            painter.save()

            painter.setPen(self.text_pen)
            painter.setFont(self.note_font)
            s = "x" + str(self.multiplier)
            r = QRect(0, self.width() / 6, self.width(), self.height())
            painter.drawText(r, Qt.AlignHCenter | Qt.AlignVCenter, s)

            painter.restore()
        def __init__(self, parent: QWidget = None):
            super(FrmColorButton, self).__init__(parent)
            self.__iconFont: QFont = QFont()

            # 判断图形字体是否存在,不存在则加入
            fontDb: QFontDatabase = QFontDatabase()
            if not fontDb.families().__contains__("FontAwesome"):
                fontId: int = fontDb.addApplicationFont(":/image/fontawesome-webfont.ttf")
                fontName: List[str] = fontDb.applicationFontFamilies(fontId)
                if len(fontName) == 0:
                    print("load fontawesome-webfont.ttf error")

            if fontDb.families().__contains__("FontAwesome"):
                self.__iconFont: QFont = QFont("FontAwesome")
                self.__iconFont.setHintingPreference(QFont.PreferNoHinting)  # if Qt version >= 4.8.0

            layout = QGridLayout()

            self.colorButton1 = ColorButton()
            self.colorButton2 = ColorButton()
            self.colorButton3 = ColorButton()
            self.colorButton4 = ColorButton()
            self.colorButton5 = ColorButton()
            layout.addWidget(self.colorButton1, 0, 0)
            layout.addWidget(self.colorButton2, 0, 1)
            layout.addWidget(self.colorButton3, 0, 2)
            layout.addWidget(self.colorButton4, 0, 3)
            layout.addWidget(self.colorButton5, 0, 4)

            self.colorButton6 = ColorButton()
            self.colorButton7 = ColorButton()
            self.colorButton8 = ColorButton()
            self.colorButton9 = ColorButton()
            self.colorButton10 = ColorButton()
            layout.addWidget(self.colorButton6, 1, 0)
            layout.addWidget(self.colorButton7, 1, 1)
            layout.addWidget(self.colorButton8, 1, 2)
            layout.addWidget(self.colorButton9, 1, 3)
            layout.addWidget(self.colorButton10, 1, 4)

            self.colorButton11 = ColorButton()
            self.colorButton12 = ColorButton()
            self.colorButton13 = ColorButton()
            self.colorButton14 = ColorButton()
            self.colorButton15 = ColorButton()
            layout.addWidget(self.colorButton11, 2, 0)
            layout.addWidget(self.colorButton12, 2, 1)
            layout.addWidget(self.colorButton13, 2, 2)
            layout.addWidget(self.colorButton14, 2, 3)
            layout.addWidget(self.colorButton15, 2, 4)

            self.colorButton16 = ColorButton()
            self.colorButton17 = ColorButton()
            self.colorButton18 = ColorButton()
            self.colorButton19 = ColorButton()
            self.colorButton20 = ColorButton()
            layout.addWidget(self.colorButton16, 3, 0)
            layout.addWidget(self.colorButton17, 3, 1)
            layout.addWidget(self.colorButton18, 3, 2)
            layout.addWidget(self.colorButton19, 3, 3)
            layout.addWidget(self.colorButton20, 3, 4)

            self.colorButton21 = ColorButton()
            self.colorButton22 = ColorButton()
            self.colorButton23 = ColorButton()
            self.colorButton24 = ColorButton()
            self.colorButton25 = ColorButton()
            layout.addWidget(self.colorButton21, 4, 0)
            layout.addWidget(self.colorButton22, 4, 1)
            layout.addWidget(self.colorButton23, 4, 2)
            layout.addWidget(self.colorButton24, 4, 3)
            layout.addWidget(self.colorButton25, 4, 4)

            self.setLayout(layout)
            self.initForm()
Пример #8
0
import sys

from PySide2.QtGui import QFontDatabase
from PySide2.QtWidgets import QApplication

from Resources import Resources
from Services.Loader import Loader
from Controllers.WindowController import WindowController

if __name__ == "__main__":
    App = QApplication(sys.argv)

    QFontDatabase.addApplicationFont(":/fonts/mulish.ttf")
    QFontDatabase.addApplicationFont(":/fonts/inconsolata.ttf")

    App.setStyleSheet(Loader.PreprocessedQSS())
    Loader.SpongesMorphotypes()

    window = WindowController()

    sys.exit(App.exec_())
Пример #9
0
    def data(self,
             index: QModelIndex,
             role: Qt.ItemDataRole = Qt.DisplayRole) -> Any:
        if not index.isValid():
            return None
        col = self.getColumnKey(index.column())
        if not col:
            return None

        if role == Qt.FontRole:
            if col in (
                    'datatype',
                    'size',
            ):
                return QFontDatabase.systemFont(QFontDatabase.FixedFont)
            return None

        if role == Qt.CheckStateRole:
            if col in ('enabled', ):
                mod = self.modmodel[index.row()]
                val = mod[col]
                return Qt.Checked if val else Qt.Unchecked
            return None

        if role == Qt.BackgroundRole:
            mod = self.modmodel[index.row()]
            if not mod.enabled:
                return QColor(240, 240, 240)
            if col in ('priority', ) and mod.datatype not in (
                    'mod',
                    'udf',
            ):
                return QColor(240, 240, 240)
            if mod.installdate > self._lastUpdate:
                return QColor(242, 255, 242)
            if mod.installdate > self._lastInitialization:
                return QColor(242, 246, 255)
            if not mod.installed:
                return QColor(250, 240, 240)
            return None

        if role == Qt.ForegroundRole:
            mod = self.modmodel[index.row()]
            if not mod.enabled:
                return QColor(60, 60, 60)
            return None

        if role == Qt.DecorationRole:
            if col in ('datatype', ):
                mod = self.modmodel[index.row()]
                val = mod[col]
                return self._icons[val] if val in self._icons else self._icons[
                    'udf']
            return None

        if role == Qt.ToolTipRole:
            mod = self.modmodel[index.row()]
            if col in ('datatype', ):
                val = mod[col]
                return self._datatypes[
                    val] if val in self._datatypes else self._datatypes['udf']
            if col in ('enabled', ):
                val = mod[col]
                return 'Enabled' if val else 'Disabled'
            return str(mod[col])

        if role == Qt.TextAlignmentRole:
            if col in ('size', ):
                # Right|VCenter
                return 0x0082
            if col in (
                    'priority',
                    'installdate',
                    'binFiles',
                    'menuFiles',
                    'settings',
                    'inputs',
                    'contentFiles',
                    'scriptFiles',
            ):
                # HCenter|VCenter
                return 0x0084
            # Left|VCenter
            return 0x0081

        if role == Qt.EditRole:
            if col in (
                    'package',
                    'filename',
                    'category',
                    'priority',
            ):
                mod = self.modmodel[index.row()]
                return str(mod[col])
            return None

        # role used for sorting
        if role == Qt.UserRole:
            mod = self.modmodel[index.row()]
            if col in ('priority', ):
                return f'{int(mod[col]): >20} {mod["filename"]}'
            if col in ('size', ):
                return int(mod[col])
            if col in ('binFiles', 'menuFiles', 'contentFiles', \
                       'scriptFiles', 'settings', 'inputs',):
                return len(mod[col])
            return str(mod[col])

        if role == Qt.DisplayRole:
            if col in ('enabled', ):
                return None
            mod = self.modmodel[index.row()]
            if col in ('datatype', ):
                return str(mod[col]).upper()
            if col in ('priority', ):
                val = mod[col]
                if val <= 0:
                    return 'none'
                return val
            if col in ('installdate', ):
                return mod[col].astimezone(
                    tz=None).strftime('%Y-%m-%d %H:%M:%S')
            if col in ('size', ):
                val = mod[col]
                frm = 'b'
                val /= 1024
                frm = 'K'
                if val // 1024:
                    val /= 1024
                    frm = 'M'
                return '%.1f %s' % (val, frm)
            if col in (
                    'inputs',
                    'settings',
            ):
                val = 0
                for s in mod[col]:
                    for n in s.config.sections():
                        val += len(s.config.items(n))
                return val if val else None

            if col in (
                    'binFiles',
                    'menuFiles',
                    'contentFiles',
                    'scriptFiles',
            ):
                val = len(mod[col])
                if val < 1:
                    return ''
                return val
            return str(mod[col])

        return None
Пример #10
0
    def __init__(self, parent=None):
        super(Settings, self).__init__(parent)
        self.settings = QSettings(self)

        self.setWindowTitle('Annotations - settings')
        f = QFormLayout()
        self.setLayout(f)

        c = self.setup_combo(['Light', 'Dark'], 'theme')
        self.theme = c
        c.currentIndexChanged.connect(self._theme_changed)
        f.addRow('Theme', c)

        c = self.setup_combo(QFontDatabase().families(), 'family')
        self.family = c
        c.currentIndexChanged.connect(self._font_changed)
        f.addRow('Font', c)

        c = QSpinBox(self)
        c.setValue(int(self.settings.value('size')))
        self.size = c
        c.setMaximum(30)
        c.setMinimum(5)
        c.valueChanged.connect(self._font_changed)
        f.addRow('Font size', c)

        c = QLineEdit(self)
        c.setText(self.settings.value('annotator', ""))
        self.token = c
        c.textChanged.connect(
            lambda text: self.settings.setValue('annotator', text))
        f.addRow('Annotator name', c)

        c = QLineEdit(self)
        c.setText(
            self.settings.value('repo_location',
                                os.path.abspath('./repository')))
        self.token = c
        c.textChanged.connect(
            lambda text: self.settings.setValue('repo_location', text))
        f.addRow('Repo location', c)

        c = QLineEdit(self)
        c.setText(self.settings.value('repository'))
        self.token = c
        c.textChanged.connect(
            lambda text: self.settings.setValue('repository', text))
        f.addRow('Repository', c)

        c = QLineEdit(self)
        c.setText(self.settings.value('user'))
        self.token = c
        c.textChanged.connect(
            lambda text: self.settings.setValue('user', text))
        f.addRow('Repo user', c)

        c = QLineEdit(self)
        c.setText(self.settings.value('token'))
        self.token = c
        c.textChanged.connect(
            lambda text: self.settings.setValue('token', text))
        f.addRow('Repo token', c)

        c = QLineEdit(self)
        c.textChanged.connect(
            lambda text: self.settings.setValue('indent', text))
        c.setText(self.settings.value('indent', defaultValue='-'))
        self.token = c
        f.addRow('Summary indent', c)
Пример #11
0
    def __init__(self, parent=None, menu_handler=None):
        super(HexViewWidget, self).__init__()
        self.setupUi(self)

        self._model = HexTableModel(self)
        self.view = HexTableView(parent=self)
        sizePolicy = QSizePolicy(QSizePolicy.MinimumExpanding,
                                 QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.view.sizePolicy().hasHeightForWidth())
        self.view.setSizePolicy(sizePolicy)
        # self.view.setMinimumSize(QSize(660, 0))
        self.view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self.view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.view.setSelectionMode(QAbstractItemView.NoSelection)
        self.view.setShowGrid(False)
        self.view.setWordWrap(False)
        self.view.setStyleSheet(
            "QHeaderView { } QTableView::item { } ")  # bypass stylesheet
        # self.view.setObjectName("view")
        # self.view.horizontalHeader().setDefaultSectionSize(10)
        self.view.horizontalHeader().setMinimumSectionSize(5)
        # self.view.verticalHeader().setDefaultSectionSize(21)
        # self.view.setMinimumWidth( self.view.width() )
        self.mainLayout.insertWidget(0, self.view)

        self.view.setModel(self._model)
        for i in range(0x10):
            self.view.setColumnWidth(i, 25)
        self.view.setColumnWidth(0x10, 5)
        for i in range(0x11, 0x22):
            self.view.setColumnWidth(i, 11)

        self._hsm = HexItemSelectionModel(self._model, self.view)
        self.view.setSelectionModel(self._hsm)

        self.view.setContextMenuPolicy(Qt.CustomContextMenu)
        self.view.customContextMenuRequested.connect(
            self._handle_context_menu_requested)
        if menu_handler is not None:
            self.get_context_menu = menu_handler

        self.optimal_width = self.view.verticalScrollBar().width(
        ) + self.view.verticalHeader().width()  #- 40
        for i in range(0x22):
            self.optimal_width += self.view.columnWidth(i)

        f = QFontDatabase.systemFont(QFontDatabase.FixedFont)
        f.setPointSize(8)
        self.view.horizontalHeader().setFont(f)
        self.view.verticalHeader().setFont(f)
        self.view.setFont(f)
        self.statusLabel.setFont(f)

        self.view.setMinimumWidth(self.optimal_width)
        self.view.setMaximumWidth(self.optimal_width)

        self._hsm.selectionRangeChanged.connect(
            self._handle_selection_range_changed)
        self.view.moveKeyPressed.connect(self._hsm.handle_move_key)
        self.view.selectKeyPressed.connect(self._hsm.handle_select_key)

        self.view.setItemDelegate(HexItemDelegate(self._model, self))

        self.full_data_changed.connect(self._handle_data_changed)
        self.single_data_changed.connect(self._handle_single_data_changed)
        # self.data_edited.connect(self._handle_data_edited)

        self.statusLabel.setText("")
Пример #12
0
 def fonts(self):
     '''Add fonts to the application workspace.'''
     QFontDatabase.addApplicationFont(u':/fonts/Minecraftia.ttf')
Пример #13
0
 def font_points(self, font):
     points = [str(p) for p in QFontDatabase().pointSizes(font.family())]
     if not points:
         points = [str(p) for p in QFontDatabase().standardSizes()]
     return points
Пример #14
0
from PySide2.QtWidgets import QApplication
from PySide2.QtGui import QFontDatabase
from src.view.MainWindow import MainWindow
import sys
import os

if __name__ == '__main__':
    app = QApplication(sys.argv)

    font_path = f'{os.getcwd()}/YuGothB.ttc'
    QFontDatabase.addApplicationFont('YuGothB.ttc')

    window = MainWindow()
    window.show()

    sys.exit(app.exec_())