6#ifndef SWIFT_GUI_OVERLAYMESSAGES_FRAME_H
7#define SWIFT_GUI_OVERLAYMESSAGES_FRAME_H
46 template <
class WIDGET>
63 inner = this->innerFrameSize();
85 m_widthFactor = widthFactor;
86 m_heightFactor = heightFactor;
87 if (middleFactor >= 0)
89 m_middleFactor = middleFactor;
96 m_forceSmallMsgs = force;
106 m_reducedInfo = reduced;
115 bool appendOldMessages,
const QString &confirmationMessage,
116 std::function<
void()> okLambda,
118 std::chrono::milliseconds timeout = std::chrono::milliseconds(0))
129 m_overlayMessages->showOverlayMessagesWithConfirmation(messages, appendOldMessages, confirmationMessage,
130 okLambda, defaultButton, timeout);
156 std::chrono::milliseconds timeout = std::chrono::milliseconds(0))
169 bool appendOldMessages =
false,
170 std::chrono::milliseconds timeout = std::chrono::milliseconds(0))
177 m_overlayMessages->showOverlayMessagesOrSingleMessage(messages, appendOldMessages, timeout);
183 bool appendOldMessages =
false,
184 std::chrono::milliseconds timeout = std::chrono::milliseconds(0))
191 m_overlayMessages->showOverlayMessagesOrHTMLMessage(messages, appendOldMessages, timeout);
209 std::chrono::milliseconds timeout = std::chrono::milliseconds(0))
223 std::chrono::milliseconds timeout = std::chrono::milliseconds(0))
237 std::chrono::milliseconds timeout = std::chrono::milliseconds(0))
259 std::chrono::milliseconds timeout = std::chrono::milliseconds(0))
268 std::chrono::milliseconds timeout = std::chrono::milliseconds(0))
278 std::chrono::milliseconds timeout = std::chrono::milliseconds(0))
288 std::chrono::milliseconds timeout = std::chrono::milliseconds(0))
325 this->setWindowFlags(f);
327 m_middleFactor = isFrameless ? 1.25 : 1.5;
333 const QSize inner(innerFrameSize(widthFactor, heightFactor));
342 const QPoint middle = WIDGET::geometry().center();
343 const int w = inner.
width();
344 const int h = inner.
height();
345 const int x = middle.
x() - w / 2;
346 const int y = qRound(middle.
y() - h / m_middleFactor);
358 constexpr int MinHeight = 100;
360 if (s.
height() < MinHeight)
365 const QSize inner(innerFrameSize());
366 const QPoint middle = WIDGET::geometry().center();
367 const int w = qMin(inner.
width(), qRound(s.
width()));
369 const int x = middle.
x() - w / 2;
370 const int y = qRound(middle.
y() - h / m_middleFactor);
401 WIDGET::keyPressEvent(event);
408 WIDGET::resizeEvent(event);
417 QSize innerFrameSize(
double widthFactor = -1,
double heightFactor = -1)
const
420 const int w = std::max(WIDGET::width(), WIDGET::minimumWidth());
421 const int h = std::max(WIDGET::height(), WIDGET::minimumHeight());
423 widthFactor = qMin(widthFactor < 0 ? m_widthFactor : widthFactor, 0.95);
424 heightFactor = qMin(heightFactor < 0 ? m_heightFactor : heightFactor, 0.95);
426 int wInner = qRound(widthFactor * w);
427 int hInner = qRound(heightFactor * h);
428 if (wInner > WIDGET::maximumWidth())
430 wInner = WIDGET::maximumWidth();
432 if (hInner > WIDGET::maximumHeight())
434 hInner = WIDGET::maximumHeight();
436 return { wInner, hInner };
439 bool m_forceSmallMsgs =
false;
440 bool m_reducedInfo =
false;
441 double m_widthFactor = 0.7;
442 double m_heightFactor = 0.6;
443 double m_middleFactor = 2;
484 bool isForwardingOverlayMessages()
const;
static QSizeF fontMetricsEstimateSize(int xCharacters, int yCharacters, bool withRatio=false)
Estimate size based on current font.
static bool isMainWindowFrameless()
Is main window frameless?
void resizeEvent(QResizeEvent *event)
COverlayMessages * m_overlayMessages
embedded QFrame with status messages
void showOverlayImage(const swift::misc::CPixmap &pixmap, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
Image.
void closeOverlay()
Close button clicked.
bool showOverlayHTMLMessage(const QString &htmlMessage, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
HTML message.
void clearOverlayMessages()
Clear the overlay messages.
bool showOverlayMessage(const swift::misc::CStatusMessage &message, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
Show single message.
void showOverlayMessages(const swift::misc::CStatusMessageList &messages, bool appendOldMessages=false, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
Show multiple messages.
void showOverlayMessagesWithConfirmation(const swift::misc::CStatusMessageList &messages, bool appendOldMessages, const QString &confirmationMessage, std::function< void()> okLambda, QMessageBox::StandardButton defaultButton=QMessageBox::Cancel, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
Show multiple messages with confirmation bar.
void showOverlayVariant(const swift::misc::CVariant &variant, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
Display one of the supported types.
void initOverlayMessages(QSize inner={})
Init, normally we use lazy init, but by calling init explicitly we can force initalization.
void showStatusMessagesFrame()
Show the inner frame.
void sortOverlayMessages(const swift::misc::CPropertyIndex &property, Qt::SortOrder order)
Sort of overlay messages.
void setForceSmall(bool force)
Force small (smaller layout).
bool showOverlayHTMLMessage(const swift::misc::CStatusMessage &message, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
HTML message.
COverlayMessagesBase(QWidget *parent, Qt::WindowFlags f=Qt::WindowFlags())
Constructor.
void initInnerFrame(double widthFactor=-1, double heightFactor=-1)
Init the inner frame (if not yet initialized).
void showOverlayMessagesOrSingleMessage(const swift::misc::CStatusMessageList &messages, bool appendOldMessages=false, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
Show multiple messages or a single message.
~COverlayMessagesBase()=default
Destructor.
void initMinimalFrame(int lines=4)
Init a minimal frame (smaller as the normal one).
bool hasMinimumSize(int w, int h) const
Check minimum height/width.
void activateTextMessages(bool activate)
Active send/receive of text messages.
bool showOverlayTextMessage(const swift::misc::network::CTextMessage &textMessage, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
Info message, based on text message.
void showOverlayInlineTextMessage(components::TextMessageTab tab)
Image.
void showDownloadProgress(int progress, qint64 current, qint64 max, const QUrl &url, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
Download progress.
void setOverlayMessagesSorting(const swift::misc::CPropertyIndex &property, Qt::SortOrder order)
Set sorting of overlay messages.
void setOverlaySizeFactors(double widthFactor, double heightFactor, double middleFactor=2)
Set the size factors.
void keyPressEvent(QKeyEvent *event)
void showOverlayMessagesOrHTMLMessage(const swift::misc::CStatusMessageList &messages, bool appendOldMessages=false, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
Show multiple messages or a single message (HTML).
void setReducedInfo(bool reduced)
Display reduced information.
void showOverlayInlineTextMessage(const swift::misc::aviation::CCallsign &callsign)
Image.
void requestTextMessageEntryCallsign(const swift::misc::aviation::CCallsign &callsign)
Request an text message entry.
COverlayMessagesFrame(QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
Constructor.
void requestTextMessageWidget(const swift::misc::aviation::CCallsign &callsign)
Request a text message widget.
void requestTextMessageEntryTab(components::TextMessageTab tab)
Request an text message entry.
Display status messages (nested in the parent widget).
void setForceSmall(bool force)
Force small (smaller layout).
void setReducedInfo(bool reduced)
Display reduced information.
COverlayMessagesTableView(QWidget *parent=nullptr)
Constructor.
COverlayMessagesTreeView(QWidget *parent=nullptr)
Constructor.
COverlayMessagesWizardPage(QWidget *parent=nullptr)
Constructor.
Class for emitting a log message.
bool isEmpty() const
Message empty.
Derived & info(const char16_t(&format)[N])
Set the severity to info, providing a format string.
Pixmap which can be transferred via DBus.
bool isEmpty() const
Synonym for empty.
Streamable status message, e.g.
Status messages, e.g. from Core -> GUI.
Wrapper around QVariant which provides transparent access to CValueObject methods of the contained ob...
bool canConvert(int typeId) const
True if this variant can be converted to the type with the given metatype ID.
Value object encapsulating information of a callsign.
Value object encapsulating information of a text message.
bool isEmpty() const
Empty message.
QObject * parent() const const
qreal height() const const
void setHeight(qreal height)
qreal width() const const
#define SWIFT_GUI_EXPORT
Export a class or function from the library.