Fit right sub widget size #19

master
Jeremy Hu 2018-12-02 23:16:04 +09:30
parent 5704525505
commit 08b20e4d5b
6 changed files with 27 additions and 19 deletions

View File

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

View File

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

View File

@ -1,6 +1,7 @@
#include <QtWidgets>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "theme.h"
#include "floatnumberwidget.h"
FloatNumberWidget::FloatNumberWidget(QWidget *parent, bool singleLine) :
@ -8,7 +9,7 @@ FloatNumberWidget::FloatNumberWidget(QWidget *parent, bool singleLine) :
{
m_slider = new QSlider(Qt::Horizontal, this);
m_slider->setRange(0, 100);
m_slider->setFixedWidth(120);
m_slider->setFixedWidth(Theme::dp2px(120));
m_label = new QLabel(this);
m_label->setAlignment(Qt::AlignLeft);

View File

@ -963,8 +963,7 @@ void PartTreeWidget::partUnchecked(QUuid partId)
QSize PartTreeWidget::sizeHint() const
{
QSize size = PartWidget::preferredSize();
return QSize(size.width() * 1.35, size.height() * 5.5);
return QSize(Theme::sidebarPreferredWidth, 0);
}
bool PartTreeWidget::isComponentSelected(QUuid componentId)

View File

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

View File

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