实现场景渲染界面双击纹理列表项跳转编辑界面打开

main v0.1.1
wuyize 2023-04-09 00:06:20 +08:00
parent 1e341a8ea5
commit 32b541d927
3 changed files with 23 additions and 11 deletions

View File

@ -39,9 +39,16 @@ void EditorWidget::renameTab(QWidget* target, QString name)
}
}
void EditorWidget::handleOpenPaintingFile(QString path)
void EditorWidget::handleOpenPaintingFile(QString fileName)
{
qDebug() << path;
if (!fileName.isEmpty())
{
const int prevCount = this->tabWidget->count();
this->tabWidget->addTab(new EditorWidgetItem(fileName, this), fileName);
const int nowCount = this->tabWidget->count();
emit tabCountChanged(prevCount, nowCount);
}
}
void EditorWidget::onTabCountChanged(int prev, int now)
@ -76,14 +83,15 @@ void EditorWidget::initFileMenu()
});
connect(actionOpen, &QAction::triggered, this, [this] {
const QString fileName = QFileDialog::getOpenFileName(this, QStringLiteral("´ò¿ª"), "", QStringLiteral("JSONÎļþ(*.json)"));
if (!fileName.isEmpty())
{
const int prevCount = this->tabWidget->count();
this->tabWidget->addTab(new EditorWidgetItem(fileName, this), fileName);
const int nowCount = this->tabWidget->count();
//if (!fileName.isEmpty())
//{
// const int prevCount = this->tabWidget->count();
// this->tabWidget->addTab(new EditorWidgetItem(fileName, this), fileName);
// const int nowCount = this->tabWidget->count();
emit tabCountChanged(prevCount, nowCount);
}
// emit tabCountChanged(prevCount, nowCount);
//}
handleOpenPaintingFile(fileName);
});
connect(actionSave, &QAction::triggered, this, [this] {
auto* item = dynamic_cast<EditorWidgetItem*>(this->tabWidget->currentWidget());

View File

@ -20,7 +20,11 @@ CentralWidget::CentralWidget(QWidget* parent) : QWidget(parent)
ui.gridLayout->addWidget(navigationBarWidget, 0, 0, 1, 1, Qt::AlignTop | Qt::AlignHCenter);
QObject::connect(navigationBarWidget->tabs, &QtMaterialTabs::currentChanged, ui.stackedWidget, &QStackedWidget::setCurrentIndex);
QObject::connect(ui.stackedWidget, &QStackedWidget::currentChanged, ui.rendererWidget, &Renderer::RendererWidget::currentTabChanged);
QObject::connect(ui.rendererWidget, &Renderer::RendererWidget::openPaintingFile, ui.editorWidget, &EditorWidget::handleOpenPaintingFile);
QObject::connect(ui.rendererWidget, &Renderer::RendererWidget::openPaintingFile, [&, navigationBarWidget](QString path) {
navigationBarWidget->tabs->setCurrentTab(0);
ui.stackedWidget->setCurrentWidget(ui.editorWidget);
ui.editorWidget->handleOpenPaintingFile(path);
});
}
CentralWidget::~CentralWidget()

View File

@ -56,7 +56,7 @@ Renderer::RendererWidget::RendererWidget(QWidget* parent)
ui.tabWidget->setStyleSheet(hide
? "QTabBar::tab {background-color:rgba(0,0,0,0);} QTabBar::tab:hover{background-color: rgb(213, 213, 213);}"
: "QTabBar::tab:hover{background-color: rgb(213, 213, 213);}");
ui.tabWidget->setFixedWidth(hide ? ui.tabWidget->tabBar()->width() : maxWidth);
ui.tabWidget->setFixedWidth(hide ? ui.tabWidget->tabBar()->width() - 1 : maxWidth);
});
QObject::connect(ui.textureListWidget, &QListWidget::itemDoubleClicked, [&](QListWidgetItem* item) {