Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up Qt-related warnings #241

Merged
merged 3 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,8 @@ jobs:
brew update
brew install libchewing qt@5

# Qt
brew link --force qt@5
# Homebrew does not link mkspecs and plugins https://github.com/Homebrew/homebrew-core/issues/93056
export HOMEBREW_QT5_VERSION=$(brew list --versions qt@5 | rev | cut -d' ' -f1 | rev)
sudo ln -s /usr/local/Cellar/qt@5/$HOMEBREW_QT5_VERSION/mkspecs /usr/local/mkspecs
sudo ln -s /usr/local/Cellar/qt@5/$HOMEBREW_QT5_VERSION/plugins /usr/local/plugins
# Allow CMake to find qt@5 by passing down the environment variable
echo "CMAKE_PREFIX_PATH=$(brew --prefix qt@5)" >> $GITHUB_ENV
if: ${{ matrix.os == 'macos-latest' }}

- name: Configure CMake
Expand Down
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ elseif(MSVC)
add_definitions(-DUNICODE -D_UNICODE)
endif()

add_definitions(-DTESTDATA="${PROJECT_SOURCE_DIR}/test/data")
add_definitions(-DTESTDATA="${PROJECT_SOURCE_DIR}/test/data" -DQT_DISABLE_DEPRECATED_BEFORE=0x050e00)

find_package(PkgConfig)
find_package(Qt5Widgets REQUIRED)
Expand Down Expand Up @@ -161,12 +161,12 @@ QT5_ADD_RESOURCES(qt_resources ${PROJECT_SOURCE_DIR}/ts/ts.qrc)
# exporter
file(GLOB_RECURSE exporter_src ${PROJECT_SOURCE_DIR}/src/exporter/*)
add_library(exporter STATIC ${exporter_src})
qt5_use_modules(exporter Widgets)
target_link_libraries(exporter Qt5::Widgets)

# importer
file(GLOB_RECURSE importer_src ${PROJECT_SOURCE_DIR}/src/importer/*)
add_library(importer STATIC ${importer_src})
qt5_use_modules(importer Widgets)
target_link_libraries(importer Qt5::Widgets)

# ui
file(GLOB ui_src ${PROJECT_SOURCE_DIR}/src/ui/*)
Expand All @@ -175,7 +175,7 @@ qt5_wrap_ui(ui ${ui_src})
# util
file(GLOB util_src ${PROJECT_SOURCE_DIR}/src/util/*)
add_library(util STATIC ${util_src})
qt5_use_modules(util Widgets)
target_link_libraries(util Qt5::Widgets)

# chewing-editor
file(GLOB chewing-editor_src
Expand Down Expand Up @@ -206,7 +206,7 @@ if(MSVC)
)
endif()

qt5_use_modules(chewing-editor Widgets)
target_link_libraries(chewing-editor Qt5::Widgets)
install(PROGRAMS ${CMAKE_BINARY_DIR}/chewing-editor DESTINATION ${CMAKE_INSTALL_BINDIR})

# icon
Expand Down Expand Up @@ -273,7 +273,7 @@ target_link_libraries(run-test
util
pthread
)
qt5_use_modules(run-test Widgets)
target_link_libraries(run-test Qt5::Widgets)

add_test(test run-test)

Expand Down
7 changes: 6 additions & 1 deletion src/model/UserphraseModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include "UserphraseModel.h"

#include <QDebug>
#include <algorithm>
#include <functional>

static void logger(void *data, int level, const char *fmt, ...)
{
Expand Down Expand Up @@ -86,7 +88,10 @@ void UserphraseModel::remove(QModelIndexList indexList)
return;
}

qSort(indexList.begin(), indexList.end(), qGreater<QModelIndex>());
std::sort(indexList.begin(), indexList.end(), [] (const QModelIndex& a, const QModelIndex& b) {
// QModelIndex provides operator< but no operator>
return !(a < b);
});

// XXX: indexList is in revsrsed order, so first is actual last, and vice
// verse.
Expand Down
4 changes: 2 additions & 2 deletions src/view/ChewingEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ void ChewingEditor::execFileDialog(DialogType type)
fileDialog_->setWindowTitle(tr("Import"));
fileDialog_->setAcceptMode(QFileDialog::AcceptOpen);
fileDialog_->setFileMode(QFileDialog::ExistingFile);
fileDialog_->setConfirmOverwrite(false);
fileDialog_->setOption(QFileDialog::DontConfirmOverwrite, true);
fileDialog_->selectFile("");
break;

case DIALOG_EXPORT:
fileDialog_->setWindowTitle(tr("Export"));
fileDialog_->setAcceptMode(QFileDialog::AcceptSave);
fileDialog_->setFileMode(QFileDialog::AnyFile);
fileDialog_->setConfirmOverwrite(true);
fileDialog_->setOption(QFileDialog::DontConfirmOverwrite, false);
fileDialog_->selectFile("chewing.json");
break;

Expand Down
Loading