def on_lang(x): lang_request = languages.keys()[lang_combo.currentIndex()] if lang_request != self.config.get_above_chain('language'): self.config.set_key_above_chain("language", lang_request, True) self.gui.need_restart = True
def create_global_options(self): rows = [] # Language # lang_label = QLabel(_('Language') + ':') lang_help = HelpButton(_('Select which language is used in the GUI (after restart).')) lang_combo = QComboBox() from chainkey.i18n import languages lang_combo.addItems(languages.values()) try: index = languages.keys().index(self.config.get_above_chain("language",'')) except Exception: index = 0 lang_combo.setCurrentIndex(index) if not self.config.is_modifiable('language'): for w in [lang_combo, lang_label]: w.setEnabled(False) def on_lang(x): lang_request = languages.keys()[lang_combo.currentIndex()] if lang_request != self.config.get_above_chain('language'): self.config.set_key_above_chain("language", lang_request, True) self.gui.need_restart = True lang_combo.currentIndexChanged.connect(on_lang) rows.append(SettingsRow(self,'combobox', (lang_label, lang_combo, lang_help))) # Theme # current_theme = self.actuator.selected_theme() theme_label = QLabel(_('Theme:')) theme_value = QLabel(_(current_theme)) theme_button = QPushButton(_('Change Theme')) theme_help = HelpButton(_('Themes change how Encompass looks.')) def on_theme_button(): style.ThemeDialog(self).exec_() current_theme = self.actuator.selected_theme() theme_value.setText(_(current_theme)) theme_button.clicked.connect(on_theme_button) rows.append(SettingsRow(self,'full', (theme_label, theme_value, theme_button, theme_help))) # Favorite chains # fav_chains_list = map(lambda x: x.encode('ascii', 'ignore'), self.config.get_above_chain('favorite_chains', [])) # Maximum of three favorite chains if len(fav_chains_list) > 3: fav_chains_list = fav_chains_list[:3] self.config.set_key_above_chain('favorite_chains', fav_chains_list) # Replace an empty list with the string 'None' if not fav_chains_list: fav_chains_list = 'None' fav_chains_list = str(fav_chains_list).replace("'", "") favs_label = QLabel(_( 'Favorite coins:')) favs_value = QLabel(fav_chains_list) favs_button = QPushButton(_('Change Favorites')) favs_help = HelpButton(_('Favorite coins are in the status bar\'s coin menu, and appear before others in the currency selection window.')) def do_fav(): FavoriteCurrenciesDialog(self).exec_() fav_chains_list = map(lambda x: x.encode('ascii', 'ignore'), self.config.get_above_chain('favorite_chains', [])) if not fav_chains_list: fav_chains_list = 'None' fav_chains_list = str(fav_chains_list).replace("'", "") favs_value.setText(fav_chains_list) # update the coin menu self.gui.update_status() favs_button.clicked.connect(do_fav) rows.append(SettingsRow(self,'full', (favs_label, favs_value, favs_button, favs_help))) # Hidden Chains # hidden_chains_list = self.config.get_above_chain('hide_chains', []) hidden_chains_number = len(hidden_chains_list) hiddens_label = QLabel(_('Hidden coins:')) hiddens_value = QLabel(str(hidden_chains_number)) hiddens_button = QPushButton(_('Change Hidden Coins')) hiddens_help = HelpButton(_('Hidden coins do not appear in the currency selection window.')) def do_hiddens(): HideCurrenciesDialog(self).exec_() hidden_chains_list = self.config.get_above_chain('hide_chains', []) hiddens_value.setText(str( len(hidden_chains_list) )) hiddens_button.clicked.connect(do_hiddens) rows.append(SettingsRow(self,'full', (hiddens_label, hiddens_value, hiddens_button, hiddens_help))) # QR Device # from chainkey import qrscanner system_cameras = qrscanner._find_system_cameras() qr_combo = QComboBox() qr_combo.addItem("Default","default") for camera, device in system_cameras.items(): qr_combo.addItem(camera, device) #combo.addItem("Manually specify a device", config.get("video_device")) index = qr_combo.findData(self.config.get_above_chain("video_device")) qr_combo.setCurrentIndex(index) qr_label = QLabel(_('Video Device') + ':') qr_combo.setEnabled(qrscanner.zbar is not None) qr_help = HelpButton(_("Install the zbar package to enable this.\nOn linux, type: 'apt-get install python-zbar'")) on_video_device = lambda x: self.config.set_key_above_chain("video_device", str(qr_combo.itemData(x).toString()), True) qr_combo.currentIndexChanged.connect(on_video_device) rows.append(SettingsRow(self,'combobox', (qr_label, qr_combo, qr_help))) # Currency Dialog Verbosity # verbose_currency_dialog = QCheckBox(_('Show verbose info in Change Currency window')) verbose_currency_dialog.setChecked(self.config.get_above_chain('verbose_currency_dialog', False)) verbose_currency_dialog.stateChanged.connect(lambda x: self.config.set_key_above_chain('verbose_currency_dialog', verbose_currency_dialog.isChecked())) verbose_currency_dialog_help = HelpButton(_('Show verbose information about currencies, such as the number of default servers.')) rows.append(SettingsRow(self,'toggle', (verbose_currency_dialog, verbose_currency_dialog_help))) # Open Default Wallet on Launch # use_def_wallet_cb = QCheckBox(_('Open default_wallet on wallet start')) use_def_wallet_cb.setChecked(self.config.get_above_chain('use_default_wallet', True)) use_def_wallet_cb.stateChanged.connect(lambda x: self.config.set_key_above_chain('use_default_wallet', use_def_wallet_cb.isChecked())) use_def_wallet_help = HelpButton(_('Open default_wallet when Encompass starts. Otherwise, open the last wallet that was open.')) rows.append(SettingsRow(self,'toggle', (use_def_wallet_cb, use_def_wallet_help))) return rows