Skip to content

Commit c11b64c

Browse files
committed
Use QT_NO_KEYWORDS and clean up qt plugin includes
1 parent 9e19da8 commit c11b64c

File tree

12 files changed

+79
-59
lines changed

12 files changed

+79
-59
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
2424

2525
include("${FCITX_INSTALL_CMAKECONFIG_DIR}/Fcitx5Utils/Fcitx5CompilerSettings.cmake")
2626
add_definitions(-DFCITX_GETTEXT_DOMAIN=\"fcitx5-unikey\")
27+
add_definitions(-DQT_NO_KEYWORDS)
2728
fcitx5_add_i18n_definition()
2829

2930
if (ENABLE_QT)

keymap-editor/editor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class KeymapEditor : public FcitxQtConfigUIWidget, public Ui::Editor {
5050
QString icon() override;
5151

5252
static QString getData(CKeymapTable *table, int i, bool iskey);
53-
private slots:
53+
private Q_SLOTS:
5454
void addKeymap();
5555
void deleteKeymap();
5656
void deleteAllKeymap();

keymap-editor/model.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ void KeymapModel::deleteAllItem() {
165165
void KeymapModel::setNeedSave(bool needSave) {
166166
if (needSave_ != needSave) {
167167
needSave_ = needSave;
168-
emit needSaveChanged(needSave_);
168+
Q_EMIT needSaveChanged(needSave_);
169169
}
170170
}
171171

keymap-editor/model.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class KeymapModel : public QAbstractTableModel {
4141
void save(const QString &fileName);
4242
void load(int profile);
4343

44-
signals:
44+
Q_SIGNALS:
4545
void needSaveChanged(bool);
4646

4747
private:

macro-editor/dialog.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
*
66
*/
77
#include "dialog.h"
8-
#include "ui_dialog.h"
8+
#include <QDialog>
9+
#include <QString>
10+
#include <QWidget>
911

10-
namespace fcitx {
11-
namespace unikey {
12+
namespace fcitx::unikey {
1213
MacroDialog::MacroDialog(QWidget *parent) : QDialog(parent) { setupUi(this); }
1314

1415
QString MacroDialog::macro() const { return macroLineEdit->text(); }
1516

1617
QString MacroDialog::word() const { return wordLineEdit->text(); }
1718

18-
} // namespace unikey
19-
} // namespace fcitx
19+
} // namespace fcitx::unikey

macro-editor/dialog.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,18 @@
99

1010
#include "ui_dialog.h"
1111
#include <QDialog>
12+
#include <QString>
13+
#include <QWidget>
1214

13-
class CMacroTable;
15+
namespace fcitx::unikey {
1416

15-
namespace fcitx {
16-
namespace unikey {
1717
class MacroDialog : public QDialog, private Ui::Dialog {
1818
Q_OBJECT
1919
public:
2020
explicit MacroDialog(QWidget *parent = nullptr);
2121
QString macro() const;
2222
QString word() const;
2323
};
24-
} // namespace unikey
25-
} // namespace fcitx
24+
} // namespace fcitx::unikey
2625

2726
#endif // _MACRO_EDITOR_DIALOG_H_

macro-editor/editor.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void MacroEditor::deleteWord() {
7676
void MacroEditor::deleteAllWord() { model_->deleteAllItem(); }
7777

7878
void MacroEditor::addWord() {
79-
MacroDialog *dialog = new MacroDialog(this);
79+
auto *dialog = new MacroDialog(this);
8080
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
8181
dialog->open();
8282
connect(dialog, &QDialog::accepted, this, &MacroEditor::addWordAccepted);
@@ -118,8 +118,7 @@ QString MacroEditor::getData(CMacroTable *table, int i, bool iskey) {
118118
}
119119

120120
void MacroEditor::addWordAccepted() {
121-
const MacroDialog *dialog =
122-
qobject_cast<const MacroDialog *>(QObject::sender());
121+
const auto *dialog = qobject_cast<const MacroDialog *>(QObject::sender());
123122

124123
model_->addItem(dialog->macro(), dialog->word());
125124
}
@@ -142,7 +141,7 @@ void MacroEditor::save() {
142141
}
143142

144143
void MacroEditor::importMacro() {
145-
QFileDialog *dialog = new QFileDialog(this);
144+
auto *dialog = new QFileDialog(this);
146145
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
147146
dialog->setFileMode(QFileDialog::ExistingFile);
148147
dialog->setAcceptMode(QFileDialog::AcceptOpen);
@@ -152,8 +151,7 @@ void MacroEditor::importMacro() {
152151
}
153152

154153
void MacroEditor::importFileSelected() {
155-
const QFileDialog *dialog =
156-
qobject_cast<const QFileDialog *>(QObject::sender());
154+
const auto *dialog = qobject_cast<const QFileDialog *>(QObject::sender());
157155
if (dialog->selectedFiles().length() <= 0) {
158156
return;
159157
}
@@ -162,7 +160,7 @@ void MacroEditor::importFileSelected() {
162160
}
163161

164162
void MacroEditor::exportMacro() {
165-
QFileDialog *dialog = new QFileDialog(this);
163+
auto *dialog = new QFileDialog(this);
166164
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
167165
dialog->setDirectory("macro");
168166
dialog->setAcceptMode(QFileDialog::AcceptSave);
@@ -172,8 +170,7 @@ void MacroEditor::exportMacro() {
172170
}
173171

174172
void MacroEditor::exportFileSelected() {
175-
const QFileDialog *dialog =
176-
qobject_cast<const QFileDialog *>(QObject::sender());
173+
const auto *dialog = qobject_cast<const QFileDialog *>(QObject::sender());
177174
if (dialog->selectedFiles().length() <= 0) {
178175
return;
179176
}

macro-editor/editor.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
#define _MACRO_EDITOR_EDITOR_H_
99

1010
#include "ui_editor.h"
11+
#include <QString>
12+
#include <QWidget>
1113
#include <fcitxqtconfiguiwidget.h>
1214
#include <memory>
1315

1416
class CMacroTable;
1517

16-
namespace fcitx {
17-
namespace unikey {
18+
namespace fcitx::unikey {
1819

1920
class MacroModel;
2021
class MacroEditor : public FcitxQtConfigUIWidget, public Ui::Editor {
@@ -28,7 +29,7 @@ class MacroEditor : public FcitxQtConfigUIWidget, public Ui::Editor {
2829
QString icon() override;
2930

3031
static QString getData(CMacroTable *table, int i, bool iskey);
31-
private slots:
32+
private Q_SLOTS:
3233
void addWord();
3334
void deleteWord();
3435
void deleteAllWord();
@@ -43,7 +44,6 @@ private slots:
4344
std::unique_ptr<CMacroTable> table_;
4445
MacroModel *model_;
4546
};
46-
} // namespace unikey
47-
} // namespace fcitx
47+
} // namespace fcitx::unikey
4848

4949
#endif // _MACRO_EDITOR_EDITOR_H_

macro-editor/main.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66
*/
77
#include "main.h"
88
#include "editor.h"
9-
#include "model.h"
109
#include <QApplication>
11-
#include <qplugin.h>
10+
#include <QObject>
11+
#include <QtPlugin>
12+
#include <fcitx-utils/i18n.h>
13+
#include <fcitx-utils/macros.h>
14+
#include <fcitxqtconfiguiplugin.h>
15+
#include <fcitxqtconfiguiwidget.h>
1216

1317
namespace fcitx {
1418

@@ -18,7 +22,7 @@ MacroEditorPlugin::MacroEditorPlugin(QObject *parent)
1822
}
1923

2024
FcitxQtConfigUIWidget *MacroEditorPlugin::create(const QString &key) {
21-
Q_UNUSED(key);
25+
FCITX_UNUSED(key);
2226
return new fcitx::unikey::MacroEditor;
2327
}
2428

macro-editor/main.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#ifndef _MACRO_EDITOR_MAIN_H_
88
#define _MACRO_EDITOR_MAIN_H_
99

10+
#include <QObject>
11+
#include <QString>
1012
#include <fcitxqtconfiguiplugin.h>
1113

1214
namespace fcitx {

0 commit comments

Comments
 (0)