From 2a343cd8e22ceec11d40e2c2c749d90e1f61e428 Mon Sep 17 00:00:00 2001 From: shun-iwasawa Date: Fri, 10 Jan 2020 16:04:57 +0900 Subject: [PATCH] fix style editor UI --- toonz/sources/include/toonzqt/styleeditor.h | 3 +- .../toonzqt/Resources/orientation_h.svg | 83 +++++++++++++++++++ .../toonzqt/Resources/orientation_v.svg | 81 ++++++++++++++++++ toonz/sources/toonzqt/styleeditor.cpp | 80 ++++++++---------- toonz/sources/toonzqt/toonzqt.qrc | 2 + 5 files changed, 203 insertions(+), 46 deletions(-) create mode 100644 toonz/sources/toonzqt/Resources/orientation_h.svg create mode 100644 toonz/sources/toonzqt/Resources/orientation_v.svg diff --git a/toonz/sources/include/toonzqt/styleeditor.h b/toonz/sources/include/toonzqt/styleeditor.h index 1f53f589..307185ad 100644 --- a/toonz/sources/include/toonzqt/styleeditor.h +++ b/toonz/sources/include/toonzqt/styleeditor.h @@ -559,7 +559,6 @@ class SettingsPage final : public QScrollArea { QGridLayout *m_paramsLayout; QCheckBox *m_autoFillCheckBox; - QWidget *m_autopaintToggleBox; TColorStyleP m_editedStyle; //!< A copy of the current style being edited by //! the Style Editor. @@ -617,7 +616,7 @@ class DVAPI StyleEditor final : public QWidget, public SaveLoadQSettings { *m_newColor; //!< New style viewer (lower-right panel side). DVGui::StyleSample *m_oldColor; //!< Old style viewer (lower-right panel side). - QPushButton *m_toggleOrientationButton; + QAction *m_toggleOrientationAction; QPushButton *m_autoButton; //!< "Auto Apply" checkbox on the right panel side. QPushButton *m_applyButton; //!< "Apply" button on the right panel side. diff --git a/toonz/sources/toonzqt/Resources/orientation_h.svg b/toonz/sources/toonzqt/Resources/orientation_h.svg new file mode 100644 index 00000000..6c7720a4 --- /dev/null +++ b/toonz/sources/toonzqt/Resources/orientation_h.svg @@ -0,0 +1,83 @@ + +image/svg+xml \ No newline at end of file diff --git a/toonz/sources/toonzqt/Resources/orientation_v.svg b/toonz/sources/toonzqt/Resources/orientation_v.svg new file mode 100644 index 00000000..00ac8766 --- /dev/null +++ b/toonz/sources/toonzqt/Resources/orientation_v.svg @@ -0,0 +1,81 @@ + +image/svg+xml \ No newline at end of file diff --git a/toonz/sources/toonzqt/styleeditor.cpp b/toonz/sources/toonzqt/styleeditor.cpp index c1cd865b..8556bf0e 100644 --- a/toonz/sources/toonzqt/styleeditor.cpp +++ b/toonz/sources/toonzqt/styleeditor.cpp @@ -2528,46 +2528,33 @@ SettingsPage::SettingsPage(QWidget *parent) setWidget(paramsContainer); QVBoxLayout *paramsContainerLayout = new QVBoxLayout(this); + paramsContainerLayout->setMargin(10); + paramsContainerLayout->setSpacing(10); paramsContainer->setLayout(paramsContainerLayout); // Add a vertical layout to store the "autofill" checkbox widgets - { - m_autopaintToggleBox = new QWidget(this); - // box->setFixedHeight(22); - paramsContainerLayout->addWidget(m_autopaintToggleBox); + m_autoFillCheckBox = new QCheckBox(tr("Autopaint for Lines"), this); + paramsContainerLayout->addWidget(m_autoFillCheckBox, 0, + Qt::AlignLeft | Qt::AlignVCenter); - QHBoxLayout *hLayout = new QHBoxLayout; - m_autopaintToggleBox->setLayout(hLayout); - - hLayout->setSpacing(5); - hLayout->setMargin(0); - hLayout->addSpacing(98); - - m_autoFillCheckBox = new QCheckBox; - hLayout->addWidget(m_autoFillCheckBox); - - QLabel *label = - new QLabel(StyleEditorGUI::SettingsPage::tr("Autopaint for Lines")); - hLayout->addWidget(label); - - hLayout->addStretch(); - - ret = connect(m_autoFillCheckBox, SIGNAL(stateChanged(int)), this, - SLOT(onAutofillChanged())); - assert(ret); - } + ret = connect(m_autoFillCheckBox, SIGNAL(stateChanged(int)), this, + SLOT(onAutofillChanged())); + assert(ret); // Prepare the style parameters layout m_paramsLayout = new QGridLayout; + m_paramsLayout->setMargin(0); + m_paramsLayout->setVerticalSpacing(8); + m_paramsLayout->setHorizontalSpacing(5); paramsContainerLayout->addLayout(m_paramsLayout); - paramsContainerLayout->addStretch(); + paramsContainerLayout->addStretch(1); } //----------------------------------------------------------------------------- void SettingsPage::enableAutopaintToggle(bool enabled) { - m_autopaintToggleBox->setVisible(enabled); + m_autoFillCheckBox->setVisible(enabled); } //----------------------------------------------------------------------------- @@ -2989,21 +2976,24 @@ StyleEditor::StyleEditor(PaletteController *paletteController, QWidget *parent) menu->addAction(m_rgbAction); QToolButton *toolButton = new QToolButton(this); - toolButton->setIcon(QIcon(":Resources/menu.svg")); - toolButton->setMaximumWidth(18); - toolButton->setMaximumHeight(18); + toolButton->setIcon(createQIcon("options")); + toolButton->setFixedSize(22, 22); toolButton->setMenu(menu); toolButton->setPopupMode(QToolButton::InstantPopup); toolButton->setToolTip(tr("Show or hide parts of the Color Page.")); - QToolBar *displayToolbar = new QToolBar(this); - m_toggleOrientationButton = new QPushButton(QChar(0x2194), this); - m_toggleOrientationButton->setFixedWidth(20); - m_toggleOrientationButton->setToolTip( + QToolBar *displayToolbar = new QToolBar(this); + m_toggleOrientationAction = + displayToolbar->addAction(QIcon(":Resources/orientation_h.svg"), ""); + m_toggleOrientationAction->setToolTip( tr("Toggle orientation of the Color Page.")); - m_toggleOrientationButton->setFocusPolicy(Qt::NoFocus); - displayToolbar->addWidget(m_toggleOrientationButton); + QWidget *toggleOrientationButton = + displayToolbar->widgetForAction(m_toggleOrientationAction); + toggleOrientationButton->setFixedSize(22, 22); + toggleOrientationButton->setFocusPolicy(Qt::NoFocus); displayToolbar->addWidget(toolButton); - displayToolbar->setFixedWidth(45); + displayToolbar->setMaximumHeight(22); + displayToolbar->setIconSize(QSize(18, 18)); + /* ------- layout ------- */ QGridLayout *mainLayout = new QGridLayout; mainLayout->setMargin(0); @@ -3018,12 +3008,14 @@ StyleEditor::StyleEditor(PaletteController *paletteController, QWidget *parent) } m_tabBarContainer->setLayout(hLayout); - mainLayout->addWidget(m_tabBarContainer, 0, 0, 1, 2, 0); + mainLayout->addWidget(m_tabBarContainer, 0, 0, 1, 2); mainLayout->addWidget(m_styleChooser, 1, 0, 1, 2); - mainLayout->addWidget(bottomWidget, 2, 0, 1, 2, 0); - mainLayout->addWidget(m_toolBar, 3, 0, 1, 1, 0); - mainLayout->addWidget(displayToolbar, 3, 1, 1, 1, 0); + mainLayout->addWidget(bottomWidget, 2, 0, 1, 2); + mainLayout->addWidget(m_toolBar, 3, 0); + mainLayout->addWidget(displayToolbar, 3, 1); } + mainLayout->setColumnStretch(0, 1); + mainLayout->setRowStretch(1, 1); setLayout(mainLayout); /* ------- signal-slot connections ------- */ @@ -3062,9 +3054,9 @@ StyleEditor::StyleEditor(PaletteController *paletteController, QWidget *parent) m_plainColorPage->m_alphaFrame, SLOT(setVisible(bool))); ret = ret && connect(m_rgbAction, SIGNAL(toggled(bool)), m_plainColorPage->m_rgbFrame, SLOT(setVisible(bool))); - ret = ret && connect(m_toggleOrientationButton, SIGNAL(clicked()), + ret = ret && connect(m_toggleOrientationAction, SIGNAL(triggered()), m_plainColorPage, SLOT(toggleOrientation())); - ret = ret && connect(m_toggleOrientationButton, SIGNAL(clicked()), this, + ret = ret && connect(m_toggleOrientationAction, SIGNAL(triggered()), this, SLOT(updateOrientationButton())); assert(ret); /* ------- initial conditions ------- */ @@ -3278,9 +3270,9 @@ void StyleEditor::hideEvent(QHideEvent *) { void StyleEditor::updateOrientationButton() { if (m_plainColorPage->getIsVertical()) { - m_toggleOrientationButton->setText(QChar(0x2194)); + m_toggleOrientationAction->setIcon(QIcon(":Resources/orientation_h.svg")); } else { - m_toggleOrientationButton->setText(QChar(0x2195)); + m_toggleOrientationAction->setIcon(QIcon(":Resources/orientation_v.svg")); } } diff --git a/toonz/sources/toonzqt/toonzqt.qrc b/toonz/sources/toonzqt/toonzqt.qrc index d2256d3c..5f5b59e9 100644 --- a/toonz/sources/toonzqt/toonzqt.qrc +++ b/toonz/sources/toonzqt/toonzqt.qrc @@ -323,5 +323,7 @@ Resources/schematic_zoom_mode_off.svg Resources/schematic_hand_mode_on.svg Resources/schematic_hand_mode_off.svg + Resources/orientation_h.svg + Resources/orientation_v.svg