File: pagewindowinterface.cpp

package info (click to toggle)
dtkwidget 5.7.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 36,540 kB
  • sloc: cpp: 63,257; ansic: 132; python: 88; sh: 42; makefile: 13
file content (116 lines) | stat: -rw-r--r-- 3,257 bytes parent folder | download
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// SPDX-FileCopyrightText: 2020 - 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "pagewindowinterface.h"
#include "examplewindowinterface.h"

#include <DFrame>

#include <QLabel>
#include <QHBoxLayout>
#include <QDebug>
#include <QScrollArea>

DWIDGET_USE_NAMESPACE

PageWindowInterface::PageWindowInterface(QWidget *parent)
    : QWidget(parent)
{
}

PageWindowInterface::~PageWindowInterface()
{
}

QWidget *PageWindowInterface::doLayout(ExampleWindowInterface *pExample)
{
    Q_ASSERT(pExample != nullptr);

    DFrame *pWidget = new DFrame;
    pWidget->setFrameRounded(true);

    QLabel *pDescriptionLabel = new QLabel;
    pDescriptionLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    pDescriptionLabel->setFixedWidth(292);
    pDescriptionLabel->setFixedHeight(pExample->getFixedHeight());

    QLabel *pLabel_1 = new QLabel;
    pLabel_1->setTextInteractionFlags(Qt::TextBrowserInteraction);
    pLabel_1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    QFont font_1;
    font_1.setPixelSize(24);
    pLabel_1->setFont(font_1);
    pLabel_1->setText(pExample->getTitleName());

    QLabel *pLabel_2 = new QLabel;
    pLabel_2->setTextInteractionFlags(Qt::TextBrowserInteraction);
    pLabel_2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    QFont font_2;
    font_2.setPixelSize(12);
    pLabel_2->setFont(font_2);
    pLabel_2->setText(pExample->getDescriptionInfo());

    QVBoxLayout *pVBoxLayout_label = new QVBoxLayout;
    pVBoxLayout_label->setContentsMargins(10, 10, 10, 10);
    pVBoxLayout_label->setSpacing(0);
    pDescriptionLabel->setLayout(pVBoxLayout_label);

    pVBoxLayout_label->addWidget(pLabel_1);
    pVBoxLayout_label->setSpacing(10);
    pVBoxLayout_label->addWidget(pLabel_2);
    pVBoxLayout_label->addStretch();

    QHBoxLayout *pHBoxLayout = new QHBoxLayout;
    pHBoxLayout->setContentsMargins(0, 0, 0, 0);
    pHBoxLayout->setSpacing(0);

    pWidget->setLayout(pHBoxLayout);

    pExample->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    pHBoxLayout->addWidget(pDescriptionLabel);
    pHBoxLayout->addWidget(new DVerticalLine);
    pHBoxLayout->addWidget(pExample);

    pWidget->setFixedHeight(pExample->getFixedHeight());

    return pWidget;
}

void PageWindowInterface::initPageWindow()
{
    QScrollArea *pArea = new QScrollArea(this);

    QWidget *pWidget = new QWidget(this);

    QVBoxLayout *pVBoxLayout = new QVBoxLayout;
    pVBoxLayout->setContentsMargins(10, 10, 10, 10);
    pVBoxLayout->setSpacing(10);
    pWidget->setLayout(pVBoxLayout);

    for (auto pExample : m_exampleList) {
        pVBoxLayout->addWidget(doLayout(pExample));
    }

    pVBoxLayout->addStretch();

    pArea->setWidget(pWidget);
    pArea->setWidgetResizable(true);

    QHBoxLayout *pHBoxLayout = new QHBoxLayout;
    pHBoxLayout->setContentsMargins(0, 0, 0, 0);
    pHBoxLayout->setSpacing(0);
    setLayout(pHBoxLayout);
    pHBoxLayout->addWidget(pArea);
}

void PageWindowInterface::mouseMoveEvent(QMouseEvent *event)
{
    //屏蔽掉鼠标移动事件
    event->accept();
}

void PageWindowInterface::addExampleWindow(ExampleWindowInterface *pExample)
{
    m_exampleList << pExample;
}