Compare commits
No commits in common. "ff3ec96819c5a3835a92ad552de3efd13acc76ba" and "3e713b13a8d83465aa00b941fefc876538783060" have entirely different histories.
ff3ec96819
...
3e713b13a8
17
README.md
17
README.md
|
|
@ -3,20 +3,3 @@
|
||||||
This example combines Qt6 GUI (C++) with WGPU rendering (Rust). It doesn’t do much of either but it’s the bridging what’s relevant.
|
This example combines Qt6 GUI (C++) with WGPU rendering (Rust). It doesn’t do much of either but it’s the bridging what’s relevant.
|
||||||
|
|
||||||
Currently only X11 (XCB) is supported but it should be easy to extend to other platforms.
|
Currently only X11 (XCB) is supported but it should be easy to extend to other platforms.
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
This program is intended as a starting point rather than a dependency, so just copy it.
|
|
||||||
|
|
||||||
1. Fetch this code:
|
|
||||||
* clone the repo: `git clone https://gitea.noteuclid.ru/noteuclid/qt-wgpu-skel.git`
|
|
||||||
* or, download and unpack the [tarball](https://gitea.noteuclid.ru/noteuclid/qt-wgpu-skel/archive/master.tar.gz).
|
|
||||||
2. Rename the directory to your liking
|
|
||||||
3. Run `init.sh` with the project name, like:
|
|
||||||
* `./init.sh 'My FANCY Project'`, or
|
|
||||||
* `./init.sh 'My FANCY Project' 'fancy-project'`.
|
|
||||||
|
|
||||||
Running `init.sh` without arguments prints the help.
|
|
||||||
|
|
||||||
If you want to use Qt5, change the version in both `CMakeLists.txt`, as well as the KF version.
|
|
||||||
If you don’t want to depend on KDE, remove the ECM and KF5 dependencies, as well as `KColorCombo inBackground` from the UI. You’ll need to replace `inBackground->color()` with something else though.
|
|
||||||
|
|
|
||||||
75
init.sh
75
init.sh
|
|
@ -1,75 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# set -x # debug
|
|
||||||
set -e # abort on errors
|
|
||||||
cd "${0%/*}" # where this script is located
|
|
||||||
|
|
||||||
usage() {
|
|
||||||
{
|
|
||||||
echo "Usage:"
|
|
||||||
echo
|
|
||||||
echo " ./init.sh 'Project Name' [ internal-name ]"
|
|
||||||
echo
|
|
||||||
echo "Project name may be anything you like, in any language, with spaces (but not other control characters), etc."
|
|
||||||
echo
|
|
||||||
echo "Technical name must be ASCII alphanumeric (a-z, 0-9, also _ and - are allowed), preferably all-lowercase. If omitted, it will be generated from the project name (but that only works if the latter is ASCII too)."
|
|
||||||
echo
|
|
||||||
echo "Running this script with no arguments shows this message"
|
|
||||||
} | fold -s 2>&1
|
|
||||||
}
|
|
||||||
|
|
||||||
name="$1"
|
|
||||||
[ -n "$name" ] || { usage; exit 0; } 2>&1
|
|
||||||
echo -n "$name" | LC_ALL=C grep '[[:cntrl:]]' && { echo 'Project name must not contain any control characters'; exit 2; } 2>&1
|
|
||||||
name="$(echo -n $name)" # normalize whitespace
|
|
||||||
|
|
||||||
techname="$2"
|
|
||||||
if [ -z "$techname" ]; then
|
|
||||||
techname=$(
|
|
||||||
echo -n $name |
|
|
||||||
LC_ALL=C tr ' ' '-' |
|
|
||||||
LC_ALL=C tr -d -c '[:alnum:]-_' |
|
|
||||||
LC_ALL=C tr '[:upper:]' '[:lower:]' |
|
|
||||||
cat
|
|
||||||
)
|
|
||||||
echo "Technical name not specified; autogenerated: \"$techname\"" >&2
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -n $techname | LC_ALL=C grep '[^0-9A-Za-z_-]' && { echo 'Technical name must be ASCII alphanumeric'; exit 2; } 2>&1
|
|
||||||
echo -n $techname | LC_ALL=C grep -q '^[A-Za-z]' || { echo 'Technical name must start with an ASCII letter'; exit 2; } 2>&1
|
|
||||||
echo -n $techname | LC_ALL=C grep -q '[A-Za-z0-9]$' || { echo 'Technical name must end with an ASCII letter or digit'; exit 2; } 2>&1
|
|
||||||
|
|
||||||
echo "Project name: $name"
|
|
||||||
echo "Internal name: $techname"
|
|
||||||
|
|
||||||
if ! [ -e .git ]; then
|
|
||||||
alias git='echo skipping:'
|
|
||||||
fi
|
|
||||||
|
|
||||||
# detach from the skeleton repository
|
|
||||||
# oldurl="$(git remote -v get-url origin)"
|
|
||||||
git remote remove origin
|
|
||||||
|
|
||||||
# remove this script from the project (but keep on disk for now)
|
|
||||||
git rm --cached init.sh
|
|
||||||
|
|
||||||
# escape HTML special characters (&, <, and >), but also sed special characters (& again, \, and /)
|
|
||||||
htmlname=$(echo -n "$name" | sed 's/&/\&/g; s/</\</g; s/>/\>/g; s:[\\/&]:\\&:g')
|
|
||||||
sed -i "s/PROJECT NAME/$htmlname/" ui/src/main_window.ui
|
|
||||||
|
|
||||||
# escape Rust special characters (" and \; don't worry of the others as they are unlikely enough and easy to fix manually), and also sed special characters (&, \, and /)
|
|
||||||
quotname=$(echo -n "$name" | sed 's/"/\\"/g; s:[\\/&]:\\&:g')
|
|
||||||
sed -i "s/PROJECT NAME/$quotname/" src/main.rs
|
|
||||||
|
|
||||||
# $techname is alphanumeric, nothing to escape
|
|
||||||
grep -l -r PROJECT-NAME | xargs sed -i "s/PROJECT-NAME/$techname/g"
|
|
||||||
|
|
||||||
# replace - with _ to form a valid snake_case identifier
|
|
||||||
ident=$(echo -n $techname | LC_ALL=C tr '-' '_')
|
|
||||||
grep -l -r PROJECT_NAME | xargs sed -i "s/PROJECT_NAME/$ident/g"
|
|
||||||
|
|
||||||
# black magic to convert snake_case to PascalCase
|
|
||||||
pascal=$(echo -n $ident | LC_ALL=C tr '_' '\n' | LC_ALL=C awk -v FIELDWIDTHS='1 1000' -v ORS='' '{print toupper($1) $2}')
|
|
||||||
grep -l -r PROJECTNAME | xargs sed -i "s/PROJECTNAME/$pascal/g"
|
|
||||||
|
|
||||||
git commit -a -m "MORPH INTO: $name"
|
|
||||||
Loading…
Reference in New Issue
Block a user