1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-07 03:12:36 +01:00

Add QStackedWidget to MainWindow for model viewer mode

This commit is contained in:
Daniel Evans 2014-09-20 14:20:12 +01:00
parent bf462702a3
commit 78334aa51b
2 changed files with 34 additions and 7 deletions

View File

@ -35,12 +35,6 @@ ViewerWindow::ViewerWindow(QWidget* parent, Qt::WindowFlags flags)
ex->setShortcut(QKeySequence::Quit);
connect(ex, SIGNAL(triggered()), QApplication::instance(), SLOT(closeAllWindows()));
QMenu* data = mb->addMenu("&Data");
//data->addAction("Export &Model", objectViewer, SLOT(exportModel()));
QMenu* anim = mb->addMenu("&Animation");
anim->addAction("Load &Animations", this, SLOT(openAnimations()));
viewerWidget = new ViewerWidget;
viewerWidget->context()->makeCurrent();
@ -49,11 +43,32 @@ ViewerWindow::ViewerWindow(QWidget* parent, Qt::WindowFlags flags)
glewInit();
objectViewer = new ObjectViewer(viewerWidget);
this->setCentralWidget(objectViewer);
connect(this, SIGNAL(loadedData(GameWorld*)), objectViewer, SLOT(showData(GameWorld*)));
connect(this, SIGNAL(loadedData(GameWorld*)), viewerWidget, SLOT(dataLoaded(GameWorld*)));
viewSwitcher = new QStackedWidget;
viewSwitcher->addWidget(objectViewer);
viewSwitcher->addWidget(new QLabel("Model Viewer Not Implemented Yet"));
QMenu* view = mb->addMenu("&View");
QAction* objectAction = view->addAction("&Object");
QAction* modelAction = view->addAction("&Model");
objectAction->setData(0);
modelAction->setData(1);
connect(objectAction, SIGNAL(triggered()), this, SLOT(switchWidget()));
connect(modelAction, SIGNAL(triggered()), this, SLOT(switchWidget()));
QMenu* data = mb->addMenu("&Data");
//data->addAction("Export &Model", objectViewer, SLOT(exportModel()));
QMenu* anim = mb->addMenu("&Animation");
anim->addAction("Load &Animations", this, SLOT(openAnimations()));
this->setCentralWidget(viewSwitcher);
updateRecentGames();
}
@ -152,6 +167,14 @@ void ViewerWindow::openRecent()
}
}
void ViewerWindow::switchWidget()
{
QAction* r = qobject_cast< QAction* >(sender());
if(r) {
viewSwitcher->setCurrentIndex(r->data().toInt() );
}
}
void ViewerWindow::updateRecentGames()
{
QSettings settings("OpenRW", "rwviewer");

View File

@ -4,6 +4,7 @@
#include <QMainWindow>
#include <engine/GameWorld.hpp>
#include <QGLContext>
#include <QStackedWidget>
class ObjectViewer;
class ViewerWidget;
@ -17,6 +18,7 @@ class ViewerWindow : public QMainWindow
/** Contains the OGL context */
ViewerWidget* viewerWidget;
ObjectViewer* objectViewer;
QStackedWidget* viewSwitcher;
QGLContext* context;
public:
@ -49,6 +51,8 @@ private slots:
void openRecent();
void switchWidget();
private:
QList<QAction*> recentGames;