@@ -29,6 +29,12 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
2929 hotkey =new QHotkey (this );
3030 translator =new QTranslator (this );
3131
32+ ui->setupUi (this );
33+
34+ settingsBtn = ui->bottomWidget ->findChild <QtMaterialFlatButton *>(" settingsBtn" );
35+ aboutBtn = ui->bottomWidget ->findChild <QtMaterialFlatButton *>(" aboutBtn" );
36+ settingsWindow =nullptr ;
37+
3238initUI ();
3339
3440Language::initLanguage ();
@@ -58,6 +64,8 @@ MainWindow *MainWindow::getInstance()
5864void MainWindow::changeEvent (QEvent *event)
5965{
6066if (event->type () == QEvent::LanguageChange) {
67+ ui->retranslateUi (this );
68+
6169// 更新文本, 用于翻译
6270updateText ();
6371 }
@@ -67,33 +75,13 @@ void MainWindow::changeEvent(QEvent *event)
6775
6876void MainWindow::initUI ()
6977{
70- ui->setupUi (this );
71-
72- setFocusPolicy (Qt::ClickFocus);
73-
74- setWindowIcon (QIcon (" :/icons/copy" ));
75-
7678 ui->autoToggle ->setText (tr (" Auto Mode" ));
7779 ui->hotkeyToggle ->setText (tr (" Hotkey Mode" ));
7880
79- settingsBtn = ui->bottomWidget ->findChild <QtMaterialFlatButton *>(" settingsBtn" );
80- aboutBtn = ui->bottomWidget ->findChild <QtMaterialFlatButton *>(" aboutBtn" );
81-
82- // settingsBtn->setIcon(QIcon(":/icons/settings"));
83- settingsBtn->setRole (Material::Primary);
84- settingsBtn->setBackgroundMode (Qt::OpaqueMode);
81+ setFlatBtnStyle (aboutBtn);
82+ setFlatBtnStyle (settingsBtn);
8583
86- // aboutBtn->setIcon(QIcon(":/icons/settings"));
87- aboutBtn->setRole (Material::Primary);
88- aboutBtn->setBackgroundMode (Qt::OpaqueMode);
89-
90- // setFixedSize(size()); // 放到最后,更新并固定窗口大小
91-
92- settingsWindow =nullptr ;
93-
94- // 设置按钮
95- // floatBtn = new QtMaterialFloatingActionButton(QIcon(":/icons/settings"),this);
96- // floatBtn->setMini(true);
84+ setFixedSize (size ());// 放到最后,更新并固定窗口大小
9785
9886#ifdef Q_OS_MAC
9987// mac 暂不支持自动合并
@@ -113,6 +101,14 @@ void MainWindow::updateText()
113101// ui->keySequenceEdit->lineEdit->setPlaceholderText(tr("快捷键"));
114102}
115103
104+ void MainWindow::setFlatBtnStyle (QtMaterialFlatButton *fBtn )
105+ {
106+ // fBtn->setIcon(QIcon(":/icons/settings"));
107+ fBtn ->setRole (Material::Primary);
108+ fBtn ->setBackgroundMode (Qt::OpaqueMode);
109+ fBtn ->setFont (QFont (" Microsoft YaHei" ));
110+ }
111+
116112void MainWindow::initConnections ()
117113{
118114connect (ui->autoToggle , &Toggle::toggled,this , &MainWindow::autoToggleChecked);
@@ -128,7 +124,7 @@ void MainWindow::initConnections()
128124 settingsWindow =new SettingsWindow (this );
129125
130126connect (settingsWindow, &SettingsWindow::closed,this , [&]() { settingsWindow =nullptr ; });
131-
127+
132128 settingsWindow->show ();
133129 settingsWindow->raise ();
134130 settingsWindow->activateWindow ();