mirror of
https://github.com/leozide/leocad
synced 2024-12-26 21:58:44 +01:00
Added Page Setup controls.
This commit is contained in:
parent
5c2a5aa167
commit
f4461756bd
7 changed files with 214 additions and 10 deletions
88
common/lc_collapsiblewidget.cpp
Normal file
88
common/lc_collapsiblewidget.cpp
Normal file
|
@ -0,0 +1,88 @@
|
|||
#include "lc_global.h"
|
||||
#include "lc_collapsiblewidget.h"
|
||||
|
||||
QImage lcCollapsibleWidget::mExpandedIcon;
|
||||
QImage lcCollapsibleWidget::mCollapsedIcon;
|
||||
|
||||
lcCollapsibleWidget::lcCollapsibleWidget(const QString& Title, QWidget* Parent)
|
||||
: QWidget(Parent)
|
||||
{
|
||||
QVBoxLayout* Layout = new QVBoxLayout(this);
|
||||
// Layout->setSpacing(0);
|
||||
Layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
QHBoxLayout* TitleLayout = new QHBoxLayout();
|
||||
TitleLayout->setContentsMargins(0, 0, 0, 0);
|
||||
Layout->addLayout(TitleLayout);
|
||||
|
||||
mTitleButton = new QToolButton(this);
|
||||
mTitleButton->setText(Title);
|
||||
mTitleButton->setAutoRaise(true);
|
||||
mTitleButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||
mTitleButton->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
|
||||
TitleLayout->addWidget(mTitleButton);
|
||||
|
||||
connect(mTitleButton, SIGNAL(clicked()), this, SLOT(TitleClicked()));
|
||||
|
||||
mChildWidget = new QWidget(this);
|
||||
Layout->addWidget(mChildWidget);
|
||||
|
||||
UpdateIcon();
|
||||
}
|
||||
|
||||
void lcCollapsibleWidget::TitleClicked()
|
||||
{
|
||||
mExpanded = !mExpanded;
|
||||
mChildWidget->setVisible(mExpanded);
|
||||
UpdateIcon();
|
||||
}
|
||||
|
||||
void lcCollapsibleWidget::Collapse()
|
||||
{
|
||||
if (mExpanded)
|
||||
TitleClicked();
|
||||
}
|
||||
|
||||
void lcCollapsibleWidget::SetChildLayout(QLayout* Layout)
|
||||
{
|
||||
Layout->setContentsMargins(12, 0, 0, 0);
|
||||
mChildWidget->setLayout(Layout);
|
||||
}
|
||||
|
||||
void lcCollapsibleWidget::UpdateIcon()
|
||||
{
|
||||
if (mExpanded)
|
||||
{
|
||||
if (mExpandedIcon.isNull())
|
||||
{
|
||||
QImage Image(16, 16, QImage::Format::Format_ARGB32);
|
||||
Image.fill(QColor(0, 0, 0, 0));
|
||||
QColor Color(palette().color(QPalette::Text));
|
||||
|
||||
for (int y = 0; y < 8; y++)
|
||||
for (int x = y; x < 8 - y; x++)
|
||||
Image.setPixelColor(x + 4, y + 6, Color);
|
||||
|
||||
mExpandedIcon = Image;
|
||||
}
|
||||
|
||||
mTitleButton->setIcon(QPixmap::fromImage(mExpandedIcon));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mCollapsedIcon.isNull())
|
||||
{
|
||||
QImage Image(16, 16, QImage::Format::Format_ARGB32);
|
||||
Image.fill(QColor(0, 0, 0, 0));
|
||||
QColor Color(palette().color(QPalette::Text));
|
||||
|
||||
for (int y = 0; y < 8; y++)
|
||||
for (int x = y; x < 8 - y; x++)
|
||||
Image.setPixelColor(y + 6, x + 4, Color);
|
||||
|
||||
mCollapsedIcon = Image;
|
||||
}
|
||||
|
||||
mTitleButton->setIcon(QPixmap::fromImage(mCollapsedIcon));
|
||||
}
|
||||
}
|
25
common/lc_collapsiblewidget.h
Normal file
25
common/lc_collapsiblewidget.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
#pragma once
|
||||
|
||||
class lcCollapsibleWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
lcCollapsibleWidget(const QString& RootTitle, QWidget* Parent = nullptr);
|
||||
|
||||
void Collapse();
|
||||
void SetChildLayout(QLayout* Layout);
|
||||
|
||||
protected slots:
|
||||
void TitleClicked();
|
||||
|
||||
protected:
|
||||
void UpdateIcon();
|
||||
|
||||
QToolButton* mTitleButton = nullptr;
|
||||
QWidget* mChildWidget = nullptr;
|
||||
bool mExpanded = true;
|
||||
|
||||
static QImage mExpandedIcon;
|
||||
static QImage mCollapsedIcon;
|
||||
};
|
|
@ -86,6 +86,7 @@ class lcVector4;
|
|||
class lcMatrix33;
|
||||
class lcMatrix44;
|
||||
|
||||
class lcCollapsibleWidget;
|
||||
class lcViewWidget;
|
||||
class lcView;
|
||||
class lcContext;
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#include "lc_global.h"
|
||||
#include "lc_instructionsdialog.h"
|
||||
#include "lc_collapsiblewidget.h"
|
||||
#include "project.h"
|
||||
#include "lc_model.h"
|
||||
#include "lc_qutils.h"
|
||||
|
||||
lcInstructionsPageWidget::lcInstructionsPageWidget(QWidget* Parent)
|
||||
: QGraphicsView(Parent)
|
||||
|
@ -43,9 +45,77 @@ lcInstructionsPageListWidget::lcInstructionsPageListWidget(QWidget* Parent)
|
|||
setWidget(CentralWidget);
|
||||
setWindowTitle(tr("Pages"));
|
||||
|
||||
QHBoxLayout* Layout = new QHBoxLayout(CentralWidget);
|
||||
QVBoxLayout* Layout = new QVBoxLayout(CentralWidget);
|
||||
Layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
lcCollapsibleWidget* SetupWidget = new lcCollapsibleWidget(tr("Page Setup"), CentralWidget);
|
||||
Layout->addWidget(SetupWidget);
|
||||
|
||||
QVBoxLayout* SetupLayout = new QVBoxLayout();
|
||||
SetupWidget->SetChildLayout(SetupLayout);
|
||||
|
||||
lcCollapsibleWidget* SizeWidget = new lcCollapsibleWidget(tr("Size"));
|
||||
SetupLayout->addWidget(SizeWidget);
|
||||
|
||||
QGridLayout* SizeLayout = new QGridLayout();
|
||||
SizeWidget->SetChildLayout(SizeLayout);
|
||||
|
||||
mSizeComboBox = new QComboBox();
|
||||
SizeLayout->addWidget(mSizeComboBox, 0, 0, 1, -1);
|
||||
|
||||
mWidthEdit = new lcSmallLineEdit();
|
||||
SizeLayout->addWidget(new QLabel(tr("Width:")), 1, 0);
|
||||
SizeLayout->addWidget(mWidthEdit, 1, 1);
|
||||
|
||||
mHeightEdit = new lcSmallLineEdit();
|
||||
SizeLayout->addWidget(new QLabel(tr("Height:")), 1, 2);
|
||||
SizeLayout->addWidget(mHeightEdit, 1, 3);
|
||||
|
||||
lcCollapsibleWidget* OrientationWidget = new lcCollapsibleWidget(tr("Orientation"));
|
||||
SetupLayout->addWidget(OrientationWidget);
|
||||
|
||||
QVBoxLayout* OrientationLayout = new QVBoxLayout();
|
||||
OrientationWidget->SetChildLayout(OrientationLayout);
|
||||
|
||||
mPortraitButton = new QRadioButton(tr("Portrait"));
|
||||
OrientationLayout->addWidget(mPortraitButton);
|
||||
mLandscapeButton = new QRadioButton(tr("Landscape"));
|
||||
OrientationLayout->addWidget(mLandscapeButton);
|
||||
|
||||
lcCollapsibleWidget* MarginsWidget = new lcCollapsibleWidget(tr("Margins"));
|
||||
SetupLayout->addWidget(MarginsWidget);
|
||||
|
||||
QGridLayout* MarginsLayout = new QGridLayout();
|
||||
MarginsWidget->SetChildLayout(MarginsLayout);
|
||||
|
||||
mLeftMarginEdit = new lcSmallLineEdit();
|
||||
MarginsLayout->addWidget(new QLabel(tr("Left:")), 0, 0);
|
||||
MarginsLayout->addWidget(mLeftMarginEdit, 0, 1);
|
||||
|
||||
mRightMarginEdit = new lcSmallLineEdit();
|
||||
MarginsLayout->addWidget(new QLabel(tr("Right:")), 0, 2);
|
||||
MarginsLayout->addWidget(mRightMarginEdit, 0, 3);
|
||||
|
||||
mTopMarginEdit = new lcSmallLineEdit();
|
||||
MarginsLayout->addWidget(new QLabel(tr("Top:")), 1, 0);
|
||||
MarginsLayout->addWidget(mTopMarginEdit, 1, 1);
|
||||
|
||||
mBottomMarginEdit = new lcSmallLineEdit();
|
||||
MarginsLayout->addWidget(new QLabel(tr("Bottom:")), 1, 2);
|
||||
MarginsLayout->addWidget(mBottomMarginEdit, 1, 3);
|
||||
|
||||
lcCollapsibleWidget* UnitsWidget = new lcCollapsibleWidget(tr("Units"));
|
||||
SetupLayout->addWidget(UnitsWidget);
|
||||
|
||||
QVBoxLayout* UnitsLayout = new QVBoxLayout();
|
||||
UnitsWidget->SetChildLayout(UnitsLayout);
|
||||
|
||||
mUnitsComboBox = new QComboBox();
|
||||
mUnitsComboBox->addItems(QStringList() << tr("Pixels") << tr("Centimeters") << tr("Inches"));
|
||||
UnitsLayout->addWidget(mUnitsComboBox);
|
||||
|
||||
SetupWidget->Collapse();
|
||||
|
||||
mThumbnailsWidget = new QListWidget(CentralWidget);
|
||||
Layout->addWidget(mThumbnailsWidget);
|
||||
}
|
||||
|
@ -90,8 +160,8 @@ lcInstructionsDialog::lcInstructionsDialog(QWidget* Parent, Project* Project)
|
|||
connect(mPageListWidget->mThumbnailsWidget, SIGNAL(currentRowChanged(int)), this, SLOT(CurrentThumbnailChanged(int)));
|
||||
mPageListWidget->mThumbnailsWidget->setCurrentRow(0);
|
||||
|
||||
connect(mVerticalPageAction, SIGNAL(toggled()), this, SLOT(UpdatePageSettings()));
|
||||
connect(mHorizontalPageAction, SIGNAL(toggled()), this, SLOT(UpdatePageSettings()));
|
||||
connect(mVerticalPageAction, SIGNAL(toggled(bool)), this, SLOT(UpdatePageSettings()));
|
||||
connect(mHorizontalPageAction, SIGNAL(toggled(bool)), this, SLOT(UpdatePageSettings()));
|
||||
connect(mRowsSpinBox, SIGNAL(valueChanged(int)), this, SLOT(UpdatePageSettings()));
|
||||
connect(mColumnsSpinBox, SIGNAL(valueChanged(int)), this, SLOT(UpdatePageSettings()));
|
||||
}
|
||||
|
@ -122,7 +192,7 @@ void lcInstructionsDialog::UpdatePageSettings()
|
|||
|
||||
void lcInstructionsDialog::CurrentThumbnailChanged(int Index)
|
||||
{
|
||||
if (Index < 0 || Index >= mInstructions.mPages.size())
|
||||
if (Index < 0 || Index >= static_cast<int>(mInstructions.mPages.size()))
|
||||
{
|
||||
mPageWidget->SetCurrentPage(nullptr);
|
||||
return;
|
||||
|
|
|
@ -20,6 +20,20 @@ public:
|
|||
lcInstructionsPageListWidget(QWidget* Parent);
|
||||
|
||||
//protected:
|
||||
QComboBox* mSizeComboBox = nullptr;
|
||||
QLineEdit* mWidthEdit = nullptr;
|
||||
QLineEdit* mHeightEdit = nullptr;
|
||||
|
||||
QRadioButton* mPortraitButton = nullptr;
|
||||
QRadioButton* mLandscapeButton = nullptr;
|
||||
|
||||
QLineEdit* mLeftMarginEdit = nullptr;
|
||||
QLineEdit* mRightMarginEdit = nullptr;
|
||||
QLineEdit* mTopMarginEdit = nullptr;
|
||||
QLineEdit* mBottomMarginEdit = nullptr;
|
||||
|
||||
QComboBox* mUnitsComboBox = nullptr;
|
||||
|
||||
QListWidget* mThumbnailsWidget = nullptr;
|
||||
};
|
||||
|
||||
|
|
|
@ -180,6 +180,7 @@ SOURCES += \
|
|||
common/light.cpp \
|
||||
common/lc_application.cpp \
|
||||
common/lc_category.cpp \
|
||||
common/lc_collapsiblewidget.cpp \
|
||||
common/lc_colors.cpp \
|
||||
common/lc_commands.cpp \
|
||||
common/lc_context.cpp \
|
||||
|
@ -245,6 +246,7 @@ HEADERS += \
|
|||
common/lc_application.h \
|
||||
common/lc_array.h \
|
||||
common/lc_category.h \
|
||||
common/lc_collapsiblewidget.h \
|
||||
common/lc_colors.h \
|
||||
common/lc_commands.h \
|
||||
common/lc_context.h \
|
||||
|
|
|
@ -8,6 +8,8 @@ float lcParseValueLocalized(const QString& Value);
|
|||
|
||||
class lcQTreeWidgetColumnStretcher : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
lcQTreeWidgetColumnStretcher(QTreeWidget* TreeWidget, int ColumnToStretch);
|
||||
|
||||
|
@ -16,14 +18,11 @@ public:
|
|||
const int m_columnToStretch;
|
||||
};
|
||||
|
||||
class lcTransformLineEdit : public QLineEdit
|
||||
class lcSmallLineEdit : public QLineEdit
|
||||
{
|
||||
public:
|
||||
lcTransformLineEdit()
|
||||
: QLineEdit()
|
||||
{
|
||||
}
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QSize sizeHint() const override
|
||||
{
|
||||
QFontMetrics FontMetrics(font());
|
||||
|
@ -36,6 +35,11 @@ public:
|
|||
|
||||
return QLineEdit::sizeHint() - QSize(Width, 0);
|
||||
}
|
||||
};
|
||||
|
||||
class lcTransformLineEdit : public lcSmallLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
protected:
|
||||
bool event(QEvent* Event) override
|
||||
|
|
Loading…
Reference in a new issue