Skip to content

Commit

Permalink
typo + clang-format applied
Browse files Browse the repository at this point in the history
  • Loading branch information
Overflwn committed Feb 16, 2024
1 parent fa48710 commit 3d9e12c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 29 deletions.
5 changes: 2 additions & 3 deletions include/qspdlog/qspdlog.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <QWidget>
#include <QFont>
#include <QWidget>

namespace spdlog
{
Expand Down Expand Up @@ -168,8 +168,7 @@ class QSpdLog : public QWidget
* font from
* @return std::optional<QFont> the QFont object or std::nullopt
*/
std::optional<QFont> getLoggerFont(std::string_view loggerName
) const;
std::optional<QFont> getLoggerFont(std::string_view loggerName) const;

/**
* @brief Set the policy of the auto-scrolling feature.
Expand Down
5 changes: 2 additions & 3 deletions sample/sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
#include <QTimer>
#include <QToolBar>
#include <QToolButton>
#include <thread>

#include "qspdlog/qabstract_spdlog_toolbar.hpp"
#include "qspdlog/qspdlog.hpp"
#include "spdlog/spdlog.h"
#include <thread>

std::shared_ptr<spdlog::logger> createLogger(std::string name)
{
Expand Down Expand Up @@ -77,15 +77,14 @@ void configureToolbar(
&QAction::triggered,
[ logger ](bool) {
// generate 10 messages with random levels
for (int i = 0; i < 10; ++i) {
for (int i = 0; i < 10; ++i)
logger->log(
static_cast<spdlog::level::level_enum>(
rand() % spdlog::level::off
),
"Message {}",
i
);
}
});

generateMultipleAction->connect(
Expand Down
6 changes: 2 additions & 4 deletions src/qspdlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,12 @@ std::optional<QBrush> QSpdLog::getLoggerBackground(std::string_view loggerName

void QSpdLog::setLoggerFont(
std::string_view loggerName, std::optional<QFont> font
)
)
{
_sourceModel->setLoggerFont(loggerName, font);
}

std::optional<QFont> QSpdLog::getLoggerFont(
std::string_view loggerName
) const
std::optional<QFont> QSpdLog::getLoggerFont(std::string_view loggerName) const
{
return _sourceModel->getLoggerFont(loggerName);
}
20 changes: 10 additions & 10 deletions src/qspdlog_model.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <QBrush>
#include <QDateTime>
#include <QFile>
#include <QIcon>
#include <QFont>
#include <QIcon>

#include "qspdlog_model.hpp"

Expand Down Expand Up @@ -151,7 +151,7 @@ QVariant QSpdLogModel::data(const QModelIndex& index, int role) const
std::string loggerName = _items[ index.row() ].loggerName;
if (_fontMappings.contains(loggerName))
return _fontMappings.at(loggerName);

break;
}

Expand All @@ -172,6 +172,7 @@ QVariant QSpdLogModel::headerData(

return QVariant();
}

void QSpdLogModel::setLoggerForeground(
std::string_view loggerName, std::optional<QColor> color
)
Expand All @@ -198,6 +199,7 @@ void QSpdLogModel::setLoggerForeground(
);
}
}

std::optional<QColor> QSpdLogModel::getLoggerForeground(
std::string_view loggerName
) const
Expand All @@ -207,6 +209,7 @@ std::optional<QColor> QSpdLogModel::getLoggerForeground(

return std::nullopt;
}

void QSpdLogModel::setLoggerBackground(
std::string_view loggerName, std::optional<QBrush> brush
)
Expand All @@ -233,6 +236,7 @@ void QSpdLogModel::setLoggerBackground(
);
}
}

std::optional<QBrush> QSpdLogModel::getLoggerBackground(
std::string_view loggerName
) const
Expand All @@ -256,21 +260,17 @@ void QSpdLogModel::setLoggerFont(
if (font.has_value()) {
_fontMappings[ std::string(loggerName) ] = font.value();
emit dataChanged(
this->index(0),
this->index(lastRow, lastColumn),
{ Qt::FontRole }
this->index(0), this->index(lastRow, lastColumn), { Qt::FontRole }
);
} else if (_fontMappings.contains(std::string(loggerName))) {
_fontMappings.erase(std::string(loggerName));
emit dataChanged(
this->index(0),
this->index(lastRow, lastColumn),
{ Qt::FontRole }
this->index(0), this->index(lastRow, lastColumn), { Qt::FontRole }
);
}
}
std::optional<QFont> QSpdLogModel::getLoggerFont(
std::string_view loggerName

std::optional<QFont> QSpdLogModel::getLoggerFont(std::string_view loggerName
) const
{
if (_fontMappings.contains(std::string(loggerName)))
Expand Down
23 changes: 14 additions & 9 deletions src/qspdlog_style_dialog.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <QBoxLayout>
#include <QCheckBox>
#include <QDialogButtonBox>
#include <QLineEdit>
#include <QCheckBox>

#include "qspdlog_style_dialog.hpp"

Expand Down Expand Up @@ -37,7 +37,9 @@ QSpdLogStyleDialog::QSpdLogStyleDialog(QWidget* parent)
loggerNameEdit,
&QLineEdit::textChanged,
this,
[ this, backgroundColorEdit, textColorEdit, checkBoxBold ](const QString& name) {
[ this, backgroundColorEdit, textColorEdit, checkBoxBold ](
const QString& name
) {
std::string namestdstr = name.toStdString();
auto bg = _model->getLoggerBackground(namestdstr);
auto fg = _model->getLoggerForeground(namestdstr);
Expand All @@ -51,14 +53,12 @@ QSpdLogStyleDialog::QSpdLogStyleDialog(QWidget* parent)
if (fg)
textColorEdit->setText(fg.value().name());
else
backgroundColorEdit->setText("");
textColorEdit->setText("");

if (fnt)
{
if (fnt) {
bool isBold = fnt->bold();
checkBoxBold->setChecked(isBold);
}else
{
} else {
checkBoxBold->setChecked(false);
}
});
Expand All @@ -67,7 +67,11 @@ QSpdLogStyleDialog::QSpdLogStyleDialog(QWidget* parent)
buttonBox,
&QDialogButtonBox::accepted,
this,
[ this, loggerNameEdit, backgroundColorEdit, textColorEdit, checkBoxBold ]() {
[ this,
loggerNameEdit,
backgroundColorEdit,
textColorEdit,
checkBoxBold ]() {
if (!loggerNameEdit->text().isEmpty())
reject();

Expand All @@ -82,11 +86,12 @@ QSpdLogStyleDialog::QSpdLogStyleDialog(QWidget* parent)
_result.textColor = QColor(textColorEdit->text());
else
_result.textColor = std::nullopt;

_result.fontBold = checkBoxBold->isChecked();

accept();
});

connect(buttonBox, &QDialogButtonBox::rejected, this, [ this ]() {
reject();
});
Expand Down

0 comments on commit 3d9e12c

Please sign in to comment.