def __init__(self, parent=None): super(WaitForServiceProvider, self).__init__(parent) self.setFrameStyle(QFrame.Panel | QFrame.Raised) # Global horizontal layout vbox = QVBoxLayout() vbox.setContentsMargins(0, 0, 0, 0) self.image = QLabel() self.image.setAlignment(Qt.AlignCenter) def get_res(f): return resource_filename("clacks.client", "data/%s" % f) self.pixmaps = [QPixmap(get_res("network-wireless-connected-00.png")), QPixmap(get_res("network-wireless-connected-25.png")), QPixmap(get_res("network-wireless-connected-50.png")), QPixmap(get_res("network-wireless-connected-75.png")), QPixmap(get_res("network-wireless.png"))] self.pixmap_index = -1 self.rotate_image() vbox.addWidget(self.image) label = QLabel(_("Searching service provider...")) self.setStyleSheet("QWidget { background-color: #F0F0F0; color: black; padding: 5;}") label.setAlignment(Qt.AlignCenter) vbox.addWidget(label) # Finalize the window self.setLayout(vbox) self.setMinimumSize(300, 150) self.setWindowTitle(_("Searching for service provider")) # Disable close self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.CustomizeWindowHint) self.setGeometry((QApplication.desktop().width() - 300) / 2, (QApplication.desktop().height() - self.sizeHint().height()) / 2, 300, self.sizeHint().height()) # Start animation timer = QTimer(self) self.connect(timer, SIGNAL("timeout()"), self.rotate_image) timer.start(500)
def __init__(self, parent=None): super(MainWindow, self).__init__(parent) # Global form layout form = QFormLayout() form.setContentsMargins(0, 0, 0, 0) # Header box containing label and icon hbox = QHBoxLayout() hbox.setSpacing(0) hbox.setContentsMargins(0, 0, 0, 0) header = QFrame() header.setFrameStyle(QFrame.Panel | QFrame.Sunken) header.setStyleSheet("QWidget { background-color: white; color: black;}") header_text = QLabel("<b>" + _("Clacks Infrastructure") + "</b><br>" + "v%s" % VERSION) header_text.setStyleSheet("QWidget { background-color: white; color: black; border: 0; margin: 0; padding: 3;}") header_text.setAlignment(Qt.AlignLeft | Qt.AlignTop) hbox.addWidget(header_text, 1) header_image = QLabel() header_image.setStyleSheet("QWidget { background-color: white; color: black; border: 0; margin: 0; padding: 0;}") header_image.setAlignment(Qt.AlignRight | Qt.AlignTop) bg = QPixmap(resource_filename("clacks.client", "data/secure-card.png")) header_image.setPixmap(bg) hbox.addWidget(header_image) header.setLayout(hbox) form.addRow(header) # Dialog headline headline = QLabel(_("Please enter the credentials of an administrative user to join this client.")) headline.setWordWrap(True) headline.setStyleSheet("QLabel { padding: 3; }") form.addRow(headline) # Separator line = QFrame() line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) form.addRow(line) # Input fields for user and password ll = QGridLayout() userLabel = QLabel("User name") self.userEdit = QLineEdit(self) passwordLabel = QLabel("Password") self.passwordEdit = QLineEdit(self) self.passwordEdit.setEchoMode(QLineEdit.Password) # Add focus key handler for line edits kpe = FocusNextOnReturn(self) self.userEdit.installEventFilter(kpe) aor = AcceptOnReturn(self) self.passwordEdit.installEventFilter(aor) # Place widgets in layout ll.addWidget(userLabel, 0, 0) ll.addWidget(self.userEdit, 0, 1) ll.addWidget(passwordLabel, 1, 0) ll.addWidget(self.passwordEdit, 1, 1) ll.setContentsMargins(3, 3, 3, 3) form.addRow(ll) # Separator line2 = QFrame() line2.setFrameShape(QFrame.HLine) line2.setFrameShadow(QFrame.Sunken) form.addRow(line2) # OK button buttonBox = QDialogButtonBox(QDialogButtonBox.Ok) form.addRow(buttonBox) buttonBox.accepted.connect(self.accept) # Finalize the window self.setLayout(form) self.setMinimumSize(400, 150) self.setWindowTitle('Join client') self.setGeometry((QApplication.desktop().width() - self.sizeHint().width()) / 2, (QApplication.desktop().height() - self.sizeHint().height()) / 2, self.sizeHint().width(), self.sizeHint().height()) # Disable close self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.CustomizeWindowHint | Qt.Window | Qt.WindowTitleHint)