src: Removed unused Log component and QtSplashScreen

This commit is contained in:
Eberhard Graether
2017-09-21 01:59:36 +02:00
parent 1e7d934cb8
commit 83c24c5cd0
17 changed files with 0 additions and 818 deletions
-8
View File
@@ -6,8 +6,6 @@
#include "utility/messaging/type/MessageLoadProject.h"
#include "utility/messaging/type/MessageWindowFocus.h"
#include "utility/logging/LogManager.h"
#include "component/controller/LogController.h"
#include "utility/utilityApp.h"
QtApplication::QtApplication(int& argc, char** argv)
@@ -18,12 +16,6 @@ QtApplication::QtApplication(int& argc, char** argv)
int QtApplication::exec()
{
LogController* log = dynamic_cast<LogController*>(LogManager::getInstance()->getLoggerByType("WindowLogger"));
if (log != nullptr)
{
log->setEnabled(true);
}
return QApplication::exec();
}
-309
View File
@@ -1,309 +0,0 @@
#include "qt/view/QtLogView.h"
#include <QBoxLayout>
#include <QFrame>
#include <QLabel>
#include <QCheckBox>
#include <QPushButton>
#include <QStandardItemModel>
#include "Application.h"
#include "settings/ApplicationSettings.h"
#include "settings/ColorScheme.h"
#include "qt/view/QtViewWidgetWrapper.h"
#include "utility/messaging/type/MessageClearLogView.h"
#include "utility/messaging/type/MessageRefresh.h"
#include "utility/messaging/type/MessageLogFilterChanged.h"
#include "utility/ResourcePaths.h"
#include "qt/utility/utilityQt.h"
#include "utility/logging/LogManager.h"
#include "qt/element/QtTable.h"
QtLogView::QtLogView(ViewLayout* viewLayout)
: LogView(viewLayout)
, m_addLogFunctor(std::bind(&QtLogView::doAddLog, this, std::placeholders::_1, std::placeholders::_2))
, m_addLogsFunctor(std::bind(&QtLogView::doAddLogs, this, std::placeholders::_1 ))
, m_clearFunctor(std::bind(&QtLogView::doClear, this))
, m_refreshFunctor(std::bind(&QtLogView::doRefreshView, this))
{
}
QtLogView::~QtLogView()
{
}
void QtLogView::createWidgetWrapper()
{
setWidgetWrapper(std::make_shared<QtViewWidgetWrapper>(new QFrame()));
}
void QtLogView::initView()
{
QWidget* widget = QtViewWidgetWrapper::getWidgetOfView(this);
QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom);
layout->setContentsMargins(0, 10, 0, 5);
layout->setSpacing(0);
widget->setLayout(layout);
QHBoxLayout* headerLayout = new QHBoxLayout();
headerLayout->addSpacing(10);
ApplicationSettings* settings = ApplicationSettings::getInstance().get();
m_viewEnabled = new QCheckBox("Logging enabled (file, console logging)");
m_viewEnabled->setChecked(settings->getLoggingEnabled());
connect(m_viewEnabled, &QCheckBox::stateChanged,
[=](int){
setLoggingEnabled(m_viewEnabled->isChecked());
}
);
headerLayout->addWidget(m_viewEnabled);
headerLayout->addSpacing(25);
m_showAstLogging = new QCheckBox("AST Logging");
m_showAstLogging->setEnabled(m_viewEnabled->isChecked());
m_showAstLogging->setChecked(settings->getVerboseIndexerLoggingEnabled());
connect(m_showAstLogging, &QCheckBox::stateChanged,
[=](int){
setAstLoggingEnabled(m_showAstLogging->isChecked());
}
);
headerLayout->addWidget(m_showAstLogging);
headerLayout->addStretch();
layout->addLayout(headerLayout);
m_table = new QtTable(this);
m_model = new QStandardItemModel(this);
m_table->setModel(m_model);
m_model->setColumnCount(3);
m_table->setColumnWidth(LOGVIEW_COLUMN::TYPE, 100);
m_table->setColumnWidth(LOGVIEW_COLUMN::TIMESTAMP, 150);
m_table->setColumnWidth(LOGVIEW_COLUMN::TYPE, 100);
QStringList headers;
headers << "Type" << "Timestamp" << "Message";
m_model->setHorizontalHeaderLabels(headers);
layout->addWidget(m_table);
QHBoxLayout* filters = new QHBoxLayout();
filters->addSpacing(15);
m_logLevel = settings->getLogFilter();
m_showErrors = createFilterCheckbox("error", filters, m_logLevel & Logger::LOG_ERRORS);
m_showWarnings = createFilterCheckbox("warnings", filters, m_logLevel & Logger::LOG_WARNINGS);
m_showInfo = createFilterCheckbox("info", filters, m_logLevel & Logger::LOG_INFOS);
filters->addStretch();
QPushButton* clearButton = new QPushButton("clear log");
connect(clearButton, &QPushButton::clicked,
[=]()
{
//doClear();
MessageClearLogView().dispatch();
});
filters->addWidget(clearButton);
filters->addSpacing(30);
updateMask();
layout->addLayout(filters);
doRefreshView();
}
QCheckBox* QtLogView::createFilterCheckbox(const QString& name, QBoxLayout* layout, bool checked)
{
QCheckBox* checkbox = new QCheckBox(name);
checkbox->setChecked(checked);
connect(checkbox, &QCheckBox::stateChanged,
[=](int)
{
m_table->selectionModel()->clearSelection();
updateMask();
updateTable();
}
);
layout->addWidget(checkbox);
layout->addSpacing(25);
return checkbox;
}
void QtLogView::setLoggingEnabled(bool enabled)
{
m_showAstLogging->setEnabled(enabled);
LogManager::getInstance()->setLoggingEnabled(enabled);
ApplicationSettings::getInstance()->setLoggingEnabled(enabled);
ApplicationSettings::getInstance()->save();
Application::getInstance()->loadSettings();
MessageRefresh msg;
msg.uiOnly = true;
msg.dispatchImmediately();
}
void QtLogView::setAstLoggingEnabled(bool enabled)
{
ApplicationSettings::getInstance()->setVerboseIndexerLoggingEnabled(enabled);
ApplicationSettings::getInstance()->save();
Application::getInstance()->loadSettings();
MessageRefresh msg;
msg.uiOnly = true;
msg.dispatchImmediately();
}
void QtLogView::refreshView()
{
m_refreshFunctor();
}
void QtLogView::clear()
{
m_clearFunctor();
}
void QtLogView::addLog(Logger::LogLevel type, const LogMessage& message)
{
m_addLogFunctor(type, message);
}
void QtLogView::addLogs(const std::vector<Log>& logs)
{
m_addLogsFunctor(logs);
}
void QtLogView::doClear()
{
if (!m_model->index(0, 0).data(Qt::DisplayRole).toString().isEmpty())
{
m_model->removeRows(0, m_model->rowCount());
}
m_logs.clear();
}
void QtLogView::doRefreshView()
{
setStyleSheet();
}
void QtLogView::setStyleSheet() const
{
QWidget* widget = QtViewWidgetWrapper::getWidgetOfView(this);
utility::setWidgetBackgroundColor(widget, ColorScheme::getInstance()->getColor("error/background"));
QPalette palette(m_showErrors->palette());
palette.setColor(QPalette::WindowText, QColor(ColorScheme::getInstance()->getColor("error/text/normal").c_str()));
//palette.setColor(QPalette::Text, QColor(ColorScheme::getInstance()->getColor("error/text/normal").c_str()));
//palette.setColor(QPalette::ButtonText, QColor(ColorScheme::getInstance()->getColor("error/text/normal").c_str()));
//m_showErrors->setAutoFillBackground(true);
//m_showErrors->setPalette(palette);
//m_showFatals->setPalette(palette);
//m_showNonIndexedErrors->setPalette(palette);
//m_showNonIndexedFatals->setPalette(palette);
widget->setStyleSheet(
utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("error_view/error_view.css"))).c_str()
);
m_table->updateRows();
}
const char* QtLogView::getLogType(Logger::LogLevel type) const
{
switch (type)
{
case Logger::LOG_INFOS:
return "INFO";
case Logger::LOG_WARNINGS:
return "WARNING";
case Logger::LOG_ERRORS:
return "ERROR";
case Logger::LOG_ALL:
return "UNKNOWN";
}
}
bool QtLogView::isCheckedType(const Logger::LogLevel type) const
{
return m_logLevel & type;
}
void QtLogView::updateTable()
{
if (!m_model->index(0, 0).data(Qt::DisplayRole).toString().isEmpty())
{
m_model->removeRows(0, m_model->rowCount());
}
for ( Log& log : m_logs )
{
if (log.type & m_logLevel)
{
addLogToTable(log);
}
}
}
void QtLogView::updateMask()
{
m_logLevel =
(m_showInfo->isChecked() ? Logger::LOG_INFOS : 0) +
(m_showWarnings->isChecked() ? Logger::LOG_WARNINGS : 0) +
(m_showErrors->isChecked() ? Logger::LOG_ERRORS : 0);
MessageLogFilterChanged(m_logLevel).dispatch();
}
void QtLogView::addLogToTable(Log log)
{
const int rowNumber = m_table->getFilledRowCount();
if (rowNumber < m_model->rowCount())
{
m_model->insertRow(rowNumber);
}
m_model->setItem(rowNumber, LOGVIEW_COLUMN::TYPE, new QStandardItem(getLogType(log.type)));
m_model->setItem(rowNumber, LOGVIEW_COLUMN::TIMESTAMP, new QStandardItem(log.timestamp.c_str()));
m_model->setItem(rowNumber, LOGVIEW_COLUMN::MESSAGE, new QStandardItem(log.message.c_str()));
m_table->updateRows();
}
void QtLogView::doAddLog(Logger::LogLevel type, const LogMessage& message)
{
if (type & m_logLevel)
{
Log log(
type,
(message.getFileName().empty() ? "" : message.getFileName() + ": ") + message.message,
message.getTimeString("%H:%M:%S"));
m_logs.push_back(log);
addLogToTable(log);
}
}
void QtLogView::doAddLogs(const std::vector<Log>& logs)
{
doClear();
for(const Log& log : logs)
{
if( log.type & m_logLevel )
{
addLogToTable(log);
}
}
}
-81
View File
@@ -1,81 +0,0 @@
#ifndef QT_LOG_VIEW_H
#define QT_LOG_VIEW_H
#include <QWidget>
#include "component/view/LogView.h"
#include "qt/utility/QtThreadedFunctor.h"
#include "utility/logging/Logger.h"
class QBoxLayout;
class QCheckBox;
class QPalette;
class QStandardItemModel;
class QtTable;
class QtLogView
: public QWidget
, public LogView
{
Q_OBJECT
public:
QtLogView(ViewLayout* viewLayout);
virtual ~QtLogView();
// View implementation
virtual void createWidgetWrapper();
virtual void initView();
virtual void refreshView();
// Log View Implementation
virtual void clear();
virtual void addLog(Logger::LogLevel type, const LogMessage& message);
virtual void addLogs(const std::vector<Log>& logs);
private:
enum LOGVIEW_COLUMN
{
TYPE = 0,
TIMESTAMP = 1,
MESSAGE = 2,
};
void doClear();
void doRefreshView();
void doAddLog(Logger::LogLevel type, const LogMessage& message);
void doAddLogs(const std::vector<Log>& logs);
std::vector<Log> m_logs;
const char* getLogType(Logger::LogLevel type) const;
void addLogToTable(Log log);
void setLogFilter();
bool isCheckedType(const Logger::LogLevel type) const;
QCheckBox* createFilterCheckbox(const QString& name, QBoxLayout* layout, bool checked = false);
void setStyleSheet() const;
void setLoggingEnabled(bool enabled);
void setAstLoggingEnabled(bool enabled);
void updateMask();
void updateTable();
Logger::LogLevelMask m_logLevel;
QtTable* m_table;
QStandardItemModel* m_model;
QCheckBox* m_viewEnabled;
QCheckBox* m_showAstLogging;
QCheckBox* m_showErrors;
QCheckBox* m_showWarnings;
QCheckBox* m_showInfo;
QtThreadedFunctor<Logger::LogLevel, const LogMessage&> m_addLogFunctor;
QtThreadedFunctor<const std::vector<Log>&> m_addLogsFunctor;
QtThreadedFunctor<void> m_clearFunctor;
QtThreadedFunctor<void> m_refreshFunctor;
};
#endif // QT_LOG_VIEW_H
-6
View File
@@ -8,7 +8,6 @@
#include "qt/view/QtErrorView.h"
#include "qt/view/QtGraphView.h"
#include "qt/view/QtGraphViewStyleImpl.h"
#include "qt/view/QtLogView.h"
#include "qt/view/QtMainView.h"
#include "qt/view/QtRefreshView.h"
#include "qt/view/QtScreenSearchView.h"
@@ -64,11 +63,6 @@ std::shared_ptr<ErrorView> QtViewFactory::createErrorView(ViewLayout* viewLayout
return View::createInitAndAddToLayout<QtErrorView>(viewLayout);
}
std::shared_ptr<LogView> QtViewFactory::createLogView(ViewLayout* viewLayout) const
{
return View::createInitAndAddToLayout<QtLogView>(viewLayout);
}
std::shared_ptr<StatusView> QtViewFactory::createStatusView(ViewLayout* viewLayout) const
{
return View::createInitAndAddToLayout<QtStatusView>(viewLayout);
-1
View File
@@ -18,7 +18,6 @@ public:
virtual std::shared_ptr<CodeView> createCodeView(ViewLayout* viewLayout) const;
virtual std::shared_ptr<ErrorView> createErrorView(ViewLayout* viewLayout) const;
virtual std::shared_ptr<GraphView> createGraphView(ViewLayout* viewLayout) const;
virtual std::shared_ptr<LogView> createLogView(ViewLayout* viewLayout) const;
virtual std::shared_ptr<RefreshView> createRefreshView(ViewLayout* viewLayout) const;
virtual std::shared_ptr<ScreenSearchView> createScreenSearchView(ViewLayout* viewLayout) const;
virtual std::shared_ptr<SearchView> createSearchView(ViewLayout* viewLayout) const;
-6
View File
@@ -10,7 +10,6 @@
#include <QTimer>
#include "Application.h"
#include "component/controller/LogController.h"
#include "component/view/CompositeView.h"
#include "component/view/TabbedView.h"
#include "component/view/View.h"
@@ -379,11 +378,6 @@ void QtMainWindow::contextMenuEvent(QContextMenuEvent* event)
void QtMainWindow::closeEvent(QCloseEvent* event)
{
LogController* log = dynamic_cast<LogController*>(LogManager::getInstance()->getLoggerByType("WindowLogger"));
if (log != nullptr)
{
log->setEnabled(false);
}
MessageWindowClosed().dispatchImmediately();
}
-98
View File
@@ -1,98 +0,0 @@
#include "qt/window/QtSplashScreen.h"
#include <QApplication>
#include <QThread>
#include <QTimer>
#include "qt/utility/QtDeviceScaledPixmap.h"
#include "utility/ResourcePaths.h"
namespace
{
class InitThread : public QThread
{
public:
void run(void)
{
// Mininmum time the SplashScreen gets displayed.
QThread::msleep(5000);
}
};
}
QtSplashScreen::QtSplashScreen(const QPixmap &pixmap, Qt::WindowFlags f)
: QSplashScreen(pixmap, f)
, m_state(0)
{
QtDeviceScaledPixmap foreground((ResourcePaths::getGuiPath().str() + "splash_white.png").c_str());
foreground.scaleToHeight(pixmap.size().height() * 0.8);
m_foreground = foreground.pixmap();
QtDeviceScaledPixmap background((ResourcePaths::getGuiPath().str() + "splash_blue.png").c_str());
background.scaleToHeight(pixmap.size().height() * 0.9);
m_background = background.pixmap();
}
QtSplashScreen::~QtSplashScreen()
{
}
void QtSplashScreen::exec(QApplication& app)
{
m_state = 0;
QTimer* timer = new QTimer(this);
QObject::connect(timer, &QTimer::timeout, this, &QtSplashScreen::animate);
timer->start(150);
app.processEvents();
show();
repaint();
app.processEvents();
}
void QtSplashScreen::setMessage(const QString &str)
{
m_string = str;
repaint();
}
void QtSplashScreen::setVersion(const QString &str)
{
m_version = str;
repaint();
}
void QtSplashScreen::animate()
{
m_state = (m_state + 2) % 120;
repaint();
}
void QtSplashScreen::drawContents(QPainter *painter)
{
painter->save();
painter->translate(rect().width() / 2, rect().height() / 2);
painter->rotate(m_state * 3);
painter->drawPixmap(-rect().width() * 0.9 / 2, -rect().height() * 0.9 / 2, m_background);
painter->restore();
painter->drawPixmap(rect().width() * 0.1, rect().height() * 0.1, m_foreground);
QRect r = rect();
r.setRect(r.x() + 5, r.height() - 20, r.width() - 10, 20);
painter->drawText(r, Qt::AlignRight, QString("Sourcetrail v").append(m_version));
// Draw message at given position, limited to 43 chars
// If message is too long, string is truncated
if (m_string.length() > 40)
{
m_string.truncate(39);
m_string += "...";
}
painter->drawText(r, Qt::AlignLeft, m_string);
}
-39
View File
@@ -1,39 +0,0 @@
#ifndef QTSPLASHSCREEN_H
#define QTSPLASHSCREEN_H
#include <QSplashScreen>
#include <QPainter>
#include <QWidget>
class QApplication;
class QPixmap;
class QtSplashScreen
: public QSplashScreen
{
Q_OBJECT
public:
QtSplashScreen(const QPixmap& pixmap, Qt::WindowFlags f = 0);
virtual ~QtSplashScreen();
void exec(QApplication& app);
void setMessage(const QString& str);
void setVersion(const QString& str);
public slots:
void animate();
private:
void drawContents(QPainter* painter);
int m_state;
QString m_string;
QString m_version;
QPixmap m_background;
QPixmap m_foreground;
};
#endif //QTSPLASHSCREEN_H