|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/paletteviewer.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzQt includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/gutil.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/keyframenavigator.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/trepetitionguard.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/dvdialog.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/dvscrollwidget.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/studiopaletteviewer.h"
|
|
shun-iwasawa |
b37337 |
#include "toonzqt/styleselection.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "palettedata.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzLib includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/palettecmd.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/studiopalettecmd.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshlevel.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/toonzscene.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/sceneproperties.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/studiopalette.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tframehandle.h"
|
|
shun-iwasawa |
b37337 |
#include "toonz/fullcolorpalette.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzCore includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tconvert.h"
|
|
John Dancel |
35a3a8 |
#include "tsystem.h"
|
|
shun-iwasawa |
726b1d |
#include "tenv.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Qt includes
|
|
Toshihiro Shimizu |
890ddd |
#include <qvboxlayout></qvboxlayout>
|
|
Toshihiro Shimizu |
890ddd |
#include <qtoolbar></qtoolbar>
|
|
Toshihiro Shimizu |
890ddd |
#include <qscrollarea></qscrollarea>
|
|
Toshihiro Shimizu |
890ddd |
#include <qmouseevent></qmouseevent>
|
|
Toshihiro Shimizu |
890ddd |
#include <qmenubar></qmenubar>
|
|
Toshihiro Shimizu |
890ddd |
#include <qtoolbutton></qtoolbutton>
|
|
Toshihiro Shimizu |
890ddd |
#include <qurl></qurl>
|
|
Toshihiro Shimizu |
890ddd |
#include <qapplication></qapplication>
|
|
Toshihiro Shimizu |
890ddd |
#include <qlabel></qlabel>
|
|
Toshihiro Shimizu |
890ddd |
#include <qdrag></qdrag>
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
726b1d |
TEnv::IntVar ShowNewStyleButton("ShowNewStyleButton", 1);
|
|
Toshihiro Shimizu |
890ddd |
using namespace PaletteViewerGUI;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
/*! \class PaletteViewer
|
|
manongjohn |
649b9a |
\brief The PaletteViewer class provides an object to view and
|
|
manongjohn |
649b9a |
manage palette view.
|
|
manongjohn |
649b9a |
|
|
manongjohn |
649b9a |
Inherits \b QWidget.
|
|
manongjohn |
649b9a |
|
|
manongjohn |
649b9a |
This object allows to show and manage palette; it's possible
|
|
manongjohn |
649b9a |
distinguish three
|
|
manongjohn |
649b9a |
view type, class can show: current level palette, current studio
|
|
manongjohn |
649b9a |
palette or
|
|
manongjohn |
649b9a |
current cleanup palette, using setPalette() to set palette
|
|
manongjohn |
649b9a |
viewer.
|
|
manongjohn |
649b9a |
The object is composed of a vertical layout with three widget:
|
|
manongjohn |
649b9a |
\li a tab bar \b PaletteViewerGUI::TabBar in which are displayed
|
|
manongjohn |
649b9a |
palette page
|
|
manongjohn |
649b9a |
\b createTabBar();
|
|
manongjohn |
649b9a |
\li a central frame \b PaletteViewerGUI::PageViewer in which are
|
|
manongjohn |
649b9a |
displayed
|
|
manongjohn |
649b9a |
all style of current page in palette
|
|
manongjohn |
649b9a |
\li a button bar, \b createToolBar(), \b createPaletteToolBar()
|
|
manongjohn |
649b9a |
and \b createSavePaletteToolBar();
|
|
manongjohn |
649b9a |
|
|
manongjohn |
649b9a |
A collection of method allows you to manage this object and its
|
|
manongjohn |
649b9a |
interaction
|
|
manongjohn |
649b9a |
with palette.
|
|
manongjohn |
649b9a |
*/
|
|
Toshihiro Shimizu |
890ddd |
/*! \fn const TPaletteP PaletteViewer::&getPalette() const
|
|
manongjohn |
649b9a |
Return current viewer palette.
|
|
manongjohn |
649b9a |
*/
|
|
Toshihiro Shimizu |
890ddd |
/*! \fn void PaletteViewer::createToolBar()
|
|
manongjohn |
649b9a |
Create down button bar.
|
|
manongjohn |
649b9a |
*/
|
|
Toshihiro Shimizu |
890ddd |
/*! \fn void PaletteViewer::updateToolBar()
|
|
manongjohn |
649b9a |
Update button bar.
|
|
manongjohn |
649b9a |
*/
|
|
Shinya Kitaoka |
120a6e |
PaletteViewer::PaletteViewer(QWidget *parent, PaletteViewType viewType,
|
|
Shinya Kitaoka |
120a6e |
bool hasSaveToolBar, bool hasPageCommand,
|
|
Shinya Kitaoka |
120a6e |
bool hasPasteColors)
|
|
Shinya Kitaoka |
120a6e |
: QFrame(parent)
|
|
Shinya Kitaoka |
120a6e |
, m_tabBarContainer(0)
|
|
Shinya Kitaoka |
120a6e |
, m_pagesBar(0)
|
|
Shinya Kitaoka |
120a6e |
, m_paletteToolBar(0)
|
|
Shinya Kitaoka |
120a6e |
, m_savePaletteToolBar(0)
|
|
Shinya Kitaoka |
120a6e |
, m_pageViewer(0)
|
|
Shinya Kitaoka |
120a6e |
, m_pageViewerScrollArea(0)
|
|
Shinya Kitaoka |
120a6e |
, m_indexPageToDelete(-1)
|
|
Shinya Kitaoka |
120a6e |
, m_viewType(viewType)
|
|
Shinya Kitaoka |
120a6e |
, m_frameHandle(0)
|
|
Shinya Kitaoka |
120a6e |
, m_paletteHandle(0)
|
|
Shinya Kitaoka |
120a6e |
, m_changeStyleCommand(0)
|
|
Shinya Kitaoka |
120a6e |
, m_xsheetHandle(0)
|
|
Shinya Kitaoka |
120a6e |
, m_hasSavePaletteToolbar(hasSaveToolBar)
|
|
Shinya Kitaoka |
120a6e |
, m_hasPageCommand(hasPageCommand)
|
|
Shinya Kitaoka |
120a6e |
, m_isSaveActionEnabled(true)
|
|
Shinya Kitaoka |
120a6e |
, m_lockPaletteAction(0)
|
|
Shinya Kitaoka |
120a6e |
, m_lockPaletteToolButton(0) {
|
|
Shinya Kitaoka |
120a6e |
setObjectName("OnePixelMarginFrame");
|
|
Shinya Kitaoka |
120a6e |
setFrameStyle(QFrame::StyledPanel);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
createTabBar();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Create pageView
|
|
Shinya Kitaoka |
120a6e |
m_pageViewerScrollArea = new QScrollArea();
|
|
Shinya Kitaoka |
120a6e |
m_pageViewerScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
Shinya Kitaoka |
120a6e |
m_pageViewerScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
|
Shinya Kitaoka |
120a6e |
m_pageViewerScrollArea->setWidgetResizable(true);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_pageViewer =
|
|
Shinya Kitaoka |
120a6e |
new PageViewer(m_pageViewerScrollArea, m_viewType, hasPasteColors);
|
|
Shinya Kitaoka |
120a6e |
m_pageViewerScrollArea->setWidget(m_pageViewer);
|
|
Shinya Kitaoka |
120a6e |
m_pagesBar->setPageViewer(m_pageViewer);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Create toolbar. It is an horizontal layout with three internal toolbar.
|
|
Shinya Kitaoka |
120a6e |
DvScrollWidget *toolbarScrollWidget = new DvScrollWidget;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
toolbarScrollWidget->setObjectName(
|
|
Shinya Kitaoka |
120a6e |
"ToolBarContainer"); // Toonz's qss files are instructed to leave a
|
|
manongjohn |
649b9a |
// 1px grey margin on top for scroll buttons
|
|
Shinya Kitaoka |
120a6e |
QWidget *toolBarWidget = new QWidget; // children of this parent name.
|
|
Shinya Kitaoka |
120a6e |
toolbarScrollWidget->setWidget(toolBarWidget);
|
|
Shinya Kitaoka |
120a6e |
toolBarWidget->setSizePolicy(QSizePolicy::MinimumExpanding,
|
|
Shinya Kitaoka |
120a6e |
QSizePolicy::Fixed);
|
|
Shinya Kitaoka |
120a6e |
toolBarWidget->setFixedHeight(22);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_paletteToolBar = new QToolBar(toolBarWidget);
|
|
Shinya Kitaoka |
120a6e |
m_savePaletteToolBar = new QToolBar(toolBarWidget);
|
|
Shinya Kitaoka |
120a6e |
createToolBar();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QHBoxLayout *toolBarLayout = new QHBoxLayout(toolBarWidget);
|
|
Shinya Kitaoka |
120a6e |
toolBarLayout->setMargin(0);
|
|
Shinya Kitaoka |
120a6e |
toolBarLayout->setSpacing(0);
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
toolBarLayout->addWidget(m_savePaletteToolBar, 0, Qt::AlignRight);
|
|
Shinya Kitaoka |
120a6e |
toolBarLayout->addWidget(m_paletteToolBar, 0, Qt::AlignRight);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
toolBarWidget->setLayout(toolBarLayout);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// This widget is used to set the background color of the tabBar
|
|
Shinya Kitaoka |
120a6e |
// using the styleSheet.
|
|
Shinya Kitaoka |
120a6e |
// It is also used to take 6px on the left before the tabBar
|
|
Shinya Kitaoka |
120a6e |
// and to draw the two lines on the bottom size
|
|
Shinya Kitaoka |
120a6e |
m_tabBarContainer = new TabBarContainter(this);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QVBoxLayout *mainLayout = new QVBoxLayout(this);
|
|
Shinya Kitaoka |
120a6e |
mainLayout->setMargin(0);
|
|
Shinya Kitaoka |
120a6e |
mainLayout->setSpacing(0);
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
// To add 6px (on the left) before the TabBar
|
|
Shinya Kitaoka |
120a6e |
QHBoxLayout *hLayout = new QHBoxLayout;
|
|
Shinya Kitaoka |
120a6e |
hLayout->setMargin(0);
|
|
Shinya Kitaoka |
120a6e |
// hLayout->setAlignment(Qt::AlignLeft);
|
|
Shinya Kitaoka |
120a6e |
// hLayout->addSpacing(6);
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
hLayout->addWidget(m_pagesBar, 0);
|
|
Shinya Kitaoka |
120a6e |
hLayout->addStretch(1);
|
|
Shinya Kitaoka |
120a6e |
hLayout->addWidget(toolbarScrollWidget, 0);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
m_tabBarContainer->setLayout(hLayout);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// To align this panel with the style Editor
|
|
Shinya Kitaoka |
120a6e |
mainLayout->addWidget(m_tabBarContainer, 0);
|
|
Shinya Kitaoka |
120a6e |
mainLayout->addWidget(m_pageViewerScrollArea, 1);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
setLayout(mainLayout);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
connect(m_pagesBar, SIGNAL(currentChanged(int)), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(setPageView(int)));
|
|
Shinya Kitaoka |
120a6e |
connect(m_pagesBar, SIGNAL(movePage(int, int)), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(movePage(int, int)));
|
|
Shinya Kitaoka |
120a6e |
connect(m_pageViewer, SIGNAL(changeWindowTitleSignal()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(changeWindowTitle()));
|
|
manongjohn |
649b9a |
connect(m_pageViewer, SIGNAL(switchToPage(int)), this,
|
|
manongjohn |
649b9a |
SLOT(onSwitchToPage(int)));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
changeWindowTitle();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
setAcceptDrops(true);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
PaletteViewer::~PaletteViewer() { delete m_changeStyleCommand; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::setPaletteHandle(TPaletteHandle *paletteHandle) {
|
|
Shinya Kitaoka |
120a6e |
if (m_paletteHandle == paletteHandle) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Kite |
521c84 |
bool ret = true;
|
|
Shinya Kitaoka |
120a6e |
if (m_paletteHandle) ret = ret && disconnect(m_paletteHandle, 0, this, 0);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_paletteHandle = paletteHandle;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_paletteHandle && isVisible()) {
|
|
Shinya Kitaoka |
120a6e |
ret = ret && connect(m_paletteHandle, SIGNAL(paletteSwitched()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onPaletteSwitched()));
|
|
Shinya Kitaoka |
120a6e |
ret = ret && connect(m_paletteHandle, SIGNAL(paletteChanged()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onPaletteChanged()));
|
|
Shinya Kitaoka |
120a6e |
ret = ret && connect(m_paletteHandle, SIGNAL(paletteChanged()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(changeWindowTitle()));
|
|
Shinya Kitaoka |
120a6e |
ret = ret && connect(m_paletteHandle, SIGNAL(paletteTitleChanged()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(changeWindowTitle()));
|
|
Shinya Kitaoka |
120a6e |
ret = ret && connect(m_paletteHandle, SIGNAL(colorStyleSwitched()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onColorStyleSwitched()));
|
|
shun_iwasawa |
e553fc |
ret = ret && connect(m_paletteHandle, SIGNAL(colorStyleChanged(bool)), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(changeWindowTitle()));
|
|
Shinya Kitaoka |
120a6e |
ret = ret && connect(m_paletteHandle, SIGNAL(paletteDirtyFlagChanged()),
|
|
Shinya Kitaoka |
120a6e |
this, SLOT(changeWindowTitle()));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(ret);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_viewType != CLEANUP_PALETTE)
|
|
Shinya Kitaoka |
120a6e |
m_keyFrameButton->setPaletteHandle(m_paletteHandle);
|
|
Shinya Kitaoka |
120a6e |
m_pageViewer->setPaletteHandle(m_paletteHandle);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
setPageView(0);
|
|
Shinya Kitaoka |
120a6e |
updateTabBar();
|
|
Shinya Kitaoka |
120a6e |
updatePaletteToolBar();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::setFrameHandle(TFrameHandle *frameHandle) {
|
|
Shinya Kitaoka |
120a6e |
m_frameHandle = frameHandle;
|
|
Shinya Kitaoka |
120a6e |
if (m_viewType != CLEANUP_PALETTE)
|
|
Shinya Kitaoka |
120a6e |
m_keyFrameButton->setFrameHandle(m_frameHandle);
|
|
Shinya Kitaoka |
120a6e |
m_pageViewer->setFrameHandle(m_frameHandle);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::setXsheetHandle(TXsheetHandle *xsheetHandle) {
|
|
Shinya Kitaoka |
120a6e |
m_xsheetHandle = xsheetHandle;
|
|
Shinya Kitaoka |
120a6e |
m_pageViewer->setXsheetHandle(m_xsheetHandle);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
/*!for clearing level cache after "paste style" command called from style
|
|
shun-iwasawa |
b37337 |
* selection
|
|
shun-iwasawa |
b37337 |
*/
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::setLevelHandle(TXshLevelHandle *levelHandle) {
|
|
Shinya Kitaoka |
120a6e |
m_pageViewer->setLevelHandle(levelHandle);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPalette *PaletteViewer::getPalette() {
|
|
Shinya Kitaoka |
120a6e |
if (!m_paletteHandle) return 0;
|
|
Shinya Kitaoka |
120a6e |
return m_paletteHandle->getPalette();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::updateView() {
|
|
Shinya Kitaoka |
120a6e |
changeWindowTitle();
|
|
Shinya Kitaoka |
120a6e |
setPageView(0);
|
|
Shinya Kitaoka |
120a6e |
clearStyleSelection();
|
|
Shinya Kitaoka |
120a6e |
updateTabBar();
|
|
Shinya Kitaoka |
120a6e |
updatePaletteToolBar();
|
|
Shinya Kitaoka |
120a6e |
updateSavePaletteToolBar();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::enableSaveAction(bool enable) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_savePaletteToolBar) return;
|
|
Shinya Kitaoka |
120a6e |
QList<qaction *=""> actions;</qaction>
|
|
Shinya Kitaoka |
120a6e |
actions = m_savePaletteToolBar->actions();
|
|
Shinya Kitaoka |
120a6e |
enable = !getPalette() ? false : enable;
|
|
Shinya Kitaoka |
120a6e |
m_isSaveActionEnabled = enable;
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < actions.count() - 1; i++) {
|
|
Shinya Kitaoka |
120a6e |
QAction *act = actions[i];
|
|
Shinya Kitaoka |
120a6e |
if (act->text() == tr("&Save Palette As") ||
|
|
Shinya Kitaoka |
120a6e |
act->text() == tr("&Save Palette"))
|
|
Shinya Kitaoka |
120a6e |
act->setEnabled(enable);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Create tab bar to select palette page.
|
|
shun-iwasawa |
b37337 |
*/
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::createTabBar() {
|
|
Shinya Kitaoka |
120a6e |
m_pagesBar = new PaletteTabBar(this, m_hasPageCommand);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
connect(m_pagesBar, SIGNAL(tabTextChanged(int)), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onTabTextChanged(int)));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (!getPalette()) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
updateTabBar();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Create right part of button bar.
|
|
shun-iwasawa |
b37337 |
*/
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::createPaletteToolBar() {
|
|
Shinya Kitaoka |
120a6e |
m_paletteToolBar->clear();
|
|
Shinya Kitaoka |
120a6e |
m_paletteToolBar->setMovable(false);
|
|
Kite |
521c84 |
m_paletteToolBar->setIconSize(QSize(20, 20));
|
|
Shinya Kitaoka |
120a6e |
m_paletteToolBar->setLayoutDirection(Qt::RightToLeft);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Lock button to avoid editing the palette by mistake
|
|
Shinya Kitaoka |
120a6e |
if (m_viewType == LEVEL_PALETTE) {
|
|
Shinya Kitaoka |
120a6e |
m_lockPaletteToolButton = new QToolButton(this);
|
|
Kite |
521c84 |
m_lockPaletteToolButton->setIcon(createQIcon("lock"));
|
|
Shinya Kitaoka |
120a6e |
m_lockPaletteToolButton->setCheckable(true);
|
|
Shinya Kitaoka |
120a6e |
m_lockPaletteToolButton->setObjectName("PaletteLockButton");
|
|
Shinya Kitaoka |
120a6e |
m_lockPaletteToolButton->setToolTip(tr("Lock Palette"));
|
|
Shinya Kitaoka |
120a6e |
if (getPalette()) {
|
|
Shinya Kitaoka |
120a6e |
m_lockPaletteToolButton->setChecked(getPalette()->isLocked());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
connect(m_lockPaletteToolButton, SIGNAL(clicked(bool)), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(setIsLocked(bool)));
|
|
Shinya Kitaoka |
120a6e |
m_paletteToolBar->addWidget(m_lockPaletteToolButton);
|
|
Shinya Kitaoka |
120a6e |
} else if (m_viewType == STUDIO_PALETTE) {
|
|
Shinya Kitaoka |
120a6e |
QToolButton *toolButton = new QToolButton(this);
|
|
Shinya Kitaoka |
120a6e |
toolButton->setPopupMode(QToolButton::InstantPopup);
|
|
Kite |
521c84 |
toolButton->setIcon(createQIcon("lock"));
|
|
Shinya Kitaoka |
120a6e |
toolButton->setObjectName("PaletteLockButton");
|
|
Shinya Kitaoka |
120a6e |
toolButton->setToolTip(tr("Lock Palette"));
|
|
Shinya Kitaoka |
120a6e |
toolButton->setCheckable(true);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QMenu *lockMenu = new QMenu(toolButton);
|
|
Shinya Kitaoka |
120a6e |
m_lockPaletteAction = new QAction(tr("&Lock Palette"), toolButton);
|
|
Shinya Kitaoka |
120a6e |
m_lockPaletteAction->setCheckable(true);
|
|
Shinya Kitaoka |
120a6e |
lockMenu->addAction(m_lockPaletteAction);
|
|
Shinya Kitaoka |
120a6e |
toolButton->setMenu(lockMenu);
|
|
Shinya Kitaoka |
120a6e |
if (getPalette()) {
|
|
Shinya Kitaoka |
120a6e |
m_lockPaletteAction->setChecked(getPalette()->isLocked());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
connect(m_lockPaletteAction, SIGNAL(triggered(bool)), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(setIsLocked(bool)));
|
|
Shinya Kitaoka |
120a6e |
connect(m_lockPaletteAction, SIGNAL(toggled(bool)), toolButton,
|
|
Shinya Kitaoka |
120a6e |
SLOT(setChecked(bool)));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_paletteToolBar->addWidget(toolButton);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Attenzione: alcune modifiche sono state fatte a livello di stylesheet
|
|
Shinya Kitaoka |
120a6e |
QToolButton *viewModeButton = new QToolButton(this);
|
|
Shinya Kitaoka |
120a6e |
viewModeButton->setPopupMode(QToolButton::InstantPopup);
|
|
Shinya Kitaoka |
120a6e |
|
|
Kite |
521c84 |
QIcon viewModeIcon = createQIcon("menu");
|
|
Shinya Kitaoka |
120a6e |
viewModeButton->setIcon(viewModeIcon);
|
|
Shinya Kitaoka |
120a6e |
QMenu *viewMode = new QMenu(QString("Options"), viewModeButton);
|
|
Shinya Kitaoka |
120a6e |
viewMode->setToolTip(tr("Options"));
|
|
shun-iwasawa |
b37337 |
viewMode->setLayoutDirection(Qt::LeftToRight);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QActionGroup *viewModeGroup = new QActionGroup(viewMode);
|
|
shun-iwasawa |
b37337 |
viewModeGroup->setExclusive(true);
|
|
Shinya Kitaoka |
120a6e |
connect(viewModeGroup, SIGNAL(triggered(QAction *)), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onViewMode(QAction *)));
|
|
Shinya Kitaoka |
120a6e |
|
|
shun-iwasawa |
b37337 |
auto addViewAction = [&](const QString &label, PageViewer::ViewMode mode) {
|
|
shun-iwasawa |
b37337 |
QAction *viewAction = new QAction(label, viewMode);
|
|
shun-iwasawa |
b37337 |
viewAction->setData(mode);
|
|
shun-iwasawa |
b37337 |
viewAction->setCheckable(true);
|
|
shun-iwasawa |
b37337 |
if (m_pageViewer->getViewMode() == mode) viewAction->setChecked(true);
|
|
shun-iwasawa |
b37337 |
viewModeGroup->addAction(viewAction);
|
|
shun-iwasawa |
b37337 |
viewMode->addAction(viewAction);
|
|
shun-iwasawa |
b37337 |
};
|
|
shun-iwasawa |
b37337 |
|
|
shun-iwasawa |
b37337 |
addViewAction(tr("&Small Thumbnails View"), PageViewer::SmallChips);
|
|
shun-iwasawa |
b37337 |
addViewAction(tr("&Medium Thumbnails View"), PageViewer::MediumChips);
|
|
shun-iwasawa |
b37337 |
addViewAction(tr("&Large Thumbnails View"), PageViewer::LargeChips);
|
|
shun-iwasawa |
b37337 |
addViewAction(tr("&List View"), PageViewer::List);
|
|
shun-iwasawa |
b37337 |
|
|
shun-iwasawa |
b37337 |
viewMode->addSeparator();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QActionGroup *nameDisplayModeGroup = new QActionGroup(viewMode);
|
|
shun-iwasawa |
b37337 |
nameDisplayModeGroup->setExclusive(true);
|
|
Shinya Kitaoka |
120a6e |
connect(nameDisplayModeGroup, SIGNAL(triggered(QAction *)), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onNameDisplayMode(QAction *)));
|
|
shun-iwasawa |
b37337 |
|
|
shun-iwasawa |
b37337 |
auto addNameDisplayAction = [&](const QString &label,
|
|
shun-iwasawa |
b37337 |
PageViewer::NameDisplayMode mode) {
|
|
shun-iwasawa |
b37337 |
QAction *nameDisplayAction = new QAction(label, viewMode);
|
|
shun-iwasawa |
b37337 |
nameDisplayAction->setData(mode);
|
|
shun-iwasawa |
b37337 |
nameDisplayAction->setCheckable(true);
|
|
shun-iwasawa |
b37337 |
if (m_pageViewer->getNameDisplayMode() == mode)
|
|
shun-iwasawa |
b37337 |
nameDisplayAction->setChecked(true);
|
|
shun-iwasawa |
b37337 |
nameDisplayModeGroup->addAction(nameDisplayAction);
|
|
shun-iwasawa |
b37337 |
viewMode->addAction(nameDisplayAction);
|
|
shun-iwasawa |
b37337 |
};
|
|
shun-iwasawa |
b37337 |
|
|
shun-iwasawa |
b37337 |
addNameDisplayAction(tr("Style Name"), PageViewer::Style);
|
|
shun-iwasawa |
b37337 |
addNameDisplayAction(tr("StudioPalette Name"), PageViewer::Original);
|
|
shun-iwasawa |
b37337 |
addNameDisplayAction(tr("Both Names"), PageViewer::StyleAndOriginal);
|
|
Shinya Kitaoka |
120a6e |
|
|
shun-iwasawa |
726b1d |
viewMode->addSeparator();
|
|
shun-iwasawa |
726b1d |
QString str = (ShowNewStyleButton) ? tr("Hide New Style Button")
|
|
shun-iwasawa |
726b1d |
: tr("Show New Style Button");
|
|
shun-iwasawa |
726b1d |
QAction *showNewStyleBtn = viewMode->addAction(str);
|
|
shun-iwasawa |
726b1d |
connect(showNewStyleBtn, SIGNAL(triggered()), this,
|
|
shun-iwasawa |
726b1d |
SLOT(onShowNewStyleButtonToggled()));
|
|
shun-iwasawa |
726b1d |
|
|
Shinya Kitaoka |
120a6e |
viewModeButton->setMenu(viewMode);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Attenzione: avendo invertito la direzione devo aggiungere gli oggetti al
|
|
Shinya Kitaoka |
120a6e |
// contrario
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_paletteToolBar->addWidget(viewModeButton);
|
|
Shinya Kitaoka |
120a6e |
m_paletteToolBar->addSeparator();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_hasPageCommand) {
|
|
Shinya Kitaoka |
120a6e |
QAction *addPage;
|
|
shun_iwasawa |
4a5f42 |
QIcon addPageIcon = createQIcon("newpage");
|
|
Shinya Kitaoka |
120a6e |
addPage = new QAction(addPageIcon, tr("&New Page"), m_paletteToolBar);
|
|
Shinya Kitaoka |
120a6e |
connect(addPage, SIGNAL(triggered()), this, SLOT(addNewPage()));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_paletteToolBar->addAction(addPage);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
shun_iwasawa |
4a5f42 |
QIcon newColorIcon = createQIcon("newstyle");
|
|
Shinya Kitaoka |
120a6e |
QAction *addColor =
|
|
Shinya Kitaoka |
120a6e |
new QAction(newColorIcon, tr("&New Style"), m_paletteToolBar);
|
|
Shinya Kitaoka |
120a6e |
connect(addColor, SIGNAL(triggered()), this, SLOT(addNewColor()));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_paletteToolBar->addAction(addColor);
|
|
Shinya Kitaoka |
120a6e |
m_paletteToolBar->addSeparator();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// KeyFrame button
|
|
Shinya Kitaoka |
120a6e |
if (m_viewType != CLEANUP_PALETTE) {
|
|
Shinya Kitaoka |
120a6e |
m_keyFrameButton = new PaletteKeyframeNavigator(m_paletteToolBar);
|
|
Shinya Kitaoka |
120a6e |
m_paletteToolBar->addWidget(m_keyFrameButton);
|
|
Shinya Kitaoka |
120a6e |
m_paletteToolBar->addSeparator();
|
|
Shinya Kitaoka |
120a6e |
m_keyFrameButton->setSelection(m_pageViewer->getSelection());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
updatePaletteToolBar();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Create left part of button bar; insert different actions in according to
|
|
manongjohn |
649b9a |
current viewer palette type.
|
|
manongjohn |
649b9a |
*/
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::createSavePaletteToolBar() {
|
|
Shinya Kitaoka |
120a6e |
m_savePaletteToolBar->clear();
|
|
Shinya Kitaoka |
120a6e |
m_savePaletteToolBar->setMovable(false);
|
|
Kite |
521c84 |
m_savePaletteToolBar->setIconSize(QSize(20, 20));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!m_hasSavePaletteToolbar || m_viewType == CLEANUP_PALETTE) {
|
|
Shinya Kitaoka |
120a6e |
m_savePaletteToolBar->hide();
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// save palette as
|
|
Kite |
521c84 |
QIcon saveAsPaletteIcon = createQIcon("saveas");
|
|
Shinya Kitaoka |
120a6e |
QAction *saveAsPalette = new QAction(
|
|
Shinya Kitaoka |
120a6e |
saveAsPaletteIcon, tr("&Save Palette As"), m_savePaletteToolBar);
|
|
Shinya Kitaoka |
120a6e |
// overwrite palette
|
|
Kite |
521c84 |
QIcon savePaletteIcon = createQIcon("save");
|
|
Shinya Kitaoka |
120a6e |
QAction *savePalette =
|
|
Shinya Kitaoka |
120a6e |
new QAction(savePaletteIcon, tr("&Save Palette"), m_savePaletteToolBar);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_viewType == STUDIO_PALETTE) {
|
|
Shinya Kitaoka |
120a6e |
connect(savePalette, SIGNAL(triggered()), this, SLOT(saveStudioPalette()));
|
|
Shinya Kitaoka |
120a6e |
m_savePaletteToolBar->addAction(savePalette);
|
|
Shinya Kitaoka |
120a6e |
} else if (m_viewType == LEVEL_PALETTE) {
|
|
Shinya Kitaoka |
120a6e |
// save load palette
|
|
Shinya Kitaoka |
120a6e |
PaletteIconWidget *movePalette =
|
|
Shinya Kitaoka |
120a6e |
new PaletteIconWidget(m_savePaletteToolBar);
|
|
Shinya Kitaoka |
120a6e |
connect(movePalette, SIGNAL(startDrag()), this, SLOT(startDragDrop()));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QAction *act = m_savePaletteToolBar->addWidget(movePalette);
|
|
Shinya Kitaoka |
120a6e |
act->setText(tr("&Move Palette"));
|
|
Shinya Kitaoka |
120a6e |
m_savePaletteToolBar->addSeparator();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// save palette as
|
|
Shinya Kitaoka |
120a6e |
connect(saveAsPalette, SIGNAL(triggered()),
|
|
Shinya Kitaoka |
120a6e |
CommandManager::instance()->getAction("MI_SavePaletteAs"),
|
|
Shinya Kitaoka |
120a6e |
SIGNAL(triggered()));
|
|
Shinya Kitaoka |
120a6e |
m_savePaletteToolBar->addAction(saveAsPalette);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// overwrite palette
|
|
Shinya Kitaoka |
120a6e |
connect(savePalette, SIGNAL(triggered()),
|
|
Shinya Kitaoka |
120a6e |
CommandManager::instance()->getAction("MI_OverwritePalette"),
|
|
Shinya Kitaoka |
120a6e |
SIGNAL(triggered()));
|
|
Shinya Kitaoka |
120a6e |
m_savePaletteToolBar->addAction(savePalette);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
updateSavePaletteToolBar();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Update page tab bar adding or removing tab in accord with viewer palette.
|
|
shun-iwasawa |
b37337 |
*/
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::updateTabBar() {
|
|
Shinya Kitaoka |
120a6e |
int tabCount = m_pagesBar->count();
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Se ci sono tab li butto
|
|
Shinya Kitaoka |
120a6e |
for (i = tabCount - 1; i >= 0; i--) m_pagesBar->removeTab(i);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPalette *palette = getPalette();
|
|
Shinya Kitaoka |
120a6e |
if (!palette) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Kite |
521c84 |
QIcon tabIcon = createQIcon("palette_tab");
|
|
Kite |
521c84 |
m_pagesBar->setIconSize(QSize(16, 16));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Aggiungo i tab in funzione delle pagine di m_palette
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < palette->getPageCount(); i++) {
|
|
Shinya Kitaoka |
120a6e |
TPalette::Page *page = palette->getPage(i);
|
|
Shinya Kitaoka |
120a6e |
std::wstring ws = page->getName();
|
|
Shinya Kitaoka |
120a6e |
QString pageName = QString::fromStdWString(ws);
|
|
Shinya Kitaoka |
120a6e |
m_pagesBar->addTab(tabIcon, pageName);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
m_pagesBar->update();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
/*! Update right button bar, enable its action if current viewer palette is
|
|
shun-iwasawa |
b37337 |
* empty.
|
|
shun-iwasawa |
b37337 |
*/
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::updatePaletteToolBar() {
|
|
Shinya Kitaoka |
120a6e |
if (!m_paletteToolBar) return;
|
|
Shinya Kitaoka |
120a6e |
QList<qaction *=""> actions;</qaction>
|
|
Shinya Kitaoka |
120a6e |
actions = m_paletteToolBar->actions();
|
|
Shinya Kitaoka |
120a6e |
TPalette *palette = getPalette();
|
|
Shinya Kitaoka |
120a6e |
bool enable = !palette ? false : true;
|
|
Shinya Kitaoka |
120a6e |
bool enableNewStyleAct = enable;
|
|
Shinya Kitaoka |
120a6e |
// limit the number of cleanup styles to 7
|
|
Shinya Kitaoka |
120a6e |
if (palette && palette->isCleanupPalette())
|
|
Shinya Kitaoka |
120a6e |
enableNewStyleAct = (palette->getStyleInPagesCount() < 8);
|
|
Shinya Kitaoka |
120a6e |
if (m_viewType != CLEANUP_PALETTE) m_keyFrameButton->setEnabled(enable);
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < actions.count(); i++) {
|
|
Shinya Kitaoka |
120a6e |
QAction *act = actions[i];
|
|
Shinya Kitaoka |
120a6e |
if (act->text() == tr("&New Style")) {
|
|
Shinya Kitaoka |
120a6e |
act->setEnabled(enableNewStyleAct);
|
|
Shinya Kitaoka |
120a6e |
continue;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
act->setEnabled(enable);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
/*! Update left button bar, enable its action if current viewer palette is
|
|
shun-iwasawa |
b37337 |
* empty.
|
|
shun-iwasawa |
b37337 |
*/
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::updateSavePaletteToolBar() {
|
|
Shinya Kitaoka |
120a6e |
if (!m_savePaletteToolBar) return;
|
|
Shinya Kitaoka |
120a6e |
QList<qaction *=""> actions;</qaction>
|
|
Shinya Kitaoka |
120a6e |
actions = m_savePaletteToolBar->actions();
|
|
Shinya Kitaoka |
120a6e |
bool enable = !getPalette() ? false : true;
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < actions.count(); i++) {
|
|
Shinya Kitaoka |
120a6e |
QAction *act = actions[i];
|
|
Shinya Kitaoka |
120a6e |
if (act->text() == tr("&Save Palette As") ||
|
|
Shinya Kitaoka |
120a6e |
act->text() == tr("&Save Palette") ||
|
|
Shinya Kitaoka |
120a6e |
act->text() == tr("&Palette Gizmo"))
|
|
Shinya Kitaoka |
120a6e |
act->setEnabled(enable);
|
|
Shinya Kitaoka |
120a6e |
else if (m_viewType != STUDIO_PALETTE && i == 0) // move action
|
|
Shinya Kitaoka |
120a6e |
actions[i]->setVisible(enable);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
actions[i]->setEnabled(false);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Resize the widget and its child.
|
|
shun-iwasawa |
b37337 |
*/
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::resizeEvent(QResizeEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
QWidget::resizeEvent(event);
|
|
Shinya Kitaoka |
120a6e |
if (m_pageViewer) m_pageViewer->computeSize();
|
|
Shinya Kitaoka |
120a6e |
if (m_pagesBar) m_pagesBar->setMaximumWidth(width() - 12);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::setChangeStyleCommand(
|
|
Shinya Kitaoka |
120a6e |
ChangeStyleCommand *changeStyleCommand) {
|
|
Shinya Kitaoka |
120a6e |
if (m_changeStyleCommand) delete m_changeStyleCommand;
|
|
Shinya Kitaoka |
120a6e |
m_changeStyleCommand = changeStyleCommand;
|
|
Shinya Kitaoka |
120a6e |
m_pageViewer->setChangeStyleCommand(m_changeStyleCommand);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Create and open the Right-click menu.
|
|
shun-iwasawa |
b37337 |
*/
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::contextMenuEvent(QContextMenuEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
m_indexPageToDelete = -1;
|
|
Shinya Kitaoka |
120a6e |
QPoint pos = event->pos();
|
|
Shinya Kitaoka |
120a6e |
if (!getPalette() || !m_tabBarContainer->geometry().contains(pos)) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QMenu *menu = new QMenu(this);
|
|
Shinya Kitaoka |
120a6e |
if (m_hasPageCommand) {
|
|
Shinya Kitaoka |
120a6e |
QAction *newPage = menu->addAction(tr("New Page"));
|
|
Shinya Kitaoka |
120a6e |
connect(newPage, SIGNAL(triggered()), SLOT(addNewPage()));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_pagesBar->geometry().contains(pos)) {
|
|
Shinya Kitaoka |
120a6e |
int tabIndex = m_pagesBar->tabAt(pos);
|
|
Shinya Kitaoka |
120a6e |
TPalette::Page *page = getPalette()->getPage(tabIndex);
|
|
Shinya Kitaoka |
120a6e |
if (page) {
|
|
Shinya Kitaoka |
120a6e |
bool canRemovePage = true;
|
|
Shinya Kitaoka |
120a6e |
if (page->getStyleId(0) == 0 || page->getStyleId(1) == 1)
|
|
Shinya Kitaoka |
120a6e |
canRemovePage = false;
|
|
Shinya Kitaoka |
120a6e |
if (canRemovePage) {
|
|
Shinya Kitaoka |
120a6e |
m_indexPageToDelete = tabIndex;
|
|
Shinya Kitaoka |
120a6e |
QAction *deletePage = menu->addAction(tr("Delete Page"));
|
|
Shinya Kitaoka |
120a6e |
connect(deletePage, SIGNAL(triggered()), SLOT(deletePage()));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_viewType == LEVEL_PALETTE && m_isSaveActionEnabled) {
|
|
Shinya Kitaoka |
120a6e |
menu->addSeparator();
|
|
Shinya Kitaoka |
120a6e |
menu->addAction(
|
|
Shinya Kitaoka |
120a6e |
CommandManager::instance()->getAction("MI_OverwritePalette"));
|
|
Shinya Kitaoka |
120a6e |
menu->addAction(CommandManager::instance()->getAction("MI_SavePaletteAs"));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
shun-iwasawa |
b37337 |
if (m_viewType == LEVEL_PALETTE && !getPalette()->isLocked() &&
|
|
shun-iwasawa |
b37337 |
m_isSaveActionEnabled &&
|
|
shun-iwasawa |
b37337 |
!FullColorPalette::instance()->isFullColorPalette(getPalette())) {
|
|
shun-iwasawa |
b37337 |
menu->addSeparator();
|
|
shun-iwasawa |
b37337 |
menu->addAction(
|
|
shun-iwasawa |
b37337 |
CommandManager::instance()->getAction("MI_EraseUnusedStyles"));
|
|
shun-iwasawa |
b37337 |
}
|
|
shun-iwasawa |
b37337 |
|
|
Shinya Kitaoka |
120a6e |
menu->exec(event->globalPos());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
b37337 |
void PaletteViewer::mousePressEvent(QMouseEvent *event) {
|
|
shun-iwasawa |
b37337 |
QFrame::mousePressEvent(event);
|
|
shun-iwasawa |
b37337 |
if (event->button() == Qt::RightButton) {
|
|
shun-iwasawa |
b37337 |
m_pageViewer->getSelection()->makeCurrent();
|
|
shun-iwasawa |
b37337 |
m_pageViewer->updateCommandLocks();
|
|
shun-iwasawa |
b37337 |
}
|
|
shun-iwasawa |
b37337 |
}
|
|
shun-iwasawa |
b37337 |
|
|
shun-iwasawa |
b37337 |
//-----------------------------------------------------------------------------
|
|
shun-iwasawa |
b37337 |
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::showEvent(QShowEvent *) {
|
|
Shinya Kitaoka |
120a6e |
onPaletteSwitched();
|
|
Shinya Kitaoka |
120a6e |
changeWindowTitle();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!m_paletteHandle) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
connect(m_paletteHandle, SIGNAL(paletteSwitched()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onPaletteSwitched()));
|
|
Shinya Kitaoka |
120a6e |
connect(m_paletteHandle, SIGNAL(paletteChanged()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onPaletteChanged()));
|
|
Shinya Kitaoka |
120a6e |
connect(m_paletteHandle, SIGNAL(paletteTitleChanged()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(changeWindowTitle()));
|
|
Shinya Kitaoka |
120a6e |
connect(m_paletteHandle, SIGNAL(colorStyleSwitched()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onColorStyleSwitched()));
|
|
shun_iwasawa |
e553fc |
connect(m_paletteHandle, SIGNAL(colorStyleChanged(bool)), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(changeWindowTitle()));
|
|
Shinya Kitaoka |
120a6e |
connect(m_paletteHandle, SIGNAL(paletteDirtyFlagChanged()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(changeWindowTitle()));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!m_frameHandle) return;
|
|
Shinya Kitaoka |
120a6e |
// Connessione necessaria per aggiornare lo stile in caso di palette animate.
|
|
Shinya Kitaoka |
120a6e |
connect(m_frameHandle, SIGNAL(frameSwitched()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onFrameSwitched()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::hideEvent(QHideEvent *) {
|
|
Shinya Kitaoka |
120a6e |
disconnect(m_paletteHandle, SIGNAL(paletteSwitched()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onPaletteSwitched()));
|
|
Shinya Kitaoka |
120a6e |
disconnect(m_paletteHandle, SIGNAL(paletteChanged()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onPaletteChanged()));
|
|
Shinya Kitaoka |
120a6e |
disconnect(m_paletteHandle, SIGNAL(paletteTitleChanged()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(changeWindowTitle()));
|
|
Shinya Kitaoka |
120a6e |
disconnect(m_paletteHandle, SIGNAL(colorStyleSwitched()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onColorStyleSwitched()));
|
|
shun_iwasawa |
e553fc |
disconnect(m_paletteHandle, SIGNAL(colorStyleChanged(bool)), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(changeWindowTitle()));
|
|
Shinya Kitaoka |
120a6e |
disconnect(m_paletteHandle, SIGNAL(paletteDirtyFlagChanged()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(changeWindowTitle()));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!m_frameHandle) return;
|
|
Shinya Kitaoka |
120a6e |
disconnect(m_frameHandle, SIGNAL(frameSwitched()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onFrameSwitched()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! If currente palette viewer exist verify event data, if is a PaletteData or
|
|
manongjohn |
649b9a |
has urls accept event.
|
|
manongjohn |
649b9a |
*/
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::dragEnterEvent(QDragEnterEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
TPalette *palette = getPalette();
|
|
Shinya Kitaoka |
120a6e |
if (!palette || m_viewType == CLEANUP_PALETTE) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
const QMimeData *mimeData = event->mimeData();
|
|
Shinya Kitaoka |
120a6e |
const PaletteData *paletteData = dynamic_cast<const *="" palettedata="">(mimeData);</const>
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (paletteData) {
|
|
Shinya Kitaoka |
120a6e |
// Sto "draggando" stili.
|
|
Shinya Kitaoka |
120a6e |
if (paletteData->hasStyleIndeces()) {
|
|
Shinya Kitaoka |
120a6e |
m_pageViewer->createDropPage();
|
|
manongjohn |
649b9a |
if (!palette) onSwitchToPage(palette->getPageCount() - 1);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
// Accetto l'evento
|
|
Shinya Kitaoka |
120a6e |
event->acceptProposedAction();
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!acceptResourceDrop(mimeData->urls())) return;
|
|
Shinya Kitaoka |
120a6e |
QList<qurl> urls = mimeData->urls();</qurl>
|
|
Shinya Kitaoka |
120a6e |
int count = urls.size();
|
|
Shinya Kitaoka |
120a6e |
if (count == 0) return;
|
|
Shinya Kitaoka |
120a6e |
// Accetto l'evento solo se ho tutte palette.
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < count; i++) {
|
|
Shinya Kitaoka |
120a6e |
TFilePath path(urls[i].toLocalFile().toStdWString());
|
|
Shinya Kitaoka |
120a6e |
if (!path.getType().empty() && path.getType() != "tpl") return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
manongjohn |
0036c5 |
// Force CopyAction
|
|
manongjohn |
0036c5 |
event->setDropAction(Qt::CopyAction);
|
|
manongjohn |
0036c5 |
// For files, don't accept original proposed action in case it's a move
|
|
manongjohn |
0036c5 |
event->accept();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Execute drop event.
|
|
shun-iwasawa |
b37337 |
*/
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::dropEvent(QDropEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
if (m_viewType == CLEANUP_PALETTE) return;
|
|
Shinya Kitaoka |
120a6e |
const QMimeData *mimeData = event->mimeData();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QPoint tollBarPos = m_savePaletteToolBar->mapFrom(this, event->pos());
|
|
Shinya Kitaoka |
120a6e |
QAction *currentAction = m_savePaletteToolBar->actionAt(tollBarPos);
|
|
Shinya Kitaoka |
120a6e |
bool loadPalette =
|
|
Shinya Kitaoka |
120a6e |
currentAction && currentAction->text() == QString(tr("&Move Palette"));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// ho i path delle palette
|
|
Shinya Kitaoka |
120a6e |
if (mimeData->hasUrls()) {
|
|
Shinya Kitaoka |
120a6e |
QList<qurl> urls = mimeData->urls();</qurl>
|
|
Shinya Kitaoka |
120a6e |
int count = urls.size();
|
|
Shinya Kitaoka |
120a6e |
if (count == 0) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < count; i++) {
|
|
Shinya Kitaoka |
120a6e |
TFilePath path(urls[i].toLocalFile().toStdWString());
|
|
Shinya Kitaoka |
120a6e |
if (!path.getType().empty() && path.getType() != "tpl") return;
|
|
Shinya Kitaoka |
120a6e |
if (loadPalette && i == 0) {
|
|
Shinya Kitaoka |
120a6e |
if (m_xsheetHandle) {
|
|
Shinya Kitaoka |
120a6e |
TPalette *newPalette =
|
|
Shinya Kitaoka |
120a6e |
StudioPalette::instance()->getPalette(path, false);
|
|
Shinya Kitaoka |
120a6e |
if (!newPalette) return;
|
|
Shinya Kitaoka |
120a6e |
int ret = DVGui::eraseStylesInDemand(getPalette(), m_xsheetHandle,
|
|
Shinya Kitaoka |
120a6e |
newPalette);
|
|
Shinya Kitaoka |
120a6e |
if (ret == 0) return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
StudioPaletteCmd::loadIntoCurrentPalette(m_paletteHandle, path);
|
|
manongjohn |
649b9a |
} else {
|
|
manongjohn |
649b9a |
int nextPageIndex = m_paletteHandle->getPalette()->getPageCount();
|
|
Shinya Kitaoka |
120a6e |
StudioPaletteCmd::mergeIntoCurrentPalette(m_paletteHandle, path);
|
|
manongjohn |
649b9a |
if (!i) onSwitchToPage(nextPageIndex);
|
|
manongjohn |
649b9a |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (loadPalette) {
|
|
Shinya Kitaoka |
120a6e |
TFilePath refImagePath =
|
|
Shinya Kitaoka |
120a6e |
StudioPalette::instance()->getPalette(path, true)->getRefImgPath();
|
|
Shinya Kitaoka |
120a6e |
if (!refImagePath.isEmpty() &&
|
|
Shinya Kitaoka |
120a6e |
getPalette()->getRefImgPath().isEmpty()) {
|
|
Shinya Kitaoka |
120a6e |
getPalette()->setRefImgPath(refImagePath);
|
|
Shinya Kitaoka |
120a6e |
m_paletteHandle->notifyPaletteChanged();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
manongjohn |
0036c5 |
// Force CopyAction
|
|
manongjohn |
0036c5 |
event->setDropAction(Qt::CopyAction);
|
|
manongjohn |
0036c5 |
// For files, don't accept original proposed action in case it's a move
|
|
manongjohn |
0036c5 |
event->accept();
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
const PaletteData *paletteData = dynamic_cast<const *="" palettedata="">(mimeData);</const>
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!paletteData) return;
|
|
Shinya Kitaoka |
120a6e |
// Sto inserendo stili
|
|
Shinya Kitaoka |
120a6e |
if (paletteData->hasStyleIndeces()) {
|
|
Shinya Kitaoka |
120a6e |
m_pageViewer->drop(-1, mimeData);
|
|
Shinya Kitaoka |
120a6e |
event->acceptProposedAction();
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
// Ho la palette da inserire
|
|
Shinya Kitaoka |
120a6e |
TPalette *palette = paletteData->getPalette();
|
|
Shinya Kitaoka |
120a6e |
if (getPalette() == palette) return;
|
|
Shinya Kitaoka |
120a6e |
if (loadPalette) {
|
|
Shinya Kitaoka |
120a6e |
if (m_xsheetHandle) {
|
|
Shinya Kitaoka |
120a6e |
int ret =
|
|
Shinya Kitaoka |
120a6e |
DVGui::eraseStylesInDemand(getPalette(), m_xsheetHandle, palette);
|
|
Shinya Kitaoka |
120a6e |
if (ret == 0) return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
StudioPaletteCmd::loadIntoCurrentPalette(m_paletteHandle, palette);
|
|
manongjohn |
649b9a |
} else {
|
|
manongjohn |
649b9a |
int nextPageIndex = m_paletteHandle->getPalette()->getPageCount();
|
|
Shinya Kitaoka |
120a6e |
StudioPaletteCmd::mergeIntoCurrentPalette(m_paletteHandle, palette);
|
|
manongjohn |
649b9a |
onSwitchToPage(nextPageIndex);
|
|
manongjohn |
649b9a |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Start drag and drop; if current page exist set drag and drop event data.
|
|
shun-iwasawa |
b37337 |
*/
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::startDragDrop() {
|
|
Shinya Kitaoka |
120a6e |
TRepetitionGuard guard;
|
|
Shinya Kitaoka |
120a6e |
if (!guard.hasLock()) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (m_viewType == CLEANUP_PALETTE) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
assert(m_viewType != STUDIO_PALETTE && m_viewType != CLEANUP_PALETTE);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPalette *palette = getPalette();
|
|
Shinya Kitaoka |
120a6e |
if (!palette) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QDrag *drag = new QDrag(this);
|
|
Shinya Kitaoka |
120a6e |
PaletteData *paletteData = new PaletteData();
|
|
Shinya Kitaoka |
120a6e |
paletteData->setPalette(palette);
|
|
Shinya Kitaoka |
120a6e |
drag->setMimeData(paletteData);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::clearStyleSelection() { m_pageViewer->clearSelection(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Set current view page to \b currentIndexPage
|
|
shun-iwasawa |
b37337 |
*/
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::setPageView(int currentIndexPage) {
|
|
Shinya Kitaoka |
120a6e |
TPalette *palette = getPalette();
|
|
Shinya Kitaoka |
120a6e |
TPalette::Page *page = palette ? palette->getPage(currentIndexPage) : 0;
|
|
Shinya Kitaoka |
120a6e |
m_pageViewer->setPage(page);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! If current palette viewer is not empty create emit a signal to create new
|
|
manongjohn |
649b9a |
palette page.
|
|
manongjohn |
649b9a |
*/
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::addNewPage() {
|
|
Shinya Kitaoka |
120a6e |
TPalette *palette = getPalette();
|
|
Shinya Kitaoka |
120a6e |
if (palette) {
|
|
Shinya Kitaoka |
120a6e |
if (palette->isLocked()) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
updateTabBar();
|
|
Shinya Kitaoka |
120a6e |
PaletteCmd::addPage(m_paletteHandle);
|
|
manongjohn |
649b9a |
onSwitchToPage(m_paletteHandle->getPalette()->getPageCount() - 1);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
/*! Create a new style in current page view of current palette viewer emit a
|
|
manongjohn |
649b9a |
signal
|
|
manongjohn |
649b9a |
to create a new style.
|
|
manongjohn |
649b9a |
*/
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::addNewColor() {
|
|
Shinya Kitaoka |
120a6e |
if (!getPalette() || getPalette()->isLocked()) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPalette::Page *page = m_pageViewer->getPage();
|
|
Shinya Kitaoka |
120a6e |
update();
|
|
Shinya Kitaoka |
120a6e |
PaletteCmd::createStyle(m_paletteHandle, page);
|
|
Shinya Kitaoka |
120a6e |
m_pageViewer->computeSize();
|
|
Shinya Kitaoka |
120a6e |
if (m_viewType == CLEANUP_PALETTE) updatePaletteToolBar();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Emit a signal to delete a page of current palette viewer.
|
|
shun-iwasawa |
b37337 |
*/
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::deletePage() {
|
|
Shinya Kitaoka |
120a6e |
TPalette *palette = getPalette();
|
|
Shinya Kitaoka |
120a6e |
if (!palette || palette->isLocked()) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_xsheetHandle) {
|
|
Shinya Kitaoka |
120a6e |
std::vector<int> styleIds;</int>
|
|
Shinya Kitaoka |
120a6e |
TPalette::Page *page = palette->getPage(m_indexPageToDelete);
|
|
Shinya Kitaoka |
120a6e |
if (!page) return; // La pagina dovrebbe esserci sempre
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < page->getStyleCount(); i++)
|
|
Shinya Kitaoka |
120a6e |
styleIds.push_back(page->getStyleId(i));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int ret = DVGui::eraseStylesInDemand(palette, styleIds, m_xsheetHandle);
|
|
Shinya Kitaoka |
120a6e |
if (ret == 0) return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
PaletteCmd::destroyPage(m_paletteHandle, m_indexPageToDelete);
|
|
Shinya Kitaoka |
120a6e |
updateTabBar();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
palette->setDirtyFlag(true);
|
|
Shinya Kitaoka |
120a6e |
if (m_viewType == CLEANUP_PALETTE) updatePaletteToolBar();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! If current palette view is studio palette and palette has a global name
|
|
manongjohn |
649b9a |
save current viewer palette in studio palette.
|
|
manongjohn |
649b9a |
*/
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::saveStudioPalette() {
|
|
Shinya Kitaoka |
120a6e |
StudioPalette *sp = StudioPalette::instance();
|
|
Shinya Kitaoka |
120a6e |
TPalette *palette = getPalette();
|
|
Shinya Kitaoka |
120a6e |
if (!palette) {
|
|
Shinya Kitaoka |
120a6e |
DVGui::warning("No current palette");
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
std::wstring gname = palette->getGlobalName();
|
|
Shinya Kitaoka |
120a6e |
if (gname.empty()) {
|
|
Shinya Kitaoka |
120a6e |
StudioPaletteViewer *parentSPV =
|
|
Shinya Kitaoka |
120a6e |
qobject_cast<studiopaletteviewer *="">(parentWidget());</studiopaletteviewer>
|
|
Shinya Kitaoka |
120a6e |
if (!parentSPV) {
|
|
Shinya Kitaoka |
120a6e |
DVGui::warning("No GlobalName");
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
TFilePath palettePath = parentSPV->getCurrentItemPath();
|
|
Shinya Kitaoka |
120a6e |
if (palettePath.isEmpty())
|
|
Shinya Kitaoka |
120a6e |
DVGui::warning("No GlobalName, No Filepath");
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
QString question;
|
|
Shinya Kitaoka |
120a6e |
question = "Do you want to overwrite current palette to " +
|
|
Shinya Kitaoka |
120a6e |
toQString(palettePath) + " ?";
|
|
Shinya Kitaoka |
120a6e |
int ret = DVGui::MsgBox(question, QObject::tr("Overwrite"),
|
|
Shinya Kitaoka |
120a6e |
QObject::tr("Don't Overwrite"), 0);
|
|
Shinya Kitaoka |
120a6e |
if (ret == 2 || ret == 0) return;
|
|
John Dancel |
35a3a8 |
try {
|
|
John Dancel |
35a3a8 |
StudioPalette::instance()->save(palettePath, palette);
|
|
John Dancel |
35a3a8 |
palette->setDirtyFlag(false);
|
|
John Dancel |
35a3a8 |
} catch (TSystemException se) {
|
|
John Dancel |
35a3a8 |
QApplication::restoreOverrideCursor();
|
|
John Dancel |
35a3a8 |
DVGui::warning(QString::fromStdWString(se.getMessage()));
|
|
John Dancel |
35a3a8 |
return;
|
|
John Dancel |
35a3a8 |
} catch (...) {
|
|
John Dancel |
35a3a8 |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TFilePath fp = sp->getPalettePath(gname);
|
|
Shinya Kitaoka |
120a6e |
if (fp != TFilePath()) {
|
|
Shinya Kitaoka |
120a6e |
QString question;
|
|
Shinya Kitaoka |
120a6e |
question = "Do you want to overwrite current studio palette to " +
|
|
Shinya Kitaoka |
120a6e |
toQString(fp) + " ?";
|
|
Shinya Kitaoka |
120a6e |
int ret =
|
|
Shinya Kitaoka |
120a6e |
DVGui::MsgBox(question, tr("Overwrite"), tr("Don't Overwrite"), 0);
|
|
Shinya Kitaoka |
120a6e |
if (ret == 2 || ret == 0) return;
|
|
shun-iwasawa |
7f18c9 |
try {
|
|
shun-iwasawa |
7f18c9 |
sp->setPalette(fp, getPalette(), false);
|
|
shun-iwasawa |
7f18c9 |
} catch (TSystemException se) {
|
|
shun-iwasawa |
7f18c9 |
DVGui::warning(QString::fromStdWString(se.getMessage()));
|
|
shun-iwasawa |
7f18c9 |
return;
|
|
shun-iwasawa |
7f18c9 |
} catch (...) {
|
|
shun-iwasawa |
7f18c9 |
DVGui::warning(QString::fromStdWString(fp.getWideString() + L"\n") +
|
|
shun-iwasawa |
7f18c9 |
tr("Failed to save palette."));
|
|
shun-iwasawa |
7f18c9 |
return;
|
|
shun-iwasawa |
7f18c9 |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
shun_iwasawa |
640862 |
StudioPaletteCmd::updateAllLinkedStyles(m_paletteHandle, m_xsheetHandle);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
palette->setDirtyFlag(false);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_paletteHandle->notifyPaletteChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! If current color switched update current page view.
|
|
shun-iwasawa |
b37337 |
*/
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::onColorStyleSwitched() {
|
|
Shinya Kitaoka |
120a6e |
TPalette *palette = getPalette();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// se non c'e' palette, pageviewer p pagina corrente esco (non dovrebbe
|
|
Shinya Kitaoka |
120a6e |
// succedere mai)
|
|
Shinya Kitaoka |
120a6e |
if (!palette || !m_pageViewer) return;
|
|
Shinya Kitaoka |
120a6e |
int styleIndex = m_paletteHandle->getStyleIndex();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
setPageView(m_pagesBar->currentIndex());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPalette::Page *page = m_pageViewer->getPage();
|
|
Shinya Kitaoka |
120a6e |
if (!page) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// faccio in modo che la pagina che contiene il colore selezionato diventi
|
|
Shinya Kitaoka |
120a6e |
// corrente
|
|
Shinya Kitaoka |
120a6e |
int indexInPage = page->search(styleIndex);
|
|
Shinya Kitaoka |
120a6e |
if (indexInPage == -1) {
|
|
Shinya Kitaoka |
120a6e |
if (!palette->getStylePage(styleIndex)) return;
|
|
Shinya Kitaoka |
120a6e |
int pageIndex = palette->getStylePage(styleIndex)->getIndex();
|
|
manongjohn |
649b9a |
onSwitchToPage(pageIndex);
|
|
Shinya Kitaoka |
120a6e |
indexInPage = m_pageViewer->getPage()->search(styleIndex);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QRect colorStyleRect = m_pageViewer->getItemRect(indexInPage);
|
|
Shinya Kitaoka |
120a6e |
m_pageViewerScrollArea->ensureVisible(colorStyleRect.center().x(),
|
|
Shinya Kitaoka |
120a6e |
colorStyleRect.center().y(),
|
|
Shinya Kitaoka |
120a6e |
colorStyleRect.size().width() / 2 + 4,
|
|
Shinya Kitaoka |
120a6e |
colorStyleRect.size().height() / 2 + 4);
|
|
Shinya Kitaoka |
120a6e |
m_pageViewer->update();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Update view. Remember current page bar index.
|
|
shun-iwasawa |
b37337 |
*/
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::onPaletteChanged() {
|
|
Shinya Kitaoka |
120a6e |
int index = m_pagesBar->currentIndex();
|
|
Shinya Kitaoka |
120a6e |
updateTabBar();
|
|
manongjohn |
649b9a |
onSwitchToPage(index);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_pageViewer->update();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (m_viewType == CLEANUP_PALETTE) updatePaletteToolBar();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
changeWindowTitle();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::onPaletteSwitched() {
|
|
Shinya Kitaoka |
120a6e |
updateView();
|
|
Shinya Kitaoka |
120a6e |
|
|
manongjohn |
649b9a |
int pageIndex = 0;
|
|
manongjohn |
649b9a |
if (m_paletteHandle) {
|
|
manongjohn |
649b9a |
TPalette *palette = m_paletteHandle->getPalette();
|
|
manongjohn |
649b9a |
if (palette) {
|
|
manongjohn |
649b9a |
int currentStyleId = palette->getCurrentStyleId();
|
|
manongjohn |
649b9a |
TPalette::Page *page = palette->getStylePage(currentStyleId);
|
|
Kite |
521c84 |
if (page) pageIndex = page->getIndex();
|
|
manongjohn |
649b9a |
}
|
|
manongjohn |
649b9a |
}
|
|
manongjohn |
649b9a |
onSwitchToPage(pageIndex);
|
|
manongjohn |
649b9a |
|
|
Shinya Kitaoka |
120a6e |
// update GUI according to the "lock" property
|
|
Shinya Kitaoka |
120a6e |
if (getPalette() && m_viewType != CLEANUP_PALETTE &&
|
|
Shinya Kitaoka |
120a6e |
(m_lockPaletteAction || m_lockPaletteToolButton)) {
|
|
Shinya Kitaoka |
120a6e |
if (m_lockPaletteAction) {
|
|
Shinya Kitaoka |
120a6e |
m_lockPaletteAction->setEnabled(true);
|
|
Shinya Kitaoka |
120a6e |
m_lockPaletteAction->setChecked(getPalette()->isLocked());
|
|
Shinya Kitaoka |
120a6e |
} else if (m_lockPaletteToolButton) {
|
|
Shinya Kitaoka |
120a6e |
m_lockPaletteToolButton->setEnabled(true);
|
|
Shinya Kitaoka |
120a6e |
m_lockPaletteToolButton->setChecked(getPalette()->isLocked());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
// update commands
|
|
Shinya Kitaoka |
120a6e |
m_pageViewer->updateCommandLocks();
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
if (m_lockPaletteAction)
|
|
Shinya Kitaoka |
120a6e |
m_lockPaletteAction->setEnabled(false);
|
|
Shinya Kitaoka |
120a6e |
else if (m_lockPaletteToolButton)
|
|
Shinya Kitaoka |
120a6e |
m_lockPaletteToolButton->setEnabled(false);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::onFrameSwitched() {
|
|
Shinya Kitaoka |
120a6e |
TPalette *palette = getPalette();
|
|
Shinya Kitaoka |
120a6e |
if (!palette) return;
|
|
Shinya Kitaoka |
120a6e |
palette->setFrame(m_frameHandle->getFrameIndex());
|
|
Shinya Kitaoka |
120a6e |
m_pageViewer->update();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Set a new name to palette page of index \b tabIndex.
|
|
shun-iwasawa |
b37337 |
*/
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::onTabTextChanged(int tabIndex) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_paletteHandle) return;
|
|
Shinya Kitaoka |
120a6e |
QString newName = m_pagesBar->tabText(tabIndex);
|
|
Shinya Kitaoka |
120a6e |
PaletteCmd::renamePalettePage(m_paletteHandle, tabIndex,
|
|
Shinya Kitaoka |
120a6e |
newName.toStdWString());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Change page style view mode.
|
|
shun-iwasawa |
b37337 |
*/
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::onViewMode(QAction *action) {
|
|
Shinya Kitaoka |
120a6e |
int viewMode = action->data().toInt();
|
|
Shinya Kitaoka |
120a6e |
m_pageViewer->setViewMode((PageViewer::ViewMode)viewMode);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
/*! Change name display mode on the style chips
|
|
shun-iwasawa |
b37337 |
*/
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::onNameDisplayMode(QAction *action) {
|
|
Shinya Kitaoka |
120a6e |
int nameDisplayMode = action->data().toInt();
|
|
Shinya Kitaoka |
120a6e |
m_pageViewer->setNameDisplayMode(
|
|
Shinya Kitaoka |
120a6e |
(PageViewer::NameDisplayMode)nameDisplayMode);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! If current view type is LEVEL_PALETTE add to window title current level
|
|
manongjohn |
649b9a |
name and current frame.
|
|
manongjohn |
649b9a |
*/
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::changeWindowTitle() {
|
|
Shinya Kitaoka |
120a6e |
QString name = tr("Palette");
|
|
Shinya Kitaoka |
120a6e |
QWidget *titleOwner;
|
|
Shinya Kitaoka |
120a6e |
TPalette *palette = getPalette();
|
|
Shinya Kitaoka |
120a6e |
if (m_viewType == LEVEL_PALETTE) {
|
|
Shinya Kitaoka |
120a6e |
name = tr("Level Palette: ");
|
|
Shinya Kitaoka |
120a6e |
if (palette) {
|
|
Shinya Kitaoka |
120a6e |
name = name + QString::fromStdWString(palette->getPaletteName());
|
|
Shinya Kitaoka |
120a6e |
if (palette->getDirtyFlag()) name += QString(" *");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
titleOwner = parentWidget();
|
|
Shinya Kitaoka |
120a6e |
} else if (m_viewType == CLEANUP_PALETTE) {
|
|
Shinya Kitaoka |
120a6e |
name = tr("Cleanup Palette");
|
|
Shinya Kitaoka |
120a6e |
titleOwner = parentWidget();
|
|
Shinya Kitaoka |
120a6e |
} else if (m_viewType == STUDIO_PALETTE) {
|
|
Shinya Kitaoka |
120a6e |
name = QString();
|
|
Shinya Kitaoka |
120a6e |
if (palette) {
|
|
Shinya Kitaoka |
120a6e |
if (palette->getDirtyFlag()) {
|
|
Shinya Kitaoka |
120a6e |
name = QString("* ");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
name = name + QString::fromStdWString(palette->getPaletteName()) +
|
|
Shinya Kitaoka |
120a6e |
QString(" : ");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
name += tr("Studio Palette");
|
|
Shinya Kitaoka |
120a6e |
titleOwner = parentWidget()->parentWidget();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// add color model name, if exists
|
|
Shinya Kitaoka |
120a6e |
TFilePath refImagePath = (palette) ? palette->getRefImgPath() : TFilePath();
|
|
Shinya Kitaoka |
120a6e |
if (!refImagePath.isEmpty()) {
|
|
Shinya Kitaoka |
120a6e |
QString cmName = tr(" (Color Model: ") +
|
|
Shinya Kitaoka |
120a6e |
QString::fromStdWString(refImagePath.getWideName()) +
|
|
Shinya Kitaoka |
120a6e |
tr(")");
|
|
Shinya Kitaoka |
120a6e |
name += cmName;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
titleOwner->setWindowTitle(name);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
/*! Move palette view page from \b srcIndex page index to \b dstIndex page
|
|
shun-iwasawa |
b37337 |
* index.
|
|
shun-iwasawa |
b37337 |
*/
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::movePage(int srcIndex, int dstIndex) {
|
|
Shinya Kitaoka |
120a6e |
PaletteCmd::movePalettePage(m_paletteHandle, srcIndex, dstIndex);
|
|
manongjohn |
649b9a |
onSwitchToPage(dstIndex);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Process when the lock button toggled
|
|
shun-iwasawa |
b37337 |
*/
|
|
Shinya Kitaoka |
120a6e |
void PaletteViewer::setIsLocked(bool lock) {
|
|
Shinya Kitaoka |
120a6e |
if (m_viewType == CLEANUP_PALETTE) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
getPalette()->setIsLocked(lock);
|
|
Shinya Kitaoka |
120a6e |
getPalette()->setDirtyFlag(true);
|
|
Shinya Kitaoka |
120a6e |
m_pageViewer->updateCommandLocks();
|
|
Shinya Kitaoka |
120a6e |
// notify for updating the style editor
|
|
Shinya Kitaoka |
120a6e |
m_paletteHandle->notifyPaletteLockChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
manongjohn |
649b9a |
|
|
manongjohn |
649b9a |
void PaletteViewer::onSwitchToPage(int pageIndex) {
|
|
manongjohn |
649b9a |
m_pagesBar->setCurrentIndex(pageIndex);
|
|
manongjohn |
649b9a |
}
|
|
shun-iwasawa |
726b1d |
|
|
shun-iwasawa |
726b1d |
//-----------------------------------------------------------------------------
|
|
shun-iwasawa |
726b1d |
|
|
shun-iwasawa |
726b1d |
void PaletteViewer::onShowNewStyleButtonToggled() {
|
|
shun-iwasawa |
726b1d |
ShowNewStyleButton = (ShowNewStyleButton == 1) ? 0 : 1;
|
|
shun-iwasawa |
726b1d |
QAction *act = dynamic_cast<qaction *="">(sender());</qaction>
|
|
shun-iwasawa |
726b1d |
if (act) {
|
|
shun-iwasawa |
726b1d |
QString str = (ShowNewStyleButton) ? tr("Hide New Style Button")
|
|
shun-iwasawa |
726b1d |
: tr("Show New Style Button");
|
|
shun-iwasawa |
726b1d |
act->setText(str);
|
|
shun-iwasawa |
726b1d |
}
|
|
shun-iwasawa |
726b1d |
m_pageViewer->computeSize();
|
|
shun-iwasawa |
726b1d |
m_pageViewer->update();
|
|
shun-iwasawa |
726b1d |
}
|