fix: eliminate window flickering and Sketcher icon clipping
Some checks failed
Build and Test / build (pull_request) Has been cancelled
Some checks failed
Build and Test / build (pull_request) Has been cancelled
- Replace statusBar()->setStyleSheet() with QPalette color changes in MainWindow::showStatus() and clearStatus(). The setStyleSheet() call triggered full style recalculation on every status message (selection, pan, tooltip hover), causing the entire window to flicker. - Add min-height: 24px to QListView::item in KindredCreate.qss so Sketcher constraint and element icons (24x24) are not clipped by the 4px padding.
This commit is contained in:
@@ -2541,10 +2541,18 @@ void MainWindow::changeEvent(QEvent* e)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void setStatusBarForeground(QStatusBar* bar, const QColor& color)
|
||||||
|
{
|
||||||
|
QPalette pal = bar->palette();
|
||||||
|
pal.setColor(QPalette::WindowText, color);
|
||||||
|
bar->setPalette(pal);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::clearStatus()
|
void MainWindow::clearStatus()
|
||||||
{
|
{
|
||||||
d->currentStatusType = 100;
|
d->currentStatusType = 100;
|
||||||
statusBar()->setStyleSheet(QStringLiteral("#statusBar{}"));
|
// Reset to default foreground from the stylesheet/theme
|
||||||
|
statusBar()->setPalette(QPalette());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::statusMessageChanged()
|
void MainWindow::statusMessageChanged()
|
||||||
@@ -2607,16 +2615,16 @@ void MainWindow::showStatus(int type, const QString& message)
|
|||||||
QString msg = fm.elidedText(message, Qt::ElideMiddle, this->d->actionLabel->width());
|
QString msg = fm.elidedText(message, Qt::ElideMiddle, this->d->actionLabel->width());
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case MainWindow::Err:
|
case MainWindow::Err:
|
||||||
statusBar()->setStyleSheet(d->status->err);
|
setStatusBarForeground(statusBar(), d->status->err);
|
||||||
break;
|
break;
|
||||||
case MainWindow::Wrn:
|
case MainWindow::Wrn:
|
||||||
statusBar()->setStyleSheet(d->status->wrn);
|
setStatusBarForeground(statusBar(), d->status->wrn);
|
||||||
break;
|
break;
|
||||||
case MainWindow::Pane:
|
case MainWindow::Pane:
|
||||||
statusBar()->setStyleSheet(QStringLiteral("#statusBar{}"));
|
statusBar()->setPalette(QPalette());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
statusBar()->setStyleSheet(d->status->msg);
|
setStatusBarForeground(statusBar(), d->status->msg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
d->currentStatusType = -type;
|
d->currentStatusType = -type;
|
||||||
@@ -2739,9 +2747,9 @@ void MainWindow::setWindowTitle(const QString& string)
|
|||||||
StatusBarObserver::StatusBarObserver()
|
StatusBarObserver::StatusBarObserver()
|
||||||
: WindowParameter("OutputWindow")
|
: WindowParameter("OutputWindow")
|
||||||
{
|
{
|
||||||
msg = QStringLiteral("#statusBar{color: #000000}"); // black
|
msg = QColor(0, 0, 0); // black
|
||||||
wrn = QStringLiteral("#statusBar{color: #ffaa00}"); // orange
|
wrn = QColor(0xff, 0xaa, 0); // orange
|
||||||
err = QStringLiteral("#statusBar{color: #ff0000}"); // red
|
err = QColor(0xff, 0, 0); // red
|
||||||
Base::Console().attachObserver(this);
|
Base::Console().attachObserver(this);
|
||||||
getWindowParameter()->Attach(this);
|
getWindowParameter()->Attach(this);
|
||||||
getWindowParameter()->NotifyAll();
|
getWindowParameter()->NotifyAll();
|
||||||
@@ -2756,24 +2764,21 @@ StatusBarObserver::~StatusBarObserver()
|
|||||||
void StatusBarObserver::OnChange(Base::Subject<const char*>& rCaller, const char* sReason)
|
void StatusBarObserver::OnChange(Base::Subject<const char*>& rCaller, const char* sReason)
|
||||||
{
|
{
|
||||||
ParameterGrp& rclGrp = ((ParameterGrp&)rCaller);
|
ParameterGrp& rclGrp = ((ParameterGrp&)rCaller);
|
||||||
auto format = QStringLiteral("#statusBar{color: %1}");
|
|
||||||
if (strcmp(sReason, "colorText") == 0) {
|
if (strcmp(sReason, "colorText") == 0) {
|
||||||
unsigned long col = rclGrp.GetUnsigned(sReason);
|
unsigned long col = rclGrp.GetUnsigned(sReason);
|
||||||
this->msg = format.arg(Base::Color::fromPackedRGB<QColor>(col).name());
|
this->msg = Base::Color::fromPackedRGB<QColor>(col);
|
||||||
}
|
}
|
||||||
else if (strcmp(sReason, "colorWarning") == 0) {
|
else if (strcmp(sReason, "colorWarning") == 0) {
|
||||||
unsigned long col = rclGrp.GetUnsigned(sReason);
|
unsigned long col = rclGrp.GetUnsigned(sReason);
|
||||||
this->wrn = format.arg(Base::Color::fromPackedRGB<QColor>(col).name());
|
this->wrn = Base::Color::fromPackedRGB<QColor>(col);
|
||||||
}
|
}
|
||||||
else if (strcmp(sReason, "colorError") == 0) {
|
else if (strcmp(sReason, "colorError") == 0) {
|
||||||
unsigned long col = rclGrp.GetUnsigned(sReason);
|
unsigned long col = rclGrp.GetUnsigned(sReason);
|
||||||
this->err = format.arg(Base::Color::fromPackedRGB<QColor>(col).name());
|
this->err = Base::Color::fromPackedRGB<QColor>(col);
|
||||||
}
|
}
|
||||||
else if (strcmp(sReason, "colorCritical") == 0) {
|
else if (strcmp(sReason, "colorCritical") == 0) {
|
||||||
unsigned long col = rclGrp.GetUnsigned(sReason);
|
unsigned long col = rclGrp.GetUnsigned(sReason);
|
||||||
this->critical = format.arg(
|
this->critical = QColor((col >> 24) & 0xff, (col >> 16) & 0xff, (col >> 8) & 0xff);
|
||||||
QColor((col >> 24) & 0xff, (col >> 16) & 0xff, (col >> 8) & 0xff).name()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -438,7 +438,7 @@ public:
|
|||||||
friend class MainWindow;
|
friend class MainWindow;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString msg, wrn, err, critical;
|
QColor msg, wrn, err, critical;
|
||||||
};
|
};
|
||||||
|
|
||||||
// -------------------------------------------------------------
|
// -------------------------------------------------------------
|
||||||
|
|||||||
@@ -862,6 +862,7 @@ QListView {
|
|||||||
QListView::item {
|
QListView::item {
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
|
min-height: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
QListView::item:hover {
|
QListView::item:hover {
|
||||||
|
|||||||
Reference in New Issue
Block a user