|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "insertfxpopup.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Tnz6 includes
|
|
Toshihiro Shimizu |
890ddd |
#include "menubarcommandids.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tapp.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzQt includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/menubarcommand.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/gutil.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/fxselection.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/tselectionhandle.h"
|
|
Shinya Kitaoka |
120a6e |
#include "toonzqt/pluginloader.h" // inter-module plugin loader accessor
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzLib includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tscenehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txsheethandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tframehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tcolumnhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tfxhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/toonzscene.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txsheet.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/fxdag.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tcolumnfx.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshlevelcolumn.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tcolumnfxset.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tstageobjecttree.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshzeraryfxcolumn.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/toonzfolders.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/scenefx.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/fxcommand.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tw/stringtable.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzBase includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tdoubleparam.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tparamcontainer.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tmacrofx.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tfx.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "texternfx.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzCore includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tsystem.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Qt includes
|
|
Toshihiro Shimizu |
890ddd |
#include <qpushbutton></qpushbutton>
|
|
Toshihiro Shimizu |
890ddd |
#include <qtreewidget></qtreewidget>
|
|
Toshihiro Shimizu |
890ddd |
#include <qhboxlayout></qhboxlayout>
|
|
Toshihiro Shimizu |
890ddd |
#include <qheaderview></qheaderview>
|
|
Toshihiro Shimizu |
890ddd |
#include <qmenu></qmenu>
|
|
Toshihiro Shimizu |
890ddd |
#include <qcontextmenuevent></qcontextmenuevent>
|
|
Toshihiro Shimizu |
890ddd |
#include <qmainwindow></qmainwindow>
|
|
pojienie |
1cc671 |
#include <qlineedit></qlineedit>
|
|
pojienie |
1cc671 |
#include <qlabel></qlabel>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Campbell Barton |
40cabe |
#include <memory></memory>
|
|
Campbell Barton |
40cabe |
|
|
Toshihiro Shimizu |
890ddd |
using namespace DVGui;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Shinya Kitaoka |
120a6e |
namespace {
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFx *createFxByName(const std::string &fxId) {
|
|
Shinya Kitaoka |
120a6e |
if (fxId.find("_ext_") == 0) {
|
|
Shinya Kitaoka |
120a6e |
return TExternFx::create(fxId.substr(5));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (fxId.find("_plg_") == 0) {
|
|
Shinya Kitaoka |
120a6e |
return PluginLoader::create_host(fxId);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return TFx::create(fxId);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFx *createPresetFxByName(TFilePath path) {
|
|
Shinya Kitaoka |
120a6e |
const std::string &id = path.getParentDir().getName();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFx *fx = createFxByName(id);
|
|
Shinya Kitaoka |
120a6e |
if (fx) {
|
|
Shinya Kitaoka |
120a6e |
TIStream is(path);
|
|
Shinya Kitaoka |
120a6e |
fx->loadPreset(is);
|
|
Shinya Kitaoka |
120a6e |
fx->setName(path.getWideName());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return fx;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
shun-iwasawa |
272865 |
// same as createMacroFxByPath() in addfxcontextmenu.cpp
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFx *createMacroFxByPath(TFilePath path) {
|
|
shun-iwasawa |
272865 |
try {
|
|
shun-iwasawa |
272865 |
TIStream is(path);
|
|
shun-iwasawa |
272865 |
TPersist *p = 0;
|
|
shun-iwasawa |
272865 |
is >> p;
|
|
shun-iwasawa |
272865 |
TMacroFx *fx = dynamic_cast<tmacrofx *="">(p);</tmacrofx>
|
|
shun-iwasawa |
272865 |
if (!fx) return 0;
|
|
shun-iwasawa |
272865 |
fx->setName(path.getWideName());
|
|
shun-iwasawa |
272865 |
// Assign a unic ID to each fx in the macro!
|
|
shun-iwasawa |
272865 |
TApp *app = TApp::instance();
|
|
shun-iwasawa |
272865 |
TXsheet *xsh = app->getCurrentXsheet()->getXsheet();
|
|
shun-iwasawa |
272865 |
if (!xsh) return fx;
|
|
shun-iwasawa |
272865 |
FxDag *fxDag = xsh->getFxDag();
|
|
shun-iwasawa |
272865 |
if (!fxDag) return fx;
|
|
shun-iwasawa |
272865 |
std::vector<tfxp> fxs;</tfxp>
|
|
shun-iwasawa |
272865 |
fxs = fx->getFxs();
|
|
shun-iwasawa |
272865 |
QMap<std::wstring, std::wstring=""> oldNewId;</std::wstring,>
|
|
shun-iwasawa |
272865 |
int i;
|
|
shun-iwasawa |
272865 |
for (i = 0; i < fxs.size(); i++) {
|
|
shun-iwasawa |
272865 |
std::wstring oldId = fxs[i]->getFxId();
|
|
shun-iwasawa |
272865 |
fxDag->assignUniqueId(fxs[i].getPointer());
|
|
shun-iwasawa |
272865 |
std::wstring newId = fxs[i]->getFxId();
|
|
shun-iwasawa |
272865 |
oldNewId[oldId] = newId;
|
|
shun-iwasawa |
272865 |
|
|
shun-iwasawa |
272865 |
// changing the id of the internal effects of a macro breaks the links
|
|
shun-iwasawa |
272865 |
// between the name of the port and the port to which it is linked :
|
|
shun-iwasawa |
272865 |
// I have to change the names of the ports and remap them within the macro
|
|
shun-iwasawa |
272865 |
int j;
|
|
shun-iwasawa |
272865 |
for (j = 0; j < fx->getInputPortCount(); j++) {
|
|
shun-iwasawa |
272865 |
QString inputName = QString::fromStdString(fx->getInputPortName(j));
|
|
shun-iwasawa |
272865 |
if (inputName.endsWith(QString::fromStdWString(oldId))) {
|
|
shun-iwasawa |
272865 |
QString newInputName = inputName;
|
|
shun-iwasawa |
272865 |
newInputName.replace(QString::fromStdWString(oldId),
|
|
shun-iwasawa |
272865 |
QString::fromStdWString(newId));
|
|
shun-iwasawa |
272865 |
fx->renamePort(inputName.toStdString(), newInputName.toStdString());
|
|
shun-iwasawa |
272865 |
}
|
|
shun-iwasawa |
272865 |
}
|
|
shun-iwasawa |
272865 |
}
|
|
shun-iwasawa |
272865 |
|
|
shun-iwasawa |
272865 |
return fx;
|
|
shun-iwasawa |
272865 |
} catch (...) {
|
|
shun-iwasawa |
272865 |
return 0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
} // anonymous namespace
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
pojienie |
1cc671 |
// FxTree
|
|
pojienie |
1cc671 |
//=============================================================================
|
|
pojienie |
1cc671 |
|
|
pojienie |
d6e8b1 |
void FxTree::displayAll(QTreeWidgetItem *item) {
|
|
pojienie |
d6e8b1 |
int childCount = item->childCount();
|
|
pojienie |
d6e8b1 |
for (int i = 0; i < childCount; ++i) {
|
|
pojienie |
d6e8b1 |
displayAll(item->child(i));
|
|
pojienie |
d6e8b1 |
}
|
|
pojienie |
d6e8b1 |
item->setHidden(false);
|
|
pojienie |
d6e8b1 |
item->setExpanded(false);
|
|
pojienie |
d6e8b1 |
}
|
|
pojienie |
d6e8b1 |
|
|
pojienie |
d6e8b1 |
//-------------------------------------------------------------------
|
|
pojienie |
d6e8b1 |
|
|
pojienie |
d6e8b1 |
void FxTree::hideAll(QTreeWidgetItem *item) {
|
|
pojienie |
d6e8b1 |
int childCount = item->childCount();
|
|
pojienie |
d6e8b1 |
for (int i = 0; i < childCount; ++i) {
|
|
pojienie |
d6e8b1 |
hideAll(item->child(i));
|
|
pojienie |
d6e8b1 |
}
|
|
pojienie |
d6e8b1 |
item->setHidden(true);
|
|
pojienie |
d6e8b1 |
item->setExpanded(false);
|
|
pojienie |
d6e8b1 |
}
|
|
pojienie |
d6e8b1 |
|
|
pojienie |
d6e8b1 |
//-------------------------------------------------------------------
|
|
pojienie |
d6e8b1 |
|
|
pojienie |
1cc671 |
void FxTree::searchItems(const QString &searchWord) {
|
|
pojienie |
1cc671 |
// if search word is empty, show all items
|
|
pojienie |
1cc671 |
if (searchWord.isEmpty()) {
|
|
pojienie |
1cc671 |
int itemCount = topLevelItemCount();
|
|
pojienie |
1cc671 |
for (int i = 0; i < itemCount; ++i) {
|
|
pojienie |
d6e8b1 |
displayAll(topLevelItem(i));
|
|
pojienie |
1cc671 |
}
|
|
pojienie |
1cc671 |
update();
|
|
pojienie |
1cc671 |
return;
|
|
pojienie |
1cc671 |
}
|
|
pojienie |
1cc671 |
|
|
pojienie |
1cc671 |
// hide all items first
|
|
pojienie |
1cc671 |
int itemCount = topLevelItemCount();
|
|
pojienie |
1cc671 |
for (int i = 0; i < itemCount; ++i) {
|
|
pojienie |
d6e8b1 |
hideAll(topLevelItem(i));
|
|
pojienie |
1cc671 |
}
|
|
pojienie |
1cc671 |
|
|
pojienie |
1cc671 |
QList<qtreewidgetitem *=""> foundItems =</qtreewidgetitem>
|
|
pojienie |
1cc671 |
findItems(searchWord, Qt::MatchContains | Qt::MatchRecursive, 0);
|
|
pojienie |
1cc671 |
if (foundItems.isEmpty()) { // if nothing is found, do nothing but update
|
|
pojienie |
1cc671 |
update();
|
|
pojienie |
1cc671 |
return;
|
|
pojienie |
1cc671 |
}
|
|
pojienie |
1cc671 |
|
|
pojienie |
1cc671 |
// for each item found, show it and show its parent
|
|
pojienie |
1cc671 |
for (auto item : foundItems) {
|
|
pojienie |
d6e8b1 |
while (item) {
|
|
pojienie |
d6e8b1 |
item->setHidden(false);
|
|
pojienie |
d6e8b1 |
item->setExpanded(true);
|
|
pojienie |
d6e8b1 |
item = item->parent();
|
|
pojienie |
1cc671 |
}
|
|
pojienie |
1cc671 |
}
|
|
pojienie |
1cc671 |
|
|
pojienie |
1cc671 |
update();
|
|
pojienie |
1cc671 |
}
|
|
pojienie |
1cc671 |
|
|
pojienie |
1cc671 |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
/*! \class InsertFxPopup
|
|
Shinya Kitaoka |
120a6e |
\brief The InsertFxPopup class provides a dialog to browse fx
|
|
Shinya Kitaoka |
120a6e |
and add it to
|
|
Shinya Kitaoka |
120a6e |
current scene.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
Inherits \b Dialog.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
InsertFxPopup::InsertFxPopup()
|
|
Shinya Kitaoka |
120a6e |
: Dialog(TApp::instance()->getMainWindow(), true, false, "InsertFx")
|
|
Shinya Kitaoka |
120a6e |
, m_folderIcon(QIcon())
|
|
Shinya Kitaoka |
120a6e |
, m_presetIcon(QIcon())
|
|
Shinya Kitaoka |
120a6e |
, m_fxIcon(QIcon()) {
|
|
Shinya Kitaoka |
120a6e |
setWindowTitle(tr("FX Browser"));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
setModal(false);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
setTopMargin(0);
|
|
Shinya Kitaoka |
120a6e |
setTopSpacing(0);
|
|
Shinya Kitaoka |
120a6e |
|
|
pojienie |
1cc671 |
QHBoxLayout *searchLay = new QHBoxLayout();
|
|
pojienie |
1cc671 |
QLineEdit *searchEdit = new QLineEdit(this);
|
|
pojienie |
1cc671 |
|
|
pojienie |
1cc671 |
searchLay->setMargin(0);
|
|
pojienie |
1cc671 |
searchLay->setSpacing(5);
|
|
pojienie |
1cc671 |
searchLay->addWidget(new QLabel(tr("Search:"), this), 0);
|
|
pojienie |
1cc671 |
searchLay->addWidget(searchEdit);
|
|
pojienie |
1cc671 |
addLayout(searchLay);
|
|
pojienie |
1cc671 |
connect(searchEdit, SIGNAL(textChanged(const QString &)), this,
|
|
pojienie |
1cc671 |
SLOT(onSearchTextChanged(const QString &)));
|
|
pojienie |
1cc671 |
|
|
pojienie |
1cc671 |
m_fxTree = new FxTree();
|
|
Kite |
521c84 |
m_fxTree->setIconSize(QSize(21, 18));
|
|
Shinya Kitaoka |
120a6e |
m_fxTree->setColumnCount(1);
|
|
Shinya Kitaoka |
120a6e |
m_fxTree->header()->close();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_fxTree->setObjectName("FxTreeView");
|
|
Shinya Kitaoka |
120a6e |
m_fxTree->setAlternatingRowColors(true);
|
|
Shinya Kitaoka |
120a6e |
|
|
Kite |
521c84 |
m_presetIcon = createQIcon("folder_preset", true);
|
|
Kite |
521c84 |
m_fxIcon = createQIcon("fx");
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QList<qtreewidgetitem *=""> fxItems;</qtreewidgetitem>
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TFilePath path = TFilePath(ToonzFolder::getProfileFolder() + "layouts" +
|
|
Shinya Kitaoka |
120a6e |
"fxs" + "fxs.lst");
|
|
Shinya Kitaoka |
120a6e |
m_presetFolder = TFilePath(ToonzFolder::getFxPresetFolder() + "presets");
|
|
Shinya Kitaoka |
120a6e |
loadFx(path);
|
|
Shinya Kitaoka |
120a6e |
loadMacro();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// add 'Plugins' directory
|
|
Shinya Kitaoka |
120a6e |
auto plugins =
|
|
Shinya Kitaoka |
120a6e |
new QTreeWidgetItem((QTreeWidget *)NULL, QStringList("Plugins"));
|
|
Kite |
521c84 |
plugins->setIcon(0, createQIcon("folder", true));
|
|
Shinya Kitaoka |
120a6e |
m_fxTree->addTopLevelItem(plugins);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// create vendor / Fx
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// send a special setup for the menu item
|
|
Shinya Kitaoka |
120a6e |
std::map<std::string, *="" qtreewidgetitem=""> vendors =</std::string,>
|
|
Shinya Kitaoka |
120a6e |
PluginLoader::create_menu_items(
|
|
Shinya Kitaoka |
120a6e |
[&](QTreeWidgetItem *firstlevel_item) {
|
|
Shinya Kitaoka |
120a6e |
plugins->addChild(firstlevel_item);
|
|
Kite |
521c84 |
firstlevel_item->setIcon(0, createQIcon("folder"));
|
|
Shinya Kitaoka |
120a6e |
},
|
|
Shinya Kitaoka |
120a6e |
[&](QTreeWidgetItem *secondlevel_item) {
|
|
Shinya Kitaoka |
120a6e |
secondlevel_item->setIcon(0, m_fxIcon);
|
|
Shinya Kitaoka |
120a6e |
});
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_fxTree->insertTopLevelItems(0, fxItems);
|
|
Shinya Kitaoka |
120a6e |
connect(m_fxTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)),
|
|
Shinya Kitaoka |
120a6e |
SLOT(onItemDoubleClicked(QTreeWidgetItem *, int)));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
addWidget(m_fxTree);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QPushButton *insertBtn = new QPushButton(tr("Insert"), this);
|
|
flurick |
839284 |
insertBtn->setMinimumSize(65, 25);
|
|
pojienie |
49b15f |
insertBtn->setObjectName("PushButton_NoPadding");
|
|
Shinya Kitaoka |
120a6e |
connect(insertBtn, SIGNAL(clicked()), this, SLOT(onInsert()));
|
|
Shinya Kitaoka |
120a6e |
insertBtn->setDefault(true);
|
|
Shinya Kitaoka |
120a6e |
m_buttonLayout->addWidget(insertBtn);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QPushButton *addBtn = new QPushButton(tr("Add"), this);
|
|
flurick |
839284 |
addBtn->setMinimumSize(65, 25);
|
|
pojienie |
49b15f |
addBtn->setObjectName("PushButton_NoPadding");
|
|
Shinya Kitaoka |
120a6e |
connect(addBtn, SIGNAL(clicked()), this, SLOT(onAdd()));
|
|
Shinya Kitaoka |
120a6e |
m_buttonLayout->addWidget(addBtn);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QPushButton *replaceBtn = new QPushButton(tr("Replace"), this);
|
|
flurick |
1f25a0 |
replaceBtn->setMinimumSize(65, 25);
|
|
pojienie |
49b15f |
replaceBtn->setObjectName("PushButton_NoPadding");
|
|
Shinya Kitaoka |
120a6e |
connect(replaceBtn, SIGNAL(clicked()), this, SLOT(onReplace()));
|
|
Shinya Kitaoka |
120a6e |
m_buttonLayout->addWidget(replaceBtn);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
pojienie |
1cc671 |
void InsertFxPopup::onSearchTextChanged(const QString &text) {
|
|
pojienie |
1cc671 |
static bool busy = false;
|
|
pojienie |
1cc671 |
if (busy) return;
|
|
pojienie |
1cc671 |
busy = true;
|
|
pojienie |
1cc671 |
m_fxTree->searchItems(text);
|
|
pojienie |
1cc671 |
busy = false;
|
|
pojienie |
1cc671 |
}
|
|
pojienie |
1cc671 |
|
|
pojienie |
1cc671 |
//-------------------------------------------------------------------
|
|
pojienie |
1cc671 |
|
|
Shinya Kitaoka |
120a6e |
void InsertFxPopup::makeItem(QTreeWidgetItem *parent, std::string fxId) {
|
|
Shinya Kitaoka |
120a6e |
QTreeWidgetItem *fxItem = new QTreeWidgetItem(
|
|
Shinya Kitaoka |
120a6e |
(QTreeWidget *)0,
|
|
Shinya Kitaoka |
120a6e |
QStringList(QString::fromStdWString(TStringTable::translate(fxId))));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
fxItem->setData(0, Qt::UserRole, QVariant(QString::fromStdString(fxId)));
|
|
Shinya Kitaoka |
120a6e |
parent->addChild(fxItem);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
fxItem->setIcon(0, loadPreset(fxItem) ? m_presetIcon : m_fxIcon);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void InsertFxPopup::loadFolder(QTreeWidgetItem *parent) {
|
|
Shinya Kitaoka |
120a6e |
while (!m_is->eos()) {
|
|
Shinya Kitaoka |
120a6e |
std::string tagName;
|
|
Shinya Kitaoka |
120a6e |
if (m_is->matchTag(tagName)) {
|
|
Shinya Kitaoka |
120a6e |
// Found a sub-folder
|
|
Shinya Kitaoka |
120a6e |
QString folderName = QString::fromStdString(tagName);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
2a7129 |
std::unique_ptr<qtreewidgetitem> folder(</qtreewidgetitem>
|
|
Shinya Kitaoka |
120a6e |
new QTreeWidgetItem((QTreeWidget *)0, QStringList(folderName)));
|
|
Kite |
521c84 |
folder->setIcon(0, createQIcon("folder", true));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
loadFolder(folder.get());
|
|
Shinya Kitaoka |
120a6e |
m_is->closeChild();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (folder->childCount()) {
|
|
Shinya Kitaoka |
120a6e |
if (parent)
|
|
Shinya Kitaoka |
120a6e |
parent->addChild(folder.release());
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
m_fxTree->addTopLevelItem(folder.release());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
// Found an fx
|
|
Shinya Kitaoka |
120a6e |
std::string fxName;
|
|
Shinya Kitaoka |
120a6e |
*m_is >> fxName;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
makeItem(parent, fxName);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool InsertFxPopup::loadFx(TFilePath fp) {
|
|
Shinya Kitaoka |
120a6e |
TIStream is(fp);
|
|
Shinya Kitaoka |
120a6e |
if (!is) return false;
|
|
Shinya Kitaoka |
120a6e |
m_is = &is;
|
|
Shinya Kitaoka |
120a6e |
try {
|
|
Shinya Kitaoka |
120a6e |
std::string tagName;
|
|
Shinya Kitaoka |
120a6e |
if (m_is->matchTag(tagName) && tagName == "fxs") {
|
|
Shinya Kitaoka |
120a6e |
loadFolder(0);
|
|
Shinya Kitaoka |
120a6e |
m_is->closeChild();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} catch (...) {
|
|
Shinya Kitaoka |
120a6e |
m_is = 0;
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
m_is = 0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool InsertFxPopup::loadPreset(QTreeWidgetItem *item) {
|
|
Shinya Kitaoka |
120a6e |
QString str = item->data(0, Qt::UserRole).toString();
|
|
Shinya Kitaoka |
120a6e |
TFilePath presetsFilepath(m_presetFolder + str.toStdWString());
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
for (i = item->childCount() - 1; i >= 0; i--)
|
|
Shinya Kitaoka |
120a6e |
item->removeChild(item->child(i));
|
|
Shinya Kitaoka |
120a6e |
if (TFileStatus(presetsFilepath).isDirectory()) {
|
|
Shinya Kitaoka |
120a6e |
TFilePathSet presets = TSystem::readDirectory(presetsFilepath);
|
|
Shinya Kitaoka |
120a6e |
if (!presets.empty()) {
|
|
Shinya Kitaoka |
120a6e |
for (TFilePathSet::iterator it2 = presets.begin(); it2 != presets.end();
|
|
Shinya Kitaoka |
120a6e |
++it2) {
|
|
Shinya Kitaoka |
120a6e |
TFilePath presetPath = *it2;
|
|
Shinya Kitaoka |
120a6e |
QString name(presetPath.getName().c_str());
|
|
Shinya Kitaoka |
120a6e |
QTreeWidgetItem *presetItem =
|
|
Shinya Kitaoka |
120a6e |
new QTreeWidgetItem((QTreeWidget *)0, QStringList(name));
|
|
Shinya Kitaoka |
120a6e |
presetItem->setData(0, Qt::UserRole, QVariant(toQString(presetPath)));
|
|
Shinya Kitaoka |
120a6e |
item->addChild(presetItem);
|
|
Shinya Kitaoka |
120a6e |
presetItem->setIcon(0, m_fxIcon);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void InsertFxPopup::loadMacro() {
|
|
Shinya Kitaoka |
120a6e |
TFilePath fp = m_presetFolder + TFilePath("macroFx");
|
|
Shinya Kitaoka |
120a6e |
try {
|
|
Shinya Kitaoka |
120a6e |
if (TFileStatus(fp).isDirectory()) {
|
|
Shinya Kitaoka |
120a6e |
TFilePathSet macros = TSystem::readDirectory(fp);
|
|
Shinya Kitaoka |
120a6e |
if (macros.empty()) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QTreeWidgetItem *macroFolder =
|
|
Shinya Kitaoka |
120a6e |
new QTreeWidgetItem((QTreeWidget *)0, QStringList(tr("Macro")));
|
|
Shinya Kitaoka |
120a6e |
macroFolder->setData(0, Qt::UserRole, QVariant(toQString(fp)));
|
|
Kite |
521c84 |
macroFolder->setIcon(0, createQIcon("folder", true));
|
|
Shinya Kitaoka |
120a6e |
m_fxTree->addTopLevelItem(macroFolder);
|
|
Shinya Kitaoka |
120a6e |
for (TFilePathSet::iterator it = macros.begin(); it != macros.end();
|
|
Shinya Kitaoka |
120a6e |
++it) {
|
|
Shinya Kitaoka |
120a6e |
TFilePath macroPath = *it;
|
|
Shinya Kitaoka |
120a6e |
QString name(macroPath.getName().c_str());
|
|
Shinya Kitaoka |
120a6e |
QTreeWidgetItem *macroItem =
|
|
Shinya Kitaoka |
120a6e |
new QTreeWidgetItem((QTreeWidget *)0, QStringList(name));
|
|
Shinya Kitaoka |
120a6e |
macroItem->setData(0, Qt::UserRole, QVariant(toQString(macroPath)));
|
|
Shinya Kitaoka |
120a6e |
macroItem->setIcon(0, m_fxIcon);
|
|
Shinya Kitaoka |
120a6e |
macroFolder->addChild(macroItem);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} catch (...) {
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void InsertFxPopup::onItemDoubleClicked(QTreeWidgetItem *w, int c) {
|
|
Shinya Kitaoka |
120a6e |
if (w->childCount() == 0) // E' una foglia
|
|
Shinya Kitaoka |
120a6e |
onInsert();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void InsertFxPopup::onInsert() {
|
|
Shinya Kitaoka |
120a6e |
TFx *fx = createFx();
|
|
Shinya Kitaoka |
120a6e |
if (fx) {
|
|
Shinya Kitaoka |
120a6e |
TApp *app = TApp::instance();
|
|
Shinya Kitaoka |
120a6e |
TXsheetHandle *xshHandle = app->getCurrentXsheet();
|
|
Shinya Kitaoka |
120a6e |
QList<tfxp> fxs;</tfxp>
|
|
Shinya Kitaoka |
120a6e |
QList<tfxcommand::link> links;</tfxcommand::link>
|
|
Shinya Kitaoka |
120a6e |
FxSelection *selection =
|
|
Shinya Kitaoka |
120a6e |
dynamic_cast<fxselection *="">(app->getCurrentSelection()->getSelection());</fxselection>
|
|
Shinya Kitaoka |
120a6e |
if (selection) {
|
|
Shinya Kitaoka |
120a6e |
fxs = selection->getFxs();
|
|
Shinya Kitaoka |
120a6e |
links = selection->getLinks();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
TFxCommand::insertFx(fx, fxs, links, app,
|
|
Shinya Kitaoka |
120a6e |
app->getCurrentColumn()->getColumnIndex(),
|
|
Shinya Kitaoka |
120a6e |
app->getCurrentFrame()->getFrameIndex());
|
|
Shinya Kitaoka |
120a6e |
xshHandle->notifyXsheetChanged();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void InsertFxPopup::onAdd() {
|
|
Shinya Kitaoka |
120a6e |
TFx *fx = createFx();
|
|
Shinya Kitaoka |
120a6e |
if (fx) {
|
|
Shinya Kitaoka |
120a6e |
TApp *app = TApp::instance();
|
|
Shinya Kitaoka |
120a6e |
TXsheetHandle *xshHandle = app->getCurrentXsheet();
|
|
Shinya Kitaoka |
120a6e |
QList<tfxp> fxs;</tfxp>
|
|
Shinya Kitaoka |
120a6e |
FxSelection *selection =
|
|
Shinya Kitaoka |
120a6e |
dynamic_cast<fxselection *="">(app->getCurrentSelection()->getSelection());</fxselection>
|
|
Shinya Kitaoka |
120a6e |
if (selection) fxs = selection->getFxs();
|
|
Shinya Kitaoka |
120a6e |
TFxCommand::addFx(fx, fxs, app, app->getCurrentColumn()->getColumnIndex(),
|
|
Shinya Kitaoka |
120a6e |
app->getCurrentFrame()->getFrameIndex());
|
|
Shinya Kitaoka |
120a6e |
xshHandle->notifyXsheetChanged();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void InsertFxPopup::onReplace() {
|
|
Shinya Kitaoka |
120a6e |
TFx *fx = createFx();
|
|
Shinya Kitaoka |
120a6e |
if (fx) {
|
|
Shinya Kitaoka |
120a6e |
TApp *app = TApp::instance();
|
|
Shinya Kitaoka |
120a6e |
TXsheetHandle *xshHandle = app->getCurrentXsheet();
|
|
Shinya Kitaoka |
120a6e |
QList<tfxp> fxs;</tfxp>
|
|
Shinya Kitaoka |
120a6e |
FxSelection *selection =
|
|
Shinya Kitaoka |
120a6e |
dynamic_cast<fxselection *="">(app->getCurrentSelection()->getSelection());</fxselection>
|
|
Shinya Kitaoka |
120a6e |
if (selection) fxs = selection->getFxs();
|
|
Shinya Kitaoka |
120a6e |
TFxCommand::replaceFx(fx, fxs, app->getCurrentXsheet(),
|
|
Shinya Kitaoka |
120a6e |
app->getCurrentFx());
|
|
Shinya Kitaoka |
120a6e |
xshHandle->notifyXsheetChanged();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFx *InsertFxPopup::createFx() {
|
|
Shinya Kitaoka |
120a6e |
TApp *app = TApp::instance();
|
|
Shinya Kitaoka |
120a6e |
ToonzScene *scene = app->getCurrentScene()->getScene();
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = scene->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QTreeWidgetItem *item = m_fxTree->currentItem();
|
|
pojienie |
c99df6 |
if (item == NULL) return 0;
|
|
Shinya Kitaoka |
120a6e |
|
|
pojienie |
c99df6 |
QString text = item->data(0, Qt::UserRole).toString();
|
|
Shinya Kitaoka |
120a6e |
if (text.isEmpty()) return 0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TFx *fx;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TFilePath path = TFilePath(text.toStdWString());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (TFileStatus(path).doesExist() &&
|
|
Shinya Kitaoka |
120a6e |
TFileStatus(path.getParentDir()).isDirectory()) {
|
|
Shinya Kitaoka |
120a6e |
std::string folder = path.getParentDir().getName();
|
|
Shinya Kitaoka |
120a6e |
if (folder == "macroFx") // Devo caricare una macro
|
|
Shinya Kitaoka |
120a6e |
fx = createMacroFxByPath(path);
|
|
Shinya Kitaoka |
120a6e |
else // Verifico se devo caricare un preset
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
folder = path.getParentDir().getParentDir().getName();
|
|
Shinya Kitaoka |
120a6e |
if (folder == "presets") // Devo caricare un preset
|
|
Shinya Kitaoka |
120a6e |
fx = createPresetFxByName(path);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
fx = createFxByName(text.toStdString());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fx)
|
|
Shinya Kitaoka |
120a6e |
return fx;
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void InsertFxPopup::showEvent(QShowEvent *) {
|
|
Shinya Kitaoka |
120a6e |
updatePresets();
|
|
Shinya Kitaoka |
120a6e |
connect(TApp::instance()->getCurrentFx(), SIGNAL(fxPresetSaved()),
|
|
Shinya Kitaoka |
120a6e |
SLOT(updatePresets()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void InsertFxPopup::hideEvent(QHideEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
disconnect(TApp::instance()->getCurrentFx(), SIGNAL(fxPresetSaved()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(updatePresets()));
|
|
Shinya Kitaoka |
120a6e |
Dialog::hideEvent(e);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void InsertFxPopup::contextMenuEvent(QContextMenuEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
QTreeWidgetItem *item = m_fxTree->currentItem();
|
|
Shinya Kitaoka |
120a6e |
QString itemRole = item->data(0, Qt::UserRole).toString();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TFilePath path = TFilePath(itemRole.toStdWString());
|
|
Shinya Kitaoka |
120a6e |
if (TFileStatus(path).doesExist() &&
|
|
Shinya Kitaoka |
120a6e |
TFileStatus(path.getParentDir()).isDirectory()) {
|
|
Shinya Kitaoka |
120a6e |
QMenu *menu = new QMenu(this);
|
|
Shinya Kitaoka |
120a6e |
std::string folder = path.getParentDir().getName();
|
|
Shinya Kitaoka |
120a6e |
if (folder == "macroFx") // Menu' macro
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
QAction *remove = new QAction(tr("Remove Macro FX"), menu);
|
|
Shinya Kitaoka |
120a6e |
connect(remove, SIGNAL(triggered()), this, SLOT(removePreset()));
|
|
Shinya Kitaoka |
120a6e |
menu->addAction(remove);
|
|
Shinya Kitaoka |
120a6e |
} else // Verifico se devo caricare un preset
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
folder = path.getParentDir().getParentDir().getName();
|
|
Shinya Kitaoka |
120a6e |
if (folder == "presets") // Menu' preset
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
QAction *remove = new QAction(tr("Remove Preset"), menu);
|
|
Shinya Kitaoka |
120a6e |
connect(remove, SIGNAL(triggered()), this, SLOT(removePreset()));
|
|
Shinya Kitaoka |
120a6e |
menu->addAction(remove);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
menu->exec(event->globalPos());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void InsertFxPopup::updatePresets() {
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < m_fxTree->topLevelItemCount(); i++) {
|
|
Shinya Kitaoka |
120a6e |
QTreeWidgetItem *folder = m_fxTree->topLevelItem(i);
|
|
Shinya Kitaoka |
120a6e |
TFilePath path =
|
|
Shinya Kitaoka |
120a6e |
TFilePath(folder->data(0, Qt::UserRole).toString().toStdWString());
|
|
Shinya Kitaoka |
120a6e |
if (folder->text(0).toStdString() == "Plugins") {
|
|
Shinya Kitaoka |
120a6e |
continue;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (path.getName() == "macroFx") {
|
|
Shinya Kitaoka |
120a6e |
int j;
|
|
Shinya Kitaoka |
120a6e |
for (j = folder->childCount() - 1; j >= 0; j--)
|
|
Shinya Kitaoka |
120a6e |
folder->removeChild(folder->child(j));
|
|
Shinya Kitaoka |
120a6e |
m_fxTree->removeItemWidget(folder, 0);
|
|
Shinya Kitaoka |
120a6e |
delete folder;
|
|
Shinya Kitaoka |
120a6e |
} else if (path.getParentDir().getName() == "macroFx")
|
|
Shinya Kitaoka |
120a6e |
continue;
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < folder->childCount(); i++) {
|
|
Shinya Kitaoka |
120a6e |
bool isPresetLoaded = loadPreset(folder->child(i));
|
|
Shinya Kitaoka |
120a6e |
if (isPresetLoaded)
|
|
Shinya Kitaoka |
120a6e |
folder->child(i)->setIcon(0, m_presetIcon);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
folder->child(i)->setIcon(0, m_fxIcon);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
loadMacro();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
update();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void InsertFxPopup::removePreset() {
|
|
Shinya Kitaoka |
120a6e |
QTreeWidgetItem *item = m_fxTree->currentItem();
|
|
Shinya Kitaoka |
120a6e |
QString itemRole = item->data(0, Qt::UserRole).toString();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TFilePath path = TFilePath(itemRole.toStdWString());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QString question = QString(
|
|
Shinya Kitaoka |
120a6e |
tr("Are you sure you want to delete %1?").arg(path.getName().c_str()));
|
|
Shinya Kitaoka |
120a6e |
int ret = DVGui::MsgBox(question, tr("Yes"), tr("No"), 1);
|
|
Shinya Kitaoka |
120a6e |
if (ret == 2 || ret == 0) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
try {
|
|
Shinya Kitaoka |
120a6e |
TSystem::deleteFile(path);
|
|
Shinya Kitaoka |
120a6e |
} catch (...) {
|
|
Shinya Kitaoka |
120a6e |
error(QString(tr("It is not possible to delete %1.").arg(toQString(path))));
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
m_fxTree->removeItemWidget(item, 0);
|
|
Shinya Kitaoka |
120a6e |
delete item;
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentFx()->notifyFxPresetRemoved();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
OpenPopupCommandHandler<insertfxpopup> openInsertFxPopup(MI_InsertFx);</insertfxpopup>
|