added custom info window,

set min size to mainwindow
This commit is contained in:
Anakin 2017-01-16 15:41:37 +01:00
parent 86dfe32145
commit 47c73ed881
6 changed files with 196 additions and 4 deletions

View File

@ -0,0 +1,127 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FileInfoWindow</class>
<widget class="QWidget" name="FileInfoWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>200</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>File information</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="basic">
<property name="text">
<string>Name: -
Materials: -
Vertices: -
Triangles: -</string>
</property>
</widget>
</item>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="palette">
<palette>
<active>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>180</width>
<height>222</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="detail">
<property name="text">
<string>No file is open</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -10,11 +10,20 @@
<height>400</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>600</width>
<height>400</height>
</size>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget"/>
<widget class="QToolBar" name="mainToolBar">
<property name="allowedAreas">
<set>Qt::LeftToolBarArea|Qt::RightToolBarArea|Qt::TopToolBarArea</set>
</property>
<attribute name="toolBarArea">
<enum>LeftToolBarArea</enum>
</attribute>

View File

@ -0,0 +1,20 @@
#pragma once
#include <QWidget>
#include <QString>
#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);
};

View File

@ -6,6 +6,7 @@
#include <QStringList>
#include <QLabel>
#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();

View File

@ -0,0 +1,27 @@
#include "..\Header\FileInfoWindow.h"
#include <QIcon>
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);
}

View File

@ -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: -\n<detail>No file is open";
m_fileInfo += "Filename: -\nMaterials: -\nVertices: -\nTriangle: -<detail>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("<detail>"))),
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("<detail>") - 8)));
dialog->exec();
delete dialog;
delete dialog;*/
m_infoWindow->show();
}
void MainWindow::aboutTool()
@ -189,6 +192,10 @@ void MainWindow::setFileInfo(QString name, QVector<Material>* materials, int ver
}
m_output->setText(m_fileInfo.left(m_fileInfo.indexOf("<detail>")));
m_infoWindow->setBasicText(QString(m_fileInfo.left(m_fileInfo.indexOf("<detail>"))));
m_infoWindow->setDetailText(QString(m_fileInfo.right(m_fileInfo.size() - m_fileInfo.indexOf("<detail>") - 8)));
}
void MainWindow::printMessage(QString message, int severity)