6 #ifndef SWIFT_GUI_OVERLAYMESSAGES_FRAME_H
7 #define SWIFT_GUI_OVERLAYMESSAGES_FRAME_H
11 #include <QDockWidget>
14 #include <QMessageBox>
22 #include <QWizardPage>
46 template <
class WIDGET>
58 if (inner.isNull()) { inner = this->innerFrameSize(); }
79 m_widthFactor = widthFactor;
80 m_heightFactor = heightFactor;
81 if (middleFactor >= 0) { m_middleFactor = middleFactor; }
87 m_forceSmallMsgs = force;
94 m_reducedInfo = reduced;
100 bool appendOldMessages,
const QString &confirmationMessage,
101 std::function<
void()> okLambda,
102 QMessageBox::StandardButton defaultButton = QMessageBox::Cancel,
103 std::chrono::milliseconds timeout = std::chrono::milliseconds(0))
105 if (messages.
isEmpty()) {
return; }
109 okLambda, defaultButton, timeout);
129 std::chrono::milliseconds timeout = std::chrono::milliseconds(0))
131 if (messages.
isEmpty()) {
return; }
139 bool appendOldMessages =
false,
140 std::chrono::milliseconds timeout = std::chrono::milliseconds(0))
142 if (messages.
isEmpty()) {
return; }
150 bool appendOldMessages =
false,
151 std::chrono::milliseconds timeout = std::chrono::milliseconds(0))
153 if (messages.
isEmpty()) {
return; }
173 std::chrono::milliseconds timeout = std::chrono::milliseconds(0))
175 if (message.
isEmpty()) {
return false; }
184 std::chrono::milliseconds timeout = std::chrono::milliseconds(0))
186 if (textMessage.
isEmpty()) {
return false; }
195 std::chrono::milliseconds timeout = std::chrono::milliseconds(0))
211 std::chrono::milliseconds timeout = std::chrono::milliseconds(0))
220 std::chrono::milliseconds timeout = std::chrono::milliseconds(0))
230 std::chrono::milliseconds timeout = std::chrono::milliseconds(0))
240 std::chrono::milliseconds timeout = std::chrono::milliseconds(0))
271 this->setWindowFlags(f);
273 m_middleFactor = isFrameless ? 1.25 : 1.5;
279 const QSize inner(innerFrameSize(widthFactor, heightFactor));
288 const QPoint middle = WIDGET::geometry().center();
289 const int w = inner.width();
290 const int h = inner.height();
291 const int x = middle.x() - w / 2;
292 const int y = qRound(middle.y() - h / m_middleFactor);
304 constexpr
int MinHeight = 100;
306 if (s.height() < MinHeight) { s.setHeight(MinHeight); }
308 const QSize inner(innerFrameSize());
309 const QPoint middle = WIDGET::geometry().center();
310 const int w = qMin(inner.width(), qRound(s.width()));
311 const int h = qMin(inner.height(), qRound(s.height()));
312 const int x = middle.x() - w / 2;
313 const int y = qRound(middle.y() - h / m_middleFactor);
342 else { WIDGET::keyPressEvent(event); }
348 WIDGET::resizeEvent(event);
354 QSize innerFrameSize(
double widthFactor = -1,
double heightFactor = -1)
const
357 const int w = std::max(WIDGET::width(), WIDGET::minimumWidth());
358 const int h = std::max(WIDGET::height(), WIDGET::minimumHeight());
360 widthFactor = qMin(widthFactor < 0 ? m_widthFactor : widthFactor, 0.95);
361 heightFactor = qMin(heightFactor < 0 ? m_heightFactor : heightFactor, 0.95);
363 int wInner = qRound(widthFactor * w);
364 int hInner = qRound(heightFactor * h);
365 if (wInner > WIDGET::maximumWidth()) { wInner = WIDGET::maximumWidth(); }
366 if (hInner > WIDGET::maximumHeight()) { hInner = WIDGET::maximumHeight(); }
367 return QSize(wInner, hInner);
370 bool m_forceSmallMsgs =
false;
371 bool m_reducedInfo =
false;
372 double m_widthFactor = 0.7;
373 double m_heightFactor = 0.6;
374 double m_middleFactor = 2;
411 Qt::WindowFlags f = Qt::WindowFlags());
415 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?
Base class to display overlay messages in different widgets (nested in this widget).
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.
virtual ~COverlayMessagesBase()
Destructor.
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)
virtual void keyPressEvent(QKeyEvent *event)
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.
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 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.
virtual void resizeEvent(QResizeEvent *event)
Using this class provides a QFrame with the overlay functionality already integrated.
void requestTextMessageEntryCallsign(const swift::misc::aviation::CCallsign &callsign)
Request an text message entry.
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 sortOverlayMessages(const swift::misc::CPropertyIndex &propertyIndex, Qt::SortOrder order=Qt::AscendingOrder)
Sort of overlay messages.
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.
void activateTextMessages(bool activate)
Active send/receive of text messages.
bool isTextMessagesActivated() const
Are text messages.
void showOverlayVariant(const swift::misc::CVariant &variant, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
Display one of the supported types.
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 &propertyIndex, Qt::SortOrder order=Qt::AscendingOrder)
Set sorting of overlay messages.
void clearOverlayMessages()
Clear the overlay messages.
void close()
Close button clicked.
void showOverlayTextMessage(const swift::misc::network::CTextMessage &textMessage, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
Info message, based on text message.
void showOverlayMessages(const swift::misc::CStatusMessageList &messages, bool appendOldMessages=false, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
Show multiple messages.
void showOverlayMessage(const swift::misc::CStatusMessage &message, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
Show single message.
void setForceSmall(bool force)
Force small (smaller layout)
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 showOverlayInlineTextMessage(components::TextMessageTab tab)
Inline text message.
void setReducedInfo(bool reduced)
Display reduced information.
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 showHTMLMessage(const swift::misc::CStatusMessage &message, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
HTML message.
void showOverlayImage(const swift::misc::CPixmap &image, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
Image.
Using this class provides a QTableView with the overlay functionality already integrated.
Using this class provides a QTableView with the overlay functionality already integrated.
Using this class provides a QWizardPage with the overlay functionality already integrated.
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.
#define SWIFT_GUI_EXPORT
Export a class or function from the library.