From 47c73ed88143f2ccf0d14d150a2efa37af7468e7 Mon Sep 17 00:00:00 2001 From: Anakin Date: Mon, 16 Jan 2017 15:41:37 +0100 Subject: [PATCH] added custom info window, set min size to mainwindow --- QtMeshViewer/Form Files/FileInfoWindow.ui | 127 ++++++++++++++++++++++ QtMeshViewer/Form Files/MainWindow.ui | 9 ++ QtMeshViewer/Header/FileInfoWindow.h | 20 ++++ QtMeshViewer/Header/MainWindow.h | 2 + QtMeshViewer/Source/FileInfoWindow.cpp | 27 +++++ QtMeshViewer/Source/MainWindow.cpp | 15 ++- 6 files changed, 196 insertions(+), 4 deletions(-) create mode 100644 QtMeshViewer/Form Files/FileInfoWindow.ui create mode 100644 QtMeshViewer/Header/FileInfoWindow.h create mode 100644 QtMeshViewer/Source/FileInfoWindow.cpp diff --git a/QtMeshViewer/Form Files/FileInfoWindow.ui b/QtMeshViewer/Form Files/FileInfoWindow.ui new file mode 100644 index 0000000..5e66054 --- /dev/null +++ b/QtMeshViewer/Form Files/FileInfoWindow.ui @@ -0,0 +1,127 @@ + + + FileInfoWindow + + + + 0 + 0 + 200 + 300 + + + + File information + + + + + + Name: - +Materials: - +Vertices: - +Triangles: - + + + + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + false + + + true + + + + + 0 + 0 + 180 + 222 + + + + + + + No file is open + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + + + + + diff --git a/QtMeshViewer/Form Files/MainWindow.ui b/QtMeshViewer/Form Files/MainWindow.ui index a9b1e77..2cfb5c4 100644 --- a/QtMeshViewer/Form Files/MainWindow.ui +++ b/QtMeshViewer/Form Files/MainWindow.ui @@ -10,11 +10,20 @@ 400 + + + 600 + 400 + + MainWindow + + Qt::LeftToolBarArea|Qt::RightToolBarArea|Qt::TopToolBarArea + LeftToolBarArea diff --git a/QtMeshViewer/Header/FileInfoWindow.h b/QtMeshViewer/Header/FileInfoWindow.h new file mode 100644 index 0000000..a48bad1 --- /dev/null +++ b/QtMeshViewer/Header/FileInfoWindow.h @@ -0,0 +1,20 @@ +#pragma once +#include +#include +#include "ui_FileInfoWindow.h" + +class FileInfoWindow : public QWidget +{ + Q_OBJECT + +public: + FileInfoWindow(QWidget *parent = Q_NULLPTR); + ~FileInfoWindow(); + +private: + Ui::FileInfoWindow* ui; + +public: + void setBasicText(QString text); + void setDetailText(QString text); +}; \ No newline at end of file diff --git a/QtMeshViewer/Header/MainWindow.h b/QtMeshViewer/Header/MainWindow.h index af132e3..bd86804 100644 --- a/QtMeshViewer/Header/MainWindow.h +++ b/QtMeshViewer/Header/MainWindow.h @@ -6,6 +6,7 @@ #include #include #include "ui_MainWindow.h" +#include "..\Header\FileInfoWindow.h" struct Material; @@ -23,6 +24,7 @@ private: void setupWidgets(); QByteArray m_fileInfo; QLabel* m_output; + FileInfoWindow* m_infoWindow; private: void openFile(); diff --git a/QtMeshViewer/Source/FileInfoWindow.cpp b/QtMeshViewer/Source/FileInfoWindow.cpp new file mode 100644 index 0000000..598b497 --- /dev/null +++ b/QtMeshViewer/Source/FileInfoWindow.cpp @@ -0,0 +1,27 @@ +#include "..\Header\FileInfoWindow.h" +#include + +FileInfoWindow::FileInfoWindow(QWidget *parent) + : QWidget(parent) + , ui(new Ui::FileInfoWindow) +{ + ui->setupUi(this); + + setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint | Qt::NoDropShadowWindowHint); + +} + +FileInfoWindow::~FileInfoWindow() +{ + delete ui; +} + +void FileInfoWindow::setBasicText(QString text) +{ + ui->basic->setText(text); +} + +void FileInfoWindow::setDetailText(QString text) +{ + ui->detail->setText(text); +} diff --git a/QtMeshViewer/Source/MainWindow.cpp b/QtMeshViewer/Source/MainWindow.cpp index 0f2ad76..250a5c9 100644 --- a/QtMeshViewer/Source/MainWindow.cpp +++ b/QtMeshViewer/Source/MainWindow.cpp @@ -19,6 +19,7 @@ MainWindow::MainWindow(QWidget *parent) , ui(new Ui::MainWindowClass) , m_curSeverity(0) , m_output(new QLabel(this)) + , m_infoWindow(new FileInfoWindow()) { ui->setupUi(this); @@ -33,13 +34,14 @@ MainWindow::MainWindow(QWidget *parent) ui->statusBar->showMessage("MeshViewer by Anakin", 0); - m_fileInfo += "Filename: -\nMaterials: -\nVertices: -\nTriangle: -\nNo file is open"; + m_fileInfo += "Filename: -\nMaterials: -\nVertices: -\nTriangle: -No file is open"; } MainWindow::~MainWindow() { delete ui; delete m_output; + delete m_infoWindow; } void MainWindow::openFile() @@ -114,12 +116,12 @@ void MainWindow::setupWidgets() m_output->setAlignment(Qt::AlignTop); m_output->setText("Name: -\nMaterials: -\nVertice: -\nTriangle: -"); m_output->raise(); - + } void MainWindow::aboutFile() { - QMessageBox* dialog = new QMessageBox(QMessageBox::NoIcon, + /*QMessageBox* dialog = new QMessageBox(QMessageBox::NoIcon, WINDOW_NAME, QString(m_fileInfo.left(m_fileInfo.indexOf(""))), QMessageBox::StandardButton::Close, @@ -129,7 +131,8 @@ void MainWindow::aboutFile() dialog->setStyleSheet("QLabel{min-width: 200px;}"); dialog->setDetailedText(QString(m_fileInfo.right(m_fileInfo.size() - m_fileInfo.indexOf("") - 8))); dialog->exec(); - delete dialog; + delete dialog;*/ + m_infoWindow->show(); } void MainWindow::aboutTool() @@ -189,6 +192,10 @@ void MainWindow::setFileInfo(QString name, QVector* materials, int ver } m_output->setText(m_fileInfo.left(m_fileInfo.indexOf(""))); + + m_infoWindow->setBasicText(QString(m_fileInfo.left(m_fileInfo.indexOf("")))); + m_infoWindow->setDetailText(QString(m_fileInfo.right(m_fileInfo.size() - m_fileInfo.indexOf("") - 8))); + } void MainWindow::printMessage(QString message, int severity)