Skip to content
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

Option for QValidator in lineedit? #474

Closed
demmm opened this issue Jan 25, 2020 · 15 comments
Closed

Option for QValidator in lineedit? #474

demmm opened this issue Jan 25, 2020 · 15 comments

Comments

@demmm
Copy link

@demmm demmm commented Jan 25, 2020

There are several Qt & KDE apps that I know of that implement color changes for different line inputs. Konsole/kate/kwrite for example have in their find/search option the lineedit color set to green if a string is found, red if not. This works on any application style I know of (fusion, breeze, qtcurve to name a few). With Kvantum, any theme I tried, no such color change are implemented.
An app like Octopi changes color on different search results too, see:
https://github.com/aarnt/octopi/blob/0a7f7c782ed898a0580bcf78de248abe2fa4fe5a/src/searchlineedit.cpp#L200
If I set LineEdit > interior=false, then the notFound color is applied (yellow for Found is never applied). With interior=true, the focus color is always applied, color that Octopi sets is ignored.
I have tried adding lineedit elements to a custom kvantum .svg file, normal and focused are shown as should. Is there currently a way to show lineedit elements for other events? If not, is there a plan to add QValidator as a read option for lineedit output?

@tsujan

This comment has been minimized.

Copy link
Owner

@tsujan tsujan commented Jan 25, 2020

Simply put, all of those apps do it wrong. Their codes were written when developers thought QStyle was only what they saw in a few widget styles. Unfortunately, some developers still have that idea.

To change the colors of a widget (line-edit included) correctly, there are two ways: (a) Either you should draw it completely in your code by using QStyle methods — in other words, you use a hard-coded style — or (b) you use stylesheets correctly; stylesheets override QStyle (but are ugly).

Kvantum rightfully resists hard-coded palettes as far as possible. It uses SVG elements to draw widgets.

@tsujan tsujan closed this Jan 25, 2020
@tsujan

This comment has been minimized.

Copy link
Owner

@tsujan tsujan commented Jan 25, 2020

Is there currently a way to show lineedit elements for other events?

They aren't Qt events but specific methods inside some apps. Kvantum covers all Qt events.

@demmm

This comment has been minimized.

Copy link
Author

@demmm demmm commented Jan 25, 2020

It uses SVG elements to draw widgets

That was my first question. Is there an option to use a lineedit element to show other events besides normal & focused? This is not a question about an app, just trying to see if I can get Kvantum to show same options as other application styles show.

@tsujan

This comment has been minimized.

Copy link
Owner

@tsujan tsujan commented Jan 25, 2020

That was my first question. Is there an option to use a lineedit element to show other events besides normal & focused?

I answered your question above but give a thorougher explanation here:

"Normal" and "focused" aren't events but QStyle states. For a line-edit, the states are normal, focused, inactively normal, disabled, and inactively disabled. Some Kvantum themes ignore the inactive states but Kvantum supports them (other widget styles don't).

What Kate and Konsole do doesn't have anything to do with states. They just change palettes, supposing that the widget style should follow the change. That's a false assumption in most cases. Sadly, other developers copy those codes in their apps...

@demmm

This comment has been minimized.

Copy link
Author

@demmm demmm commented Jan 25, 2020

For a line-edit, the states are normal, focused, inactively normal, disabled, and inactively disabled.

Thanks for that, maybe that will do. Will try some extra svg elements with those options.

@tsujan

This comment has been minimized.

Copy link
Owner

@tsujan tsujan commented Jan 25, 2020

Thanks for that

You're welcome.

maybe that will do

It isn't related to what Kate does ;)

Actually, I've added workarounds to Kvantum for code mistakes that were very frequent. One example is "color button". Most developers think that once they change the palette of a button, the style should reflect that and they will have a "color button" in their apps. This mistake was so frequent that I added a workaround for it several years ago.

By "mistake" I mean something that contradicts Qt's methods. But even skillful developers might make them.

Anyway, I might add a workaround for this one too if it proves to be worth the effort — but no promise ;)

@tsujan

This comment has been minimized.

Copy link
Owner

@tsujan tsujan commented Jan 25, 2020

A (complex) workaround is possible, although it temporarily makes rounded line-edits of some Kvantum themes as ugly as Breeze's line-edits:

kate

I should do lots of test before making sure that it's safe to add a commit.

EDIT: I added this comment an hour ago but GitHub had a problem. So, it might be duplicated later.

@demmm

This comment has been minimized.

Copy link
Author

@demmm demmm commented Jan 25, 2020

If you have a patch available, I sure will help with testing.

@tsujan

This comment has been minimized.

Copy link
Owner

@tsujan tsujan commented Jan 25, 2020

@demmm

My tests are only for finding probable cases where it might have a side effect for normal line-edits; otherwise, it works with palette change (as Kate and Konsole enforce). So far, so good :)

I'll tell you here when I add the commit -- now, I'm a little busy with other projects.

@demmm

This comment has been minimized.

Copy link
Author

@demmm demmm commented Jan 25, 2020

OK, thanks for all the work :).

@tsujan

This comment has been minimized.

Copy link
Owner

@tsujan tsujan commented Jan 26, 2020

@demmm

I added the commit. You could test the latest git Kvantum now. Thanks!

@demmm

This comment has been minimized.

Copy link
Author

@demmm demmm commented Jan 26, 2020

Fix is perfect here, tested mostly in the custom theme, but also in default Kvantum. Example:
Screenshot_20200126_113738

@tsujan

This comment has been minimized.

Copy link
Owner

@tsujan tsujan commented Jan 26, 2020

Thanks for testing! I really appreciate it. If you found any problem, please tell me.

@demmm

This comment has been minimized.

Copy link
Author

@demmm demmm commented Jan 26, 2020

A few more KaOS users have tested it, on a variety of themes, no issues found so far.

@tsujan

This comment has been minimized.

Copy link
Owner

@tsujan tsujan commented Jan 26, 2020

That's good news :)

Anyhow, there's a lot of time for testing/reporting before I publish the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.