예제 #1
0
 def __init__(self, sync_manager, network_access_manager, url=None, username=None, password=None, certificate=""):
     self.sync_manager = sync_manager
     self.nam = network_access_manager
     self.certificate = certificate
     self.replies = set()
     super(SettingsWindow, self).__init__()
     self.setWindowIcon(QIcon(os.path.join('icons', 'Logo_sync.png')))
     self.setGeometry(70, 60, 300, 250)
     self.setWindowTitle("c't SESAM Sync Settings")
     layout = QBoxLayout(QBoxLayout.TopToBottom)
     layout.setContentsMargins(0, 0, 0, 0)
     # Header bar
     header_bar = QFrame()
     header_bar.setStyleSheet("QWidget { background: rgb(40, 40, 40); } " +
                              "QToolButton { background: rgb(40, 40, 40); }" +
                              "QToolTip { color: rgb(255, 255, 255); background-color: rgb(20, 20, 20); " +
                              "border: 1px solid white; }")
     header_bar.setAutoFillBackground(True)
     header_bar.setFixedHeight(45)
     header_bar_layout = QBoxLayout(QBoxLayout.RightToLeft)
     header_bar_layout.addStretch()
     header_bar.setLayout(header_bar_layout)
     layout.addWidget(header_bar)
     self.create_header_bar(header_bar_layout)
     self.certificate_loaded.connect(self.test_connection)
     # Main area
     main_area = QFrame()
     main_layout = QBoxLayout(QBoxLayout.TopToBottom)
     main_area.setLayout(main_layout)
     layout.addWidget(main_area)
     self.create_main_area(main_layout, url, username, password)
     # Show the window
     layout.addStretch()
     self.setLayout(layout)
     self.show()
    def _init_widgets(self):

        state = self._state

        if state is None:
            return

        if state.arch.name not in self.ARCH_REGISTERS:
            l.error(
                "Architecture %s is not listed in QRegisterViewer.ARCH_REGISTERS.",
                state.arch.name)
            return

        layout = QVBoxLayout()
        area = QScrollArea()
        area.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        area.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        area.setWidgetResizable(True)

        regs = self.ARCH_REGISTERS[state.arch.name]

        # common ones
        common_regs = regs['common']

        for reg_name in common_regs:
            sublayout = QHBoxLayout()

            lbl_reg_name = QLabel(self)
            lbl_reg_name.setProperty('class', 'reg_viewer_label')
            lbl_reg_name.setText(reg_name)
            lbl_reg_name.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
            sublayout.addWidget(lbl_reg_name)

            sublayout.addSpacing(10)
            reg_value = QASTViewer(None, parent=self)
            self._registers[reg_name] = reg_value
            sublayout.addWidget(reg_value)

            layout.addLayout(sublayout)

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

        # the container
        container = QFrame()
        container.setAutoFillBackground(True)
        palette = container.palette()
        palette.setColor(container.backgroundRole(), Qt.white)
        container.setPalette(palette)
        container.setLayout(layout)

        area.setWidget(container)

        base_layout = QVBoxLayout()
        base_layout.addWidget(area)
        self.setLayout(base_layout)
예제 #3
0
 def __init__(self):
     super(MainWindow, self).__init__()
     self.nam = QNetworkAccessManager()
     self.setWindowIcon(QIcon(os.path.join('icons', 'Logo_rendered_edited.png')))
     layout = QBoxLayout(QBoxLayout.TopToBottom)
     layout.setContentsMargins(0, 0, 0, 0)
     self.preference_manager = PreferenceManager()
     self.kgk_manager = KgkManager()
     self.kgk_manager.set_preference_manager(self.preference_manager)
     self.settings_manager = PasswordSettingsManager(self.preference_manager)
     self.setting_dirty = True
     # Header bar
     header_bar = QFrame()
     header_bar.setStyleSheet(
         "QWidget { background: rgb(40, 40, 40); } " +
         "QToolButton { background: rgb(40, 40, 40); }" +
         "QToolTip { color: rgb(255, 255, 255); background-color: rgb(20, 20, 20); " +
         "border: 1px solid white; }")
     header_bar.setAutoFillBackground(True)
     header_bar.setFixedHeight(45)
     header_bar_layout = QBoxLayout(QBoxLayout.LeftToRight)
     header_bar_layout.addStretch()
     header_bar.setLayout(header_bar_layout)
     layout.addWidget(header_bar)
     self.create_header_bar(header_bar_layout)
     # Widget area
     main_area = QFrame()
     main_layout = QBoxLayout(QBoxLayout.TopToBottom)
     main_area.setLayout(main_layout)
     layout.addWidget(main_area)
     self.create_main_area(main_layout)
     # Window layout
     layout.addStretch()
     main_layout.addStretch()
     self.setLayout(layout)
     settings = QSettings()
     size = settings.value("MainWindow/size")
     if not size:
         size = QSize(350, 450)
     self.resize(size)
     position = settings.value("MainWindow/pos")
     if not position:
         position = QPoint(0, 24)
     self.move(position)
     self.setWindowTitle("c't SESAM")
     self.master_password_edit.setFocus()
     self.show()
    def _load_tmps(self):

        state = self._state

        layout = QVBoxLayout()

        self._tmps.clear()
        if state is None:
            tmps = {}
        else:
            tmps = state.scratch.temps

        # tmps
        for tmp_id, tmp_value in tmps.iteritems():
            sublayout = QHBoxLayout()

            lbl_tmp_name = QLabel(self)
            lbl_tmp_name.setProperty('class', 'reg_viewer_label')
            lbl_tmp_name.setText("tmp_%d" % tmp_id)
            lbl_tmp_name.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
            sublayout.addWidget(lbl_tmp_name)

            sublayout.addSpacing(10)

            tmp_viewer = QASTViewer(tmp_value, parent=self)
            self._tmps[tmp_id] = tmp_viewer
            sublayout.addWidget(tmp_viewer)

            layout.addLayout(sublayout)

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

        # the container
        container = QFrame()
        container.setAutoFillBackground(True)
        palette = container.palette()
        palette.setColor(container.backgroundRole(), Qt.white)
        container.setPalette(palette)
        container.setLayout(layout)

        self._area.setWidget(container)
예제 #5
0
 def __init__(self,
              sync_manager,
              network_access_manager,
              url=None,
              username=None,
              password=None,
              certificate=""):
     self.sync_manager = sync_manager
     self.nam = network_access_manager
     self.certificate = certificate
     self.replies = set()
     super(SettingsWindow, self).__init__()
     self.setWindowIcon(QIcon(os.path.join('icons', 'Logo_sync.png')))
     self.setGeometry(70, 60, 300, 250)
     self.setWindowTitle("c't SESAM Sync Settings")
     layout = QBoxLayout(QBoxLayout.TopToBottom)
     layout.setContentsMargins(0, 0, 0, 0)
     # Header bar
     header_bar = QFrame()
     header_bar.setStyleSheet(
         "QWidget { background: rgb(40, 40, 40); } " +
         "QToolButton { background: rgb(40, 40, 40); }" +
         "QToolTip { color: rgb(255, 255, 255); background-color: rgb(20, 20, 20); "
         + "border: 1px solid white; }")
     header_bar.setAutoFillBackground(True)
     header_bar.setFixedHeight(45)
     header_bar_layout = QBoxLayout(QBoxLayout.RightToLeft)
     header_bar_layout.addStretch()
     header_bar.setLayout(header_bar_layout)
     layout.addWidget(header_bar)
     self.create_header_bar(header_bar_layout)
     self.certificate_loaded.connect(self.test_connection)
     # Main area
     main_area = QFrame()
     main_layout = QBoxLayout(QBoxLayout.TopToBottom)
     main_area.setLayout(main_layout)
     layout.addWidget(main_area)
     self.create_main_area(main_layout, url, username, password)
     # Show the window
     layout.addStretch()
     self.setLayout(layout)
     self.show()
예제 #6
0
class CommentsWidget(QWidget):
    def _append_comment(self, comment):
        l = QLabel(comment.text)
        l.setWordWrap(True)
        l.setStyleSheet("background-color: #ffffff;")
        # l.setTextInteractionFlags(Qt.TextSelectableByMouse | Qt.TextSelectableByKeyboard | Qt.LinksAccessibleByMouse | Qt.LinksAccessibleByKeyboard)

        self._comments_layout.addWidget(l)

        l = QLabel("Chuck Norris, 14/4/2016")
        l.setStyleSheet("color: #808080;")
        self._comments_layout.addWidget(l)
        self._comments_layout.setAlignment(l, Qt.AlignRight)
        self.comments_list_widget.setVisible(True)

    def show_comments(self, comments):

        self._comments = comments or []

        while self._comments_layout.count() > 0:
            self._comments_layout.removeItem(0)

        for comment in comments:
            self._append_comment(comment)

        self.comments_list_widget.setVisible(len(self._comments) > 0)

    @Slot()
    def submit_comment(self):
        comment = self.text_edit.toPlainText().strip()

        if comment:

            c = self._change_tracker.make_change_tracking_dto(Comment)
            c.text = comment
            self._append_comment(c)
            self.text_edit.setText("")

    def __init__(self, parent, change_tracker: ChangeTracker):
        super(CommentsWidget, self).__init__(parent)

        self._change_tracker = change_tracker
        #self.setObjectName("zwhite")
        layout = QVBoxLayout()

        self.comments_list_widget = QFrame(
            self
        )  # If you use QWidget, the background won't be set; don't know why :-(
        self.comments_list_widget.setStyleSheet("background: white;")
        self.comments_list_widget.setAutoFillBackground(True)
        #self.comments_list_widget.setObjectName("zwhite")

        self._comments_layout = QVBoxLayout()
        self.comments_list_widget.setLayout(self._comments_layout)

        self.comments_list_widget.hide()

        self.text_edit = QTextEdit(self)
        self.submit_button = QPushButton(("Add"), self)

        layout.addWidget(self.comments_list_widget)
        layout.addWidget(self.text_edit)
        hlayout = QHBoxLayout()

        hlayout.addStretch()
        hlayout.addWidget(self.submit_button)
        layout.addLayout(hlayout)
        self.setLayout(layout)

        self.submit_button.clicked.connect(self.submit_comment)