Skip to content

Commit

Permalink
fixed issues #5 and #6 and added about dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Theverat committed Jan 21, 2015
1 parent 10932d4 commit 6f023d0
Show file tree
Hide file tree
Showing 7 changed files with 179 additions and 55 deletions.
9 changes: 6 additions & 3 deletions NormalmapGenerator.pro
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ SOURCES += main.cpp\
queuemanager.cpp \
gaussianblur.cpp \
boxblur.cpp \
ssaogenerator.cpp
ssaogenerator.cpp \
aboutdialog.cpp

HEADERS += mainwindow.h \
intensitymap.h \
Expand All @@ -37,6 +38,8 @@ HEADERS += mainwindow.h \
queuemanager.h \
gaussianblur.h \
boxblur.h \
ssaogenerator.h
ssaogenerator.h \
aboutdialog.h

FORMS += mainwindow.ui
FORMS += mainwindow.ui \
aboutdialog.ui
14 changes: 14 additions & 0 deletions aboutdialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "aboutdialog.h"
#include "ui_aboutdialog.h"

AboutDialog::AboutDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::AboutDialog)
{
ui->setupUi(this);
}

AboutDialog::~AboutDialog()
{
delete ui;
}
22 changes: 22 additions & 0 deletions aboutdialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef ABOUTDIALOG_H
#define ABOUTDIALOG_H

#include <QDialog>

namespace Ui {
class AboutDialog;
}

class AboutDialog : public QDialog
{
Q_OBJECT

public:
explicit AboutDialog(QWidget *parent = 0);
~AboutDialog();

private:
Ui::AboutDialog *ui;
};

#endif // ABOUTDIALOG_H
41 changes: 41 additions & 0 deletions aboutdialog.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AboutDialog</class>
<widget class="QDialog" name="AboutDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>215</width>
<height>105</height>
</rect>
</property>
<property name="windowTitle">
<string>About NormalmapGenerator</string>
</property>
<property name="modal">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTextBrowser" name="textBrowser">
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt;Author: Simon Wendsche&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;http://byob.carbonmade.com/&quot;&gt;&lt;span style=&quot; font-size:10pt; text-decoration: underline; color:#0000ff;&quot;&gt;Website&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt; text-decoration: underline; color:#0000ff;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;https://github.com/Theverat/NormalmapGenerator/releases&quot;&gt;&lt;span style=&quot; font-size:10pt; text-decoration: underline; color:#0000ff;&quot;&gt;NormalmapGenerator Updates&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
22 changes: 15 additions & 7 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "ssaogenerator.h"
#include "intensitymap.h"
#include "boxblur.h"
#include "aboutdialog.h"

#include <QMessageBox>
#include <QFileDialog>
Expand Down Expand Up @@ -474,10 +475,10 @@ void MainWindow::stopProcessingQueue() {

//save maps using the file dialog
void MainWindow::saveUserFilePath() {
QUrl url = QFileDialog::getSaveFileUrl(this,
"Save as",
loadedImagePath,
"Image Formats (*.png *.jpg *.jpeg *.tiff *.ppm *.bmp *.xpm)");
QFileDialog::Options options(QFileDialog::DontConfirmOverwrite);
QUrl url = QFileDialog::getSaveFileUrl(this, "Save as", loadedImagePath,
"Image Formats (*.png *.jpg *.jpeg *.tiff *.ppm *.bmp *.xpm)",
0, options);
save(url);
}

Expand All @@ -504,21 +505,21 @@ void MainWindow::save(QUrl url) {
QString name_displace = file.absolutePath() + "/" + file.baseName() + "_displace." + suffix;

//check if maps where generated, if yes, check if it could be saved
if(!normalmap.isNull()) {
if(!normalmap.isNull() && ui->checkBox_queue_generateNormal->isChecked()) {
if(!normalmap.save(name_normal))
QMessageBox::information(this, "Error while saving Normalmap", "Normalmap not saved!");
else
ui->statusBar->showMessage("Normalmap saved as \"" + name_normal + "\"", 4000);
}

if(!specmap.isNull()) {
if(!specmap.isNull() && ui->checkBox_queue_generateSpec->isChecked()) {
if(!specmap.save(name_specular))
QMessageBox::information(this, "Error while saving Specularmap", "Specularmap not saved!");
else
ui->statusBar->showMessage("Specularmap saved as \"" + name_specular + "\"", 4000);
}

if(!displacementmap.isNull()) {
if(!displacementmap.isNull() && ui->checkBox_queue_generateDisplace->isChecked()) {
if(!displacementmap.save(name_displace))
QMessageBox::information(this, "Error while saving Displacementmap", "Displacementmap not saved!");
else
Expand Down Expand Up @@ -775,6 +776,11 @@ int MainWindow::calcPercentage(int value, int percentage) {
return (int) (((double)value / 100.0) * percentage);
}

void MainWindow::showAboutDialog() {
AboutDialog *dialog = new AboutDialog(this);
dialog->show();
}

//connects gui buttons with Slots in this class
void MainWindow::connectSignalSlots() {
//connect signals/slots
Expand Down Expand Up @@ -855,4 +861,6 @@ void MainWindow::connectSignalSlots() {
connect(ui->listWidget_queue, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(queueItemDoubleClicked(QListWidgetItem*)));
//normalmap size preview text
connect(ui->spinBox_normalmapSize, SIGNAL(valueChanged(int)), this, SLOT(normalmapSizeChanged()));
//"About" button
connect(ui->pushButton_about, SIGNAL(clicked()), this, SLOT(showAboutDialog()));
}
1 change: 1 addition & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ private slots:
void updateQueueExportOptions();
void queueItemDoubleClicked(QListWidgetItem *item);
void normalmapSizeChanged();
void showAboutDialog();
};

#endif // MAINWINDOW_H
125 changes: 80 additions & 45 deletions mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -29,48 +29,6 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_save">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Save Current Maps</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_removeImagesFromQueue">
<property name="text">
<string>Remove Selected From Queue</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="listWidget_queue">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy">
Expand All @@ -80,7 +38,7 @@
</sizepolicy>
</property>
<property name="title">
<string>Generate</string>
<string>Save</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
Expand Down Expand Up @@ -116,6 +74,55 @@
</layout>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_save">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Save Maps</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_25">
<property name="text">
<string>Queue:</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="listWidget_queue">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_removeImagesFromQueue">
<property name="text">
<string>Remove Selected From Queue</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
Expand Down Expand Up @@ -252,7 +259,7 @@
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex">
<number>4</number>
<number>0</number>
</property>
<property name="elideMode">
<enum>Qt::ElideNone</enum>
Expand Down Expand Up @@ -589,6 +596,9 @@
<property name="text">
<string>Invert Height</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
Expand All @@ -600,6 +610,9 @@
</item>
<item>
<widget class="QCheckBox" name="checkBox_keepLargeDetail">
<property name="toolTip">
<string>Switch off if you want flat normalmaps</string>
</property>
<property name="text">
<string>Keep Large Detail</string>
</property>
Expand All @@ -609,6 +622,9 @@
<property name="checked">
<bool>true</bool>
</property>
<property name="tristate">
<bool>false</bool>
</property>
</widget>
</item>
<item>
Expand Down Expand Up @@ -1132,7 +1148,7 @@
</widget>
<widget class="QWidget" name="tab_ssao">
<attribute name="title">
<string>Ambient Occlusion Map</string>
<string>Ambient Occlusion Map (Experimental)</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
Expand Down Expand Up @@ -1411,6 +1427,25 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_about">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>About</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
Expand Down

0 comments on commit 6f023d0

Please sign in to comment.