Changeset View
Standalone View
src/view/kateviewhelpers.cpp
Show First 20 Lines • Show All 1420 Lines • ▼ Show 20 Line(s) | 1416 | { | |||
---|---|---|---|---|---|
1421 | // have a background, there's no need for Qt to erase the widget's area | 1421 | // have a background, there's no need for Qt to erase the widget's area | ||
1422 | // before repainting. Enabling this prevents flickering when the widget is | 1422 | // before repainting. Enabling this prevents flickering when the widget is | ||
1423 | // repainted. | 1423 | // repainted. | ||
1424 | setAttribute(Qt::WA_OpaquePaintEvent); | 1424 | setAttribute(Qt::WA_OpaquePaintEvent); | ||
1425 | 1425 | | |||
1426 | setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); | 1426 | setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); | ||
1427 | setMouseTracking(true); | 1427 | setMouseTracking(true); | ||
1428 | m_doc->setMarkDescription(MarkInterface::markType01, i18n("Bookmark")); | 1428 | m_doc->setMarkDescription(MarkInterface::markType01, i18n("Bookmark")); | ||
1429 | m_doc->setMarkPixmap(MarkInterface::markType01, QIcon::fromTheme(QStringLiteral("bookmarks")).pixmap(32, 32)); | 1429 | m_doc->setMarkIcon(MarkInterface::markType01, QIcon::fromTheme(QStringLiteral("bookmarks"))); | ||
1430 | 1430 | | |||
1431 | connect(m_annotationItemDelegate, &AbstractAnnotationItemDelegate::sizeHintChanged, this, &KateIconBorder::updateAnnotationBorderWidth); | 1431 | connect(m_annotationItemDelegate, &AbstractAnnotationItemDelegate::sizeHintChanged, this, &KateIconBorder::updateAnnotationBorderWidth); | ||
1432 | 1432 | | |||
1433 | updateFont(); | 1433 | updateFont(); | ||
1434 | 1434 | | |||
1435 | m_antiFlickerTimer.setSingleShot(true); | 1435 | m_antiFlickerTimer.setSingleShot(true); | ||
1436 | m_antiFlickerTimer.setInterval(300); | 1436 | m_antiFlickerTimer.setInterval(300); | ||
1437 | connect(&m_antiFlickerTimer, &QTimer::timeout, this, &KateIconBorder::highlightFolding); | 1437 | connect(&m_antiFlickerTimer, &QTimer::timeout, this, &KateIconBorder::highlightFolding); | ||
▲ Show 20 Lines • Show All 512 Lines • ▼ Show 20 Line(s) | 1948 | if (m_iconBorderOn) { | |||
1950 | p.setBrush(m_view->renderer()->config()->separatorColor()); | 1950 | p.setBrush(m_view->renderer()->config()->separatorColor()); | ||
1951 | p.drawLine(lnX + m_iconAreaWidth, y, lnX + m_iconAreaWidth, y + h); | 1951 | p.drawLine(lnX + m_iconAreaWidth, y, lnX + m_iconAreaWidth, y + h); | ||
1952 | 1952 | | |||
1953 | const uint mrk(m_doc->mark(realLine)); // call only once | 1953 | const uint mrk(m_doc->mark(realLine)); // call only once | ||
1954 | if (mrk && lineLayout.startCol() == 0) { | 1954 | if (mrk && lineLayout.startCol() == 0) { | ||
1955 | for (uint bit = 0; bit < 32; bit++) { | 1955 | for (uint bit = 0; bit < 32; bit++) { | ||
1956 | MarkInterface::MarkTypes markType = (MarkInterface::MarkTypes)(1 << bit); | 1956 | MarkInterface::MarkTypes markType = (MarkInterface::MarkTypes)(1 << bit); | ||
1957 | if (mrk & markType) { | 1957 | if (mrk & markType) { | ||
1958 | QPixmap px_mark(m_doc->markPixmap(markType)); | 1958 | const QIcon markIcon = m_doc->markIcon(markType); | ||
1959 | px_mark.setDevicePixelRatio(devicePixelRatioF()); | | |||
1960 | 1959 | | |||
1961 | if (!px_mark.isNull() && h > 0 && m_iconAreaWidth > 0) { | 1960 | if (!markIcon.isNull() && h > 0 && m_iconAreaWidth > 0) { | ||
1962 | // scale up to a usable size | 1961 | const int s = qMin(m_iconAreaWidth, static_cast<int>(h)) - 2; | ||
kossebau: Possibly `QIcon::paint()` might be also working here as wanted? Needs someone with HiDPI to… | |||||
dhaumann: I believe you can check yourself with proper environment variables, or? | |||||
anthonyfieroni: You should keep devicePixelRatioF calls | |||||
This is true. But in this case a non-answer: Maybe QIcon::paint does it correct as well. In other words, the code can very likely be improved, but also ok as is. dhaumann: This is true. But in this case a non-answer: Maybe QIcon::paint does it correct as well. In… | |||||
@anthonyfieroni Why exactly do you think these calls should be kept, and how? From what I understood the old code to do and tested before & after I had changed the code in the updated patch to now use QIcon::paint() instead of doing an own scaled QPixmap, the old logic used the devicePixelRatioF() calls as needed to match Qt's HiDPI support with internally bigger actual pixmaps. kossebau: @anthonyfieroni Why exactly do you think these calls should be kept, and how?
From what I… | |||||
1963 | const int s = qMin(m_iconAreaWidth * devicePixelRatioF(), h * devicePixelRatioF()) - 2; | | |||
1964 | px_mark = px_mark.scaled(s, s, Qt::KeepAspectRatio, Qt::SmoothTransformation); | | |||
1965 | 1962 | | |||
1966 | // center the mark pixmap | 1963 | // center the mark pixmap | ||
1967 | int x_px = 0.5 * qMax(m_iconAreaWidth - (s / devicePixelRatioF()), 0.0); | 1964 | const int x_px = qMax(m_iconAreaWidth - s, 0) / 2; | ||
1968 | int y_px = 0.5 * qMax(h - (s / devicePixelRatioF()), 0.0); | 1965 | const int y_px = qMax(static_cast<int>(h) - s, 0) / 2; | ||
1969 | 1966 | | |||
1970 | p.drawPixmap(lnX + x_px, y + y_px, px_mark); | 1967 | markIcon.paint(&p, lnX + x_px, y + y_px, s, s); | ||
1971 | } | 1968 | } | ||
1972 | } | 1969 | } | ||
1973 | } | 1970 | } | ||
1974 | } | 1971 | } | ||
1975 | 1972 | | |||
1976 | lnX += m_iconAreaWidth + m_separatorWidth; | 1973 | lnX += m_iconAreaWidth + m_separatorWidth; | ||
1977 | if (m_updatePositionToArea) { | 1974 | if (m_updatePositionToArea) { | ||
1978 | m_positionToArea.append(AreaPosition(lnX, IconBorder)); | 1975 | m_positionToArea.append(AreaPosition(lnX, IconBorder)); | ||
▲ Show 20 Lines • Show All 422 Lines • ▼ Show 20 Line(s) | 2382 | { | |||
2401 | for (uint bit = 0; bit < 32; bit++) { | 2398 | for (uint bit = 0; bit < 32; bit++) { | ||
2402 | MarkInterface::MarkTypes markType = (MarkInterface::MarkTypes)(1 << bit); | 2399 | MarkInterface::MarkTypes markType = (MarkInterface::MarkTypes)(1 << bit); | ||
2403 | if (!(m_doc->editableMarks() & markType)) { | 2400 | if (!(m_doc->editableMarks() & markType)) { | ||
2404 | continue; | 2401 | continue; | ||
2405 | } | 2402 | } | ||
2406 | 2403 | | |||
2407 | QAction *mA; | 2404 | QAction *mA; | ||
2408 | QAction *dMA; | 2405 | QAction *dMA; | ||
2409 | const QPixmap icon = m_doc->markPixmap(markType); | 2406 | const QIcon icon = m_doc->markIcon(markType); | ||
2410 | if (!m_doc->markDescription(markType).isEmpty()) { | 2407 | if (!m_doc->markDescription(markType).isEmpty()) { | ||
2411 | mA = markMenu.addAction(icon, m_doc->markDescription(markType)); | 2408 | mA = markMenu.addAction(icon, m_doc->markDescription(markType)); | ||
2412 | dMA = selectDefaultMark.addAction(icon, m_doc->markDescription(markType)); | 2409 | dMA = selectDefaultMark.addAction(icon, m_doc->markDescription(markType)); | ||
2413 | } else { | 2410 | } else { | ||
2414 | mA = markMenu.addAction(icon, i18n("Mark Type %1", bit + 1)); | 2411 | mA = markMenu.addAction(icon, i18n("Mark Type %1", bit + 1)); | ||
2415 | dMA = selectDefaultMark.addAction(icon, i18n("Mark Type %1", bit + 1)); | 2412 | dMA = selectDefaultMark.addAction(icon, i18n("Mark Type %1", bit + 1)); | ||
2416 | } | 2413 | } | ||
2417 | selectDefaultMarkActionGroup->addAction(dMA); | 2414 | selectDefaultMarkActionGroup->addAction(dMA); | ||
▲ Show 20 Lines • Show All 633 Lines • Show Last 20 Lines |
Possibly QIcon::paint() might be also working here as wanted? Needs someone with HiDPI to check if all things behave as wanted. The old code with all the devicePixelRatioF() made me change not too much here.