diff --git a/rwviewer/ViewerWindow.cpp b/rwviewer/ViewerWindow.cpp index f5a91c77..d76736b5 100644 --- a/rwviewer/ViewerWindow.cpp +++ b/rwviewer/ViewerWindow.cpp @@ -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"); diff --git a/rwviewer/ViewerWindow.hpp b/rwviewer/ViewerWindow.hpp index fa9c068d..78323695 100644 --- a/rwviewer/ViewerWindow.hpp +++ b/rwviewer/ViewerWindow.hpp @@ -4,6 +4,7 @@ #include #include #include +#include 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 recentGames;