Compare commits

..

2 Commits

Author SHA1 Message Date
karlis 7e0e07292f merge 2023-03-22 14:46:59 +08:00
karlis b2f37cc4eb Experimental:添加了【图层提升/下放功能】 2023-03-22 14:45:43 +08:00
1 changed files with 7 additions and 8 deletions

View File

@ -212,16 +212,15 @@ QAction* LayerTreeWidget::getPromoteUpAction()
QAction* action = new QAction(QString::fromLocal8Bit("ÌáÉý (experimental)"), this);
QMenu* optionMenu = new QMenu();
QList<QAction*> optionList;
std::vector<LayerWrapper*> layers;
std::vector<FolderLayerWrapper*> layers;
auto layer = this->selectedItem->data(0, Qt::UserRole).value<LayerWrapper*>();
layer = layer->getParent();
while (layer != nullptr)
{
if (layer->getParent() == nullptr)
break;
layer = layer->getParent();
if (layer->getParent() == nullptr)
break;
layers.push_back(layer);
layers.push_back(dynamic_cast<FolderLayerWrapper*>(layer));
}
reverse(layers.begin(), layers.end());
if (layers.size() == 0)
@ -233,12 +232,12 @@ QAction* LayerTreeWidget::getPromoteUpAction()
{
if (layer == nullptr)
continue;
QAction* option = new QAction(QString::fromLocal8Bit("ÌáÉýÖÁ ") + layer->property.name + QString::fromLocal8Bit(" ͬ¼¶"), this);
option->setData(QVariant::fromValue(std::pair<LayerWrapper*, LayerWrapper*>({this->selectedItem->data(0, Qt::UserRole).value<LayerWrapper*>(), layer})));
QAction* option = new QAction(QString::fromLocal8Bit("ÌáÉýÖÁ ") + layer->property.name + QString::fromLocal8Bit(" ÏÂ"), this);
option->setData(QVariant::fromValue(std::pair<LayerWrapper*, FolderLayerWrapper*>({this->selectedItem->data(0, Qt::UserRole).value<LayerWrapper*>(), layer})));
connect(option, &QAction::triggered, this, [this, option]() {
auto pair = option->data().value<std::pair<LayerWrapper*, LayerWrapper*>>();
auto pair = option->data().value<std::pair<LayerWrapper*, FolderLayerWrapper*>>();
auto layer = pair.first;
auto parent = pair.second->getParent();
auto parent = pair.second;
this->moveLayer(layer, parent);
});
optionList.append(option);