Skip to content

Commit

Permalink
WIP for asset selection and multiple editor window workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
nemerle committed Jul 5, 2022
1 parent 1509552 commit ced698a
Show file tree
Hide file tree
Showing 73 changed files with 982 additions and 792 deletions.
2 changes: 1 addition & 1 deletion Utilities/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ add_subdirectory(TextureConverter)
add_subdirectory(dbtool)
add_subdirectory(AuthExerciser)
add_subdirectory(SEGSAdmin)
add_subdirectory(EditorComponets/)
add_subdirectory(EditorComponents)
IF(BUILD_RPC_TEST_CLIENT)
add_subdirectory(RPCTestClient)
ENDIF(BUILD_RPC_TEST_CLIENT)
File renamed without changes.
20 changes: 20 additions & 0 deletions Utilities/EditorComponents/AssetSelector.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "AssetSelector.h"
#include "ui_AssetSelector.h"

AssetSelector::AssetSelector(QWidget *parent) :
QWidget(parent),
ui(new Ui::AssetSelector)
{
ui->setupUi(this);
}

AssetSelector::~AssetSelector()
{
delete ui;
}

void AssetSelector::on_fakeAsset_clicked()
{
emit assetActivated(0,"data/bin/origins.bin");
}

25 changes: 25 additions & 0 deletions Utilities/EditorComponents/AssetSelector.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once

#include <QWidget>

namespace Ui
{
class AssetSelector;
}

class AssetSelector : public QWidget
{
Q_OBJECT

public:
explicit AssetSelector(QWidget *parent = nullptr);
~AssetSelector();

signals:
void assetActivated(int type,const QString &path);
private slots:
void on_fakeAsset_clicked();

private:
Ui::AssetSelector *ui;
};
34 changes: 34 additions & 0 deletions Utilities/EditorComponents/AssetSelector.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AssetSelector</class>
<widget class="QWidget" name="AssetSelector">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>658</width>
<height>92</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>64</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QToolButton" name="fakeAsset">
<property name="text">
<string>Origins</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ find_package(Threads REQUIRED)

set(sources
main.cpp
MainWindow.cpp MainWindow.h MainWindow.ui
AssetSelector.h AssetSelector.cpp AssetSelector.ui
SegsOriginEditor.cpp
SegsOriginEditor.h
SegsOriginEditor.ui
Expand Down
59 changes: 59 additions & 0 deletions Utilities/EditorComponents/MainWindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#include "MainWindow.h"

#include "ui_mainwindow.h"

#include "AssetSelector.h"
#include "SegsOriginEditor.h"

#include <QDockWidget>
#include <QMdiSubWindow>

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);

addEditors();
addDocks();
addMdis();

}

void MainWindow::addDocks() {
QDockWidget *dock = new QDockWidget(tr("Asset List"), this);
dock->setAllowedAreas(Qt::DockWidgetArea::AllDockWidgetAreas);
auto *sel = new AssetSelector(dock);
dock->setWidget(sel);
addDockWidget(Qt::LeftDockWidgetArea, dock);

connect(sel,&AssetSelector::assetActivated,this,&MainWindow::onAssetActivated);

}

void MainWindow::onAssetActivated(int type, const QString &path) {

if(m_editors[0]->isVisible()) {
m_mdis[0]->activateWindow();
m_editors[0]->activateWindow();
} else {
m_editors[0]->showMaximized();
}
}

void MainWindow::addEditors() {
m_editors.push_back(new SegsOriginEditor());
m_editors.back()->setAttribute(Qt::WA_DeleteOnClose,false);

}

void MainWindow::addMdis() {
m_mdis.push_back(new QMdiSubWindow(ui->centralwidget));
m_mdis.back()->setAttribute(Qt::WA_DeleteOnClose,false);
//subWindow1->setWidget(w);
}

MainWindow::~MainWindow()
{
delete ui;
}
31 changes: 31 additions & 0 deletions Utilities/EditorComponents/MainWindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#pragma once

#include <QMainWindow>

class QMdiSubWindow;

namespace Ui
{
class MainWindow;
}

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow();

private slots:
void onAssetActivated(int type, const QString &path);

private:
void addDocks();
void addMdis();
void addEditors();

Ui::MainWindow *ui;
std::vector<QWidget *> m_editors;
std::vector<QMdiSubWindow *> m_mdis;
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


SegsOriginEditor::SegsOriginEditor(QWidget *parent) :
QMainWindow(parent),
QWidget(parent),
ui(new Ui::SegsOriginEditor)
{
ui->setupUi(this);
Expand All @@ -24,7 +24,7 @@ SegsOriginEditor::~SegsOriginEditor()

void SegsOriginEditor::changeEvent(QEvent *e)
{
QMainWindow::changeEvent(e);
QWidget::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#pragma once

#include <QtWidgets/QMainWindow>
#include <QtWidgets/QWidget>

namespace Ui {
class SegsOriginEditor;
}

class QAbstractItemModel;

class SegsOriginEditor : public QMainWindow
class SegsOriginEditor : public QWidget
{
Q_OBJECT

Expand Down
Loading

0 comments on commit ced698a

Please sign in to comment.