Compare commits

...

2 commits

2 changed files with 26 additions and 3 deletions

View file

@ -1,11 +1,15 @@
#include "mainwindow.h"
#include "./ui_mainwindow.h"
#include "common.h"
#include "logger.h"
#include "objects/snap.h"
#include <map>
#include <memory>
#include <qclipboard.h>
#include <qglobal.h>
#include <qmessagebox.h>
#include <qmimedata.h>
#include <qstylefactory.h>
#include <qstylehints.h>
#ifdef _NDEBUG
@ -27,7 +31,23 @@ inline bool isDarkMode() {
return text.lightness() > window.lightness();
#endif // QT_VERSION
}
QtMessageHandler defaultMessageHandler = nullptr;
std::map<QtMsgType, Logger::LogLevel> QT_MESSAGE_TYPE_TO_LOG_LEVEL = {
{ QtMsgType::QtInfoMsg, Logger::LogLevel::INFO },
{ QtMsgType::QtSystemMsg, Logger::LogLevel::INFO },
{ QtMsgType::QtDebugMsg, Logger::LogLevel::DEBUG },
{ QtMsgType::QtWarningMsg, Logger::LogLevel::WARNING },
{ QtMsgType::QtCriticalMsg, Logger::LogLevel::ERROR },
{ QtMsgType::QtFatalMsg, Logger::LogLevel::FATAL_ERROR },
};
void logQtMessage(QtMsgType type, const QMessageLogContext &context, const QString &msg) {
Logger::log("[Qt] " + msg.toStdString(), QT_MESSAGE_TYPE_TO_LOG_LEVEL[type]);
// if (defaultMessageHandler) defaultMessageHandler(type, context, msg);
}
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
@ -45,7 +65,9 @@ MainWindow::MainWindow(QWidget *parent)
QIcon::setFallbackThemeName("editor-dark");
else
QIcon::setFallbackThemeName("editor");
// qApp->setStyle(QStyleFactory::create("fusion"));
defaultMessageHandler = qInstallMessageHandler(logQtMessage);
setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);

View file

@ -6,7 +6,8 @@
ExplorerView::ExplorerView(QWidget* parent):
QTreeView(parent),
model(ExplorerModel(std::dynamic_pointer_cast<Instance>(gDataModel))) {
model(ExplorerModel(std::dynamic_pointer_cast<Instance>(gDataModel))),
contextMenu(this) {
this->setModel(&model);
// Disabling the root decoration will cause the expand/collapse chevrons to be hidden too, we don't want that