Skip to content

Commit d59b3ce

Browse files
pppanghu77deepin-bot[bot]
authored andcommitted
fix: [ui] fix ui bug 108
fix ui bug Log: fix ui bug Bug: https://pms.uniontech.com/bug-view-256019.html
1 parent a976c75 commit d59b3ce

9 files changed

+97
-28
lines changed

src/configs/settings/settings.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ bool Settings::setValueNoNotify(const QString &group, const QString &key, const
447447

448448
changed = true;
449449
} else {
450-
changed = this->value(group, key, value) != value;
450+
changed = this->value(group, key) != value;
451451
}
452452

453453
d->writableData.setValue(group, key, value);

src/plugins/cooperation/core/gui/dialogs/transferdialog.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
#include <QMovie>
88

9+
#include <maincontroller/maincontroller.h>
10+
911
using namespace cooperation_core;
1012
#ifdef linux
1113
static constexpr char Ktransfer_success[] = "transfer_success";
@@ -134,6 +136,11 @@ void TransferDialog::createProgressPage()
134136
vLayout->addWidget(progressMsgLael);
135137
}
136138

139+
bool TransferDialog::isInProgress() const
140+
{
141+
return stackedLayout->currentIndex() == 2;
142+
}
143+
137144
void TransferDialog::switchWaitConfirmPage()
138145
{
139146
stackedLayout->setCurrentIndex(0);

src/plugins/cooperation/core/gui/dialogs/transferdialog.h

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ class TransferDialog : public CooperationDialog
2424
void switchResultPage(bool success, const QString &msg);
2525
void switchProgressPage(const QString &title);
2626

27+
bool isInProgress() const;
28+
2729
public Q_SLOTS:
2830
void updateProgress(int value, const QString &remainTime);
2931

src/plugins/cooperation/core/gui/widgets/cooperationstatewidget.cpp

+53-19
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ void NoNetworkWidget::initUI()
143143
QVBoxLayout *vLayout = new QVBoxLayout;
144144
vLayout->setContentsMargins(0, 0, 0, 0);
145145
vLayout->setSpacing(0);
146-
vLayout->addSpacing(116);
146+
vLayout->addStretch();
147147
vLayout->addWidget(iconLabel, 0, Qt::AlignCenter);
148148
vLayout->addSpacing(14);
149149
vLayout->addWidget(tipsLabel, 0, Qt::AlignCenter);
@@ -242,12 +242,34 @@ void NoResultTipWidget::initUI()
242242
#endif
243243
}
244244

245+
void NoResultTipWidget::paintEvent(QPaintEvent *event)
246+
{
247+
if (useTipMode) {
248+
QWidget::paintEvent(event);
249+
return;
250+
}
251+
QPainter painter(this);
252+
QColor color;
253+
254+
if (CooperationGuiHelper::isDarkTheme())
255+
color.setRgb(255, 255, 255, static_cast<int>(255 * 0.05));
256+
else
257+
color.setRgb(0, 0, 0, static_cast<int>(255 * 0.05));
258+
painter.fillRect(rect(), color);
259+
QWidget::paintEvent(event);
260+
}
261+
245262
NoResultWidget::NoResultWidget(QWidget *parent)
246263
: QWidget(parent)
247264
{
248265
initUI();
249266
}
250267

268+
void NoResultWidget::mousePressEvent(QMouseEvent *event)
269+
{
270+
Q_UNUSED(event);
271+
}
272+
251273
void NoResultWidget::initUI()
252274
{
253275
setFocusPolicy(Qt::ClickFocus);
@@ -265,42 +287,42 @@ void NoResultWidget::initUI()
265287
font.setWeight(QFont::Medium);
266288
tipsLabel->setFont(font);
267289

268-
BackgroundWidget *contentBackgroundWidget = new BackgroundWidget(this);
269-
contentBackgroundWidget->setBackground(17, BackgroundWidget::ItemBackground,
270-
BackgroundWidget::TopAndBottom);
290+
BackgroundWidget *backgroundWidget = new BackgroundWidget(this);
291+
QScrollArea *scrollArea = new QScrollArea();
292+
backgroundWidget->setBackground(17, BackgroundWidget::ItemBackground,
293+
BackgroundWidget::TopAndBottom);
271294

272295
QVBoxLayout *contentLayout = new QVBoxLayout;
273296
NoResultTipWidget *noResultTipWidget = new NoResultTipWidget();
274297
noResultTipWidget->setTitleVisible(false);
275-
contentLayout->addWidget(noResultTipWidget);
276-
contentBackgroundWidget->setLayout(contentLayout);
298+
backgroundWidget->setLayout(contentLayout);
277299

278300
QVBoxLayout *vLayout = new QVBoxLayout;
279301
vLayout->setContentsMargins(0, 0, 0, 0);
280302

281-
QSpacerItem *sp_1 = new QSpacerItem(20, 88, QSizePolicy::Minimum, QSizePolicy::Expanding);
282-
QSpacerItem *sp_2 = new QSpacerItem(20, 14, QSizePolicy::Minimum, QSizePolicy::Expanding);
283-
QSpacerItem *sp_3 = new QSpacerItem(20, 22, QSizePolicy::Minimum, QSizePolicy::Expanding);
303+
QSpacerItem *sp_1 = new QSpacerItem(20, 70, QSizePolicy::Minimum, QSizePolicy::Expanding);
284304

285305
vLayout->addItem(sp_1);
286306
vLayout->addWidget(iconLabel, 0, Qt::AlignCenter);
287-
vLayout->addItem(sp_2);
307+
vLayout->addSpacing(10);
288308
vLayout->addWidget(tipsLabel, 0, Qt::AlignCenter);
289-
vLayout->addItem(sp_3);
290-
QScrollArea *scrollArea = new QScrollArea();
309+
vLayout->addSpacing(10);
310+
291311
scrollArea->setWidgetResizable(true);
292-
scrollArea->setWidget(contentBackgroundWidget);
312+
contentLayout->addWidget(scrollArea);
313+
contentLayout->setSpacing(0);
314+
scrollArea->setWidget(noResultTipWidget);
293315

294316
#ifndef __linux__
295317
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
296318
#endif
297-
scrollArea->setWidget(contentBackgroundWidget);
298319
scrollArea->show();
299320
scrollArea->setFrameStyle(QFrame::NoFrame);
300-
vLayout->addWidget(scrollArea);
321+
vLayout->addWidget(backgroundWidget);
301322

302323
vLayout->addSpacerItem(new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding));
303324
setLayout(vLayout);
325+
backgroundWidget->setMaximumHeight(129);
304326
}
305327

306328
BottomLabel::BottomLabel(QWidget *parent)
@@ -340,8 +362,7 @@ void BottomLabel::initUI()
340362
{
341363
QString ip = QString(tr("Local IP: %1").arg(CooperationUtil::localIPAddress()));
342364
ipLabel = new QLabel(ip);
343-
ipLabel->setAlignment(Qt::AlignHCenter);
344-
ipLabel->setFixedHeight(30);
365+
ipLabel->setAlignment(Qt::AlignCenter);
345366
connect(MainController::instance(), &MainController::onlineStateChanged, this, [this](bool isOnline) {
346367
if (!isOnline)
347368
return;
@@ -354,6 +375,7 @@ void BottomLabel::initUI()
354375
QScrollArea *scrollArea = new QScrollArea(dialog);
355376
tipLabel = new QLabel(qobject_cast<QWidget *>(this->parent()));
356377
tipLabel->installEventFilter(this);
378+
ipLabel->setFixedSize(500, 33);
357379

358380
#ifdef linux
359381
updateSizeMode();
@@ -373,7 +395,7 @@ void BottomLabel::initUI()
373395
scrollArea->setStyleSheet("QScrollArea { border: none; background-color: transparent; }");
374396
#endif
375397

376-
dialog->setFixedSize(260, 208);
398+
dialog->setFixedSize(260, 210);
377399
scrollArea->setWidgetResizable(true);
378400
QWidget *contentWidget = new QWidget;
379401

@@ -383,10 +405,21 @@ void BottomLabel::initUI()
383405
NoResultTipWidget *tipWidgt = new NoResultTipWidget(scrollArea, true);
384406
layout->addWidget(tipWidgt);
385407
scrollArea->setWidget(contentWidget);
408+
scrollArea->setFrameStyle(QFrame::NoFrame);
409+
410+
QWidget *topSpace = new QWidget();
411+
topSpace->setFixedHeight(5);
412+
topSpace->setAutoFillBackground(true);
413+
QWidget *bottomSpace = new QWidget();
414+
bottomSpace->setFixedHeight(5);
415+
bottomSpace->setAutoFillBackground(true);
386416

387417
QVBoxLayout *contentLayout = new QVBoxLayout;
388418
contentLayout->setContentsMargins(0, 0, 0, 0);
419+
contentLayout->setSpacing(0);
420+
contentLayout->addWidget(topSpace);
389421
contentLayout->addWidget(scrollArea);
422+
contentLayout->addWidget(bottomSpace);
390423
contentLayout->setAlignment(Qt::AlignCenter);
391424

392425
dialog->setLayout(contentLayout);
@@ -397,7 +430,8 @@ void BottomLabel::initUI()
397430

398431
QVBoxLayout *mainLayout = new QVBoxLayout;
399432
mainLayout->addWidget(ipLabel);
400-
mainLayout->setAlignment(Qt::AlignHCenter);
433+
mainLayout->setAlignment(Qt::AlignCenter);
434+
mainLayout->setContentsMargins(0, 0, 0, 0);
401435
setLayout(mainLayout);
402436

403437
timer = new QTimer(this);

src/plugins/cooperation/core/gui/widgets/cooperationstatewidget.h

+4
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class NoResultTipWidget : public QWidget
5252
void onLinkActivated(const QString &link);
5353
void setTitleVisible(bool visible);
5454

55+
protected:
56+
void paintEvent(QPaintEvent *event) override;
5557
private:
5658
void initUI();
5759
CooperationLabel *titleLabel { nullptr };
@@ -63,6 +65,8 @@ class NoResultWidget : public QWidget
6365
Q_OBJECT
6466
public:
6567
explicit NoResultWidget(QWidget *parent = nullptr);
68+
void mousePressEvent(QMouseEvent *event) override;
69+
6670

6771
private:
6872
void initUI();

src/plugins/cooperation/core/gui/widgets/firsttipwidget.cpp

+21-8
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@ FirstTipWidget::FirstTipWidget(QWidget *parent)
2828
void FirstTipWidget::themeTypeChanged()
2929
{
3030
if (CooperationGuiHelper::instance()->isDarkTheme()) {
31-
shadowEffect->setColor(QColor(122, 192, 255, 128));
31+
shadowEffect->setColor(QColor(10, 57, 99, 128));
3232
bannerLabel->setPixmap(QIcon::fromTheme(":/icons/deepin/builtin/dark/icons/banner_128px.png").pixmap(234, 158));
33-
3433
} else {
35-
shadowEffect->setColor(QColor(10, 57, 99, 128));
34+
shadowEffect->setColor(QColor(122, 192, 255, 128));
3635
bannerLabel->setPixmap(QIcon::fromTheme(":/icons/deepin/builtin/light/icons/banner_128px.png").pixmap(234, 158));
3736
}
3837
if (!qApp->property("onlyTransfer").toBool())
@@ -46,7 +45,7 @@ void FirstTipWidget::showEvent(QShowEvent *event)
4645
{
4746
auto ge = lineBalls.last()->geometry();
4847

49-
line->setGeometry(32, 26, qApp->devicePixelRatio(), ge.y() - 26);
48+
line->setGeometry(32, 32, qApp->devicePixelRatio(), ge.y() - 32);
5049
QWidget::showEvent(event);
5150
}
5251

@@ -81,7 +80,7 @@ void FirstTipWidget::initbackgroundFrame()
8180
QString backdarkStyle = ".QFrame { background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(132, 141, 179, 0.24), stop:1 rgba(224, 225, 255, 0.12)); "
8281
"border-radius: 10px;"
8382
"color: rgba(0, 0, 0, 0.6);"
84-
"border: 1px solid rgba(0, 0, 0, 0.05); } ";
83+
"border: 1px solid rgba(255, 255, 255, 0.05); } ";
8584
CooperationGuiHelper::initThemeTypeConnect(backgroundFrame, backlightStyle, backdarkStyle);
8685
backgroundFrame->setFixedWidth(480);
8786

@@ -116,12 +115,14 @@ void FirstTipWidget::initbackgroundFrame()
116115

117116
QLabel *lineball = new QLabel(this);
118117
lineBalls.append(lineball);
119-
lineball->setFixedSize(12, 12);
118+
lineball->setFixedSize(12, 14);
120119
QString balllightStyle = "background-color: rgb(33, 138, 244); "
121120
"border-radius: 6px;"
121+
"margin-top: 2px;"
122122
"border: 1px solid white;";
123123
QString balldarkStyle = "background-color: rgb(0, 89, 210); "
124124
"border-radius: 6px;"
125+
"margin-top: 2px;" //用style画圆形背景会出现顶部被切割,规避一下
125126
"border: 1px solid white; ";
126127
CooperationGuiHelper::initThemeTypeConnect(lineball, balllightStyle, balldarkStyle);
127128
lineball->setGraphicsEffect(shadowEffect);
@@ -204,8 +205,13 @@ void FirstTipWidget::inittipBtn()
204205
flag.close();
205206
setVisible(false);
206207
});
207-
tipBtn->setStyleSheet("QToolButton { background-color: rgba(0, 0, 0, 0.1); border-radius: 9px; }"
208-
"QToolButton::hover { background-color: rgba(0, 0, 0, 0.2); border-radius: 9px; }");
208+
209+
tipBtn->setFixedSize(18, 20);
210+
QString lightStyle = "QToolButton { background-color: rgba(0, 0, 0, 0.1); margin-top: 2px; border-radius: 9px; }"
211+
"QToolButton::hover { background-color: rgba(0, 0, 0, 0.15); margin-top: 2px; border-radius: 9px; }";
212+
QString darkStyle = "QToolButton { background-color: rgba(255, 255, 255, 0.1); margin-top: 2px; border-radius: 9px; }"
213+
"QToolButton::hover { background-color: rgba(255, 255, 255, 0.2); margin-top: 2px; border-radius: 9px; }";
214+
CooperationGuiHelper::initThemeTypeConnect(tipBtn, lightStyle, darkStyle);
209215
}
210216

211217
void FirstTipWidget::setVisible(bool visible)
@@ -244,7 +250,14 @@ void LineWidget::paintEvent(QPaintEvent *event)
244250
int x = width() / 2;
245251
int y = 0;
246252
int dashLength = 4; // 每段虚线的长度
253+
int mid = 0;
247254
while (y < height()) {
255+
//中间一段不画,不然就画到圆圈上了
256+
if (mid < 1 && y > height() / 2 - 8) {
257+
mid++;
258+
y += 4 * dashLength;
259+
continue;
260+
}
248261
painter.drawLine(x, y, x, qMin(y + dashLength, height()));
249262
y += 2 * dashLength; // 虚线间距
250263
}

src/plugins/cooperation/core/gui/widgets/workspacewidget.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ void WorkspaceWidgetPrivate::initUI()
6767
stackedLayout->addWidget(nnWidget);
6868
stackedLayout->addWidget(nrWidget);
6969
stackedLayout->addWidget(dlWidget);
70+
stackedLayout->setAlignment(Qt::AlignCenter);
7071
stackedLayout->setCurrentIndex(0);
7172

7273
QVBoxLayout *mainLayout = new QVBoxLayout;

src/plugins/cooperation/core/transfer/transferhelper.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929
# include <QDBusInterface>
3030
# include <QDBusReply>
31+
32+
# include <maincontroller/maincontroller.h>
3133
#endif
3234

3335
using ButtonStateCallback = std::function<bool(const QString &, const DeviceInfoPointer)>;
@@ -226,6 +228,11 @@ TransferHelper::TransferHelper(QObject *parent)
226228
: QObject(parent),
227229
d(new TransferHelperPrivate(this))
228230
{
231+
connect(MainController::instance(), &MainController::onlineStateChanged, this, [this](bool isOnline) {
232+
if (isOnline || !d->transDialog()->isVisible() || !d->transDialog()->isInProgress())
233+
return;
234+
d->transferResult(false, tr("Network not connected, file delivery failed this time. Please connect to the network and try again!"));
235+
});
229236
}
230237

231238
TransferHelper::~TransferHelper()

src/plugins/cooperation/core/transfer/transferhelper_p.h

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public Q_SLOTS:
7272
QTimer confirmTimer;
7373
bool isTransTimeout = false;
7474
QString recvFilesSavePath;
75+
int jobId = 0;
7576
};
7677

7778
} // namespace cooperation_core

0 commit comments

Comments
 (0)