-
-
Notifications
You must be signed in to change notification settings - Fork 117
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
Adds macOS theme switch listening #430
base: master
Are you sure you want to change the base?
Adds macOS theme switch listening #430
Conversation
src/ui/MainWindow.cpp
Outdated
@@ -589,3 +590,14 @@ QString MainWindow::windowGroup() const { | |||
QByteArray hash = QCryptographicHash::hash(group, QCryptographicHash::Md5); | |||
return QString::fromUtf8(hash.toHex()); | |||
} | |||
|
|||
void MainWindow::changeEvent(QEvent *e) { | |||
#ifdef Q_OS_MACX |
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.
Just a headsup, there are tools that replicate this macOS function on Windows etc.
(I don’t know QT, so not sure if this triggers the same event or if it even supports it, so feel free to disregard this.)
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.
yes maybe we can use it also for windows and linux
@0verEngineer thanks for the work and @LenaWil thanks for the review! @0verEngineer can you remove the ifdef for testing. Then we are getting builds for windows, linux and macos and we can test it easily. @LenaWil did it work for you? |
@Murmele I have removed the ifdefs and i also tested the event thing on Gnome but no event is fired on theme neither lagacy theme switch. |
Checked KDE and Windows Theme change in Settings: KDE: Windows: If we reload the theme on each of the 3 Events it will be done multiple times in a row, idk how this works performance wise, i think we should reload on Windows and KDE only on the I will do it later :) |
I haven’t actually set up a build-environment currently, before I do that, is there a way to easily downloaded a pre-built version? |
Yes, just check the build artifacts. There you can find a macos build. |
Thanks for testing. Would be nice if we can fix it on all three OS. |
Okay definitely better than first, the only thing is that the code preview doesn’t update properly and still has the dark/light theme after switching to the opposite. But I can at least read the code now! |
great! Something for scintilla is missing |
Maybe we have to implement the event also for the texteditor TextEditor::TextEditor(QWidget *parent) : ScintillaIFace(parent) {
// Load colors.
Theme *theme = Application::theme();
mOursColor = theme->diff(Theme::Diff::Ours);
mTheirsColor = theme->diff(Theme::Diff::Theirs);
mAdditionColor = theme->diff(Theme::Diff::Addition);
mDeletionColor = theme->diff(Theme::Diff::Deletion);
There are more theme related things below // Set word diff indicators.
indicSetStyle(WordAddition, INDIC_STRAIGHTBOX);
indicSetFore(WordAddition, theme->diff(Theme::Diff::WordAddition));
indicSetAlpha(WordAddition, 255);
indicSetUnder(WordAddition, true);
indicSetStyle(WordDeletion, INDIC_STRAIGHTBOX);
indicSetFore(WordDeletion, theme->diff(Theme::Diff::WordDeletion));
indicSetAlpha(WordDeletion, 255);
indicSetUnder(WordDeletion, true);
indicSetStyle(NoteIndicator, INDIC_SQUIGGLE);
indicSetFore(NoteIndicator, theme->diff(Theme::Diff::Note));
indicSetAlpha(NoteIndicator, 255);
indicSetUnder(NoteIndicator, true);
indicSetStyle(WarningIndicator, INDIC_STRAIGHTBOX);
indicSetFore(WarningIndicator, theme->diff(Theme::Diff::Warning));
indicSetAlpha(WarningIndicator, 255);
indicSetUnder(WarningIndicator, true);
indicSetStyle(ErrorIndicator, INDIC_STRAIGHTBOX);
indicSetFore(ErrorIndicator, theme->diff(Theme::Diff::Error));
indicSetAlpha(ErrorIndicator, 255);
indicSetUnder(ErrorIndicator, true);
// Initialize LPeg lexer.
QColor base = palette().color(QPalette::Base);
QColor text = palette().color(QPalette::Text);
bool dark = (text.lightnessF() > base.lightnessF());
setLexerLanguage("lpeg");
setProperty("lexer.lpeg.home", Settings::lexerDir().path());
setProperty("lexer.lpeg.themes", theme->dir().path());
setProperty("lexer.lpeg.theme", theme->name());
setProperty("lexer.lpeg.theme.mode", dark ? "dark" : "light"); moving all related code to the end of the constructor if this is working in own function which will be called also for those events |
@Murmele The changeEvent is not called on the TextEditors so i have added a static list that holds all instances in order to refresh the theme, but if i call all that theme related stuff inside its own function only the text color is changed, the background and highlight colors stay the same. I don't know Scintilla at all so i have no idea how to implement this atm. |
I will have a look next days |
@0verEngineer can you enable that I have write permission to your branch? Otherwise I cannot push changes (If I remember me correctly you can do it here in this PR on the right side somewhere) |
@Murmele It is already enabled and i have nothing changed after creating the fork |
ah sorry was on the _test branch and not on the one from this PR. I am not able to get the changeEvent triggered with windows 10, I am trying later on linux. |
Ahh this is my fault, i did the testing if the events are triggered with qt 6.2... It is not triggered on KDE either. |
From here:
Instead of this workaround I would let it be for all systems which do not support it and once we are going with Qt6 it is working automatically. |
@Murmele I also don't like the TextEdit list :D I have just tested your changes but it does not change anything about the TextEditor and i also found 2 problems in the normal theming |
@0verEngineer Sorry for comming back that late. This problem does not exist on Windows and I never realized it on Linux so I assume it is also not there. The problem is, that I was currently not able to get the switching reproducable. I have to check how to get the switching work |
@Murmele Is |
No I did not see. I think if you get it work completely for macos this is fine for me and we can merge it. Once we found a solution on windows / linux we are changing it or it might be resolved automatically with qt6. |
Can you try to rebase this one on top of the Qt6 branch to see if it works? |
…er/Gittyup.git Conflicts: src/ui/MainWindow.cpp
#408