mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
Take care of QToolButton not handling hdpi properly
This commit is contained in:
parent
565bc3a5d0
commit
08021ba9a8
@ -21,9 +21,12 @@ YACReaderLibraryItemWidget::YACReaderLibraryItemWidget(QString n /*ame*/, QStrin
|
|||||||
nameLabel = new QLabel(name, this);
|
nameLabel = new QLabel(name, this);
|
||||||
|
|
||||||
options = new QToolButton(this);
|
options = new QToolButton(this);
|
||||||
#ifdef Q_OS_MAC
|
|
||||||
// TODO fix this crazy hack for having a propper retina icon for the options
|
// TODO fix this crazy hack for having a propper retina icon for the options, this is still a problem in 2022
|
||||||
// this hack has been perpetrated using Qt 5.5.0
|
// 1.- QPixmap won't pick the right @2x asset
|
||||||
|
// 2.- Using QToolButton::setIcon(QIcon(":/images/sidebar/libraryOptions.png")) will pick the right asset and then QToolButton will fail to set the right image size, it will use a image size twice bigger
|
||||||
|
// 3.- Using a QAction + QToolButton doesn't fix the problem either
|
||||||
|
// 4.- SVG support is also buggy QTBUG-96553
|
||||||
QString sourceOptionsImage;
|
QString sourceOptionsImage;
|
||||||
if (devicePixelRatioF() > 1)
|
if (devicePixelRatioF() > 1)
|
||||||
sourceOptionsImage = ":/images/sidebar/libraryOptions@2x.png";
|
sourceOptionsImage = ":/images/sidebar/libraryOptions@2x.png";
|
||||||
@ -32,15 +35,12 @@ YACReaderLibraryItemWidget::YACReaderLibraryItemWidget(QString n /*ame*/, QStrin
|
|||||||
QPixmap iconOptionsPixmap(sourceOptionsImage);
|
QPixmap iconOptionsPixmap(sourceOptionsImage);
|
||||||
iconOptionsPixmap.setDevicePixelRatio(devicePixelRatioF());
|
iconOptionsPixmap.setDevicePixelRatio(devicePixelRatioF());
|
||||||
QLabel *helperLabel = new QLabel(options);
|
QLabel *helperLabel = new QLabel(options);
|
||||||
helperLabel->move(4, 2);
|
helperLabel->move(4, 3);
|
||||||
helperLabel->setFixedSize(14, 14);
|
helperLabel->setFixedSize(14, 14);
|
||||||
helperLabel->setPixmap(iconOptionsPixmap);
|
helperLabel->setPixmap(iconOptionsPixmap);
|
||||||
#else
|
|
||||||
options->setIcon(QIcon(":/images/sidebar/libraryOptions.png"));
|
|
||||||
#endif
|
|
||||||
options->setHidden(true);
|
options->setHidden(true);
|
||||||
options->setFixedWidth(18);
|
options->setIconSize(QSize(18, 18));
|
||||||
options->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
|
|
||||||
options->setStyleSheet("QToolButton {border:none;}");
|
options->setStyleSheet("QToolButton {border:none;}");
|
||||||
connect(options, &QAbstractButton::clicked, this, &YACReaderLibraryItemWidget::showOptions);
|
connect(options, &QAbstractButton::clicked, this, &YACReaderLibraryItemWidget::showOptions);
|
||||||
/*up = new QToolButton(this);
|
/*up = new QToolButton(this);
|
||||||
@ -56,9 +56,8 @@ YACReaderLibraryItemWidget::YACReaderLibraryItemWidget(QString n /*ame*/, QStrin
|
|||||||
down->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Minimum);*/
|
down->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Minimum);*/
|
||||||
|
|
||||||
mainLayout->addWidget(icon);
|
mainLayout->addWidget(icon);
|
||||||
mainLayout->addWidget(nameLabel, Qt::AlignLeft);
|
mainLayout->addWidget(nameLabel, 1, Qt::AlignLeft);
|
||||||
mainLayout->addStretch();
|
mainLayout->addWidget(options, Qt::AlignCenter);
|
||||||
mainLayout->addWidget(options);
|
|
||||||
/*mainLayout->addWidget(up);
|
/*mainLayout->addWidget(up);
|
||||||
mainLayout->addWidget(down);*/
|
mainLayout->addWidget(down);*/
|
||||||
|
|
||||||
@ -75,6 +74,7 @@ YACReaderLibraryItemWidget::YACReaderLibraryItemWidget(QString n /*ame*/, QStrin
|
|||||||
nameLabel->setStyleSheet(nameLabelStyleSheet);
|
nameLabel->setStyleSheet(nameLabelStyleSheet);
|
||||||
|
|
||||||
setMinimumHeight(20);
|
setMinimumHeight(20);
|
||||||
|
setAttribute(Qt::WA_StyledBackground, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void YACReaderLibraryItemWidget::showUpDownButtons(bool show)
|
void YACReaderLibraryItemWidget::showUpDownButtons(bool show)
|
||||||
|
Loading…
Reference in New Issue
Block a user