修改程序完成遮罩和子窗口在x11下的正常显示
This commit is contained in:
parent
8f602fd007
commit
2c4a54738b
|
|
@ -9,6 +9,7 @@ class dvieMainWindow;
|
|||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class TransparentMask;
|
||||
class Dashboard;
|
||||
class DashboardFrame;
|
||||
class DvieSecondaryWindow;
|
||||
|
|
@ -21,6 +22,9 @@ public:
|
|||
DvieMainWindow(QWidget *parent = nullptr);
|
||||
~DvieMainWindow();
|
||||
|
||||
void showTransparentMask();
|
||||
void hideTransparentMask();
|
||||
|
||||
DashboardFrame* dashboardFrame();
|
||||
DashboardFrame* getDashboardFrame(const QString&);
|
||||
void creatSecondaryWindowAndAddDashboard(QPoint, Dashboard*);
|
||||
|
|
@ -28,6 +32,7 @@ public:
|
|||
|
||||
private:
|
||||
Ui::dvieMainWindow* ui;
|
||||
TransparentMask* m_pTransparentMask;
|
||||
DashboardFrame* m_pDashboardFrame;
|
||||
QHash<QString, DvieSecondaryWindow*> m_hashSecondaryWindow;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ class dvieSecondaryWindow;
|
|||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class TransparentMask;
|
||||
class DvieMainWindow;
|
||||
class Dashboard;
|
||||
class DashboardFrame;
|
||||
|
|
@ -21,6 +22,9 @@ public:
|
|||
DvieSecondaryWindow(const QString&, QWidget *parent = nullptr);
|
||||
~DvieSecondaryWindow();
|
||||
|
||||
void showTransparentMask();
|
||||
void hideTransparentMask();
|
||||
|
||||
QString name();
|
||||
DashboardFrame* dashboardFrame();
|
||||
DashboardFrame* getDashboardFrame(const QString&);
|
||||
|
|
@ -32,6 +36,7 @@ protected:
|
|||
|
||||
private:
|
||||
Ui::dvieSecondaryWindow* ui;
|
||||
TransparentMask* m_pTransparentMask;
|
||||
QString m_strName;
|
||||
DvieMainWindow* m_pMainWindow;
|
||||
DashboardFrame* m_pDashboardFrame;
|
||||
|
|
|
|||
|
|
@ -129,27 +129,49 @@ void DashboardFrame::dropEvent(QDropEvent* event)
|
|||
{
|
||||
Dashboard* dashboard = fromFrame->takeDashboard(strTabText);
|
||||
addDashboard(dashboard);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DashboardFrame::showTransparentMask()
|
||||
{
|
||||
if(m_pParentWindow) //遮罩作为子组件最多只能在自身范围内覆盖,无法覆盖到父组件,因此需要父组件其它部分需要父组件去完成
|
||||
{
|
||||
if(m_type == dashboardFrame::ft_main)
|
||||
{
|
||||
DvieMainWindow* dvieWindow = qobject_cast<DvieMainWindow*>(m_pParentWindow);
|
||||
if(dvieWindow)
|
||||
dvieWindow->showTransparentMask();
|
||||
}
|
||||
else if(m_type == dashboardFrame::ft_secondary)
|
||||
{
|
||||
DvieSecondaryWindow* dvieWindow = qobject_cast<DvieSecondaryWindow*>(m_pParentWindow);
|
||||
if(dvieWindow)
|
||||
dvieWindow->showTransparentMask();
|
||||
}
|
||||
}
|
||||
|
||||
if(m_pTransparentMask == nullptr)
|
||||
m_pTransparentMask = new TransparentMask(this);
|
||||
|
||||
QPoint originPoint = QPoint(0, 0);
|
||||
if(m_pParentWindow)
|
||||
originPoint = m_pParentWindow->mapToGlobal(QPoint(0, 0));
|
||||
else
|
||||
originPoint = this->mapToGlobal(QPoint(0, 0));
|
||||
|
||||
m_pTransparentMask->setGeometry(originPoint.x(), originPoint.y(), this->width(), this->height());
|
||||
m_pTransparentMask->setGeometry(0, 0, this->width(), this->height());
|
||||
m_pTransparentMask->show();
|
||||
}
|
||||
void DashboardFrame::hideTransparentMask()
|
||||
{
|
||||
if(m_type == dashboardFrame::ft_main)
|
||||
{
|
||||
DvieMainWindow* dvieWindow = qobject_cast<DvieMainWindow*>(m_pParentWindow);
|
||||
if(dvieWindow)
|
||||
dvieWindow->hideTransparentMask();
|
||||
}
|
||||
else if(m_type == dashboardFrame::ft_secondary)
|
||||
{
|
||||
DvieSecondaryWindow* dvieWindow = qobject_cast<DvieSecondaryWindow*>(m_pParentWindow);
|
||||
if(dvieWindow)
|
||||
dvieWindow->hideTransparentMask();
|
||||
}
|
||||
|
||||
if(m_pTransparentMask != nullptr && m_pTransparentMask->isVisible())
|
||||
m_pTransparentMask->hide();
|
||||
}
|
||||
|
|
@ -164,13 +186,10 @@ void DashboardFrame::showMessageDialog(MessageDialogType type,const QString& str
|
|||
}
|
||||
|
||||
m_pMessageDialog->setMessage(type, strTitle, strContent);
|
||||
// QPoint originPoint = this->mapToGlobal(QPoint(0, 0));
|
||||
// int nX = originPoint.x() + (this->width() - m_pMessageDialog->width()) * 0.5;
|
||||
// int nY = originPoint.y() + (this->height() - m_pMessageDialog->height()) * 0.5;
|
||||
QPoint originPoint = ui->navigationPanel->mapToGlobal(QPoint(0, 0));
|
||||
int nX = originPoint.x() + (ui->navigationPanel->width() - m_pMessageDialog->width()) * 0.5;
|
||||
int nY = originPoint.y() + ui->navigationPanel->height() * 0.5;
|
||||
int nX = (ui->navigationPanel->width() - m_pMessageDialog->width()) * 0.5;
|
||||
int nY = ui->navigationPanel->y() + ui->navigationPanel->height() * 0.5;
|
||||
m_pMessageDialog->setGeometry(nX, nY, m_pMessageDialog->width(), m_pMessageDialog->height());
|
||||
m_pMessageDialog->raise();
|
||||
if(type == type_question)
|
||||
m_pMessageDialog->exec();
|
||||
else
|
||||
|
|
@ -181,20 +200,6 @@ void DashboardFrame::addDashboard(const QString& strName)
|
|||
{
|
||||
Dashboard* dashboard = new Dashboard(strName);
|
||||
insertDashboard(m_listDashboard.count(), dashboard);
|
||||
// connect(dashboard, SIGNAL(sgl_rename()), this, SLOT(onSignal_renameDashboard()));
|
||||
// connect(dashboard, SIGNAL(sgl_remove()), this, SLOT(onSignal_removeDashboard()));
|
||||
// dashboard->setDisplayAreaLayout(ui->hLayout_dashboardDisplayArea);
|
||||
|
||||
// //添加tab
|
||||
// CustomTab* tab = dashboard->tab();
|
||||
// m_pDashboardTabBar->addTab(tab);
|
||||
// connect(tab, SIGNAL(clicked()), this, SLOT(onBtnClicked_dashboardTab()));
|
||||
|
||||
// m_listDashboard.push_back(dashboard);
|
||||
// if(m_curActiveDashboard)
|
||||
// m_curActiveDashboard->setActive(false);
|
||||
// dashboard->setActive(true);
|
||||
// m_curActiveDashboard = dashboard;
|
||||
}
|
||||
void DashboardFrame::addDashboard(Dashboard* dashboard)
|
||||
{
|
||||
|
|
@ -409,11 +414,11 @@ void DashboardFrame::onBtnClicked_addDashboard()
|
|||
}
|
||||
|
||||
showTransparentMask();
|
||||
QPoint originPoint = ui->navigationPanel->mapToGlobal(QPoint(0, 0));
|
||||
int nX = originPoint.x() + (ui->navigationPanel->width() - m_pDashboardNamingDialog->width()) * 0.5;
|
||||
int nY = originPoint.y() + ui->navigationPanel->height() * 0.5;
|
||||
int nX = (ui->navigationPanel->width() - m_pDashboardNamingDialog->width()) * 0.5;
|
||||
int nY = ui->navigationPanel->y() + ui->navigationPanel->height() * 0.5;
|
||||
m_pDashboardNamingDialog->setGeometry(nX, nY, m_pDashboardNamingDialog->width(), m_pDashboardNamingDialog->height());
|
||||
m_pDashboardNamingDialog->showUsedForCreat();
|
||||
m_pDashboardNamingDialog->raise();
|
||||
}
|
||||
|
||||
void DashboardFrame::onBtnClicked_addDataPanel()
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ DashboardNamingDialog::DashboardNamingDialog(QWidget *parent)
|
|||
, ui(new Ui::dashboardNamingDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog);
|
||||
setWindowFlags(Qt::FramelessWindowHint);
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
|
||||
m_strUsedFor = "create";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "dvieMainWindow.h"
|
||||
#include "./ui_dvieMainWindow.h"
|
||||
#include "transparentMask.h"
|
||||
#include "dashboardFrame.h"
|
||||
#include "dvieSecondaryWindow.h"
|
||||
#include <QDateTime>
|
||||
|
|
@ -7,6 +8,7 @@
|
|||
DvieMainWindow::DvieMainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::dvieMainWindow)
|
||||
, m_pTransparentMask(nullptr)
|
||||
, m_pDashboardFrame(nullptr)
|
||||
|
||||
{
|
||||
|
|
@ -22,6 +24,20 @@ DvieMainWindow::~DvieMainWindow()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
void DvieMainWindow::showTransparentMask()
|
||||
{
|
||||
if(m_pTransparentMask == nullptr)
|
||||
m_pTransparentMask = new TransparentMask(this);
|
||||
|
||||
m_pTransparentMask->setGeometry(ui->topWidget->geometry());
|
||||
m_pTransparentMask->show();
|
||||
}
|
||||
void DvieMainWindow::hideTransparentMask()
|
||||
{
|
||||
if(m_pTransparentMask != nullptr && m_pTransparentMask->isVisible())
|
||||
m_pTransparentMask->hide();
|
||||
}
|
||||
|
||||
DashboardFrame* DvieMainWindow::dashboardFrame()
|
||||
{
|
||||
return m_pDashboardFrame;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "dvieSecondaryWindow.h"
|
||||
#include "./ui_dvieSecondaryWindow.h"
|
||||
#include "transparentMask.h"
|
||||
#include "dvieMainWindow.h"
|
||||
#include "dashboardFrame.h"
|
||||
#include <QCloseEvent>
|
||||
|
|
@ -8,6 +9,7 @@ DvieSecondaryWindow::DvieSecondaryWindow(const QString& strName, QWidget *parent
|
|||
: QMainWindow(parent)
|
||||
, ui(new Ui::dvieSecondaryWindow)
|
||||
, m_pMainWindow(nullptr)
|
||||
, m_pTransparentMask(nullptr)
|
||||
, m_pDashboardFrame(nullptr)
|
||||
|
||||
{
|
||||
|
|
@ -26,6 +28,20 @@ DvieSecondaryWindow::~DvieSecondaryWindow()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
void DvieSecondaryWindow::showTransparentMask()
|
||||
{
|
||||
if(m_pTransparentMask == nullptr)
|
||||
m_pTransparentMask = new TransparentMask(this);
|
||||
|
||||
m_pTransparentMask->setGeometry(ui->topWidget->geometry());
|
||||
m_pTransparentMask->show();
|
||||
}
|
||||
void DvieSecondaryWindow::hideTransparentMask()
|
||||
{
|
||||
if(m_pTransparentMask != nullptr && m_pTransparentMask->isVisible())
|
||||
m_pTransparentMask->hide();
|
||||
}
|
||||
|
||||
void DvieSecondaryWindow::closeEvent(QCloseEvent* e)
|
||||
{
|
||||
if(m_pMainWindow)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <QApplication>
|
||||
#include <QScreen>
|
||||
#include <QSysInfo>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
|
@ -17,9 +18,12 @@ int main(int argc, char *argv[])
|
|||
// int a = 1;
|
||||
// }
|
||||
|
||||
qputenv("QT_ENABLE_HIGHDPI_SCALING", "1");
|
||||
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
QString osName = QSysInfo::productType();
|
||||
qDebug() << "Operating System Name:" << osName;
|
||||
|
||||
// qputenv("QT_ENABLE_HIGHDPI_SCALING", "1");
|
||||
// QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||
// QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ MessageDialog::MessageDialog(QWidget *parent)
|
|||
, ui(new Ui::messageDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog | Qt::WindowDoesNotAcceptFocus);
|
||||
setWindowFlags(Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus);
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
ui->btnClose->setVisible(false);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ TransparentMask::TransparentMask(QWidget *parent)
|
|||
, ui(new Ui::transparentMask)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog | Qt::WindowDoesNotAcceptFocus);
|
||||
setWindowFlags(Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus);
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue