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

Bugfixes #4

Merged
merged 7 commits into from
Apr 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
12 changes: 11 additions & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ jobs:
- name: Install dependencies
run: pip install -r requirements.txt

- name: Cache Conan
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/conan/
~/.conan2
key: conan2-${{ runner.os }}-${{ hashFiles('conan/conanfile.txt') }}
restore-keys: |
conan2-${{ runner.os }}-

- name: Run Conan
run: |
conan profile detect
Expand All @@ -57,7 +67,7 @@ jobs:
with:
version: '6.5.*'
cache: 'true'
cache-key-prefix: 'install-qt-action'
cache-key-prefix: 'install-qt-action-${{ runner.os }}'

- name: Configure
run: cmake -Bbuild -DCMAKE_TOOLCHAIN_FILE="conan/conan_toolchain.cmake"
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ jobs:
- name: Install dependencies
run: pip install -r requirements.txt

- name: Cache Conan
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/conan/
~/.conan2
key: conan2-${{ runner.os }}-${{ hashFiles('conan/conanfile.txt') }}
restore-keys: |
conan2-${{ runner.os }}-

- name: Run Conan
run: |
conan profile detect
Expand All @@ -57,7 +67,7 @@ jobs:
with:
version: '6.5.*'
cache: 'true'
cache-key-prefix: 'install-qt-action'
cache-key-prefix: 'install-qt-action-${{ runner.os }}'

- name: Configure
run: cmake -Bbuild -DCMAKE_TOOLCHAIN_FILE="conan/conan_toolchain.cmake"
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ jobs:
- name: Install dependencies
run: pip install -r requirements.txt

- name: Cache Conan
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/conan/
~/.conan2
key: conan2-${{ runner.os }}-${{ hashFiles('conan/conanfile.txt') }}
restore-keys: |
conan2-${{ runner.os }}-

- name: Run Conan
run: |
conan profile detect
Expand All @@ -58,7 +68,7 @@ jobs:
with:
version: '6.5.*'
cache: 'true'
cache-key-prefix: 'install-qt-action'
cache-key-prefix: 'install-qt-action-${{ runner.os }}'

- name: Configure
run: cmake -Bbuild -DCMAKE_TOOLCHAIN_FILE="conan/conan_toolchain.cmake"
Expand Down
53 changes: 29 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,36 @@ foreach(library IN LISTS BOOST_COMPONENTS)
endif()
endforeach()

# Resources
include(cmake/Resources.cmake)
string(REPLACE "-" "_" QML_URI "${PROJECT_NAME}")
if (${PROJECT_NAME}_QT_QUICK)
qt_add_qml_module(${PROJECT_NAME}
URI ${QML_URI}
RESOURCE_PREFIX "/qt/qml/"
QML_FILES ${QML_FILES}
RESOURCES ${RESOURCES}
NO_PLUGIN)
else()
qt_add_resources(${PROJECT_NAME} "resources"
PREFIX "/resource"
FILES ${RESOURCES})
endif()

# Create code filters
# For resource files
source_group("Resources" FILES
"${CMAKE_BINARY_DIR}/.rcc/resources.qrc"
"${CMAKE_BINARY_DIR}/.rcc/qrc_resources.cpp")
file(GLOB_RECURSE SOURCES "*.rc" "*.qrc")
foreach(SOURCE ${SOURCES})
source_group("Resources" FILES ${SOURCE})
endforeach()
# Resources defined in cmake/Resources.cmake
foreach(SOURCE ${RESOURCES})
source_group("Resources" FILES ${SOURCE})
endforeach()

# For source code
file(GLOB_RECURSE SOURCES "src/*.cpp" "src/*.h" "src/*.ui")
foreach(SOURCE ${SOURCES})
Expand All @@ -164,14 +193,6 @@ foreach(SOURCE ${SOURCES})
string(REPLACE "src" "Source Files" SOURCE_PATH "${SOURCE_PATH}")
source_group("${SOURCE_PATH}" FILES ${SOURCE})
endforeach()
# For resources
file(GLOB_RECURSE SOURCES "*.rc" "*.qrc")
foreach(SOURCE ${SOURCES})
source_group("Resources" FILES ${SOURCE})
endforeach()
source_group("Resources" FILES
"${CMAKE_BINARY_DIR}/.rcc/resources.qrc"
"${CMAKE_BINARY_DIR}/.rcc/qrc_resources.cpp")

# For autogenerated by Qt ui_[name].h files for every src/*.ui file
file(GLOB_RECURSE SOURCES "src/*.ui")
Expand All @@ -186,22 +207,6 @@ foreach(SOURCE ${SOURCES})
"${CMAKE_BINARY_DIR}/${PROJECT_NAME}_autogen/include_RelWithDebInfo/${FILE_PATH}ui_${FILE_NAME}.h")
endforeach()

# Resources
include(cmake/Resources.cmake)
string(REPLACE "-" "_" QML_URI "${PROJECT_NAME}")
if (${PROJECT_NAME}_QT_QUICK)
qt_add_qml_module(${PROJECT_NAME}
URI ${QML_URI}
RESOURCE_PREFIX "/qt/qml/"
QML_FILES ${QML_FILES}
RESOURCES ${RESOURCES}
NO_PLUGIN)
else()
qt_add_resources(${PROJECT_NAME} "resources"
PREFIX "/resource"
FILES ${RESOURCES})
endif()

# For autogenerated by Qt stamp files
source_group("Autogen/autouic" FILES
"${CMAKE_BINARY_DIR}/${PROJECT_NAME}_LIB_autogen/autouic_Debug.stamp"
Expand Down
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,19 @@ At line `174` of `CMakeLists.txt` you can modify following code for **filters**
<details><summary>The code</summary>

```cmake
# Create code filters
# For resource files
source_group("Resources" FILES
"${CMAKE_BINARY_DIR}/.rcc/resources.qrc"
"${CMAKE_BINARY_DIR}/.rcc/qrc_resources.cpp")
file(GLOB_RECURSE SOURCES "*.rc" "*.qrc")
foreach(SOURCE ${SOURCES})
source_group("Resources" FILES ${SOURCE})
endforeach()
# Resources defined in cmake/Resources.cmake
foreach(SOURCE ${RESOURCES})
source_group("Resources" FILES ${SOURCE})
endforeach()

# For source code
file(GLOB_RECURSE SOURCES "src/*.cpp" "src/*.h" "src/*.ui")
foreach(SOURCE ${SOURCES})
Expand All @@ -500,14 +512,6 @@ foreach(SOURCE ${SOURCES})
string(REPLACE "src" "Source Files" SOURCE_PATH "${SOURCE_PATH}")
source_group("${SOURCE_PATH}" FILES ${SOURCE})
endforeach()
# For resources
file(GLOB_RECURSE SOURCES "*.rc" "*.qrc")
foreach(SOURCE ${SOURCES})
source_group("Resources" FILES ${SOURCE})
endforeach()
source_group("Resources" FILES
"${CMAKE_BINARY_DIR}/.rcc/resources.qrc"
"${CMAKE_BINARY_DIR}/.rcc/qrc_resources.cpp")

# For autogenerated by Qt ui_[name].h files for every src/*.ui file
file(GLOB_RECURSE SOURCES "src/*.ui")
Expand Down Expand Up @@ -548,7 +552,7 @@ source_group("CMake Rules" FILES "CMakeLists.txt")

</details>

You can add your own filters after line `226` in `CMakeLists.txt`, by adding:
You can add your own filters after line `232` in `CMakeLists.txt`, by adding:

```cmake
source_group("[FILTER_NAME]" FILES "[FILE_PATHS]")
Expand Down
1 change: 1 addition & 0 deletions src/Exceptions/Exceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ void errorMessageHandler(QtMsgType type, const QMessageLogContext& context, cons
{
case QtInfoMsg:
case QtWarningMsg:
//QMessageBoxes won't display when used with Qt Quick, so you can remove this line, if you use it
showMessage();
break;

Expand Down
4 changes: 2 additions & 2 deletions src/Exceptions/Exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class AppException final : public QException
/// Instead of throwing exceptions use:
/// - `qDebug() << [ErrorType] << [message]` for information that should be written in a log only when debugging is enabled
/// - `qInfo() << [ErrorType] << [message]` for information that should be written in a log
/// - `qWarn() << [ErrorType] << [message]` for information that should be displayed as a warning to the user
/// - `qWarning() << [ErrorType] << [message]` for information that should be displayed as a warning to the user
/// - `qCritical() << [ErrorType] << [message]` for exceptions
/// - `qFatal() << [ErrorType] << [message]` for exceptions that cannot be recovered from
QDebug operator<<(QDebug logger, const ErrorType& errorType);
Expand All @@ -73,7 +73,7 @@ QDebug operator<<(QDebug logger, const ErrorType& errorType);
/// Instead of throwing exceptions use:
/// - `qDebug() << [ErrorType] << [message]` for information that should be written in a log only when debugging is enabled
/// - `qInfo() << [ErrorType] << [message]` for information that should be written in a log
/// - `qWarn() << [ErrorType] << [message]` for information that should be displayed as a warning to the user
/// - `qWarning() << [ErrorType] << [message]` for information that should be displayed as a warning to the user
/// - `qCritical() << [ErrorType] << [message]` for exceptions
/// - `qFatal() << [ErrorType] << [message]` for exceptions that cannot be recovered from
void errorMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg);
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ int main(int argc, char* argv[])
catch (...)
{
std::cerr << "[Critical] Unidentified exception has occurred\n";
showExceptionMessageBox("Unidentified \"std::exception\" has occurred");
showExceptionMessageBox("Unidentified exception has occurred");
throw;
}
boost::filesystem::recursive_directory_iterator it;
Expand Down
Loading