From 6f023d08fba9eba7c1fbb31fce3e278069592fd5 Mon Sep 17 00:00:00 2001 From: Theverat Date: Wed, 21 Jan 2015 14:42:53 +0100 Subject: [PATCH] fixed issues #5 and #6 and added about dialog --- NormalmapGenerator.pro | 9 ++- aboutdialog.cpp | 14 +++++ aboutdialog.h | 22 ++++++++ aboutdialog.ui | 41 ++++++++++++++ mainwindow.cpp | 22 +++++--- mainwindow.h | 1 + mainwindow.ui | 125 ++++++++++++++++++++++++++--------------- 7 files changed, 179 insertions(+), 55 deletions(-) create mode 100644 aboutdialog.cpp create mode 100644 aboutdialog.h create mode 100644 aboutdialog.ui diff --git a/NormalmapGenerator.pro b/NormalmapGenerator.pro index 623647d..00cd899 100644 --- a/NormalmapGenerator.pro +++ b/NormalmapGenerator.pro @@ -25,7 +25,8 @@ SOURCES += main.cpp\ queuemanager.cpp \ gaussianblur.cpp \ boxblur.cpp \ - ssaogenerator.cpp + ssaogenerator.cpp \ + aboutdialog.cpp HEADERS += mainwindow.h \ intensitymap.h \ @@ -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 diff --git a/aboutdialog.cpp b/aboutdialog.cpp new file mode 100644 index 0000000..cca3b84 --- /dev/null +++ b/aboutdialog.cpp @@ -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; +} diff --git a/aboutdialog.h b/aboutdialog.h new file mode 100644 index 0000000..2eb311a --- /dev/null +++ b/aboutdialog.h @@ -0,0 +1,22 @@ +#ifndef ABOUTDIALOG_H +#define ABOUTDIALOG_H + +#include + +namespace Ui { +class AboutDialog; +} + +class AboutDialog : public QDialog +{ + Q_OBJECT + +public: + explicit AboutDialog(QWidget *parent = 0); + ~AboutDialog(); + +private: + Ui::AboutDialog *ui; +}; + +#endif // ABOUTDIALOG_H diff --git a/aboutdialog.ui b/aboutdialog.ui new file mode 100644 index 0000000..df2a93b --- /dev/null +++ b/aboutdialog.ui @@ -0,0 +1,41 @@ + + + AboutDialog + + + + 0 + 0 + 215 + 105 + + + + About NormalmapGenerator + + + false + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Author: Simon Wendsche</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://byob.carbonmade.com/"><span style=" font-size:10pt; text-decoration: underline; color:#0000ff;">Website</span></a></p> +<p style="-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;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="https://github.com/Theverat/NormalmapGenerator/releases"><span style=" font-size:10pt; text-decoration: underline; color:#0000ff;">NormalmapGenerator Updates</span></a></p></body></html> + + + true + + + + + + + + diff --git a/mainwindow.cpp b/mainwindow.cpp index ab0ce01..035712c 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -6,6 +6,7 @@ #include "ssaogenerator.h" #include "intensitymap.h" #include "boxblur.h" +#include "aboutdialog.h" #include #include @@ -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); } @@ -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 @@ -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 @@ -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())); } diff --git a/mainwindow.h b/mainwindow.h index 1d9efc8..89c276b 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -82,6 +82,7 @@ private slots: void updateQueueExportOptions(); void queueItemDoubleClicked(QListWidgetItem *item); void normalmapSizeChanged(); + void showAboutDialog(); }; #endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui index 8cee30b..d8b63f5 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -29,48 +29,6 @@ - - - - false - - - Save Current Maps - - - - - - - Remove Selected From Queue - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 200 - 16777215 - - - - QAbstractItemView::ExtendedSelection - - - @@ -80,7 +38,7 @@ - Generate + Save @@ -116,6 +74,55 @@ + + + + false + + + Save Maps + + + + + + + Queue: + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 200 + 16777215 + + + + QAbstractItemView::ExtendedSelection + + + + + + + Remove Selected From Queue + + + @@ -252,7 +259,7 @@ QTabWidget::Rounded - 4 + 0 Qt::ElideNone @@ -589,6 +596,9 @@ Invert Height + + false + @@ -600,6 +610,9 @@ + + Switch off if you want flat normalmaps + Keep Large Detail @@ -609,6 +622,9 @@ true + + false + @@ -1132,7 +1148,7 @@ - Ambient Occlusion Map + Ambient Occlusion Map (Experimental) @@ -1411,6 +1427,25 @@ + + + + + 0 + 0 + + + + + 50 + 16777215 + + + + About + + +