Skip to content

Commit

Permalink
Merge pull request #241 from yan12125/qt5-clean
Browse files Browse the repository at this point in the history
Clean up Qt-related warnings
  • Loading branch information
jserv committed Jul 15, 2024
2 parents 11841ff + b603144 commit 16d8863
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
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

0 comments on commit 16d8863

Please sign in to comment.