From 54d98e291701f2187174a67c186f1ea762c6b959 Mon Sep 17 00:00:00 2001
From: isanae <14251494+isanae@users.noreply.github.com>
Date: Tue, 16 Jul 2019 05:38:32 -0400
Subject: removed unused or redundant stuff in error_report.h renamed log() to
vlog() for now extracted console creation to Console class rewrote LogBuffer
to work with logging from uibase, renamed to LogModel added fmt dependency
---
src/organizercore.cpp | 1 -
1 file changed, 1 deletion(-)
(limited to 'src/organizercore.cpp')
diff --git a/src/organizercore.cpp b/src/organizercore.cpp
index eeb69e61..5f5c3afe 100644
--- a/src/organizercore.cpp
+++ b/src/organizercore.cpp
@@ -342,7 +342,6 @@ OrganizerCore::~OrganizerCore()
m_CurrentProfile = nullptr;
ModInfo::clear();
- LogBuffer::cleanQuit();
m_ModList.setProfile(nullptr);
// NexusInterface::instance()->cleanup();
--
cgit v1.3.1
From 6217f910f095adea4b06f370726636b09efea4ed Mon Sep 17 00:00:00 2001
From: isanae <14251494+isanae@users.noreply.github.com>
Date: Tue, 16 Jul 2019 05:42:22 -0400
Subject: renamed logbuffer files to loglist
---
src/CMakeLists.txt | 6 +-
src/logbuffer.cpp | 171 --------------------------------------------------
src/logbuffer.h | 61 ------------------
src/loglist.cpp | 171 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/loglist.h | 61 ++++++++++++++++++
src/main.cpp | 2 +-
src/mainwindow.cpp | 2 +-
src/organizercore.cpp | 1 -
8 files changed, 237 insertions(+), 238 deletions(-)
delete mode 100644 src/logbuffer.cpp
delete mode 100644 src/logbuffer.h
create mode 100644 src/loglist.cpp
create mode 100644 src/loglist.h
(limited to 'src/organizercore.cpp')
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a359b8a9..9dbab132 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -73,7 +73,7 @@ SET(organizer_SRCS
mainwindow.cpp
main.cpp
loghighlighter.cpp
- logbuffer.cpp
+ loglist.cpp
lockeddialogbase.cpp
lockeddialog.cpp
waitingonclosedialog.cpp
@@ -181,7 +181,7 @@ SET(organizer_HDRS
messagedialog.h
mainwindow.h
loghighlighter.h
- logbuffer.h
+ loglist.h
lockeddialogbase.h
lockeddialog.h
waitingonclosedialog.h
@@ -436,7 +436,7 @@ set(widgets
filterwidget
icondelegate
lcdnumber
- logbuffer
+ loglist
loghighlighter
modflagicondelegate
modidlineedit
diff --git a/src/logbuffer.cpp b/src/logbuffer.cpp
deleted file mode 100644
index 9e3cd712..00000000
--- a/src/logbuffer.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
-Copyright (C) 2012 Sebastian Herbord. All rights reserved.
-
-This file is part of Mod Organizer.
-
-Mod Organizer is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-Mod Organizer is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Mod Organizer. If not, see .
-*/
-
-#include "logbuffer.h"
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-using namespace MOBase;
-
-static LogModel* g_instance = nullptr;
-const std::size_t MaxLines = 1000;
-
-LogModel::LogModel()
-{
- connect(this, &LogModel::entryAdded, [&](auto&& e){ onEntryAdded(e); });
-}
-
-void LogModel::create()
-{
- g_instance = new LogModel;
-}
-
-LogModel& LogModel::instance()
-{
- return *g_instance;
-}
-
-void LogModel::add(MOBase::log::Entry e)
-{
- emit entryAdded(std::move(e));
-}
-
-void LogModel::onEntryAdded(MOBase::log::Entry e)
-{
- bool full = false;
- if (m_messages.size() > MaxLines) {
- m_messages.pop_front();
- full = true;
- }
-
- const int row = static_cast(m_messages.size());
-
- if (!full) {
- beginInsertRows(QModelIndex(), row, row + 1);
- }
-
- m_messages.emplace_back(std::move(e));
-
- if (!full) {
- endInsertRows();
- } else {
- emit dataChanged(
- createIndex(row, 0),
- createIndex(row + 1, columnCount({})));
- }
-}
-
-QModelIndex LogModel::index(int row, int column, const QModelIndex&) const
-{
- return createIndex(row, column, row);
-}
-
-QModelIndex LogModel::parent(const QModelIndex&) const
-{
- return QModelIndex();
-}
-
-int LogModel::rowCount(const QModelIndex& parent) const
-{
- if (parent.isValid())
- return 0;
- else
- return static_cast(m_messages.size());
-}
-
-int LogModel::columnCount(const QModelIndex&) const
-{
- return 3;
-}
-
-QVariant LogModel::data(const QModelIndex& index, int role) const
-{
- using namespace std::chrono;
-
- const auto row = static_cast(index.row());
- if (row >= m_messages.size()) {
- return {};
- }
-
- const auto& e = m_messages[row];
-
- if (role == Qt::DisplayRole) {
- if (index.column() == 1) {
- const auto ms = duration_cast(e.time.time_since_epoch());
- const auto s = duration_cast(ms);
-
- const std::time_t t = s.count();
- const std::size_t frac = ms.count() % 1000;
-
- auto time = QDateTime::fromTime_t(t).time();
- time = time.addMSecs(frac);
-
- return time.toString("hh:mm:ss.zzz");
- } else if (index.column() == 2) {
- return QString::fromStdString(e.message);
- }
- }
-
- if (role == Qt::DecorationRole) {
- if (index.column() == 0) {
- switch (e.level) {
- case log::Warning:
- return QIcon(":/MO/gui/warning");
-
- case log::Error:
- return QIcon(":/MO/gui/problem");
-
- case log::Debug: // fall-through
- case log::Info:
- default:
- return {};
- }
- }
- }
-
- return QVariant();
-}
-
-QVariant LogModel::headerData(int, Qt::Orientation, int) const
-{
- return {};
-}
-
-void vlog(const char *format, ...)
-{
- va_list argList;
- va_start(argList, format);
-
- static const int BUFFERSIZE = 1000;
-
- char buffer[BUFFERSIZE + 1];
- buffer[BUFFERSIZE] = '\0';
-
- vsnprintf(buffer, BUFFERSIZE, format, argList);
-
- qCritical("%s", buffer);
-
- va_end(argList);
-}
diff --git a/src/logbuffer.h b/src/logbuffer.h
deleted file mode 100644
index 1bf8901b..00000000
--- a/src/logbuffer.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
-Copyright (C) 2012 Sebastian Herbord. All rights reserved.
-
-This file is part of Mod Organizer.
-
-Mod Organizer is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-Mod Organizer is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Mod Organizer. If not, see .
-*/
-
-#ifndef LOGBUFFER_H
-#define LOGBUFFER_H
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-class LogModel : public QAbstractItemModel
-{
- Q_OBJECT
-
-public:
- static void create();
- static LogModel& instance();
-
- void add(MOBase::log::Entry e);
-
-protected:
- QModelIndex index(int row, int column, const QModelIndex& parent) const override;
- QModelIndex parent(const QModelIndex &child) const override;
- int rowCount(const QModelIndex &parent) const override;
- int columnCount(const QModelIndex &parent) const override;
- QVariant data(const QModelIndex &index, int role) const override;
-
- QVariant headerData(
- int section, Qt::Orientation ori, int role=Qt::DisplayRole) const override;
-
-signals:
- void entryAdded(MOBase::log::Entry e);
-
-private:
- std::deque m_messages;
-
- LogModel();
- void onEntryAdded(MOBase::log::Entry e);
-};
-
-#endif // LOGBUFFER_H
diff --git a/src/loglist.cpp b/src/loglist.cpp
new file mode 100644
index 00000000..cb927272
--- /dev/null
+++ b/src/loglist.cpp
@@ -0,0 +1,171 @@
+/*
+Copyright (C) 2012 Sebastian Herbord. All rights reserved.
+
+This file is part of Mod Organizer.
+
+Mod Organizer is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+Mod Organizer is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mod Organizer. If not, see .
+*/
+
+#include "loglist.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+using namespace MOBase;
+
+static LogModel* g_instance = nullptr;
+const std::size_t MaxLines = 1000;
+
+LogModel::LogModel()
+{
+ connect(this, &LogModel::entryAdded, [&](auto&& e){ onEntryAdded(e); });
+}
+
+void LogModel::create()
+{
+ g_instance = new LogModel;
+}
+
+LogModel& LogModel::instance()
+{
+ return *g_instance;
+}
+
+void LogModel::add(MOBase::log::Entry e)
+{
+ emit entryAdded(std::move(e));
+}
+
+void LogModel::onEntryAdded(MOBase::log::Entry e)
+{
+ bool full = false;
+ if (m_messages.size() > MaxLines) {
+ m_messages.pop_front();
+ full = true;
+ }
+
+ const int row = static_cast(m_messages.size());
+
+ if (!full) {
+ beginInsertRows(QModelIndex(), row, row + 1);
+ }
+
+ m_messages.emplace_back(std::move(e));
+
+ if (!full) {
+ endInsertRows();
+ } else {
+ emit dataChanged(
+ createIndex(row, 0),
+ createIndex(row + 1, columnCount({})));
+ }
+}
+
+QModelIndex LogModel::index(int row, int column, const QModelIndex&) const
+{
+ return createIndex(row, column, row);
+}
+
+QModelIndex LogModel::parent(const QModelIndex&) const
+{
+ return QModelIndex();
+}
+
+int LogModel::rowCount(const QModelIndex& parent) const
+{
+ if (parent.isValid())
+ return 0;
+ else
+ return static_cast(m_messages.size());
+}
+
+int LogModel::columnCount(const QModelIndex&) const
+{
+ return 3;
+}
+
+QVariant LogModel::data(const QModelIndex& index, int role) const
+{
+ using namespace std::chrono;
+
+ const auto row = static_cast(index.row());
+ if (row >= m_messages.size()) {
+ return {};
+ }
+
+ const auto& e = m_messages[row];
+
+ if (role == Qt::DisplayRole) {
+ if (index.column() == 1) {
+ const auto ms = duration_cast(e.time.time_since_epoch());
+ const auto s = duration_cast(ms);
+
+ const std::time_t t = s.count();
+ const std::size_t frac = ms.count() % 1000;
+
+ auto time = QDateTime::fromTime_t(t).time();
+ time = time.addMSecs(frac);
+
+ return time.toString("hh:mm:ss.zzz");
+ } else if (index.column() == 2) {
+ return QString::fromStdString(e.message);
+ }
+ }
+
+ if (role == Qt::DecorationRole) {
+ if (index.column() == 0) {
+ switch (e.level) {
+ case log::Warning:
+ return QIcon(":/MO/gui/warning");
+
+ case log::Error:
+ return QIcon(":/MO/gui/problem");
+
+ case log::Debug: // fall-through
+ case log::Info:
+ default:
+ return {};
+ }
+ }
+ }
+
+ return QVariant();
+}
+
+QVariant LogModel::headerData(int, Qt::Orientation, int) const
+{
+ return {};
+}
+
+void vlog(const char *format, ...)
+{
+ va_list argList;
+ va_start(argList, format);
+
+ static const int BUFFERSIZE = 1000;
+
+ char buffer[BUFFERSIZE + 1];
+ buffer[BUFFERSIZE] = '\0';
+
+ vsnprintf(buffer, BUFFERSIZE, format, argList);
+
+ qCritical("%s", buffer);
+
+ va_end(argList);
+}
diff --git a/src/loglist.h b/src/loglist.h
new file mode 100644
index 00000000..1bf8901b
--- /dev/null
+++ b/src/loglist.h
@@ -0,0 +1,61 @@
+/*
+Copyright (C) 2012 Sebastian Herbord. All rights reserved.
+
+This file is part of Mod Organizer.
+
+Mod Organizer is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+Mod Organizer is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mod Organizer. If not, see .
+*/
+
+#ifndef LOGBUFFER_H
+#define LOGBUFFER_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+class LogModel : public QAbstractItemModel
+{
+ Q_OBJECT
+
+public:
+ static void create();
+ static LogModel& instance();
+
+ void add(MOBase::log::Entry e);
+
+protected:
+ QModelIndex index(int row, int column, const QModelIndex& parent) const override;
+ QModelIndex parent(const QModelIndex &child) const override;
+ int rowCount(const QModelIndex &parent) const override;
+ int columnCount(const QModelIndex &parent) const override;
+ QVariant data(const QModelIndex &index, int role) const override;
+
+ QVariant headerData(
+ int section, Qt::Orientation ori, int role=Qt::DisplayRole) const override;
+
+signals:
+ void entryAdded(MOBase::log::Entry e);
+
+private:
+ std::deque m_messages;
+
+ LogModel();
+ void onEntryAdded(MOBase::log::Entry e);
+};
+
+#endif // LOGBUFFER_H
diff --git a/src/main.cpp b/src/main.cpp
index 23ea234a..8b5648c9 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -39,7 +39,7 @@ along with Mod Organizer. If not, see .
#include "singleinstance.h"
#include "utility.h"
#include "helper.h"
-#include "logbuffer.h"
+#include "loglist.h"
#include "selectiondialog.h"
#include "moapplication.h"
#include "tutorialmanager.h"
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index cd224414..107f3e09 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -59,7 +59,7 @@ along with Mod Organizer. If not, see .
#include "installationmanager.h"
#include "lockeddialog.h"
#include "waitingonclosedialog.h"
-#include "logbuffer.h"
+#include "loglist.h"
#include "downloadlistsortproxy.h"
#include "motddialog.h"
#include "filedialogmemory.h"
diff --git a/src/organizercore.cpp b/src/organizercore.cpp
index 5f5c3afe..d3cd54ee 100644
--- a/src/organizercore.cpp
+++ b/src/organizercore.cpp
@@ -14,7 +14,6 @@
#include "plugincontainer.h"
#include "pluginlistsortproxy.h"
#include "profile.h"
-#include "logbuffer.h"
#include "credentialsdialog.h"
#include "filedialogmemory.h"
#include "modinfodialog.h"
--
cgit v1.3.1
From bca6283311cf1dea4c96f8ee5bf192bdb1640cb3 Mon Sep 17 00:00:00 2001
From: isanae <14251494+isanae@users.noreply.github.com>
Date: Wed, 17 Jul 2019 08:56:16 -0400
Subject: use log::Levels instead of ints create log level combobox in code,
set selected index based on value instead added log level to context menu in
log list
---
src/mainwindow.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++++---
src/mainwindow.h | 12 +++++++++---
src/mainwindow.ui | 30 +++++++++++++++---------------
src/organizercore.cpp | 4 +++-
src/organizercore.h | 5 ++++-
src/settings.cpp | 30 ++++++++++++++++++++++++++----
src/settings.h | 10 +++++++++-
src/settingsdialog.ui | 20 --------------------
src/usvfsconnector.cpp | 20 +++++++++++---------
src/usvfsconnector.h | 7 ++++++-
10 files changed, 127 insertions(+), 58 deletions(-)
(limited to 'src/organizercore.cpp')
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 4e91ef9f..f65bf4e1 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -357,7 +357,7 @@ MainWindow::MainWindow(QSettings &initSettings
m_CategoryFactory.loadCategories();
- ui->logList->addAction(ui->actionCopy_Log_to_Clipboard);
+ setupLogMenu();
int splitterSize = this->size().height(); // actually total window size, but the splitter doesn't seem to return the true value
ui->topLevelSplitter->setSizes(QList() << splitterSize - 100 << 100);
@@ -812,6 +812,36 @@ void MainWindow::setupActionMenu(QAction* a)
tb->setPopupMode(QToolButton::InstantPopup);
}
+void MainWindow::setupLogMenu()
+{
+ connect(ui->logList, &QWidget::customContextMenuRequested, [&](auto&& pos){
+ auto* menu = new QMenu(ui->logList);
+
+ menu->addAction(tr("Copy& Log"), [&]{ ui->logList->copyToClipboard(); });
+ menu->addSeparator();
+
+ auto* levels = new QMenu(tr("&Level"));
+ menu->addMenu(levels);
+
+ auto* ag = new QActionGroup(menu);
+
+ auto addAction = [&](auto&& text, auto&& level) {
+ auto* a = new QAction(text, ag);
+ a->setCheckable(true);
+ a->setChecked(log::getDefault().level() == level);
+ connect(a, &QAction::triggered, [this, level]{ setLogLevel(level); });
+ levels->addAction(a);
+ };
+
+ addAction(tr("&Errors"), log::Error);
+ addAction(tr("&Warnings"), log::Warning);
+ addAction(tr("&Info"), log::Info);
+ addAction(tr("&Debug"), log::Debug);
+
+ menu->popup(ui->logList->viewport()->mapToGlobal(pos));
+ });
+}
+
void MainWindow::updatePinnedExecutables()
{
for (auto* a : ui->toolBar->actions()) {
@@ -5287,12 +5317,23 @@ void MainWindow::on_actionSettings_triggered()
m_statusBar->checkSettings(m_OrganizerCore.settings());
updateDownloadView();
- m_OrganizerCore.updateVFSParams(settings.logLevel(), settings.crashDumpsType(), settings.executablesBlacklist());
+ setLogLevel(settings.logLevel());
m_OrganizerCore.cycleDiagnostics();
toggleMO2EndorseState();
}
+void MainWindow::setLogLevel(log::Levels level)
+{
+ auto& s = m_OrganizerCore.settings();
+
+ s.setLogLevel(level);
+
+ m_OrganizerCore.updateVFSParams(
+ s.logLevel(), s.crashDumpsType(), s.executablesBlacklist());
+
+ log::getDefault().setLevel(s.logLevel());
+}
void MainWindow::on_actionNexus_triggered()
{
@@ -6811,7 +6852,7 @@ void MainWindow::on_restoreModsButton_clicked()
}
}
-void MainWindow::on_actionCopy_Log_to_Clipboard_triggered()
+void MainWindow::on_actionLogCopy_triggered()
{
ui->logList->copyToClipboard();
}
diff --git a/src/mainwindow.h b/src/mainwindow.h
index d7dbfd90..74993667 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -30,6 +30,9 @@ along with Mod Organizer. If not, see .
#include "modlistsortproxy.h"
#include "savegameinfo.h"
#include "tutorialcontrol.h"
+#include "plugincontainer.h" //class PluginContainer;
+#include "iplugingame.h" //namespace MOBase { class IPluginGame; }
+#include
//Note the commented headers here can be replaced with forward references,
//when I get round to cleaning up main.cpp
@@ -38,10 +41,10 @@ class CategoryFactory;
class LockedDialogBase;
class OrganizerCore;
class StatusBar;
-#include "plugincontainer.h" //class PluginContainer;
+
class PluginListSortProxy;
namespace BSA { class Archive; }
-#include "iplugingame.h" //namespace MOBase { class IPluginGame; }
+
namespace MOBase { class IPluginModPage; }
namespace MOBase { class IPluginTool; }
namespace MOBase { class ISaveGame; }
@@ -633,10 +636,13 @@ private slots:
void search_activated();
void searchClear_activated();
+ void setupLogMenu();
void resetActionIcons();
void updateModCount();
void updatePluginCount();
+ void setLogLevel(MOBase::log::Levels level);
+
private slots: // ui slots
// actions
void on_actionAdd_Profile_triggered();
@@ -690,7 +696,7 @@ private slots: // ui slots
void on_restoreButton_clicked();
void on_restoreModsButton_clicked();
void on_saveModsButton_clicked();
- void on_actionCopy_Log_to_Clipboard_triggered();
+ void on_actionLogCopy_triggered();
void on_categoriesAndBtn_toggled(bool checked);
void on_categoriesOrBtn_toggled(bool checked);
void on_managedArchiveLabel_linkHovered(const QString &link);
diff --git a/src/mainwindow.ui b/src/mainwindow.ui
index c694abd4..fc2bcdd3 100644
--- a/src/mainwindow.ui
+++ b/src/mainwindow.ui
@@ -1428,7 +1428,7 @@ p, li { white-space: pre-wrap; }
-
- Qt::ActionsContextMenu
+ Qt::CustomContextMenu
false
@@ -1645,20 +1645,6 @@ p, li { white-space: pre-wrap; }
Endorse Mod Organizer
-
-
- Copy &Log
-
-
- Copy &Log
-
-
- Copy log to clipboard
-
-
- Copy log to clipboard
-
-
@@ -1771,6 +1757,20 @@ p, li { white-space: pre-wrap; }
Log
+
+
+ Copy &Log
+
+
+ Copy &Log
+
+
+ Copy log to clipboard
+
+
+ Copy log to clipboard
+
+
diff --git a/src/organizercore.cpp b/src/organizercore.cpp
index d3cd54ee..25fbc7cd 100644
--- a/src/organizercore.cpp
+++ b/src/organizercore.cpp
@@ -726,7 +726,9 @@ void OrganizerCore::prepareVFS()
m_USVFS.updateMapping(fileMapping(m_CurrentProfile->name(), QString()));
}
-void OrganizerCore::updateVFSParams(int logLevel, int crashDumpsType, QString executableBlacklist) {
+void OrganizerCore::updateVFSParams(
+ log::Levels logLevel, int crashDumpsType, QString executableBlacklist)
+{
setGlobalCrashDumpsType(crashDumpsType);
m_USVFS.updateParams(logLevel, crashDumpsType, executableBlacklist);
}
diff --git a/src/organizercore.h b/src/organizercore.h
index 99b1c5f2..ef1a4133 100644
--- a/src/organizercore.h
+++ b/src/organizercore.h
@@ -21,6 +21,7 @@
#include
#include
#include "executableinfo.h"
+#include
class ModListSortProxy;
class PluginListSortProxy;
@@ -191,7 +192,9 @@ public:
void prepareVFS();
- void updateVFSParams(int logLevel, int crashDumpsType, QString executableBlacklist);
+ void updateVFSParams(
+ MOBase::log::Levels logLevel, int crashDumpsType,
+ QString executableBlacklist);
bool cycleDiagnostics();
diff --git a/src/settings.cpp b/src/settings.cpp
index 5cb2524f..e622d632 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -415,9 +415,14 @@ bool Settings::offlineMode() const
return m_Settings.value("Settings/offline_mode", false).toBool();
}
-int Settings::logLevel() const
+log::Levels Settings::logLevel() const
{
- return m_Settings.value("Settings/log_level", static_cast(LogLevel::Info)).toInt();
+ return static_cast(m_Settings.value("Settings/log_level").toInt());
+}
+
+void Settings::setLogLevel(log::Levels level)
+{
+ m_Settings.setValue("Settings/log_level", static_cast(level));
}
int Settings::crashDumpsType() const
@@ -1000,7 +1005,7 @@ Settings::DiagnosticsTab::DiagnosticsTab(Settings *m_parent, SettingsDialog &m_d
, m_dumpsMaxEdit(m_dialog.findChild("dumpsMaxEdit"))
, m_diagnosticsExplainedLabel(m_dialog.findChild("diagnosticsExplainedLabel"))
{
- m_logLevelBox->setCurrentIndex(m_parent->logLevel());
+ setLevelsBox();
m_dumpsTypeBox->setCurrentIndex(m_parent->crashDumpsType());
m_dumpsMaxEdit->setValue(m_parent->crashDumpsMax());
QString logsPath = qApp->property("dataPath").toString()
@@ -1016,11 +1021,28 @@ Settings::DiagnosticsTab::DiagnosticsTab(Settings *m_parent, SettingsDialog &m_d
void Settings::DiagnosticsTab::update()
{
- m_Settings.setValue("Settings/log_level", m_logLevelBox->currentIndex());
+ m_Settings.setValue("Settings/log_level", m_logLevelBox->currentData().toInt());
m_Settings.setValue("Settings/crash_dumps_type", m_dumpsTypeBox->currentIndex());
m_Settings.setValue("Settings/crash_dumps_max", m_dumpsMaxEdit->value());
}
+void Settings::DiagnosticsTab::setLevelsBox()
+{
+ m_logLevelBox->clear();
+
+ m_logLevelBox->addItem(tr("Debug"), log::Debug);
+ m_logLevelBox->addItem(tr("Info (recommended)"), log::Info);
+ m_logLevelBox->addItem(tr("Warning"), log::Warning);
+ m_logLevelBox->addItem(tr("Error"), log::Error);
+
+ for (int i=0; icount(); ++i) {
+ if (m_logLevelBox->itemData(i) == m_parent->logLevel()) {
+ m_logLevelBox->setCurrentIndex(i);
+ break;
+ }
+ }
+}
+
Settings::NexusTab::NexusTab(Settings *parent, SettingsDialog &dialog)
: Settings::SettingsTab(parent, dialog)
, m_offlineBox(dialog.findChild("offlineBox"))
diff --git a/src/settings.h b/src/settings.h
index bccd1e81..c66eb94c 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -21,6 +21,7 @@ along with Mod Organizer. If not, see .
#define SETTINGS_H
#include "loadmechanism.h"
+#include
#include
#include
@@ -232,7 +233,12 @@ public:
/**
* @return the configured log level
*/
- int logLevel() const;
+ MOBase::log::Levels logLevel() const;
+
+ /**
+ * sets the log level setting
+ */
+ void setLogLevel(MOBase::log::Levels level);
/**
* @return the configured crash dumps type
@@ -481,6 +487,8 @@ private:
QComboBox *m_dumpsTypeBox;
QSpinBox *m_dumpsMaxEdit;
QLabel *m_diagnosticsExplainedLabel;
+
+ void setLevelsBox();
};
/** Display/store the configuration in the 'nexus' tab of the settings dialogue */
diff --git a/src/settingsdialog.ui b/src/settingsdialog.ui
index fccc8be0..1e94bcde 100644
--- a/src/settingsdialog.ui
+++ b/src/settingsdialog.ui
@@ -1426,26 +1426,6 @@ programs you are intentionally running.
"Debug" produces very useful information for finding problems. There is usually no noteworthy performance impact but the file may become rather large. If this is a problem you may prefer the "Info" level for regular use. On the "Error" level the log file usually remains empty.
-
-
-
- Debug
-
-
- -
-
- Info (recommended)
-
-
- -
-
- Warning
-
-
- -
-
- Error
-
-
diff --git a/src/usvfsconnector.cpp b/src/usvfsconnector.cpp
index b752667d..197955b8 100644
--- a/src/usvfsconnector.cpp
+++ b/src/usvfsconnector.cpp
@@ -32,7 +32,7 @@ along with Mod Organizer. If not, see .
#include
static const char SHMID[] = "mod_organizer_instance";
-
+using namespace MOBase;
std::string to_hex(void *bufferIn, size_t bufferSize)
{
@@ -90,15 +90,16 @@ void LogWorker::exit()
m_QuitRequested = true;
}
-LogLevel logLevel(int level)
+LogLevel toUsvfsLogLevel(log::Levels level)
{
- switch (static_cast(level)) {
- case LogLevel::Info:
+ switch (level) {
+ case log::Info:
return LogLevel::Info;
- case LogLevel::Warning:
+ case log::Warning:
return LogLevel::Warning;
- case LogLevel::Error:
+ case log::Error:
return LogLevel::Error;
+ case log::Debug: // fall-through
default:
return LogLevel::Debug;
}
@@ -121,7 +122,7 @@ CrashDumpsType crashDumpsType(int type)
UsvfsConnector::UsvfsConnector()
{
USVFSParameters params;
- LogLevel level = logLevel(Settings::instance().logLevel());
+ LogLevel level = toUsvfsLogLevel(Settings::instance().logLevel());
CrashDumpsType dumpType = crashDumpsType(Settings::instance().crashDumpsType());
std::string dumpPath = MOShared::ToString(OrganizerCore::crashDumpsPath(), true);
@@ -205,9 +206,10 @@ void UsvfsConnector::updateMapping(const MappingType &mapping)
*/
}
-void UsvfsConnector::updateParams(int logLevel, int crashDumpsType, QString executableBlacklist)
+void UsvfsConnector::updateParams(
+ MOBase::log::Levels logLevel, int crashDumpsType, QString executableBlacklist)
{
- USVFSUpdateParams(::logLevel(logLevel), ::crashDumpsType(crashDumpsType));
+ USVFSUpdateParams(toUsvfsLogLevel(logLevel), ::crashDumpsType(crashDumpsType));
ClearExecutableBlacklist();
for (auto exec : executableBlacklist.split(";")) {
std::wstring buf = exec.toStdWString();
diff --git a/src/usvfsconnector.h b/src/usvfsconnector.h
index 8a88bde5..b0bd320c 100644
--- a/src/usvfsconnector.h
+++ b/src/usvfsconnector.h
@@ -29,6 +29,7 @@ along with Mod Organizer. If not, see .
#include
#include
#include
+#include
#include "executableinfo.h"
@@ -84,7 +85,11 @@ public:
~UsvfsConnector();
void updateMapping(const MappingType &mapping);
- void updateParams(int logLevel, int crashDumpsType, QString executableBlacklist);
+
+ void updateParams(
+ MOBase::log::Levels logLevel, int crashDumpsType,
+ QString executableBlacklist);
+
void updateForcedLibraries(const QList &forcedLibraries);
private:
--
cgit v1.3.1
From 3bf7717c0a8507c9befce6b74c84c4dbdcac99de Mon Sep 17 00:00:00 2001
From: isanae <14251494+isanae@users.noreply.github.com>
Date: Wed, 17 Jul 2019 11:41:09 -0400
Subject: moved Settings out of OrganizerCore so it can be created by itself to
access settings early set log level on startup replaced more qDebug()
---
src/main.cpp | 100 +++++++++++++++++++++++++-------------------------
src/organizercore.cpp | 6 +--
src/organizercore.h | 4 +-
src/shared/util.cpp | 4 +-
4 files changed, 57 insertions(+), 57 deletions(-)
(limited to 'src/organizercore.cpp')
diff --git a/src/main.cpp b/src/main.cpp
index f55c32f2..aa842ead 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -425,8 +425,6 @@ void setupPath()
{
static const int BUFSIZE = 4096;
- log::debug("MO at {}", QCoreApplication::applicationDirPath());
-
QCoreApplication::setLibraryPaths(QStringList(QCoreApplication::applicationDirPath() + "/dlls") + QCoreApplication::libraryPaths());
boost::scoped_array oldPath(new TCHAR[BUFSIZE]);
@@ -446,8 +444,6 @@ void setupPath()
void preloadDll(const QString& filename)
{
- log::debug("preloading {}", filename);
-
if (GetModuleHandleW(filename.toStdWString().c_str())) {
// already loaded, this can happen when "restarting" MO by switching
// instances, for example
@@ -513,62 +509,68 @@ void dumpEnvironment()
int runApplication(MOApplication &application, SingleInstance &instance,
const QString &splashPath)
{
-
log::info(
- "Starting Mod Organizer version {} revision {}",
- getVersionDisplayString(), GITID);
+ "Starting Mod Organizer version {} revision {} in {}",
+ getVersionDisplayString(), GITID, QCoreApplication::applicationDirPath());
-#if !defined(QT_NO_SSL)
preloadSsl();
- log::info("ssl support: {}", QSslSocket::supportsSsl());
-#else
- log::info("non-ssl build");
-#endif
-
- dumpEnvironment();
+ if (!QSslSocket::supportsSsl()) {
+ log::warn("no ssl support");
+ }
QString dataPath = application.property("dataPath").toString();
- qDebug("data path: %s", qUtf8Printable(dataPath));
+ log::info("data path: {}", dataPath);
if (!bootstrap()) {
reportError("failed to set up data paths");
return 1;
}
- QWindowsWindowFunctions::setWindowActivationBehavior(QWindowsWindowFunctions::AlwaysActivateWindow);
+ QWindowsWindowFunctions::setWindowActivationBehavior(
+ QWindowsWindowFunctions::AlwaysActivateWindow);
QStringList arguments = application.arguments();
try {
- qDebug("Working directory: %s", qUtf8Printable(QDir::toNativeSeparators(QDir::currentPath())));
+ log::info("working directory: {}", QDir::currentPath());
- QSettings settings(dataPath + "/"
- + QString::fromStdWString(AppConfig::iniFileName()),
- QSettings::IniFormat);
+ QSettings initSettings(
+ dataPath + "/" + QString::fromStdWString(AppConfig::iniFileName()),
+ QSettings::IniFormat);
- // global crashDumpType sits in OrganizerCore to make a bit less ugly to update it when the settings are changed during runtime
- OrganizerCore::setGlobalCrashDumpsType(settings.value("Settings/crash_dumps_type", static_cast(CrashDumpsType::Mini)).toInt());
+ Settings settings(initSettings);
+ log::getDefault().setLevel(settings.logLevel());
- qDebug("Loaded settings:");
- settings.beginGroup("Settings");
- for (auto k : settings.allKeys())
- if (!k.contains("username") && !k.contains("password") && !k.contains("nexus_api_key"))
- qDebug(" %s=%s", k.toUtf8().data(), settings.value(k).toString().toUtf8().data());
- settings.endGroup();
+ dumpEnvironment();
+ // global crashDumpType sits in OrganizerCore to make a bit less ugly to
+ // update it when the settings are changed during runtime
+ OrganizerCore::setGlobalCrashDumpsType(settings.crashDumpsType());
- qDebug("initializing core");
+ log::debug("Loaded settings:");
+
+ initSettings.beginGroup("Settings");
+ for (auto k : initSettings.allKeys()) {
+ if (!k.contains("username") && !k.contains("password") && !k.contains("nexus_api_key")) {
+ log::debug(" {}={}", k, initSettings.value(k).toString());
+ }
+ }
+ initSettings.endGroup();
+
+
+ log::debug("initializing core");
OrganizerCore organizer(settings);
if (!organizer.bootstrap()) {
reportError("failed to set up data paths");
return 1;
}
- qDebug("initialize plugins");
+
+ log::debug("initializing plugins");
PluginContainer pluginContainer(&organizer);
pluginContainer.loadPlugins();
MOBase::IPluginGame *game = determineCurrentGame(
- application.applicationDirPath(), settings, pluginContainer);
+ application.applicationDirPath(), initSettings, pluginContainer);
if (game == nullptr) {
InstanceManager &instance = InstanceManager::instance();
QString instanceName = instance.currentInstance();
@@ -586,14 +588,14 @@ int runApplication(MOApplication &application, SingleInstance &instance,
if (!image.isNull()) {
image.save(dataPath + "/splash.png");
} else {
- qDebug("no plugin splash");
+ log::debug("no plugin splash");
}
}
organizer.setManagedGame(game);
organizer.createDefaultProfile();
- if (!settings.contains("game_edition")) {
+ if (!initSettings.contains("game_edition")) {
QStringList editions = game->gameVariants();
if (editions.size() > 1) {
SelectionDialog selection(
@@ -609,18 +611,17 @@ int runApplication(MOApplication &application, SingleInstance &instance,
if (selection.exec() == QDialog::Rejected) {
return 1;
} else {
- settings.setValue("game_edition", selection.getChoiceString());
+ initSettings.setValue("game_edition", selection.getChoiceString());
}
}
}
- game->setGameVariant(settings.value("game_edition").toString());
+ game->setGameVariant(initSettings.value("game_edition").toString());
- qDebug("managing game at %s", qUtf8Printable(QDir::toNativeSeparators(
- game->gameDirectory().absolutePath())));
+ log::info("managing game at {}", game->gameDirectory().absolutePath());
- organizer.updateExecutablesList(settings);
+ organizer.updateExecutablesList(initSettings);
- QString selectedProfileName = determineProfile(arguments, settings);
+ QString selectedProfileName = determineProfile(arguments, initSettings);
organizer.setCurrentProfile(selectedProfileName);
// if we have a command line parameter, it is either a nxm link or
@@ -640,13 +641,12 @@ int runApplication(MOApplication &application, SingleInstance &instance,
}
}
else if (OrganizerCore::isNxmLink(arguments.at(1))) {
- qDebug("starting download from command line: %s",
- qUtf8Printable(arguments.at(1)));
+ log::debug("starting download from command line: {}", arguments.at(1));
organizer.externalMessage(arguments.at(1));
}
else {
QString exeName = arguments.at(1);
- qDebug("starting %s from command line", qUtf8Printable(exeName));
+ log::debug("starting {} from command line", exeName);
arguments.removeFirst(); // remove application name (ModOrganizer.exe)
arguments.removeFirst(); // remove binary name
// pass the remaining parameters to the binary
@@ -665,8 +665,8 @@ int runApplication(MOApplication &application, SingleInstance &instance,
QPixmap pixmap(splashPath);
QSplashScreen splash(pixmap);
- if (settings.contains("window_monitor")) {
- const int monitor = settings.value("window_monitor").toInt();
+ if (initSettings.contains("window_monitor")) {
+ const int monitor = initSettings.value("window_monitor").toInt();
if (monitor != -1) {
QDesktopWidget* desktop = QApplication::desktop();
@@ -683,21 +683,21 @@ int runApplication(MOApplication &application, SingleInstance &instance,
NexusInterface::instance(&pluginContainer)->getAccessManager()->apiCheck(apiKey);
}
- qDebug("initializing tutorials");
+ log::debug("initializing tutorials");
TutorialManager::init(
qApp->applicationDirPath() + "/"
+ QString::fromStdWString(AppConfig::tutorialsPath()) + "/",
&organizer);
- if (!application.setStyleFile(settings.value("Settings/style", "").toString())) {
+ if (!application.setStyleFile(initSettings.value("Settings/style", "").toString())) {
// disable invalid stylesheet
- settings.setValue("Settings/style", "");
+ initSettings.setValue("Settings/style", "");
}
int res = 1;
{ // scope to control lifetime of mainwindow
// set up main window and its data structures
- MainWindow mainWindow(settings, organizer, pluginContainer);
+ MainWindow mainWindow(initSettings, organizer, pluginContainer);
NexusInterface::instance(&pluginContainer)
->getAccessManager()->setTopLevelWidget(&mainWindow);
@@ -714,7 +714,7 @@ int runApplication(MOApplication &application, SingleInstance &instance,
mainWindow.readSettings();
- qDebug("displaying main window");
+ log::debug("displaying main window");
mainWindow.show();
mainWindow.activateWindow();
@@ -857,7 +857,7 @@ int main(int argc, char *argv[])
if (moshortcut ||
arguments.size() > 1 && OrganizerCore::isNxmLink(arguments.at(1)))
{
- qDebug("not primary instance, sending shortcut/download message");
+ log::debug("not primary instance, sending shortcut/download message");
instance.sendMessage(arguments.at(1));
return 0;
} else if (arguments.size() == 1) {
diff --git a/src/organizercore.cpp b/src/organizercore.cpp
index 25fbc7cd..400f5391 100644
--- a/src/organizercore.cpp
+++ b/src/organizercore.cpp
@@ -268,12 +268,12 @@ bool checkService()
}
-OrganizerCore::OrganizerCore(const QSettings &initSettings)
+OrganizerCore::OrganizerCore(Settings &settings)
: m_UserInterface(nullptr)
, m_PluginContainer(nullptr)
, m_GameName()
, m_CurrentProfile(nullptr)
- , m_Settings(initSettings)
+ , m_Settings(settings)
, m_Updater(NexusInterface::instance(m_PluginContainer))
, m_AboutToRun()
, m_FinishedRun()
@@ -294,7 +294,7 @@ OrganizerCore::OrganizerCore(const QSettings &initSettings)
NexusInterface::instance(m_PluginContainer)->setCacheDirectory(m_Settings.getCacheDirectory());
- MOBase::QuestionBoxMemory::init(initSettings.fileName());
+ MOBase::QuestionBoxMemory::init(m_Settings.directInterface().fileName());
m_InstallationManager.setModsDirectory(m_Settings.getModDirectory());
m_InstallationManager.setDownloadDirectory(m_Settings.getDownloadDirectory());
diff --git a/src/organizercore.h b/src/organizercore.h
index ef1a4133..c368d101 100644
--- a/src/organizercore.h
+++ b/src/organizercore.h
@@ -97,7 +97,7 @@ public:
static bool isNxmLink(const QString &link) { return link.startsWith("nxm://", Qt::CaseInsensitive); }
- OrganizerCore(const QSettings &initSettings);
+ OrganizerCore(Settings &settings);
~OrganizerCore();
@@ -336,7 +336,7 @@ private:
Profile *m_CurrentProfile;
- Settings m_Settings;
+ Settings& m_Settings;
SelfUpdater m_Updater;
diff --git a/src/shared/util.cpp b/src/shared/util.cpp
index 29e52f40..8d8c2000 100644
--- a/src/shared/util.cpp
+++ b/src/shared/util.cpp
@@ -1492,11 +1492,11 @@ QString WindowsInfo::toString() const
const QString real = m_real.toString();
// version
- sl.push_back("version: " + reported);
+ sl.push_back("version " + reported);
// real version if different
if (compatibilityMode()) {
- sl.push_back("real version: " + real);
+ sl.push_back("real version " + real);
}
// build.UBR, such as 17763.557
--
cgit v1.3.1
From aae6d6a5aa8d6b101fcc38388222a8a6e7ee2ec6 Mon Sep 17 00:00:00 2001
From: isanae <14251494+isanae@users.noreply.github.com>
Date: Fri, 19 Jul 2019 01:09:19 -0400
Subject: replaced qWarning()
---
src/bbcode.cpp | 9 ++++----
src/categories.cpp | 3 ++-
src/directoryrefresher.cpp | 4 ++--
src/downloadmanager.cpp | 21 +++++++++---------
src/editexecutablesdialog.cpp | 19 ++++++++--------
src/executableslist.cpp | 6 +++---
src/filerenamer.cpp | 7 ++++--
src/icondelegate.cpp | 4 +++-
src/installationmanager.cpp | 2 +-
src/instancemanager.cpp | 14 +++++++-----
src/mainwindow.cpp | 50 +++++++++++++++++++++++--------------------
src/moapplication.cpp | 5 +++--
src/modflagicondelegate.cpp | 4 +++-
src/modinfo.cpp | 2 +-
src/modinfodialogesps.cpp | 7 +++---
src/modlist.cpp | 7 +++---
src/modlistsortproxy.cpp | 6 ++++--
src/nexusinterface.cpp | 27 +++++++++++++----------
src/nxmaccessmanager.cpp | 2 +-
src/organizercore.cpp | 46 +++++++++++++++++++--------------------
src/plugincontainer.cpp | 11 +++++-----
src/pluginlist.cpp | 4 ++--
src/problemsdialog.cpp | 2 +-
src/profile.cpp | 21 ++++++++++--------
src/profilesdialog.cpp | 4 ++--
src/settings.cpp | 5 +++--
26 files changed, 161 insertions(+), 131 deletions(-)
(limited to 'src/organizercore.cpp')
diff --git a/src/bbcode.cpp b/src/bbcode.cpp
index 323dd128..d9b7debd 100644
--- a/src/bbcode.cpp
+++ b/src/bbcode.cpp
@@ -18,13 +18,13 @@ along with Mod Organizer. If not, see .
*/
#include "bbcode.h"
-
+#include
#include
#include