This repository has been archived by the owner on Oct 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add context menu option to show the raw message
fixes #437
- Loading branch information
Showing
7 changed files
with
112 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#pragma once | ||
|
||
#include <QFont> | ||
#include <QFontDatabase> | ||
#include <QTextBrowser> | ||
#include <QVBoxLayout> | ||
#include <QWidget> | ||
|
||
#include "json.hpp" | ||
|
||
#include "Logging.h" | ||
#include "MainWindow.h" | ||
#include "ui/FlatButton.h" | ||
|
||
namespace dialogs { | ||
|
||
class RawMessage : public QWidget | ||
{ | ||
Q_OBJECT | ||
public: | ||
RawMessage(QString msg, QWidget *parent = nullptr) | ||
: QWidget{parent} | ||
{ | ||
QFont monospaceFont = QFontDatabase::systemFont(QFontDatabase::FixedFont); | ||
|
||
auto layout = new QVBoxLayout{this}; | ||
auto viewer = new QTextBrowser{this}; | ||
viewer->setFont(monospaceFont); | ||
viewer->setText(msg); | ||
|
||
layout->setSpacing(0); | ||
layout->setMargin(0); | ||
layout->addWidget(viewer); | ||
|
||
setAutoFillBackground(true); | ||
setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint); | ||
setAttribute(Qt::WA_DeleteOnClose, true); | ||
|
||
QSize winsize; | ||
QPoint center; | ||
|
||
auto window = MainWindow::instance(); | ||
if (window) { | ||
winsize = window->frameGeometry().size(); | ||
center = window->frameGeometry().center(); | ||
|
||
move(center.x() - (width() * 0.5), center.y() - (height() * 0.5)); | ||
} else { | ||
nhlog::ui()->warn("unable to retrieve MainWindow's size"); | ||
} | ||
|
||
raise(); | ||
show(); | ||
} | ||
}; | ||
} // namespace dialogs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters