-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PR: Add an option to set cursor blinking speed in miliseconds #4758
PR: Add an option to set cursor blinking speed in miliseconds #4758
Conversation
@jnsebgosselin thanks for the contribution, you need to align the two spinboxes (the one from custom margins from panes) Look at the code that does this for the fonts on upper part of your screenshot |
@jnsebgosselin also you should make the PR against 3.x I think @ccordoba12 ? |
Note: I had to connect box toggled signal to both spinbox and slabel setEnabled slot since custom merged spinbox layout becomes irrelevant as soon as the spinbox and slabel are added individually in the layout (for alignment purpose).
Looks good, except for the branch @ccordoba12 ? |
@jnsebgosselin, thanks a lot for your contributions! However, we need to ask you to move all your branches from the 3.1.x branch (which is not going to receive more updates) to the 3.x branch (which is our maintenance branch right now). Sorry for not being clear enough since your first contribution, but you can find the instructions to do that here https://github.com/spyder-ide/spyder/blob/master/CONTRIBUTING.md#spyder-branches |
Note: I had to connect box toggled signal to both spinbox and slabel setEnabled slot since custom merged spinbox layout becomes irrelevant as soon as the spinbox and slabel are added individually in the layout (for alignment purpose).
…t_blinking_option # Conflicts: # spyder/config/main.py # spyder/plugins/configdialog.py
@ccordoba12 kk good. I finally managed to rebase this PR. I hope it is not too messy. I can create a new clean PR if required. Thanks for the link, I'll read it carefully and I will try to improve my setup. |
spyder/app/mainwindow.py
Outdated
@@ -2539,6 +2539,11 @@ def apply_settings(self): | |||
|
|||
self.apply_panes_settings() | |||
self.apply_statusbar_settings() | |||
|
|||
if CONF.get('main', 'use_custom_caret_blinking') is True: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need for is True
at the end of this line, so please remove it.
spyder/config/main.py
Outdated
@@ -93,6 +93,8 @@ | |||
'cpu_usage/timeout': 2000, | |||
'use_custom_margin': True, | |||
'custom_margin': 0, | |||
'use_custom_caret_blinking': False, | |||
'custom_caret_blinking': 1000, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using caret
as part of these options, please use cursor
instead, i.e. use_custom_cursor_blinking
and custom_cursor_blinking
.
Changing this option requires a Spyder restart because it's applied at the window level. @rlaverde, please instruct @jnsebgosselin on how to do that. |
@jnsebgosselin Thanks for you contribution, in order to make this a restarting option, you need to add restart support to You could take a look at this commit 8fafe45 |
QApplication cursorFlashTime is cached on startup so that the default value of the OS can be used if the user unchecked `Cursor blinking` option in preferences. This is needed since QApplication.cursorFlashTime() returns the value of the current QApplication instance, not the OS default value.
@rlaverde @ccordoba12 Thank you. But are you sure this needs a restart? Seems to me like this can be applied at run-time. At least, it is on Windows. That being said, something was not working as expected with the code. When the option to use a custom cursor blinking time was unchecked, after a custom value had been set, the value was not reset to the OS default. I haven't found an easy way to get the OS default value for the cursor flash time. This seems to be very platform dependent. Unless you guys know of a better way, maybe we could cache the value of |
spyder/config/main.py
Outdated
@@ -93,6 +93,8 @@ | |||
'cpu_usage/timeout': 2000, | |||
'use_custom_margin': True, | |||
'custom_margin': 0, | |||
'use_custom_cursor_blinking': False, | |||
'custom_cursor_blinking': 1000, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this value should be used then 'custom_cursor_blinking': CURSORBLINK_OSDEFAULT
, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. This makes sense to set the default value here as the default value for the OS. I will change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@goanpeca in the header of this file (main.py
), it is written:
Note: Leave this file free of Qt related imports [...]
So I don't know how I can link CURSORBLINK_OSDEFAULT
, whose value must be obtained with QApplication... Do you have any idea? Maybe another solution could be to set the default value when creating the spinbox within the configdialog.py
module instead of here? Something like:
cursor_spin = self.create_spinbox(
"", _("ms"), 'custom_cursor_blinking',
default = QApplication.cursorFlashTime(),
min_ = 0, max_ = 5000)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jnsebgosselin, your solution is the only one that occurs to me too.
Since we can't adjust this value in our config system, please remove it from here. It'll be written to spyder.ini
when the spinbox is created.
spyder/plugins/configdialog.py
Outdated
@@ -887,7 +889,8 @@ def setup_page(self): | |||
cursor_box = newcb(_("Cursor blinking:"), | |||
'use_custom_cursor_blinking') | |||
cursor_spin = self.create_spinbox("", _("ms"), 'custom_cursor_blinking', | |||
0, 0, 5000) | |||
default = QApplication.cursorFlashTime(), | |||
min_ = 0, max_ = 5000, step = 10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove spaces around =
. They are not needed for keyword args.
spyder/plugins/configdialog.py
Outdated
@@ -328,6 +329,7 @@ def load_from_conf(self): | |||
if lineedit.restart_required: | |||
self.restart_options[option] = lineedit.label_text | |||
for spinbox, (option, default) in list(self.spinboxes.items()): | |||
print(option, default, self.get_option(option, default)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this print
here.
spyder/config/main.py
Outdated
@@ -94,7 +94,6 @@ | |||
'use_custom_margin': True, | |||
'custom_margin': 0, | |||
'use_custom_cursor_blinking': False, | |||
'custom_cursor_blinking': 1000, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ccordoba12 and @jnsebgosselin I think we still need to have the option here, the only difference is that it would be None
by default, and when building the spinbox, we would check if it is None and update with the default by QApplication, or just use the stored value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I do that, then delete my .init files and restart Spyder, I get the following traceback:
Traceback (most recent call last):
File "C:\Users\jsgosselin\spyder\spyder\app\mainwindow.py", line 2585, in edit_preferences
widget.initialize()
File "C:\Users\jsgosselin\spyder\spyder\plugins\configdialog.py", line 76, in initialize
self.load_from_conf()
File "C:\Users\jsgosselin\spyder\spyder\plugins\configdialog.py", line 332, in load_from_conf
spinbox.setValue(self.get_option(option, default))
TypeError: setValue(self, int): argument 1 has unexpected type 'NoneType'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@goanpeca, there is no need to do that because values are placed here only if we plan to change/update them in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this value is OS dependent, so we can't put it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
@ccordoba12 This is working as expected, both on Windows and Linux, without any Spyder reboot required |
Thanks a lot for testing @andfoy! Merging then ;-) |
Fixes #4277