Fix toolbar icon size #19

master
Jeremy Hu 2018-12-03 22:56:20 +09:30
parent 08b20e4d5b
commit 251e1f5a6e
5 changed files with 16 additions and 28 deletions

View File

@ -4,10 +4,10 @@ DEFINES += NDEBUG
RESOURCES += resources.qrc RESOURCES += resources.qrc
isEmpty(HUMAN_VERSION) { isEmpty(HUMAN_VERSION) {
HUMAN_VERSION = "1.0.0-beta.9" HUMAN_VERSION = "1.0.0-beta.10"
} }
isEmpty(VERSION) { isEmpty(VERSION) {
VERSION = 1.0.0.9 VERSION = 1.0.0.10
} }
REPOSITORY_URL = "https://github.com/huxingyi/dust3d" REPOSITORY_URL = "https://github.com/huxingyi/dust3d"

View File

@ -117,7 +117,7 @@ DocumentWindow::DocumentWindow() :
QVBoxLayout *toolButtonLayout = new QVBoxLayout; QVBoxLayout *toolButtonLayout = new QVBoxLayout;
toolButtonLayout->setSpacing(0); toolButtonLayout->setSpacing(0);
toolButtonLayout->setContentsMargins(Theme::dp2px(5), Theme::dp2px(10), Theme::dp2px(4), 0); toolButtonLayout->setContentsMargins(5, 10, 4, 0);
QPushButton *addButton = new QPushButton(QChar(fa::plus)); QPushButton *addButton = new QPushButton(QChar(fa::plus));
Theme::initAwesomeButton(addButton); Theme::initAwesomeButton(addButton);
@ -177,15 +177,15 @@ DocumentWindow::DocumentWindow() :
toolButtonLayout->addWidget(dragButton); toolButtonLayout->addWidget(dragButton);
toolButtonLayout->addWidget(zoomInButton); toolButtonLayout->addWidget(zoomInButton);
toolButtonLayout->addWidget(zoomOutButton); toolButtonLayout->addWidget(zoomOutButton);
toolButtonLayout->addSpacing(Theme::dp2px(10)); toolButtonLayout->addSpacing(10);
toolButtonLayout->addWidget(m_xlockButton); toolButtonLayout->addWidget(m_xlockButton);
toolButtonLayout->addWidget(m_ylockButton); toolButtonLayout->addWidget(m_ylockButton);
toolButtonLayout->addWidget(m_zlockButton); toolButtonLayout->addWidget(m_zlockButton);
toolButtonLayout->addWidget(m_radiusLockButton); toolButtonLayout->addWidget(m_radiusLockButton);
toolButtonLayout->addSpacing(Theme::dp2px(10)); toolButtonLayout->addSpacing(10);
toolButtonLayout->addWidget(rotateCounterclockwiseButton); toolButtonLayout->addWidget(rotateCounterclockwiseButton);
toolButtonLayout->addWidget(rotateClockwiseButton); toolButtonLayout->addWidget(rotateClockwiseButton);
toolButtonLayout->addSpacing(Theme::dp2px(10)); toolButtonLayout->addSpacing(10);
toolButtonLayout->addWidget(regenerateButton); toolButtonLayout->addWidget(regenerateButton);
@ -204,7 +204,7 @@ DocumentWindow::DocumentWindow() :
mainLeftLayout->addLayout(toolButtonLayout); mainLeftLayout->addLayout(toolButtonLayout);
mainLeftLayout->addStretch(); mainLeftLayout->addStretch();
mainLeftLayout->addLayout(logoLayout); mainLeftLayout->addLayout(logoLayout);
mainLeftLayout->addSpacing(Theme::dp2px(10)); mainLeftLayout->addSpacing(10);
SkeletonGraphicsWidget *graphicsWidget = new SkeletonGraphicsWidget(m_document); SkeletonGraphicsWidget *graphicsWidget = new SkeletonGraphicsWidget(m_document);
m_graphicsWidget = graphicsWidget; m_graphicsWidget = graphicsWidget;
@ -298,7 +298,7 @@ DocumentWindow::DocumentWindow() :
mainLayout->setContentsMargins(0, 0, 0, 0); mainLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->addLayout(mainLeftLayout); mainLayout->addLayout(mainLeftLayout);
mainLayout->addWidget(containerWidget); mainLayout->addWidget(containerWidget);
mainLayout->addSpacing(Theme::dp2px(3)); mainLayout->addSpacing(3);
QWidget *centralWidget = new QWidget; QWidget *centralWidget = new QWidget;
centralWidget->setLayout(mainLayout); centralWidget->setLayout(mainLayout);

View File

@ -9,7 +9,7 @@ FloatNumberWidget::FloatNumberWidget(QWidget *parent, bool singleLine) :
{ {
m_slider = new QSlider(Qt::Horizontal, this); m_slider = new QSlider(Qt::Horizontal, this);
m_slider->setRange(0, 100); m_slider->setRange(0, 100);
m_slider->setFixedWidth(Theme::dp2px(120)); m_slider->setFixedWidth(120);
m_label = new QLabel(this); m_label = new QLabel(this);
m_label->setAlignment(Qt::AlignLeft); m_label->setAlignment(Qt::AlignLeft);

View File

@ -1,7 +1,7 @@
#include <QApplication> #include <QApplication>
#include <QGuiApplication> #include <QGuiApplication>
#include <QDebug> #include <QDebug>
#include <QScreen> #include <QFontMetrics>
#include "theme.h" #include "theme.h"
// Red // Red
@ -43,30 +43,20 @@ int Theme::posePreviewImageSize = 0;
int Theme::motionPreviewImageSize = 0; int Theme::motionPreviewImageSize = 0;
int Theme::sidebarPreferredWidth = 0; int Theme::sidebarPreferredWidth = 0;
int Theme::normalButtonSize = 0; int Theme::normalButtonSize = 0;
double Theme::dpi = 0;
float Theme::dp2px(float dp)
{
return dp / 72 * Theme::dpi;
}
void Theme::initAwsomeBaseSizes() void Theme::initAwsomeBaseSizes()
{ {
Theme::dpi = QGuiApplication::primaryScreen()->physicalDotsPerInch(); QFontMetrics fontMetrics(QApplication::font());
Theme::toolIconFontSize = fontMetrics.height();
Theme::toolIconFontSize = QApplication::font().pixelSize();
if (-1 == Theme::toolIconFontSize) {
Theme::toolIconFontSize = Theme::dp2px(QApplication::font().pointSize());
}
Theme::toolIconSize = (int)(Theme::toolIconFontSize * 1.5); Theme::toolIconSize = (int)(Theme::toolIconFontSize * 1.5);
Theme::miniIconFontSize = (int)(Theme::toolIconFontSize * 0.64); Theme::miniIconFontSize = (int)(Theme::toolIconFontSize * 0.64);
Theme::miniIconSize = (int)(Theme::miniIconFontSize * 1.67); Theme::miniIconSize = (int)(Theme::miniIconFontSize * 1.67);
Theme::partPreviewImageSize = (Theme::miniIconSize * 3); Theme::partPreviewImageSize = (Theme::miniIconSize * 3);
Theme::materialPreviewImageSize = Theme::dp2px(62); Theme::materialPreviewImageSize = 75;
Theme::posePreviewImageSize = Theme::dp2px(62); Theme::posePreviewImageSize = 75;
Theme::motionPreviewImageSize = Theme::dp2px(62); Theme::motionPreviewImageSize = 75;
Theme::sidebarPreferredWidth = Theme::dp2px(150); Theme::sidebarPreferredWidth = 200;
Theme::normalButtonSize = Theme::toolIconSize * 2; Theme::normalButtonSize = Theme::toolIconSize * 2;
qDebug() << "Theme::toolIconFontSize:" << Theme::toolIconFontSize; qDebug() << "Theme::toolIconFontSize:" << Theme::toolIconFontSize;

View File

@ -42,7 +42,6 @@ public:
static int miniIconSize; static int miniIconSize;
static int sidebarPreferredWidth; static int sidebarPreferredWidth;
static int normalButtonSize; static int normalButtonSize;
static double dpi;
public: public:
static void initAwesomeButton(QPushButton *button); static void initAwesomeButton(QPushButton *button);
static void initAwesomeLabel(QLabel *label); static void initAwesomeLabel(QLabel *label);
@ -52,7 +51,6 @@ public:
static void initAwesomeToolButton(QPushButton *button); static void initAwesomeToolButton(QPushButton *button);
static void initAwesomeToolButtonWithoutFont(QPushButton *button); static void initAwesomeToolButtonWithoutFont(QPushButton *button);
static void initAwsomeBaseSizes(); static void initAwsomeBaseSizes();
static float dp2px(float dp);
}; };
#endif #endif