QtPass Developer documentation
QtPass test coverage
Current view: top level - src/plainmessagebox.cpp (source / functions) Coverage Total Hit
Test: QtPass Lines: 100.0 % 18 18
Test Date: 2026-11-14 13:19:18 Functions: 100.0 % 4 4

            Line data    Source code
       1              : // SPDX-FileCopyrightText: 2026 Anne Jan Brouwer
       2              : // SPDX-License-Identifier: GPL-3.0-or-later
       3              : /**
       4              :  * @file
       5              :  * @brief Implements the PlainMessageBox helpers; the text format is set before
       6              :  * the text so it is never laid out as rich text.
       7              :  */
       8              : #include "plainmessagebox.h"
       9              : 
      10           21 : auto PlainMessageBox::show(QWidget *parent, QMessageBox::Icon icon,
      11              :                            const QString &title, const QString &text,
      12              :                            QMessageBox::StandardButtons buttons)
      13              :     -> QMessageBox::StandardButton {
      14           21 :   QMessageBox box(parent);
      15           21 :   box.setIcon(icon);
      16           21 :   box.setWindowTitle(title);
      17              :   // Before the text: set afterwards, the text would already have been laid
      18              :   // out as rich text once.
      19           21 :   box.setTextFormat(Qt::PlainText);
      20           21 :   box.setText(text);
      21           21 :   box.setStandardButtons(buttons);
      22           42 :   return static_cast<QMessageBox::StandardButton>(box.exec());
      23           21 : }
      24              : 
      25            7 : auto PlainMessageBox::askYes(QWidget *parent, const QString &title,
      26              :                              const QString &text) -> bool {
      27            7 :   return show(parent, QMessageBox::Question, title, text,
      28            7 :               QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes;
      29              : }
      30              : 
      31            7 : void PlainMessageBox::warning(QWidget *parent, const QString &title,
      32              :                               const QString &text) {
      33            7 :   show(parent, QMessageBox::Warning, title, text);
      34            7 : }
      35              : 
      36            7 : void PlainMessageBox::critical(QWidget *parent, const QString &title,
      37              :                                const QString &text) {
      38            7 :   show(parent, QMessageBox::Critical, title, text);
      39            7 : }
        

Generated by: LCOV version 2.0-1