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

Dark fusion theme [Qt6, Win11] #535

Open
eddiezato opened this issue Feb 19, 2024 · 8 comments
Open

Dark fusion theme [Qt6, Win11] #535

eddiezato opened this issue Feb 19, 2024 · 8 comments

Comments

@eddiezato
Copy link

I tried to enable the fusion theme when building with Qt6 on Win11. And it already looks pretty nice. Maybe we need an option.

image

@easymodo
Copy link
Owner

So it now follows the system dark theme setting on windows?

Maybe worth switching to it by default if available, instead of an option

@eddiezato
Copy link
Author

So it now follows the system dark theme setting on windows?

Yep, including the titlebar.

@danmacode
Copy link

I'm following these instructions to compile from source: https://github.com/easymodo/qimgv/wiki/Compiling-qimgv-from-source

Can you share the changes needed to enable Qt6?

@eddiezato
Copy link
Author

eddiezato commented May 2, 2024

I just roughly replace Qt5 with Qt6 in CMakeLists:

sed -i 's|^find_package(Qt5|find_package(Qt6|;s|^if(Qt5_FOUND)|if(NOT Qt6_FOUND)|' CMakeLists.txt

I can share my build script for Win11, but it is strictly for msys2/ucrt64.

@niZyalB
Copy link

niZyalB commented Aug 11, 2024

I just roughly replace Qt5 with Qt6 in CMakeLists:

sed -i 's|^find_package(Qt5|find_package(Qt6|;s|^if(Qt5_FOUND)|if(NOT Qt6_FOUND)|' CMakeLists.txt

I can share my build script for Win11, but it is strictly for msys2/ucrt64.

would be nice if you could share your build script please.

@eddiezato
Copy link
Author

@niZyalB sure:

qimgv.sh
#!/bin/bash
while getopts 'csajpeoqd' flag ; do
    case "${flag}" in
        c) CLR=1 ;;     # remove ucrt folder
        s) DSRC=1 ;;    # download source-code
        a) BAVIF=1 ;;   # build libavif
        j) BJXL=1 ;;    # build libjxl
        p) BPLGS=1 ;;   # build plugins
        e) BEXIV=1 ;;   # build exiv2
        o) BOPCV=1 ;;   # build opencv
        q) BQMGV=1 ;;   # build qimgv
        d) DQMGV=1 ;;   # deploy qimgv
    esac
done

if [[ $OPTIND == 1 ]]; then
    printf '\nOptions:\n'
    printf '   -c   remove ucrt folder\n'
    printf '   -s   download source-code\n'
    printf '   -a   build libavif\n'
    printf '   -j   build libjxl\n'
    printf '   -p   build plugins\n'
    printf '   -e   build exiv2\n'
    printf '   -o   build opencv\n'
    printf '   -q   build qimgv\n'
    printf '   -d   deploy qimgv\n'
    exit
fi

if [[ $MSYSTEM != 'UCRT64' ]] ; then
    printf '\e[1;31mNot UCRT64 environment\e[0m\n'
    exit 1
fi

set -e
MGNT='\e[1;35m'
RST='\e[0m'
export CC=clang CXX=clang++
CFL='-fuse-ld=lld -flto=thin -ffunction-sections -fdata-sections -march=native -O2 -pipe'
LFL='-fuse-ld=lld -flto=thin -Wl,--gc-sections -Wl,-O1'

if [[ $CLR == 1 ]] ; then
    printf "\n${MGNT}:: Remove ucrt folder ::${RST}\n"
    rm -rf ucrt
fi

mkdir -p ucrt/install
EXTDIR=$(realpath ucrt/install)
cd ucrt

# download source-code
if [[ $DSRC == 1 ]] ; then
    # download libavif
    if [[ ! -d libavif ]]; then
        printf "\n${MGNT}:: Download libavif ::${RST}\n"
        git clone --depth 1 --branch v1.1.1 https://github.com/AOMediaCodec/libavif.git
        cd libavif/ext
        if [[ ! -d dav1d ]]; then
            branch=($(grep -i "git clone" dav1d.cmd))
            git clone -b ${branch[3]} --depth 1 https://code.videolan.org/videolan/dav1d.git
            mkdir -p dav1d/build
        fi
        if [[ ! -d libyuv ]]; then
            branch=($(grep -i "git checkout" libyuv.cmd))
            git clone --single-branch https://chromium.googlesource.com/libyuv/libyuv
            cd libyuv
            git checkout ${branch[2]}
            cd ..
        fi
        cd ../..
    fi
    # download libjxl
    if [[ ! -d libjxl ]]; then
        printf "\n${MGNT}:: Download libjxl ::${RST}\n"
        git clone --branch v0.10.3 --depth 1 https://github.com/libjxl/libjxl.git
    fi
    # download qavif
    if [[ ! -d qt-avif-image-plugin ]]; then
        printf "\n${MGNT}:: Download qavif ::${RST}\n"
        git clone --depth 1 https://github.com/novomesk/qt-avif-image-plugin.git
        sed -i 's|set(REQUIRED_QT_VERSION 5.14.0)|set(REQUIRED_QT_VERSION 6.7.0)|' qt-avif-image-plugin/CMakeLists.txt
        sed -i 's|${QT_MAJOR_VERSION}|6|' qt-avif-image-plugin/CMakeLists.txt
        sed -i 's|${QT_MAJOR_VERSION}|6|' qt-avif-image-plugin/src/CMakeLists.txt
    fi
    # download qjpegxl
    if [[ ! -d qt-jpegxl-image-plugin ]]; then
        printf "\n${MGNT}:: Download qjpegxl ::${RST}\n"
        git clone --depth 1 https://github.com/novomesk/qt-jpegxl-image-plugin.git
        sed -i 's|set(REQUIRED_QT_VERSION 5.14.0)|set(REQUIRED_QT_VERSION 6.7.0)|' qt-jpegxl-image-plugin/CMakeLists.txt
        sed -i 's|${QT_MAJOR_VERSION}|6|' qt-jpegxl-image-plugin/CMakeLists.txt
        sed -i 's|${QT_MAJOR_VERSION}|6|' qt-jpegxl-image-plugin/src/CMakeLists.txt
    fi
    # download exif
    if [[ ! -d exiv2 ]]; then
        printf "\n${MGNT}:: Download exiv2 ::${RST}\n"
        git clone --branch 'v0.28.3' --depth 1 https://github.com/Exiv2/exiv2.git
    fi
    # download opencv
    if [[ ! -d opencv ]]; then
        printf "\n${MGNT}:: Download opencv ::${RST}\n"
        git clone --depth 1 --branch '4.10.0' https://github.com/opencv/opencv.git
    fi
    # download qimgv
    if [[ ! -d qimgv ]]; then
        printf "\n${MGNT}:: Download qimgv ::${RST}\n"
        git clone https://github.com/easymodo/qimgv.git
        sed -i 's|RoundPreferFloor|PassThrough|' qimgv/qimgv/main.cpp
        sed -i 's|a.setStyle(new ProxyStyle);|if(QStyleFactory::keys().contains("Fusion"))\n        a.setStyle(new ProxyStyle(QStyleFactory::create("Fusion")));\n    else\n        a.setStyle(new ProxyStyle);|' qimgv/qimgv/main.cpp
        sed -i 's|virtual void|ProxyStyle(QStyle *style = nullptr) : QProxyStyle(style) {}\n    virtual void|' qimgv/qimgv/proxystyle.h
        sed -i 's|^find_package(Qt5|find_package(Qt6|;s|^if(Qt5_FOUND)|if(NOT Qt6_FOUND)|' qimgv/CMakeLists.txt
        sed -i 's|toStdWString|toStdString|;s|fromStdWString|fromStdString|' qimgv/qimgv/utils/stuff.cpp
        sed -i 's|std::wstring|std::string|;s|wchar_t|char|' qimgv/qimgv/utils/stuff.h
    fi
fi

# build libavif
if [[ $BAVIF == 1 ]] ; then
    printf "\n${MGNT}:: Build libavif ::${RST}\n"
    cd libavif/ext
    # build dav1d
    cd dav1d
    rm -rf build
    CFLAGS="$CFL" CXXFLAGS="$CFL" LDFLAGS="$LFL" meson setup --default-library=static --buildtype=release -Denable_tools=false -Denable_tests=false build ./
    ninja -C build
    cd ..
    # build libyuv
    cd libyuv
    rm -rf build
    cmake -B build -G Ninja -S ./ \
        -DBUILD_SHARED_LIBS=OFF \
        -DCMAKE_BUILD_TYPE=Release \
        -DCMAKE_C_FLAGS="$CFL" -DCMAKE_CXX_FLAGS="$CFL" -DCMAKE_EXE_LINKER_FLAGS="$LFL" \
        -Wno-dev
    ninja -C build yuv
    cd ../..
    # build libavif
    rm -rf build
    cmake -B build -G Ninja -S ./ \
        -DCMAKE_INSTALL_PREFIX="$EXTDIR" \
        -DCMAKE_BUILD_TYPE=Release \
        -DAVIF_CODEC_DAV1D=ON \
        -DAVIF_LOCAL_DAV1D=ON \
        -DAVIF_LOCAL_LIBYUV=ON \
        -DCMAKE_C_FLAGS="$CFL" -DCMAKE_CXX_FLAGS="$CFL" -DCMAKE_EXE_LINKER_FLAGS="$LFL"
    ninja install -C build
    cd ..
fi

# build libjxl
if [[ $BJXL == 1 ]] ; then
    printf "\n${MGNT}:: Build libjxl ::${RST}\n"
    cd libjxl
    rm -rf build
    cmake -B build -G Ninja -S ./ \
        -DCMAKE_INSTALL_PREFIX="$EXTDIR" \
        -DCMAKE_BUILD_TYPE=Release \
        -DBUILD_TESTING=OFF \
        -DJPEGXL_ENABLE_TOOLS=OFF \
        -DJPEGXL_ENABLE_JPEGLI=OFF \
        -DJPEGXL_ENABLE_JPEGLI_LIBJPEG=OFF \
        -DJPEGXL_ENABLE_DOXYGEN=OFF \
        -DJPEGXL_ENABLE_MANPAGES=OFF \
        -DJPEGXL_ENABLE_BENCHMARK=OFF \
        -DJPEGXL_ENABLE_EXAMPLES=OFF \
        -DJPEGXL_ENABLE_JNI=OFF \
        -DJPEGXL_ENABLE_SJPEG=OFF \
        -DJPEGXL_ENABLE_OPENEXR=OFF \
        -DJPEGXL_ENABLE_SKCMS=OFF \
        -DJPEGXL_WARNINGS_AS_ERRORS=OFF \
        -DJPEGXL_FORCE_SYSTEM_BROTLI=ON \
        -DJPEGXL_FORCE_SYSTEM_LCMS2=ON \
        -DJPEGXL_FORCE_SYSTEM_HWY=ON \
        -DCMAKE_C_FLAGS="$CFL" -DCMAKE_CXX_FLAGS="$CFL" -DCMAKE_EXE_LINKER_FLAGS="$LFL" \
        -Wno-dev
    ninja install -C build
    cd ..
fi

# build plugins
if [[ $BPLGS == 1 ]] ; then
    # build qavif
    printf "\n${MGNT}:: Build qavif ::${RST}\n"
    cd qt-avif-image-plugin
    rm -rf build
    cmake -B build -G Ninja -S ./ -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$EXTDIR" \
        -DCMAKE_C_FLAGS="$CFL" -DCMAKE_CXX_FLAGS="$CFL" -DCMAKE_EXE_LINKER_FLAGS="$LFL"
    ninja -C build
    cd ..
    # build qjpegxl
    printf "\n${MGNT}:: Build qjpegxl ::${RST}\n"
    cd qt-jpegxl-image-plugin
    rm -rf build
    cmake -B build -G Ninja -S ./ -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$EXTDIR" \
        -DCMAKE_C_FLAGS="$CFL" -DCMAKE_CXX_FLAGS="$CFL" -DCMAKE_EXE_LINKER_FLAGS="$LFL"
    ninja -C build
    cd ..
fi

# build exiv2
if [[ $BEXIV == 1 ]] ; then
    printf "\n${MGNT}:: Build exiv2 ::${RST}\n"
    cd exiv2
    rm -rf build
    cmake -B build -G Ninja -S ./ \
        -DCMAKE_INSTALL_PREFIX="$EXTDIR" \
        -DCMAKE_BUILD_TYPE=Release \
        -DEXIV2_ENABLE_VIDEO=OFF \
        -DEXIV2_ENABLE_INIH=OFF \
        -DEXIV2_BUILD_EXIV2_COMMAND=OFF \
        -DCMAKE_C_FLAGS="$CFL" -DCMAKE_CXX_FLAGS="$CFL -pthread" -DCMAKE_EXE_LINKER_FLAGS="$LFL"
    ninja install -C build
    cd ..
fi

# build opencv
if [[ $BOPCV == 1 ]] ; then
    printf "\n${MGNT}:: Build opencv ::${RST}\n"
    cd opencv
    rm -rf build
    cmake -B build -G Ninja -S ./ \
        -DCMAKE_INSTALL_PREFIX="$EXTDIR" \
        -DCMAKE_BUILD_TYPE=Release \
        -DBUILD_LIST='core,imgproc' \
        -DWITH_1394=OFF \
        -DWITH_AVIF=ON \
        -DWITH_VTK=OFF \
        -DWITH_FFMPEG=OFF \
        -DWITH_GSTREAMER=OFF \
        -DWITH_DSHOW=OFF \
        -DWITH_QUIRC=OFF \
        -DBUILD_SHARED_LIBS=ON \
        -DCMAKE_C_FLAGS="$CFL" -DCMAKE_CXX_FLAGS="$CFL" -DCMAKE_EXE_LINKER_FLAGS="$LFL"
    ninja install -C build
    cd ..
fi

# build qimgv
if [[ $BQMGV == 1 ]] ; then
    printf "\n${MGNT}:: Build qimgv ::${RST}\n"
    cd qimgv
    rm -rf build
    cmake -B build -G Ninja -S ./ \
        -DCMAKE_BUILD_TYPE=Release \
        -DVIDEO_SUPPORT=OFF \
        -DOPENCV_SUPPORT=ON \
        -DEXIV2=ON \
        -DCMAKE_PREFIX_PATH="$EXTDIR" \
        -DCMAKE_C_FLAGS="$CFL" -DCMAKE_CXX_FLAGS="$CFL" -DCMAKE_EXE_LINKER_FLAGS="$LFL"
    ninja -C build
    cd ..
fi

# deploy qimgv
if [[ $DQMGV == 1 ]] ; then
    # copying dependencies
    printf "\n${MGNT}:: Deploy portable qimgv ::${RST}\n"
    rm -rf qimgv_w64
    mkdir qimgv_w64
    cp qimgv/build/qimgv/qimgv.exe qimgv_w64/
    windeployqt-qt6 qimgv_w64/qimgv.exe \
        --release \
        --compiler-runtime \
        --no-system-d3d-compiler \
        --no-translations \
        --skip-plugin-types generic,networkinformation,tls \
        --qtpaths "/ucrt64/bin/qtpaths-qt6.exe"
    printf 'Copying dependencies '
    cp install/{bin/lib{avif,exiv2,jxl*}.dll,x64/mingw/bin/libopencv_*.dll} qimgv_w64/ && printf '.'
    for aj in 'avif' 'jpegxl'; do cp "qt-$aj-image-plugin/build/bin/imageformats/libq${aj}6.dll" "qimgv_w64/imageformats/q$aj.dll" && printf '.'; done
    mkdir -p qimgv_w64/data/mime/packages && cp libjxl/plugins/mime/image-jxl.xml qimgv_w64/data/mime/packages/ && printf '.'
    while
        files2=$files1
        files1=$(ldd qimgv_w64/{*.{exe,dll},imageformats/*.dll} | grep "/ucrt64/bin/" | grep -v 'Qt6' | sed 's/.* => //;s/ (.*//' | sort -u)
        printf '.'
        for f in $files1; do
            cp -u $f qimgv_w64/
        done
        [[ $files1 != $files2 ]]
    do :; done
    echo 'ok'
    # strip size
    printf 'Reduce file sizes .'
    strip -s qimgv_w64/{qimgv.exe,{./,*/}*.dll}
    printf 'ok\n'
fi

@niZyalB
Copy link

niZyalB commented Aug 11, 2024

@niZyalB sure:
qimgv.sh

Thanks, I got it to work without much of a hitch but it seems like when you enable video support it doesn't seem to work. Could it be that the player_mpv.dll doesn't compile well with qt6?

@eddiezato
Copy link
Author

Dunno, since I use mpv independently of qimgv and have never tried to compile with its support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants