Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased](https://github.com/KDAB/cxx-qt/compare/v0.8.0...HEAD)

- Support for further types: `QMessageLogger`

## [0.8.0](https://github.com/KDAB/cxx-qt/compare/v0.7.2...v0.8.0) - 2025-12-18

### Added
Expand Down
2 changes: 2 additions & 0 deletions crates/cxx-qt-lib/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ fn main() {
"core/qmap/qmap_qstring_qvariant",
"core/qmargins",
"core/qmarginsf",
"core/qmessagelogger",
"core/qmodelindex",
"core/qobject",
"core/qpersistentmodelindex",
Expand Down Expand Up @@ -253,6 +254,7 @@ fn main() {
"core/qmap/qmap",
"core/qmargins",
"core/qmarginsf",
"core/qmessagelogger",
"core/qmodelindex",
"core/qpersistentmodelindex",
"core/qpoint",
Expand Down
26 changes: 26 additions & 0 deletions crates/cxx-qt-lib/include/core/qmessagelogger.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// clang-format off
// SPDX-FileCopyrightText: 2026 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
// clang-format on
// SPDX-FileContributor: Joshua Booth <joshua.n.booth@gmail.com>
//
// SPDX-License-Identifier: MIT OR Apache-2.0
#pragma once

#include "rust/cxx.h"
#include <QtCore/QMessageLogger>

namespace rust {

template<>
struct IsRelocatable<QMessageLogger> : ::std::true_type
{};

} // namespace rust

namespace rust {
namespace cxxqtlib1 {
bool
isLoggingCategoryEnabled(const QMessageLogContext& context,
QtMsgType enableForLevel);
}
}
9 changes: 9 additions & 0 deletions crates/cxx-qt-lib/include/qmessagelogger.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// clang-format off
// SPDX-FileCopyrightText: 2026 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
// clang-format on
// SPDX-FileContributor: Joshua Booth <joshua.n.booth@gmail.com>
//
// SPDX-License-Identifier: MIT OR Apache-2.0
#pragma once

#include "core/qmessagelogger.h"
4 changes: 4 additions & 0 deletions crates/cxx-qt-lib/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ pub use qmarginsf::QMarginsF;
// Reexport QMetaObjectConnection and guard from cxx-qt
pub use cxx_qt::{QMetaObjectConnection, QMetaObjectConnectionGuard};

#[macro_use]
mod qmessagelogger;
pub use qmessagelogger::QMessageLogger;

mod qmodelindex;
pub use qmodelindex::QModelIndex;

Expand Down
47 changes: 47 additions & 0 deletions crates/cxx-qt-lib/src/core/qmessagelogger.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// clang-format off
// SPDX-FileCopyrightText: 2026 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
// clang-format on
// SPDX-FileContributor: Joshua Booth <joshua.n.booth@gmail.com>
//
// SPDX-License-Identifier: MIT OR Apache-2.0
#include "cxx-qt-lib/qmessagelogger.h"

#include <cxx-qt-lib/assertion_utils.h>

#include <QtCore/QLoggingCategory>

assert_alignment_and_size(QMessageLogger, { QMessageLogContext context; });

static_assert(::std::is_trivially_destructible<QMessageLogger>::value);

namespace rust {
namespace cxxqtlib1 {
bool
isLoggingCategoryEnabled(const QMessageLogContext& context,
QtMsgType enableForLevel)
{
#if defined(QT_NO_DEBUG_OUTPUT)
if (enableForLevel == QtMsgType::QtDebugMsg) {
return false;
}
#endif
#if defined(QT_NO_INFO_OUTPUT)
if (enableForLevel == QtMsgType::QtInfoMsg) {
return false;
}
#endif
#if defined(QT_NO_WARNING_OUTPUT)
if (enableForLevel == QtMsgType::QtWarningMsg) {
return false;
}
#endif
if (context.category == nullptr || strcmp(context.category, "default") == 0) {
if (QLoggingCategory* defaultCategory =
QLoggingCategory::defaultCategory()) {
return defaultCategory->isEnabled(enableForLevel);
}
}
return QLoggingCategory(context.category).isEnabled(enableForLevel);
}
}
}
Loading
Loading