Beispiel #1
0
def select_profile(profiles_dict):
    title = _('Profile Selection')
    input_label = _('Select a stored profile:')
    ok_label = _('OK')
    cancel_label = _('Quit')

    input_dialog = ComboBoxInputDialog(autoaccept=True)
    input_dialog.set_window_title(title)
    input_dialog.set_label_text(input_label)
    input_dialog.set_ok_button_text(ok_label)
    input_dialog.set_cancel_button_text(cancel_label)
    input_dialog.set_items(sorted(profiles_dict.keys()) + [NEW_PROFILE_LABEL])
    _last_used_profile = last_used_profile()
    if _last_used_profile:
        input_dialog.set_choice_by_text(_last_used_profile)
    input_dialog.set_ok_button_default()

    last_index = input_dialog.count() - 1
    custom_font = QFont()
    custom_font.setItalic(True)
    icon = art.Icon('tango/16x16/actions/document-new.png').getQIcon()
    input_dialog.set_data(last_index, custom_font, Qt.FontRole)
    input_dialog.set_data(last_index, icon, Qt.DecorationRole)

    dialog_code = input_dialog.exec_()
    if dialog_code == QDialog.Accepted:
        return unicode(input_dialog.get_text())

    return None
Beispiel #2
0
    def __init__(self, profiles, parent=None):
        super(ProfileWizard, self).__init__(parent)

        self._connection_valid = False
        self.network_reply = None
        self.profiles = profiles

        self.setWindowTitle(_('Profile Wizard'))
        self.set_banner_logo_pixmap(
            art.Icon(
                'tango/22x22/categories/preferences-system.png').getQPixmap())
        self.set_banner_title(_('Create New/Edit Profile'))
        self.set_banner_subtitle(_('Please enter the database settings'))
        self.banner_widget().setStyleSheet('background-color: white;')

        self.manager = QtNetwork.QNetworkAccessManager(self)
        self.manager.finished.connect(self.update_network_status)
        #self.manager.networkAccessibleChanged.connect( self.network_accessible_changed )
        self.manager.proxyAuthenticationRequired.connect(
            self.proxy_authentication_required)

        self.create_labels_and_widgets()
        self.create_buttons()
        self.set_tab_order()
        self.set_widgets_values()
        # note: connections come after labels and widgets are created
        # and have default values
        self.connect_widgets()
        self.connect_buttons()

        timer = QtCore.QTimer(self)
        timer.timeout.connect(self.new_network_request)
        timer.setInterval(3000)
        timer.start()
        self.new_network_request()
Beispiel #3
0
    def __init__(self, parent=None):
        super(ProfileSelection, self).__init__(parent)

        self._connection_valid = False

        self.profiles = fetch_profiles()
        logger.debug('original profiles fetched:\n%s' % self.profiles)
        self.profiles_choices = set()
        for profile in self.profiles:
            if 'profilename' in profile and profile['profilename']:
                self.profiles_choices.add(
                    (profile['profilename'], profile['profilename']))
        logger.debug('original profiles choices:\n%s' % self.profiles_choices)

        self.setWindowTitle(_('Profile Selection'))
        self.set_banner_logo_pixmap(
            art.Icon(
                'tango/22x22/categories/preferences-system.png').getQPixmap())
        self.set_banner_title(_('Database Settings'))
        self.set_banner_subtitle(_('Connect with an existing profile'))
        self.banner_widget().setStyleSheet('background-color: white;')

        self.create_labels_and_widgets()
        self.set_widgets_values()
        self.connect_widgets()

        self.create_buttons()
        self.connect_buttons()
Beispiel #4
0
    def create_buttons(self):
        self.cancel_button = QPushButton(_('Cancel'))
        #self.clear_button = QPushButton(_('Clear'))
        self.ok_button = QPushButton(_('OK'))
        self.new_button = QPushButton(
            art.Icon('tango/16x16/actions/list-add.png').getQIcon(), '')
        self.new_button.setToolTip(_('Add a new profile name'))

        layout = QHBoxLayout()
        layout.setDirection(QBoxLayout.RightToLeft)

        layout.addWidget(self.cancel_button)
        #layout.addWidget(self.clear_button)
        layout.addWidget(self.ok_button)
        layout.addStretch()

        self.main_widget().layout().addWidget(self.new_button, 0, 5, 1, 1)
        self.buttons_widget().setLayout(layout)