diff --git a/stuff/config/qss/Blue/Blue.qss b/stuff/config/qss/Blue/Blue.qss index 69eb343..f733955 100644 --- a/stuff/config/qss/Blue/Blue.qss +++ b/stuff/config/qss/Blue/Blue.qss @@ -1588,6 +1588,9 @@ PaletteViewer QToolBar #keyFrameNavigator #KeyTotal { background-color: #d57a7a; border-color: #d57a7a; } +#PltPageViewerScrollArea { + border-bottom: 1px solid #262728; +} /* ----------------------------------------------------------------------------- Quick Renamer ----------------------------------------------------------------------------- */ diff --git a/stuff/config/qss/Dark/Dark.qss b/stuff/config/qss/Dark/Dark.qss index 28fb4b8..d2564a4 100644 --- a/stuff/config/qss/Dark/Dark.qss +++ b/stuff/config/qss/Dark/Dark.qss @@ -1588,6 +1588,9 @@ PaletteViewer QToolBar #keyFrameNavigator #KeyTotal { background-color: #d57a7a; border-color: #d57a7a; } +#PltPageViewerScrollArea { + border-bottom: 1px solid #111111; +} /* ----------------------------------------------------------------------------- Quick Renamer ----------------------------------------------------------------------------- */ diff --git a/stuff/config/qss/Default/Default.qss b/stuff/config/qss/Default/Default.qss index 9d4fb1d..41ec273 100644 --- a/stuff/config/qss/Default/Default.qss +++ b/stuff/config/qss/Default/Default.qss @@ -1588,6 +1588,9 @@ PaletteViewer QToolBar #keyFrameNavigator #KeyTotal { background-color: #d57a7a; border-color: #d57a7a; } +#PltPageViewerScrollArea { + border-bottom: 1px solid #2c2c2c; +} /* ----------------------------------------------------------------------------- Quick Renamer ----------------------------------------------------------------------------- */ diff --git a/stuff/config/qss/Default/less/layouts/palette.less b/stuff/config/qss/Default/less/layouts/palette.less index dc4d059..0430dee 100644 --- a/stuff/config/qss/Default/less/layouts/palette.less +++ b/stuff/config/qss/Default/less/layouts/palette.less @@ -146,6 +146,10 @@ PaletteViewer { } } +#PltPageViewerScrollArea { + border-bottom: 1px solid @accent; +} + /* ----------------------------------------------------------------------------- Quick Renamer ----------------------------------------------------------------------------- */ diff --git a/stuff/config/qss/Light/Light.qss b/stuff/config/qss/Light/Light.qss index 2b3017a..9d37d55 100644 --- a/stuff/config/qss/Light/Light.qss +++ b/stuff/config/qss/Light/Light.qss @@ -1588,6 +1588,9 @@ PaletteViewer QToolBar #keyFrameNavigator #KeyTotal { background-color: #eca09c; border-color: #b42922; } +#PltPageViewerScrollArea { + border-bottom: 1px solid #a8a8a8; +} /* ----------------------------------------------------------------------------- Quick Renamer ----------------------------------------------------------------------------- */ diff --git a/stuff/config/qss/Neutral/Neutral.qss b/stuff/config/qss/Neutral/Neutral.qss index 48a367e..9887d45 100644 --- a/stuff/config/qss/Neutral/Neutral.qss +++ b/stuff/config/qss/Neutral/Neutral.qss @@ -1588,6 +1588,9 @@ PaletteViewer QToolBar #keyFrameNavigator #KeyTotal { background-color: #d28b8b; border-color: #7b3030; } +#PltPageViewerScrollArea { + border-bottom: 1px solid #5a5a5a; +} /* ----------------------------------------------------------------------------- Quick Renamer ----------------------------------------------------------------------------- */ diff --git a/toonz/sources/include/toonzqt/paletteviewer.h b/toonz/sources/include/toonzqt/paletteviewer.h index 0873b19..3ca481d 100644 --- a/toonz/sources/include/toonzqt/paletteviewer.h +++ b/toonz/sources/include/toonzqt/paletteviewer.h @@ -3,8 +3,12 @@ #ifndef PALETTEVIEWER_H #define PALETTEVIEWER_H +#include "saveloadqsettings.h" #include "paletteviewergui.h" #include "toonz/tpalettehandle.h" +#include "toonz/preferences.h" +#include +#include #undef DVAPI #undef DVVAR @@ -18,6 +22,7 @@ // forward declaration class QScrollArea; +class DvScrollWidget; class QToolBar; class PaletteKeyframeNavigator; class TFrameHandle; @@ -40,7 +45,7 @@ class TXsheetHandle; // PaletteViewer //----------------------------------------------------------------------------- -class DVAPI PaletteViewer final : public QFrame { +class DVAPI PaletteViewer final : public QFrame, public SaveLoadQSettings { Q_OBJECT public: @@ -49,6 +54,12 @@ public: bool hasPasteColors = true); ~PaletteViewer(); + QString currentRoomChoice = Preferences::instance()->getCurrentRoomChoice(); + + bool m_toolbarOnTop = currentRoomChoice.contains("StudioGhibli", Qt::CaseInsensitive) ? true : false; + + void setToolbarOnTop(bool isToolbarOnTop); + const TPaletteHandle *getPaletteHandle() const { return m_paletteHandle; } void setPaletteHandle(TPaletteHandle *paletteHandle); @@ -78,19 +89,32 @@ public: void enableSaveAction(bool enable); + bool getStudioGhibli(); + + // SaveLoadQSettings + virtual void save(QSettings &settings) const override; + virtual void load(QSettings &settings) override; + +public slots: + void toolbarOnTopToggled(bool ignore); + protected: TPaletteHandle *m_paletteHandle; TFrameHandle *m_frameHandle; TXsheetHandle *m_xsheetHandle; TXshLevelHandle *m_levelHandle; + QAction *m_showToolbarOnTopAct; QScrollArea *m_pageViewerScrollArea; PaletteViewerGUI::PageViewer *m_pageViewer; TabBarContainter *m_tabBarContainer; PaletteTabBar *m_pagesBar; - QToolBar *m_paletteToolBar; QToolBar *m_savePaletteToolBar; + QSpacerItem *m_spacer_hExpanding; + DvScrollWidget *m_toolbarScrollWidget; + QHBoxLayout *m_hLayout; + QVBoxLayout *m_mainLayout; int m_indexPageToDelete; diff --git a/toonz/sources/include/toonzqt/studiopaletteviewer.h b/toonz/sources/include/toonzqt/studiopaletteviewer.h index 07d8459..0430d21 100644 --- a/toonz/sources/include/toonzqt/studiopaletteviewer.h +++ b/toonz/sources/include/toonzqt/studiopaletteviewer.h @@ -6,6 +6,7 @@ #include "toonz/studiopalette.h" #include "toonz/tproject.h" #include "toonzqt/dvdialog.h" +#include "saveloadqsettings.h" #include #include @@ -212,7 +213,8 @@ protected: allows to show and modify current studio palette selected in tree. */ -class DVAPI StudioPaletteViewer final : public QSplitter { +class DVAPI StudioPaletteViewer final : public QSplitter, + public SaveLoadQSettings { Q_OBJECT StudioPaletteTreeViewer *m_studioPaletteTreeViewer; @@ -230,6 +232,10 @@ public: int getViewMode() const; void setViewMode(int mode); + + // SaveLoadQSettings + virtual void save(QSettings &settings) const override; + virtual void load(QSettings &settings) override; }; //----------------------------------------------------------------------------- diff --git a/toonz/sources/toonzqt/paletteviewer.cpp b/toonz/sources/toonzqt/paletteviewer.cpp index 7f0ba2c..d6f992a 100644 --- a/toonz/sources/toonzqt/paletteviewer.cpp +++ b/toonz/sources/toonzqt/paletteviewer.cpp @@ -21,13 +21,16 @@ #include "toonz/studiopalette.h" #include "toonz/tframehandle.h" #include "toonz/fullcolorpalette.h" +#include "toonz/preferences.h" // TnzCore includes +#include "saveloadqsettings.h" #include "tconvert.h" #include "tsystem.h" #include "tenv.h" // Qt includes +#include #include #include #include @@ -82,10 +85,19 @@ PaletteViewer::PaletteViewer(QWidget *parent, PaletteViewType viewType, bool hasSaveToolBar, bool hasPageCommand, bool hasPasteColors) : QFrame(parent) + , m_toolbarOnTop( + currentRoomChoice.contains("StudioGhibli", Qt::CaseInsensitive) + ? true + : false) + , m_showToolbarOnTopAct(0) , m_tabBarContainer(0) , m_pagesBar(0) , m_paletteToolBar(0) , m_savePaletteToolBar(0) + , m_spacer_hExpanding(0) + , m_toolbarScrollWidget(0) + , m_hLayout(0) + , m_mainLayout(0) , m_pageViewer(0) , m_pageViewerScrollArea(0) , m_indexPageToDelete(-1) @@ -106,6 +118,9 @@ PaletteViewer::PaletteViewer(QWidget *parent, PaletteViewType viewType, // Create pageView m_pageViewerScrollArea = new QScrollArea(); + m_pageViewerScrollArea->setObjectName( + "PltPageViewerScrollArea"); // for setting border between toolbar in + // stylesheet m_pageViewerScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_pageViewerScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); m_pageViewerScrollArea->setWidgetResizable(true); @@ -116,13 +131,11 @@ PaletteViewer::PaletteViewer(QWidget *parent, PaletteViewType viewType, m_pagesBar->setPageViewer(m_pageViewer); // Create toolbar. It is an horizontal layout with three internal toolbar. - DvScrollWidget *toolbarScrollWidget = new DvScrollWidget; + m_toolbarScrollWidget = new DvScrollWidget; - toolbarScrollWidget->setObjectName( - "ToolBarContainer"); // Toonz's qss files are instructed to leave a - // 1px grey margin on top for scroll buttons + m_toolbarScrollWidget->setObjectName("ToolBarContainer"); QWidget *toolBarWidget = new QWidget; // children of this parent name. - toolbarScrollWidget->setWidget(toolBarWidget); + m_toolbarScrollWidget->setWidget(toolBarWidget); toolBarWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); toolBarWidget->setFixedHeight(22); @@ -131,42 +144,40 @@ PaletteViewer::PaletteViewer(QWidget *parent, PaletteViewType viewType, m_savePaletteToolBar = new QToolBar(toolBarWidget); createToolBar(); + m_spacer_hExpanding = + new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); + QHBoxLayout *toolBarLayout = new QHBoxLayout(toolBarWidget); toolBarLayout->setMargin(0); toolBarLayout->setSpacing(0); { - toolBarLayout->addWidget(m_savePaletteToolBar, 0, Qt::AlignRight); + toolBarLayout->addWidget(m_savePaletteToolBar, 0, Qt::AlignLeft); + toolBarLayout->addItem(m_spacer_hExpanding); toolBarLayout->addWidget(m_paletteToolBar, 0, Qt::AlignRight); } toolBarWidget->setLayout(toolBarLayout); - // This widget is used to set the background color of the tabBar - // using the styleSheet. - // It is also used to take 6px on the left before the tabBar - // and to draw the two lines on the bottom size + // This is for setting tab container bg color in stylesheet m_tabBarContainer = new TabBarContainter(this); - QVBoxLayout *mainLayout = new QVBoxLayout(this); - mainLayout->setMargin(0); - mainLayout->setSpacing(0); + m_mainLayout = new QVBoxLayout(this); + m_mainLayout->setMargin(0); + m_mainLayout->setSpacing(0); { - // To add 6px (on the left) before the TabBar - QHBoxLayout *hLayout = new QHBoxLayout; - hLayout->setMargin(0); - // hLayout->setAlignment(Qt::AlignLeft); - // hLayout->addSpacing(6); + m_hLayout = new QHBoxLayout; + m_hLayout->setMargin(0); { - hLayout->addWidget(m_pagesBar, 0); - hLayout->addStretch(1); - hLayout->addWidget(toolbarScrollWidget, 0); + m_hLayout->addWidget(m_pagesBar, 0); + m_hLayout->addStretch(1); } - m_tabBarContainer->setLayout(hLayout); + m_tabBarContainer->setLayout(m_hLayout); // To align this panel with the style Editor - mainLayout->addWidget(m_tabBarContainer, 0); - mainLayout->addWidget(m_pageViewerScrollArea, 1); + m_mainLayout->addWidget(m_tabBarContainer, 0); + m_mainLayout->addWidget(m_pageViewerScrollArea, 1); + m_mainLayout->addWidget(m_toolbarScrollWidget, 0); } - setLayout(mainLayout); + setLayout(m_mainLayout); connect(m_pagesBar, SIGNAL(currentChanged(int)), this, SLOT(setPageView(int))); @@ -188,10 +199,81 @@ PaletteViewer::~PaletteViewer() { delete m_changeStyleCommand; } //----------------------------------------------------------------------------- +void PaletteViewer::toolbarOnTopToggled(bool ignore) { + m_toolbarOnTop = !m_toolbarOnTop; + setToolbarOnTop(m_toolbarOnTop); +} + +//----------------------------------------------------------------------------- + +void PaletteViewer::setToolbarOnTop(bool isToolbarOnTop) { + m_toolbarOnTop = isToolbarOnTop; + + // Swap toolbar position in layout + if (isToolbarOnTop == true) { + // Show a border line between toolbar and pageViewerScrollArea when toolbar + // is set to below styles only, this is styled in the stylesheet, set it to + // 0px width to hide it when toolbar is set to display above styles. + m_pageViewerScrollArea->setStyleSheet("border-width: 0px;"); // hide + m_mainLayout->removeWidget(m_toolbarScrollWidget); + m_hLayout->addWidget(m_toolbarScrollWidget, 0); + } else { + m_pageViewerScrollArea->setStyleSheet("border-width: 1px;"); // show + m_hLayout->removeWidget(m_toolbarScrollWidget); + m_mainLayout->addWidget(m_toolbarScrollWidget, 0); + } + + // Handle check state for menu action + if (m_toolbarOnTop == true) { + m_showToolbarOnTopAct->setText(tr("Set Toolbar Below Styles")); + } else { + m_showToolbarOnTopAct->setText(tr("Set Toolbar Above Styles")); + } +} + +//----------------------------------------------------------------------------- + +bool PaletteViewer::getStudioGhibli() { + // To prevent interruption to users of long established layout, we will handle + // that if the current room choice is [StudioGhibli], make sure the toolbar is + // set to display [ABOVE] styles like before by default. + // + // All other choices has the reverse behaviour. This will affect both + // currently docked and newly opened floating panels. + + QString currentRoomChoice = Preferences::instance()->getCurrentRoomChoice(); + bool isStudioGhibli = 0; + if (currentRoomChoice.contains("StudioGhibli", Qt::CaseInsensitive)) + isStudioGhibli = 1; + else + isStudioGhibli = 0; + return isStudioGhibli; +} + +//----------------------------------------------------------------------------- + +void PaletteViewer::save(QSettings &settings) const { + bool toolbarOnTop = m_toolbarOnTop ? 1 : 0; + settings.setValue("toolbarOnTop", toolbarOnTop); +} + +void PaletteViewer::load(QSettings &settings) { + bool isStudioGhibli = getStudioGhibli(); + + QVariant toolbarOnTop = + settings.value("toolbarOnTop", isStudioGhibli).toBool(); + if (toolbarOnTop.canConvert(QVariant::Bool)) { + m_toolbarOnTop = toolbarOnTop.toBool(); + setToolbarOnTop(m_toolbarOnTop); + } +} + +//----------------------------------------------------------------------------- + void PaletteViewer::setPaletteHandle(TPaletteHandle *paletteHandle) { if (m_paletteHandle == paletteHandle) return; - bool ret = true; + bool ret = true; if (m_paletteHandle) ret = ret && disconnect(m_paletteHandle, 0, this, 0); m_paletteHandle = paletteHandle; @@ -397,6 +479,17 @@ void PaletteViewer::createPaletteToolBar() { addNameDisplayAction(tr("Both Names"), PageViewer::StyleAndOriginal); viewMode->addSeparator(); + + m_showToolbarOnTopAct = new QAction; + if (m_toolbarOnTop) + m_showToolbarOnTopAct->setText(tr("Set Toolbar Below Styles")); + if (!m_toolbarOnTop) + m_showToolbarOnTopAct->setText(tr("Set Toolbar Above Styles")); + viewMode->addAction(m_showToolbarOnTopAct); + m_showToolbarOnTopAct->setCheckable(false); + connect(m_showToolbarOnTopAct, SIGNAL(triggered(bool)), this, + SLOT(toolbarOnTopToggled(bool))); + QString str = (ShowNewStyleButton) ? tr("Hide New Style Button") : tr("Show New Style Button"); QAction *showNewStyleBtn = viewMode->addAction(str); @@ -1029,7 +1122,7 @@ void PaletteViewer::onPaletteSwitched() { if (palette) { int currentStyleId = palette->getCurrentStyleId(); TPalette::Page *page = palette->getStylePage(currentStyleId); - if (page) pageIndex = page->getIndex(); + if (page) pageIndex = page->getIndex(); } } onSwitchToPage(pageIndex); diff --git a/toonz/sources/toonzqt/studiopaletteviewer.cpp b/toonz/sources/toonzqt/studiopaletteviewer.cpp index d99f1c5..43d8b07 100644 --- a/toonz/sources/toonzqt/studiopaletteviewer.cpp +++ b/toonz/sources/toonzqt/studiopaletteviewer.cpp @@ -20,8 +20,10 @@ #include "toonz/sceneproperties.h" #include "toonz/txsheethandle.h" #include "toonz/txshlevelhandle.h" +#include "toonz/preferences.h" // TnzCore includes +#include "saveloadqsettings.h" #include "tconvert.h" #include "tundo.h" #include "tsystem.h" @@ -29,6 +31,7 @@ #include "../toonz/menubarcommandids.h" // Qt includes +#include #include #include #include @@ -129,7 +132,7 @@ StudioPaletteTreeViewer::StudioPaletteTreeViewer( bool ret = connect(this, SIGNAL(itemChanged(QTreeWidgetItem *, int)), SLOT(onItemChanged(QTreeWidgetItem *, int))); - ret = ret && connect(this, SIGNAL(itemClicked(QTreeWidgetItem *, int)), + ret = ret && connect(this, SIGNAL(itemClicked(QTreeWidgetItem *, int)), SLOT(onItemClicked(QTreeWidgetItem *, int))); ret = ret && @@ -942,8 +945,8 @@ void StudioPaletteTreeViewer::contextMenuEvent(QContextMenuEvent *event) { QTreeWidgetItem *item = items[i]; QRect rect = visualItemRect(item); if (QRect(0, rect.y(), width(), rect.height()).contains(event->pos())) - isClickInSelection = true; - TFilePath path = getItemPath(item); + isClickInSelection = true; + TFilePath path = getItemPath(item); if (studioPalette->isFolder(path)) areAllPalette = false; } if (!isClickInSelection) return; @@ -986,9 +989,8 @@ void StudioPaletteTreeViewer::mousePressEvent(QMouseEvent *event) { void StudioPaletteTreeViewer::mouseMoveEvent(QMouseEvent *event) { // If left button is not pressed return; is not drag event. if (!(event->buttons() & Qt::LeftButton)) return; - if (!m_startPos.isNull() && - (m_startPos - event->pos()).manhattanLength() >= - QApplication::startDragDistance()) + if (!m_startPos.isNull() && (m_startPos - event->pos()).manhattanLength() >= + QApplication::startDragDistance()) startDragDrop(); } @@ -1140,7 +1142,7 @@ void StudioPaletteTreeViewer::dropEvent(QDropEvent *event) { pltName = tr("the palette \"%1\"") .arg(QString::fromStdWString(palettePaths[0].getWideName())); else - pltName = tr("the selected palettes"); + pltName = tr("the selected palettes"); QString dstName = QString::fromStdWString(newPath.getWideName()); QString question = @@ -1248,4 +1250,23 @@ int StudioPaletteViewer::getViewMode() const { void StudioPaletteViewer::setViewMode(int mode) { m_studioPaletteViewer->setViewMode( (PaletteViewerGUI::PageViewer::ViewMode)mode); +} + +//----------------------------------------------------------------------------- + +void StudioPaletteViewer::save(QSettings &settings) const { + bool toolbarOnTop = m_studioPaletteViewer->m_toolbarOnTop ? 1 : 0; + settings.setValue("toolbarOnTop", toolbarOnTop); +} + +void StudioPaletteViewer::load(QSettings &settings) { + bool isStudioGhibli = m_studioPaletteViewer->getStudioGhibli(); + + QVariant toolbarOnTop = + settings.value("toolbarOnTop", isStudioGhibli).toBool(); + if (toolbarOnTop.canConvert(QVariant::Bool)) { + m_studioPaletteViewer->m_toolbarOnTop = toolbarOnTop.toBool(); + m_studioPaletteViewer->setToolbarOnTop( + m_studioPaletteViewer->m_toolbarOnTop); + } } \ No newline at end of file