Add MultyMessageDialog.
This commit is contained in:
@@ -15,10 +15,13 @@
|
|||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
typedef void(*error_cb)(const char* msg);
|
typedef void(*error_cb)(const char* msg);
|
||||||
|
// level:0 infomation,1 warning,2 error,3 sucessed
|
||||||
|
typedef void(*message_callback)(const char* msg, unsigned int level);
|
||||||
|
|
||||||
int statusCountFlag = 0;
|
int statusCountFlag = 0;
|
||||||
error_cb innerCallback = NULL;
|
error_cb innerCallback = NULL;
|
||||||
|
message_callback msgCallback = NULL;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
void ThreadFunc(void*);
|
void ThreadFunc(void*);
|
||||||
@@ -47,6 +50,15 @@ int InitLib(error_cb cb)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetMessageCallback(message_callback cb)
|
||||||
|
{
|
||||||
|
msgCallback = cb;
|
||||||
|
msgCallback("info message", 0);
|
||||||
|
msgCallback("warning message", 1);
|
||||||
|
msgCallback("error message", 2);
|
||||||
|
msgCallback("sucess message", 3);
|
||||||
|
}
|
||||||
|
|
||||||
volatile int running = 1;
|
volatile int running = 1;
|
||||||
volatile int progress = 0;
|
volatile int progress = 0;
|
||||||
volatile int status = READY;
|
volatile int status = READY;
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ typedef enum {
|
|||||||
|
|
||||||
extern int InitLib(void(*)(const char *msg));
|
extern int InitLib(void(*)(const char *msg));
|
||||||
|
|
||||||
|
extern void SetMessageCallback(void(*)(const char* msg,unsigned int level));
|
||||||
|
|
||||||
extern int ScanControl(ScanAction actionType);
|
extern int ScanControl(ScanAction actionType);
|
||||||
|
|
||||||
extern StatusInfo GetStatus();
|
extern StatusInfo GetStatus();
|
||||||
|
|||||||
@@ -7,60 +7,67 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <qDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "event/EventCenter.h"
|
#include "event/EventCenter.h"
|
||||||
#include "dialogs/GUIMessageDialog.h"
|
#include "dialogs/GUIMessageDialog.h"
|
||||||
#include "dialogs/ChangePasswordFormDialog.h"
|
#include "dialogs/ChangePasswordFormDialog.h"
|
||||||
#include "dialogs/AccountFormDialog.h"
|
#include "dialogs/AccountFormDialog.h"
|
||||||
|
#include "dialogs/MultyMessageDialogManager.h"
|
||||||
#include "appvals/AppGlobalValues.h"
|
#include "appvals/AppGlobalValues.h"
|
||||||
#include "windows/LoginDialog.h"
|
#include "windows/LoginDialog.h"
|
||||||
|
#include "shimlib/ShimLib.h"
|
||||||
|
|
||||||
|
void messageCallback(const char* aMessage,unsigned int aMessageLevel)
|
||||||
|
{
|
||||||
|
DialogManager::Default()->raiseMultyMessageDialog(QString::fromLatin1(aMessage),MessageLevel(aMessageLevel));
|
||||||
|
}
|
||||||
|
|
||||||
DialogManager::DialogManager()
|
DialogManager::DialogManager()
|
||||||
: QObject()
|
: QObject()
|
||||||
, mFunctionDialog(nullptr)
|
, mFunctionDialog(nullptr)
|
||||||
, mMessageDialog(nullptr)
|
, mMessageDialog(nullptr)
|
||||||
, topWidget(nullptr)
|
, mTopWidget(nullptr)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogManager::init() {
|
void DialogManager::init(QWidget* aParent) {
|
||||||
connect(EventCenter::Default(), &EventCenter::DeviceErrorRaise,this,&DialogManager::raiseDeviceError);
|
connect(EventCenter::Default(), &EventCenter::DeviceErrorRaise,this,&DialogManager::raiseDeviceError);
|
||||||
connect(EventCenter::Default(), &EventCenter::InvokeOperationStart,this,&DialogManager::invokeOperationStart);
|
connect(EventCenter::Default(), &EventCenter::InvokeOperationStart,this,&DialogManager::invokeOperationStart);
|
||||||
connect(EventCenter::Default(), &EventCenter::InvokeOperationProgress,this,&DialogManager::invokeOperationProgress);
|
connect(EventCenter::Default(), &EventCenter::InvokeOperationProgress,this,&DialogManager::invokeOperationProgress);
|
||||||
connect(EventCenter::Default(), &EventCenter::InvokeOperationPending,this,&DialogManager::invokeOperationPending);
|
connect(EventCenter::Default(), &EventCenter::InvokeOperationPending,this,&DialogManager::invokeOperationPending);
|
||||||
connect(EventCenter::Default(), &EventCenter::InvokeOperationEnd,this,&DialogManager::invokeOperationEnd);
|
connect(EventCenter::Default(), &EventCenter::InvokeOperationEnd,this,&DialogManager::invokeOperationEnd);
|
||||||
|
MultyMessageDialogManager::getInstance()->setDialogParent(aParent);
|
||||||
|
SetMessageCallback(messageCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
//得考虑多线程的问题
|
//得考虑多线程的问题
|
||||||
void DialogManager::setTopWidget(QWidget* widget) {
|
void DialogManager::setTopWidget(QWidget* widget) {
|
||||||
std::lock_guard<std::mutex> lockGuard(mutex);
|
std::lock_guard<std::mutex> lockGuard(mMutex);
|
||||||
if (!topWidget&& QApplication::activeWindow()){
|
if (nullptr == widget)
|
||||||
topWidget = QApplication::activeWindow();
|
{
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
qDebug()<<"last top:"<<topWidget->objectName()<<", new top:"<<widget->objectName();
|
if (!mTopWidget&& QApplication::activeWindow()){
|
||||||
widget->setParent(topWidget,widget->windowFlags());
|
mTopWidget = QApplication::activeWindow();
|
||||||
topWidget = widget;
|
}
|
||||||
|
qDebug()<<"last top:"<<mTopWidget->objectName()<<", new top:"<<widget->objectName();
|
||||||
|
widget->setParent(mTopWidget,widget->windowFlags());
|
||||||
|
mTopWidget = widget;
|
||||||
++mDialogCount;
|
++mDialogCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogManager::releaseTopWidget(QWidget* expectedTopWidget) {
|
void DialogManager::releaseTopWidget(QWidget* expectedTopWidget) {
|
||||||
std::lock_guard<std::mutex> lockGuard(mutex);
|
std::lock_guard<std::mutex> lockGuard(mMutex);
|
||||||
if (topWidget == expectedTopWidget){
|
if (nullptr == expectedTopWidget)
|
||||||
topWidget = expectedTopWidget->parentWidget();
|
{
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else{
|
if (mTopWidget == expectedTopWidget){
|
||||||
while (auto tempWidget = topWidget->parentWidget()){
|
mTopWidget = expectedTopWidget->parentWidget();
|
||||||
if (tempWidget->parentWidget() == expectedTopWidget){
|
--mDialogCount;
|
||||||
tempWidget->setParent(expectedTopWidget->parentWidget());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
--mDialogCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogManager::requestLogin()
|
void DialogManager::requestLogin()
|
||||||
@@ -119,7 +126,6 @@ void DialogManager::requestChangePassword() {
|
|||||||
//考虑以后使用另外的dialog显示错误
|
//考虑以后使用另外的dialog显示错误
|
||||||
void DialogManager::raiseDeviceError(QObject *parent, QObject *msg) {
|
void DialogManager::raiseDeviceError(QObject *parent, QObject *msg) {
|
||||||
clearMessageDialog();
|
clearMessageDialog();
|
||||||
//new dialog
|
|
||||||
auto dialog = new GUIMessageDialog;
|
auto dialog = new GUIMessageDialog;
|
||||||
|
|
||||||
if (msg) {
|
if (msg) {
|
||||||
@@ -132,6 +138,7 @@ void DialogManager::raiseDeviceError(QObject *parent, QObject *msg) {
|
|||||||
dialog->showExitButton();
|
dialog->showExitButton();
|
||||||
setTopWidget(dialog);
|
setTopWidget(dialog);
|
||||||
dialog->setWindowModality(Qt::NonModal);
|
dialog->setWindowModality(Qt::NonModal);
|
||||||
|
dialog->showFullScreen ();
|
||||||
dialog->exec();
|
dialog->exec();
|
||||||
releaseTopWidget(dialog);
|
releaseTopWidget(dialog);
|
||||||
dialog->deleteLater();
|
dialog->deleteLater();
|
||||||
@@ -214,7 +221,6 @@ void DialogManager::invokeOperationEnd(QObject *parent, QObject *msg) {
|
|||||||
mMessageDialog->accept();
|
mMessageDialog->accept();
|
||||||
}
|
}
|
||||||
delete mMessageDialog;
|
delete mMessageDialog;
|
||||||
mMessageDialog = nullptr;
|
|
||||||
AppGlobalValues::setInProcessing(false);
|
AppGlobalValues::setInProcessing(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -223,10 +229,14 @@ void DialogManager::clearMessageDialog() {
|
|||||||
if (mMessageDialog){
|
if (mMessageDialog){
|
||||||
if (!mMessageDialog->isHidden()) mMessageDialog->hide();
|
if (!mMessageDialog->isHidden()) mMessageDialog->hide();
|
||||||
delete mMessageDialog;
|
delete mMessageDialog;
|
||||||
mMessageDialog = nullptr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogManager::~DialogManager() {
|
DialogManager::~DialogManager() {
|
||||||
clearMessageDialog();
|
clearMessageDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DialogManager::raiseMultyMessageDialog(const QString aMessage, MessageLevel aMessageLevel)
|
||||||
|
{
|
||||||
|
MultyMessageDialogManager::getInstance()->raiseDialog(aMessage, aMessageLevel);
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#define GUI_DIALOGMANAGER_H
|
#define GUI_DIALOGMANAGER_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QPointer>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <QStack>
|
#include <QStack>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
@@ -14,6 +15,7 @@ class QWidget;
|
|||||||
class QDialog;
|
class QDialog;
|
||||||
class GUIMessageDialog;
|
class GUIMessageDialog;
|
||||||
class QSqlTableModel;
|
class QSqlTableModel;
|
||||||
|
enum MessageLevel:unsigned int;
|
||||||
|
|
||||||
class DialogManager:public QObject {
|
class DialogManager:public QObject {
|
||||||
public:
|
public:
|
||||||
@@ -26,7 +28,7 @@ public:
|
|||||||
|
|
||||||
~DialogManager() override;
|
~DialogManager() override;
|
||||||
|
|
||||||
void init();
|
void init(QWidget* aParent);
|
||||||
void setTopWidget(QWidget* widget);
|
void setTopWidget(QWidget* widget);
|
||||||
void releaseTopWidget(QWidget* expectedTopWidget);
|
void releaseTopWidget(QWidget* expectedTopWidget);
|
||||||
void requestLogin();
|
void requestLogin();
|
||||||
@@ -35,6 +37,7 @@ public:
|
|||||||
int requestEditAdminAccount(const QMap<QString, QVariant>& values);
|
int requestEditAdminAccount(const QMap<QString, QVariant>& values);
|
||||||
void requestChangePassword();
|
void requestChangePassword();
|
||||||
void raiseDeviceError(QObject* parent, QObject* msg);
|
void raiseDeviceError(QObject* parent, QObject* msg);
|
||||||
|
void raiseMultyMessageDialog(const QString aMessage,MessageLevel aMessageLevel);
|
||||||
void invokeOperationStart(QObject* parent, QObject* msg);
|
void invokeOperationStart(QObject* parent, QObject* msg);
|
||||||
void invokeOperationProgress(QObject* parent, QObject* msg);
|
void invokeOperationProgress(QObject* parent, QObject* msg);
|
||||||
void invokeOperationPending(QObject* parent, QObject* msg);
|
void invokeOperationPending(QObject* parent, QObject* msg);
|
||||||
@@ -43,9 +46,9 @@ private:
|
|||||||
void clearMessageDialog();
|
void clearMessageDialog();
|
||||||
|
|
||||||
QDialog* mFunctionDialog;
|
QDialog* mFunctionDialog;
|
||||||
GUIMessageDialog* mMessageDialog;
|
QPointer<GUIMessageDialog> mMessageDialog;
|
||||||
QWidget* topWidget;
|
QWidget* mTopWidget;
|
||||||
std::mutex mutex;
|
std::mutex mMutex;
|
||||||
int mDialogCount = 0;
|
int mDialogCount = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ GUIMessageDialog::GUIMessageDialog(QWidget *parent)
|
|||||||
mUI->setupUi(this);
|
mUI->setupUi(this);
|
||||||
this->setObjectName("MessageDialog");
|
this->setObjectName("MessageDialog");
|
||||||
this->setWindowFlags (Qt :: FramelessWindowHint | Qt :: Dialog);
|
this->setWindowFlags (Qt :: FramelessWindowHint | Qt :: Dialog);
|
||||||
this->showFullScreen ();
|
|
||||||
initBaseLayout();
|
initBaseLayout();
|
||||||
this->setWindowOpacity(0.6);
|
this->setWindowOpacity(0.6);
|
||||||
initLoadingFrameString();
|
initLoadingFrameString();
|
||||||
|
|||||||
112
src/dialogs/MultyMessageDialog.cpp
Normal file
112
src/dialogs/MultyMessageDialog.cpp
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
#include "MultyMessageDialog.h"
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
const int AUTO_DISAPPEAR_TIME = 5000;
|
||||||
|
const int DIALOG_WIDTH = 240;
|
||||||
|
const int DIALOG_HEIGHT = 50;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
MultyMessageDialog::MultyMessageDialog(const QString& aMessage,MessageLevel aMessageLevel,QWidget* aParent)
|
||||||
|
: QDialog(aParent)
|
||||||
|
, mAutoDisappearTime(AUTO_DISAPPEAR_TIME)
|
||||||
|
, mTimer(new QTimer(this))
|
||||||
|
, mDisappearAnimation(new QPropertyAnimation(this,"pos",this))
|
||||||
|
, mShowAnimation(new QPropertyAnimation(this,"pos",this))
|
||||||
|
, mMessage(new QLabel(aMessage,this))
|
||||||
|
, mIcon(new QLabel(this))
|
||||||
|
, mLevel(aMessageLevel)
|
||||||
|
{
|
||||||
|
setWindowFlags(Qt::FramelessWindowHint| Qt::WindowStaysOnTopHint| Qt::BypassWindowManagerHint);
|
||||||
|
resize(DIALOG_WIDTH,DIALOG_HEIGHT);
|
||||||
|
mTimer->setSingleShot(true);
|
||||||
|
connect(mTimer,&QTimer::timeout,this,&MultyMessageDialog::startHideAnimation);
|
||||||
|
initializeAnimation();
|
||||||
|
initializeIcon();
|
||||||
|
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||||
|
layout->addWidget(mIcon);
|
||||||
|
layout->addWidget(mMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
MultyMessageDialog::~MultyMessageDialog()
|
||||||
|
{
|
||||||
|
emit dialogDestroyed();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MultyMessageDialog::initializeAnimation()
|
||||||
|
{
|
||||||
|
mDisappearAnimation->setDuration(100);
|
||||||
|
|
||||||
|
mShowAnimation->setDuration(100);
|
||||||
|
|
||||||
|
connect(mDisappearAnimation, &QPropertyAnimation::finished, this, &MultyMessageDialog::hideDialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MultyMessageDialog::initializeIcon()
|
||||||
|
{
|
||||||
|
switch (mLevel)
|
||||||
|
{
|
||||||
|
case Info:
|
||||||
|
mIcon->setObjectName("MultyMessageDialogInfo");
|
||||||
|
break;
|
||||||
|
case Warning:
|
||||||
|
mIcon->setObjectName("MultyMessageDialogWarning");
|
||||||
|
break;
|
||||||
|
case Error:
|
||||||
|
mIcon->setObjectName("MultyMessageDialogError");
|
||||||
|
break;
|
||||||
|
case Sucess:
|
||||||
|
mIcon->setObjectName("MultyMessageDialogSucess");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
mIcon->setObjectName("MultyMessageDialogInfo");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MultyMessageDialog::setMessage(const QString& aMessage)
|
||||||
|
{
|
||||||
|
mMessage->setText(aMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MultyMessageDialog::startHideAnimation()
|
||||||
|
{
|
||||||
|
if (mTimer->isActive())
|
||||||
|
{
|
||||||
|
mTimer->stop();
|
||||||
|
}
|
||||||
|
mDisappearAnimation->setStartValue(pos());
|
||||||
|
mDisappearAnimation->setEndValue(QPoint(pos().x(),pos().y()-30-height()));
|
||||||
|
mDisappearAnimation->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MultyMessageDialog::hideDialog()
|
||||||
|
{
|
||||||
|
hide();
|
||||||
|
deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MultyMessageDialog::setAutoDisappearTime(int aAutoDisappearTime)
|
||||||
|
{
|
||||||
|
mAutoDisappearTime = aAutoDisappearTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MultyMessageDialog::showEvent(QShowEvent* aEvent)
|
||||||
|
{
|
||||||
|
mTimer->start(mAutoDisappearTime);
|
||||||
|
mShowAnimation->setStartValue(QPoint(pos().x(),pos().y()-30-height()));
|
||||||
|
mShowAnimation->setEndValue(pos());
|
||||||
|
mShowAnimation->start();
|
||||||
|
QDialog::showEvent(aEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MultyMessageDialog::stopShowAnimation()
|
||||||
|
{
|
||||||
|
if (QAbstractAnimation::Running == mShowAnimation->state())
|
||||||
|
{
|
||||||
|
mShowAnimation->stop();
|
||||||
|
move(mShowAnimation->endValue().toPoint());
|
||||||
|
}
|
||||||
|
}
|
||||||
55
src/dialogs/MultyMessageDialog.h
Normal file
55
src/dialogs/MultyMessageDialog.h
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
#ifndef MULTYMESSAGEDIALOG_H
|
||||||
|
#define MULTYMESSAGEDIALOG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QPropertyAnimation>
|
||||||
|
|
||||||
|
enum MessageLevel:unsigned int
|
||||||
|
{
|
||||||
|
Info = 0,
|
||||||
|
Warning,
|
||||||
|
Error,
|
||||||
|
Sucess,
|
||||||
|
};
|
||||||
|
|
||||||
|
class MultyMessageDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
MultyMessageDialog(const QString& aMessage = "",MessageLevel aMessageLevel = MessageLevel::Info,QWidget* aParent = nullptr);
|
||||||
|
~MultyMessageDialog() override;
|
||||||
|
void setAutoDisappearTime(int aAutoDisappearTime);
|
||||||
|
void setMessage(const QString& aMessage);
|
||||||
|
void stopShowAnimation();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void dialogDestroyed();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void hideDialog();
|
||||||
|
void startHideAnimation();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void showEvent(QShowEvent* aEvent) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void initializeAnimation();
|
||||||
|
void initializeIcon();
|
||||||
|
|
||||||
|
private:
|
||||||
|
int mAutoDisappearTime;
|
||||||
|
QTimer* mTimer;
|
||||||
|
QSize mSize;
|
||||||
|
QPropertyAnimation* mDisappearAnimation;
|
||||||
|
QPropertyAnimation* mShowAnimation;
|
||||||
|
QLabel* mMessage;
|
||||||
|
QLabel* mIcon;
|
||||||
|
MessageLevel mLevel;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MULTYMESSAGEDIALOG_H
|
||||||
71
src/dialogs/MultyMessageDialogManager.cpp
Normal file
71
src/dialogs/MultyMessageDialogManager.cpp
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
#include "MultyMessageDialogManager.h"
|
||||||
|
#include "MultyMessageDialog.h"
|
||||||
|
|
||||||
|
#include <QMutexLocker>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
const int DIALOGS_MARGIN = 30;
|
||||||
|
const int GEOMETY_X = 1620;
|
||||||
|
const int GEOMETY_Y = 30;
|
||||||
|
}
|
||||||
|
MultyMessageDialogManager* MultyMessageDialogManager::getInstance()
|
||||||
|
{
|
||||||
|
static MultyMessageDialogManager instance;
|
||||||
|
return &instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
MultyMessageDialogManager::MultyMessageDialogManager()
|
||||||
|
: QObject()
|
||||||
|
, mDialogParent(nullptr)
|
||||||
|
, mDialogList()
|
||||||
|
, mMutex()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
MultyMessageDialogManager::~MultyMessageDialogManager()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void MultyMessageDialogManager::setDialogParent(QWidget* aParent)
|
||||||
|
{
|
||||||
|
mDialogParent = aParent;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MultyMessageDialogManager::raiseDialog(const QString& aMessage,MessageLevel aMessageLevel)
|
||||||
|
{
|
||||||
|
QMutexLocker locker(&mMutex);
|
||||||
|
MultyMessageDialog* dialog = new MultyMessageDialog(aMessage,aMessageLevel,mDialogParent);
|
||||||
|
mDialogList.append(dialog);
|
||||||
|
int yDistance = GEOMETY_Y;
|
||||||
|
for (int i = 0; i < mDialogList.count() - 1; ++i)
|
||||||
|
{
|
||||||
|
yDistance += mDialogList.at(i)->size().height() + DIALOGS_MARGIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
dialog->move(GEOMETY_X,yDistance);
|
||||||
|
dialog->show();
|
||||||
|
connect(dialog,&MultyMessageDialog::dialogDestroyed,this,&MultyMessageDialogManager::removeDestoryedDialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MultyMessageDialogManager::removeDestoryedDialog()
|
||||||
|
{
|
||||||
|
QMutexLocker locker(&mMutex);
|
||||||
|
MultyMessageDialog* dialog = qobject_cast<MultyMessageDialog*>(sender());
|
||||||
|
if (nullptr == dialog)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int index = mDialogList.indexOf(dialog);
|
||||||
|
if (index >= 0)
|
||||||
|
{
|
||||||
|
mDialogList.removeAt(index);
|
||||||
|
for (int i = 0; i < mDialogList.count(); ++i)
|
||||||
|
{
|
||||||
|
MultyMessageDialog* target = mDialogList.at(i);
|
||||||
|
target->stopShowAnimation();
|
||||||
|
QPoint position = target->mapToGlobal(QPoint(0, 0));
|
||||||
|
target->move(position.x(),position.y()-dialog->height()-DIALOGS_MARGIN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
30
src/dialogs/MultyMessageDialogManager.h
Normal file
30
src/dialogs/MultyMessageDialogManager.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#ifndef MULTYMESSAGEDIALOGMANAGER_H
|
||||||
|
#define MULTYMESSAGEDIALOGMANAGER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QList>
|
||||||
|
#include <QMutex>
|
||||||
|
|
||||||
|
class MultyMessageDialog;
|
||||||
|
enum MessageLevel:unsigned int;
|
||||||
|
|
||||||
|
class MultyMessageDialogManager : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
static MultyMessageDialogManager* getInstance();
|
||||||
|
void raiseDialog(const QString& aMessage,MessageLevel aMessageLevel);
|
||||||
|
void setDialogParent(QWidget* aParent);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void removeDestoryedDialog();
|
||||||
|
|
||||||
|
private:
|
||||||
|
MultyMessageDialogManager();
|
||||||
|
~MultyMessageDialogManager();
|
||||||
|
QWidget* mDialogParent;
|
||||||
|
QList<MultyMessageDialog*> mDialogList;
|
||||||
|
QMutex mMutex;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MULTYMESSAGEDIALOGMANAGER_H
|
||||||
BIN
src/icons/dicom/info.png
Normal file
BIN
src/icons/dicom/info.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
BIN
src/icons/dicom/warning.png
Normal file
BIN
src/icons/dicom/warning.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
@@ -12,10 +12,12 @@
|
|||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <src/device/DeviceManager.h>
|
#include <src/device/DeviceManager.h>
|
||||||
#include "dialogs/DialogManager.h"
|
#include "dialogs/DialogManager.h"
|
||||||
|
#include "dialogs/MultyMessageDialogManager.h"
|
||||||
#include "json/jsonobject.h"
|
#include "json/jsonobject.h"
|
||||||
#include "src/utilities/Locker.h"
|
#include "src/utilities/Locker.h"
|
||||||
#include "src/utilities/LanguageSwitcher.h"
|
#include "src/utilities/LanguageSwitcher.h"
|
||||||
#include "utilities/TouchScreenSignalSender.h"
|
#include "utilities/TouchScreenSignalSender.h"
|
||||||
|
#include "Keyboard/KeyboardManager.h"
|
||||||
|
|
||||||
QString loadFontFromFile(QString path)
|
QString loadFontFromFile(QString path)
|
||||||
{
|
{
|
||||||
@@ -83,6 +85,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
QStringList app_args = a.arguments();
|
QStringList app_args = a.arguments();
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
KeyboardManager::getInstance();
|
||||||
|
|
||||||
if (app_args.contains("-d"))
|
if (app_args.contains("-d"))
|
||||||
//if (true)
|
//if (true)
|
||||||
@@ -104,7 +107,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
w.requestLogin();
|
w.requestLogin();
|
||||||
|
|
||||||
DialogManager::Default()->init();
|
DialogManager::Default()->init(&w);
|
||||||
DeviceManager::Default()->initDevice();
|
DeviceManager::Default()->initDevice();
|
||||||
|
|
||||||
ret = a.exec();
|
ret = a.exec();
|
||||||
@@ -115,7 +118,7 @@ int main(int argc, char* argv[])
|
|||||||
{
|
{
|
||||||
w.showFullScreen();
|
w.showFullScreen();
|
||||||
w.requestLogin();
|
w.requestLogin();
|
||||||
DialogManager::Default()->init();
|
DialogManager::Default()->init(&w);
|
||||||
DeviceManager::Default()->initDevice();
|
DeviceManager::Default()->initDevice();
|
||||||
ret = a.exec();
|
ret = a.exec();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,8 @@
|
|||||||
<file>icons/dicom/echo_suc.png</file>
|
<file>icons/dicom/echo_suc.png</file>
|
||||||
<file>icons/dicom/echo_ing.png</file>
|
<file>icons/dicom/echo_ing.png</file>
|
||||||
<file>icons/dicom/echo_fail.png</file>
|
<file>icons/dicom/echo_fail.png</file>
|
||||||
|
<file>icons/dicom/info.png</file>
|
||||||
|
<file>icons/dicom/warning.png</file>
|
||||||
<file>icons/dicomsettings.png</file>
|
<file>icons/dicomsettings.png</file>
|
||||||
<file>icons/dicomsettings_d.png</file>
|
<file>icons/dicomsettings_d.png</file>
|
||||||
<file>icons/networksettings.png</file>
|
<file>icons/networksettings.png</file>
|
||||||
|
|||||||
@@ -795,3 +795,52 @@ QWidget#EditMenu QListWidget:item:hover {
|
|||||||
background: #006dc7;
|
background: #006dc7;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MultyMessageDialog {
|
||||||
|
border: 2px solid #2db7f5;
|
||||||
|
border-radius: 16px;
|
||||||
|
/*background: rgba(249,250,250,180);*/
|
||||||
|
background: rgba(239,240,241,200);
|
||||||
|
}
|
||||||
|
|
||||||
|
MultyMessageDialog QLabel {
|
||||||
|
background: rgba(255,0,0,0);
|
||||||
|
color: black;
|
||||||
|
font: normal 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
QLabel#MultyMessageDialogInfo {
|
||||||
|
min-width: 30px;
|
||||||
|
max-width: 30px;
|
||||||
|
min-height: 30px;
|
||||||
|
max-height: 30px;
|
||||||
|
qproperty-pixmap: url(":/icons/dicom/info.png");
|
||||||
|
qproperty-scaledContents: true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QLabel#MultyMessageDialogWarning {
|
||||||
|
min-width: 30px;
|
||||||
|
max-width: 30px;
|
||||||
|
min-height: 30px;
|
||||||
|
max-height: 30px;
|
||||||
|
qproperty-pixmap: url(":/icons/dicom/warning.png");
|
||||||
|
qproperty-scaledContents: true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QLabel#MultyMessageDialogError {
|
||||||
|
min-width: 30px;
|
||||||
|
max-width: 30px;
|
||||||
|
min-height: 30px;
|
||||||
|
max-height: 30px;
|
||||||
|
qproperty-pixmap: url(":/icons/dicom/echo_fail.png");
|
||||||
|
qproperty-scaledContents: true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QLabel#MultyMessageDialogSucess {
|
||||||
|
min-width: 30px;
|
||||||
|
max-width: 30px;
|
||||||
|
min-height: 30px;
|
||||||
|
max-height: 30px;
|
||||||
|
qproperty-pixmap: url(":/icons/dicom/echo_suc.png");
|
||||||
|
qproperty-scaledContents: true;
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDeskTopWidget>
|
#include <QDesktopWidget>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QtWidgets/QLabel>
|
#include <QtWidgets/QLabel>
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ LoginDialog::LoginDialog(QWidget* aParent)
|
|||||||
, mErrorMessage(new QLabel(this))
|
, mErrorMessage(new QLabel(this))
|
||||||
{
|
{
|
||||||
initializeAllWidget();
|
initializeAllWidget();
|
||||||
setWindowFlags(windowFlags() | Qt::Window | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint);
|
setWindowFlags(windowFlags() | Qt::Window | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint| Qt::BypassWindowManagerHint);
|
||||||
setGeometry(QApplication::desktop()->screenGeometry());
|
setGeometry(QApplication::desktop()->screenGeometry());
|
||||||
mAccountEdit->setText(JsonObject::Instance()->defaultUser());
|
mAccountEdit->setText(JsonObject::Instance()->defaultUser());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user