@@ -143,7 +143,7 @@ void NoNetworkWidget::initUI()
143
143
QVBoxLayout *vLayout = new QVBoxLayout;
144
144
vLayout->setContentsMargins (0 , 0 , 0 , 0 );
145
145
vLayout->setSpacing (0 );
146
- vLayout->addSpacing ( 116 );
146
+ vLayout->addStretch ( );
147
147
vLayout->addWidget (iconLabel, 0 , Qt::AlignCenter);
148
148
vLayout->addSpacing (14 );
149
149
vLayout->addWidget (tipsLabel, 0 , Qt::AlignCenter);
@@ -242,12 +242,34 @@ void NoResultTipWidget::initUI()
242
242
#endif
243
243
}
244
244
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
+
245
262
NoResultWidget::NoResultWidget (QWidget *parent)
246
263
: QWidget(parent)
247
264
{
248
265
initUI ();
249
266
}
250
267
268
+ void NoResultWidget::mousePressEvent (QMouseEvent *event)
269
+ {
270
+ Q_UNUSED (event);
271
+ }
272
+
251
273
void NoResultWidget::initUI ()
252
274
{
253
275
setFocusPolicy (Qt::ClickFocus);
@@ -265,42 +287,42 @@ void NoResultWidget::initUI()
265
287
font.setWeight (QFont::Medium);
266
288
tipsLabel->setFont (font);
267
289
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);
271
294
272
295
QVBoxLayout *contentLayout = new QVBoxLayout;
273
296
NoResultTipWidget *noResultTipWidget = new NoResultTipWidget ();
274
297
noResultTipWidget->setTitleVisible (false );
275
- contentLayout->addWidget (noResultTipWidget);
276
- contentBackgroundWidget->setLayout (contentLayout);
298
+ backgroundWidget->setLayout (contentLayout);
277
299
278
300
QVBoxLayout *vLayout = new QVBoxLayout;
279
301
vLayout->setContentsMargins (0 , 0 , 0 , 0 );
280
302
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);
284
304
285
305
vLayout->addItem (sp_1);
286
306
vLayout->addWidget (iconLabel, 0 , Qt::AlignCenter);
287
- vLayout->addItem (sp_2 );
307
+ vLayout->addSpacing ( 10 );
288
308
vLayout->addWidget (tipsLabel, 0 , Qt::AlignCenter);
289
- vLayout->addItem (sp_3 );
290
- QScrollArea *scrollArea = new QScrollArea ();
309
+ vLayout->addSpacing ( 10 );
310
+
291
311
scrollArea->setWidgetResizable (true );
292
- scrollArea->setWidget (contentBackgroundWidget);
312
+ contentLayout->addWidget (scrollArea);
313
+ contentLayout->setSpacing (0 );
314
+ scrollArea->setWidget (noResultTipWidget);
293
315
294
316
#ifndef __linux__
295
317
scrollArea->setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
296
318
#endif
297
- scrollArea->setWidget (contentBackgroundWidget);
298
319
scrollArea->show ();
299
320
scrollArea->setFrameStyle (QFrame::NoFrame);
300
- vLayout->addWidget (scrollArea );
321
+ vLayout->addWidget (backgroundWidget );
301
322
302
323
vLayout->addSpacerItem (new QSpacerItem (10 , 10 , QSizePolicy::Minimum, QSizePolicy::Expanding));
303
324
setLayout (vLayout);
325
+ backgroundWidget->setMaximumHeight (129 );
304
326
}
305
327
306
328
BottomLabel::BottomLabel (QWidget *parent)
@@ -340,8 +362,7 @@ void BottomLabel::initUI()
340
362
{
341
363
QString ip = QString (tr (" Local IP: %1" ).arg (CooperationUtil::localIPAddress ()));
342
364
ipLabel = new QLabel (ip);
343
- ipLabel->setAlignment (Qt::AlignHCenter);
344
- ipLabel->setFixedHeight (30 );
365
+ ipLabel->setAlignment (Qt::AlignCenter);
345
366
connect (MainController::instance (), &MainController::onlineStateChanged, this , [this ](bool isOnline) {
346
367
if (!isOnline)
347
368
return ;
@@ -354,6 +375,7 @@ void BottomLabel::initUI()
354
375
QScrollArea *scrollArea = new QScrollArea (dialog);
355
376
tipLabel = new QLabel (qobject_cast<QWidget *>(this ->parent ()));
356
377
tipLabel->installEventFilter (this );
378
+ ipLabel->setFixedSize (500 , 33 );
357
379
358
380
#ifdef linux
359
381
updateSizeMode ();
@@ -373,7 +395,7 @@ void BottomLabel::initUI()
373
395
scrollArea->setStyleSheet (" QScrollArea { border: none; background-color: transparent; }" );
374
396
#endif
375
397
376
- dialog->setFixedSize (260 , 208 );
398
+ dialog->setFixedSize (260 , 210 );
377
399
scrollArea->setWidgetResizable (true );
378
400
QWidget *contentWidget = new QWidget;
379
401
@@ -383,10 +405,21 @@ void BottomLabel::initUI()
383
405
NoResultTipWidget *tipWidgt = new NoResultTipWidget (scrollArea, true );
384
406
layout->addWidget (tipWidgt);
385
407
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 );
386
416
387
417
QVBoxLayout *contentLayout = new QVBoxLayout;
388
418
contentLayout->setContentsMargins (0 , 0 , 0 , 0 );
419
+ contentLayout->setSpacing (0 );
420
+ contentLayout->addWidget (topSpace);
389
421
contentLayout->addWidget (scrollArea);
422
+ contentLayout->addWidget (bottomSpace);
390
423
contentLayout->setAlignment (Qt::AlignCenter);
391
424
392
425
dialog->setLayout (contentLayout);
@@ -397,7 +430,8 @@ void BottomLabel::initUI()
397
430
398
431
QVBoxLayout *mainLayout = new QVBoxLayout;
399
432
mainLayout->addWidget (ipLabel);
400
- mainLayout->setAlignment (Qt::AlignHCenter);
433
+ mainLayout->setAlignment (Qt::AlignCenter);
434
+ mainLayout->setContentsMargins (0 , 0 , 0 , 0 );
401
435
setLayout (mainLayout);
402
436
403
437
timer = new QTimer (this );
0 commit comments