Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Commit

Permalink
Fix cxx detection, update flags, and fix warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
wengxt committed Oct 26, 2021
1 parent 2fa77d2 commit c2feea4
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 21 deletions.
25 changes: 17 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,25 @@ include(CMakePackageConfigHelpers)
include(ECMSetupVersion)
include(ECMGenerateHeaders)

include(CheckCXXCompilerFlag)

check_cxx_compiler_flag("-std=gnu++17" SUPPORT_CXX17)

if(NOT SUPPORT_CXX11)
message(FATAL_ERROR "need c++ 17 compatible compiler to compile")
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_STANDARD 17)

set(CMAKE_C_FLAGS "-Wall -Wextra ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-Wall -Wextra ${CMAKE_CXX_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined -Wl,--as-needed ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--no-undefined -Wl,--as-needed ${CMAKE_MODULE_LINKER_FLAGS}")

set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN On)

if (POLICY CMP0063)
# No sane project should be affected by CMP0063, so suppress the warnings
# generated by the above visibility settings in CMake >= 3.3
cmake_policy(SET CMP0063 NEW)
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++17 -Wall")

find_package(XKBCommon 0.5.0 REQUIRED COMPONENTS XKBCommon)

if (ENABLE_LIBRARY)
Expand Down
2 changes: 1 addition & 1 deletion qt5/platforminputcontext/fcitxwatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ void FcitxWatcher::unwatchSocketFile() {
m_fsWatcher->disconnect(SIGNAL(directoryChanged(QString)));
}

void FcitxWatcher::imChanged(const QString &service, const QString &oldOwner,
void FcitxWatcher::imChanged(const QString &service, const QString &,
const QString &newOwner) {
if (service == m_serviceName) {
if (!newOwner.isEmpty()) {
Expand Down
2 changes: 1 addition & 1 deletion qt5/quickphrase-editor/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ QString ListEditor::addon() { return "fcitx-quickphrase"; }

bool ListEditor::asyncSave() { return true; }

void ListEditor::changeFile(int newIndex) {
void ListEditor::changeFile(int) {
if (m_model->needSave()) {
int ret = QMessageBox::question(
this, _("Save Changes"),
Expand Down
2 changes: 1 addition & 1 deletion qt5/quickphrase-editor/filelistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fcitx::FileListModel::FileListModel(QObject *parent)

fcitx::FileListModel::~FileListModel() {}

int fcitx::FileListModel::rowCount(const QModelIndex &parent) const {
int fcitx::FileListModel::rowCount(const QModelIndex &) const {
return m_fileList.size();
}

Expand Down
2 changes: 1 addition & 1 deletion qt5/quickphrase-editor/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void QuickPhraseModel::deleteAllItem() {

Qt::ItemFlags QuickPhraseModel::flags(const QModelIndex &index) const {
if (!index.isValid())
return 0;
return {};

return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}
Expand Down
7 changes: 4 additions & 3 deletions qt5/widgetsaddons/fcitxqtkeysequencewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class FcitxQtKeySequenceWidgetPrivate {
}

// private slot
void doneRecording(bool validate = true);
void doneRecording();

// members
FcitxQtKeySequenceWidget *const q;
Expand Down Expand Up @@ -198,6 +198,7 @@ QKeySequence FcitxQtKeySequenceWidget::keySequence() const {
void FcitxQtKeySequenceWidget::setKeySequence(
const QKeySequence &seq, FcitxQtModifierSide side,
FcitxQtKeySequenceWidget::Validation validate) {
Q_UNUSED(validate);
// oldKeySequence holds the key sequence before recording started, if
// setKeySequence()
// is called while not recording then set oldKeySequence to the existing
Expand All @@ -212,7 +213,7 @@ void FcitxQtKeySequenceWidget::setKeySequence(

d->side = side;
d->keySequence = seq;
d->doneRecording(validate == Validate);
d->doneRecording();
}

// slot
Expand Down Expand Up @@ -240,7 +241,7 @@ void FcitxQtKeySequenceWidgetPrivate::startRecording() {
updateShortcutDisplay();
}

void FcitxQtKeySequenceWidgetPrivate::doneRecording(bool validate) {
void FcitxQtKeySequenceWidgetPrivate::doneRecording() {
modifierlessTimeout.stop();
isRecording = false;
keyButton->releaseKeyboard();
Expand Down
13 changes: 7 additions & 6 deletions qt5/widgetsaddons/qtkeytrans.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <QTextCodec>
#include <ctype.h>
#include <fcitx-config/hotkey.h>
#include <algorithm>

#define _ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
#define _ARRAY_END(a) (a + _ARRAY_SIZE(a))
Expand All @@ -36,14 +37,14 @@ void qEventToSym(int key, const QString &text, Qt::KeyboardModifiers mod,
break;
int uni = text[0].unicode();
int *result =
qBinaryFind(unicodeHasKey, _ARRAY_END(unicodeHasKey), uni);
std::lower_bound(unicodeHasKey, _ARRAY_END(unicodeHasKey), uni);
if (result != _ARRAY_END(unicodeHasKey)) {
sym = *result + 0x1000000;
break;
}

Unicode2Key *keyMap =
qBinaryFind(unicodeKeyMap, _ARRAY_END(unicodeKeyMap), uni);
std::lower_bound(unicodeKeyMap, _ARRAY_END(unicodeKeyMap), uni);
if (keyMap != _ARRAY_END(unicodeKeyMap)) {
sym = keyMap->key;
break;
Expand All @@ -56,26 +57,26 @@ void qEventToSym(int key, const QString &text, Qt::KeyboardModifiers mod,

QtCode2Key *result = nullptr;
if (mod & Qt::KeypadModifier) {
result = qBinaryFind(keyPadQtCodeToKey,
result = std::lower_bound(keyPadQtCodeToKey,
_ARRAY_END(keyPadQtCodeToKey), key);
if (result == _ARRAY_END(keyPadQtCodeToKey))
result = nullptr;
} else {
if (text.isNull()) {
result = qBinaryFind(qtCodeToKeyBackup,
result = std::lower_bound(qtCodeToKeyBackup,
_ARRAY_END(qtCodeToKeyBackup), key);
if (result == _ARRAY_END(qtCodeToKeyBackup))
result = nullptr;
}
if (!result) {
result = qBinaryFind(qtCodeToKey, _ARRAY_END(qtCodeToKey), key);
result = std::lower_bound(qtCodeToKey, _ARRAY_END(qtCodeToKey), key);

if (result == _ARRAY_END(qtCodeToKey))
result = nullptr;
}

if (!result) {
result = qBinaryFind(keyPadQtCodeToKey,
result = std::lower_bound(keyPadQtCodeToKey,
_ARRAY_END(keyPadQtCodeToKey), key);
if (result == _ARRAY_END(keyPadQtCodeToKey))
result = nullptr;
Expand Down

0 comments on commit c2feea4

Please sign in to comment.