修改程序完成遮罩和子窗口在x11下的正常显示
This commit is contained in:
parent
8f602fd007
commit
2c4a54738b
|
|
@ -9,6 +9,7 @@ class dvieMainWindow;
|
||||||
}
|
}
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
class TransparentMask;
|
||||||
class Dashboard;
|
class Dashboard;
|
||||||
class DashboardFrame;
|
class DashboardFrame;
|
||||||
class DvieSecondaryWindow;
|
class DvieSecondaryWindow;
|
||||||
|
|
@ -21,6 +22,9 @@ public:
|
||||||
DvieMainWindow(QWidget *parent = nullptr);
|
DvieMainWindow(QWidget *parent = nullptr);
|
||||||
~DvieMainWindow();
|
~DvieMainWindow();
|
||||||
|
|
||||||
|
void showTransparentMask();
|
||||||
|
void hideTransparentMask();
|
||||||
|
|
||||||
DashboardFrame* dashboardFrame();
|
DashboardFrame* dashboardFrame();
|
||||||
DashboardFrame* getDashboardFrame(const QString&);
|
DashboardFrame* getDashboardFrame(const QString&);
|
||||||
void creatSecondaryWindowAndAddDashboard(QPoint, Dashboard*);
|
void creatSecondaryWindowAndAddDashboard(QPoint, Dashboard*);
|
||||||
|
|
@ -28,6 +32,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::dvieMainWindow* ui;
|
Ui::dvieMainWindow* ui;
|
||||||
|
TransparentMask* m_pTransparentMask;
|
||||||
DashboardFrame* m_pDashboardFrame;
|
DashboardFrame* m_pDashboardFrame;
|
||||||
QHash<QString, DvieSecondaryWindow*> m_hashSecondaryWindow;
|
QHash<QString, DvieSecondaryWindow*> m_hashSecondaryWindow;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ class dvieSecondaryWindow;
|
||||||
}
|
}
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
class TransparentMask;
|
||||||
class DvieMainWindow;
|
class DvieMainWindow;
|
||||||
class Dashboard;
|
class Dashboard;
|
||||||
class DashboardFrame;
|
class DashboardFrame;
|
||||||
|
|
@ -21,6 +22,9 @@ public:
|
||||||
DvieSecondaryWindow(const QString&, QWidget *parent = nullptr);
|
DvieSecondaryWindow(const QString&, QWidget *parent = nullptr);
|
||||||
~DvieSecondaryWindow();
|
~DvieSecondaryWindow();
|
||||||
|
|
||||||
|
void showTransparentMask();
|
||||||
|
void hideTransparentMask();
|
||||||
|
|
||||||
QString name();
|
QString name();
|
||||||
DashboardFrame* dashboardFrame();
|
DashboardFrame* dashboardFrame();
|
||||||
DashboardFrame* getDashboardFrame(const QString&);
|
DashboardFrame* getDashboardFrame(const QString&);
|
||||||
|
|
@ -32,6 +36,7 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::dvieSecondaryWindow* ui;
|
Ui::dvieSecondaryWindow* ui;
|
||||||
|
TransparentMask* m_pTransparentMask;
|
||||||
QString m_strName;
|
QString m_strName;
|
||||||
DvieMainWindow* m_pMainWindow;
|
DvieMainWindow* m_pMainWindow;
|
||||||
DashboardFrame* m_pDashboardFrame;
|
DashboardFrame* m_pDashboardFrame;
|
||||||
|
|
|
||||||
|
|
@ -129,27 +129,49 @@ void DashboardFrame::dropEvent(QDropEvent* event)
|
||||||
{
|
{
|
||||||
Dashboard* dashboard = fromFrame->takeDashboard(strTabText);
|
Dashboard* dashboard = fromFrame->takeDashboard(strTabText);
|
||||||
addDashboard(dashboard);
|
addDashboard(dashboard);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DashboardFrame::showTransparentMask()
|
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)
|
if(m_pTransparentMask == nullptr)
|
||||||
m_pTransparentMask = new TransparentMask(this);
|
m_pTransparentMask = new TransparentMask(this);
|
||||||
|
|
||||||
QPoint originPoint = QPoint(0, 0);
|
m_pTransparentMask->setGeometry(0, 0, this->width(), this->height());
|
||||||
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->show();
|
m_pTransparentMask->show();
|
||||||
}
|
}
|
||||||
void DashboardFrame::hideTransparentMask()
|
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())
|
if(m_pTransparentMask != nullptr && m_pTransparentMask->isVisible())
|
||||||
m_pTransparentMask->hide();
|
m_pTransparentMask->hide();
|
||||||
}
|
}
|
||||||
|
|
@ -164,13 +186,10 @@ void DashboardFrame::showMessageDialog(MessageDialogType type,const QString& str
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pMessageDialog->setMessage(type, strTitle, strContent);
|
m_pMessageDialog->setMessage(type, strTitle, strContent);
|
||||||
// QPoint originPoint = this->mapToGlobal(QPoint(0, 0));
|
int nX = (ui->navigationPanel->width() - m_pMessageDialog->width()) * 0.5;
|
||||||
// int nX = originPoint.x() + (this->width() - m_pMessageDialog->width()) * 0.5;
|
int nY = ui->navigationPanel->y() + ui->navigationPanel->height() * 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;
|
|
||||||
m_pMessageDialog->setGeometry(nX, nY, m_pMessageDialog->width(), m_pMessageDialog->height());
|
m_pMessageDialog->setGeometry(nX, nY, m_pMessageDialog->width(), m_pMessageDialog->height());
|
||||||
|
m_pMessageDialog->raise();
|
||||||
if(type == type_question)
|
if(type == type_question)
|
||||||
m_pMessageDialog->exec();
|
m_pMessageDialog->exec();
|
||||||
else
|
else
|
||||||
|
|
@ -181,20 +200,6 @@ void DashboardFrame::addDashboard(const QString& strName)
|
||||||
{
|
{
|
||||||
Dashboard* dashboard = new Dashboard(strName);
|
Dashboard* dashboard = new Dashboard(strName);
|
||||||
insertDashboard(m_listDashboard.count(), dashboard);
|
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)
|
void DashboardFrame::addDashboard(Dashboard* dashboard)
|
||||||
{
|
{
|
||||||
|
|
@ -409,11 +414,11 @@ void DashboardFrame::onBtnClicked_addDashboard()
|
||||||
}
|
}
|
||||||
|
|
||||||
showTransparentMask();
|
showTransparentMask();
|
||||||
QPoint originPoint = ui->navigationPanel->mapToGlobal(QPoint(0, 0));
|
int nX = (ui->navigationPanel->width() - m_pDashboardNamingDialog->width()) * 0.5;
|
||||||
int nX = originPoint.x() + (ui->navigationPanel->width() - m_pDashboardNamingDialog->width()) * 0.5;
|
int nY = ui->navigationPanel->y() + ui->navigationPanel->height() * 0.5;
|
||||||
int nY = originPoint.y() + ui->navigationPanel->height() * 0.5;
|
|
||||||
m_pDashboardNamingDialog->setGeometry(nX, nY, m_pDashboardNamingDialog->width(), m_pDashboardNamingDialog->height());
|
m_pDashboardNamingDialog->setGeometry(nX, nY, m_pDashboardNamingDialog->width(), m_pDashboardNamingDialog->height());
|
||||||
m_pDashboardNamingDialog->showUsedForCreat();
|
m_pDashboardNamingDialog->showUsedForCreat();
|
||||||
|
m_pDashboardNamingDialog->raise();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DashboardFrame::onBtnClicked_addDataPanel()
|
void DashboardFrame::onBtnClicked_addDataPanel()
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ DashboardNamingDialog::DashboardNamingDialog(QWidget *parent)
|
||||||
, ui(new Ui::dashboardNamingDialog)
|
, ui(new Ui::dashboardNamingDialog)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog);
|
setWindowFlags(Qt::FramelessWindowHint);
|
||||||
setAttribute(Qt::WA_TranslucentBackground);
|
setAttribute(Qt::WA_TranslucentBackground);
|
||||||
|
|
||||||
m_strUsedFor = "create";
|
m_strUsedFor = "create";
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include "dvieMainWindow.h"
|
#include "dvieMainWindow.h"
|
||||||
#include "./ui_dvieMainWindow.h"
|
#include "./ui_dvieMainWindow.h"
|
||||||
|
#include "transparentMask.h"
|
||||||
#include "dashboardFrame.h"
|
#include "dashboardFrame.h"
|
||||||
#include "dvieSecondaryWindow.h"
|
#include "dvieSecondaryWindow.h"
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
@ -7,6 +8,7 @@
|
||||||
DvieMainWindow::DvieMainWindow(QWidget *parent)
|
DvieMainWindow::DvieMainWindow(QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
, ui(new Ui::dvieMainWindow)
|
, ui(new Ui::dvieMainWindow)
|
||||||
|
, m_pTransparentMask(nullptr)
|
||||||
, m_pDashboardFrame(nullptr)
|
, m_pDashboardFrame(nullptr)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
@ -22,6 +24,20 @@ DvieMainWindow::~DvieMainWindow()
|
||||||
delete ui;
|
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()
|
DashboardFrame* DvieMainWindow::dashboardFrame()
|
||||||
{
|
{
|
||||||
return m_pDashboardFrame;
|
return m_pDashboardFrame;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include "dvieSecondaryWindow.h"
|
#include "dvieSecondaryWindow.h"
|
||||||
#include "./ui_dvieSecondaryWindow.h"
|
#include "./ui_dvieSecondaryWindow.h"
|
||||||
|
#include "transparentMask.h"
|
||||||
#include "dvieMainWindow.h"
|
#include "dvieMainWindow.h"
|
||||||
#include "dashboardFrame.h"
|
#include "dashboardFrame.h"
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
|
|
@ -8,6 +9,7 @@ DvieSecondaryWindow::DvieSecondaryWindow(const QString& strName, QWidget *parent
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
, ui(new Ui::dvieSecondaryWindow)
|
, ui(new Ui::dvieSecondaryWindow)
|
||||||
, m_pMainWindow(nullptr)
|
, m_pMainWindow(nullptr)
|
||||||
|
, m_pTransparentMask(nullptr)
|
||||||
, m_pDashboardFrame(nullptr)
|
, m_pDashboardFrame(nullptr)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
@ -26,6 +28,20 @@ DvieSecondaryWindow::~DvieSecondaryWindow()
|
||||||
delete ui;
|
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)
|
void DvieSecondaryWindow::closeEvent(QCloseEvent* e)
|
||||||
{
|
{
|
||||||
if(m_pMainWindow)
|
if(m_pMainWindow)
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
|
#include <QSysInfo>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
@ -17,9 +18,12 @@ int main(int argc, char *argv[])
|
||||||
// int a = 1;
|
// int a = 1;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
qputenv("QT_ENABLE_HIGHDPI_SCALING", "1");
|
QString osName = QSysInfo::productType();
|
||||||
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
qDebug() << "Operating System Name:" << osName;
|
||||||
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
|
||||||
|
// qputenv("QT_ENABLE_HIGHDPI_SCALING", "1");
|
||||||
|
// QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||||
|
// QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||||
|
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ MessageDialog::MessageDialog(QWidget *parent)
|
||||||
, ui(new Ui::messageDialog)
|
, ui(new Ui::messageDialog)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog | Qt::WindowDoesNotAcceptFocus);
|
setWindowFlags(Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus);
|
||||||
setAttribute(Qt::WA_TranslucentBackground);
|
setAttribute(Qt::WA_TranslucentBackground);
|
||||||
ui->btnClose->setVisible(false);
|
ui->btnClose->setVisible(false);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ TransparentMask::TransparentMask(QWidget *parent)
|
||||||
, ui(new Ui::transparentMask)
|
, ui(new Ui::transparentMask)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog | Qt::WindowDoesNotAcceptFocus);
|
setWindowFlags(Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus);
|
||||||
setAttribute(Qt::WA_TranslucentBackground);
|
setAttribute(Qt::WA_TranslucentBackground);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue