Ejemplo n.º 1
0
    def initialize_controls(self):
        self.setWindowTitle(DIALOG_NAME)
        layout = QVBoxLayout(self)
        self.setLayout(layout)
        title_layout = ImageTitleLayout(self, 'images/icon.png', 'Update custom columns in Library')
        layout.addLayout(title_layout)

        column_group = QGroupBox(_("Columns to update"), self)
        layout.addWidget(column_group)
        column_layout = QGridLayout()
        column_group.setLayout(column_layout)

        pos = 0
        self.checkbox = {}
        for key in sorted (self.custom_cols):
            value = self.custom_cols[key]
            self.checkbox[key] = self.createCheckbox (value)
            column_layout.addWidget(self.checkbox[key], int ((pos / 2)), int ((pos % 2)* 2 + 1), 1, 1)
            pos = pos + 1
            
        layout.addStretch(1)

        # Dialog buttons
        button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        button_box.accepted.connect(self.ok_clicked)
        button_box.rejected.connect(self.reject)
        layout.addWidget(button_box)
Ejemplo n.º 2
0
   def horizontal_vertical_box_layout(self):
       label_1 = QLabel('First label')
       label_2 = QLabel('Another label')
         
       button_1 = QPushButton('Click 1')
       button_2 = QPushButton('Click 2')
         
       hbox_1 = QHBoxLayout()
       hbox_1.addStretch()         # push/stretch to right
       hbox_2 = QHBoxLayout()
       hbox_2.addStretch()         # push/stretch to right
         
       hbox_1.addWidget(label_1)
       hbox_1.addWidget(button_1)
 
       hbox_2.addWidget(label_2)
       hbox_2.addWidget(button_2)
                 
       vbox = QVBoxLayout()
       vbox.addStretch()           # push/stretch down
         
       vbox.addLayout(hbox_1)
       vbox.addLayout(hbox_2)
         
       layout_widget = QWidget()       # create QWidget object
       layout_widget.setLayout(vbox)   # set layout
         
       self.setCentralWidget(layout_widget)    # make QWidget the central widget
Ejemplo n.º 3
0
    def __init__(self, plugin_action):
        QWidget.__init__(self)
        self.plugin_action = plugin_action
        layout = QVBoxLayout(self)
        self.setLayout(layout)

        keyboard_shortcuts_button = QPushButton('Keyboard shortcuts...', self)
        keyboard_shortcuts_button.setToolTip(
            _('Edit the keyboard shortcuts associated with this plugin'))
        keyboard_shortcuts_button.clicked.connect(self.edit_shortcuts)
        layout.addWidget(keyboard_shortcuts_button)

        reset_confirmation_button = QPushButton(
            _('Reset disabled &confirmation dialogs'), self)
        reset_confirmation_button.setToolTip(
            _('Reset all show me again dialogs for the Find Duplicates plugin')
        )
        reset_confirmation_button.clicked.connect(self.reset_dialogs)
        layout.addWidget(reset_confirmation_button)
        view_prefs_button = QPushButton('&View library preferences...', self)
        view_prefs_button.setToolTip(
            _('View data stored in the library database for this plugin'))
        view_prefs_button.clicked.connect(self.view_prefs)
        layout.addWidget(view_prefs_button)
        layout.addStretch(1)
def createSpeedControls():
    speed_gb = QGroupBox("Speed")
    speed_gb.setMaximumWidth(50)

    layout = QVBoxLayout()
    layout.setContentsMargins(0, 0, 0, 0)
    layout.setSpacing(0)

    speed1_btn = QPushButton("1")
    speed2_btn = QPushButton("2")
    speed3_btn = QPushButton("3")
    speed4_btn = QPushButton("4")
    speed5_btn = QPushButton("5")
    speed6_btn = QPushButton("6")

    speed1_btn.clicked.connect(lambda: send_cmd(["1"]))
    speed2_btn.clicked.connect(lambda: send_cmd(["2"]))
    speed3_btn.clicked.connect(lambda: send_cmd(["3"]))
    speed4_btn.clicked.connect(lambda: send_cmd(["4"]))
    speed5_btn.clicked.connect(lambda: send_cmd(["5"]))
    speed6_btn.clicked.connect(lambda: send_cmd(["6"]))

    layout.addWidget(speed1_btn)
    layout.addWidget(speed2_btn)
    layout.addWidget(speed3_btn)
    layout.addWidget(speed4_btn)
    layout.addWidget(speed5_btn)
    layout.addWidget(speed6_btn)
    layout.addStretch(1)

    speed_gb.setLayout(layout)

    return speed_gb
def createCalibrationControls():
    gb = QGroupBox("Calibration")

    #------------------------------------------
    layout = QGridLayout()

    arduino = createArduinoCalibrationControls()
    pc = createPcCalibrationControls()
    gui = createGuiCalibration()

    layout.addWidget(arduino, 0, 0, 1, 1)
    layout.addWidget(pc, 1, 0, 1, 1)
    layout.addWidget(gui, 0, 1, 2, 1)

    layout.setContentsMargins(0, 0, 0, 0)
    layout.setSpacing(5)

    upper = QWidget()
    upper.setLayout(layout)

    #------------------------------------------

    vbox = QVBoxLayout()

    vbox.addWidget(upper)
    vbox.addStretch(1)

    vbox.setContentsMargins(0, 0, 0, 0)
    vbox.setSpacing(0)

    gb.setLayout(vbox)
    return gb
Ejemplo n.º 6
0
class HashGeneratorTab(QWidget):
    def __init__(self, console):
        super().__init__()
        self.layout = QVBoxLayout(self)

        self.titleText = QLabel("<H1>HashGenerator</H1>\nText Einfügen")
        self.layout.addWidget(self.titleText)

        self.textField = QTextEdit()
        self.layout.addWidget(self.textField)

        self.selectHash = QComboBox()
        self.selectHash.addItems(
            ["SHA1", "SHA224", "SHA256", "SHA384", "SHA512", "MD5"])
        self.selectHash.setCurrentText("SHA512")
        self.layout.addWidget(self.selectHash)

        self.genButton = QPushButton("Generiere Hash")
        self.hashGenerator = HashGenerator()
        self.genButton.clicked.connect(self.generateHash)
        self.layout.addWidget(self.genButton)

        self.output = QTextEdit("Output")
        self.output.setReadOnly(True)
        self.layout.addWidget(self.output)

        self.layout.addStretch(1)

    def generateHash(self):
        text = self.textField.toPlainText()
        hash = self.selectHash.currentText()

        self.output.setText(self.hashGenerator.getHash(text, hash))
Ejemplo n.º 7
0
class Tabs(QWidget):
    def __init__(self, parent):
        super(QWidget, self).__init__(parent)
        self.layout = QVBoxLayout(self)

        self.console = Console("Superconsole")

        self.tabs = QTabWidget()

        self.ddosTab = DosTab(self.console)
        self.portscannerTab = PortScannerTab(self.console)
        # self.hashcrackerTab = HashcrackerTab(self.console)
        self.hashGeneratorTab = HashGeneratorTab(self.console)
        self.rtGenTab = RainbowGeneratorTab(self.console)
        self.stressTab = CPUStressTab(self.console)

        # self.tabs.resize(800, 600)

        self.tabs.addTab(self.ddosTab, "Denial of Service")
        self.tabs.addTab(self.portscannerTab, "Portscanner")
        self.tabs.addTab(self.hashGeneratorTab, "HashGenrator")
        # self.tabs.addTab(self.hashcrackerTab, "Hashcracker (Not Working)")
        self.tabs.addTab(self.rtGenTab, "Rainbowtable Generator")
        self.tabs.addTab(self.stressTab, "CPU Stress")

        self.layout.addWidget(self.tabs)

        self.layout.addStretch(1)
        self.layout.addWidget(self.console)
Ejemplo n.º 8
0
    def horizontal_vertical_box_layout(self):
        label_1 = QLabel('Our first label')  # create and set the label
        label_2 = QLabel('Another label')

        button_1 = QPushButton('Click 1')
        button_2 = QPushButton('Click 2')

        hbox_1 = QHBoxLayout()
        hbox_1.addStretch()
        hbox_2 = QHBoxLayout()
        hbox_2.addStretch()

        hbox_1.addWidget(label_1)
        hbox_1.addWidget(button_1)

        hbox_2.addWidget(label_2)
        hbox_2.addWidget(button_2)

        vbox = QVBoxLayout()
        vbox.addStretch()  #fijarlo hasta abajo

        vbox.addLayout(hbox_1)
        vbox.addLayout(hbox_2)

        layout_widget = QWidget()  # Create the object
        layout_widget.setLayout(vbox)

        self.setCentralWidget(layout_widget)
def createNavigationControls():
    gb = QGroupBox("Navigation Controls")

    #-------------------------------------------

    layout = QGridLayout()

    pause_both_btn = QPushButton("Pause vector && time")
    pause_btn = QPushButton("Pause vector")
    pause_time_btn = QPushButton("Pause time")
    continue_btn = QPushButton("Continue")
    release_btn = QPushButton("Release")
    cwHalfStep_btn = QPushButton("=> half step")
    ccwHalfStep_btn = QPushButton("<= half step")
    ccwDir_btn = QPushButton("CCW direction")
    cwDir_btn = QPushButton("CW direction")

    continue_btn.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)

    pause_both_btn.clicked.connect(pause_vector_and_time)
    pause_btn.clicked.connect(lambda: send_cmd(["p"]))
    pause_time_btn.clicked.connect(tracker.pause_time)
    continue_btn.clicked.connect(continue_)
    release_btn.clicked.connect(lambda: send_cmd(["r"]))
    cwHalfStep_btn.clicked.connect(lambda: send_cmd([">", "h", "<"]))
    ccwHalfStep_btn.clicked.connect(lambda: send_cmd(["<", "h"]))
    ccwDir_btn.clicked.connect(lambda: send_cmd(["<"]))
    cwDir_btn.clicked.connect(lambda: send_cmd([">"]))

    layout.setContentsMargins(0, 0, 0, 0)
    layout.setSpacing(0)
    layout.setVerticalSpacing(0)

    layout.addWidget(pause_both_btn, 0, 0)
    layout.addWidget(pause_btn, 1, 0)
    layout.addWidget(pause_time_btn, 2, 0)
    layout.addWidget(continue_btn, 0, 1, 3, 1)
    layout.addWidget(ccwHalfStep_btn, 3, 0)
    layout.addWidget(cwHalfStep_btn, 3, 1)
    layout.addWidget(ccwDir_btn, 4, 0)
    layout.addWidget(cwDir_btn, 4, 1)
    layout.addWidget(createGotoControls(), 5, 0, 1, 2)
    layout.addWidget(release_btn, 6, 0, 1, 2)

    upper = QWidget()
    upper.setLayout(layout)

    #-------------------------------------------
    vbox = QVBoxLayout()

    vbox.addWidget(upper)
    vbox.addStretch(1)

    vbox.setContentsMargins(0, 0, 0, 0)
    vbox.setSpacing(0)

    gb.setLayout(vbox)
    return gb
Ejemplo n.º 10
0
class DosTab(QWidget):
    running = False
    dos = None

    def __init__(self, console):
        super().__init__()
        self.console = console
        self.layout = QVBoxLayout(self)

        self.titleText = QLabel()
        self.titleText.setText("<H1>Denial of service</h1>\nIp Adresse")
        self.layout.addWidget(self.titleText)

        self.ipField = QLineEdit("127.0.0.1")
        self.layout.addWidget(self.ipField)

        self.portLabel = QLabel()
        self.portLabel.setText("Port")
        self.layout.addWidget(self.portLabel)

        self.portField = QLineEdit()
        self.layout.addWidget(self.portField)

        self.startButton = QPushButton()
        self.startButton.setText("Starte Attacke")

        self.dos = DenialOfService(self.console)

        self.startButton.clicked.connect(self.start)
        self.layout.addWidget(self.startButton)

        self.layout.addStretch(1)

    def start(self):
        if not self.running:

            try:
                mysocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                mysocket.connect(
                    (self.ipField.text(), int(self.portField.text())))
            except:
                self.console.log("Verbindung fehlgeschlagen")
                return

            self.running = True
            self.startButton.setText("Stoppe Attacke")
            self.console.log("Angrff gestartet")
            self.dos.setIp(self.ipField.text())
            self.dos.setPort(int(self.portField.text()))
            self.dos.start()

        else:
            self.startButton.setText("Starte Attacke")
            self.running = False
            self.console.log("Angrff gestoppt")
            self.dos.stop()
Ejemplo n.º 11
0
 def __init__(self, parent):
     QWidget.__init__(self, parent)
     l = QVBoxLayout()
     self.setLayout(l)
     l.addStretch(10)
     self.pi = ProgressIndicator(self, 128)
     l.addWidget(self.pi, alignment=Qt.AlignHCenter)
     self.dummy = QLabel('<h2>\xa0')
     l.addSpacing(10)
     l.addWidget(self.dummy, alignment=Qt.AlignHCenter)
     l.addStretch(10)
     self.text = _('Calculating differences, please wait...')
Ejemplo n.º 12
0
 def __init__(self, parent):
     QWidget.__init__(self, parent)
     l = QVBoxLayout()
     self.setLayout(l)
     l.addStretch(10)
     self.pi = ProgressIndicator(self, 128)
     l.addWidget(self.pi, alignment=Qt.AlignHCenter)
     self.dummy = QLabel('<h2>\xa0')
     l.addSpacing(10)
     l.addWidget(self.dummy, alignment=Qt.AlignHCenter)
     l.addStretch(10)
     self.text = _('Calculating differences, please wait...')
Ejemplo n.º 13
0
 def __init__(self, parent):
     QWidget.__init__(self, parent)
     l = QVBoxLayout()
     self.setLayout(l)
     l.addStretch(10)
     self.pi = ProgressIndicator(self, 128)
     l.addWidget(self.pi, alignment=Qt.AlignHCenter)
     self.dummy = QLabel('<h2>\xa0')
     l.addSpacing(10)
     l.addWidget(self.dummy, alignment=Qt.AlignHCenter)
     l.addStretch(10)
     self.setVisible(False)
     self.text = ''
     self.setFocusPolicy(Qt.NoFocus)
Ejemplo n.º 14
0
 def __init__(self, parent):
     QWidget.__init__(self, parent)
     l = QVBoxLayout()
     self.setLayout(l)
     l.addStretch(10)
     self.pi = ProgressIndicator(self, 128)
     l.addWidget(self.pi, alignment=Qt.AlignmentFlag.AlignHCenter)
     self.dummy = QLabel('<h2>\xa0')
     l.addSpacing(10)
     l.addWidget(self.dummy, alignment=Qt.AlignmentFlag.AlignHCenter)
     l.addStretch(10)
     self.setVisible(False)
     self.text = ''
     self.setFocusPolicy(Qt.FocusPolicy.NoFocus)
class HashcrackerTab(QWidget):

    def __init__(self, console):
        super().__init__()

        self.layout = QVBoxLayout(self)

        self.titleText = QLabel("<H1>Hashcracker</H1>\nHash hier einfügen")
        self.layout.addWidget(self.titleText)

        self.hashField = QLineEdit()
        self.layout.addWidget(self.hashField)

        self.hashSelectionLabel = QLabel("Wähle Hashfunktion aus")
        self.layout.addWidget(self.hashSelectionLabel)

        self.selectHash = QComboBox(self)
        self.selectHash.addItems(["SHA1", "SHA224", "SHA256", "SHA384", "SHA512", "MD5"])
        self.selectHash.setCurrentText("SHA-512")
        self.layout.addWidget(self.selectHash)

        self.hboxText = QHBoxLayout()
        self.bruteforceLabel = QLabel("<H2>Bruteforce</H2>")
        self.listLabel = QLabel("<H2>Passwort Liste</H2>")
        self.rtLabel = QLabel("<H2>Ranbowtable Crack</H2>")
        self.hboxText.addWidget(self.bruteforceLabel)
        self.hboxText.addWidget(self.listLabel)
        self.hboxText.addWidget(self.rtLabel)
        self.layout.addLayout(self.hboxText)

        self.hboxAction = QHBoxLayout()
        self.bruteforceCharset = QLineEdit("Charset")
        self.hboxAction.addWidget(self.bruteforceCharset)
        self.listSelect = QPushButton("Wähle Datei aus")
        self.hboxAction.addWidget(self.listSelect)
        self.rtSelect = QPushButton("Wähle Ranbowtable aus")
        self.hboxAction.addWidget(self.rtSelect)
        self.layout.addLayout(self.hboxAction)

        self.hboxCrackButton = QHBoxLayout()
        self.bruteforceCrack = QPushButton("Crack Bruteforce")
        self.hboxCrackButton.addWidget(self.bruteforceCrack)
        self.listCrack = QPushButton("Crack List")
        self.hboxCrackButton.addWidget(self.listCrack)
        self.rainbowCrack = QPushButton("Crack Rainbowtable")
        self.hboxCrackButton.addWidget(self.rainbowCrack)
        self.layout.addLayout(self.hboxCrackButton)

        self.layout.addStretch(1)
def createControlWidgets():
    gb = QGroupBox()

    layout = QGridLayout()

    layout.addWidget(createSpeedControls(), 0, 0, 1, 1)
    layout.addWidget(createCalibrationControls(), 0, 1, 1, 1)
    layout.addWidget(createGuiControls(), 1, 1, 1, 1)
    layout.addWidget(createNavigationControls(), 0, 2, 2, 1)

    layout.setContentsMargins(0, 0, 0, 0)
    layout.setSpacing(5)

    upper = QWidget()
    upper.setLayout(layout)

    #------------------------------------------

    lower = createMonitorControls()

    #------------------------------------------

    vbox = QVBoxLayout()

    vbox.addWidget(upper)
    vbox.addWidget(lower)
    vbox.addStretch(1)

    vbox.setContentsMargins(0, 0, 0, 0)
    vbox.setSpacing(0)

    right = QWidget()
    right.setLayout(vbox)

    #------------------------------------------

    layout = QHBoxLayout()

    layout.addStretch(1)
    layout.addWidget(right)

    layout.setContentsMargins(0, 0, 0, 0)
    layout.setSpacing(0)

    gb.setLayout(layout)
    gb.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
    gb.setMaximumHeight(400)
    return gb
Ejemplo n.º 17
0
    def setup_ui(self):
        from calibre.gui2.preferences.look_feel import DisplayedFields, move_field_up, move_field_down
        self.l = QVBoxLayout(self)
        self.field_display_order = fdo = QListView(self)
        self.model = DisplayedFields(self.db, fdo, pref_name='popup_book_display_fields')
        self.model.initialize()
        fdo.setModel(self.model)
        fdo.setAlternatingRowColors(True)
        del self.db
        self.l.addWidget(QLabel('Select displayed metadata'))
        h = QHBoxLayout()
        h.addWidget(fdo)
        v = QVBoxLayout()
        self.mub = b = QToolButton(self)
        b.clicked.connect(partial(move_field_up, fdo, self.model))
        b.setIcon(QIcon(I('arrow-up.png')))
        b.setToolTip(_('Move the selected field up'))
        v.addWidget(b), v.addStretch(10)
        self.mud = b = QToolButton(self)
        b.setIcon(QIcon(I('arrow-down.png')))
        b.setToolTip(_('Move the selected field down'))
        b.clicked.connect(partial(move_field_down, fdo, self.model))
        v.addWidget(b)
        h.addLayout(v)

        self.l.addLayout(h)
        self.l.addWidget(QLabel('<p>' + _(
            'Note that <b>comments</b> will always be displayed at the end, regardless of the order you assign here')))

        b = self.bb.addButton(_('Restore &defaults'), self.bb.ActionRole)
        b.clicked.connect(self.restore_defaults)
        self.l.addWidget(self.bb)
        self.setMinimumHeight(500)
Ejemplo n.º 18
0
    def __init__(self, plugin_action):
        QWidget.__init__(self)
        self.plugin_action = plugin_action
        layout = QVBoxLayout(self)
        self.setLayout(layout)

        custom_cols = self.get_custom_columns()

        pos = 0
        self.checkbox = {}
        for key, value in six.iteritems(custom_cols):
            self.chexkbox[key] = self.createCheckbox(value)
            layout.addWidget(checkbox[key])
            pos = pos + 1

        layout.addStretch(1)
Ejemplo n.º 19
0
class Browser(QScrollArea):  # {{{

    show_plugin = pyqtSignal(object)

    def __init__(self, parent=None):
        QScrollArea.__init__(self, parent)
        self.setWidgetResizable(True)

        category_map, category_names = {}, {}
        for plugin in preferences_plugins():
            if plugin.category not in category_map:
                category_map[plugin.category] = plugin.category_order
            if category_map[plugin.category] < plugin.category_order:
                category_map[plugin.category] = plugin.category_order
            if plugin.category not in category_names:
                category_names[plugin.category] = (plugin.gui_category
                                                   if plugin.gui_category else
                                                   plugin.category)

        self.category_names = category_names

        categories = list(category_map.keys())
        categories.sort(cmp=lambda x, y: cmp(category_map[x], category_map[y]))

        self.category_map = OrderedDict()
        for c in categories:
            self.category_map[c] = []

        for plugin in preferences_plugins():
            self.category_map[plugin.category].append(plugin)

        for plugins in self.category_map.values():
            plugins.sort(cmp=lambda x, y: cmp(x.name_order, y.name_order))

        self.widgets = []
        self._layout = QVBoxLayout()
        self.container = QWidget(self)
        self.container.setLayout(self._layout)
        self.setWidget(self.container)

        for name, plugins in self.category_map.items():
            w = Category(name, plugins, self.category_names[name], parent=self)
            self.widgets.append(w)
            self._layout.addWidget(w)
            w.plugin_activated.connect(self.show_plugin.emit)
        self._layout.addStretch(1)
Ejemplo n.º 20
0
class Browser(QScrollArea):  # {{{

    show_plugin = pyqtSignal(object)

    def __init__(self, parent=None):
        QScrollArea.__init__(self, parent)
        self.setWidgetResizable(True)

        category_map, category_names = {}, {}
        for plugin in preferences_plugins():
            if plugin.category not in category_map:
                category_map[plugin.category] = plugin.category_order
            if category_map[plugin.category] < plugin.category_order:
                category_map[plugin.category] = plugin.category_order
            if plugin.category not in category_names:
                category_names[plugin.category] = (plugin.gui_category if
                    plugin.gui_category else plugin.category)

        self.category_names = category_names

        categories = list(category_map.keys())
        categories.sort(key=lambda x: category_map[x])

        self.category_map = OrderedDict()
        for c in categories:
            self.category_map[c] = []

        for plugin in preferences_plugins():
            self.category_map[plugin.category].append(plugin)

        for plugins in self.category_map.values():
            plugins.sort(key=lambda x: x.name_order)

        self.widgets = []
        self._layout = QVBoxLayout()
        self.container = QWidget(self)
        self.container.setLayout(self._layout)
        self.setWidget(self.container)

        for name, plugins in self.category_map.items():
            w = Category(name, plugins, self.category_names[name], parent=self)
            self.widgets.append(w)
            self._layout.addWidget(w)
            w.plugin_activated.connect(self.show_plugin.emit)
        self._layout.addStretch(1)
Ejemplo n.º 21
0
    def _initUi(self):
        """初始化界面"""
        self.setWindowTitle('进度')

        labelTotal = QLabel('总体进度')
        labelSingle = QLabel('个体进度')

        self._progressSingle = QProgressBar(self)
        self._progressTotal = QProgressBar(self)

        vbox = QVBoxLayout()
        vbox.addWidget(labelTotal)
        vbox.addWidget(self._progressTotal)
        vbox.addWidget(labelSingle)
        vbox.addWidget(self._progressSingle)
        vbox.addStretch()

        self.setLayout(vbox)
Ejemplo n.º 22
0
    def enemyClick(self, enemy):
        # Opens an info screen on the enemy
        if self.parent.gameover == False and enemy.isDead == False:

            if self.parent.isTowerSelected == False:
                # self.statusBarMessage("Enemy clicked")
                self.enemyPopUp = QFrame()
                self.enemyPopUp.setGeometry(500, 500, 100, 100)

                grid = QGridLayout()
                self.enemyPopUp.setLayout(grid)

                enemyStats = QLabel("Enemy Stats")
                name = QLabel("Name: " + str(enemy.name))
                speed = QLabel("Speed: " + str(enemy.speed))
                health = QLabel("Health: {:.0f}".format(enemy.health))
                pixmap = QLabel()
                pixmap.setPixmap(enemy.picture)

                vbox = QVBoxLayout()
                vbox.addWidget(enemyStats)
                vbox.addWidget(name)
                vbox.addWidget(speed)
                vbox.addWidget(health)

                grid.addLayout(vbox, 0, 0)

                vbox2 = QVBoxLayout()
                vbox2.addWidget(pixmap)
                vbox2.addStretch()

                doneButton = QPushButton("Done")
                vbox2.addWidget(doneButton)
                grid.addLayout(vbox2, 0, 1)

                location = QPoint(QCursor.pos())
                self.enemyPopUp.move(location.x() - 100, location.y())
                self.enemyPopUp.show()
                doneButton.clicked.connect(self.enemyPopUp.hide)

        elif self.parent.gameover == True:
            self.statusBarMessage("The game has ended. Stop doing stuff.")
Ejemplo n.º 23
0
 def enemyClick(self, enemy):
     # Opens an info screen on the enemy
     if self.parent.gameover == False and enemy.isDead == False:
     
         if self.parent.isTowerSelected == False:
             # self.statusBarMessage("Enemy clicked")
             self.enemyPopUp = QFrame()
             self.enemyPopUp.setGeometry(500, 500, 100, 100)
         
             grid = QGridLayout()
             self.enemyPopUp.setLayout(grid)
         
             enemyStats = QLabel("Enemy Stats")
             name = QLabel("Name: " + str(enemy.name))
             speed = QLabel("Speed: " + str(enemy.speed))
             health = QLabel("Health: {:.0f}".format(enemy.health))
             pixmap = QLabel()
             pixmap.setPixmap(enemy.picture)
         
             vbox = QVBoxLayout()
             vbox.addWidget(enemyStats)
             vbox.addWidget(name)
             vbox.addWidget(speed)
             vbox.addWidget(health)
 
             grid.addLayout(vbox, 0, 0)
         
             vbox2 = QVBoxLayout()
             vbox2.addWidget(pixmap)
             vbox2.addStretch()
             
             doneButton = QPushButton("Done")
             vbox2.addWidget(doneButton)
             grid.addLayout(vbox2, 0, 1)
             
             location = QPoint(QCursor.pos())
             self.enemyPopUp.move(location.x() - 100, location.y())
             self.enemyPopUp.show()
             doneButton.clicked.connect(self.enemyPopUp.hide)
     
     elif self.parent.gameover == True:
         self.statusBarMessage("The game has ended. Stop doing stuff.")
Ejemplo n.º 24
0
class Tab1Config(DeviceConfigTab):  # {{{
    def __init__(self, parent, device):
        super(Tab1Config, self).__init__(parent)

        self.l = QVBoxLayout(self)
        self.setLayout(self.l)

        self.collections_options = CollectionsGroupBox(self, device)
        self.l.addWidget(self.collections_options)
        self.addDeviceWidget(self.collections_options)

        self.covers_options = CoversGroupBox(self, device)
        self.l.addWidget(self.covers_options)
        self.addDeviceWidget(self.covers_options)

        self.book_uploads_options = BookUploadsGroupBox(self, device)
        self.l.addWidget(self.book_uploads_options)
        self.addDeviceWidget(self.book_uploads_options)

        self.l.addStretch()
Ejemplo n.º 25
0
    def _initialize_layout(self):
        # Get the current database
        database = self.gui.current_db
        library_config = get_library_config(database)
        columns_from_preferences = library_config[PREFS_KEY_COLUMNS]

        # remove already configured columns from available columns
        for key in columns_from_preferences.keys():
            if key in self.available_columns:
                del self.available_columns[key]

        # Build the gui
        layoutH = QHBoxLayout()

        self.sourceList = CustomListWidget(self.gui, self.available_columns)
        self.sourceList.setToolTip(_('List of available columns'))
        layoutH.addWidget(self.sourceList)

        button_layout = QVBoxLayout()
        layoutH.addLayout(button_layout)

        self.use_btn = QToolButton(self.gui)
        self.use_btn.setIcon(QIcon(I('forward.png')))
        self.use_btn.setToolTip(_('Use the column for statistic'))
        self.use_btn.clicked.connect(self._add_row)

        self.no_use_btn = QToolButton(self.gui)
        self.no_use_btn.setIcon(QIcon(I('back.png')))
        self.no_use_btn.setToolTip(_('Don\'t use the column for statistics'))
        self.no_use_btn.clicked.connect(self._remove_row)

        button_layout.addWidget(self.use_btn)
        button_layout.addStretch(1)
        button_layout.addWidget(self.no_use_btn)

        self.destinationList = CustomListWidget(self.gui,
                                                columns_from_preferences)
        self.destinationList.setToolTip(_('List of evaluated columns'))
        layoutH.addWidget(self.destinationList)

        self.setLayout(layoutH)
Ejemplo n.º 26
0
class Tab1Config(DeviceConfigTab):  # {{{

    def __init__(self, parent, device):
        super(Tab1Config, self).__init__(parent)

        self.l = QVBoxLayout(self)
        self.setLayout(self.l)

        self.collections_options = CollectionsGroupBox(self, device)
        self.l.addWidget(self.collections_options)
        self.addDeviceWidget(self.collections_options)

        self.covers_options = CoversGroupBox(self, device)
        self.l.addWidget(self.covers_options)
        self.addDeviceWidget(self.covers_options)

        self.book_uploads_options = BookUploadsGroupBox(self, device)
        self.l.addWidget(self.book_uploads_options)
        self.addDeviceWidget(self.book_uploads_options)

        self.l.addStretch()
def createMonitorControls():
    gb = QGroupBox("Monitor")

    #------------------------------------------

    layout = QHBoxLayout()

    label1 = QLabel("Angle:")
    label2 = QLabel("Half steps:")
    global angle_le
    angle_le = QLineEdit()
    global halfSteps_le
    halfSteps_le = QLineEdit()

    angle_le.setMaximumWidth(50)
    halfSteps_le.setMaximumWidth(50)

    layout.setContentsMargins(0, 0, 0, 0)
    layout.setSpacing(5)

    layout.addWidget(label1)
    layout.addWidget(angle_le)
    layout.addWidget(label2)
    layout.addWidget(halfSteps_le)
    layout.addStretch()

    upper = QWidget()
    upper.setLayout(layout)

    #------------------------------------------
    vbox = QVBoxLayout()

    vbox.addWidget(upper)
    vbox.addStretch(1)

    vbox.setContentsMargins(0, 0, 0, 0)
    vbox.setSpacing(0)

    gb.setLayout(vbox)
    return gb
def createGuiControls():
    gb = QGroupBox("GUI Controls")

    #-------------------------------------------------

    layout = QVBoxLayout()

    drawShadow_cb = QCheckBox("Draw Shadow")
    drawRotatingVector_cb = QCheckBox("Draw Rotating Vector and projection")

    drawShadow_cb.setChecked(tracker.draw_shadow)
    drawRotatingVector_cb.setChecked(tracker.draw_rotating_vector)

    drawShadow_cb.stateChanged.connect(
        lambda: tracker.show_shadow(drawShadow_cb.isChecked()))
    drawRotatingVector_cb.stateChanged.connect(
        lambda: tracker.show_rotating_vector(drawRotatingVector_cb.isChecked()
                                             ))

    layout.setContentsMargins(0, 0, 0, 0)
    layout.setSpacing(0)

    layout.addWidget(drawShadow_cb)
    layout.addWidget(drawRotatingVector_cb)

    upper = QWidget()
    upper.setLayout(layout)

    #-------------------------------------------------

    vbox = QVBoxLayout()

    vbox.setContentsMargins(0, 0, 0, 0)
    vbox.setSpacing(0)

    vbox.addWidget(upper)
    vbox.addStretch(1)
    gb.setLayout(vbox)
    return gb
Ejemplo n.º 29
0
    def __init__(self, gui, formats, parent=None):
        QDialog.__init__(self, parent=parent)

        self.gui = gui
        self.formats = formats
        buttonBox = QDialogButtonBox(QDialogButtonBox.Ok)

        msg = '\nThis book has multiple formats which could be scrambled.\n' \
            'Please select one of the following:\n'
        label = QLabel(msg)

        self.dradio = {}
        for k in self.formats:
            self.dradio[k] = QRadioButton(k)

        gpbox1 = QGroupBox('Formats available:')
        lay1 = QHBoxLayout()
        gpbox1.setLayout(lay1)

        for fmt in self.formats:
            lay1.addWidget(self.dradio[fmt])

        if 'EPUB' in self.formats:
            self.dradio['EPUB'].setChecked(True)
        else:
            self.dradio[self.formats[0]].setChecked(True)

        lay = QVBoxLayout()
        lay.addWidget(label)
        lay.addWidget(gpbox1)
        lay.addStretch()
        lay.addWidget(buttonBox)
        self.setLayout(lay)

        buttonBox.accepted.connect(self.accept)
        buttonBox.rejected.connect(self.reject)

        self.setWindowTitle('ScrambleEbook: Select a single format')
        self.setWindowIcon(get_icons('images/plugin_icon.png'))
Ejemplo n.º 30
0
class CPUStressTab(QWidget):
    def __init__(self, console):
        super().__init__()
        self.console = console
        self.cpustress = CPUStress()

        self.stress = False

        self.layout = QVBoxLayout(self)

        self.title = QLabel(
            "<h1>CPU Stress</h1>\nAnzahl der Kerne (0 Cores = Anzahl der Systemkerne"
        )
        self.layout.addWidget(self.title)
        self.cpuCoresSpin = QSpinBox()
        self.layout.addWidget(self.cpuCoresSpin)

        self.startButton = QPushButton("Start")
        self.startButton.clicked.connect(self.start)
        self.layout.addWidget(self.startButton)

        self.layout.addStretch(1)

    def start(self):
        if not self.stress:
            self.stress = True
            self.startButton.setText("Beende Stress")
            cpucores = int(self.cpuCoresSpin.text())
            if cpucores == 0:
                cpucores = os.cpu_count()
            self.console.log("Starte Stress mit " + str(cpucores) + " Kernen")
            self.cpustress.run(cpucores)

        else:
            self.stress = False
            self.startButton.setText("Start")
            self.cpustress.stop()
            self.console.log("Beendet")
Ejemplo n.º 31
0
class Tab2Config(DeviceConfigTab):  # {{{
    def __init__(self, parent, device):
        super(Tab2Config, self).__init__(parent)

        self.l = QVBoxLayout(self)
        self.setLayout(self.l)

        self.metadata_options = MetadataGroupBox(self, device)
        self.l.addWidget(self.metadata_options)
        self.addDeviceWidget(self.metadata_options)

        self.device_list_options = DeviceListGroupBox(self, device)
        self.l.addWidget(self.device_list_options)
        self.addDeviceWidget(self.device_list_options)

        self.advanced_options = AdvancedGroupBox(self, device)
        self.l.addWidget(self.advanced_options)
        self.addDeviceWidget(self.advanced_options)

        self.l.addStretch()

    def validate(self):
        return self.metadata_options.validate()
    def initialize_controls(self, title, initial_value):
        self.setWindowTitle('Lock Series Index')
        layout = QVBoxLayout(self)
        self.setLayout(layout)
        title_layout = ImageTitleLayout(self, 'images/lock32.png',
                                        'Lock Series Index')
        layout.addLayout(title_layout)

        layout.addSpacing(10)
        self.title_label = QLabel('Series index for book: \'%s\'' % title,
                                  self)
        layout.addWidget(self.title_label)

        hlayout = QHBoxLayout()
        layout.addLayout(hlayout)

        self.value_spinbox = QDoubleSpinBox(self)
        self.value_spinbox.setRange(0, 99000000)
        self.value_spinbox.setDecimals(2)
        if initial_value is not None:
            self.value_spinbox.setValue(initial_value)
        self.value_spinbox.selectAll()
        hlayout.addWidget(self.value_spinbox, 0)
        hlayout.addStretch(1)

        self.assign_same_checkbox = QCheckBox(
            '&Assign this index value to all remaining books', self)
        layout.addWidget(self.assign_same_checkbox)
        layout.addStretch(1)

        # Dialog buttons
        button_box = QDialogButtonBox(QDialogButtonBox.Ok
                                      | QDialogButtonBox.Cancel)
        button_box.accepted.connect(self.accept)
        button_box.rejected.connect(self.reject)
        layout.addWidget(button_box)
Ejemplo n.º 33
0
class Tab2Config(DeviceConfigTab):  # {{{

    def __init__(self, parent, device):
        super(Tab2Config, self).__init__(parent)

        self.l = QVBoxLayout(self)
        self.setLayout(self.l)

        self.metadata_options = MetadataGroupBox(self, device)
        self.l.addWidget(self.metadata_options)
        self.addDeviceWidget(self.metadata_options)

        self.device_list_options = DeviceListGroupBox(self, device)
        self.l.addWidget(self.device_list_options)
        self.addDeviceWidget(self.device_list_options)

        self.advanced_options = AdvancedGroupBox(self, device)
        self.l.addWidget(self.advanced_options)
        self.addDeviceWidget(self.advanced_options)

        self.l.addStretch()

    def validate(self):
        return self.metadata_options.validate()
Ejemplo n.º 34
0
    def setup_ui(self):
        from calibre.gui2.preferences.look_feel import (DisplayedFields,
                                                        move_field_down,
                                                        move_field_up)
        self.l = QVBoxLayout(self)
        self.field_display_order = fdo = QListView(self)
        self.model = DisplayedFields(self.db,
                                     fdo,
                                     pref_name='popup_book_display_fields')
        self.model.initialize()
        fdo.setModel(self.model)
        fdo.setAlternatingRowColors(True)
        del self.db
        self.l.addWidget(QLabel(_('Select displayed metadata')))
        h = QHBoxLayout()
        h.addWidget(fdo)
        v = QVBoxLayout()
        self.mub = b = QToolButton(self)
        connect_lambda(b.clicked, self,
                       lambda self: move_field_up(fdo, self.model))
        b.setIcon(QIcon(I('arrow-up.png')))
        b.setToolTip(_('Move the selected field up'))
        v.addWidget(b), v.addStretch(10)
        self.mud = b = QToolButton(self)
        b.setIcon(QIcon(I('arrow-down.png')))
        b.setToolTip(_('Move the selected field down'))
        connect_lambda(b.clicked, self,
                       lambda self: move_field_down(fdo, self.model))
        v.addWidget(b)
        h.addLayout(v)

        self.l.addLayout(h)
        self.l.addWidget(
            QLabel('<p>' + _(
                'Note that <b>comments</b> will always be displayed at the end, regardless of the order you assign here'
            )))

        b = self.bb.addButton(_('Restore &defaults'),
                              QDialogButtonBox.ButtonRole.ActionRole)
        b.clicked.connect(self.restore_defaults)
        b = self.bb.addButton(_('Select &all'),
                              QDialogButtonBox.ButtonRole.ActionRole)
        b.clicked.connect(self.select_all)
        b = self.bb.addButton(_('Select &none'),
                              QDialogButtonBox.ButtonRole.ActionRole)
        b.clicked.connect(self.select_none)
        self.l.addWidget(self.bb)
        self.setMinimumHeight(500)
Ejemplo n.º 35
0
    def _initialise_layout(self):
        layout = QHBoxLayout(self)
        self.setLayout(layout)

        self.tv = QTreeWidget(self.gui)
        self.tv.setIconSize(QSize(ICON_SIZE, ICON_SIZE))
        self.tv.header().hide()
        layout.addWidget(self.tv, 1)

        self.items_list = FavMenusListWidget(self.gui)
        self.items_list.setIconSize(QSize(ICON_SIZE, ICON_SIZE))
        layout.addWidget(self.items_list, 1)

        button_layout = QVBoxLayout()
        layout.addLayout(button_layout)

        self.up_btn = QToolButton(self.gui)
        self.up_btn.setIcon(get_icon('arrow-up.png'))
        self.up_btn.setToolTip('Move the selected menu item up')
        self.up_btn.clicked.connect(self._move_item_up)
        self.down_btn = QToolButton(self.gui)
        self.down_btn.setIcon(get_icon('arrow-down.png'))
        self.down_btn.setToolTip('Move the selected menu item down')
        self.down_btn.clicked.connect(self._move_item_down)
        self.remove_btn = QToolButton(self.gui)
        self.remove_btn.setIcon(get_icon('trash.png'))
        self.remove_btn.setToolTip('Remove the selected item from the menu')
        self.remove_btn.clicked.connect(self._remove_item)
        self.sep_btn = QToolButton(self.gui)
        self.sep_btn.setIcon(get_icon('plus.png'))
        self.sep_btn.setToolTip('Add a separator to the menu following the selected item')
        self.sep_btn.clicked.connect(self._add_separator)
        self.rename_btn = QToolButton(self.gui)
        self.rename_btn.setIcon(get_icon('edit-undo.png'))
        self.rename_btn.setToolTip('Rename the menu item for when it appears on your Favourites menu')
        self.rename_btn.clicked.connect(self._rename_item)
        button_layout.addWidget(self.up_btn)
        button_layout.addStretch(1)
        button_layout.addWidget(self.rename_btn)
        button_layout.addStretch(1)
        button_layout.addWidget(self.sep_btn)
        button_layout.addStretch(1)
        button_layout.addWidget(self.remove_btn)
        button_layout.addStretch(1)
        button_layout.addWidget(self.down_btn)
Ejemplo n.º 36
0
    def __init__(self, main):
        super(GameListWidget, self).__init__()
        self.main_win = main
        self.keystore_exchanged = False

        self.setObjectName("GameListWidget")
        v_layout = QVBoxLayout()

        h_layout1 = QHBoxLayout()
        self.game_list_view = QListView()
        self.game_list_view.setViewMode(QListView.ListMode)
        self.game_list_view.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.game_list_model = GameListModel(self.main_win.games)
        self.game_list_view.setModel(self.game_list_model)
        self.game_list_view.clicked.connect(self.list_item_onclick)
        h_layout1.addWidget(self.game_list_view, 1)
        self.game_list_view.setCurrentIndex(
            self.game_list_model.index(self.main_win.game_index))
        self.game = self.main_win.games[self.main_win.game_index]

        form_layout = QFormLayout()
        form_layout.setContentsMargins(20, 50, 20, 50)
        self.game_name_value = QLineEdit()
        form_layout.addRow("游戏名称:", self.game_name_value)
        self.game_desc_value = QTextEdit()
        form_layout.addRow("游戏简介:", self.game_desc_value)
        self.game_appid_value = QLabel()
        self.game_appid_value.setTextInteractionFlags(Qt.TextSelectableByMouse)
        form_layout.addRow("游戏ID:", self.game_appid_value)
        self.game_appkey_value = QLabel()
        self.game_appkey_value.setTextInteractionFlags(
            Qt.TextSelectableByMouse)
        form_layout.addRow("客户端Key:", self.game_appkey_value)
        h_layout = QHBoxLayout()
        self.keystore_path = QLineEdit()
        select_key_btn = QPushButton("浏览")
        select_key_btn.setStyleSheet('QPushButton{border-radius: 0px;}')
        select_key_btn.clicked.connect(self.select_ketstore)
        h_layout.addWidget(self.keystore_path)
        h_layout.addWidget(select_key_btn)
        form_layout.addRow("KeyStore:", h_layout)
        self.keystore_pwd_value = QLineEdit()
        form_layout.addRow("KeyPass:"******"Alias:", self.keystore_alias_value)
        self.keystore_aliaspwd_value = QLineEdit()
        form_layout.addRow("AliasPass:"******"更换Icon")
        icon_exchange_btn.setFixedWidth(100)
        icon_exchange_btn.clicked.connect(self.exchange_icon)
        v_layout1.addWidget(icon_exchange_btn, alignment=Qt.AlignHCenter)
        v_layout1.addStretch(2)
        h_layout1.addLayout(v_layout1, 1)
        v_layout.addLayout(h_layout1)

        h_layout2 = QHBoxLayout()
        create_game_btn = QPushButton("返 回")
        create_game_btn.setFixedWidth(100)
        create_game_btn.clicked.connect(self.back)
        h_layout2.addWidget(create_game_btn,
                            alignment=Qt.AlignLeft | Qt.AlignBottom)
        back_btn = QPushButton("创建游戏")
        back_btn.setFixedWidth(100)
        back_btn.clicked.connect(self.add_game)
        h_layout2.addWidget(back_btn, alignment=Qt.AlignHCenter)
        next_btn = QPushButton("下一步")
        next_btn.setFixedWidth(100)
        next_btn.clicked.connect(self.next)
        h_layout2.addWidget(next_btn, alignment=Qt.AlignRight | Qt.AlignBottom)
        v_layout.addLayout(h_layout2)
        self.setLayout(v_layout)
        self.set_game_info()
Ejemplo n.º 37
0
    def __init__(self, window, plugin, keystore, device_id):
        title = _("%s Settings") % plugin.device
        super(SettingsDialog, self).__init__(window, title)
        self.setMaximumWidth(540)

        devmgr = plugin.device_manager()
        config = devmgr.config
        handler = keystore.handler
        thread = keystore.thread
        hs_rows, hs_cols = (64, 128)

        def invoke_client(method, *args, **kw_args):
            unpair_after = kw_args.pop('unpair_after', False)

            def task():
                client = devmgr.client_by_id(device_id)
                if not client:
                    raise RuntimeError("Device not connected")
                if method:
                    getattr(client, method)(*args, **kw_args)
                if unpair_after:
                    devmgr.unpair_id(device_id)
                return client.features

            thread.add(task, on_success=update)

        def update(features):
            self.features = features
            set_label_enabled()
            bl_hash = bh2u(features.bootloader_hash)
            bl_hash = "\n".join([bl_hash[:32], bl_hash[32:]])
            noyes = [_("No"), _("Yes")]
            endis = [_("Enable Passphrases"), _("Disable Passphrases")]
            disen = [_("Disabled"), _("Enabled")]
            setchange = [_("Set a PIN"), _("Change PIN")]

            version = "%d.%d.%d" % (features.major_version,
                                    features.minor_version,
                                    features.patch_version)
            coins = ", ".join(coin.coin_name for coin in features.coins)

            device_label.setText(features.label)
            pin_set_label.setText(noyes[features.pin_protection])
            passphrases_label.setText(disen[features.passphrase_protection])
            bl_hash_label.setText(bl_hash)
            label_edit.setText(features.label)
            device_id_label.setText(features.device_id)
            initialized_label.setText(noyes[features.initialized])
            version_label.setText(version)
            coins_label.setText(coins)
            clear_pin_button.setVisible(features.pin_protection)
            clear_pin_warning.setVisible(features.pin_protection)
            pin_button.setText(setchange[features.pin_protection])
            pin_msg.setVisible(not features.pin_protection)
            passphrase_button.setText(endis[features.passphrase_protection])
            language_label.setText(features.language)

        def set_label_enabled():
            label_apply.setEnabled(label_edit.text() != self.features.label)

        def rename():
            invoke_client('change_label', label_edit.text())

        def toggle_passphrase():
            title = _("Confirm Toggle Passphrase Protection")
            currently_enabled = self.features.passphrase_protection
            if currently_enabled:
                msg = _("After disabling passphrases, you can only pair this "
                        "Electrum-DASH wallet if it had an empty passphrase.  "
                        "If its passphrase was not empty, you will need to "
                        "create a new wallet with the install wizard.  You "
                        "can use this wallet again at any time by re-enabling "
                        "passphrases and entering its passphrase.")
            else:
                msg = _(
                    "Your current Electrum-DASH wallet can only be used with "
                    "an empty passphrase.  You must create a separate "
                    "wallet with the install wizard for other passphrases "
                    "as each one generates a new set of addresses.")
            msg += "\n\n" + _("Are you sure you want to proceed?")
            if not self.question(msg, title=title):
                return
            invoke_client('toggle_passphrase', unpair_after=currently_enabled)

        def change_homescreen():
            from PIL import Image  # FIXME
            dialog = QFileDialog(self, _("Choose Homescreen"))
            filename, __ = dialog.getOpenFileName()
            if filename:
                im = Image.open(str(filename))
                if im.size != (hs_cols, hs_rows):
                    raise Exception('Image must be 64 x 128 pixels')
                im = im.convert('1')
                pix = im.load()
                img = ''
                for j in range(hs_rows):
                    for i in range(hs_cols):
                        img += '1' if pix[i, j] else '0'
                img = ''.join(
                    chr(int(img[i:i + 8], 2)) for i in range(0, len(img), 8))
                invoke_client('change_homescreen', img)

        def clear_homescreen():
            invoke_client('change_homescreen', '\x00')

        def set_pin():
            invoke_client('set_pin', remove=False)

        def clear_pin():
            invoke_client('set_pin', remove=True)

        def wipe_device():
            wallet = window.wallet
            if wallet and sum(wallet.get_balance()):
                title = _("Confirm Device Wipe")
                msg = _("Are you SURE you want to wipe the device?\n"
                        "Your wallet still has Dash coins in it!")
                if not self.question(
                        msg, title=title, icon=QMessageBox.Critical):
                    return
            invoke_client('wipe_device', unpair_after=True)

        def slider_moved():
            mins = timeout_slider.sliderPosition()
            timeout_minutes.setText(_("%2d minutes") % mins)

        def slider_released():
            config.set_session_timeout(timeout_slider.sliderPosition() * 60)

        # Information tab
        info_tab = QWidget()
        info_layout = QVBoxLayout(info_tab)
        info_glayout = QGridLayout()
        info_glayout.setColumnStretch(2, 1)
        device_label = QLabel()
        pin_set_label = QLabel()
        passphrases_label = QLabel()
        version_label = QLabel()
        device_id_label = QLabel()
        bl_hash_label = QLabel()
        bl_hash_label.setWordWrap(True)
        coins_label = QLabel()
        coins_label.setWordWrap(True)
        language_label = QLabel()
        initialized_label = QLabel()
        rows = [
            (_("Device Label"), device_label),
            (_("PIN set"), pin_set_label),
            (_("Passphrases"), passphrases_label),
            (_("Firmware Version"), version_label),
            (_("Device ID"), device_id_label),
            (_("Bootloader Hash"), bl_hash_label),
            (_("Supported Coins"), coins_label),
            (_("Language"), language_label),
            (_("Initialized"), initialized_label),
        ]
        for row_num, (label, widget) in enumerate(rows):
            info_glayout.addWidget(QLabel(label), row_num, 0)
            info_glayout.addWidget(widget, row_num, 1)
        info_layout.addLayout(info_glayout)

        # Settings tab
        settings_tab = QWidget()
        settings_layout = QVBoxLayout(settings_tab)
        settings_glayout = QGridLayout()

        # Settings tab - Label
        label_msg = QLabel(
            _("Name this %s.  If you have mutiple devices "
              "their labels help distinguish them.") % plugin.device)
        label_msg.setWordWrap(True)
        label_label = QLabel(_("Device Label"))
        label_edit = QLineEdit()
        label_edit.setMinimumWidth(150)
        label_edit.setMaxLength(plugin.MAX_LABEL_LEN)
        label_apply = QPushButton(_("Apply"))
        label_apply.clicked.connect(rename)
        label_edit.textChanged.connect(set_label_enabled)
        settings_glayout.addWidget(label_label, 0, 0)
        settings_glayout.addWidget(label_edit, 0, 1, 1, 2)
        settings_glayout.addWidget(label_apply, 0, 3)
        settings_glayout.addWidget(label_msg, 1, 1, 1, -1)

        # Settings tab - PIN
        pin_label = QLabel(_("PIN Protection"))
        pin_button = QPushButton()
        pin_button.clicked.connect(set_pin)
        settings_glayout.addWidget(pin_label, 2, 0)
        settings_glayout.addWidget(pin_button, 2, 1)
        pin_msg = QLabel(
            _("PIN protection is strongly recommended.  "
              "A PIN is your only protection against someone "
              "stealing your Dash coins if they obtain physical "
              "access to your %s.") % plugin.device)
        pin_msg.setWordWrap(True)
        pin_msg.setStyleSheet("color: red")
        settings_glayout.addWidget(pin_msg, 3, 1, 1, -1)

        # Settings tab - Homescreen
        if plugin.device != 'KeepKey':  # Not yet supported by KK firmware
            homescreen_layout = QHBoxLayout()
            homescreen_label = QLabel(_("Homescreen"))
            homescreen_change_button = QPushButton(_("Change..."))
            homescreen_clear_button = QPushButton(_("Reset"))
            homescreen_change_button.clicked.connect(change_homescreen)
            homescreen_clear_button.clicked.connect(clear_homescreen)
            homescreen_msg = QLabel(
                _("You can set the homescreen on your "
                  "device to personalize it.  You must "
                  "choose a %d x %d monochrome black and "
                  "white image.") % (hs_rows, hs_cols))
            homescreen_msg.setWordWrap(True)
            settings_glayout.addWidget(homescreen_label, 4, 0)
            settings_glayout.addWidget(homescreen_change_button, 4, 1)
            settings_glayout.addWidget(homescreen_clear_button, 4, 2)
            settings_glayout.addWidget(homescreen_msg, 5, 1, 1, -1)

        # Settings tab - Session Timeout
        timeout_label = QLabel(_("Session Timeout"))
        timeout_minutes = QLabel()
        timeout_slider = QSlider(Qt.Horizontal)
        timeout_slider.setRange(1, 60)
        timeout_slider.setSingleStep(1)
        timeout_slider.setTickInterval(5)
        timeout_slider.setTickPosition(QSlider.TicksBelow)
        timeout_slider.setTracking(True)
        timeout_msg = QLabel(
            _("Clear the session after the specified period "
              "of inactivity.  Once a session has timed out, "
              "your PIN and passphrase (if enabled) must be "
              "re-entered to use the device."))
        timeout_msg.setWordWrap(True)
        timeout_slider.setSliderPosition(config.get_session_timeout() // 60)
        slider_moved()
        timeout_slider.valueChanged.connect(slider_moved)
        timeout_slider.sliderReleased.connect(slider_released)
        settings_glayout.addWidget(timeout_label, 6, 0)
        settings_glayout.addWidget(timeout_slider, 6, 1, 1, 3)
        settings_glayout.addWidget(timeout_minutes, 6, 4)
        settings_glayout.addWidget(timeout_msg, 7, 1, 1, -1)
        settings_layout.addLayout(settings_glayout)
        settings_layout.addStretch(1)

        # Advanced tab
        advanced_tab = QWidget()
        advanced_layout = QVBoxLayout(advanced_tab)
        advanced_glayout = QGridLayout()

        # Advanced tab - clear PIN
        clear_pin_button = QPushButton(_("Disable PIN"))
        clear_pin_button.clicked.connect(clear_pin)
        clear_pin_warning = QLabel(
            _("If you disable your PIN, anyone with physical access to your "
              "%s device can spend your Dash coins.") % plugin.device)
        clear_pin_warning.setWordWrap(True)
        clear_pin_warning.setStyleSheet("color: red")
        advanced_glayout.addWidget(clear_pin_button, 0, 2)
        advanced_glayout.addWidget(clear_pin_warning, 1, 0, 1, 5)

        # Advanced tab - toggle passphrase protection
        passphrase_button = QPushButton()
        passphrase_button.clicked.connect(toggle_passphrase)
        passphrase_msg = WWLabel(PASSPHRASE_HELP)
        passphrase_warning = WWLabel(PASSPHRASE_NOT_PIN)
        passphrase_warning.setStyleSheet("color: red")
        advanced_glayout.addWidget(passphrase_button, 3, 2)
        advanced_glayout.addWidget(passphrase_msg, 4, 0, 1, 5)
        advanced_glayout.addWidget(passphrase_warning, 5, 0, 1, 5)

        # Advanced tab - wipe device
        wipe_device_button = QPushButton(_("Wipe Device"))
        wipe_device_button.clicked.connect(wipe_device)
        wipe_device_msg = QLabel(
            _("Wipe the device, removing all data from it.  The firmware "
              "is left unchanged."))
        wipe_device_msg.setWordWrap(True)
        wipe_device_warning = QLabel(
            _("Only wipe a device if you have the recovery seed written down "
              "and the device wallet(s) are empty, otherwise the Dash coins "
              "will be lost forever."))
        wipe_device_warning.setWordWrap(True)
        wipe_device_warning.setStyleSheet("color: red")
        advanced_glayout.addWidget(wipe_device_button, 6, 2)
        advanced_glayout.addWidget(wipe_device_msg, 7, 0, 1, 5)
        advanced_glayout.addWidget(wipe_device_warning, 8, 0, 1, 5)
        advanced_layout.addLayout(advanced_glayout)
        advanced_layout.addStretch(1)

        tabs = QTabWidget(self)
        tabs.addTab(info_tab, _("Information"))
        tabs.addTab(settings_tab, _("Settings"))
        tabs.addTab(advanced_tab, _("Advanced"))
        dialog_vbox = QVBoxLayout(self)
        dialog_vbox.addWidget(tabs)
        dialog_vbox.addLayout(Buttons(CloseButton(self)))

        # Update information
        invoke_client(None)
Ejemplo n.º 38
0
    def __init__(self, window, plugin, keystore, device_id):
        title = _("{} Settings").format(plugin.device)
        super(SettingsDialog, self).__init__(window, title)
        self.setMaximumWidth(540)

        devmgr = plugin.device_manager()
        config = devmgr.config
        handler = keystore.handler
        thread = keystore.thread
        hs_rows, hs_cols = (64, 128)

        def invoke_client(method, *args, **kw_args):
            unpair_after = kw_args.pop('unpair_after', False)

            def task():
                client = devmgr.client_by_id(device_id)
                if not client:
                    raise RuntimeError("Device not connected")
                if method:
                    getattr(client, method)(*args, **kw_args)
                if unpair_after:
                    devmgr.unpair_id(device_id)
                return client.features

            thread.add(task, on_success=update)

        def update(features):
            self.features = features
            set_label_enabled()
            if features.bootloader_hash:
                bl_hash = bh2u(features.bootloader_hash)
                bl_hash = "\n".join([bl_hash[:32], bl_hash[32:]])
            else:
                bl_hash = "N/A"
            noyes = [_("No"), _("Yes")]
            endis = [_("Enable Passphrases"), _("Disable Passphrases")]
            disen = [_("Disabled"), _("Enabled")]
            setchange = [_("Set a PIN"), _("Change PIN")]

            version = "%d.%d.%d" % (features.major_version,
                                    features.minor_version,
                                    features.patch_version)

            device_label.setText(features.label)
            pin_set_label.setText(noyes[features.pin_protection])
            passphrases_label.setText(disen[features.passphrase_protection])
            bl_hash_label.setText(bl_hash)
            label_edit.setText(features.label)
            device_id_label.setText(features.device_id)
            initialized_label.setText(noyes[features.initialized])
            version_label.setText(version)
            clear_pin_button.setVisible(features.pin_protection)
            clear_pin_warning.setVisible(features.pin_protection)
            pin_button.setText(setchange[features.pin_protection])
            pin_msg.setVisible(not features.pin_protection)
            passphrase_button.setText(endis[features.passphrase_protection])
            language_label.setText(features.language)

        def set_label_enabled():
            label_apply.setEnabled(label_edit.text() != self.features.label)

        def rename():
            invoke_client('change_label', label_edit.text())

        def toggle_passphrase():
            title = _("Confirm Toggle Passphrase Protection")
            currently_enabled = self.features.passphrase_protection
            if currently_enabled:
                msg = _("After disabling passphrases, you can only pair this "
                        "Electrum wallet if it had an empty passphrase.  "
                        "If its passphrase was not empty, you will need to "
                        "create a new wallet with the install wizard.  You "
                        "can use this wallet again at any time by re-enabling "
                        "passphrases and entering its passphrase.")
            else:
                msg = _("Your current Electrum wallet can only be used with "
                        "an empty passphrase.  You must create a separate "
                        "wallet with the install wizard for other passphrases "
                        "as each one generates a new set of addresses.")
            msg += "\n\n" + _("Are you sure you want to proceed?")
            if not self.question(msg, title=title):
                return
            invoke_client('toggle_passphrase', unpair_after=currently_enabled)

        def change_homescreen():
            dialog = QFileDialog(self, _("Choose Homescreen"))
            filename, __ = dialog.getOpenFileName()
            if not filename:
                return  # user cancelled

            if filename.endswith('.toif'):
                img = open(filename, 'rb').read()
                if img[:8] != b'TOIf\x90\x00\x90\x00':
                    handler.show_error('File is not a TOIF file with size of 144x144')
                    return
            else:
                from PIL import Image # FIXME
                im = Image.open(filename)
                if im.size != (128, 64):
                    handler.show_error('Image must be 128 x 64 pixels')
                    return
                im = im.convert('1')
                pix = im.load()
                img = bytearray(1024)
                for j in range(64):
                    for i in range(128):
                        if pix[i, j]:
                            o = (i + j * 128)
                            img[o // 8] |= (1 << (7 - o % 8))
                img = bytes(img)
            invoke_client('change_homescreen', img)

        def clear_homescreen():
            invoke_client('change_homescreen', b'\x00')

        def set_pin():
            invoke_client('set_pin', remove=False)

        def clear_pin():
            invoke_client('set_pin', remove=True)

        def wipe_device():
            wallet = window.wallet
            if wallet and sum(wallet.get_balance()):
                title = _("Confirm Device Wipe")
                msg = _("Are you SURE you want to wipe the device?\n"
                        "Your wallet still has bitcoins in it!")
                if not self.question(msg, title=title,
                                     icon=QMessageBox.Critical):
                    return
            invoke_client('wipe_device', unpair_after=True)

        def slider_moved():
            mins = timeout_slider.sliderPosition()
            timeout_minutes.setText(_("%2d minutes") % mins)

        def slider_released():
            config.set_session_timeout(timeout_slider.sliderPosition() * 60)

        # Information tab
        info_tab = QWidget()
        info_layout = QVBoxLayout(info_tab)
        info_glayout = QGridLayout()
        info_glayout.setColumnStretch(2, 1)
        device_label = QLabel()
        pin_set_label = QLabel()
        passphrases_label = QLabel()
        version_label = QLabel()
        device_id_label = QLabel()
        bl_hash_label = QLabel()
        bl_hash_label.setWordWrap(True)
        language_label = QLabel()
        initialized_label = QLabel()
        rows = [
            (_("Device Label"), device_label),
            (_("PIN set"), pin_set_label),
            (_("Passphrases"), passphrases_label),
            (_("Firmware Version"), version_label),
            (_("Device ID"), device_id_label),
            (_("Bootloader Hash"), bl_hash_label),
            (_("Language"), language_label),
            (_("Initialized"), initialized_label),
        ]
        for row_num, (label, widget) in enumerate(rows):
            info_glayout.addWidget(QLabel(label), row_num, 0)
            info_glayout.addWidget(widget, row_num, 1)
        info_layout.addLayout(info_glayout)

        # Settings tab
        settings_tab = QWidget()
        settings_layout = QVBoxLayout(settings_tab)
        settings_glayout = QGridLayout()

        # Settings tab - Label
        label_msg = QLabel(_("Name this {}.  If you have multiple devices "
                             "their labels help distinguish them.")
                           .format(plugin.device))
        label_msg.setWordWrap(True)
        label_label = QLabel(_("Device Label"))
        label_edit = QLineEdit()
        label_edit.setMinimumWidth(150)
        label_edit.setMaxLength(plugin.MAX_LABEL_LEN)
        label_apply = QPushButton(_("Apply"))
        label_apply.clicked.connect(rename)
        label_edit.textChanged.connect(set_label_enabled)
        settings_glayout.addWidget(label_label, 0, 0)
        settings_glayout.addWidget(label_edit, 0, 1, 1, 2)
        settings_glayout.addWidget(label_apply, 0, 3)
        settings_glayout.addWidget(label_msg, 1, 1, 1, -1)

        # Settings tab - PIN
        pin_label = QLabel(_("PIN Protection"))
        pin_button = QPushButton()
        pin_button.clicked.connect(set_pin)
        settings_glayout.addWidget(pin_label, 2, 0)
        settings_glayout.addWidget(pin_button, 2, 1)
        pin_msg = QLabel(_("PIN protection is strongly recommended.  "
                           "A PIN is your only protection against someone "
                           "stealing your bitcoins if they obtain physical "
                           "access to your {}.").format(plugin.device))
        pin_msg.setWordWrap(True)
        pin_msg.setStyleSheet("color: red")
        settings_glayout.addWidget(pin_msg, 3, 1, 1, -1)

        # Settings tab - Homescreen
        homescreen_label = QLabel(_("Homescreen"))
        homescreen_change_button = QPushButton(_("Change..."))
        homescreen_clear_button = QPushButton(_("Reset"))
        homescreen_change_button.clicked.connect(change_homescreen)
        try:
            import PIL
        except ImportError:
            homescreen_change_button.setDisabled(True)
            homescreen_change_button.setToolTip(
                _("Required package 'PIL' is not available - Please install it or use the Trezor website instead.")
            )
        homescreen_clear_button.clicked.connect(clear_homescreen)
        homescreen_msg = QLabel(_("You can set the homescreen on your "
                                  "device to personalize it.  You must "
                                  "choose a {} x {} monochrome black and "
                                  "white image.").format(hs_rows, hs_cols))
        homescreen_msg.setWordWrap(True)
        settings_glayout.addWidget(homescreen_label, 4, 0)
        settings_glayout.addWidget(homescreen_change_button, 4, 1)
        settings_glayout.addWidget(homescreen_clear_button, 4, 2)
        settings_glayout.addWidget(homescreen_msg, 5, 1, 1, -1)

        # Settings tab - Session Timeout
        timeout_label = QLabel(_("Session Timeout"))
        timeout_minutes = QLabel()
        timeout_slider = QSlider(Qt.Horizontal)
        timeout_slider.setRange(1, 60)
        timeout_slider.setSingleStep(1)
        timeout_slider.setTickInterval(5)
        timeout_slider.setTickPosition(QSlider.TicksBelow)
        timeout_slider.setTracking(True)
        timeout_msg = QLabel(
            _("Clear the session after the specified period "
              "of inactivity.  Once a session has timed out, "
              "your PIN and passphrase (if enabled) must be "
              "re-entered to use the device."))
        timeout_msg.setWordWrap(True)
        timeout_slider.setSliderPosition(config.get_session_timeout() // 60)
        slider_moved()
        timeout_slider.valueChanged.connect(slider_moved)
        timeout_slider.sliderReleased.connect(slider_released)
        settings_glayout.addWidget(timeout_label, 6, 0)
        settings_glayout.addWidget(timeout_slider, 6, 1, 1, 3)
        settings_glayout.addWidget(timeout_minutes, 6, 4)
        settings_glayout.addWidget(timeout_msg, 7, 1, 1, -1)
        settings_layout.addLayout(settings_glayout)
        settings_layout.addStretch(1)

        # Advanced tab
        advanced_tab = QWidget()
        advanced_layout = QVBoxLayout(advanced_tab)
        advanced_glayout = QGridLayout()

        # Advanced tab - clear PIN
        clear_pin_button = QPushButton(_("Disable PIN"))
        clear_pin_button.clicked.connect(clear_pin)
        clear_pin_warning = QLabel(
            _("If you disable your PIN, anyone with physical access to your "
              "{} device can spend your bitcoins.").format(plugin.device))
        clear_pin_warning.setWordWrap(True)
        clear_pin_warning.setStyleSheet("color: red")
        advanced_glayout.addWidget(clear_pin_button, 0, 2)
        advanced_glayout.addWidget(clear_pin_warning, 1, 0, 1, 5)

        # Advanced tab - toggle passphrase protection
        passphrase_button = QPushButton()
        passphrase_button.clicked.connect(toggle_passphrase)
        passphrase_msg = WWLabel(PASSPHRASE_HELP)
        passphrase_warning = WWLabel(PASSPHRASE_NOT_PIN)
        passphrase_warning.setStyleSheet("color: red")
        advanced_glayout.addWidget(passphrase_button, 3, 2)
        advanced_glayout.addWidget(passphrase_msg, 4, 0, 1, 5)
        advanced_glayout.addWidget(passphrase_warning, 5, 0, 1, 5)

        # Advanced tab - wipe device
        wipe_device_button = QPushButton(_("Wipe Device"))
        wipe_device_button.clicked.connect(wipe_device)
        wipe_device_msg = QLabel(
            _("Wipe the device, removing all data from it.  The firmware "
              "is left unchanged."))
        wipe_device_msg.setWordWrap(True)
        wipe_device_warning = QLabel(
            _("Only wipe a device if you have the recovery seed written down "
              "and the device wallet(s) are empty, otherwise the bitcoins "
              "will be lost forever."))
        wipe_device_warning.setWordWrap(True)
        wipe_device_warning.setStyleSheet("color: red")
        advanced_glayout.addWidget(wipe_device_button, 6, 2)
        advanced_glayout.addWidget(wipe_device_msg, 7, 0, 1, 5)
        advanced_glayout.addWidget(wipe_device_warning, 8, 0, 1, 5)
        advanced_layout.addLayout(advanced_glayout)
        advanced_layout.addStretch(1)

        tabs = QTabWidget(self)
        tabs.addTab(info_tab, _("Information"))
        tabs.addTab(settings_tab, _("Settings"))
        tabs.addTab(advanced_tab, _("Advanced"))
        dialog_vbox = QVBoxLayout(self)
        dialog_vbox.addWidget(tabs)
        dialog_vbox.addLayout(Buttons(CloseButton(self)))

        # Update information
        invoke_client(None)
Ejemplo n.º 39
0
    def __init__(self, parent = None):
        super(SettingsWidget, self).__init__(parent, Qt.FramelessWindowHint)
        self._mousePressed = False
        self._orgPos = QPoint(0, 0)
        self.setObjectName('SettingsWidget')

        #
        self.stylize()

        # main layout
        labelTitle = QLabel('设置', self)
        buttonClose = JCloseButton(self)
        buttonClose.setObjectName('buttonClose')
        buttonClose.setToolTip('关闭')

        horiLayoutTitle = QHBoxLayout()
        horiLayoutTitle.setContentsMargins(6, 0, 6, 6)
        horiLayoutTitle.addWidget(labelTitle, 0, Qt.AlignTop)
        horiLayoutTitle.addStretch()
        horiLayoutTitle.addWidget(buttonClose, 0, Qt.AlignTop)

        groupBoxSettings = QGroupBox('设置端口', self)
        groupBoxSettings.setObjectName('groupBoxSettings')
        formLayoutSettings = QFormLayout(groupBoxSettings)
        formLayoutSettings.setContentsMargins(40, 10, 40, 10)
        formLayoutSettings.setVerticalSpacing(20)
        formLayoutSettings.setLabelAlignment(Qt.AlignRight)

        self.comboBoxPort = QComboBox(self)
        self.comboBoxPort.setMinimumWidth(100)
        formLayoutSettings.addRow('端口号:', self.comboBoxPort)

        self.comboBoxBaudRate = QComboBox(self)
        self.comboBoxBaudRate.setMinimumWidth(100)
        formLayoutSettings.addRow('波特率:', self.comboBoxBaudRate)

        self.labelDataBits = QComboBox(self)
        self.labelDataBits.setMinimumWidth(100)
        formLayoutSettings.addRow('数据位:', self.labelDataBits)

        self.comboBoxParity = QComboBox(self)
        self.comboBoxParity.setMinimumWidth(100)
        formLayoutSettings.addRow('校验位:', self.comboBoxParity)

        self.comboBoxStopBits = QComboBox(self)
        self.comboBoxStopBits.setMinimumWidth(100)
        formLayoutSettings.addRow('停止位:', self.comboBoxStopBits)

        # all
        horiLayoutSettings = QHBoxLayout();
        horiLayoutSettings.addStretch();
        horiLayoutSettings.addWidget(groupBoxSettings);
        horiLayoutSettings.addStretch();

        buttonOk = QPushButton('确定', self)
        buttonOk.setObjectName('buttonOk')
        horiLayoutButtons = QHBoxLayout()
        horiLayoutButtons.addStretch()
        horiLayoutButtons.addWidget(buttonOk)

        vertLayoutMain = QVBoxLayout(self)
        vertLayoutMain.addLayout(horiLayoutTitle)
        vertLayoutMain.addSpacing(5)
        # vertLayoutMain.addWidget(groupBoxSettings)
        vertLayoutMain.addLayout(horiLayoutSettings)
        vertLayoutMain.addStretch()
        vertLayoutMain.addLayout(horiLayoutButtons)

        buttonClose.clicked.connect(self.close)
Ejemplo n.º 40
0
 def towerClick(self, tower):
     # Opens a popup to see tower stats and to upgrade tower
     if self.parent.gameover == False:
         
         if self.parent.isTowerSelected == False:
             self.clickedTower = tower
             # self.statusBarMessage("Tower clicked")
             self.towerPopUp = QFrame()
             self.towerPopUp.setGeometry(500, 500, 100, 100)
         
             grid = QGridLayout()
             self.towerPopUp.setLayout(grid)
             
             vbox = QVBoxLayout()
             pixmap = QLabel()
             vbox.addStretch()
             if tower.level == 2:
                 pixmap.setPixmap(tower.upgradedPicture)
             else:
                 pixmap.setPixmap(tower.picture)
             vbox.addWidget(pixmap)
             vbox.addStretch()
             
             grid.addLayout(vbox, 0, 0)
             
             towerStats = QLabel(tower.name + " Tower Stats", self)
             power = QLabel("Power: {:.0f}".format(tower.power), self)
             towerRange = QLabel("Range: {:.0f}".format(tower.range), self)
             fireRate = QLabel("Rate of Fire: " + str(tower.fireRate), self)
             level = QLabel("Level: " + str(tower.level), self)
         
             vbox2 = QVBoxLayout()
             vbox2.addWidget(towerStats)
             vbox2.addWidget(power)
             vbox2.addWidget(towerRange)
             vbox2.addWidget(fireRate)
             vbox2.addWidget(level)
         
             grid.addLayout(vbox2, 0, 1)
     
             vbox3 = QVBoxLayout()
             
             if self.clickedTower.maxLevel > self.clickedTower.level:
                 upgradeButton = QPushButton("Upgrade for " + str(tower.upgradePrice))
                 vbox3.addWidget(upgradeButton)
                 upgradeButton.clicked.connect(self.upgrade)
             else:
                 maxLevel = QLabel("Tower at maximum level.")
                 vbox3.addWidget(maxLevel)
             
             doneButton = QPushButton("Done")
             vbox3.addWidget(doneButton)
             grid.addLayout(vbox3, 0, 2)
         
             location = QPoint(QCursor.pos())
             self.towerPopUp.move(location.x() - 180, location.y())
             self.towerPopUp.show()
             doneButton.clicked.connect(self.towerPopUp.hide)
     
     else:
         self.statusBarMessage("The game has ended. Stop doing stuff.")
    def get_settings_widget(self):
        """
        Return the alignak settings QWidget

        :return: settings QWidget
        :rtype: QWidget
        """

        server_widget = QWidget()
        server_widget.setObjectName('dialog')
        server_layout = QVBoxLayout(server_widget)

        # Title
        title_lbl = QLabel(_('Alignak Backend'))
        title_lbl.setObjectName('itemtitle')
        server_layout.addWidget(title_lbl)
        server_layout.setAlignment(title_lbl, Qt.AlignTop)

        # Description
        desc_label = QLabel(
            _('Here you can define alignak settings. Be sure to enter a valid address.')
        )
        desc_label.setWordWrap(True)
        server_layout.addWidget(desc_label)

        # Server URL
        server_lbl = QLabel(_('Server'))
        server_layout.addWidget(server_lbl)

        self.server_url.setText(settings.get_config('Alignak', 'url'))
        self.server_url.setPlaceholderText(_('alignak backend url...'))
        self.server_url.setFixedHeight(25)
        server_layout.addWidget(self.server_url)

        # Server Port
        port_lbl = QLabel(_('Port'))
        server_layout.addWidget(port_lbl)

        cur_port = settings.get_config('Alignak', 'backend').split(':')[2]
        self.server_port.setText(cur_port)
        self.server_port.setPlaceholderText(_('alignak backend port...'))
        self.server_port.setFixedHeight(25)
        server_layout.addWidget(self.server_port)

        # Server Processes (displayed only for Unix platforms)
        if 'win32' not in sys.platform:
            process_lbl = QLabel(_('Processes'))
            server_layout.addWidget(process_lbl)

            cur_proc = settings.get_config('Alignak', 'processes')
            self.server_proc.setText(cur_proc)
            self.server_proc.setPlaceholderText(_('alignak backend processes...'))
            self.server_proc.setFixedHeight(25)
            server_layout.addWidget(self.server_proc)

        # Web Service description
        server_layout.addStretch(1)
        webservice_lbl = QLabel(_('Web Service'))
        webservice_lbl.setObjectName('itemtitle')
        server_layout.addWidget(webservice_lbl)
        ws_desc_lbl = QLabel(
            _('Here you can define your alignak web service url, with port if needed')
        )
        ws_desc_lbl.setWordWrap(True)
        server_layout.addWidget(ws_desc_lbl)

        # Web Service URL
        self.webservice_url.setText(settings.get_config('Alignak', 'webservice'))
        self.webservice_url.setPlaceholderText(_('alignak webservice url...'))
        self.webservice_url.setFixedHeight(25)
        server_layout.addWidget(self.webservice_url)

        # Valid Button
        valid_btn = QPushButton(_('Valid'))
        valid_btn.setObjectName('valid')
        valid_btn.setMinimumHeight(30)
        valid_btn.clicked.connect(self.accept)

        server_layout.addWidget(valid_btn)

        return server_widget
Ejemplo n.º 42
0
 def initUI(self, gameboard): 
     
     self.setStyleSheet("QWidget { background: #BCBCBC}")
     self.setFrameStyle(QFrame.Sunken | QFrame.StyledPanel)
     self.setFixedSize((gameboard.width - 1)*blockSize, 120)
     self.grid = QGridLayout()
     self.setLayout(self.grid)
     
     hbox = QHBoxLayout()
     vbox = QVBoxLayout()
     
     towerLabel = QLabel()
     towerLabel.setPixmap(QPixmap(os.path.join('./Pictures/', "tower.png")))
     
     vbox.addWidget(towerLabel)
     
     vbox.addLayout(hbox)
     self.grid.addLayout(vbox, 0, 0)
     
     towers = gameboard.getTowers()
     i = 0
     buttons = 0
     
     # We go through the list of different towers in the map and add buttons for them to the bottom left corner of the screen.
     while i < len(towers):
         if towers[i] == "t1":
             self.musketeerButton = BuyButton(QPixmap(os.path.join('./Pictures/', "musketeer_buybutton.png")), QPixmap(os.path.join('./Pictures/', "musketeer_buybutton_hover.png")), QPixmap(os.path.join('./Pictures/', "musketeer_buybutton_pressed.png")), self)
             self.musketeerButton.move(buttons*towerButtonSize + 10, 50)
             self.musketeerButton.clicked.connect(self.musketeerButtonClick)
             hbox.addWidget(self.musketeerButton)
             buttons += 1
         elif towers[i] == "t2":
             self.cannonButton = BuyButton(QPixmap(os.path.join('./Pictures/', "cannon_buybutton.png")), QPixmap(os.path.join('./Pictures/', "cannon_buybutton_hovered.png")), QPixmap(os.path.join('./Pictures/', "cannon_buybutton_pressed.png")), self)
             self.cannonButton.move(buttons*towerButtonSize + 10, 50)
             self.cannonButton.clicked.connect(self.cannonButtonClick)
             hbox.addWidget(self.cannonButton)
             buttons += 1
         i += 1
     
     hbox.addStretch()
     
     '''
     slider2 = QSlider(Qt.Horizontal, self)
     slider2.setFocusPolicy(Qt.NoFocus)
     slider2.setSliderPosition(100 - self.parent.gameSpeed)
     #slider2.setGeometry(210, 140, 100, 20)
     slider2.valueChanged[int].connect(self.changeGameSpeed)
     
     hbox2 = QHBoxLayout()
     hbox2.addWidget(slider2)
     hbox2.addStretch()
     
     self.grid.addLayout(hbox2, 0, 1)
     '''
     
     hbox3 = QHBoxLayout()
     vbox3 = QVBoxLayout()
     hbox3.addStretch()
     
     self.lcd = QLCDNumber(self)
     
     vbox3.addStretch()
     vbox3.addWidget(self.lcd)
     vbox3.addStretch()
     
     self.pauseButton = QPushButton('Pause')
     self.pauseButton.clicked.connect(self.pauseGame)
 
     # I could add a restart button
     
     vbox3.addWidget(self.pauseButton)      
     self.grid.addLayout(vbox3, 0,2)
     
     self.show()
Ejemplo n.º 43
0
    def __init__(self, plugin_action):
        QWidget.__init__(self)
        self.plugin_action = plugin_action
        layout = QVBoxLayout(self)
        self.setLayout(layout)
        self.help_anchor = "configuration"
        
        title_layout = ImageTitleLayout(self, 'images/icon.png', 'Sony Utilities Options')
        layout.addLayout(title_layout)

#        c = plugin_prefs[STORE_NAME]
        library_config = get_library_config(self.plugin_action.gui.current_db)

        custom_column_group = QGroupBox(_('Custom Columns'), self)
        layout.addWidget(custom_column_group )
        options_layout = QGridLayout()
        custom_column_group.setLayout(options_layout)

        avail_text_columns   = self.get_text_custom_columns()
        avail_number_columns = self.get_number_custom_columns()
        avail_rating_columns = self.get_rating_custom_columns()
        avail_date_columns   = self.get_date_custom_columns()
#        debug_print("avail_rating_columns=", avail_rating_columns)
#        debug_print("default columns=", self.plugin_action.gui.library_view.model().orig_headers)
        current_Location_column  = library_config.get(KEY_CURRENT_LOCATION_CUSTOM_COLUMN, DEFAULT_LIBRARY_VALUES[KEY_CURRENT_LOCATION_CUSTOM_COLUMN])
        precent_read_column      = library_config.get(KEY_PERCENT_READ_CUSTOM_COLUMN, DEFAULT_LIBRARY_VALUES[KEY_PERCENT_READ_CUSTOM_COLUMN])
        rating_column            = library_config.get(KEY_RATING_CUSTOM_COLUMN, DEFAULT_LIBRARY_VALUES[KEY_RATING_CUSTOM_COLUMN])
        last_read_column         = library_config.get(KEY_LAST_READ_CUSTOM_COLUMN, DEFAULT_LIBRARY_VALUES[KEY_LAST_READ_CUSTOM_COLUMN])

        store_on_connect         = get_plugin_pref(COMMON_OPTIONS_STORE_NAME, KEY_STORE_ON_CONNECT)
        prompt_to_store          = get_plugin_pref(COMMON_OPTIONS_STORE_NAME, KEY_PROMPT_TO_STORE)
        store_if_more_recent     = get_plugin_pref(COMMON_OPTIONS_STORE_NAME, KEY_STORE_IF_MORE_RECENT)
        do_not_store_if_reopened = get_plugin_pref(COMMON_OPTIONS_STORE_NAME, KEY_DO_NOT_STORE_IF_REOPENED)

#         do_check_for_firmware_updates = get_plugin_pref(UPDATE_OPTIONS_STORE_NAME, KEY_DO_UPDATE_CHECK)
#         do_early_firmware_updates     = get_plugin_pref(UPDATE_OPTIONS_STORE_NAME, KEY_DO_EARLY_FIRMWARE_CHECK)
#         self.update_check_last_time   = get_plugin_pref(UPDATE_OPTIONS_STORE_NAME, KEY_LAST_FIRMWARE_CHECK_TIME)

        do_daily_backup          = get_plugin_pref(BACKUP_OPTIONS_STORE_NAME, KEY_DO_DAILY_BACKUP)
        dest_directory           = get_plugin_pref(BACKUP_OPTIONS_STORE_NAME, KEY_BACKUP_DEST_DIRECTORY)
        copies_to_keep           = get_plugin_pref(BACKUP_OPTIONS_STORE_NAME, KEY_BACKUP_COPIES_TO_KEEP)
#        debug_print("current_Location_column=%s, precent_read_column=%s, rating_column=%s" % (current_Location_column, precent_read_column, rating_column))

        current_Location_label = QLabel(_('Current Reading Location Column:'), self)
        current_Location_label.setToolTip(_("Select a custom column to store the current reading location. The column type must be 'text'. Leave this blank if you do not want to store or restore the current reading location."))
        self.current_Location_combo = CustomColumnComboBox(self, avail_text_columns, current_Location_column)
        current_Location_label.setBuddy(self.current_Location_combo)
        options_layout.addWidget(current_Location_label, 0, 0, 1, 1)
        options_layout.addWidget(self.current_Location_combo, 0, 1, 1, 1)
        
        percent_read_label = QLabel(_('Percent Read Column:'), self)
        percent_read_label.setToolTip(_("Column used to store the current percent read. The column type must be a 'integer'. Leave this blank if you do not want to store or restore the percentage read."))
        self.percent_read_combo = CustomColumnComboBox(self, avail_number_columns, precent_read_column)
        percent_read_label.setBuddy(self.percent_read_combo)
        options_layout.addWidget(percent_read_label, 2, 0, 1, 1)
        options_layout.addWidget(self.percent_read_combo, 2, 1, 1, 1)

        rating_label = QLabel(_('Rating Column:'), self)
        rating_label.setToolTip(_("Column used to store the rating. The column type must be a 'integer'. Leave this blank if you do not want to store or restore the rating."))
        self.rating_combo = CustomColumnComboBox(self, avail_rating_columns, rating_column)
        rating_label.setBuddy(self.rating_combo)
        options_layout.addWidget(rating_label, 3, 0, 1, 1)
        options_layout.addWidget(self.rating_combo, 3, 1, 1, 1)

        last_read_label = QLabel(_('Last Read Column:'), self)
        last_read_label.setToolTip(_("Column used to store when the book was last read. The column type must be a 'Date'. Leave this blank if you do not want to store the last read timestamp."))
        self.last_read_combo = CustomColumnComboBox(self, avail_date_columns, last_read_column)
        last_read_label.setBuddy(self.last_read_combo)
        options_layout.addWidget(last_read_label, 4, 0, 1, 1)
        options_layout.addWidget(self.last_read_combo, 4, 1, 1, 1)

        auto_store_group = QGroupBox(_('Store on connect'), self)
        layout.addWidget(auto_store_group )
        options_layout = QGridLayout()
        auto_store_group.setLayout(options_layout)

        self.store_on_connect_checkbox = QCheckBox(_("Store current bookmarks on connect"), self)
        self.store_on_connect_checkbox.setToolTip(_("When this is checked, the library will be updated with the current bookmark for all books on the device."))
        self.store_on_connect_checkbox.setCheckState(Qt.Checked if store_on_connect else Qt.Unchecked)
        self.store_on_connect_checkbox.clicked.connect(self.store_on_connect_checkbox_clicked)
        options_layout.addWidget(self.store_on_connect_checkbox, 0, 0, 1, 3)

        self.prompt_to_store_checkbox = QCheckBox(_("Prompt to store any changes"), self)
        self.prompt_to_store_checkbox.setToolTip(_("Enable this to be prompted to save the changed bookmarks after an automatic store is done."))
        self.prompt_to_store_checkbox.setCheckState(Qt.Checked if prompt_to_store else Qt.Unchecked)
        self.prompt_to_store_checkbox.setEnabled(store_on_connect)
        options_layout.addWidget(self.prompt_to_store_checkbox, 1, 0, 1, 1)

        self.store_if_more_recent_checkbox = QCheckBox(_("Only if more recent"), self)
        self.store_if_more_recent_checkbox.setToolTip(_("Only store the reading position if the last read timestamp on the device is more recent than in the library."))
        self.store_if_more_recent_checkbox.setCheckState(Qt.Checked if store_if_more_recent else Qt.Unchecked)
        self.store_if_more_recent_checkbox.setEnabled(store_on_connect)
        options_layout.addWidget(self.store_if_more_recent_checkbox, 1, 1, 1, 1)

        self.do_not_store_if_reopened_checkbox = QCheckBox(_("Not if finished in library"), self)
        self.do_not_store_if_reopened_checkbox.setToolTip(_("Do not store the reading position if the library has the book as finished. This is if the percent read is 100%."))
        self.do_not_store_if_reopened_checkbox.setCheckState(Qt.Checked if do_not_store_if_reopened else Qt.Unchecked)
        self.do_not_store_if_reopened_checkbox.setEnabled(store_on_connect)
        options_layout.addWidget(self.do_not_store_if_reopened_checkbox, 1, 2, 1, 1)

#         update_options_group = QGroupBox(_('Firmware Update Options'), self)
#         layout.addWidget(update_options_group)
#         options_layout = QGridLayout()
#         update_options_group.setLayout(options_layout)
# 
#         self.do_update_check = QCheckBox(_('Check for Sony firmware updates daily?'), self)
#         self.do_update_check.setToolTip(_('If this is selected the plugin will check for Sony firmware updates when your Sony device is plugged in, once per 24-hour period.'))
#         self.do_update_check.setCheckState(Qt.Checked if do_check_for_firmware_updates else Qt.Unchecked)
#         options_layout.addWidget(self.do_update_check, 0, 0, 1, 1)
# 
#         self.do_early_firmware_check = QCheckBox(_('Use early firmware adopter affiliate?'), self)
#         self.do_early_firmware_check.setToolTip(_('WARNING: THIS OPTION RISKS DOWNLOADING THE WRONG FIRMWARE FOR YOUR DEVICE! YOUR DEVICE MAY NOT FUNCTION PROPERLY IF THIS HAPPENS! Choose this option to attempt to download Sony firmware updates before they are officially available for your device.'))
#         self.do_early_firmware_check.setCheckState(Qt.Checked if do_early_firmware_updates else Qt.Unchecked)
#         options_layout.addWidget(self.do_early_firmware_check, 0, 1, 1, 1)

        backup_options_group = QGroupBox(_('Device Database Backup'), self)
        layout.addWidget(backup_options_group)
        options_layout = QGridLayout()
        backup_options_group.setLayout(options_layout)

        self.do_daily_backp_checkbox = QCheckBox(_('Backup the device database daily'), self)
        self.do_daily_backp_checkbox.setToolTip(_('If this is selected the plugin will backup the device database the first time it is connected each day.'))
        self.do_daily_backp_checkbox.setCheckState(Qt.Checked if do_daily_backup else Qt.Unchecked)
        self.do_daily_backp_checkbox.clicked.connect(self.do_daily_backp_checkbox_clicked)
        options_layout.addWidget(self.do_daily_backp_checkbox, 0, 0, 1, 3)

        self.dest_directory_label = QLabel(_("Destination:"), self)
        self.dest_directory_label.setToolTip(_("Select the destination the annotations files are to be backed up in."))
        self.dest_directory_edit = QLineEdit(self)
        self.dest_directory_edit.setMinimumSize(150, 0)
        self.dest_directory_edit.setText(dest_directory)
        self.dest_directory_label.setBuddy(self.dest_directory_edit)
        self.dest_pick_button = QPushButton(_("..."), self)
        self.dest_pick_button.setMaximumSize(24, 20)
        self.dest_pick_button.clicked.connect(self._get_dest_directory_name)
        options_layout.addWidget(self.dest_directory_label, 1, 0, 1, 1)
        options_layout.addWidget(self.dest_directory_edit, 1, 1, 1, 1)
        options_layout.addWidget(self.dest_pick_button, 1, 2, 1, 1)

        self.copies_to_keep_checkbox = QCheckBox(_('Copies to keep'), self)
        self.copies_to_keep_checkbox.setToolTip(_("Select this to limit the number of backup kept. If not set, the backup files must be manually deleted."))
        self.copies_to_keep_spin = QSpinBox(self)
        self.copies_to_keep_spin.setMinimum(2)
        self.copies_to_keep_spin.setToolTip(_("The number of backup copies of the database to keep. The minimum is 2."))
        options_layout.addWidget(self.copies_to_keep_checkbox, 1, 3, 1, 1)
        options_layout.addWidget(self.copies_to_keep_spin, 1, 4, 1, 1)
        self.copies_to_keep_checkbox.clicked.connect(self.copies_to_keep_checkbox_clicked)
        if copies_to_keep == -1:
            self.copies_to_keep_checkbox.setCheckState(not Qt.Checked)
        else:
            self.copies_to_keep_checkbox.setCheckState(Qt.Checked)
            self.copies_to_keep_spin.setProperty('value', copies_to_keep)

        self.do_daily_backp_checkbox_clicked(do_daily_backup)

        other_options_group = QGroupBox(_('Other Options'), self)
        layout.addWidget(other_options_group )
        options_layout = QGridLayout()
        other_options_group.setLayout(options_layout)

        library_default_label = QLabel(_('&Library Button default:'), self)
        library_default_label.setToolTip(_('If plugin is placed as a toolbar button, choose a default action when clicked on'))
        self.library_default_combo = KeyComboBox(self, self.plugin_action.library_actions_map, unicode(get_plugin_pref(COMMON_OPTIONS_STORE_NAME, KEY_BUTTON_ACTION_LIBRARY)))
        library_default_label.setBuddy(self.library_default_combo)
        options_layout.addWidget(library_default_label, 0, 0, 1, 1)
        options_layout.addWidget(self.library_default_combo, 0, 1, 1, 2)

        device_default_label = QLabel(_('&Device Button default:'), self)
        device_default_label.setToolTip(_('If plugin is placed as a toolbar button, choose a default action when clicked on'))
        self.device_default_combo = KeyComboBox(self, self.plugin_action.device_actions_map, unicode(get_plugin_pref(COMMON_OPTIONS_STORE_NAME, KEY_BUTTON_ACTION_DEVICE)))
        device_default_label.setBuddy(self.device_default_combo)
        options_layout.addWidget(device_default_label, 1, 0, 1, 1)
        options_layout.addWidget(self.device_default_combo, 1, 1, 1, 2)

        keyboard_shortcuts_button = QPushButton(_('Keyboard shortcuts...'), self)
        keyboard_shortcuts_button.setToolTip(_('Edit the keyboard shortcuts associated with this plugin'))
        keyboard_shortcuts_button.clicked.connect(self.edit_shortcuts)
        layout.addWidget(keyboard_shortcuts_button)
        layout.addStretch(1)
Ejemplo n.º 44
0
    def get_settings_widget(self):
        """
        Return the alignak settings QWidget

        :return: settings QWidget
        :rtype: QWidget
        """

        server_widget = QWidget()
        server_widget.setObjectName('dialog')
        server_layout = QVBoxLayout(server_widget)

        # Title
        title_lbl = QLabel(_('Alignak Backend'))
        title_lbl.setObjectName('itemtitle')
        server_layout.addWidget(title_lbl)
        server_layout.setAlignment(title_lbl, Qt.AlignTop)

        # Description
        desc_label = QLabel(
            _('Here you can define alignak settings. Be sure to enter a valid address.'
              ))
        desc_label.setWordWrap(True)
        server_layout.addWidget(desc_label)

        # Server URL
        server_lbl = QLabel(_('Server'))
        server_layout.addWidget(server_lbl)

        self.server_url.setText(settings.get_config('Alignak', 'url'))
        self.server_url.setPlaceholderText(_('alignak backend url...'))
        self.server_url.setFixedHeight(25)
        server_layout.addWidget(self.server_url)

        # Server Port
        port_lbl = QLabel(_('Port'))
        server_layout.addWidget(port_lbl)

        cur_port = settings.get_config('Alignak', 'backend').split(':')[2]
        self.server_port.setText(cur_port)
        self.server_port.setPlaceholderText(_('alignak backend port...'))
        self.server_port.setFixedHeight(25)
        server_layout.addWidget(self.server_port)

        # Server Processes (displayed only for Unix platforms)
        if 'win32' not in sys.platform:
            process_lbl = QLabel(_('Processes'))
            server_layout.addWidget(process_lbl)

            cur_proc = settings.get_config('Alignak', 'processes')
            self.server_proc.setText(cur_proc)
            self.server_proc.setPlaceholderText(
                _('alignak backend processes...'))
            self.server_proc.setFixedHeight(25)
            server_layout.addWidget(self.server_proc)

        # Web Service description
        server_layout.addStretch(1)
        webservice_lbl = QLabel(_('Web Service'))
        webservice_lbl.setObjectName('itemtitle')
        server_layout.addWidget(webservice_lbl)
        ws_desc_lbl = QLabel(
            _('Here you can define your alignak web service url, with port if needed'
              ))
        ws_desc_lbl.setWordWrap(True)
        server_layout.addWidget(ws_desc_lbl)

        # Web Service URL
        self.webservice_url.setText(
            settings.get_config('Alignak', 'webservice'))
        self.webservice_url.setPlaceholderText(_('alignak webservice url...'))
        self.webservice_url.setFixedHeight(25)
        server_layout.addWidget(self.webservice_url)

        # Valid Button
        valid_btn = QPushButton(_('Valid'))
        valid_btn.setObjectName('valid')
        valid_btn.setMinimumHeight(30)
        valid_btn.clicked.connect(self.accept)

        server_layout.addWidget(valid_btn)

        return server_widget