-
Notifications
You must be signed in to change notification settings - Fork 0
/
layouts.cpp
65 lines (54 loc) · 1.77 KB
/
layouts.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "layouts.h"
#include <QWindow>
#include <QWidget>
#include <QFile>
#include <QXmlStreamReader>
#include <QDebug>
Layouts::Layouts(){
setWindowsIds();
}
// destructor
Layouts::~Layouts()
{
}
QVBoxLayout* Layouts::createlayoutLeftPanel(){
// check if the ids get converted
bool leftOk;
long left = m_leftPaneId.toLong(&leftOk, 16);
QVBoxLayout* layoutLeftPanel = new QVBoxLayout();
QWindow* leftPanelContainer = QWindow::fromWinId(left);
QWidget* leftPanelWidget = QWidget::createWindowContainer(leftPanelContainer);
layoutLeftPanel->addWidget(leftPanelWidget);
layoutLeftPanel->setContentsMargins(0, 0, 0, 0);
return layoutLeftPanel;
}
QVBoxLayout* Layouts::createlayoutRightPanel(){
// check if the ids get converted
bool rightOk;
long right = m_rightPaneId.toLong(&rightOk,16);
QVBoxLayout* layoutRightPanel = new QVBoxLayout();
QWindow* rightPanelContainer = QWindow::fromWinId(right);
QWidget* rightPanelWidget = QWidget::createWindowContainer(rightPanelContainer);
layoutRightPanel->addWidget(rightPanelWidget);
layoutRightPanel->setContentsMargins(0, 0, 0, 0);
return layoutRightPanel;
}
void Layouts::setWindowsIds()
{
QFile xmlFile(":/windowsId.xml");
if(!xmlFile.open(QFile::ReadOnly | QFile::Text)){
qDebug() << "Cannot read file" << xmlFile.errorString();
exit(0);
}
QXmlStreamReader xmlReader(&xmlFile);
if (xmlReader.readNextStartElement()){
while(xmlReader.readNextStartElement()){
if (xmlReader.name() =="leftpane") {
m_leftPaneId = xmlReader.readElementText();
}
else if (xmlReader.name() =="rightpane") {
m_rightPaneId = xmlReader.readElementText();
}
}
}
}