mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-22 10:22:52 +01:00
Preview text
This commit is contained in:
parent
280a806e2f
commit
1741d7c295
@ -14,4 +14,13 @@ void ArchiveContentsWidget::setArchive(const LoaderIMG& archive)
|
||||
model = new IMGArchiveModel(archive);
|
||||
table->setModel(model);
|
||||
delete m;
|
||||
connect(table->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), SLOT(selectedIndexChanged(QModelIndex)));
|
||||
}
|
||||
|
||||
void ArchiveContentsWidget::selectedIndexChanged(const QModelIndex& current)
|
||||
{
|
||||
if(current.row() < model->getArchive().getAssetCount()) {
|
||||
auto& f = model->getArchive().getAssetInfoByIndex(current.row());
|
||||
emit selectedFileChanged(f.name);
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,12 @@ public:
|
||||
ArchiveContentsWidget(QWidget* parent = 0, Qt::WindowFlags flags = 0);
|
||||
|
||||
void setArchive(const LoaderIMG& archive);
|
||||
|
||||
signals:
|
||||
void selectedFileChanged(const std::string& file);
|
||||
|
||||
public slots:
|
||||
void selectedIndexChanged(const QModelIndex& current);
|
||||
};
|
||||
|
||||
#endif
|
@ -23,6 +23,8 @@ public:
|
||||
virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
||||
|
||||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||
|
||||
const LoaderIMG& getArchive() const { return archive; }
|
||||
};
|
||||
|
||||
#endif
|
@ -2,18 +2,31 @@
|
||||
|
||||
void ViewerWidget::initializeGL()
|
||||
{
|
||||
QGLWidget::initializeGL();
|
||||
QGLWidget::initializeGL();
|
||||
timer.setInterval(16);
|
||||
connect(&timer, SIGNAL(timeout()), SLOT(updateGL()));
|
||||
timer.start();
|
||||
}
|
||||
|
||||
void ViewerWidget::resizeGL(int w, int h)
|
||||
{
|
||||
QGLWidget::resizeGL(w, h);
|
||||
QGLWidget::resizeGL(w, h);
|
||||
}
|
||||
|
||||
void ViewerWidget::paintGL()
|
||||
{
|
||||
glClearColor(0.3f, 0.3f, 0.3f, 1.f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
renderText(5, height() - 5, "Testing, 1 2 3 ...");
|
||||
|
||||
if( !currentFile.empty() ) {
|
||||
QString dbg;
|
||||
dbg.append("Viewing: ");
|
||||
dbg.append(currentFile.c_str());
|
||||
renderText(5, height() - 5, dbg);
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerWidget::showFile(const std::string& file)
|
||||
{
|
||||
currentFile = file;
|
||||
}
|
@ -2,15 +2,26 @@
|
||||
#ifndef _VIEWERWIDGET_HPP_
|
||||
#define _VIEWERWIDGET_HPP_
|
||||
#include <QGLWidget>
|
||||
#include <QTimer>
|
||||
|
||||
class ViewerWidget : public QGLWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
std::string currentFile;
|
||||
|
||||
QTimer timer;
|
||||
|
||||
public:
|
||||
virtual void initializeGL();
|
||||
|
||||
virtual void resizeGL(int w, int h);
|
||||
|
||||
virtual void paintGL();
|
||||
|
||||
public slots:
|
||||
|
||||
void showFile(const std::string& file);
|
||||
};
|
||||
|
||||
#endif
|
@ -23,6 +23,8 @@ ViewerWindow::ViewerWindow(QWidget* parent, Qt::WindowFlags flags): QMainWindow(
|
||||
file->addSeparator();
|
||||
file->addAction("E&xit", QApplication::instance(), SLOT(quit()), QKeySequence::Quit);
|
||||
|
||||
connect(archivewidget, SIGNAL(selectedFileChanged(std::string)), viewer, SLOT(showFile(std::string)));
|
||||
|
||||
QSettings settings("OpenRW", "rwviewer");
|
||||
restoreGeometry(settings.value("geometry").toByteArray());
|
||||
restoreState(settings.value("windowState").toByteArray());
|
||||
|
Loading…
Reference in New Issue
Block a user