refactor: LineEditValidator, adjust border style based on the Qt Style in use
This commit is contained in:
parent
2b8e7fa6b2
commit
b8b7799a47
2 changed files with 26 additions and 6 deletions
|
|
@ -12,9 +12,6 @@ namespace deskflow::gui {
|
||||||
|
|
||||||
const auto kColorError = "#ec4c47";
|
const auto kColorError = "#ec4c47";
|
||||||
|
|
||||||
const auto kStyleLineEditErrorBorder =
|
|
||||||
QStringLiteral("border: 1px solid %1; border-radius: 2px; padding: 2px;").arg(kColorError);
|
|
||||||
|
|
||||||
const auto kStyleErrorActiveLabel = //
|
const auto kStyleErrorActiveLabel = //
|
||||||
QStringLiteral(
|
QStringLiteral(
|
||||||
"padding: 3px 5px; border-radius: 3px; "
|
"padding: 3px 5px; border-radius: 3px; "
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Deskflow -- mouse and keyboard sharing utility
|
* Deskflow -- mouse and keyboard sharing utility
|
||||||
|
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||||
* SPDX-FileCopyrightText: (C) 2021 Symless Ltd.
|
* SPDX-FileCopyrightText: (C) 2021 Symless Ltd.
|
||||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||||
*/
|
*/
|
||||||
|
|
@ -8,6 +9,8 @@
|
||||||
|
|
||||||
#include "gui/Styles.h"
|
#include "gui/Styles.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QStyle>
|
||||||
#include <QValidator>
|
#include <QValidator>
|
||||||
|
|
||||||
using namespace deskflow::gui;
|
using namespace deskflow::gui;
|
||||||
|
|
@ -42,9 +45,29 @@ QValidator::State LineEditValidator::validate(QString &input, int &) const
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errorMessage.isEmpty()) {
|
if (errorMessage.isEmpty()) {
|
||||||
m_pLineEdit->setStyleSheet("");
|
m_pLineEdit->setStyleSheet({});
|
||||||
} else {
|
} else { // The values here are for fusion style
|
||||||
m_pLineEdit->setStyleSheet(kStyleLineEditErrorBorder);
|
int radius = 3;
|
||||||
|
int padVer = 2;
|
||||||
|
int padHor = 0;
|
||||||
|
int borderWidth = 1;
|
||||||
|
if (const auto wStyle = QApplication::style()->name().toLower(); wStyle == QStringLiteral("breeze")) {
|
||||||
|
radius = 6;
|
||||||
|
padVer = 5;
|
||||||
|
padHor = 5;
|
||||||
|
} else if (wStyle == QStringLiteral("macos")) {
|
||||||
|
radius = 4;
|
||||||
|
padVer = 1;
|
||||||
|
borderWidth = 3;
|
||||||
|
} else if (wStyle == QStringLiteral("windows")) {
|
||||||
|
padVer = 1;
|
||||||
|
padHor = 1;
|
||||||
|
}
|
||||||
|
m_pLineEdit->setStyleSheet(QStringLiteral("border-radius: %1px; padding: %2px %3px; border: %4px solid %5;")
|
||||||
|
.arg(
|
||||||
|
QString::number(radius), QString::number(padVer), QString::number(padHor),
|
||||||
|
QString::number(borderWidth), kColorError
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_pError) {
|
if (m_pError) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue