Skip to content

Commit

Permalink
Fit right sub widget size huxingyi#19
Browse files Browse the repository at this point in the history
  • Loading branch information
huxingyi committed Dec 2, 2018
1 parent 5704525 commit 08b20e4
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 19 deletions.
4 changes: 2 additions & 2 deletions dust3d.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 6 additions & 6 deletions src/documentwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);


Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/floatnumberwidget.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#include <QtWidgets>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "theme.h"
#include "floatnumberwidget.h"

FloatNumberWidget::FloatNumberWidget(QWidget *parent, bool singleLine) :
QWidget(parent)
{
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);
Expand Down
3 changes: 1 addition & 2 deletions src/parttreewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 14 additions & 8 deletions src/theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/theme.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Theme
static int miniIconSize;
static int sidebarPreferredWidth;
static int normalButtonSize;
static double dpi;
public:
static void initAwesomeButton(QPushButton *button);
static void initAwesomeLabel(QLabel *label);
Expand All @@ -51,6 +52,7 @@ class Theme
static void initAwesomeToolButton(QPushButton *button);
static void initAwesomeToolButtonWithoutFont(QPushButton *button);
static void initAwsomeBaseSizes();
static float dp2px(float dp);
};

#endif

0 comments on commit 08b20e4

Please sign in to comment.