mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Properly scale some icons for HiDPI (#12695)
This commit is contained in:
parent
5f7ae3ade5
commit
8863d6d785
@ -114,6 +114,7 @@
|
|||||||
#include <QSocketNotifier>
|
#include <QSocketNotifier>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
|
#include <QSvgRenderer>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QThreadPool>
|
#include <QThreadPool>
|
||||||
@ -2666,6 +2667,30 @@ bool GuiApplication::unhide(Buffer * buf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QPixmap GuiApplication::getScaledPixmap(QString imagedir, QString name) const
|
||||||
|
{
|
||||||
|
qreal dpr = 1.0;
|
||||||
|
// Consider device/pixel ratio (HiDPI)
|
||||||
|
if (currentView())
|
||||||
|
dpr = currentView()->devicePixelRatio();
|
||||||
|
// We render SVG directly for HiDPI scalability
|
||||||
|
QPixmap pm = getPixmap(imagedir, name, "svgz,png");
|
||||||
|
FileName fname = imageLibFileSearch(imagedir, name, "svgz,png");
|
||||||
|
QString fpath = toqstr(fname.absFileName());
|
||||||
|
if (!fpath.isEmpty()) {
|
||||||
|
QSvgRenderer svgRenderer(fpath);
|
||||||
|
if (svgRenderer.isValid()) {
|
||||||
|
pm = QPixmap(pm.size() * dpr);
|
||||||
|
pm.fill(Qt::transparent);
|
||||||
|
QPainter painter(&pm);
|
||||||
|
svgRenderer.render(&painter);
|
||||||
|
pm.setDevicePixelRatio(dpr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pm;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Clipboard & GuiApplication::clipboard()
|
Clipboard & GuiApplication::clipboard()
|
||||||
{
|
{
|
||||||
return d->clipboard_;
|
return d->clipboard_;
|
||||||
|
@ -94,6 +94,9 @@ public:
|
|||||||
/// Return true if current position is RTL of if no document is open and interface if RTL
|
/// Return true if current position is RTL of if no document is open and interface if RTL
|
||||||
bool rtlContext() const;
|
bool rtlContext() const;
|
||||||
|
|
||||||
|
/// Scale Pixmaps properly (also for HiDPI)
|
||||||
|
QPixmap getScaledPixmap(QString imagedir, QString name) const;
|
||||||
|
|
||||||
///
|
///
|
||||||
Clipboard & clipboard();
|
Clipboard & clipboard();
|
||||||
///
|
///
|
||||||
|
@ -614,7 +614,8 @@ void PreambleModule::editExternal() {
|
|||||||
preambleTE->setReadOnly(true);
|
preambleTE->setReadOnly(true);
|
||||||
theFormats().edit(*current_id_, tempfilename, format);
|
theFormats().edit(*current_id_, tempfilename, format);
|
||||||
editPB->setText(qt_("&End Edit"));
|
editPB->setText(qt_("&End Edit"));
|
||||||
QIcon warn(getPixmap("images/", "emblem-shellescape", "svgz,png"));
|
QIcon warn(guiApp ? guiApp->getScaledPixmap("images/", "emblem-shellescape-user")
|
||||||
|
: getPixmap("images/", "emblem-shellescape", "svgz,png"));
|
||||||
editPB->setIcon(warn);
|
editPB->setIcon(warn);
|
||||||
changed();
|
changed();
|
||||||
}
|
}
|
||||||
@ -793,7 +794,8 @@ void LocalLayout::editExternal() {
|
|||||||
locallayoutTE->setReadOnly(true);
|
locallayoutTE->setReadOnly(true);
|
||||||
theFormats().edit(*current_id_, tempfilename, format);
|
theFormats().edit(*current_id_, tempfilename, format);
|
||||||
editPB->setText(qt_("&End Edit"));
|
editPB->setText(qt_("&End Edit"));
|
||||||
QIcon warn(getPixmap("images/", "emblem-shellescape", "svgz,png"));
|
QIcon warn(guiApp ? guiApp->getScaledPixmap("images/", "emblem-shellescape-user")
|
||||||
|
: getPixmap("images/", "emblem-shellescape", "svgz,png"));
|
||||||
editPB->setIcon(warn);
|
editPB->setIcon(warn);
|
||||||
validatePB->setEnabled(false);
|
validatePB->setEnabled(false);
|
||||||
hideConvert();
|
hideConvert();
|
||||||
@ -1960,8 +1962,10 @@ void GuiDocument::filterModules(QString const & str)
|
|||||||
return 0 < b.name.localeAwareCompare(a.name);
|
return 0 < b.name.localeAwareCompare(a.name);
|
||||||
});
|
});
|
||||||
|
|
||||||
QIcon user_icon(getPixmap("images/", "lyxfiles-user", "svgz,png"));
|
QIcon user_icon(guiApp ? guiApp->getScaledPixmap("images/", "lyxfiles-user")
|
||||||
QIcon system_icon(getPixmap("images/", "lyxfiles-system", "svgz,png"));
|
: getPixmap("images/", "lyxfiles-user", "svgz,png"));
|
||||||
|
QIcon system_icon(guiApp ? guiApp->getScaledPixmap("images/", "lyxfiles-system")
|
||||||
|
: getPixmap("images/", "lyxfiles-system", "svgz,png"));
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (modInfoStruct const & m : modInfoList) {
|
for (modInfoStruct const & m : modInfoList) {
|
||||||
@ -4672,8 +4676,10 @@ void GuiDocument::updateAvailableModules()
|
|||||||
modInfoList.sort([](modInfoStruct const & a, modInfoStruct const & b) {
|
modInfoList.sort([](modInfoStruct const & a, modInfoStruct const & b) {
|
||||||
return 0 < b.name.localeAwareCompare(a.name);
|
return 0 < b.name.localeAwareCompare(a.name);
|
||||||
});
|
});
|
||||||
QIcon user_icon(getPixmap("images/", "lyxfiles-user", "svgz,png"));
|
QIcon user_icon(guiApp ? guiApp->getScaledPixmap("images/", "lyxfiles-user")
|
||||||
QIcon system_icon(getPixmap("images/", "lyxfiles-system", "svgz,png"));
|
: getPixmap("images/", "lyxfiles-user", "svgz,png"));
|
||||||
|
QIcon system_icon(guiApp ? guiApp->getScaledPixmap("images/", "lyxfiles-system")
|
||||||
|
: getPixmap("images/", "lyxfiles-system", "svgz,png"));
|
||||||
int i = 0;
|
int i = 0;
|
||||||
QFont catfont;
|
QFont catfont;
|
||||||
catfont.setBold(true);
|
catfont.setBold(true);
|
||||||
|
@ -214,8 +214,10 @@ GuiLyXFiles::GuiLyXFiles(GuiView & lv)
|
|||||||
//filesLW->setViewMode(QListView::ListMode);
|
//filesLW->setViewMode(QListView::ListMode);
|
||||||
filesLW->setIconSize(QSize(22, 22));
|
filesLW->setIconSize(QSize(22, 22));
|
||||||
|
|
||||||
QIcon user_icon(getPixmap("images/", "lyxfiles-user", "svgz,png"));
|
QIcon user_icon(guiApp ? guiApp->getScaledPixmap("images/", "lyxfiles-user")
|
||||||
QIcon system_icon(getPixmap("images/", "lyxfiles-system", "svgz,png"));
|
: getPixmap("images/", "lyxfiles-user", "svgz,png"));
|
||||||
|
QIcon system_icon(guiApp ? guiApp->getScaledPixmap("images/", "lyxfiles-system")
|
||||||
|
: getPixmap("images/", "lyxfiles-system", "svgz,png"));
|
||||||
fileTypeCO->addItem(qt_("User and System Files"), toqstr("all"));
|
fileTypeCO->addItem(qt_("User and System Files"), toqstr("all"));
|
||||||
fileTypeCO->addItem(user_icon, qt_("User Files Only"), toqstr("user"));
|
fileTypeCO->addItem(user_icon, qt_("User Files Only"), toqstr("user"));
|
||||||
fileTypeCO->addItem(system_icon, qt_("System Files Only"), toqstr("system"));
|
fileTypeCO->addItem(system_icon, qt_("System Files Only"), toqstr("system"));
|
||||||
@ -308,8 +310,10 @@ void GuiLyXFiles::on_filesLW_itemClicked(QTreeWidgetItem * item, int)
|
|||||||
setLanguage();
|
setLanguage();
|
||||||
QString const realpath = getRealPath();
|
QString const realpath = getRealPath();
|
||||||
filesLW->currentItem()->setData(0, Qt::ToolTipRole, realpath);
|
filesLW->currentItem()->setData(0, Qt::ToolTipRole, realpath);
|
||||||
QIcon user_icon(getPixmap("images/", "lyxfiles-user", "svgz,png"));
|
QIcon user_icon(guiApp ? guiApp->getScaledPixmap("images/", "lyxfiles-user")
|
||||||
QIcon system_icon(getPixmap("images/", "lyxfiles-system", "svgz,png"));
|
: getPixmap("images/", "lyxfiles-user", "svgz,png"));
|
||||||
|
QIcon system_icon(guiApp ? guiApp->getScaledPixmap("images/", "lyxfiles-system")
|
||||||
|
: getPixmap("images/", "lyxfiles-system", "svgz,png"));
|
||||||
QIcon file_icon = (realpath.startsWith(toqstr(package().user_support().absFileName()))) ?
|
QIcon file_icon = (realpath.startsWith(toqstr(package().user_support().absFileName()))) ?
|
||||||
user_icon : system_icon;
|
user_icon : system_icon;
|
||||||
item->setIcon(0, file_icon);
|
item->setIcon(0, file_icon);
|
||||||
@ -410,10 +414,16 @@ void GuiLyXFiles::updateContents()
|
|||||||
languageCO->model()->sort(0);
|
languageCO->model()->sort(0);
|
||||||
|
|
||||||
filesLW->clear();
|
filesLW->clear();
|
||||||
QIcon user_icon(getPixmap("images/", "lyxfiles-user", "svgz,png"));
|
|
||||||
QIcon system_icon(getPixmap("images/", "lyxfiles-system", "svgz,png"));
|
QIcon user_icon(guiApp ? guiApp->getScaledPixmap("images/", "lyxfiles-user")
|
||||||
QIcon user_folder_icon(getPixmap("images/", "lyxfiles-user-folder", "svgz,png"));
|
: getPixmap("images/", "lyxfiles-user", "svgz,png"));
|
||||||
QIcon system_folder_icon(getPixmap("images/", "lyxfiles-system-folder", "svgz,png"));
|
QIcon system_icon(guiApp ? guiApp->getScaledPixmap("images/", "lyxfiles-system")
|
||||||
|
: getPixmap("images/", "lyxfiles-system", "svgz,png"));
|
||||||
|
QIcon user_folder_icon(guiApp ? guiApp->getScaledPixmap("images/", "lyxfiles-user-folder")
|
||||||
|
: getPixmap("images/", "lyxfiles-user-folder", "svgz,png"));
|
||||||
|
QIcon system_folder_icon(guiApp ? guiApp->getScaledPixmap("images/", "lyxfiles-system-folder")
|
||||||
|
: getPixmap("images/", "lyxfiles-system-folder", "svgz,png"));
|
||||||
|
|
||||||
QStringList cats;
|
QStringList cats;
|
||||||
QMap<QString, QString>::const_iterator it = files.constBegin();
|
QMap<QString, QString>::const_iterator it = files.constBegin();
|
||||||
QFont capfont;
|
QFont capfont;
|
||||||
|
@ -155,7 +155,8 @@ void PanelStack::markPanelValid(QString const & name, bool valid)
|
|||||||
item->setIcon(0, QIcon());
|
item->setIcon(0, QIcon());
|
||||||
item->setToolTip(0, QString());
|
item->setToolTip(0, QString());
|
||||||
} else {
|
} else {
|
||||||
QIcon warn(getPixmap("images/", "emblem-shellescape", "svgz,png"));
|
QIcon warn(guiApp ? guiApp->getScaledPixmap("images/", "emblem-shellescape-user")
|
||||||
|
: getPixmap("images/", "emblem-shellescape", "svgz,png"));
|
||||||
item->setIcon(0, warn);
|
item->setIcon(0, warn);
|
||||||
item->setToolTip(0, qt_("This section contains invalid input. Please fix!"));
|
item->setToolTip(0, qt_("This section contains invalid input. Please fix!"));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user