Commit Graph

38 Commits

Author SHA1 Message Date
SomberNight
24980feab7 config: introduce ConfigVars
A new config API is introduced, and ~all of the codebase is adapted to it.
The old API is kept but mainly only for dynamic usage where its extra flexibility is needed.

Using examples, the old config API looked this:
```
>>> config.get("request_expiry", 86400)
604800
>>> config.set_key("request_expiry", 86400)
>>>
```

The new config API instead:
```
>>> config.WALLET_PAYREQ_EXPIRY_SECONDS
604800
>>> config.WALLET_PAYREQ_EXPIRY_SECONDS = 86400
>>>
```

The old API operated on arbitrary string keys, the new one uses
a static ~enum-like list of variables.

With the new API:
- there is a single centralised list of config variables, as opposed to
  these being scattered all over
- no more duplication of default values (in the getters)
- there is now some (minimal for now) type-validation/conversion for
  the config values

closes https://github.com/spesmilo/electrum/pull/5640
closes https://github.com/spesmilo/electrum/pull/5649

Note: there is yet a third API added here, for certain niche/abstract use-cases,
where we need a reference to the config variable itself.
It should only be used when needed:
```
>>> var = config.cv.WALLET_PAYREQ_EXPIRY_SECONDS
>>> var
<ConfigVarWithConfig key='request_expiry'>
>>> var.get()
604800
>>> var.set(3600)
>>> var.get_default_value()
86400
>>> var.is_set()
True
>>> var.is_modifiable()
True
```
2023-05-25 17:39:48 +00:00
SomberNight
4a626a113d qt receive_tab: fix "show_address_on_hw" functionality
follow-up b07fe970bf

I don't like this being hidden in the toolbar menu.
The other items in the toolbar menu are ~settings or generic actions
independent of the current request. This one is dependent on the
current request, and even the active "tab"... does not make sense
to show this when the lightning tab is active.
It is more difficult to discover it in the first place than previously,
and it being less visible goes against encouraging hw device users of
using it, which is what we should be doing.

Anyway, this commit just makes it functional as-is.
2023-03-31 01:14:08 +00:00
ThomasV
31bff4d2a8 receive_tab: initialize fields 2023-03-29 11:10:00 +02:00
SomberNight
ed0f1ea27f qt receive_tab: use correct qrcode icon (based on dark/light theme) 2023-03-21 15:31:07 +00:00
ThomasV
1503ef1e2a follow-up previous commit 2023-03-21 10:42:21 +01:00
ThomasV
a080e5130f Qt receive_tab: toggle_view_button instead of tabs 2023-03-21 10:34:26 +01:00
ThomasV
5cf4b346a9 change message: detached QR code window 2023-03-19 11:40:52 +01:00
ThomasV
8b0a6940bc receive tab: disable widgets if request has expired, instead of applying red stylesheet 2023-03-19 11:13:45 +01:00
ThomasV
b07fe970bf receive tab: do not use ButtonsTextEdit, add toggle to toolbar. 2023-03-19 10:15:19 +01:00
ThomasV
8cc610298b QML: auto-delete expired requests. Add action to Qt menu 2023-03-18 09:59:18 +01:00
ThomasV
abc8d1550e Expiry: the setting is a period, not a date 2023-03-15 12:35:58 +01:00
ThomasV
5750c8954d receive tab: move back Expiry to its previous location, but use
dialog instead of ComboBox.

The toolbar location is not good, because it can be perceived as
being about the request currently displayed.
2023-03-15 12:28:26 +01:00
ThomasV
42a63643f3 receive tab: move expiry to toolbar 2023-03-15 12:20:22 +01:00
ThomasV
b690f2e5cd qr_window: keep menu in sync with actual visibility 2023-03-13 14:23:36 +01:00
ThomasV
37a0e125c6 move config settings that are related to invoice creation to receive tab. 2023-03-12 10:42:26 +01:00
ThomasV
473c86c395 toolbar: use custom MyMenu class with addToggle 2023-03-12 10:11:08 +01:00
ThomasV
5ad4023e7d restore invoices_label and requests_label. move paytomany and toggle_qr_window from main menu to toolbar 2023-03-11 18:08:00 +01:00
ThomasV
1a0a52f9b6 invoices and requests lists: move import/export menus into local toolbars 2023-03-11 15:15:16 +01:00
ThomasV
719b468eee Refresh bolt11 routing hints when channel liquidity changes:
- wallet_db update: separate Invoices and Requests.
 - do not store bolt11 invoice in Request
2023-02-28 15:33:17 +01:00
ThomasV
292ce35945 receive tab: copy to clipboard when tab is changed 2023-02-13 11:20:10 +01:00
SomberNight
95a8df69b4 qt wizard: (fix) during 2fa wallet creation, shared QR to be drawn
This was a regression from 2a31f80d09,
before which, when using the default `QRCodeWidget()` constructor,
there had been a min size set on the widget. I like that old behaviour:
reasonable size should be set by default, and if you want to set the
size manually, opt-in to that.

fixes https://github.com/spesmilo/electrum/issues/8071
2022-11-17 03:58:32 +00:00
SomberNight
d37b5e7d75 Qt ReceiveTabWidget: change cursor to hint QR code can be clicked 2022-08-29 13:30:59 +00:00
ThomasV
6a9e8da218 remove sign_payment_request: broken and not used 2022-08-29 12:50:02 +02:00
SomberNight
c95791d7ee qt/kivy: receive tab: add wallet.ReceiveRequestHelp and refactor 2022-08-12 10:06:13 +02:00
SomberNight
bd7a6a8f77 qt/kivy receive tab: show error msg when creating req with amt<dust 2022-08-11 14:55:34 +00:00
SomberNight
7d481935e2 qt ReceiveTab: handle case with URI=="" 2022-08-11 13:11:54 +00:00
SomberNight
659d6890d9 wallet.get_request_URI: rm code duplication 2022-08-11 13:07:56 +00:00
SomberNight
7daeccdf85 qt ReceiveTab: ensure TabWidget has frame in more cases 2022-08-11 12:43:17 +00:00
SomberNight
d4f76143b0 qt ReceiveTabWidget: revert prev, and add frame in a different way
This reverts commit b97d080617.
2022-08-03 22:16:24 +02:00
SomberNight
b97d080617 qt ReceiveTabWidget: add frame to "help label", and rm some nesting 2022-08-03 19:39:28 +02:00
ThomasV
0c8a828704 follow-up 7dcd8d8dc8
- set minimumHeight of VTabWidget (needed for small window size)
  - keep self.tabBar visible, otherwise the widget border is rendered with a gap on linux
  - apply stylesheet to both tabTar and surrounding widget
  - buttons style: align text left, NoFocus
  - on button click: setChecked always True, draw qr code at the end because it is slow
2022-07-31 11:33:26 +02:00
ThomasV
98e6bd6f80 Merge pull request #7909 from SomberNight/202207_qt_receive_tab_macos
Qt receive_tab: fix receive_tabs widget on macOS
2022-07-31 11:32:01 +02:00
ThomasV
a2e059ce7a receive_tab: workaround qdarkstyle bug 2022-07-31 09:55:07 +02:00
SomberNight
7dcd8d8dc8 Qt receive_tab: fix receive_tabs widget on macOS
QTabWidget with "West" tab pos and horizontal text looks completely broken on macOS
(despite looking good on e.g. Ubuntu GNOME and Windows).

The alternative here looks ok on all three OSes.

fixes https://github.com/spesmilo/electrum/issues/7908
2022-07-30 02:16:38 +02:00
ThomasV
9ae0e5bffc remove lightning parameter from wallet.create_request 2022-07-11 13:52:13 +02:00
ThomasV
1d343657f1 Qt: require left-click to toggle receive qr-code 2022-07-05 15:31:53 +02:00
SomberNight
133c0f71c4 qt ReceiveTab: (trivial) rename clear_receive_tab to do_clear 2022-07-01 16:21:56 +02:00
SomberNight
5b29e6d4f5 qt: (refactor) split "receive tab" out from main_window.py 2022-07-01 16:03:28 +02:00