Qt: add missing paintEvent overrides for stylesheet correctness

This commit is contained in:
Brad Parker 2018-08-19 18:54:13 -04:00
parent b60df44b59
commit 8380ad61f9
6 changed files with 119 additions and 0 deletions

View File

@ -1,5 +1,6 @@
#include <QCloseEvent>
#include <QResizeEvent>
#include <QPainter>
#include <QScrollArea>
#include <QVBoxLayout>
#include <QGroupBox>
@ -1152,3 +1153,16 @@ void ShaderParamsDialog::onShaderParamDoubleSpinBoxValueChanged(double value)
}
}
}
void ShaderParamsDialog::paintEvent(QPaintEvent *event)
{
QStyleOption o;
QPainter p;
o.initFrom(this);
p.begin(this);
style()->drawPrimitive(
QStyle::PE_Widget, &o, &p, this);
p.end();
QDialog::paintEvent(event);
}

View File

@ -5,6 +5,7 @@
class QCloseEvent;
class QResizeEvent;
class QPaintEvent;
class QVBoxLayout;
class QFormLayout;
class QLayout;
@ -49,6 +50,7 @@ private:
protected:
void closeEvent(QCloseEvent *event);
void resizeEvent(QResizeEvent *event);
void paintEvent(QPaintEvent *event);
};
#endif

View File

@ -191,6 +191,19 @@ void TreeView::selectionChanged(const QItemSelection &selected, const QItemSelec
emit itemsSelected(list);
}
void TreeView::paintEvent(QPaintEvent *event)
{
QStyleOption o;
QPainter p;
o.initFrom(this);
p.begin(this);
style()->drawPrimitive(
QStyle::PE_Widget, &o, &p, this);
p.end();
QTreeView::paintEvent(event);
}
TableWidget::TableWidget(QWidget *parent) :
QTableWidget(parent)
{
@ -212,12 +225,38 @@ void TableWidget::keyPressEvent(QKeyEvent *event)
QTableWidget::keyPressEvent(event);
}
void TableWidget::paintEvent(QPaintEvent *event)
{
QStyleOption o;
QPainter p;
o.initFrom(this);
p.begin(this);
style()->drawPrimitive(
QStyle::PE_Widget, &o, &p, this);
p.end();
QTableWidget::paintEvent(event);
}
CoreInfoLabel::CoreInfoLabel(QString text, QWidget *parent) :
QLabel(text, parent)
{
setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
}
void CoreInfoLabel::paintEvent(QPaintEvent *event)
{
QStyleOption o;
QPainter p;
o.initFrom(this);
p.begin(this);
style()->drawPrimitive(
QStyle::PE_Widget, &o, &p, this);
p.end();
QLabel::paintEvent(event);
}
CoreInfoWidget::CoreInfoWidget(CoreInfoLabel *label, QWidget *parent) :
QWidget(parent)
,m_label(label)
@ -238,6 +277,19 @@ void CoreInfoWidget::resizeEvent(QResizeEvent *event)
m_scrollArea->resize(event->size());
}
void CoreInfoWidget::paintEvent(QPaintEvent *event)
{
QStyleOption o;
QPainter p;
o.initFrom(this);
p.begin(this);
style()->drawPrimitive(
QStyle::PE_Widget, &o, &p, this);
p.end();
QWidget::paintEvent(event);
}
LogTextEdit::LogTextEdit(QWidget *parent) :
QPlainTextEdit(parent)
{
@ -253,6 +305,19 @@ void LogTextEdit::appendMessage(const QString& text)
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
}
void LogTextEdit::paintEvent(QPaintEvent *event)
{
QStyleOption o;
QPainter p;
o.initFrom(this);
p.begin(this);
style()->drawPrimitive(
QStyle::PE_Widget, &o, &p, this);
p.end();
QPlainTextEdit::paintEvent(event);
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
,m_loadCoreWindow(new LoadCoreWindow(this))
@ -2947,6 +3012,19 @@ void MainWindow::onShowInfoMessage(QString msg)
showMessageBox(msg, MainWindow::MSGBOX_TYPE_INFO, Qt::ApplicationModal, false);
}
void MainWindow::paintEvent(QPaintEvent *event)
{
QStyleOption o;
QPainter p;
o.initFrom(this);
p.begin(this);
style()->drawPrimitive(
QStyle::PE_Widget, &o, &p, this);
p.end();
QMainWindow::paintEvent(event);
}
static void* ui_window_qt_init(void)
{
ui_window.qtWindow = new MainWindow();

View File

@ -10,6 +10,7 @@
#include <QFileDialog>
#include <QApplication>
#include <QColorDialog>
#include <QPainter>
#include "viewoptionsdialog.h"
#include "../ui_qt.h"
@ -216,3 +217,15 @@ void ViewOptionsDialog::hideDialog()
reject();
}
void ViewOptionsDialog::paintEvent(QPaintEvent *event)
{
QStyleOption o;
QPainter p;
o.initFrom(this);
p.begin(this);
style()->drawPrimitive(
QStyle::PE_Widget, &o, &p, this);
p.end();
QDialog::paintEvent(event);
}

View File

@ -44,6 +44,8 @@ private:
QCheckBox *m_suggestLoadedCoreFirstCheckBox;
QSpinBox *m_allPlaylistsListMaxCountSpinBox;
QSpinBox *m_allPlaylistsGridMaxCountSpinBox;
protected:
void paintEvent(QPaintEvent *event);
};
#endif

View File

@ -153,6 +153,8 @@ signals:
protected slots:
void columnCountChanged(int oldCount, int newCount);
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
protected:
void paintEvent(QPaintEvent *event);
};
class TableWidget : public QTableWidget
@ -165,6 +167,8 @@ signals:
void deletePressed();
protected:
void keyPressEvent(QKeyEvent *event);
protected:
void paintEvent(QPaintEvent *event);
};
class AppHandler : public QObject
@ -186,6 +190,8 @@ class CoreInfoLabel : public QLabel
Q_OBJECT
public:
CoreInfoLabel(QString text = QString(), QWidget *parent = 0);
protected:
void paintEvent(QPaintEvent *event);
};
class CoreInfoWidget : public QWidget
@ -196,6 +202,7 @@ public:
QSize sizeHint() const;
protected:
void resizeEvent(QResizeEvent *event);
void paintEvent(QPaintEvent *event);
private:
CoreInfoLabel *m_label;
QScrollArea *m_scrollArea;
@ -208,6 +215,8 @@ public:
LogTextEdit(QWidget *parent = 0);
public slots:
void appendMessage(const QString& text);
protected:
void paintEvent(QPaintEvent *event);
};
class MainWindow : public QMainWindow
@ -450,6 +459,7 @@ private:
protected:
void closeEvent(QCloseEvent *event);
void keyPressEvent(QKeyEvent *event);
void paintEvent(QPaintEvent *event);
};
Q_DECLARE_METATYPE(ThumbnailWidget)