|
103 | 103 | from .balance_dialog import BalanceToolButton, COLOR_FROZEN, COLOR_UNMATURED, COLOR_UNCONFIRMED, COLOR_CONFIRMED, COLOR_LIGHTNING, COLOR_FROZEN_LIGHTNING
|
104 | 104 |
|
105 | 105 | if TYPE_CHECKING:
|
| 106 | + from electrum.simple_config import ConfigVarWithConfig |
106 | 107 | from . import ElectrumGui
|
107 | 108 |
|
108 | 109 |
|
@@ -173,8 +174,8 @@ def __init__(self, gui_object: 'ElectrumGui', wallet: Abstract_Wallet):
|
173 | 174 | self.gui_thread = gui_object.gui_thread
|
174 | 175 | assert wallet, "no wallet"
|
175 | 176 | self.wallet = wallet
|
176 |
| - if wallet.has_lightning(): |
177 |
| - self.wallet.config.set_key('show_channels_tab', True) |
| 177 | + if wallet.has_lightning() and not self.config.cv.GUI_QT_SHOW_TAB_CHANNELS.is_set(): |
| 178 | + self.config.GUI_QT_SHOW_TAB_CHANNELS = True # override default, but still allow disabling tab manually |
178 | 179 |
|
179 | 180 | Exception_Hook.maybe_setup(config=self.config, wallet=self.wallet)
|
180 | 181 |
|
@@ -216,19 +217,18 @@ def __init__(self, gui_object: 'ElectrumGui', wallet: Abstract_Wallet):
|
216 | 217 | tabs.addTab(self.send_tab, read_QIcon("tab_send.png"), _('Send'))
|
217 | 218 | tabs.addTab(self.receive_tab, read_QIcon("tab_receive.png"), _('Receive'))
|
218 | 219 |
|
219 |
| - def add_optional_tab(tabs, tab, icon, description, name): |
| 220 | + def add_optional_tab(tabs, tab, icon, description): |
220 | 221 | tab.tab_icon = icon
|
221 | 222 | tab.tab_description = description
|
222 | 223 | tab.tab_pos = len(tabs)
|
223 |
| - tab.tab_name = name |
224 |
| - if self.config.get('show_{}_tab'.format(name), False): |
| 224 | + if tab.is_shown_cv.get(): |
225 | 225 | tabs.addTab(tab, icon, description.replace("&", ""))
|
226 | 226 |
|
227 |
| - add_optional_tab(tabs, self.addresses_tab, read_QIcon("tab_addresses.png"), _("&Addresses"), "addresses") |
228 |
| - add_optional_tab(tabs, self.channels_tab, read_QIcon("lightning.png"), _("Channels"), "channels") |
229 |
| - add_optional_tab(tabs, self.utxo_tab, read_QIcon("tab_coins.png"), _("Co&ins"), "utxo") |
230 |
| - add_optional_tab(tabs, self.contacts_tab, read_QIcon("tab_contacts.png"), _("Con&tacts"), "contacts") |
231 |
| - add_optional_tab(tabs, self.console_tab, read_QIcon("tab_console.png"), _("Con&sole"), "console") |
| 227 | + add_optional_tab(tabs, self.addresses_tab, read_QIcon("tab_addresses.png"), _("&Addresses")) |
| 228 | + add_optional_tab(tabs, self.channels_tab, read_QIcon("lightning.png"), _("Channels")) |
| 229 | + add_optional_tab(tabs, self.utxo_tab, read_QIcon("tab_coins.png"), _("Co&ins")) |
| 230 | + add_optional_tab(tabs, self.contacts_tab, read_QIcon("tab_contacts.png"), _("Con&tacts")) |
| 231 | + add_optional_tab(tabs, self.console_tab, read_QIcon("tab_console.png"), _("Con&sole")) |
232 | 232 |
|
233 | 233 | tabs.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
234 | 234 |
|
@@ -339,8 +339,8 @@ def on_fx_quotes(self):
|
339 | 339 | self.address_list.refresh_all()
|
340 | 340 |
|
341 | 341 | def toggle_tab(self, tab):
|
342 |
| - show = not self.config.get('show_{}_tab'.format(tab.tab_name), False) |
343 |
| - self.config.set_key('show_{}_tab'.format(tab.tab_name), show) |
| 342 | + show = not tab.is_shown_cv.get() |
| 343 | + tab.is_shown_cv.set(show) |
344 | 344 | if show:
|
345 | 345 | # Find out where to place the tab
|
346 | 346 | index = len(self.tabs)
|
@@ -698,7 +698,7 @@ def init_menubar(self):
|
698 | 698 | wallet_menu.addAction(_("Find"), self.toggle_search).setShortcut(QKeySequence("Ctrl+F"))
|
699 | 699 |
|
700 | 700 | def add_toggle_action(view_menu, tab):
|
701 |
| - is_shown = self.config.get('show_{}_tab'.format(tab.tab_name), False) |
| 701 | + is_shown = tab.is_shown_cv.get() |
702 | 702 | tab.menu_action = view_menu.addAction(tab.tab_description, lambda: self.toggle_tab(tab))
|
703 | 703 | tab.menu_action.setCheckable(True)
|
704 | 704 | tab.menu_action.setChecked(is_shown)
|
@@ -1026,7 +1026,9 @@ def refresh_tabs(self, wallet=None):
|
1026 | 1026 |
|
1027 | 1027 | def create_channels_tab(self):
|
1028 | 1028 | self.channels_list = ChannelsList(self)
|
1029 |
| - return self.create_list_tab(self.channels_list) |
| 1029 | + tab = self.create_list_tab(self.channels_list) |
| 1030 | + tab.is_shown_cv = self.config.cv.GUI_QT_SHOW_TAB_CHANNELS |
| 1031 | + return tab |
1030 | 1032 |
|
1031 | 1033 | def create_history_tab(self):
|
1032 | 1034 | self.history_model = HistoryModel(self)
|
@@ -1351,17 +1353,22 @@ def create_addresses_tab(self):
|
1351 | 1353 | from .address_list import AddressList
|
1352 | 1354 | self.address_list = AddressList(self)
|
1353 | 1355 | tab = self.create_list_tab(self.address_list)
|
| 1356 | + tab.is_shown_cv = self.config.cv.GUI_QT_SHOW_TAB_ADDRESSES |
1354 | 1357 | return tab
|
1355 | 1358 |
|
1356 | 1359 | def create_utxo_tab(self):
|
1357 | 1360 | from .utxo_list import UTXOList
|
1358 | 1361 | self.utxo_list = UTXOList(self)
|
1359 |
| - return self.create_list_tab(self.utxo_list) |
| 1362 | + tab = self.create_list_tab(self.utxo_list) |
| 1363 | + tab.is_shown_cv = self.config.cv.GUI_QT_SHOW_TAB_UTXO |
| 1364 | + return tab |
1360 | 1365 |
|
1361 | 1366 | def create_contacts_tab(self):
|
1362 | 1367 | from .contact_list import ContactList
|
1363 | 1368 | self.contact_list = l = ContactList(self)
|
1364 |
| - return self.create_list_tab(l) |
| 1369 | + tab = self.create_list_tab(l) |
| 1370 | + tab.is_shown_cv = self.config.cv.GUI_QT_SHOW_TAB_CONTACTS |
| 1371 | + return tab |
1365 | 1372 |
|
1366 | 1373 | def remove_address(self, addr):
|
1367 | 1374 | if not self.question(_("Do you want to remove {} from your wallet?").format(addr)):
|
@@ -1489,6 +1496,7 @@ def show_lightning_invoice(self, invoice: Invoice):
|
1489 | 1496 | def create_console_tab(self):
|
1490 | 1497 | from .console import Console
|
1491 | 1498 | self.console = console = Console()
|
| 1499 | + console.is_shown_cv = self.config.cv.GUI_QT_SHOW_TAB_CONSOLE |
1492 | 1500 | return console
|
1493 | 1501 |
|
1494 | 1502 | def update_console(self):
|
|
0 commit comments