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