Compare commits
No commits in common. "f175e50b7b85a3b51df0e9a8e8aa626f274452ca" and "62d887aa07f458f93c11e59eb4a273b7062f95c1" have entirely different histories.
f175e50b7b
...
62d887aa07
|
@ -84,7 +84,7 @@ void EditorWidget::initFileMenu()
|
||||||
auto* item = dynamic_cast<EditorWidgetItem*>(this->tabWidget->currentWidget());
|
auto* item = dynamic_cast<EditorWidgetItem*>(this->tabWidget->currentWidget());
|
||||||
if (item != nullptr)
|
if (item != nullptr)
|
||||||
{
|
{
|
||||||
item->save();
|
//item->save();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connect(actionSaveAs, &QAction::triggered, this, [this] {
|
connect(actionSaveAs, &QAction::triggered, this, [this] {
|
||||||
|
|
|
@ -25,9 +25,9 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
|
||||||
qDebug() << elementInfoDisplayWidget;
|
qDebug() << elementInfoDisplayWidget;
|
||||||
auto centralRefresh = [this]() {
|
auto centralRefresh = [this]() {
|
||||||
layerInfoDisplayWidget->refresh();
|
layerInfoDisplayWidget->refresh();
|
||||||
|
elementInfoDisplayWidget->refresh();
|
||||||
treeWidget->refresh();
|
treeWidget->refresh();
|
||||||
previewWindow->refresh();
|
previewWindow->refresh();
|
||||||
elementInfoDisplayWidget->lazyRefresh();
|
|
||||||
};
|
};
|
||||||
connect(previewWindow, &PreviewWindow::triggerCentralRefresh, centralRefresh);
|
connect(previewWindow, &PreviewWindow::triggerCentralRefresh, centralRefresh);
|
||||||
connect(layerInfoDisplayWidget, &InfoDisplayWidget::triggerCentralRefresh, centralRefresh);
|
connect(layerInfoDisplayWidget, &InfoDisplayWidget::triggerCentralRefresh, centralRefresh);
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QMessagebox>
|
#include <QMessagebox>
|
||||||
#include <QTimer>
|
|
||||||
|
|
||||||
ElementPoolWidget::ElementPoolWidget(QWidget* parent)
|
ElementPoolWidget::ElementPoolWidget(QWidget* parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
|
@ -39,15 +38,10 @@ void ElementPoolWidget::setElementList(std::vector<GraphicElement*> elements) {
|
||||||
pictureList->clear();
|
pictureList->clear();
|
||||||
this->elements = elements;
|
this->elements = elements;
|
||||||
for (int index = 0; index < elements.size(); index++) {
|
for (int index = 0; index < elements.size(); index++) {
|
||||||
QListWidgetItem* pItem = new QListWidgetItem(elements[index]->name);
|
QListWidgetItem* pItem = new QListWidgetItem(
|
||||||
QPainter* painter = new QPainter();
|
elements[index]->getPreview(QSize(iconWidth - 25, iconHeight - 25)),
|
||||||
QImage* image = new QImage(QSize(iconWidth - 12, iconHeight - 12), QImage::Format_ARGB32);
|
elements[index]->name);
|
||||||
image->fill(Qt::transparent);
|
|
||||||
pItem->setIcon(QIcon(QPixmap::fromImage(*image)));
|
|
||||||
pItem->setSizeHint(QSize(iconWidth, iconHeight));
|
pItem->setSizeHint(QSize(iconWidth, iconHeight));
|
||||||
painter->begin(image);
|
|
||||||
elements[index]->paintPreview(painter);
|
|
||||||
painter->end();
|
|
||||||
pictureList->insertItem(index, pItem);
|
pictureList->insertItem(index, pItem);
|
||||||
}
|
}
|
||||||
if(elements.size() > 0)
|
if(elements.size() > 0)
|
||||||
|
@ -72,47 +66,15 @@ void ElementPoolWidget::setElementManager(ElementManager* element)
|
||||||
this->setElementList(this->elementManager->elements);
|
this->setElementList(this->elementManager->elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElementPoolWidget::lazyRefresh()
|
|
||||||
{
|
|
||||||
if (!refreshWait) {
|
|
||||||
refreshWait = true;
|
|
||||||
QTimer::singleShot(1000, this, SLOT(refresh()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ElementPoolWidget::refresh() {
|
void ElementPoolWidget::refresh() {
|
||||||
refreshWait = false;
|
this->setElementList(this->elementManager->elements);
|
||||||
if (elementManager != nullptr)
|
// update();
|
||||||
{
|
|
||||||
for (int i = 0; i < elements.size(); i++)
|
|
||||||
{
|
|
||||||
QListWidgetItem* pItem = pictureList->item(i);
|
|
||||||
if (pItem == nullptr)
|
|
||||||
{
|
|
||||||
pItem = new QListWidgetItem(elements[i]->name);
|
|
||||||
pictureList->insertItem(i, pItem);
|
|
||||||
}
|
|
||||||
QPainter* painter = new QPainter();
|
|
||||||
QImage* image = new QImage(QSize(iconWidth - 12, iconHeight - 12), QImage::Format_ARGB32);
|
|
||||||
image->fill(Qt::transparent);
|
|
||||||
painter->begin(image);
|
|
||||||
elements[i]->paintPreview(painter);
|
|
||||||
painter->end();
|
|
||||||
pItem->setIcon(QIcon(QPixmap::fromImage(*image)));
|
|
||||||
pItem->setData(Qt::UserRole, QVariant::fromValue(image));
|
|
||||||
pItem->setSizeHint(QSize(iconWidth, iconHeight));
|
|
||||||
pictureList->insertItem(i, pItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElementPoolWidget::refreshPicture(GraphicElement* element) {
|
void ElementPoolWidget::refreshPicture(GraphicElement* element) {
|
||||||
for (int i = 0; i < elements.size(); i++) {
|
for (int i = 0; i < elements.size(); i++) {
|
||||||
if (element == elements[i]) {
|
if (element == elements[i]) {
|
||||||
QPainter* painter = new QPainter();
|
pictureList->item(i)->setIcon(elements[i]->getPreview(QSize(iconWidth - 25, iconHeight - 25)));
|
||||||
painter->begin(pictureList->item(i)->data(Qt::UserRole).value<QImage*>());
|
|
||||||
elements[i]->paintPreview(painter);
|
|
||||||
painter->end();
|
|
||||||
// update();
|
// update();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -122,10 +84,7 @@ void ElementPoolWidget::refreshPicture(GraphicElement* element) {
|
||||||
void ElementPoolWidget::refreshPictureByIndex(int index) {
|
void ElementPoolWidget::refreshPictureByIndex(int index) {
|
||||||
if (index >= 0 && index < elements.size())
|
if (index >= 0 && index < elements.size())
|
||||||
{
|
{
|
||||||
QPainter* painter = new QPainter();
|
pictureList->item(index)->setIcon(elements[index]->getPreview(QSize(iconWidth - 25, iconHeight - 25)));
|
||||||
painter->begin(pictureList->item(index)->data(Qt::UserRole).value<QImage*>());
|
|
||||||
elements[index]->paintPreview(painter);
|
|
||||||
painter->end();
|
|
||||||
// update();
|
// update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,6 +118,7 @@ void ElementPoolWidget::popMenu(const QPoint& pos)
|
||||||
});
|
});
|
||||||
menu->addAction(QString::fromLocal8Bit("ɾ³ý"), this, [this, currentElement]() {
|
menu->addAction(QString::fromLocal8Bit("ɾ³ý"), this, [this, currentElement]() {
|
||||||
this->elementManager->removeElement(currentElement);
|
this->elementManager->removeElement(currentElement);
|
||||||
|
emit triggerCentralRefresh();
|
||||||
});
|
});
|
||||||
menu->actions().last()->setDisabled(currentElement->referencedCount > 0);
|
menu->actions().last()->setDisabled(currentElement->referencedCount > 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ private:
|
||||||
QListWidget* pictureList;
|
QListWidget* pictureList;
|
||||||
int iconWidth, iconHeight;
|
int iconWidth, iconHeight;
|
||||||
ElementManager* elementManager;
|
ElementManager* elementManager;
|
||||||
bool refreshWait = false;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int currentIndex = -1;
|
int currentIndex = -1;
|
||||||
|
@ -23,7 +22,6 @@ public:
|
||||||
void setElementManager(ElementManager* element);
|
void setElementManager(ElementManager* element);
|
||||||
~ElementPoolWidget();
|
~ElementPoolWidget();
|
||||||
void enableEdit();
|
void enableEdit();
|
||||||
void lazyRefresh();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void elementSelected(GraphicElement* element);
|
void elementSelected(GraphicElement* element);
|
||||||
|
|
|
@ -45,6 +45,7 @@ void GroupElement::setSourceLayer(FolderLayerWrapper* sourceLayer)
|
||||||
PixelPath GroupElement::getPaintObject() const
|
PixelPath GroupElement::getPaintObject() const
|
||||||
{
|
{
|
||||||
if (sourceLayer != nullptr) {
|
if (sourceLayer != nullptr) {
|
||||||
|
sourceLayer->refresh();
|
||||||
return sourceLayer->getCache();
|
return sourceLayer->getCache();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -112,9 +113,8 @@ void SimpleElement::paint(QPainter* painter, QTransform transform, const LayerSt
|
||||||
maxScale = std::max(fabs(transform.m11() / cos(angle)), fabs(transform.m22() / cos(angle)));
|
maxScale = std::max(fabs(transform.m11() / cos(angle)), fabs(transform.m22() / cos(angle)));
|
||||||
else
|
else
|
||||||
maxScale = std::max(fabs(transform.m12() / sin(angle)), fabs(transform.m21() / sin(angle)));
|
maxScale = std::max(fabs(transform.m12() / sin(angle)), fabs(transform.m21() / sin(angle)));
|
||||||
//double pixelRatio = maxScale * QGuiApplication::primaryScreen()->devicePixelRatio();
|
double pixelRatio = maxScale * QGuiApplication::primaryScreen()->devicePixelRatio();
|
||||||
double pixelRatio = 5;
|
if (painterPath == painterPathPrev && styles.getHash() == stylesHashValue && pixelRatio == pixelRatioPrev)
|
||||||
if (painterPath == painterPathPrev && styles.getHash() == stylesHashValue && fabs(pixelRatio - pixelRatioPrev) < 1e-3)
|
|
||||||
{
|
{
|
||||||
transform.translate(movPrev.x(), movPrev.y());
|
transform.translate(movPrev.x(), movPrev.y());
|
||||||
painter->setTransform(transform.scale(1 / pixelRatio, 1 / pixelRatio));
|
painter->setTransform(transform.scale(1 / pixelRatio, 1 / pixelRatio));
|
||||||
|
@ -153,26 +153,31 @@ bool GroupElement::isClosed() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SimpleElement::paintPreview(QPainter* painter)
|
QPixmap SimpleElement::getPreview(QSize size)
|
||||||
{
|
{
|
||||||
painter->save();
|
QPixmap result(size + QSize(5, 5));
|
||||||
painter->setWindow(painterPath.boundingRect().x() - 5, painterPath.boundingRect().y() - 5, (painterPath.boundingRect().width() + 10) * QGuiApplication::primaryScreen()->devicePixelRatio(), (painterPath.boundingRect().height() + 10) * QGuiApplication::primaryScreen()->devicePixelRatio());
|
QPainter painter(&result);
|
||||||
painter->drawPath(painterPath);
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
painter->restore();
|
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||||
|
painter.scale(size.width() / painterPath.boundingRect().width(), size.height() / painterPath.boundingRect().height());
|
||||||
|
painter.drawPath(painterPath);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupElement::paintPreview(QPainter* painter)
|
QPixmap GroupElement::getPreview(QSize size)
|
||||||
{
|
{
|
||||||
painter->save();
|
|
||||||
auto cache = sourceLayer->getCache();
|
auto cache = sourceLayer->getCache();
|
||||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
QPixmap result(QSize(1024, 1024));
|
||||||
painter->setRenderHint(QPainter::SmoothPixmapTransform, true);
|
QPainter painter(&result);
|
||||||
painter->setWindow(cache.getBoundingRect().toRect().x() - 5, cache.getBoundingRect().toRect().y() - 5, (cache.getBoundingRect().toRect().width() + 10) * QGuiApplication::primaryScreen()->devicePixelRatio(), (cache.getBoundingRect().toRect().height() + 10) * QGuiApplication::primaryScreen()->devicePixelRatio());
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
//painter->translate(-cache.getBoundingRect().toRect().x() - 5, -cache.getBoundingRect().toRect().y() - 5);
|
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||||
//double maxScale = std::max(cache.getBoundingRect().toRect().width() + 10, cache.getBoundingRect().toRect().height() + 10) * QGuiApplication::primaryScreen()->devicePixelRatio();
|
sourceLayer->paint(&painter, QTransform(), true);
|
||||||
//painter->scale(1 / maxScale, 1/ maxScale);
|
painter.end();
|
||||||
sourceLayer->paint(painter, QTransform(), true);
|
QRect rect(cache.getBoundingRect().toRect());
|
||||||
painter->restore();
|
rect.setTopLeft(rect.topLeft() - QPoint(5, 5));
|
||||||
|
rect.setBottomRight(rect.bottomRight() + QPoint(5, 5));
|
||||||
|
result = result.copy(rect);
|
||||||
|
return result.scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupElement::collectReachable(std::set<LayerWrapper*>& set) const
|
void GroupElement::collectReachable(std::set<LayerWrapper*>& set) const
|
||||||
|
|
|
@ -20,7 +20,6 @@ class ComposedPainterPath;
|
||||||
class GraphicElement
|
class GraphicElement
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool needRefresh = true;
|
|
||||||
size_t referencedCount = 0;
|
size_t referencedCount = 0;
|
||||||
Renderer::ElementRenderer *renderer;
|
Renderer::ElementRenderer *renderer;
|
||||||
QString name = "";
|
QString name = "";
|
||||||
|
@ -36,7 +35,7 @@ public:
|
||||||
virtual PixelPath getPaintObject(const LayerStyleContainer& styles) const = 0;
|
virtual PixelPath getPaintObject(const LayerStyleContainer& styles) const = 0;
|
||||||
virtual void paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles) = 0;
|
virtual void paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles) = 0;
|
||||||
virtual bool isClosed() const = 0;
|
virtual bool isClosed() const = 0;
|
||||||
virtual void paintPreview(QPainter* painter) = 0;
|
virtual QPixmap getPreview(QSize size) = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -60,7 +59,7 @@ public:
|
||||||
PixelPath getPaintObject(const LayerStyleContainer& styles) const override;
|
PixelPath getPaintObject(const LayerStyleContainer& styles) const override;
|
||||||
void paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles) override;
|
void paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles) override;
|
||||||
bool isClosed() const override;
|
bool isClosed() const override;
|
||||||
void paintPreview(QPainter* painter) override;
|
QPixmap getPreview(QSize size) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GroupElement : public GraphicElement
|
class GroupElement : public GraphicElement
|
||||||
|
@ -78,12 +77,10 @@ public:
|
||||||
void setSourceLayer(FolderLayerWrapper* sourceLayer);
|
void setSourceLayer(FolderLayerWrapper* sourceLayer);
|
||||||
void paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles) override;
|
void paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles) override;
|
||||||
bool isClosed() const override;
|
bool isClosed() const override;
|
||||||
void paintPreview(QPainter* painter) override;
|
QPixmap getPreview(QSize size) override;
|
||||||
void collectReachable(std::set<LayerWrapper*>& set) const;
|
void collectReachable(std::set<LayerWrapper*>& set) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(GraphicElement*)
|
|
||||||
|
|
||||||
//******************************** BitmapPath ********************************//
|
//******************************** BitmapPath ********************************//
|
||||||
|
|
||||||
//using std::vector;
|
//using std::vector;
|
||||||
|
|
|
@ -14,7 +14,6 @@ LayerWrapper *LayerManager::getRoot() const
|
||||||
void LayerManager::paint(QPainter *painter, QSize size,LayerWrapper* selecetedLayer) const
|
void LayerManager::paint(QPainter *painter, QSize size,LayerWrapper* selecetedLayer) const
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
root->markNeedRefresh();
|
|
||||||
root->getCache();
|
root->getCache();
|
||||||
root->paint(painter);
|
root->paint(painter);
|
||||||
painter->restore();
|
painter->restore();
|
||||||
|
|
|
@ -25,10 +25,10 @@ FolderLayerWrapper*LayerWrapper::getParent() const
|
||||||
|
|
||||||
PixelPath LayerWrapper::getCache(LayerWrapper* selectedLayer)
|
PixelPath LayerWrapper::getCache(LayerWrapper* selectedLayer)
|
||||||
{
|
{
|
||||||
if (needRefresh)
|
this->refresh(selectedLayer);
|
||||||
|
if (selectedLayer == this)
|
||||||
{
|
{
|
||||||
this->refresh(selectedLayer);
|
this->cache.highLight();
|
||||||
needRefresh = false;
|
|
||||||
}
|
}
|
||||||
return cache;
|
return cache;
|
||||||
}
|
}
|
||||||
|
@ -469,16 +469,4 @@ void LayerWrapper::paintVisualBounding(QPainter* painter) const
|
||||||
painter->setTransform(transform);
|
painter->setTransform(transform);
|
||||||
painter->drawRect(cache.getBoundingRect());
|
painter->drawRect(cache.getBoundingRect());
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
|
||||||
|
|
||||||
void LayerWrapper::markNeedRefresh()
|
|
||||||
{
|
|
||||||
this->needRefresh = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FolderLayerWrapper::markNeedRefresh()
|
|
||||||
{
|
|
||||||
LayerWrapper::markNeedRefresh();
|
|
||||||
for (auto& child : children)
|
|
||||||
child->markNeedRefresh();
|
|
||||||
}
|
}
|
|
@ -35,7 +35,6 @@ class LayerWrapper
|
||||||
PixelPath cache;
|
PixelPath cache;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool needRefresh = true;
|
|
||||||
QTreeWidgetItem* qTreeWidgetItem;
|
QTreeWidgetItem* qTreeWidgetItem;
|
||||||
bool selected;
|
bool selected;
|
||||||
bool hidden;
|
bool hidden;
|
||||||
|
@ -79,7 +78,6 @@ class LayerWrapper
|
||||||
virtual bool referencingGroupElement() const;
|
virtual bool referencingGroupElement() const;
|
||||||
virtual void paintVisualBounding(QPainter* painter) const;
|
virtual void paintVisualBounding(QPainter* painter) const;
|
||||||
bool canApplyStyles() const;
|
bool canApplyStyles() const;
|
||||||
virtual void markNeedRefresh();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class FolderLayerWrapper : public LayerWrapper
|
class FolderLayerWrapper : public LayerWrapper
|
||||||
|
@ -107,7 +105,6 @@ class FolderLayerWrapper : public LayerWrapper
|
||||||
void refreshTreeItem() override;
|
void refreshTreeItem() override;
|
||||||
size_t referencedCount(bool excludeSelf = false) const override;
|
size_t referencedCount(bool excludeSelf = false) const override;
|
||||||
bool deleteable(bool excludeSubTree = false) const override;
|
bool deleteable(bool excludeSubTree = false) const override;
|
||||||
void markNeedRefresh() override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class LeafLayerWrapper : public LayerWrapper
|
class LeafLayerWrapper : public LayerWrapper
|
||||||
|
|
|
@ -21,51 +21,37 @@ InfoDisplayWidget::InfoDisplayWidget(QWidget* parent) :QWidget(parent)
|
||||||
ui.rotation->setLabel(("旋转角度"));
|
ui.rotation->setLabel(("旋转角度"));
|
||||||
ui.scaleX->setLabel(("水平缩放"));
|
ui.scaleX->setLabel(("水平缩放"));
|
||||||
ui.scaleY->setLabel(("垂直缩放"));
|
ui.scaleY->setLabel(("垂直缩放"));
|
||||||
ui.rotation->setValidator(new QDoubleValidator(-10000, 10000, 6, this));
|
ui.rotation->setValidator(new QIntValidator(-360, 360, this));
|
||||||
ui.styleList->setDisabled(true);
|
ui.styleList->setDisabled(true);
|
||||||
connect(ui.rotation, &QLineEdit::textChanged, [=](QString content) {
|
connect(ui.rotation, &QLineEdit::textChanged, [=](const QString& content) {
|
||||||
if (fabs(content.toDouble() - this->displayLayer->property.rotation) < 1e-6)
|
this->displayLayer->property.setRotation(content.toDouble());
|
||||||
return;
|
|
||||||
this->displayLayer->property.rotation = content.toDouble();
|
|
||||||
emit triggerCentralRefresh();
|
emit triggerCentralRefresh();
|
||||||
});
|
});
|
||||||
ui.offsetX->setValidator(new QDoubleValidator(-10000, 10000, 2, this));
|
ui.offsetX->setValidator(new QIntValidator(-10000, 10000, this));
|
||||||
connect(ui.offsetX, &QLineEdit::textChanged, [=](QString content) {
|
connect(ui.offsetX, &QLineEdit::textChanged, [=](const QString& content) {
|
||||||
if (fabs(content.toDouble() - this->displayLayer->property.offset.x()) < 1e-6)
|
|
||||||
return;
|
|
||||||
this->displayLayer->property.offset = { content.toDouble(), this->displayLayer->property.offset.y() };
|
this->displayLayer->property.offset = { content.toDouble(), this->displayLayer->property.offset.y() };
|
||||||
emit triggerCentralRefresh();
|
emit triggerCentralRefresh();
|
||||||
});
|
});
|
||||||
ui.offsetY->setValidator(new QDoubleValidator(-10000, 10000, 2, this));
|
ui.offsetY->setValidator(new QIntValidator(-10000, 10000, this));
|
||||||
connect(ui.offsetY, &QLineEdit::textChanged, [=](QString content) {
|
connect(ui.offsetY, &QLineEdit::textChanged, [=](const QString& content) {
|
||||||
if (fabs(content.toDouble() - this->displayLayer->property.offset.y()) < 1e-6)
|
|
||||||
return;
|
|
||||||
this->displayLayer->property.offset = { this->displayLayer->property.offset.x(), content.toDouble() };
|
this->displayLayer->property.offset = { this->displayLayer->property.offset.x(), content.toDouble() };
|
||||||
emit triggerCentralRefresh();
|
emit triggerCentralRefresh();
|
||||||
});
|
});
|
||||||
ui.scaleX->setValidator(new QDoubleValidator(0, 10000, 6, this));
|
ui.scaleX->setValidator(new QDoubleValidator(0, 1000, 4, this));
|
||||||
connect(ui.scaleX, &QLineEdit::textChanged, [=](QString content) {
|
connect(ui.scaleX, &QLineEdit::textChanged, [=](const QString& content) {
|
||||||
if (fabs(content.toDouble() - this->displayLayer->property.scale.x()) < 1e-6)
|
|
||||||
return;
|
|
||||||
this->displayLayer->property.scale = { content.toDouble(), this->displayLayer->property.scale.y() };
|
this->displayLayer->property.scale = { content.toDouble(), this->displayLayer->property.scale.y() };
|
||||||
emit triggerCentralRefresh();
|
emit triggerCentralRefresh();
|
||||||
});
|
});
|
||||||
ui.scaleY->setValidator(new QDoubleValidator(0, 10000, 6, this));
|
ui.scaleY->setValidator(new QDoubleValidator(0, 1000, 4, this));
|
||||||
connect(ui.scaleY, &QLineEdit::textChanged, [=](QString content) {
|
connect(ui.scaleY, &QLineEdit::textChanged, [=](const QString& content) {
|
||||||
if (fabs(content.toDouble() - this->displayLayer->property.scale.y()) < 1e-6)
|
|
||||||
return;
|
|
||||||
this->displayLayer->property.scale = { this->displayLayer->property.scale.x(), content.toDouble() };
|
this->displayLayer->property.scale = { this->displayLayer->property.scale.x(), content.toDouble() };
|
||||||
emit triggerCentralRefresh();
|
emit triggerCentralRefresh();
|
||||||
});
|
});
|
||||||
connect(ui.flipX, &QtMaterialCheckBox::toggled, [=](bool state) {
|
connect(ui.flipX, &QtMaterialCheckBox::toggled, [=](bool state) {
|
||||||
if (state == this->displayLayer->property.flipX)
|
|
||||||
return;
|
|
||||||
this->displayLayer->property.flipX = state;
|
this->displayLayer->property.flipX = state;
|
||||||
emit triggerCentralRefresh();
|
emit triggerCentralRefresh();
|
||||||
});
|
});
|
||||||
connect(ui.flipY, &QtMaterialCheckBox::toggled, [=](bool state) {
|
connect(ui.flipY, &QtMaterialCheckBox::toggled, [=](bool state) {
|
||||||
if (state == this->displayLayer->property.flipY)
|
|
||||||
return;
|
|
||||||
this->displayLayer->property.flipY = state;
|
this->displayLayer->property.flipY = state;
|
||||||
emit triggerCentralRefresh();
|
emit triggerCentralRefresh();
|
||||||
});
|
});
|
||||||
|
|
|
@ -239,7 +239,6 @@ QAction* LayerTreeWidget::getPromoteUpAction()
|
||||||
auto layer = pair.first;
|
auto layer = pair.first;
|
||||||
auto parent = pair.second;
|
auto parent = pair.second;
|
||||||
this->moveLayer(layer, parent);
|
this->moveLayer(layer, parent);
|
||||||
this->setCurrentItem(layer->qTreeWidgetItem);
|
|
||||||
});
|
});
|
||||||
optionList.append(option);
|
optionList.append(option);
|
||||||
}
|
}
|
||||||
|
@ -256,11 +255,6 @@ QAction* LayerTreeWidget::getPromoteDownAction()
|
||||||
std::vector<FolderLayerWrapper*> 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*>();
|
||||||
auto parent = layer->getParent();
|
auto parent = layer->getParent();
|
||||||
if (parent == nullptr)
|
|
||||||
{
|
|
||||||
action->setEnabled(false);
|
|
||||||
return action;
|
|
||||||
}
|
|
||||||
for (auto child : parent->children)
|
for (auto child : parent->children)
|
||||||
{
|
{
|
||||||
if (child.get() == layer || typeid(*child) != typeid(FolderLayerWrapper))
|
if (child.get() == layer || typeid(*child) != typeid(FolderLayerWrapper))
|
||||||
|
@ -284,7 +278,6 @@ QAction* LayerTreeWidget::getPromoteDownAction()
|
||||||
auto layer = pair.first;
|
auto layer = pair.first;
|
||||||
auto parent = pair.second;
|
auto parent = pair.second;
|
||||||
this->moveLayer(layer, parent);
|
this->moveLayer(layer, parent);
|
||||||
this->setCurrentItem(layer->qTreeWidgetItem);
|
|
||||||
});
|
});
|
||||||
optionList.append(option);
|
optionList.append(option);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue