master
Unknown 2017-03-06 10:00:41 +01:00
parent adc60b951f
commit 1dabd1071b
12 changed files with 60 additions and 65 deletions

View File

@ -1,7 +1,7 @@
#include "colorlineedit.h"
#include <QToolButton>
#include <QStyle>
#include <QToolButton>
ColorLineEdit::ColorLineEdit(QWidget *parent) :
QLineEdit(parent)

View File

@ -1,8 +1,8 @@
#ifndef COLORLINEEDIT_H
#define COLORLINEEDIT_H
#include <QColorDialog>
#include <QLineEdit>
#include <QPushButton>
#include <QColorDialog>
class QToolButton;

View File

@ -1,14 +1,14 @@
#ifndef COLORSTXTASSISTANT_H
#define COLORSTXTASSISTANT_H
#include <QObject>
#include <QDialog>
#include <QFileDialog>
#include <QFileIconProvider>
#include <QListWidget>
#include <QListWidgetItem>
#include <QStringList>
#include <QFileIconProvider>
#include <QFileDialog>
#include <QMetaEnum>
#include <QObject>
#include <QStringList>
#include "makecolors.h"

View File

@ -1,13 +1,13 @@
#include <QDebug>
#include <QFileDialog>
#include <QMessageBox>
#include <QString>
#include <QDebug>
#include <QStandardPaths>
#include <QProcessEnvironment>
#include <QStandardPaths>
#include <QString>
#include "configdialog.h"
#include "ui_configdialog.h"
#include "mainwindow.h"
#include "ui_configdialog.h"
const QString ConfigSettings::defaultMapperExecutableName("minetestmapper");
QStringList ConfigSettings::predefinedMapperLocations;

View File

@ -1,11 +1,11 @@
#ifndef CONFIGDIALOG_H
#define CONFIGDIALOG_H
#include "minetestmapperexe.h"
#include <QDialog>
#include <QMap>
#include <QString>
#include "minetestmapperexe.h"
namespace Ui {
class ConfigDialog;

View File

@ -34,7 +34,7 @@ Geometry::Format Geometry::formatId(const QString &name)
return geometryNameIdMap[name];
}
Geometry::Format Geometry::set(QString str)
Geometry::Format Geometry::set(const QString &str)
{
qDebug()<<"Trying to detect format of "<<str;
QRegularExpressionMatch match;

View File

@ -1,9 +1,9 @@
#ifndef GEOMETRY_H
#define GEOMETRY_H
#include <QDebug>
#include <QMap>
#include <QRegularExpression>
#include <QDebug>
class Geometry
{
@ -36,7 +36,7 @@ public:
Geometry(const QString &s) { set(s); }
//Geometry(const Geometry &g);
Geometry::Format set(QString str);
Geometry::Format set(const QString &str);
void setMax(void);
void setCenterDimensions(int cx, int cy, int dx, int dy);
void setCornerDimensions(int cx, int cy, int dx, int dy);

View File

@ -1,14 +1,12 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <qprocess.h>
#include <qstringlist.h>
#include <QDebug>
#include <QFileDialog>
#include <QDesktopServices>
#include <QCompleter>
#include <QDirModel>
#include "configdialog.h"
#include <QCompleter>
#include <QDebug>
#include <QDesktopServices>
#include <QDirModel>
#include <QFileDialog>
#include <QStringList>
static QMap<int, QString> geometryGranularitySymbolic;
static QMap<QString, int> geometryGranularityNumeric;
@ -313,23 +311,23 @@ void MainWindow::on_button_generate_clicked()
return;
}
qDebug() << QString("Minetestmapper version: " + minetestMapper->getVersion() + minetestMapper->getTreeString());
qDebug() << "Minetestmapper version: " << minetestMapper->getVersion() << minetestMapper->getTreeString();
QDir worldDir = QDir(ui->path_World->text());
if(!worldDir.exists()||worldDir.path()=="."||worldDir.path()=="/"){
QMessageBox::critical(this, tr("no input world selected"),
tr("ERROR: No MinetestWorld selected<br><br>"
QMessageBox::critical(this, tr("No input world selected"),
tr("ERROR: No MinetestWorld selected.\n\n"
"please select a world"));
return;
}
QString imgName = getOutputFileName();
if(imgName.isEmpty()){
QMessageBox::critical(this, tr("no output image selected"),
tr("ERROR: No output image selected<br><br>"
"please select a output image"));
QMessageBox::critical(this, tr("No output image selected"),
tr("ERROR: No output image selected.\n\n"
"Please select a output image"));
return;
}
if(QFile::exists(imgName)){
int ret = QMessageBox::question(this, tr("the Image File does already exist"),
int ret = QMessageBox::question(this, tr("The image file does already exist"),
tr("The File <i>%1</i> does already exist. <br><br>"
"Do you want to overwrite?")
.arg(imgName));
@ -338,7 +336,7 @@ void MainWindow::on_button_generate_clicked()
QDir imgPath = QFileInfo(imgName).absoluteDir();
if(!imgPath.exists())
{
int ret = QMessageBox::question(this, tr("the directory does not exist"),
int ret = QMessageBox::question(this, tr("The directory does not exist"),
tr("The directory <i>%1</i> does not exist. <br><br>"
"Should it be created?")
.arg(imgPath.absolutePath()));
@ -359,8 +357,8 @@ void MainWindow::on_button_generate_clicked()
}
QStringList arguments;
arguments <<"-i" << ui->path_World->text()//"D:\\Programme\\minetest\\worlds\\server_minetest.king-arthur.eu_30000"
<<"--output" << imgName //"D:\\Users\\Adrian\\Desktop\\test2.png"
arguments <<"-i" << ui->path_World->text()
<<"--output" << imgName
<<"--colors" << colorsTxtFilePath
<<"--progress" //<< "--verbose-search-colors=2" //<<"--verbose"
<<"--drawalpha="+ui->drawAlpha->currentText()

View File

@ -1,29 +1,26 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QProcess>
#include <QProgressBar>
#include <QMessageBox>
#include <QRegExp>
#include <QTranslator>
#include <QColorDialog>
#include <QDate>
#include <QCloseEvent>
#include <QInputDialog>
#include <QActionGroup>
#include <QCloseEvent>
#include <QColorDialog>
#include <QDataWidgetMapper>
#include <QDate>
#include <QInputDialog>
#include <QMainWindow>
#include <QMessageBox>
#include <QProgressBar>
#include <QSettings>
#include <QStringListModel>
#include <QMessageBox>
#include <QDataWidgetMapper>
#include <QTranslator>
#ifdef Q_OS_WIN
#include <QWinTaskbarProgress>
#include <QWinTaskbarButton>
#include <QWinTaskbarProgress>
#endif
#include "configdialog.h"
#include "colorstxtassistant.h"
#include "configdialog.h"
#include "drawmapfigure.h"
#include "drawmapfiguretablemodel.h"
#include "figuredelegate.h"
@ -51,8 +48,8 @@ protected:
void showEvent(QShowEvent *event);
protected slots:
// this slot is called by the language menu actions
void slotLanguageChanged(QAction* action);
void slotProfileChanged(QAction* action);
void slotLanguageChanged(QAction *action);
void slotProfileChanged(QAction *action);
private slots:
QString getOutputFileName();
@ -133,7 +130,7 @@ private:
void finishUiInitialisation(void);
// loads a language by the given language shortcur (e.g. de, en)
void loadLanguage(const QString& rLanguage);
void loadLanguage(const QString &rLanguage);
// creates the language menu dynamically from the content of m_langPath
void createLanguageMenu(void);

View File

@ -1,7 +1,7 @@
#include "makecolors.h"
#include <QMetaEnum>
MakeColors::MakeColors(const QString nodesTxt, const QString colorsTxt, const QStringList searchPaths, QObject *parent)
MakeColors::MakeColors(const QString &nodesTxt, const QString &colorsTxt, const QStringList &searchPaths, QObject *parent)
: QThread(parent)
{
textureFileFilter << "*.png";
@ -30,7 +30,7 @@ MakeColors::~MakeColors()
QColor MakeColors::processImage(QString path)
QColor MakeColors::processImage(const QString &path)
{
//create a new image and load from path
QImage img(path);
@ -74,7 +74,7 @@ QColor MakeColors::processImage(QString path)
return color;
}
bool MakeColors::parseNodesTxt(QString nodesTxt)
bool MakeColors::parseNodesTxt(const QString &nodesTxt)
{
output("Parsing "+nodesTxt, INFO);
QFile inputFile(nodesTxt);
@ -111,7 +111,7 @@ bool MakeColors::parseNodesTxt(QString nodesTxt)
return true;
}
bool MakeColors::searchAndProgressTextures(const QString path)
bool MakeColors::searchAndProgressTextures(const QString &path)
{
QDirIterator it(path, textureFileFilter, QDir::Files, QDirIterator::Subdirectories);
while (it.hasNext()){
@ -154,7 +154,7 @@ void MakeColors::setFileNodesTxt(const QString &value)
fileNodesTxt = value;
}
bool MakeColors::writeColorsTxt(const QString file)
bool MakeColors::writeColorsTxt(const QString &file)
{
QFile outputFile(file);
output("Writing colors.txt file to "+file ,INFO);
@ -232,7 +232,7 @@ void MakeColors::stopProcess()
}
void MakeColors::output(QString message, LogLevel level)
void MakeColors::output(const QString &message, LogLevel level)
{
if(logLevel <= level){
emit outputLog(message,level);

View File

@ -18,7 +18,7 @@ class MakeColors : public QThread
{
Q_OBJECT
public:
explicit MakeColors(const QString nodesTxt, const QString colorsTxt, const QStringList searchPaths, QObject *parent);
explicit MakeColors(const QString &nodesTxt, const QString &colorsTxt, const QStringList &searchPaths, QObject *parent);
explicit MakeColors();
~MakeColors();
void startProcess();
@ -40,7 +40,7 @@ public:
void setLogLevel(const LogLevel &value);
signals:
void outputLog(QString message, int level);
void outputLog(const QString &message, int level);
void progressChanged(int);
void maxProgressChanged(int);
@ -50,9 +50,9 @@ public slots:
protected:
void run();
private slots:
QColor processImage(QString path);
bool parseNodesTxt(QString nodesTxt);
bool searchAndProgressTextures(const QString path);
QColor processImage(const QString &path);
bool parseNodesTxt(const QString &nodesTxt);
bool searchAndProgressTextures(const QString &path);
private:
bool abort;
int numberOfNodes = 0;
@ -65,8 +65,8 @@ private:
QHash<QString, QColor> requiredColors;
QMap<QString, QString> nodeList;
bool writeColorsTxt(const QString file);
void output(QString message, LogLevel level = NONE);
bool writeColorsTxt(const QString &file);
void output(const QString &message, LogLevel level = NONE);
QMutex mutex;
};

View File

@ -130,6 +130,7 @@ void MinetestMapperExe::finished(int exitCode, QProcess::ExitStatus exitStatus)
bool MinetestMapperExe::initVersion()
{
static const QRegularExpression regexp(".*Version-ID: *");
QByteArray dataRaw;
QString data;
dataRaw = process->readAllStandardError();
@ -142,7 +143,7 @@ bool MinetestMapperExe::initVersion()
if (!data.contains("Version-ID:")) {
return false;
}
version = data.replace(QRegularExpression(".*Version-ID: *"),"");
version = data.replace(regexp, "");
return true;
}
@ -232,7 +233,6 @@ MinetestMapperExe::Tree MinetestMapperExe::getTree() const
QString MinetestMapperExe::getTreeString() const
{
QMetaEnum metaEnum = QMetaEnum::fromType<MinetestMapperExe::Tree>();
qDebug() << metaEnum.valueToKey(tree);
return QString(metaEnum.valueToKey(tree));
}