ui: Fixed icons in setup dialogs blurry on high DPI screens
This commit is contained in:
@@ -35,45 +35,21 @@ QtListItemWidget #field {
|
||||
border-top: 1px solid lightgray;
|
||||
}
|
||||
|
||||
#plusButton, #minusButton, #dotsButton, #editButton {
|
||||
#iconButton, #dotsButton, #plusButton, #minusButton, #editButton {
|
||||
border: none;
|
||||
color: white;
|
||||
height: 1em;
|
||||
margin-right: 3px;
|
||||
width: 1em;
|
||||
border: none;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
#dotsButton {
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
#plusButton {
|
||||
border-image: url(<setting:gui_path>window/plus.png);
|
||||
}
|
||||
|
||||
#plusButton:hover {
|
||||
border-image: url(<setting:gui_path>window/plus_hover.png);
|
||||
}
|
||||
|
||||
#minusButton {
|
||||
border-image: url(<setting:gui_path>window/minus.png);
|
||||
}
|
||||
|
||||
#minusButton:hover {
|
||||
border-image: url(<setting:gui_path>window/minus_hover.png);
|
||||
}
|
||||
|
||||
#dotsButton {
|
||||
border-image: url(<setting:gui_path>window/dots.png);
|
||||
}
|
||||
|
||||
#dotsButton:hover {
|
||||
border-image: url(<setting:gui_path>window/dots_hover.png);
|
||||
#plusButton, #minusButton, #editButton {
|
||||
margin-right: 3px;
|
||||
}
|
||||
|
||||
#editButton {
|
||||
border-image: url(<setting:gui_path>code_view/images/edit.png);
|
||||
margin-left: 6px;
|
||||
margin-right: 3px;
|
||||
}
|
||||
|
||||
#editButton:hover {
|
||||
@@ -82,4 +58,5 @@ QtListItemWidget #field {
|
||||
|
||||
#dropInfo {
|
||||
color: #999;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
@@ -63,35 +63,16 @@ QLabel, QCheckBox {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
#helpButton, #dotsButton, #refreshButton {
|
||||
#iconButton, #dotsButton {
|
||||
border: none;
|
||||
color: white;
|
||||
height: 1em;
|
||||
width: 1em;
|
||||
}
|
||||
|
||||
#helpButton {
|
||||
border-image: url(<setting:gui_path>window/help.png);
|
||||
}
|
||||
|
||||
#helpButton:hover {
|
||||
border-image: url(<setting:gui_path>window/help_hover.png);
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
#dotsButton {
|
||||
border-image: url(<setting:gui_path>window/dots.png);
|
||||
}
|
||||
|
||||
#dotsButton:hover {
|
||||
border-image: url(<setting:gui_path>window/dots_hover.png);
|
||||
}
|
||||
|
||||
#refreshButton {
|
||||
border-image: url(<setting:gui_path>window/refresh.png);
|
||||
}
|
||||
|
||||
#refreshButton:hover {
|
||||
border-image: url(<setting:gui_path>window/refresh_hover.png);
|
||||
margin-right: 2px;
|
||||
}
|
||||
|
||||
#name, #picker {
|
||||
@@ -119,10 +100,6 @@ QLabel, QCheckBox {
|
||||
color: black;
|
||||
}
|
||||
|
||||
#dotsButton, #refreshButton {
|
||||
margin-right: 2px;
|
||||
}
|
||||
|
||||
#windowButton {
|
||||
background: white;
|
||||
border: 1px solid lightgray;
|
||||
|
||||
@@ -34,6 +34,8 @@ add_files(
|
||||
qt/element/QtDirectoryListBox.h
|
||||
qt/element/QtFontPicker.cpp
|
||||
qt/element/QtFontPicker.h
|
||||
qt/element/QtIconButton.cpp
|
||||
qt/element/QtIconButton.h
|
||||
qt/element/QtLineEdit.cpp
|
||||
qt/element/QtLineEdit.h
|
||||
qt/element/QtLocationPicker.cpp
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "utility/ResourcePaths.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
#include "qt/element/QtIconButton.h"
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "qt/window/QtTextEditDialog.h"
|
||||
|
||||
@@ -29,8 +30,9 @@ QtListItemWidget::QtListItemWidget(QtDirectoryListBox* list, QListWidgetItem* it
|
||||
m_data->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
m_data->setObjectName("field");
|
||||
|
||||
m_button = new QPushButton("");
|
||||
m_button->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
m_button = new QtIconButton(
|
||||
(ResourcePaths::getGuiPath() + "window/dots.png").c_str(),
|
||||
(ResourcePaths::getGuiPath() + "window/dots_hover.png").c_str());
|
||||
m_button->setObjectName("dotsButton");
|
||||
|
||||
layout->addWidget(m_data);
|
||||
@@ -138,19 +140,19 @@ QtDirectoryListBox::QtDirectoryListBox(QWidget *parent, const QString& listName,
|
||||
buttonContainer->setObjectName("bar");
|
||||
|
||||
QHBoxLayout* innerLayout = new QHBoxLayout();
|
||||
innerLayout->setContentsMargins(8, 4, 8, 3);
|
||||
innerLayout->setContentsMargins(8, 4, 8, 2);
|
||||
innerLayout->setSpacing(0);
|
||||
|
||||
m_addButton = new QPushButton("", this);
|
||||
m_addButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
m_addButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
m_addButton = new QtIconButton(
|
||||
(ResourcePaths::getGuiPath() + "window/plus.png").c_str(),
|
||||
(ResourcePaths::getGuiPath() + "window/plus_hover.png").c_str());
|
||||
m_addButton->setObjectName("plusButton");
|
||||
m_addButton->setToolTip("add line");
|
||||
innerLayout->addWidget(m_addButton);
|
||||
|
||||
m_removeButton = new QPushButton("", this);
|
||||
m_removeButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
m_removeButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
m_removeButton = new QtIconButton(
|
||||
(ResourcePaths::getGuiPath() + "window/minus.png").c_str(),
|
||||
(ResourcePaths::getGuiPath() + "window/minus_hover.png").c_str());
|
||||
m_removeButton->setObjectName("minusButton");
|
||||
m_removeButton->setToolTip("remove line");
|
||||
innerLayout->addWidget(m_removeButton);
|
||||
@@ -163,9 +165,9 @@ QtDirectoryListBox::QtDirectoryListBox(QWidget *parent, const QString& listName,
|
||||
dropInfoText->setAlignment(Qt::AlignRight);
|
||||
innerLayout->addWidget(dropInfoText);
|
||||
|
||||
QPushButton* editButton = new QPushButton("", this);
|
||||
editButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
editButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
QPushButton* editButton = new QtIconButton(
|
||||
(ResourcePaths::getGuiPath() + "code_view/images/edit.png").c_str(),
|
||||
QString());
|
||||
editButton->setObjectName("editButton");
|
||||
editButton->setToolTip("edit plain text");
|
||||
innerLayout->addWidget(editButton);
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#include "qt/element/QtIconButton.h"
|
||||
|
||||
QtIconButton::QtIconButton(QString iconPath, QString hoveredIconPath, QWidget* parent)
|
||||
: QPushButton("", parent)
|
||||
, m_iconPath(iconPath)
|
||||
, m_hoveredIconPath(hoveredIconPath)
|
||||
{
|
||||
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
setMouseTracking(true);
|
||||
|
||||
setObjectName("iconButton");
|
||||
|
||||
leaveEvent(nullptr);
|
||||
}
|
||||
|
||||
void QtIconButton::enterEvent(QEvent *event)
|
||||
{
|
||||
if (m_hoveredIconPath.size())
|
||||
{
|
||||
setIcon(QIcon(QPixmap(m_hoveredIconPath)));
|
||||
}
|
||||
}
|
||||
|
||||
void QtIconButton::leaveEvent(QEvent *event)
|
||||
{
|
||||
if (m_iconPath.size())
|
||||
{
|
||||
setIcon(QIcon(QPixmap(m_iconPath)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef QT_ICON_BUTTON_H
|
||||
#define QT_ICON_BUTTON_H
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
class QtIconButton
|
||||
: public QPushButton
|
||||
{
|
||||
public:
|
||||
QtIconButton(QString iconPath, QString hoveredIconPath, QWidget* parent = nullptr);
|
||||
|
||||
protected:
|
||||
void enterEvent(QEvent *event);
|
||||
void leaveEvent(QEvent *event);
|
||||
|
||||
private:
|
||||
QString m_iconPath;
|
||||
QString m_hoveredIconPath;
|
||||
};
|
||||
|
||||
#endif // QT_ICON_BUTTON_H
|
||||
@@ -7,6 +7,10 @@
|
||||
#include <QPainter>
|
||||
#include <QStyleOption>
|
||||
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
#include "qt/element/QtIconButton.h"
|
||||
|
||||
QtLocationPicker::QtLocationPicker(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_pickDirectory(false)
|
||||
@@ -23,10 +27,11 @@ QtLocationPicker::QtLocationPicker(QWidget *parent)
|
||||
m_data->setObjectName("locationField");
|
||||
layout->addWidget(m_data);
|
||||
|
||||
m_button = new QPushButton("");
|
||||
m_button = new QtIconButton(
|
||||
(ResourcePaths::getGuiPath() + "window/dots.png").c_str(),
|
||||
(ResourcePaths::getGuiPath() + "window/dots_hover.png").c_str());
|
||||
m_button->setObjectName("dotsButton");
|
||||
m_button->setToolTip("pick file");
|
||||
m_button->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
connect(m_button, SIGNAL(clicked()), this, SLOT(handleButtonPress()));
|
||||
layout->addWidget(m_button);
|
||||
|
||||
|
||||
@@ -3,17 +3,24 @@
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "qt/window/QtTextEditDialog.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
QtHelpButton::QtHelpButton(const QString& helpText, QWidget* parent)
|
||||
: QPushButton("", parent)
|
||||
: QtIconButton(
|
||||
(ResourcePaths::getGuiPath() + "window/help.png").c_str(),
|
||||
(ResourcePaths::getGuiPath() + "window/help_hover.png").c_str(),
|
||||
parent)
|
||||
, m_helpText(helpText)
|
||||
{
|
||||
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
setObjectName("helpButton");
|
||||
setMouseTracking(true);
|
||||
|
||||
setToolTip("help");
|
||||
|
||||
leaveEvent(nullptr);
|
||||
|
||||
connect(this, SIGNAL(clicked()), this, SLOT(handleHelpPress()));
|
||||
}
|
||||
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QToolButton>
|
||||
#include <QWidget>
|
||||
|
||||
#include "qt/element/QtIconButton.h"
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardWindow.h"
|
||||
#include "settings/ProjectSettings.h"
|
||||
|
||||
class QtTextEditDialog;
|
||||
|
||||
class QtHelpButton
|
||||
: public QPushButton
|
||||
: public QtIconButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
#include "qt/element/QtIconButton.h"
|
||||
#include "qt/element/QtLocationPicker.h"
|
||||
#include "settings/CxxProjectSettings.h"
|
||||
|
||||
@@ -59,9 +62,9 @@ void QtProjectWizzardContentBuildFile::populate(QGridLayout* layout, int& row)
|
||||
m_picker->setFileFilter(filter);
|
||||
m_picker->setRelativeRootDirectory(m_settings->getProjectFileLocation());
|
||||
|
||||
QPushButton* button = new QPushButton("", this);
|
||||
button->setObjectName("refreshButton");
|
||||
button->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
QPushButton* button = new QtIconButton(
|
||||
(ResourcePaths::getGuiPath() + "window/refresh.png").c_str(),
|
||||
(ResourcePaths::getGuiPath() + "window/refresh_hover.png").c_str());
|
||||
button->setToolTip("refresh paths");
|
||||
connect(button, SIGNAL(clicked()), this, SLOT(refreshClicked()));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user