feat: check for "--disable-mica" arg to disable Mica effect

This commit is contained in:
uncor3
2026-04-10 16:19:00 +03:00
parent 7293514426
commit ed8b87cd4c
7 changed files with 86 additions and 40 deletions
+10 -3
View File
@@ -45,10 +45,18 @@ int main(int argc, char *argv[])
"their default values.");
}
#ifdef WIN32
bool enableMica = !a.arguments().contains("--disable-mica") &&
!SettingsManager::sharedInstance()->disableMica();
if (!enableMica) {
SettingsManager::sharedInstance()->setDisableMica(true);
qDebug() << "Mica effect disabled";
}
QApplication::setEffectEnabled(Qt::UI_AnimateCombo, false);
QOperatingSystemVersion osVersion = QOperatingSystemVersion::current();
if (osVersion >= QOperatingSystemVersion::Windows11) {
if (enableMica && osVersion >= QOperatingSystemVersion::Windows11) {
QFile styleFile(detectDarkModeWindows() ? ":/resources/win.dark.qcss"
: ":/resources/win.light.qcss");
if (styleFile.open(QFile::ReadOnly | QFile::Text)) {
@@ -58,8 +66,7 @@ int main(int argc, char *argv[])
a.setStyleSheet(style);
}
} else {
qDebug() << "Windows version is older than 11, not applying winui "
"stylesheet.";
qDebug() << "Not applying WinUI stylesheet.";
}
QString appPath = QCoreApplication::applicationDirPath();
+30
View File
@@ -99,3 +99,33 @@ void enableMica(HWND hwnd)
DwmSetWindowAttribute(hwnd, DWMWA_MICA_EFFECT, &mica, sizeof(mica));
}
}
void setupWinWindow(QWidget *window)
{
QOperatingSystemVersion osVersion = QOperatingSystemVersion::current();
if (osVersion < QOperatingSystemVersion::Windows11 ||
SettingsManager::sharedInstance()->disableMica())
return;
window->setAttribute(Qt::WA_TranslucentBackground);
HWND hwnd = reinterpret_cast<HWND>(window->winId());
enableMica(hwnd);
/*
normally we had plans to enable acrylic on win 10 but since it's
untested and may cause issues, we'll just enable mica on win 11 and above
for now
*/
// enableAcrylic(hwnd);
}
/* apparently this only works on Win 11 but should not crash on older versions
*/
void SetCorner(HWND hwnd, CornerPreference corner)
{
if (corner != Corner_Default) {
DWM_WINDOW_CORNER_PREFERENCE cp =
static_cast<DWM_WINDOW_CORNER_PREFERENCE>(corner);
DwmSetWindowAttribute(hwnd, DWMWA_WINDOW_CORNER_PREFERENCE, &cp,
sizeof(cp));
}
}
+9 -37
View File
@@ -41,9 +41,16 @@ SERVICE_AVAILABILITY IsBonjourServiceInstalled();
// bool StartAppleMobileDeviceService();
// bool StartWinFspService();
// bool StartBonjourService();
void enableAcrylic(HWND hwnd);
void enableMica(HWND hwnd);
void setupWinWindow(QWidget *window);
enum CornerPreference : int {
Corner_Default = DWMWCP_DEFAULT,
Corner_NoRound = DWMWCP_DONOTROUND,
Corner_Round = DWMWCP_ROUND,
Corner_RoundSmall = DWMWCP_ROUNDSMALL
};
void SetCorner(HWND hwnd, CornerPreference corner);
inline QString getWindowsAccentColor()
{
@@ -97,38 +104,3 @@ inline bool detectDarkModeWindows()
}
return true; // Default to dark mode if detection fails
}
inline void setupWinWindow(QWidget *window)
{
QOperatingSystemVersion osVersion = QOperatingSystemVersion::current();
if (osVersion < QOperatingSystemVersion::Windows11)
return;
window->setAttribute(Qt::WA_TranslucentBackground);
HWND hwnd = reinterpret_cast<HWND>(window->winId());
enableMica(hwnd);
/*
normally we had plans to enable acrylic on win 10 but since it's
untested and may cause issues, we'll just enable mica on win 11 and above
for now
*/
// enableAcrylic(hwnd);
}
enum CornerPreference : int {
Corner_Default = DWMWCP_DEFAULT,
Corner_NoRound = DWMWCP_DONOTROUND,
Corner_Round = DWMWCP_ROUND,
Corner_RoundSmall = DWMWCP_ROUNDSMALL
};
/* apparently this only works on Win 11 but should not crash on older versions
*/
inline void SetCorner(HWND hwnd, CornerPreference corner)
{
if (corner != Corner_Default) {
DWM_WINDOW_CORNER_PREFERENCE cp =
static_cast<DWM_WINDOW_CORNER_PREFERENCE>(corner);
DwmSetWindowAttribute(hwnd, DWMWA_WINDOW_CORNER_PREFERENCE, &cp,
sizeof(cp));
}
}
+16
View File
@@ -24,6 +24,10 @@
#include <QSettings>
#include <QStandardPaths>
#ifdef WIN32
#include "platform/windows/win_common.h"
#endif
const QString SEEN_DEVICE_PREFIX = "seenDevices/";
SettingsManager *SettingsManager::sharedInstance()
@@ -283,6 +287,7 @@ void SettingsManager::resetToDefaults()
#ifdef WIN32
setWinBackdropType(ACRYLIC);
setDisableMica(false);
#endif
}
@@ -522,6 +527,17 @@ WIN_BACKDROP SettingsManager::winBackdropType() const
m_settings->value("winBackdropType", static_cast<int>(ACRYLIC))
.toInt());
}
bool SettingsManager::disableMica() const
{
return m_settings->value("disableMica", false).toBool();
}
void SettingsManager::setDisableMica(bool disabled)
{
m_settings->setValue("disableMica", disabled);
m_settings->sync();
}
#endif
bool SettingsManager::isSleepyDeviceWarningDismissed() const
+3
View File
@@ -140,6 +140,9 @@ public:
#ifdef WIN32
void setWinBackdropType(WIN_BACKDROP type);
WIN_BACKDROP winBackdropType() const;
bool disableMica() const;
void setDisableMica(bool disabled);
#endif
bool isSleepyDeviceWarningDismissed() const;
+17
View File
@@ -46,6 +46,7 @@ SettingsWidget::SettingsWidget(QWidget *parent) : QDialog{parent}
{
#ifdef WIN32
m_backDropTypeCombo = nullptr;
m_disableMicaCheckBox = nullptr;
#endif
setupUI();
loadSettings();
@@ -144,6 +145,10 @@ void SettingsWidget::setupUI()
backDropTypeLayout->addStretch();
generalLayout->addLayout(backDropTypeLayout);
m_disableMicaCheckBox =
new QCheckBox("Disable Mica effects (also disables WinUI styles)");
generalLayout->addWidget(m_disableMicaCheckBox);
}
#endif
@@ -350,6 +355,9 @@ void SettingsWidget::loadSettings()
m_backDropTypeCombo->setCurrentIndex(0);
}
}
if (m_disableMicaCheckBox) {
m_disableMicaCheckBox->setChecked(sm->disableMica());
}
#endif
}
@@ -426,6 +434,12 @@ void SettingsWidget::connectSignals()
onSettingChanged();
});
}
if (m_disableMicaCheckBox) {
connect(m_disableMicaCheckBox, &QCheckBox::toggled, this, [this]() {
m_restartRequired = true;
onSettingChanged();
});
}
#endif
}
@@ -534,6 +548,9 @@ void SettingsWidget::saveSettings()
sm->setWinBackdropType(static_cast<WIN_BACKDROP>(data.toInt()));
}
}
if (m_disableMicaCheckBox) {
sm->setDisableMica(m_disableMicaCheckBox->isChecked());
}
#endif
}
+1
View File
@@ -81,6 +81,7 @@ private:
#ifdef WIN32
QComboBox *m_backDropTypeCombo;
QCheckBox *m_disableMicaCheckBox;
#endif
// Buttons