Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync: from linuxdeepin/dtkwidget #27

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
20 changes: 19 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,20 @@ 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);
} else {
lineEdit->setFont(q->font());
}
}

void DLineEditPrivate::init()
Expand Down Expand Up @@ -732,6 +748,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
Loading