Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

view palette file

shun-iwasawa77a36f83a3be
diff --git a/toonz/sources/toonz/filebrowser.cpp b/toonz/sources/toonz/filebrowser.cpp
index 6ac745f18..c58355490 100644
--- a/toonz/sources/toonz/filebrowser.cpp
+++ b/toonz/sources/toonz/filebrowser.cpp
@@ -1192,7 +1192,9 @@ QMenu *FileBrowser::getContextMenu(QWidget *parent, int index) {
}
for (i = 0; i < files.size(); i++)
- if (!TFileType::isViewable(TFileType::getInfo(files[i]))) break;
+ if (!TFileType::isViewable(TFileType::getInfo(files[i])) &&
+ files[i].getType() != "tpl")
+ break;
if (i == files.size()) {
std::string type = files[0].getType();
for (j = 0; j < files.size(); j++)
diff --git a/toonz/sources/toonz/fileselection.cpp b/toonz/sources/toonz/fileselection.cpp
index e009bd57d..69958f370 100644
--- a/toonz/sources/toonz/fileselection.cpp
+++ b/toonz/sources/toonz/fileselection.cpp
@@ -23,12 +23,16 @@
#include "toonzqt/icongenerator.h"
#include "toonzqt/gutil.h"
#include "historytypes.h"
+#include "toonzqt/menubarcommand.h"
// TnzLib includes
#include "toonz/tproject.h"
#include "toonz/toonzscene.h"
#include "toonz/sceneresources.h"
#include "toonz/preferences.h"
+#include "toonz/studiopalette.h"
+#include "toonz/palettecontroller.h"
+#include "toonz/tpalettehandle.h"
// TnzCore includes
#include "tfiletype.h"
@@ -184,6 +188,8 @@ public:
return str;
}
};
+
+TPaletteP viewedPalette;
//-----------------------------------------------------------------------------
} // namespace
@@ -371,13 +377,22 @@ void FileSelection::viewFile() {
getSelectedFiles(files);
int i = 0;
for (i = 0; i < files.size(); i++) {
- if (!TFileType::isViewable(TFileType::getInfo(files[0]))) continue;
+ if (!TFileType::isViewable(TFileType::getInfo(files[i])) &&
+ files[i].getType() != "tpl")
+ continue;
if (Preferences::instance()->isDefaultViewerEnabled() &&
(files[i].getType() == "mov" || files[i].getType() == "avi" ||
files[i].getType() == "3gp"))
QDesktopServices::openUrl(QUrl("file:///" + toQString(files[i])));
- else {
+ else if (files[i].getType() == "tpl") {
+ viewedPalette = StudioPalette::instance()->getPalette(files[i], false);
+ TApp::instance()
+ ->getPaletteController()
+ ->getCurrentLevelPalette()
+ ->setPalette(viewedPalette.getPointer());
+ CommandManager::instance()->execute("MI_OpenPalette");
+ } else {
FlipBook *fb = ::viewFile(files[i]);
if (fb) {
FileBrowserPopup::setModalBrowserToParent(fb->parentWidget());
diff --git a/toonz/sources/toonz/tpanels.cpp b/toonz/sources/toonz/tpanels.cpp
index 1406d58d3..0fabc4a5a 100644
--- a/toonz/sources/toonz/tpanels.cpp
+++ b/toonz/sources/toonz/tpanels.cpp
@@ -569,6 +569,7 @@ void PaletteViewerPanel::onFreezeButtonToggled(bool frozen) {
// Cambio il livello corrente
if (!frozen) {
+ m_frozenPalette = nullptr;
std::set<TXshSimpleLevel *> levels;
TXsheet *xsheet = app->getCurrentXsheet()->getXsheet();
int row, column;
@@ -600,6 +601,7 @@ void PaletteViewerPanel::onFreezeButtonToggled(bool frozen) {
app->getCurrentLevel()->setLevel(level);
m_paletteViewer->setPaletteHandle(ph);
} else {
+ m_frozenPalette = ph->getPalette();
m_paletteHandle->setPalette(ph->getPalette());
m_paletteViewer->setPaletteHandle(m_paletteHandle);
}
diff --git a/toonz/sources/toonz/tpanels.h b/toonz/sources/toonz/tpanels.h
index 88e7cf46d..35a8eb7e4 100644
--- a/toonz/sources/toonz/tpanels.h
+++ b/toonz/sources/toonz/tpanels.h
@@ -44,6 +44,7 @@ class PaletteViewerPanel final : public StyleShortcutSwitchablePanel {
TPanelTitleBarButton *m_freezeButton;
bool m_isFrozen;
+ TPaletteP m_frozenPalette;
public:
PaletteViewerPanel(QWidget *parent);