WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 63c30dc

Browse files
committed
move mainwindow to primaryScreen center point
1 parent a3c1e72 commit 63c30dc

File tree

4 files changed

+99
-91
lines changed

4 files changed

+99
-91
lines changed

OpenSpeedy_en_US.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -650,28 +650,28 @@ Origin</translation>
650650
<translation>🪟 Operate System</translation>
651651
</message>
652652
<message>
653-
<location filename="mainwindow.cpp" line="79"/>
654-
<location filename="mainwindow.cpp" line="84"/>
653+
<location filename="mainwindow.cpp" line="87"/>
654+
<location filename="mainwindow.cpp" line="92"/>
655655
<source>%1倍</source>
656656
<translation>%1 times</translation>
657657
</message>
658658
<message>
659-
<location filename="mainwindow.cpp" line="80"/>
660-
<location filename="mainwindow.cpp" line="85"/>
659+
<location filename="mainwindow.cpp" line="88"/>
660+
<location filename="mainwindow.cpp" line="93"/>
661661
<source>✖️%1倍</source>
662662
<translation>✖️%1 times</translation>
663663
</message>
664664
<message>
665-
<location filename="mainwindow.cpp" line="354"/>
666-
<location filename="mainwindow.cpp" line="367"/>
667-
<location filename="mainwindow.cpp" line="380"/>
665+
<location filename="mainwindow.cpp" line="362"/>
666+
<location filename="mainwindow.cpp" line="375"/>
667+
<location filename="mainwindow.cpp" line="388"/>
668668
<source>提示</source>
669669
<translation>Tips</translation>
670670
</message>
671671
<message>
672-
<location filename="mainwindow.cpp" line="355"/>
673-
<location filename="mainwindow.cpp" line="368"/>
674-
<location filename="mainwindow.cpp" line="381"/>
672+
<location filename="mainwindow.cpp" line="363"/>
673+
<location filename="mainwindow.cpp" line="376"/>
674+
<location filename="mainwindow.cpp" line="389"/>
675675
<source>直到重启应用后,界面的语言才会生效</source>
676676
<translation>The UI language will only take effect after restarting the application.</translation>
677677
</message>

OpenSpeedy_zh_CN.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -633,28 +633,28 @@
633633
<translation type="unfinished"></translation>
634634
</message>
635635
<message>
636-
<location filename="mainwindow.cpp" line="79"/>
637-
<location filename="mainwindow.cpp" line="84"/>
636+
<location filename="mainwindow.cpp" line="87"/>
637+
<location filename="mainwindow.cpp" line="92"/>
638638
<source>%1倍</source>
639639
<translation type="unfinished"></translation>
640640
</message>
641641
<message>
642-
<location filename="mainwindow.cpp" line="80"/>
643-
<location filename="mainwindow.cpp" line="85"/>
642+
<location filename="mainwindow.cpp" line="88"/>
643+
<location filename="mainwindow.cpp" line="93"/>
644644
<source>✖️%1倍</source>
645645
<translation type="unfinished"></translation>
646646
</message>
647647
<message>
648-
<location filename="mainwindow.cpp" line="354"/>
649-
<location filename="mainwindow.cpp" line="367"/>
650-
<location filename="mainwindow.cpp" line="380"/>
648+
<location filename="mainwindow.cpp" line="362"/>
649+
<location filename="mainwindow.cpp" line="375"/>
650+
<location filename="mainwindow.cpp" line="388"/>
651651
<source>提示</source>
652652
<translation type="unfinished"></translation>
653653
</message>
654654
<message>
655-
<location filename="mainwindow.cpp" line="355"/>
656-
<location filename="mainwindow.cpp" line="368"/>
657-
<location filename="mainwindow.cpp" line="381"/>
655+
<location filename="mainwindow.cpp" line="363"/>
656+
<location filename="mainwindow.cpp" line="376"/>
657+
<location filename="mainwindow.cpp" line="389"/>
658658
<source>直到重启应用后,界面的语言才会生效</source>
659659
<translation type="unfinished"></translation>
660660
</message>

OpenSpeedy_zh_TW.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -634,28 +634,28 @@
634634
<translation>🪟 操作系統</translation>
635635
</message>
636636
<message>
637-
<location filename="mainwindow.cpp" line="79"/>
638-
<location filename="mainwindow.cpp" line="84"/>
637+
<location filename="mainwindow.cpp" line="87"/>
638+
<location filename="mainwindow.cpp" line="92"/>
639639
<source>%1倍</source>
640640
<translation>%1倍</translation>
641641
</message>
642642
<message>
643-
<location filename="mainwindow.cpp" line="80"/>
644-
<location filename="mainwindow.cpp" line="85"/>
643+
<location filename="mainwindow.cpp" line="88"/>
644+
<location filename="mainwindow.cpp" line="93"/>
645645
<source>✖️%1倍</source>
646646
<translation>✖️%1倍</translation>
647647
</message>
648648
<message>
649-
<location filename="mainwindow.cpp" line="354"/>
650-
<location filename="mainwindow.cpp" line="367"/>
651-
<location filename="mainwindow.cpp" line="380"/>
649+
<location filename="mainwindow.cpp" line="362"/>
650+
<location filename="mainwindow.cpp" line="375"/>
651+
<location filename="mainwindow.cpp" line="388"/>
652652
<source>提示</source>
653653
<translation>提示</translation>
654654
</message>
655655
<message>
656-
<location filename="mainwindow.cpp" line="355"/>
657-
<location filename="mainwindow.cpp" line="368"/>
658-
<location filename="mainwindow.cpp" line="381"/>
656+
<location filename="mainwindow.cpp" line="363"/>
657+
<location filename="mainwindow.cpp" line="376"/>
658+
<location filename="mainwindow.cpp" line="389"/>
659659
<source>直到重启应用后,界面的语言才会生效</source>
660660
<translation>直到重啟應用後,界面的語言才會生效</translation>
661661
</message>

mainwindow.cpp

Lines changed: 69 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ MainWindow::MainWindow(QWidget *parent)
2828
: QMainWindow(parent), ui(new Ui::MainWindow)
2929
{
3030
ui->setupUi(this);
31+
32+
QScreen *screen = QGuiApplication::primaryScreen();
33+
if (screen != nullptr)
34+
{
35+
this->move(
36+
(screen->geometry().width() - this->width())/2,
37+
(screen->geometry().height() - this->height())/2);
38+
}
3139
init();
3240
}
3341

@@ -57,15 +65,15 @@ void MainWindow::recreate()
5765
void MainWindow::refresh()
5866
{
5967
ui->cpuContent->setText(QString("<span style='color:blue'>%1%</span>")
60-
.arg(m_cpu->getUsage(), 5, 'f', 1, ' '));
68+
.arg(m_cpu->getUsage(), 5, 'f', 1, ' '));
6169

6270
double memUsage = m_mem->getUsage();
6371
double memTotal = m_mem->getTotal();
6472
ui->memContent->setText(
6573
QString("<span style='color:blue'>(%1G / %2G) %3%</span>")
66-
.arg(memUsage, 0, 'f', 1)
67-
.arg(memTotal, 0, 'f', 1)
68-
.arg(memUsage / memTotal * 100, 4, 'f', 1));
74+
.arg(memUsage, 0, 'f', 1)
75+
.arg(memTotal, 0, 'f', 1)
76+
.arg(memUsage / memTotal * 100, 4, 'f', 1));
6977
}
7078

7179
void MainWindow::on_sliderCtrl_valueChanged(int value)
@@ -159,10 +167,10 @@ void MainWindow::createTray()
159167
// 连接信号和槽
160168
connect(showAction, &QAction::triggered, this,
161169
[&]
162-
{
163-
showNormal();
164-
activateWindow();
165-
});
170+
{
171+
showNormal();
172+
activateWindow();
173+
});
166174
connect(hideAction, &QAction::triggered, this, &MainWindow::hide);
167175
connect(quitAction, &QAction::triggered, qApp, &QApplication::quit);
168176

@@ -297,30 +305,30 @@ void MainWindow::init()
297305
/* 首选项菜单 */
298306
connect(ui->menuPreference, &QMenu::aboutToShow,
299307
[this]
300-
{
301-
ui->menuPreference->hide();
302-
QTimer::singleShot(50,
303-
[this]()
304-
{
305-
m_preferenceDlg->show();
306-
m_preferenceDlg->activateWindow();
307-
m_preferenceDlg->raise();
308-
});
309-
});
308+
{
309+
ui->menuPreference->hide();
310+
QTimer::singleShot(50,
311+
[this]()
312+
{
313+
m_preferenceDlg->show();
314+
m_preferenceDlg->activateWindow();
315+
m_preferenceDlg->raise();
316+
});
317+
});
310318

311319
/* 关于菜单 */
312320
connect(ui->menuAbout, &QMenu::aboutToShow,
313321
[this]
314-
{
315-
ui->menuAbout->hide();
316-
QTimer::singleShot(50,
317-
[this]()
318-
{
319-
m_aboutDlg->show();
320-
m_aboutDlg->activateWindow();
321-
m_aboutDlg->raise();
322-
});
323-
});
322+
{
323+
ui->menuAbout->hide();
324+
QTimer::singleShot(50,
325+
[this]()
326+
{
327+
m_aboutDlg->show();
328+
m_aboutDlg->activateWindow();
329+
m_aboutDlg->raise();
330+
});
331+
});
324332

325333
m_languageGroup = new QActionGroup(this);
326334
m_languageGroup->setExclusive(true);
@@ -329,7 +337,7 @@ void MainWindow::init()
329337
m_languageGroup->addAction(ui->actionEN);
330338
QString language =
331339
m_settings->value(CONFIG_LANGUAGE, QLocale().system().name())
332-
.toString();
340+
.toString();
333341
if (language == "zh_CN")
334342
{
335343
ui->actionCN->setChecked(true);
@@ -345,42 +353,42 @@ void MainWindow::init()
345353

346354
connect(ui->actionCN, &QAction::triggered,
347355
[this]
348-
{
349-
m_settings->setValue(CONFIG_LANGUAGE, "zh_CN");
350-
QMessageBox msgBox(this);
351-
msgBox.setWindowFlags(Qt::Dialog | Qt::WindowTitleHint |
352-
Qt::CustomizeWindowHint);
353-
msgBox.setIcon(QMessageBox::Information);
354-
msgBox.setWindowTitle(tr("提示"));
355-
msgBox.setText(tr("直到重启应用后,界面的语言才会生效"));
356-
msgBox.exec();
357-
});
356+
{
357+
m_settings->setValue(CONFIG_LANGUAGE, "zh_CN");
358+
QMessageBox msgBox(this);
359+
msgBox.setWindowFlags(Qt::Dialog | Qt::WindowTitleHint |
360+
Qt::CustomizeWindowHint);
361+
msgBox.setIcon(QMessageBox::Information);
362+
msgBox.setWindowTitle(tr("提示"));
363+
msgBox.setText(tr("直到重启应用后,界面的语言才会生效"));
364+
msgBox.exec();
365+
});
358366

359367
connect(ui->actionTW, &QAction::triggered,
360368
[this]
361-
{
362-
m_settings->setValue(CONFIG_LANGUAGE, "zh_TW");
363-
QMessageBox msgBox(this);
364-
msgBox.setWindowFlags(Qt::Dialog | Qt::WindowTitleHint |
365-
Qt::CustomizeWindowHint);
366-
msgBox.setIcon(QMessageBox::Information);
367-
msgBox.setWindowTitle(tr("提示"));
368-
msgBox.setText(tr("直到重启应用后,界面的语言才会生效"));
369-
msgBox.exec();
370-
});
369+
{
370+
m_settings->setValue(CONFIG_LANGUAGE, "zh_TW");
371+
QMessageBox msgBox(this);
372+
msgBox.setWindowFlags(Qt::Dialog | Qt::WindowTitleHint |
373+
Qt::CustomizeWindowHint);
374+
msgBox.setIcon(QMessageBox::Information);
375+
msgBox.setWindowTitle(tr("提示"));
376+
msgBox.setText(tr("直到重启应用后,界面的语言才会生效"));
377+
msgBox.exec();
378+
});
371379

372380
connect(ui->actionEN, &QAction::triggered,
373381
[this]
374-
{
375-
m_settings->setValue(CONFIG_LANGUAGE, "en_US");
376-
QMessageBox msgBox(this);
377-
msgBox.setWindowFlags(Qt::Dialog | Qt::WindowTitleHint |
378-
Qt::CustomizeWindowHint);
379-
msgBox.setIcon(QMessageBox::Information);
380-
msgBox.setWindowTitle(tr("提示"));
381-
msgBox.setText(tr("直到重启应用后,界面的语言才会生效"));
382-
msgBox.exec();
383-
});
382+
{
383+
m_settings->setValue(CONFIG_LANGUAGE, "en_US");
384+
QMessageBox msgBox(this);
385+
msgBox.setWindowFlags(Qt::Dialog | Qt::WindowTitleHint |
386+
Qt::CustomizeWindowHint);
387+
msgBox.setIcon(QMessageBox::Information);
388+
msgBox.setWindowTitle(tr("提示"));
389+
msgBox.setText(tr("直到重启应用后,界面的语言才会生效"));
390+
msgBox.exec();
391+
});
384392
}
385393

386394
void MainWindow::closeEvent(QCloseEvent *event)
@@ -434,7 +442,7 @@ bool MainWindow::nativeEventFilter(const QByteArray &eventType,
434442
currentValue + m_preferenceDlg->getIncreaseStep());
435443
qDebug() << "全局快捷键: 增加速度到"
436444
<< speedFactor(currentValue +
437-
m_preferenceDlg->getIncreaseStep());
445+
m_preferenceDlg->getIncreaseStep());
438446
}
439447
}
440448
break;
@@ -453,7 +461,7 @@ bool MainWindow::nativeEventFilter(const QByteArray &eventType,
453461
currentValue - m_preferenceDlg->getDecreaseStep());
454462
qDebug() << "全局快捷键: 降低速度到"
455463
<< speedFactor(currentValue -
456-
m_preferenceDlg->getDecreaseStep());
464+
m_preferenceDlg->getDecreaseStep());
457465
}
458466
}
459467
break;

0 commit comments

Comments
 (0)