Tidy up
This commit is contained in:
parent
adc60b951f
commit
1dabd1071b
@ -1,7 +1,7 @@
|
|||||||
#include "colorlineedit.h"
|
#include "colorlineedit.h"
|
||||||
|
|
||||||
#include <QToolButton>
|
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
|
#include <QToolButton>
|
||||||
|
|
||||||
ColorLineEdit::ColorLineEdit(QWidget *parent) :
|
ColorLineEdit::ColorLineEdit(QWidget *parent) :
|
||||||
QLineEdit(parent)
|
QLineEdit(parent)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#ifndef COLORLINEEDIT_H
|
#ifndef COLORLINEEDIT_H
|
||||||
#define COLORLINEEDIT_H
|
#define COLORLINEEDIT_H
|
||||||
|
#include <QColorDialog>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QColorDialog>
|
|
||||||
|
|
||||||
class QToolButton;
|
class QToolButton;
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
#ifndef COLORSTXTASSISTANT_H
|
#ifndef COLORSTXTASSISTANT_H
|
||||||
#define COLORSTXTASSISTANT_H
|
#define COLORSTXTASSISTANT_H
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QFileIconProvider>
|
||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
#include <QListWidgetItem>
|
#include <QListWidgetItem>
|
||||||
#include <QStringList>
|
|
||||||
#include <QFileIconProvider>
|
|
||||||
#include <QFileDialog>
|
|
||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
#include "makecolors.h"
|
#include "makecolors.h"
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
|
#include <QDebug>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QString>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QStandardPaths>
|
|
||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
#include "configdialog.h"
|
#include "configdialog.h"
|
||||||
#include "ui_configdialog.h"
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
#include "ui_configdialog.h"
|
||||||
|
|
||||||
const QString ConfigSettings::defaultMapperExecutableName("minetestmapper");
|
const QString ConfigSettings::defaultMapperExecutableName("minetestmapper");
|
||||||
QStringList ConfigSettings::predefinedMapperLocations;
|
QStringList ConfigSettings::predefinedMapperLocations;
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#ifndef CONFIGDIALOG_H
|
#ifndef CONFIGDIALOG_H
|
||||||
#define CONFIGDIALOG_H
|
#define CONFIGDIALOG_H
|
||||||
|
|
||||||
|
#include "minetestmapperexe.h"
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include "minetestmapperexe.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class ConfigDialog;
|
class ConfigDialog;
|
||||||
|
@ -34,7 +34,7 @@ Geometry::Format Geometry::formatId(const QString &name)
|
|||||||
return geometryNameIdMap[name];
|
return geometryNameIdMap[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
Geometry::Format Geometry::set(QString str)
|
Geometry::Format Geometry::set(const QString &str)
|
||||||
{
|
{
|
||||||
qDebug()<<"Trying to detect format of "<<str;
|
qDebug()<<"Trying to detect format of "<<str;
|
||||||
QRegularExpressionMatch match;
|
QRegularExpressionMatch match;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#ifndef GEOMETRY_H
|
#ifndef GEOMETRY_H
|
||||||
#define GEOMETRY_H
|
#define GEOMETRY_H
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
class Geometry
|
class Geometry
|
||||||
{
|
{
|
||||||
@ -36,7 +36,7 @@ public:
|
|||||||
Geometry(const QString &s) { set(s); }
|
Geometry(const QString &s) { set(s); }
|
||||||
//Geometry(const Geometry &g);
|
//Geometry(const Geometry &g);
|
||||||
|
|
||||||
Geometry::Format set(QString str);
|
Geometry::Format set(const QString &str);
|
||||||
void setMax(void);
|
void setMax(void);
|
||||||
void setCenterDimensions(int cx, int cy, int dx, int dy);
|
void setCenterDimensions(int cx, int cy, int dx, int dy);
|
||||||
void setCornerDimensions(int cx, int cy, int dx, int dy);
|
void setCornerDimensions(int cx, int cy, int dx, int dy);
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "ui_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<int, QString> geometryGranularitySymbolic;
|
||||||
static QMap<QString, int> geometryGranularityNumeric;
|
static QMap<QString, int> geometryGranularityNumeric;
|
||||||
@ -313,23 +311,23 @@ void MainWindow::on_button_generate_clicked()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << QString("Minetestmapper version: " + minetestMapper->getVersion() + minetestMapper->getTreeString());
|
qDebug() << "Minetestmapper version: " << minetestMapper->getVersion() << minetestMapper->getTreeString();
|
||||||
QDir worldDir = QDir(ui->path_World->text());
|
QDir worldDir = QDir(ui->path_World->text());
|
||||||
if(!worldDir.exists()||worldDir.path()=="."||worldDir.path()=="/"){
|
if(!worldDir.exists()||worldDir.path()=="."||worldDir.path()=="/"){
|
||||||
QMessageBox::critical(this, tr("no input world selected"),
|
QMessageBox::critical(this, tr("No input world selected"),
|
||||||
tr("ERROR: No MinetestWorld selected<br><br>"
|
tr("ERROR: No MinetestWorld selected.\n\n"
|
||||||
"please select a world"));
|
"please select a world"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QString imgName = getOutputFileName();
|
QString imgName = getOutputFileName();
|
||||||
if(imgName.isEmpty()){
|
if(imgName.isEmpty()){
|
||||||
QMessageBox::critical(this, tr("no output image selected"),
|
QMessageBox::critical(this, tr("No output image selected"),
|
||||||
tr("ERROR: No output image selected<br><br>"
|
tr("ERROR: No output image selected.\n\n"
|
||||||
"please select a output image"));
|
"Please select a output image"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(QFile::exists(imgName)){
|
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>"
|
tr("The File <i>%1</i> does already exist. <br><br>"
|
||||||
"Do you want to overwrite?")
|
"Do you want to overwrite?")
|
||||||
.arg(imgName));
|
.arg(imgName));
|
||||||
@ -338,7 +336,7 @@ void MainWindow::on_button_generate_clicked()
|
|||||||
QDir imgPath = QFileInfo(imgName).absoluteDir();
|
QDir imgPath = QFileInfo(imgName).absoluteDir();
|
||||||
if(!imgPath.exists())
|
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>"
|
tr("The directory <i>%1</i> does not exist. <br><br>"
|
||||||
"Should it be created?")
|
"Should it be created?")
|
||||||
.arg(imgPath.absolutePath()));
|
.arg(imgPath.absolutePath()));
|
||||||
@ -359,8 +357,8 @@ void MainWindow::on_button_generate_clicked()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
arguments <<"-i" << ui->path_World->text()//"D:\\Programme\\minetest\\worlds\\server_minetest.king-arthur.eu_30000"
|
arguments <<"-i" << ui->path_World->text()
|
||||||
<<"--output" << imgName //"D:\\Users\\Adrian\\Desktop\\test2.png"
|
<<"--output" << imgName
|
||||||
<<"--colors" << colorsTxtFilePath
|
<<"--colors" << colorsTxtFilePath
|
||||||
<<"--progress" //<< "--verbose-search-colors=2" //<<"--verbose"
|
<<"--progress" //<< "--verbose-search-colors=2" //<<"--verbose"
|
||||||
<<"--drawalpha="+ui->drawAlpha->currentText()
|
<<"--drawalpha="+ui->drawAlpha->currentText()
|
||||||
|
31
mainwindow.h
31
mainwindow.h
@ -1,29 +1,26 @@
|
|||||||
#ifndef MAINWINDOW_H
|
#ifndef MAINWINDOW_H
|
||||||
#define 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 <QActionGroup>
|
||||||
|
#include <QCloseEvent>
|
||||||
|
#include <QColorDialog>
|
||||||
|
#include <QDataWidgetMapper>
|
||||||
|
#include <QDate>
|
||||||
|
#include <QInputDialog>
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QProgressBar>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QStringListModel>
|
#include <QStringListModel>
|
||||||
#include <QMessageBox>
|
#include <QTranslator>
|
||||||
#include <QDataWidgetMapper>
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include <QWinTaskbarProgress>
|
|
||||||
#include <QWinTaskbarButton>
|
#include <QWinTaskbarButton>
|
||||||
|
#include <QWinTaskbarProgress>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "configdialog.h"
|
|
||||||
#include "colorstxtassistant.h"
|
#include "colorstxtassistant.h"
|
||||||
|
#include "configdialog.h"
|
||||||
#include "drawmapfigure.h"
|
#include "drawmapfigure.h"
|
||||||
#include "drawmapfiguretablemodel.h"
|
#include "drawmapfiguretablemodel.h"
|
||||||
#include "figuredelegate.h"
|
#include "figuredelegate.h"
|
||||||
@ -51,8 +48,8 @@ protected:
|
|||||||
void showEvent(QShowEvent *event);
|
void showEvent(QShowEvent *event);
|
||||||
protected slots:
|
protected slots:
|
||||||
// this slot is called by the language menu actions
|
// this slot is called by the language menu actions
|
||||||
void slotLanguageChanged(QAction* action);
|
void slotLanguageChanged(QAction *action);
|
||||||
void slotProfileChanged(QAction* action);
|
void slotProfileChanged(QAction *action);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
QString getOutputFileName();
|
QString getOutputFileName();
|
||||||
@ -133,7 +130,7 @@ private:
|
|||||||
void finishUiInitialisation(void);
|
void finishUiInitialisation(void);
|
||||||
|
|
||||||
// loads a language by the given language shortcur (e.g. de, en)
|
// 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
|
// creates the language menu dynamically from the content of m_langPath
|
||||||
void createLanguageMenu(void);
|
void createLanguageMenu(void);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "makecolors.h"
|
#include "makecolors.h"
|
||||||
#include <QMetaEnum>
|
#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)
|
: QThread(parent)
|
||||||
{
|
{
|
||||||
textureFileFilter << "*.png";
|
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
|
//create a new image and load from path
|
||||||
QImage img(path);
|
QImage img(path);
|
||||||
@ -74,7 +74,7 @@ QColor MakeColors::processImage(QString path)
|
|||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MakeColors::parseNodesTxt(QString nodesTxt)
|
bool MakeColors::parseNodesTxt(const QString &nodesTxt)
|
||||||
{
|
{
|
||||||
output("Parsing "+nodesTxt, INFO);
|
output("Parsing "+nodesTxt, INFO);
|
||||||
QFile inputFile(nodesTxt);
|
QFile inputFile(nodesTxt);
|
||||||
@ -111,7 +111,7 @@ bool MakeColors::parseNodesTxt(QString nodesTxt)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MakeColors::searchAndProgressTextures(const QString path)
|
bool MakeColors::searchAndProgressTextures(const QString &path)
|
||||||
{
|
{
|
||||||
QDirIterator it(path, textureFileFilter, QDir::Files, QDirIterator::Subdirectories);
|
QDirIterator it(path, textureFileFilter, QDir::Files, QDirIterator::Subdirectories);
|
||||||
while (it.hasNext()){
|
while (it.hasNext()){
|
||||||
@ -154,7 +154,7 @@ void MakeColors::setFileNodesTxt(const QString &value)
|
|||||||
fileNodesTxt = value;
|
fileNodesTxt = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MakeColors::writeColorsTxt(const QString file)
|
bool MakeColors::writeColorsTxt(const QString &file)
|
||||||
{
|
{
|
||||||
QFile outputFile(file);
|
QFile outputFile(file);
|
||||||
output("Writing colors.txt file to "+file ,INFO);
|
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){
|
if(logLevel <= level){
|
||||||
emit outputLog(message,level);
|
emit outputLog(message,level);
|
||||||
|
14
makecolors.h
14
makecolors.h
@ -18,7 +18,7 @@ class MakeColors : public QThread
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
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();
|
explicit MakeColors();
|
||||||
~MakeColors();
|
~MakeColors();
|
||||||
void startProcess();
|
void startProcess();
|
||||||
@ -40,7 +40,7 @@ public:
|
|||||||
void setLogLevel(const LogLevel &value);
|
void setLogLevel(const LogLevel &value);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void outputLog(QString message, int level);
|
void outputLog(const QString &message, int level);
|
||||||
void progressChanged(int);
|
void progressChanged(int);
|
||||||
void maxProgressChanged(int);
|
void maxProgressChanged(int);
|
||||||
|
|
||||||
@ -50,9 +50,9 @@ public slots:
|
|||||||
protected:
|
protected:
|
||||||
void run();
|
void run();
|
||||||
private slots:
|
private slots:
|
||||||
QColor processImage(QString path);
|
QColor processImage(const QString &path);
|
||||||
bool parseNodesTxt(QString nodesTxt);
|
bool parseNodesTxt(const QString &nodesTxt);
|
||||||
bool searchAndProgressTextures(const QString path);
|
bool searchAndProgressTextures(const QString &path);
|
||||||
private:
|
private:
|
||||||
bool abort;
|
bool abort;
|
||||||
int numberOfNodes = 0;
|
int numberOfNodes = 0;
|
||||||
@ -65,8 +65,8 @@ private:
|
|||||||
|
|
||||||
QHash<QString, QColor> requiredColors;
|
QHash<QString, QColor> requiredColors;
|
||||||
QMap<QString, QString> nodeList;
|
QMap<QString, QString> nodeList;
|
||||||
bool writeColorsTxt(const QString file);
|
bool writeColorsTxt(const QString &file);
|
||||||
void output(QString message, LogLevel level = NONE);
|
void output(const QString &message, LogLevel level = NONE);
|
||||||
QMutex mutex;
|
QMutex mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -130,6 +130,7 @@ void MinetestMapperExe::finished(int exitCode, QProcess::ExitStatus exitStatus)
|
|||||||
|
|
||||||
bool MinetestMapperExe::initVersion()
|
bool MinetestMapperExe::initVersion()
|
||||||
{
|
{
|
||||||
|
static const QRegularExpression regexp(".*Version-ID: *");
|
||||||
QByteArray dataRaw;
|
QByteArray dataRaw;
|
||||||
QString data;
|
QString data;
|
||||||
dataRaw = process->readAllStandardError();
|
dataRaw = process->readAllStandardError();
|
||||||
@ -142,7 +143,7 @@ bool MinetestMapperExe::initVersion()
|
|||||||
if (!data.contains("Version-ID:")) {
|
if (!data.contains("Version-ID:")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
version = data.replace(QRegularExpression(".*Version-ID: *"),"");
|
version = data.replace(regexp, "");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,7 +233,6 @@ MinetestMapperExe::Tree MinetestMapperExe::getTree() const
|
|||||||
QString MinetestMapperExe::getTreeString() const
|
QString MinetestMapperExe::getTreeString() const
|
||||||
{
|
{
|
||||||
QMetaEnum metaEnum = QMetaEnum::fromType<MinetestMapperExe::Tree>();
|
QMetaEnum metaEnum = QMetaEnum::fromType<MinetestMapperExe::Tree>();
|
||||||
qDebug() << metaEnum.valueToKey(tree);
|
|
||||||
return QString(metaEnum.valueToKey(tree));
|
return QString(metaEnum.valueToKey(tree));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user