Add a button to Topbar to call out WarningMessage above mainwindow , make the WarningMEssagewidget be popup widget.
This commit is contained in:
@@ -27,8 +27,8 @@ WarningMessageWidget::WarningMessageWidget(QWidget *parent):QWidget(parent)
|
|||||||
, mErrorEmptyMessage(new QLabel(tr("System is working properly.")))
|
, mErrorEmptyMessage(new QLabel(tr("System is working properly.")))
|
||||||
, mWarningEmptyMessage(new QLabel(tr("No message.")))
|
, mWarningEmptyMessage(new QLabel(tr("No message.")))
|
||||||
{
|
{
|
||||||
// setWindowFlags(windowFlags()|Qt::FramelessWindowHint|Qt::Popup);
|
setWindowFlags(windowFlags()|Qt::FramelessWindowHint|Qt::Popup);
|
||||||
setWindowFlags(windowFlags()|Qt::FramelessWindowHint);
|
// setWindowFlags(windowFlags()|Qt::FramelessWindowHint);
|
||||||
setWindowOpacity(1);
|
setWindowOpacity(1);
|
||||||
setAttribute(Qt::WA_TranslucentBackground);
|
setAttribute(Qt::WA_TranslucentBackground);
|
||||||
setObjectName("WarningPanel");
|
setObjectName("WarningPanel");
|
||||||
|
|||||||
@@ -7,8 +7,11 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
#include <QToolButton>
|
||||||
|
|
||||||
|
|
||||||
#include "components/RollingMessageWidget.h"
|
#include "components/RollingMessageWidget.h"
|
||||||
|
|
||||||
#include "event/EventCenter.h"
|
#include "event/EventCenter.h"
|
||||||
#include "errorhandle/GUIErrorLW.h"
|
#include "errorhandle/GUIErrorLW.h"
|
||||||
#include "json/jsonobject.h"
|
#include "json/jsonobject.h"
|
||||||
@@ -51,8 +54,13 @@ TopBarWidget::TopBarWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent,
|
|||||||
QPixmap pixmap(*isConnected ? ":/icons/link_g.png" : ":/icons/link_r.png");
|
QPixmap pixmap(*isConnected ? ":/icons/link_g.png" : ":/icons/link_r.png");
|
||||||
linkIcon->setPixmap(QPixmap(pixmap));
|
linkIcon->setPixmap(QPixmap(pixmap));
|
||||||
});
|
});
|
||||||
auto readyIcon = new QLabel(this);
|
|
||||||
|
auto readyIcon = new QToolButton(this);
|
||||||
readyIcon->setObjectName("ready");
|
readyIcon->setObjectName("ready");
|
||||||
|
connect(readyIcon, &QToolButton::clicked,[=](){
|
||||||
|
emit warnBtnClicked();
|
||||||
|
});
|
||||||
|
|
||||||
auto lockIcon = new QLabel(this);
|
auto lockIcon = new QLabel(this);
|
||||||
lockIcon->setText("");
|
lockIcon->setText("");
|
||||||
auto status_layout = new QHBoxLayout(statusBarWidget);
|
auto status_layout = new QHBoxLayout(statusBarWidget);
|
||||||
@@ -66,8 +74,9 @@ TopBarWidget::TopBarWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent,
|
|||||||
|
|
||||||
layout->addWidget(spacerLine);
|
layout->addWidget(spacerLine);
|
||||||
layout->addWidget(linkIcon);
|
layout->addWidget(linkIcon);
|
||||||
layout->addWidget(readyIcon);
|
|
||||||
layout->addWidget(lockIcon);
|
layout->addWidget(lockIcon);
|
||||||
|
layout->addWidget(readyIcon);
|
||||||
|
|
||||||
|
|
||||||
auto l = new QVBoxLayout(widgetMsg);
|
auto l = new QVBoxLayout(widgetMsg);
|
||||||
l->setMargin(0);
|
l->setMargin(0);
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ class TopBarWidget :public QWidget{
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public :
|
public :
|
||||||
explicit TopBarWidget(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
|
explicit TopBarWidget(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
|
||||||
|
public:
|
||||||
|
signals:
|
||||||
|
void warnBtnClicked();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include "models/User.h"
|
#include "models/User.h"
|
||||||
#include "appvals/AppGlobalValues.h"
|
#include "appvals/AppGlobalValues.h"
|
||||||
#include "components/UTextEdit.h"
|
#include "components/UTextEdit.h"
|
||||||
|
#include "components/WarningMessageWidget.h"
|
||||||
#include "json/jsonobject.h"
|
#include "json/jsonobject.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -130,7 +131,14 @@ void MainWindow::initializeLayout()
|
|||||||
auto layout = new QVBoxLayout(mUI->mCentralWidget);
|
auto layout = new QVBoxLayout(mUI->mCentralWidget);
|
||||||
layout->setMargin(0);
|
layout->setMargin(0);
|
||||||
layout->setSpacing(0);
|
layout->setSpacing(0);
|
||||||
QWidget* topBarWidget = new TopBarWidget(this);
|
TopBarWidget* topBarWidget = new TopBarWidget(this);
|
||||||
|
auto popNotifications = new WarningMessageWidget(this);
|
||||||
|
popNotifications->hide();
|
||||||
|
connect(topBarWidget,&TopBarWidget::warnBtnClicked,[=](){
|
||||||
|
auto pos = topBarWidget->mapToGlobal(QPoint(topBarWidget->width(),topBarWidget->height()));
|
||||||
|
popNotifications->setPopupArgs(height(),pos.x(),pos.y());
|
||||||
|
popNotifications->show();
|
||||||
|
});
|
||||||
layout->addWidget(topBarWidget);
|
layout->addWidget(topBarWidget);
|
||||||
layout->addWidget(mTabWidget);
|
layout->addWidget(mTabWidget);
|
||||||
layout->addWidget(mInitializWidget);
|
layout->addWidget(mInitializWidget);
|
||||||
|
|||||||
Reference in New Issue
Block a user