dpi-dependent methods

This commit is contained in:
2021-06-14 15:45:29 +03:00
parent b09390a460
commit 8646132928
10 changed files with 18 additions and 18 deletions

View File

@@ -91,7 +91,7 @@ void BlockView::_init() {
sel_rect.hide(); sel_rect.hide();
QColor sc = palette().color(QPalette::Highlight); QColor sc = palette().color(QPalette::Highlight);
sc.setAlphaF(0.6); sc.setAlphaF(0.6);
QPen pen(sc.darker(200), lineThickness() + 1., Qt::DotLine); QPen pen(sc.darker(200), lineThickness(this) + 1., Qt::DotLine);
pen.setCosmetic(true); pen.setCosmetic(true);
sel_rect.setPen(pen); sel_rect.setPen(pen);
sc.setAlphaF(0.2); sc.setAlphaF(0.2);
@@ -791,7 +791,7 @@ void BlockView::keyReleaseEvent(QKeyEvent * e) {
void BlockView::resizeEvent(QResizeEvent * event) { void BlockView::resizeEvent(QResizeEvent * event) {
QGraphicsView::resizeEvent(event); QGraphicsView::resizeEvent(event);
thick = lineThickness(); thick = lineThickness(this);
adjustThumb(); adjustThumb();
updateNavRect(); updateNavRect();
nav_target = _nav(); nav_target = _nav();

View File

@@ -235,8 +235,8 @@ actions_Z_up(this), actions_Z_top(this), actions_Z_down(this), actions_Z_bottom(
ui->labelBrush->setMinimumSize(ui->labelPen->minimumSize()); ui->labelBrush->setMinimumSize(ui->labelPen->minimumSize());
ui->labelBrush->setMaximumSize(ui->labelBrush->minimumSize()); ui->labelBrush->setMaximumSize(ui->labelBrush->minimumSize());
widget_props->setEnabled(false); widget_props->setEnabled(false);
int fh = qMax<int>(fontHeight(), 22); int fh = qMax<int>(fontHeight(this), 22);
int thick = lineThickness(); int thick = lineThickness(this);
QSize sz(fh * 2.5, fh); QSize sz(fh * 2.5, fh);
ui->comboLineStyle->setIconSize(sz); ui->comboLineStyle->setIconSize(sz);
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {

View File

@@ -126,7 +126,7 @@ Graphic::Graphic(QWidget * parent): QFrame(parent), canvas(0), line_x_min(this),
gridx = gridy = 1.; gridx = gridy = 1.;
history = 5.; history = 5.;
visible_time = -1.; visible_time = -1.;
thick = lineThickness(); thick = lineThickness(this);
pause_phase = 0.; pause_phase = 0.;
def_rect.setRect(0., 0., 1., 1.); def_rect.setRect(0., 0., 1., 1.);
selrect = def_rect; selrect = def_rect;
@@ -320,7 +320,7 @@ void Graphic::canvasPaintEvent() {
#else #else
font_sz.setWidth(font_sz.width() * 8); font_sz.setWidth(font_sz.width() * 8);
#endif #endif
thick = lineThickness(); thick = lineThickness(this);
if (buffer != 0) if (buffer->width() != wid || buffer->height() != hei) {delete buffer; buffer = 0;} if (buffer != 0) if (buffer->width() != wid || buffer->height() != hei) {delete buffer; buffer = 0;}
if (buffer == 0) buffer = new QImage(wid, hei, QImage::Format_RGB32); if (buffer == 0) buffer = new QImage(wid, hei, QImage::Format_RGB32);
if (bufferActive) { if (bufferActive) {

View File

@@ -8,7 +8,7 @@ GraphicConf::GraphicConf(QVector<GraphicType> & graphics_, QWidget * parent): QD
ui->setupUi(this); ui->setupUi(this);
QStringList styles; QStringList styles;
int fh = qMax<int>(fontMetrics().size(0, "0").height(), 22); int fh = qMax<int>(fontMetrics().size(0, "0").height(), 22);
int thick = lineThickness(); int thick = lineThickness(this);
QSize sz(fh * 2.5, fh); QSize sz(fh * 2.5, fh);
styles << tr("NoPen") << tr("Solid") << tr("Dash") styles << tr("NoPen") << tr("Solid") << tr("Dash")
<< tr("Dot") << tr("Dash-Dot") << tr("Dash-Dot-Dot"); << tr("Dot") << tr("Dash-Dot") << tr("Dash-Dot-Dot");

View File

@@ -344,7 +344,7 @@ SQLTableWidget::SQLTableWidget(QWidget * parent): QWidget(parent), filters_group
ui->view->horizontalHeader()->viewport()->installEventFilter(this); ui->view->horizontalHeader()->viewport()->installEventFilter(this);
ui->view->setItemDelegate(new SQLItemDelegate(column_props, column_indexes, read_only, connection_name)); ui->view->setItemDelegate(new SQLItemDelegate(column_props, column_indexes, read_only, connection_name));
ui->view->horizontalHeader()->setItemDelegate(new QItemDelegate()); ui->view->horizontalHeader()->setItemDelegate(new QItemDelegate());
ui->view->verticalHeader()->setDefaultSectionSize(fontHeight() * 1.5); ui->view->verticalHeader()->setDefaultSectionSize(fontHeight(this) * 1.5);
//qDebug() << view->horizontalHeader()->itemDelegate(); //qDebug() << view->horizontalHeader()->itemDelegate();
//qDebug() << fontMetrics().elidedText(, Qt::ElideNone, 30, Qt::TextWordWrap); //qDebug() << fontMetrics().elidedText(, Qt::ElideNone, 30, Qt::TextWordWrap);
setTableVisible(false); setTableVisible(false);

View File

@@ -10,7 +10,7 @@ CLineEdit::CLineEdit(QWidget * parent): QLineEdit(parent) {
cw->hide(); cw->hide();
cw->installEventFilter(this); cw->installEventFilter(this);
connect(this, SIGNAL(textChanged(QString)), this, SLOT(textChanged_(QString))); connect(this, SIGNAL(textChanged(QString)), this, SLOT(textChanged_(QString)));
int is = fontHeight(); int is = fontHeight(this);
QMargins m = textMargins(); QMargins m = textMargins();
m.setRight(m.right() + (is * 1.2)); m.setRight(m.right() + (is * 1.2));
setTextMargins(m); setTextMargins(m);
@@ -33,7 +33,7 @@ bool CLineEdit::eventFilter(QObject * o, QEvent * e) {
void CLineEdit::resizeEvent(QResizeEvent * e) { void CLineEdit::resizeEvent(QResizeEvent * e) {
QLineEdit::resizeEvent(e); QLineEdit::resizeEvent(e);
int is = fontHeight(), tm = (height() - is) / 2; int is = fontHeight(this), tm = (height() - is) / 2;
cw->setGeometry(width() - is - tm, tm, is, is); cw->setGeometry(width() - is - tm, tm, is, is);
} }

View File

@@ -70,7 +70,7 @@ bool EvalSpinBox::eventFilter(QObject * o, QEvent * e) {
void EvalSpinBox::resizeIcons() { void EvalSpinBox::resizeIcons() {
int is = fontHeight(); int is = fontHeight(this);
int tm = (lineEdit()->height() - is + 1) / 2; int tm = (lineEdit()->height() - is + 1) / 2;
QStyleOptionFrame so; QStyleOptionFrame so;
so.initFrom(lineEdit()); so.initFrom(lineEdit());

View File

@@ -85,7 +85,7 @@ QCodeEdit::QCodeEdit(QWidget * parent): QWidget(parent) {
help_visible = true; help_visible = true;
completer = new QCodeEditCompleter(); completer = new QCodeEditCompleter();
cursor_width = qMax<int>(qRound(fontHeight() / 10.), 1); cursor_width = qMax<int>(qRound(fontHeight(this) / 10.), 1);
ui->textCode->setCursorWidth(0); ui->textCode->setCursorWidth(0);
ui->textCode->viewport()->setMouseTracking(true); ui->textCode->viewport()->setMouseTracking(true);
ui->textLines->viewport()->setAutoFillBackground(false); ui->textLines->viewport()->setAutoFillBackground(false);
@@ -202,7 +202,7 @@ void QCodeEdit::setDocument(QTextDocument * doc) {
if (!qobject_cast<QPlainTextDocumentLayout*>(doc->documentLayout())) if (!qobject_cast<QPlainTextDocumentLayout*>(doc->documentLayout()))
doc->setDocumentLayout(new QPlainTextDocumentLayout(doc)); doc->setDocumentLayout(new QPlainTextDocumentLayout(doc));
ui->textCode->setDocument(doc); ui->textCode->setDocument(doc);
cursor_width = qMax<int>(qRound(fontHeight() / 10.), 1); cursor_width = qMax<int>(qRound(fontHeight(this) / 10.), 1);
ui->textCode->setCursorWidth(0); ui->textCode->setCursorWidth(0);
//ui->textCode->setCursorWidth(qMax<int>(qRound(fontHeight() / 10.), 1)); //ui->textCode->setCursorWidth(qMax<int>(qRound(fontHeight() / 10.), 1));
setShowSpaces(spaces_); setShowSpaces(spaces_);
@@ -1576,7 +1576,7 @@ void QCodeEdit::raiseHelp(QTextCursor tc, int arg) {
#endif #endif
QPoint whp; QPoint whp;
whp.setX(whr.left() - whr.width() - (widget_help->width() - whr.width()) / 2); whp.setX(whr.left() - whr.width() - (widget_help->width() - whr.width()) / 2);
whp.setY(whr.top() - widget_help->height() - (fontHeight() / 3)); whp.setY(whr.top() - widget_help->height() - (fontHeight(this) / 3));
//qDebug() << whr << whp << widget_help->width() << ", " << st; //qDebug() << whr << whp << widget_help->width() << ", " << st;
widget_help->move(ui->textCode->viewport()->mapToGlobal(whp)); widget_help->move(ui->textCode->viewport()->mapToGlobal(whp));
widget_help->show(); widget_help->show();

View File

@@ -120,5 +120,5 @@ void QCodeEditCompleter::keyPressEvent(QKeyEvent * e) {
void QCodeEditCompleter::adjust() { void QCodeEditCompleter::adjust() {
int sz = sizeHint().width(); int sz = sizeHint().width();
resize(sz, fontHeight() * 16); resize(sz, fontHeight(this) * 16);
} }

View File

@@ -31,9 +31,9 @@ RangeSlider::RangeSlider(Qt::Orientation ori, Mode m, QWidget * parent)
void RangeSlider::init() { void RangeSlider::init() {
setMouseTracking(true); setMouseTracking(true);
scHandleSideLength = 16*lineThickness(); scHandleSideLength = 16*lineThickness(this);
scSliderBarHeight = 8*lineThickness(); scSliderBarHeight = 8*lineThickness(this);
scLeftRightMargin = 2*lineThickness(); scLeftRightMargin = 2*lineThickness(this);
} }
void RangeSlider::paintEvent(QPaintEvent *) { void RangeSlider::paintEvent(QPaintEvent *) {