mirror of
https://github.com/mapmapteam/mapmap.git
synced 2026-06-16 12:33:19 +02:00
Make the console and the application more readable
This commit is contained in:
+20
-13
@@ -32,11 +32,11 @@ ConsoleWindow::ConsoleWindow(QWidget *parent) : QMainWindow(parent)
|
||||
// Make read-only but allow copy of text
|
||||
_console->setReadOnly(true);
|
||||
// Create and customize font
|
||||
#if QT_VERSION >= 0x050400
|
||||
QFont font(QFont(":/base-font", 10, QFont::Medium));
|
||||
font.setStyleHint(QFont::Monospace, QFont::PreferAntialias);
|
||||
int id = QFontDatabase::addApplicationFont(":/console-font");
|
||||
QString family = QFontDatabase::applicationFontFamilies(id).at(0);
|
||||
QFont font(QFont(family, 10, QFont::Normal));
|
||||
_console->setFont(font);
|
||||
#endif
|
||||
|
||||
// Set color scheme
|
||||
QPalette scheme = palette();
|
||||
scheme.setColor(QPalette::Base, Qt::black);
|
||||
@@ -83,33 +83,40 @@ void ConsoleWindow::messageLog(QtMsgType type, const QMessageLogContext &context
|
||||
// Message
|
||||
QByteArray message = msg.toLocal8Bit();
|
||||
// Context
|
||||
QString contexts(QStringLiteral("%1:%2").arg(context.file).arg(context.line));
|
||||
// Date and time
|
||||
QString time(QDateTime::currentDateTime().toString(tr("MMM dd yy HH:mm")));
|
||||
QString contexts(QStringLiteral("%1:%2").arg(context.file).arg(context.line)),
|
||||
// Date and time
|
||||
time(QDateTime::currentDateTime().toString(tr("MMM dd yy HH:mm"))),
|
||||
// Colorized time
|
||||
timeHtml = "<font color=\"#000000\">" + time + "</font>",
|
||||
debug = "<strong style=\"color: #00FF00;\">Debug:</strong>",
|
||||
info = "<strong style=\"color: #1E90FF;\">Info:</strong>",
|
||||
warning = "<strong style=\"color: #FFFF00;\">Warning:</strong>",
|
||||
critical = "<strong style=\"color: #FF0000;\">Critical:</strong>",
|
||||
fatal = "<strong style=\"background: #FF0000;\">Fatal!</strong>";
|
||||
// Output
|
||||
QString output;
|
||||
|
||||
switch (type) {
|
||||
case QtDebugMsg:
|
||||
output = time + " | Debug: " + QString(message.constData()) + " - " + contexts;
|
||||
output = time + " | " + debug + " " + QString(message.constData()) + " - <strong>" + contexts + "</strong>";
|
||||
break;
|
||||
#if QT_VERSION >= 0x050400
|
||||
case QtInfoMsg:
|
||||
output = time + " | Info: " + QString(message.constData()) + " - " + contexts;
|
||||
output = time + " | " + info + " " + QString(message.constData()) + " - <strong>" + contexts + "</strong>";
|
||||
break;
|
||||
#endif
|
||||
case QtWarningMsg:
|
||||
output = time + " | Warning: " + QString(message.constData()) + " - " + contexts;
|
||||
output = time + " | " + warning + " " + QString(message.constData()) + " - <strong>" + contexts + "</strong>";
|
||||
break;
|
||||
case QtCriticalMsg:
|
||||
output = time + " | Critical: " + QString(message.constData()) + " - " + contexts;
|
||||
output = time + " | " + critical + " " + QString(message.constData()) + " - <strong>" + contexts + "</strong>";
|
||||
break;
|
||||
case QtFatalMsg:
|
||||
output = time + " | Fatal: " + QString(message.constData()) + " - " + contexts;
|
||||
output = time + " | " + fatal + " " + QString(message.constData()) + " - <strong>" + contexts + "</strong>";
|
||||
abort();
|
||||
}
|
||||
// Print in console
|
||||
_console->appendPlainText(output);
|
||||
_console->appendHtml(output);
|
||||
}
|
||||
|
||||
void ConsoleWindow::closeEvent(QCloseEvent *event)
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ MainWindow::MainWindow()
|
||||
{
|
||||
// Create model.
|
||||
#if QT_VERSION >= 0x050400
|
||||
QMessageLogger(__FILE__, __LINE__, 0).info() << "Video support: " << (Media::hasVideoSupport() ? "yes" : "no") << endl;
|
||||
QMessageLogger(__FILE__, __LINE__, 0).info() << "Video support: " << (Media::hasVideoSupport() ? "yes" : "no");
|
||||
#endif
|
||||
|
||||
mappingManager = new MappingManager;
|
||||
|
||||
@@ -116,7 +116,7 @@ int main(int argc, char *argv[])
|
||||
splash.showMessage(" " + QObject::tr("Initiating program..."),
|
||||
Qt::AlignLeft | Qt::AlignTop, MM::WHITE);
|
||||
|
||||
bool FORCE_FRENCH_LANG = false;
|
||||
//bool FORCE_FRENCH_LANG = false;
|
||||
// set_language_to_french(app);
|
||||
|
||||
// Let splash for at least one second.
|
||||
@@ -124,10 +124,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Create window.
|
||||
MainWindow* win = MainWindow::instance();
|
||||
|
||||
QFontDatabase db;
|
||||
Q_ASSERT( QFontDatabase::addApplicationFont(":/base-font") != -1);
|
||||
app.setFont(QFont(":/base-font", 10, QFont::Bold));
|
||||
// Add custom font
|
||||
int id = QFontDatabase::addApplicationFont(":/base-font");
|
||||
QString family = QFontDatabase::applicationFontFamilies(id).at(0);
|
||||
app.setFont(QFont(family, 11, QFont::Normal));
|
||||
|
||||
// Load stylesheet.
|
||||
QFile stylesheet(":/stylesheet");
|
||||
|
||||
+3
-2
@@ -23,13 +23,14 @@
|
||||
<file alias="mapmap-title">resources/images/logo/logomapmap.png</file>
|
||||
<file alias="mapmap-logo">resources/images/logo/logo_m_big_mapmap.png</file>
|
||||
<file alias="mapmap-splash">resources/images/logo/splash.png</file>
|
||||
<file alias="logo-title">resources/fonts/HelveticaNeueLTPro-Bd.otf</file>
|
||||
<file alias="base-font">resources/fonts/HelveticaNeueLTPro-Bd.otf</file>
|
||||
<file alias="logo-title">resources/fonts/DroidSans.otf</file>
|
||||
<file alias="base-font">resources/fonts/DroidSans.otf</file>
|
||||
<file alias="test-signal">resources/images/test-signal/test-signal.svg</file>
|
||||
<file alias="stylesheet">resources/qss/mapmap.qss</file>
|
||||
<file alias="reset-zoom">resources/images/icons/zoom_reset_w.png</file>
|
||||
<file alias="zoom-in">resources/images/icons/zoom_in_w.png</file>
|
||||
<file alias="zoom-out">resources/images/icons/zoom_out_w.png</file>
|
||||
<file alias="zoom-fit">resources/images/icons/zoom_fit_w.png</file>
|
||||
<file alias="console-font">resources/fonts/Hack-Regular.otf</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user