Using QString now,

fileinfo works now
This commit is contained in:
Anakin
2017-01-07 15:59:16 +01:00
parent 8c2ca44f20
commit f5ee8a973d
10 changed files with 157 additions and 129 deletions

View File

@@ -3,10 +3,11 @@
#include <QSurfaceFormat>
#include <QMessageBox>
#include <QFileDialog>
#include <QFile>
#include <QPalette>
#include <QAction>
#include <QSignalMapper>
#include <QFile>
#include <QSizePolicy>
#include "..\Header\FileInterface.h"
#define WINDOW_NAME "Mesh Viewer"
@@ -28,6 +29,8 @@ MainWindow::MainWindow(QWidget *parent)
setupWidgets();
ui->statusBar->showMessage("MeshViewer by Anakin", 0);
m_fileInfo += "Filename: -\nMaterials: -\nVertices: -\nTriangle: -\n<detail>No file is open";
}
MainWindow::~MainWindow()
@@ -38,7 +41,8 @@ MainWindow::~MainWindow()
void MainWindow::openFile()
{
QString fileName = QFileDialog::getOpenFileName(this, "Open File", "", "Mesh (*.msh)");
emit loadFile(fileName.toStdString().c_str());
if(!fileName.isEmpty())
emit loadFile(fileName);
}
void MainWindow::setupWidgets()
@@ -91,14 +95,17 @@ void MainWindow::setupWidgets()
void MainWindow::aboutFile()
{
QMessageBox* dialog = new QMessageBox(QMessageBox::Information,
QMessageBox* dialog = new QMessageBox(QMessageBox::NoIcon,
WINDOW_NAME,
"When i find some time, i'll add some information about\nthe file in the detailed text",
QString(m_fileInfo.left(m_fileInfo.indexOf("<detail>"))),
QMessageBox::StandardButton::Close,
this,
Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
dialog->setDetailedText("This is the cool detailed text\n");
dialog->setStyleSheet("QLabel{min-width: 200px;}");
dialog->setDetailedText(QString(m_fileInfo.right(m_fileInfo.size() - m_fileInfo.indexOf("<detail>") - 8)));
dialog->exec();
delete dialog;
}
void MainWindow::aboutTool()
@@ -111,13 +118,36 @@ void MainWindow::aboutTool()
QString(file.readAll()),
QMessageBox::StandardButton::Close,
this,
Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint
);
Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
//dialog->setDetailedText(QString(file.readAll()));
file.close();
dialog->exec();
delete dialog;
}
void MainWindow::setFileInfo(QString name, QStringList textures, int vertices, int triangle)
{
m_fileInfo = QByteArray("Filename: ");
m_fileInfo += name;
m_fileInfo += "\nMaterials: ";
m_fileInfo += QByteArray::number(textures.size());
m_fileInfo += "\nVertices: ";
m_fileInfo += QByteArray::number(vertices);
m_fileInfo += "\nTriangle: ";
m_fileInfo += QByteArray::number(triangle);
m_fileInfo += "<detail>";
int count(0);
for (auto& it : textures)
{
m_fileInfo += "Material ";
m_fileInfo += QByteArray::number(count++);
m_fileInfo += " - ";
m_fileInfo += it;
m_fileInfo += "\n";
}
}
void MainWindow::printMessage(QString message, int severity)