Skip to content

Commit

Permalink
#2986 add: QLineEdit dark-mode icon
Browse files Browse the repository at this point in the history
  • Loading branch information
pbek committed Mar 17, 2024
1 parent 72e7c1f commit 9b38124
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/images.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<file>images/icon-dark.png</file>
<file>images/search-notes.svg</file>
<file>images/search-notes-dark.svg</file>
<file>images/cleartext-dark.svg</file>
<file>images/layouts/full.png</file>
<file>images/layouts/minimal.png</file>
<file>images/layouts/1col.png</file>
Expand Down
71 changes: 71 additions & 0 deletions src/images/cleartext-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1599,6 +1599,8 @@ void MainWindow::initStyling() {
// hide the combo box if it looses focus if it should not be viewed
connect(ui->noteFolderComboBox, &ComboBox::focusOut, this,
&MainWindow::hideNoteFolderComboBoxIfNeeded);

Utils::Gui::fixDarkModeIcons(this);
}

/**
Expand Down
21 changes: 21 additions & 0 deletions src/utils/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <entities/tag.h>
#include <libraries/qmarkdowntextedit/markdownhighlighter.h>

#include <QAction>
#include <QApplication>
#include <QCheckBox>
#include <QClipboard>
Expand All @@ -27,6 +28,7 @@
#include <QDialogButtonBox>
#include <QDockWidget>
#include <QListWidget>
#include <QLineEdit>
#include <QMessageBox>
#include <QPlainTextEdit>
#include <QProcess>
Expand Down Expand Up @@ -1207,3 +1209,22 @@ bool Utils::Gui::enableDockWidgetQuestion(QDockWidget *dockWidget) {
dockWidget->setVisible(true);
return true;
}

/**
* Fixes the icons of the dark mode
* @param widget
*/
void Utils::Gui::fixDarkModeIcons(QWidget *widget) {
const bool darkMode = QSettings().value(QStringLiteral("darkMode")).toBool();

if (!darkMode) {
return;
}

foreach(QLineEdit *lineEdit, widget->findChildren<QLineEdit *>()) {
auto action = lineEdit->findChild<QAction *>("_q_qlineeditclearaction");
if (action) {
action->setIcon(QIcon(QStringLiteral(":/images/cleartext-dark.svg")));
}
}
}
1 change: 1 addition & 0 deletions src/utils/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,6 @@ QIcon tagIcon();
void handleTreeWidgetItemTagColor(QTreeWidgetItem *item, const Tag &tag);
void handleTreeWidgetItemTagColor(QTreeWidgetItem *item, int tag);
bool enableDockWidgetQuestion(QDockWidget *dockWidget);
void fixDarkModeIcons(QWidget *widget);
} // namespace Gui
} // namespace Utils

0 comments on commit 9b38124

Please sign in to comment.