Skip to content

Commit

Permalink
Transition from qWarning to qInfo where appropriate
Browse files Browse the repository at this point in the history
qInfo was introduced in Qt 5.5 and using it instead of qWarning where
the printed message is not actually a warning allows QT_FATAL_WARNINGS
to catch only the actual warnings.
  • Loading branch information
bjorn committed Jun 23, 2020
1 parent 4bd95f3 commit 24e92bc
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
22 changes: 11 additions & 11 deletions src/terraingenerator/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct CommandLineOptions {
static void showHelp()
{
// TODO: Make translatable
qWarning() <<
qInfo() <<
"Usage: terraingenerator [options]\n\n"
"Options:\n"
" -h --help : Display this help.\n"
Expand All @@ -87,8 +87,8 @@ static void showHelp()

static void showVersion()
{
qWarning().noquote() << "Terrain Generator"
<< QCoreApplication::applicationVersion();
qInfo().noquote() << "Terrain Generator"
<< QCoreApplication::applicationVersion();
}

static bool parseCommandLineArguments(CommandLineOptions &options)
Expand Down Expand Up @@ -457,16 +457,16 @@ int main(int argc, char *argv[])
terrains.insert(terrain->name(), terrain);

// Check if there is anything to combine.
if (options.combineList.size() == 0) {
if (options.combineList.isEmpty()) {
qWarning() << "No terrain specified to combine (-c option).";
} else {
// Dump the combine lists.
qWarning() << "Terrains to combine:";
qInfo() << "Terrains to combine:";
for (const QStringList &combine : qAsConst(options.combineList)) {
if (combine.isEmpty()) {
qCritical("Empty combine set");
}
qWarning() << combine;
qInfo() << combine;

// Make sure every terrain from this set was defined.
for (const QString &terrainName : combine)
Expand All @@ -485,7 +485,7 @@ int main(int argc, char *argv[])
}

const auto terrainNames = terrains.keys();
qDebug() << "Terrains found:" << terrainNames;
qInfo() << "Terrains found:" << terrainNames;

// Check if all terrains from priority list were found and loaded.
const auto terrainsWithPriority = lessThan.terrainPriority.keys();
Expand Down Expand Up @@ -558,7 +558,7 @@ int main(int argc, char *argv[])
Properties properties;

if (!tile) {
qWarning() << "Generating" << terrainNames;
qInfo() << "Generating" << terrainNames;

// Start a new image
QImage tileImage = QImage(targetTileset->tileWidth(),
Expand Down Expand Up @@ -589,8 +589,8 @@ int main(int argc, char *argv[])

image = QPixmap::fromImage(tileImage);
} else {
qWarning() << "Copying" << terrainNames << "from"
<< QFileInfo(tile->tileset()->fileName()).fileName();
qInfo() << "Copying" << terrainNames << "from"
<< QFileInfo(tile->tileset()->fileName()).fileName();

image = tile->image();
properties = tile->properties();
Expand All @@ -615,7 +615,7 @@ int main(int argc, char *argv[])
if (targetTileset->tileCount() % options.columns > 0)
++rows;

qWarning() << "Writing external tileset image.";
qInfo() << "Writing external tileset image.";
// Save the target tileset image
QImage image(targetTileset->tileWidth() * columns,
targetTileset->tileHeight() * rows,
Expand Down
28 changes: 14 additions & 14 deletions src/tiled/commandlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,28 +116,28 @@ bool CommandLineParser::parse(const QStringList &arguments)

void CommandLineParser::showHelp() const
{
qWarning().noquote() << tr("Usage:\n %1 [options] [files...]").arg(mCurrentProgramName)
<< "\n\n"
<< tr("Options:");
qInfo().noquote() << tr("Usage:\n %1 [options] [files...]").arg(mCurrentProgramName)
<< "\n\n"
<< tr("Options:");

qWarning(" -h %-*s : %s", mLongestArgument, "--help", qUtf8Printable(tr("Display this help")));
qInfo(" -h %-*s : %s", mLongestArgument, "--help", qUtf8Printable(tr("Display this help")));

for (const Option &option : mOptions) {
if (!option.shortName.isNull()) {
qWarning(" -%c %-*s : %s",
option.shortName.toLatin1(),
mLongestArgument,
qUtf8Printable(option.longName),
qUtf8Printable(option.help));
qInfo(" -%c %-*s : %s",
option.shortName.toLatin1(),
mLongestArgument,
qUtf8Printable(option.longName),
qUtf8Printable(option.help));
} else {
qWarning(" %-*s : %s",
mLongestArgument,
qUtf8Printable(option.longName),
qUtf8Printable(option.help));
qInfo(" %-*s : %s",
mLongestArgument,
qUtf8Printable(option.longName),
qUtf8Printable(option.help));
}
}

qWarning();
qInfo();
}

bool CommandLineParser::handleLongOption(const QString &longName)
Expand Down
12 changes: 6 additions & 6 deletions src/tiled/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ void CommandLineHandler::showVersion()
{
if (!showedVersion) {
showedVersion = true;
qWarning().noquote() << QApplication::applicationDisplayName()
<< QApplication::applicationVersion();
qInfo().noquote() << QApplication::applicationDisplayName()
<< QApplication::applicationVersion();
quit = true;
}
}
Expand Down Expand Up @@ -306,9 +306,9 @@ void CommandLineHandler::showExportFormats()
}
formats.sort(Qt::CaseSensitive);

qWarning().noquote() << tr("Map export formats:");
qInfo().noquote() << tr("Map export formats:");
for (const QString &name : formats)
qWarning(" %s", qUtf8Printable(name));
qInfo(" %s", qUtf8Printable(name));

formats.clear();
const auto tilesetFormats = PluginManager::objects<TilesetFormat>();
Expand All @@ -318,9 +318,9 @@ void CommandLineHandler::showExportFormats()
}
formats.sort(Qt::CaseSensitive);

qWarning().noquote() << tr("Tileset export formats:");
qInfo().noquote() << tr("Tileset export formats:");
for (const QString &name : formats)
qWarning(" %s", qUtf8Printable(name));
qInfo(" %s", qUtf8Printable(name));

quit = true;
}
Expand Down

0 comments on commit 24e92bc

Please sign in to comment.