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#553
  • Loading branch information
deepin-ci-robot committed Mar 5, 2024
1 parent 45fc32d commit 2b252d2
Show file tree
Hide file tree
Showing 12 changed files with 165 additions and 70 deletions.
11 changes: 8 additions & 3 deletions examples/collections/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,18 @@ MainWindow::MainWindow(QWidget *parent)
m_pStackedWidget = new QStackedWidget;
m_pListViewModel = new QStandardItemModel(this);

m_pListView = new DListView(this);
QWidget *pw = new QWidget(this);
m_pListView = new DListView(pw);
m_pListView->setFixedWidth(200);
m_pListView->setItemSpacing(0);
m_pListView->setModel(m_pListViewModel);
m_pListView->setViewportMargins(0, 0, 10, 0);

setSidebarWidget(m_pListView);
setSidebarWidth(200);
QHBoxLayout *hlay = new QHBoxLayout(pw);
hlay->setContentsMargins(10, 0, 10, 0);
hlay->addWidget(m_pListView);
setSidebarWidget(pw);
setSidebarWidth(210);

// mainLayout->addWidget(m_pListView);

Expand Down
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
4 changes: 2 additions & 2 deletions src/widgets/dblureffectwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ QColor DBlurEffectWidgetPrivate::getMaskColor(const QColor &baseColor) const

int maskAlpha = this->getMaskColorAlpha();

if (!isBehindWindowBlendMode() || DWindowManagerHelper::instance()->hasComposite()) {
if (!isBehindWindowBlendMode() || DWindowManagerHelper::instance()->hasBlurWindow()) {
color.setAlpha(maskAlpha);
} else {
return ct == DGuiApplicationHelper::DarkType ? "#202020" : "#D2D2D2";
Expand All @@ -158,7 +158,7 @@ void DBlurEffectWidgetPrivate::setMaskColor(const QColor &color)
maskColor = color;

if (isBehindWindowBlendMode()) {
maskColor.setAlpha(DWindowManagerHelper::instance()->hasComposite() ? getMaskColorAlpha() : MASK_COLOR_ALPHA_DEFAULT);
maskColor.setAlpha(DWindowManagerHelper::instance()->hasBlurWindow() ? getMaskColorAlpha() : MASK_COLOR_ALPHA_DEFAULT);
}

D_Q(DBlurEffectWidget);
Expand Down
23 changes: 22 additions & 1 deletion src/widgets/dlineedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ void DLineEdit::setEchoMode(QLineEdit::EchoMode mode)
{
D_D(DLineEdit);
d->lineEdit->setEchoMode(mode);
d->updateFont();
}

/*!
Expand Down Expand Up @@ -667,6 +668,8 @@ bool DLineEdit::eventFilter(QObject *watched, QEvent *event)
event->accept();
pLineEdit->setFocus();
return true;
} else if (event->type() == QEvent::FontChange) {
d->updateFont();
}

// if (d->frame)
Expand Down Expand Up @@ -702,7 +705,22 @@ DLineEditPrivate::DLineEditPrivate(DLineEdit *q)

void DLineEditPrivate::updateTooltipPos()
{
//control->updateTooltipPos();
}

void DLineEditPrivate::updateFont()
{
Q_Q(DLineEdit);

if (lineEdit->echoMode() == QLineEdit::Password) {
QFont passwordFont = lineEdit->font();
passwordFont.setPixelSize(6);
passwordFont.setLetterSpacing(passwordFont.letterSpacingType(), 200);
lineEdit->setFont(passwordFont);
qWarning() << "1111111111";
} else {
lineEdit->setFont(q->font());
qWarning() << "0000000000";
}
}

void DLineEditPrivate::init()
Expand All @@ -714,6 +732,7 @@ void DLineEditPrivate::init()
q->setFocusProxy(lineEdit); // fix DlineEdit setFocut but lineEdit can not edit(without focus rect)
q->setFocusPolicy(lineEdit->focusPolicy());


control = new DAlertControl(lineEdit, q);
q->connect(control, &DAlertControl::alertChanged, q, &DLineEdit::alertChanged);

Expand All @@ -732,6 +751,8 @@ void DLineEditPrivate::init()
q->connect(lineEdit, &QLineEdit::returnPressed, q, &DLineEdit::returnPressed);
q->connect(lineEdit, &QLineEdit::editingFinished, q, &DLineEdit::editingFinished);
q->connect(lineEdit, &QLineEdit::selectionChanged, q, &DLineEdit::selectionChanged);

updateFont();
}

DWIDGET_END_NAMESPACE
Loading

0 comments on commit 2b252d2

Please sign in to comment.