Skip to content

Commit

Permalink
sync: from linuxdeepin/dtkwidget
Browse files Browse the repository at this point in the history
Synchronize source files from linuxdeepin/dtkwidget.

Source-pull-request: linuxdeepin/dtkwidget#546
  • Loading branch information
deepin-ci-robot committed Jan 30, 2024
1 parent 45fc32d commit 1691488
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 34 deletions.
101 changes: 67 additions & 34 deletions src/widgets/daboutdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
DCORE_USE_NAMESPACE
DWIDGET_BEGIN_NAMESPACE

const QString DAboutDialogPrivate::websiteLinkTemplate = "<a href='%1' style='text-decoration: none; font-size:13px; color: #004EE5;'>%2</a>";
const QString DAboutDialogPrivate::websiteLinkTemplate = "<a href='%1' style='text-decoration: none; font-size:12px; color: rgba(0,129,255,0.9);'>%2</a>";

DRedPointLabel::DRedPointLabel(QWidget *parent)
: QLabel(parent)
Expand Down Expand Up @@ -62,25 +62,31 @@ void DAboutDialogPrivate::init()
{
D_Q(DAboutDialog);

q->setMaximumWidth(540);
q->setFixedSize(540, 290);

// overwrite default info if distribution config file existed.
loadDistributionInfo();

logoLabel = new QLabel();
logoLabel->setContentsMargins(0, 0, 0, 0);
logoLabel->setAlignment(Qt::AlignCenter);

productNameLabel = new QLabel();
productNameLabel->setForegroundRole(QPalette::BrightText);
productNameLabel->setObjectName("ProductNameLabel");
productNameLabel->setWordWrap(true);
productNameLabel->setAlignment(Qt::AlignCenter);
DFontSizeManager *fontManager = DFontSizeManager::instance();
fontManager->bind(productNameLabel, DFontSizeManager::T5, QFont::DemiBold);
fontManager->bind(productNameLabel, DFontSizeManager::T5, QFont::Medium);

versionLabel = new QLabel();
versionLabel->setObjectName("VersionLabel");
fontManager->bind(versionLabel, DFontSizeManager::T8, QFont::DemiBold);
versionLabel->setForegroundRole(QPalette::BrightText);
fontManager->bind(versionLabel, DFontSizeManager::T8, QFont::Medium);

companyLogoLabel = new QLabel();
companyLogoLabel->setPixmap(loadPixmap(logoPath));
companyLogoLabel->hide();

websiteLabel = new QLabel();
websiteLabel->setObjectName("WebsiteLabel");
Expand All @@ -89,24 +95,26 @@ void DAboutDialogPrivate::init()
updateWebsiteLabel();

descriptionLabel = new QLabel();
descriptionLabel->setForegroundRole(QPalette::BrightText);
descriptionLabel->setFixedWidth(280);
descriptionLabel->setObjectName("DescriptionLabel");
descriptionLabel->setAlignment(Qt::AlignLeft);
descriptionLabel->setWordWrap(true);
descriptionLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
fontManager->bind(descriptionLabel, DFontSizeManager::T8, QFont::DemiBold);
fontManager->bind(descriptionLabel, DFontSizeManager::T8, QFont::Medium);

licenseLabel = new QLabel();
licenseLabel->setFixedWidth(180);
licenseLabel->setObjectName("LicenseLabel");
licenseLabel->setAlignment(Qt::AlignHCenter);
licenseLabel->setWordWrap(true);
licenseLabel->setForegroundRole(QPalette::BrightText);
licenseLabel->setFixedWidth(280);
licenseLabel->setAlignment(Qt::AlignLeft);
licenseLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
fontManager->bind(licenseLabel, DFontSizeManager::T8, QFont::Medium);
licenseLabel->hide();
fontManager->bind(licenseLabel, DFontSizeManager::T10, QFont::Medium);

QLabel *versionTipLabel = new QLabel(QObject::tr("Version"));
fontManager->bind(versionTipLabel, DFontSizeManager::T10, QFont::Normal);
fontManager->bind(versionTipLabel, DFontSizeManager::T10, QFont::Thin);
featureLabel = new QLabel(websiteLinkTemplate.arg(websiteLink).arg(QObject::tr("Features")));
featureLabel->setContextMenuPolicy(Qt::NoContextMenu);
featureLabel->setOpenExternalLinks(false);
Expand All @@ -123,37 +131,53 @@ void DAboutDialogPrivate::init()
vFeatureLayout->addWidget(redPointLabel, 0, Qt::AlignLeft);
vFeatureLayout->addStretch(0);
QLabel *homePageTipLabel = new QLabel(QObject::tr("Homepage"));
fontManager->bind(homePageTipLabel, DFontSizeManager::T10, QFont::Normal);
fontManager->bind(homePageTipLabel, DFontSizeManager::T10, QFont::Thin);
QLabel *descriptionTipLabel = new QLabel(QObject::tr("Description"));
fontManager->bind(descriptionTipLabel, DFontSizeManager::T10, QFont::Normal);
fontManager->bind(descriptionTipLabel, DFontSizeManager::T10, QFont::Thin);
acknowledgementTipLabel = new QLabel(QObject::tr("Acknowledgements"));
fontManager->bind(acknowledgementTipLabel, DFontSizeManager::T10, QFont::Normal);
fontManager->bind(acknowledgementTipLabel, DFontSizeManager::T10, QFont::Thin);
licenseTipLabel = new QLabel(QObject::tr("License"));
fontManager->bind(licenseTipLabel, DFontSizeManager::T10, QFont::Thin);
licenseTipLabel->hide();

acknowledgementLabel = new QLabel(QObject::tr("Sincerely appreciate the open-source software used."));
acknowledgementLabel->setForegroundRole(QPalette::BrightText);
acknowledgementLabel->setFixedWidth(280);
acknowledgementLabel->setWordWrap(true);
acknowledgementLabel->setContextMenuPolicy(Qt::NoContextMenu);
acknowledgementLabel->setOpenExternalLinks(false);
fontManager->bind(acknowledgementLabel, DFontSizeManager::T8, QFont::DemiBold);
fontManager->bind(acknowledgementLabel, DFontSizeManager::T8, QFont::Medium);

q->connect(websiteLabel, SIGNAL(linkActivated(QString)), q, SLOT(_q_onLinkActivated(QString)));
q->connect(featureLabel, SIGNAL(linkActivated(QString)), q, SLOT(_q_onFeatureActivated(QString)));
q->connect(descriptionLabel, SIGNAL(linkActivated(QString)), q, SLOT(_q_onLinkActivated(QString)));
q->connect(licenseLabel, SIGNAL(linkActivated(QString)), q, SLOT(_q_onLinkActivated(QString)));
q->connect(acknowledgementLabel, SIGNAL(linkActivated(QString)), q, SLOT(_q_onLicenseActivated(QString)));

QScrollArea *productNameScrollArea = new QScrollArea;
productNameScrollArea->setMaximumHeight(50);
productNameScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAlwaysOff);
productNameScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAlwaysOff);
QPalette scrollPalette;

scrollPalette.setBrush(QPalette::Window, Qt::transparent);
productNameScrollArea->setFrameShape(QFrame::NoFrame);
productNameScrollArea->setWidget(productNameLabel);
productNameScrollArea->setWidgetResizable(true);
productNameScrollArea->setPalette(scrollPalette);

QVBoxLayout *leftVLayout = new QVBoxLayout;
leftVLayout->setContentsMargins(10, 3, 0, 10);
leftVLayout->setSpacing(0);
leftVLayout->addWidget(logoLabel, 0, Qt::AlignCenter);
leftVLayout->setContentsMargins(0, 10, 0, 0);
leftVLayout->addWidget(logoLabel);
leftVLayout->addSpacing(8);
leftVLayout->addWidget(productNameLabel, 0, Qt::AlignCenter);
leftVLayout->addStretch(0);
leftVLayout->addWidget(companyLogoLabel, 0, Qt::AlignCenter);
leftVLayout->addWidget(productNameScrollArea);
leftVLayout->addSpacing(16);
leftVLayout->addWidget(companyLogoLabel);
leftVLayout->addSpacing(3);
leftVLayout->addWidget(licenseLabel, 0, Qt::AlignHCenter);
leftVLayout->addStretch(0);

QVBoxLayout *rightVLayout = new QVBoxLayout;
rightVLayout->setContentsMargins(0, 3, 20, 10);
rightVLayout->setContentsMargins(0, 0, 10, 0);
rightVLayout->setSpacing(0);
rightVLayout->addWidget(versionTipLabel, 0, Qt::AlignLeft);
rightVLayout->addWidget(versionLabel, 0, Qt::AlignLeft);
Expand All @@ -167,27 +191,35 @@ void DAboutDialogPrivate::init()
rightVLayout->addSpacing(10);
rightVLayout->addWidget(acknowledgementTipLabel, 0, Qt::AlignLeft);
rightVLayout->addWidget(acknowledgementLabel, 0, Qt::AlignLeft);
rightVLayout->addSpacing(10);
rightVLayout->addWidget(licenseTipLabel, 0, Qt::AlignLeft);
rightVLayout->addWidget(licenseLabel, 0, Qt::AlignLeft);
rightVLayout->addStretch(0);

QScrollArea *rightScrollArea = new QScrollArea;
rightScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAlwaysOff);
rightScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAlwaysOff);
QWidget *rightContent = new QWidget;
rightContent->setLayout(rightVLayout);

rightScrollArea->setFrameShape(QFrame::NoFrame);
rightScrollArea->setWidget(rightContent);
rightScrollArea->setWidgetResizable(true);
rightScrollArea->setPalette(scrollPalette);

QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->setSpacing(0);
mainLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->addLayout(leftVLayout);
mainLayout->addSpacing(29);
mainLayout->addLayout(rightVLayout);
mainLayout->setSpacing(0);
mainLayout->setMargin(0);
mainLayout->addLayout(leftVLayout, 2);
mainLayout->addSpacing(20);
mainLayout->addWidget(rightScrollArea, 3);

QScrollArea *mainScrollArea = new QScrollArea;
QWidget *mainContent = new QWidget;
QPalette scrollPalette;

scrollPalette.setBrush(QPalette::Window, Qt::transparent);
mainScrollArea->setFrameShape(QFrame::NoFrame);
mainScrollArea->setWidget(mainContent);
mainScrollArea->setWidgetResizable(true);
mainScrollArea->setPalette(scrollPalette);

mainContent->setLayout(mainLayout);
q->addContent(mainScrollArea);
q->addContent(mainContent);
q->setContentsMargins(0, 0, 0, 10);

DConfig config("org.deepin.dtk.preference");
bool isUpdated = config.value("featureUpdated", false).toBool();
Expand Down Expand Up @@ -540,6 +572,7 @@ void DAboutDialog::setLicense(const QString &license)

d->licenseLabel->setText(license);
d->licenseLabel->setVisible(!license.isEmpty());
d->licenseTipLabel->setVisible(!license.isEmpty());
}

void DAboutDialog::keyPressEvent(QKeyEvent *event)
Expand Down
1 change: 1 addition & 0 deletions src/widgets/private/daboutdialog_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class DAboutDialogPrivate : public DDialogPrivate
QLabel *productNameLabel = nullptr;
QLabel *versionLabel = nullptr;
QLabel *descriptionLabel = nullptr;
QLabel *licenseTipLabel = nullptr;
QLabel *licenseLabel = nullptr;
QLabel *companyLogoLabel = nullptr;
QLabel *websiteLabel = nullptr;
Expand Down

0 comments on commit 1691488

Please sign in to comment.