diff --git a/.github/workflows/ci-macOS.yml b/.github/workflows/ci-macOS.yml new file mode 100644 index 000000000..dd119fc2f --- /dev/null +++ b/.github/workflows/ci-macOS.yml @@ -0,0 +1,83 @@ +name: macOS Build + +on: + push: + paths-ignore: + - '**/*.md' + pull_request: + paths-ignore: + - '**/*.md' + +concurrency: + group: ${{ github.workflow}}-${{ github.head_ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + build: + runs-on: macos-14 + permissions: + actions: write + defaults: + run: + shell: bash + + steps: + - name: Setup XCode + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: 15.0.1 + + - name: Show current version of Xcode + run: xcodebuild -version + + - name: Checkout repository + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Setup Homebrew + id: set-up-homebrew + uses: Homebrew/actions/setup-homebrew@main + + - name: Show OpenSSL version + run: pkg-config --cflags libcrypto + + - name: Install Packages + run: brew install openssl + miniupnpc + rapidjson + sqlcipher + bzip2 + zlib + botan@2 + libxslt + libxml2 + qt + + - name: Checkout submodules + run: | + env + git submodule update --init --remote libbitdht/ libretroshare/ retroshare-webui/ + git submodule update --init supportlibs/librnp supportlibs/rapidjson supportlibs/restbed openpgpsdk/ + + - name: CI-Build + run: | + qmake6 . -r "CONFIG+=rs_macos14.0" "CONFIG+=release" "CONFIG+=rs_autologin" "CONFIG+=no_rs_sam3" "CONFIG+=no_rs_sam3_libsam3" "CONFIG+=rs_no_rnplib" \ + INCLUDEPATH+="/opt/homebrew/opt/openssl@3/include" \ + INCLUDEPATH+="/opt/homebrew/opt/rapidjson/include" \ + INCLUDEPATH+="/opt/homebrew/opt/sqlcipher/include" \ + INCLUDEPATH+="/opt/homebrew/opt/miniupnpc/include" \ + INCLUDEPATH+="/opt/homebrew/opt/libxslt/include" \ + INCLUDEPATH+="/opt/homebrew/opt/libxml2/include" \ + QMAKE_LIBDIR+="/opt/homebrew/opt/openssl@3/lib" \ + QMAKE_LIBDIR+="/opt/homebrew/opt/rapidjson/lib" \ + QMAKE_LIBDIR+="/opt/homebrew/opt/sqlcipher/lib" \ + QMAKE_LIBDIR+="/opt/homebrew/opt/miniupnpc/lib" \ + QMAKE_LIBDIR+="/opt/homebrew/opt/libxslt/lib" \ + QMAKE_LIBDIR+="/opt/homebrew/opt/libxml2/lib" \ + CONFIG+=no_retroshare_service \ + CONFIG+=no_retroshare_friendserver + make diff --git a/.github/workflows/ci-mingw64-Qt6.yml b/.github/workflows/ci-mingw64-Qt6.yml new file mode 100644 index 000000000..946aa912e --- /dev/null +++ b/.github/workflows/ci-mingw64-Qt6.yml @@ -0,0 +1,71 @@ +name: MINGW64 Qt6 Build + +on: + push: + paths-ignore: + - '**/*.md' + pull_request: + paths-ignore: + - '**/*.md' + +concurrency: + group: ${{ github.workflow}}-${{ github.head_ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + build: + runs-on: windows-latest + permissions: + actions: write + defaults: + run: + shell: msys2 {0} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Setup MSYS2 + uses: msys2/setup-msys2@40677d36a502eb2cf0fb808cc9dec31bf6152638 # v2.28.0 + with: + msystem: MINGW64 + update: true + install: >- + base-devel + git + wget + p7zip + gcc + perl + ruby + doxygen + cmake + mingw-w64-x86_64-toolchain + mingw-w64-x86_64-miniupnpc + mingw-w64-x86_64-libxslt + mingw-w64-x86_64-xapian-core + mingw-w64-x86_64-sqlcipher + mingw-w64-x86_64-qt6-base + mingw-w64-x86_64-qt6-multimedia + mingw-w64-x86_64-qt6 + mingw-w64-x86_64-ccmake + mingw-w64-x86_64-rapidjson + mingw-w64-x86_64-json-c + mingw-w64-x86_64-libbotan + mingw-w64-x86_64-asio + + - name: Checkout submodules + run: | + env + git submodule update --init --remote libbitdht/ libretroshare/ retroshare-webui/ + git submodule update --init supportlibs/librnp supportlibs/rapidjson supportlibs/restbed + + - name: Build + run: | + qmake6 . -r -spec win32-g++ "CONFIG+=release" "CONFIG+=rs_autologin" "CONFIG+=no_rs_sam3" "CONFIG+=no_rs_sam3_libsam3" + mingw32-make -j3 diff --git a/.github/workflows/ci-mingw64.yml b/.github/workflows/ci-mingw64.yml new file mode 100644 index 000000000..d562938b3 --- /dev/null +++ b/.github/workflows/ci-mingw64.yml @@ -0,0 +1,70 @@ +name: MINGW64 Qt5 Build + +on: + push: + paths-ignore: + - '**/*.md' + pull_request: + paths-ignore: + - '**/*.md' + +concurrency: + group: ${{ github.workflow}}-${{ github.head_ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + build: + runs-on: windows-latest + permissions: + actions: write + defaults: + run: + shell: msys2 {0} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Setup MSYS2 + uses: msys2/setup-msys2@40677d36a502eb2cf0fb808cc9dec31bf6152638 # v2.28.0 + with: + msystem: MINGW64 + update: true + install: >- + base-devel + git + wget + p7zip + gcc + perl + ruby + doxygen + cmake + mingw-w64-x86_64-toolchain + mingw-w64-x86_64-miniupnpc + mingw-w64-x86_64-libxslt + mingw-w64-x86_64-xapian-core + mingw-w64-x86_64-sqlcipher + mingw-w64-x86_64-qt5-base + mingw-w64-x86_64-qt5-multimedia + mingw-w64-x86_64-ccmake + mingw-w64-x86_64-rapidjson + mingw-w64-x86_64-json-c + mingw-w64-x86_64-libbotan + mingw-w64-x86_64-asio + + - name: Checkout submodules + run: | + env + git submodule update --init --remote libbitdht/ libretroshare/ retroshare-webui/ + git submodule update --init supportlibs/librnp supportlibs/rapidjson supportlibs/restbed + + - name: CI-Build + run: | + qmake . -r -spec win32-g++ "CONFIG+=release" "CONFIG+=rs_autologin" "CONFIG+=no_rs_sam3" "CONFIG+=no_rs_sam3_libsam3" + mingw32-make -j3 diff --git a/.github/workflows/ci-ucrt64.yml b/.github/workflows/ci-ucrt64.yml new file mode 100644 index 000000000..df569b8bf --- /dev/null +++ b/.github/workflows/ci-ucrt64.yml @@ -0,0 +1,70 @@ +name: UCRT64 Qt5 Build + +on: + push: + paths-ignore: + - '**/*.md' + pull_request: + paths-ignore: + - '**/*.md' + +concurrency: + group: ${{ github.workflow}}-${{ github.head_ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + build: + runs-on: windows-latest + permissions: + actions: write + defaults: + run: + shell: msys2 {0} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Setup MSYS2 + uses: msys2/setup-msys2@40677d36a502eb2cf0fb808cc9dec31bf6152638 # v2.28.0 + with: + msystem: UCRT64 + update: true + install: >- + base-devel + git + wget + p7zip + gcc + perl + ruby + doxygen + cmake + mingw-w64-ucrt-x86_64-toolchain + mingw-w64-ucrt-x86_64-miniupnpc + mingw-w64-ucrt-x86_64-libxslt + mingw-w64-ucrt-x86_64-xapian-core + mingw-w64-ucrt-x86_64-sqlcipher + mingw-w64-ucrt-x86_64-qt5-base + mingw-w64-ucrt-x86_64-qt5-multimedia + mingw-w64-ucrt-x86_64-ccmake + mingw-w64-ucrt-x86_64-rapidjson + mingw-w64-ucrt-x86_64-json-c + mingw-w64-ucrt-x86_64-libbotan + mingw-w64-ucrt-x86_64-asio + + - name: Checkout submodules + run: | + env + git submodule update --init --remote libbitdht/ libretroshare/ retroshare-webui/ + git submodule update --init supportlibs/librnp supportlibs/rapidjson supportlibs/restbed + + - name: CI-Build + run: | + qmake . -r -spec win32-g++ "CONFIG+=release" "CONFIG+=rs_autologin" "CONFIG+=no_rs_sam3" "CONFIG+=no_rs_sam3_libsam3" + mingw32-make -j3 diff --git a/.github/workflows/ubuntu-qt5_c-cpp.yml b/.github/workflows/ubuntu-qt5_c-cpp.yml new file mode 100644 index 000000000..4e2fa5a80 --- /dev/null +++ b/.github/workflows/ubuntu-qt5_c-cpp.yml @@ -0,0 +1,40 @@ +name: Ubuntu Qt 5 C/C++ CI + +on: + push: + paths-ignore: + - '**/*.md' + pull_request: + paths-ignore: + - '**/*.md' + +jobs: + build: + + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v4 + - name: git init + run: git submodule update --init --remote libbitdht/ libretroshare/ openpgpsdk/ retroshare-webui/ && git --no-pager log --max-count 1 + - name: git submodule supportlibs + run: git submodule update --init supportlibs/librnp supportlibs/restbed #supportlibs/rapidjson + - name: run apt update + run: sudo apt-get update + - name: apt install + run: sudo apt-get install g++ cmake qt5-qmake qtmultimedia5-dev libqt5x11extras5-dev libasio-dev libbz2-dev libjson-c-dev libssl-dev libsqlcipher-dev libupnp-dev libxss-dev rapidjson-dev libbotan-2-dev doxygen libsecret-1-dev libxml2-dev libxslt1-dev libcurl4-openssl-dev + - name: print working directory + run: pwd && ls -la + - name: qmake + run: | + qmake CONFIG+=debug \ + CONFIG+=rs_autologin \ + CONFIG+=rs_webui \ + CONFIG+=rs_jsonapi \ + CONFIG+=wikipoos \ + CONFIG+=gxsthewire \ + CONFIG+=retroshare_plugins + - name: make + run: make + - name: make check + run: make check diff --git a/.github/workflows/ubuntu-qt6_c-cpp.yml b/.github/workflows/ubuntu-qt6_c-cpp.yml new file mode 100644 index 000000000..dd2fdb0e7 --- /dev/null +++ b/.github/workflows/ubuntu-qt6_c-cpp.yml @@ -0,0 +1,40 @@ +name: Ubuntu Qt 6 C/C++ CI + +on: + push: + paths-ignore: + - '**/*.md' + pull_request: + paths-ignore: + - '**/*.md' + +jobs: + build: + + runs-on: ubuntu-24.04 + + steps: + - uses: actions/checkout@v4 + - name: git init + run: git submodule update --init --remote libbitdht/ libretroshare/ openpgpsdk/ retroshare-webui/ && git --no-pager log --max-count 1 + - name: git submodule supportlibs + run: git submodule update --init supportlibs/librnp supportlibs/restbed #supportlibs/rapidjson + - name: run apt update + run: sudo apt-get update + - name: apt install + run: sudo apt-get install g++ cmake qt6-base-dev qt6-multimedia-dev libasio-dev libbz2-dev libjson-c-dev libssl-dev libsqlcipher-dev libupnp-dev libxss-dev rapidjson-dev libbotan-2-dev doxygen qt6-5compat-dev libqt6core5compat6-dev libsecret-1-dev libxml2-dev libxslt1-dev libcurl4-openssl-dev + - name: print working directory + run: pwd && ls -la + - name: qmake + run: | + qmake6 CONFIG+=debug \ + CONFIG+=rs_autologin \ + CONFIG+=rs_webui \ + CONFIG+=rs_jsonapi \ + CONFIG+=wikipoos \ + CONFIG+=gxsthewire \ + CONFIG+=retroshare_plugins + - name: make + run: make + - name: make check + run: make check diff --git a/README.asciidoc b/README.asciidoc deleted file mode 100644 index 6e5c52ce9..000000000 --- a/README.asciidoc +++ /dev/null @@ -1,70 +0,0 @@ -// SPDX-FileCopyrightText: Retroshare Team -// SPDX-License-Identifier: CC-BY-SA-4.0 - -= RetroShare - -RetroShare is a decentralized, private, secure, cross-platform, communication -toolkit. -RetroShare provides file sharing, chat, messages, forums, channels and more. - -|=============================================================================== -| Developer Documentation | image:https://deepwiki.com/badge.svg[link="https://deepwiki.com/RetroShare/RetroShare",title="Ask DeepWiki"] -|=============================================================================== -.Build Status -|=============================================================================== -|GNU/Linux (via Gitlab CI) | image:https://gitlab.com/RetroShare/RetroShare/badges/master/pipeline.svg[link="https://gitlab.com/RetroShare/RetroShare/-/commits/master",title="pipeline status"] -|Windows (via AppVeyor) | image:https://ci.appveyor.com/api/projects/status/github/RetroShare/RetroShare?svg=true[link="https://ci.appveyor.com/project/RetroShare58622/retroshare"] -|macOS, (via Travis CI) | image:https://app.travis-ci.com/RetroShare/RetroShare.svg?branch=master[link="https://app.travis-ci.com/github/RetroShare/RetroShare"] -|libretroshare GNU/Linux, Android (via Gitlab CI) | image:https://gitlab.com/RetroShare/libretroshare/badges/master/pipeline.svg[link="https://gitlab.com/RetroShare/libretroshare/-/commits/master",title="pipeline status"] -|=============================================================================== - -== Get the source - -Clone this repository, enter the directory and then get the submodules with the -following command - -[source,bash] --------- -git submodule update --init --remote --force libbitdht/ libretroshare/ openpgpsdk/ --------- - - -== Compilation - -Short of comprehensive and updated documentation on how to build RetroShare -(for the many supported platforms it runs on), scripts and recipes are provided -in the aim of creating packages for the supported platforms (and more) -in the `build_scripts` directory of this repository. - -Those packaging receipts together with the continuous integration files -`.travis.yml` and `appveyor.yml` are a good source of knowledge on how to -compile RetroShare on different platforms. - - -== Using RetroShare on a headless computer with web UI - -WARNING: This section is outdated need to be adapted to the new web UI - -The web UI needs to be enabled as a parameter option to the retroshare-service: - -[source,bash] --------- -./retroshare-nogui --webinterface 9090 --docroot /usr/share/retroshare/webui/ --------- - -The web UI is only accessible on localhost:9090. It is advised to keep it that way so that your RS -cannot be controlled using an untrusted connection. - -To access your web UI from a distance, just open a SSH tunnel to it: - -[source,bash] --------- -distant_machine:~/ > ssh rs_host -L 9090:localhost:9090 -N --------- - -"rs_host" is the machine running `retroshare-nogui`. Then on the distant machine, access your web UI on - - - http://localhost:9090 - -(This can also be done from the RetroShare GUI.) diff --git a/README.md b/README.md new file mode 100644 index 000000000..217121af3 --- /dev/null +++ b/README.md @@ -0,0 +1,55 @@ +## RetroShare + +RetroShare is a decentralized, private, secure, cross-platform, communication +toolkit. +RetroShare provides file sharing, chat, messages, forums, channels, boards and more. + +[![GitHub release](https://img.shields.io/github/release/retroshare/retroshare.svg?label=latest%20release)](https://github.com/retroshare/retroshare/releases/latest) +[![Downloads](https://img.shields.io/github/downloads/retroshare/retroshare/total)](https://github.com/retroshare/retroshare/releases/latest) +[![MINGW64 Qt5 Build](https://github.com/RetroShare/RetroShare/actions/workflows/ci-mingw64.yml/badge.svg)](https://github.com/RetroShare/RetroShare/actions/workflows/ci-mingw64.yml) +[![UCRT64 Qt5 Build](https://github.com/RetroShare/RetroShare/actions/workflows/ci-ucrt64.yml/badge.svg)](https://github.com/RetroShare/RetroShare/actions/workflows/ci-ucrt64.yml) +[![MINGW64 Qt6 Build](https://github.com/RetroShare/RetroShare/actions/workflows/ci-mingw64-Qt6.yml/badge.svg)](https://github.com/RetroShare/RetroShare/actions/workflows/ci-mingw64-Qt6.yml) +[![GNU/Linux (via Gitlab CI)](https://gitlab.com/RetroShare/RetroShare/badges/master/pipeline.svg)](https://gitlab.com/RetroShare/RetroShare/-/commits/master) +[![libretroshare GNU/Linux, Android (via Gitlab CI)](https://gitlab.com/RetroShare/libretroshare/badges/master/pipeline.svg)](https://gitlab.com/RetroShare/libretroshare/-/commits/master) +[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/RetroShare/RetroShare) + +## Get the source + +Clone this repository, enter the directory and then get the submodules with the +following command + + git submodule update --init --remote --force libbitdht/ libretroshare/ openpgpsdk/ + + + +## Compilation + +Short of comprehensive and updated documentation on how to build RetroShare +(for the many supported platforms it runs on), scripts and recipes are provided +in the aim of creating packages for the supported platforms (and more) +in the [build_scripts](https://github.com/RetroShare/RetroShare/tree/master/build_scripts) directory of this repository. + +## Compilation on Windows +Follow this file : [WindowsMSys2_InstallGuide](https://github.com/RetroShare/RetroShare/blob/master/build_scripts/Windows-msys2/WindowsMSys2_InstallGuide.md) + +With QtCreator : [Windows-QtCreator-InstallGuide](https://github.com/RetroShare/RetroShare/blob/master/build_scripts/Windows/Windows-QtCreator-InstallGuide.md) + +## Compilation on MacOSX + +Follow this file : [MacOS_X_InstallGuide](https://github.com/RetroShare/RetroShare/blob/master/build_scripts/OSX/MacOS_X_InstallGuide.md) + +## Compilation on Linux + +Follow this file : [Linux_InstallGuide](https://github.com/RetroShare/RetroShare/blob/master/build_scripts/Debian+Ubuntu/Linux_InstallGuide.md) + +## Releases + +Latest release [here](https://github.com/RetroShare/RetroShare/releases) + +Other Builds [RetroShare Downloads](https://retroshare.cc/downloads.html) + + +## Documentation + +- [RetroShare Docs](https://retrosharedocs.readthedocs.io/en/latest/) + diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 5bc004fa1..000000000 --- a/appveyor.yml +++ /dev/null @@ -1,312 +0,0 @@ -# SPDX-FileCopyrightText: (C) 2004-2019 Retroshare Team -# SPDX-License-Identifier: CC0-1.0 - -# Notes: -# - Minimal appveyor.yml file is an empty file. All sections are optional. -# - Indent each level of configuration with 2 spaces. Do not use tabs! -# - All section names are case-sensitive. -# - Section names should be unique on each level. -# from example: -# https://github.com/Phonations/Joker/blob/master/appveyor.yml -# https://github.com/unicorn-engine/autobuild/blob/master/.appveyor.yml - -#---------------------------------# -# general configuration # -#---------------------------------# - -# version format -version: RetroShare-git-{branch}-{build} -image: Visual Studio 2019 - -# you can use {branch} name in version format too -# version: 1.0.{build}-{branch} - -# branches to build -branches: - # whitelist - #only: - # - master - - # blacklist - except: - - /^skipthisbranch$/ - -# Do not build on tags (GitHub only) -skip_tags: true - -# Skipping commits with particular message or from user -skip_commits: - message: /Created.*\.(png|jpg|jpeg|bmp|gif)/ # Regex for matching commit message - #author: Anonymous # Commit author's username, name, email or regexp maching one of these. - -#---------------------------------# -# environment configuration # -#---------------------------------# - -# Operating system (build VM template) -#os: Windows Server 2012 - -# scripts that are called at very beginning, before repo cloning -init: - - git config --global core.autocrlf input - #To get RDP while compiling - - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) -on_finish: - #To get RDP running after compiling - #- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) - -# clone directory -clone_folder: C:\projects\RetroShare - -# fetch repository as zip archive -#shallow_clone: true # default is "false" - -# set clone depth -clone_depth: 2000 # clone entire repository history if not defined - -environment: - global: -## Qt: https://www.appveyor.com/docs/installed-software#qt -# QTDIR: C:\Qt\5.10.1\mingw53_32 - MSYS2_ARCH: i686 - TARGET: i686_32-pc-msys - MINGW_PREFIX: C:\msys64\mingw32 - RS_DEPLOY: RetroShare_deploy - - -# build cache to preserve files/folders between builds -#cache: -# Disabled because it's bigger then supported by appveyor free plan -# - C:\msys64\var\cache\pacman\pkg - -# scripts that run after cloning repository -#install: -# # by default, all script lines are interpreted as batch -# - echo This is batch -# # to run script as a PowerShell command prepend it with ps: -# - ps: Write-Host 'This is PowerShell' -# # batch commands start from cmd: -# - cmd: echo This is batch again -# - cmd: set MY_VAR=12345 -install: - # We cannot get OBS submodule as it use illegal folder name for windows. - #- git submodule update --init - # Configuring MSys2 - - set PATH=C:\msys64\usr\bin;%PATH% - - set PATH=C:\msys64\mingw32\bin;%PATH% - - > - pacman --noconfirm -Sy - mingw-w64-i686-qt5 mingw-w64-i686-miniupnpc mingw-w64-i686-rapidjson - mingw-w64-i686-sqlcipher mingw-w64-i686-xapian-core mingw-w64-i686-cmark - #- set PATH=C:\msys64\mingw32\qt5-static\bin\;%PATH% - - # Configuring Qt -# - set PATH=%QTDIR%\bin;C:\Qt\Tools\mingw491_32\bin;%PATH% - - # Hack for new MSys2 - - copy C:\msys64\mingw32\i686-w64-mingw32\bin\ar.exe C:\msys64\mingw32\bin\i686-w64-mingw32-ar.exe - - copy C:\msys64\mingw32\i686-w64-mingw32\bin\ranlib.exe C:\msys64\mingw32\bin\i686-w64-mingw32-ranlib.exe - - copy C:\msys64\mingw32\bin\windres.exe C:\msys64\mingw32\bin\i686-w64-mingw32-windres.exe - - copy C:\msys64\mingw64\x86_64-w64-mingw32\bin\ar.exe C:\msys64\mingw64\bin\x86_64-w64-mingw32-ar.exe - - copy C:\msys64\mingw64\x86_64-w64-mingw32\bin\ranlib.exe C:\msys64\mingw64\bin\x86_64-w64-mingw32-ranlib.exe - - copy C:\msys64\mingw64\bin\windres.exe C:\msys64\mingw64\bin\x86_64-w64-mingw32-windres.exe - - # Work-around linker looking for Qt dll in wrong place - - copy C:\msys64\mingw32\bin\Qt5PrintSupport.dll C:\msys64\mingw32\lib\Qt5PrintSupport.dll - - copy C:\msys64\mingw32\bin\Qt5Widgets.dll C:\msys64\mingw32\lib\Qt5Widgets.dll - - copy C:\msys64\mingw32\bin\Qt5Multimedia.dll C:\msys64\mingw32\lib\Qt5Multimedia.dll - - copy C:\msys64\mingw32\bin\Qt5Gui.dll C:\msys64\mingw32\lib\Qt5Gui.dll - - copy C:\msys64\mingw32\bin\Qt5Network.dll C:\msys64\mingw32\lib\Qt5Network.dll - - copy C:\msys64\mingw32\bin\Qt5Xml.dll C:\msys64\mingw32\lib\Qt5Xml.dll - - copy C:\msys64\mingw32\bin\Qt5Core.dll C:\msys64\mingw32\lib\Qt5Core.dll - - -#---------------------------------# -# build configuration # -#---------------------------------# - -# build platform, i.e. x86, x64, Any CPU. This setting is optional. -platform: x86 - -# to add several platforms to build matrix: -#platform: -# - x86 -# - Any CPU - -# build Configuration, i.e. Debug, Release, etc. -configuration: Release - -# to add several configurations to build matrix: -#configuration: -# - Debug -# - Release - -# scripts to run before build -before_build: - - cd C:\projects\RetroShare - - git submodule update --init - - cd C:\projects\ - - mkdir RetroShare-build - - cd RetroShare-build -# - find C:\ > filelist.txt - -# scripts to run *after* solution is built and *before* automatic packaging occurs (web apps, NuGet packages, Azure Cloud Services) -before_package: - -# to run your custom scripts instead of automatic MSBuild -build_script: - - env - - qmake ../RetroShare -spec win32-g++ "CONFIG+=debug" - - mingw32-make -j3 - -# scripts to run after build -after_build: - - find . - - - mkdir %RS_DEPLOY% - - copy retroshare-gui\src\debug\retroshare.exe %RS_DEPLOY%\ - - copy retroshare-service\src\debug\retroshare-service.exe %RS_DEPLOY%\ -# - copy retroshare-service\src\retroshare-service.exe %RS_DEPLOY%\ -# - copy retroshare-gui\src\retroshare.exe %RS_DEPLOY%\ - -## In Debug build winedeplyqt forget the non debug Qt libs - - copy C:\msys64\mingw32\bin\Qt5Svg.dll %RS_DEPLOY%\ - - copy C:\msys64\mingw32\bin\Qt5Core.dll %RS_DEPLOY%\ - - copy C:\msys64\mingw32\bin\Qt5Multimedia.dll %RS_DEPLOY%\ - - copy C:\msys64\mingw32\bin\Qt5Widgets.dll %RS_DEPLOY%\ - - copy C:\msys64\mingw32\bin\Qt5Xml.dll %RS_DEPLOY%\ - - copy C:\msys64\mingw32\bin\Qt5PrintSupport.dll %RS_DEPLOY%\ - - copy C:\msys64\mingw32\bin\Qt5Gui.dll %RS_DEPLOY%\ - - copy C:\msys64\mingw32\bin\Qt5Network.dll %RS_DEPLOY%\ - - - mkdir %RS_DEPLOY%\playlistformats\ - - copy C:\msys64\mingw32\share\qt5\plugins\playlistformats\qtmultimedia_m3u.dll %RS_DEPLOY%\playlistformats - - - mkdir %RS_DEPLOY%\printsupport\ - - copy C:\msys64\mingw32\share\qt5\plugins\printsupport\windowsprintersupport.dll %RS_DEPLOY%\printsupport\ - - - mkdir %RS_DEPLOY%\iconengines\ - - copy C:\msys64\mingw32\share\qt5\plugins\iconengines\qsvgicon.dll %RS_DEPLOY%\iconengines\ - - - mkdir %RS_DEPLOY%\bearer\ - - copy C:\msys64\mingw32\share\qt5\plugins\bearer\qgenericbearer.dll %RS_DEPLOY%\bearer\ - - - mkdir %RS_DEPLOY%\mediaservice\ - - copy C:\msys64\mingw32\share\qt5\plugins\mediaservice\qtmedia_audioengine.dll %RS_DEPLOY%\mediaservice\ - - copy C:\msys64\mingw32\share\qt5\plugins\mediaservice\dsengine.dll %RS_DEPLOY%\mediaservice\ - - - mkdir %RS_DEPLOY%\styles\ - - copy C:\msys64\mingw32\share\qt5\plugins\styles\qwindowsvistastyle.dll %RS_DEPLOY%\styles\ - - - mkdir %RS_DEPLOY%\imageformats\ - - copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qwebp.dll %RS_DEPLOY%\imageformats\ - - copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qicns.dll %RS_DEPLOY%\imageformats\ - - copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qjpeg.dll %RS_DEPLOY%\imageformats\ - - copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qtiff.dll %RS_DEPLOY%\imageformats\ - - copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qtga.dll %RS_DEPLOY%\imageformats\ - - copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qjp2.dll %RS_DEPLOY%\imageformats\ - - copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qico.dll %RS_DEPLOY%\imageformats\ - - copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qwbmp.dll %RS_DEPLOY%\imageformats\ - - copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qicns.dll %RS_DEPLOY%\imageformats\ - - copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qgif.dll %RS_DEPLOY%\imageformats\ - - copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qsvg.dll %RS_DEPLOY%\imageformats\ - - - mkdir %RS_DEPLOY%\platforms\ - - copy C:\msys64\mingw32\share\qt5\plugins\platforms\qwindows.dll %RS_DEPLOY%\platforms\ - - - mkdir %RS_DEPLOY%\audio\ - - copy C:\msys64\mingw32\share\qt5\plugins\audio\qtaudio_windows.dll %RS_DEPLOY%\audio\ - - - windeployqt %RS_DEPLOY%\retroshare.exe - - - copy C:\msys64\mingw32\bin\libbz2*.dll %RS_DEPLOY%\ - #- copy C:\msys64\mingw32\bin\libeay32.dll %RS_DEPLOY%\ - - copy C:\OpenSSL-Win32\libeay32.dll %RS_DEPLOY%\ - - copy C:\msys64\mingw32\bin\libminiupnpc.dll %RS_DEPLOY%\ - - copy C:\msys64\mingw32\bin\libsqlcipher*.dll %RS_DEPLOY%\ - - copy C:\msys64\mingw32\bin\libsqlite3*.dll %RS_DEPLOY%\ - #- copy C:\msys64\mingw32\bin\ssleay32.dll %RS_DEPLOY%\ - - copy C:\OpenSSL-Win32\ssleay32.dll %RS_DEPLOY%\ - - copy C:\msys64\mingw32\bin\zlib*.dll %RS_DEPLOY%\ - - copy C:\msys64\mingw32\bin\libgcc_s_dw2*.dll %RS_DEPLOY%\ - - copy C:\msys64\mingw32\bin\libstdc*.dll %RS_DEPLOY%\ - - copy C:\msys64\mingw32\bin\libwinpthread*.dll %RS_DEPLOY%\ - - copy C:\msys64\mingw32\bin\libicu*.dll %RS_DEPLOY%\ - - copy C:\msys64\mingw32\bin\libpcre*.dll %RS_DEPLOY%\ - - copy C:\msys64\mingw32\bin\libharfbuzz*.dll %RS_DEPLOY%\ - - copy C:\msys64\mingw32\bin\libpng*.dll %RS_DEPLOY%\ - - copy C:\msys64\mingw32\bin\libfreetype*.dll %RS_DEPLOY%\ - - copy C:\msys64\mingw32\bin\libglib*.dll %RS_DEPLOY%\ - - copy C:\msys64\mingw32\bin\libgraphite2.dll %RS_DEPLOY%\ - - copy C:\msys64\mingw32\bin\libintl*.dll %RS_DEPLOY%\ - - copy C:\msys64\mingw32\bin\libiconv*.dll %RS_DEPLOY%\ - - copy C:\msys64\mingw32\bin\libjasper*.dll %RS_DEPLOY%\ - - copy C:\msys64\mingw32\bin\libjpeg*.dll %RS_DEPLOY%\ - - copy C:\msys64\mingw32\bin\libtiff*.dll %RS_DEPLOY%\ - - copy C:\msys64\mingw32\bin\libwebp*.dll %RS_DEPLOY%\ - - copy C:\msys64\mingw32\bin\libwebpdemux*.dll %RS_DEPLOY%\ - - copy C:\msys64\mingw32\bin\liblzma*.dll %RS_DEPLOY%\ - -## Needed for cmark - - copy C:\msys64\mingw32\bin\libcmark*.dll %RS_DEPLOY%\ - - copy C:\msys64\mingw32\bin\libdouble-conversion*.dll %RS_DEPLOY%\ - -# to disable automatic builds -#build: off - -#---------------------------------# -# artifacts configuration # -#---------------------------------# - -artifacts: - - path: '**\*.exe' - - path: filelist.txt - - path: $(RS_DEPLOY) - -# -# # pushing a single file -# - path: test.zip -# -# # pushing a single file with environment variable in path and "Deployment name" specified -# - path: MyProject\bin\$(configuration) -# name: myapp -# -# # pushing entire folder as a zip archive -# - path: logs - - -#---------------------------------# -# deployment configuration # -#---------------------------------# -#No deployment under unknown computer!!! - -#---------------------------------# -# global handlers # -#---------------------------------# - -# on successful build -#on_success: -# - do something - -# on build failure -#on_failure: -# - do something - -# after build failure or success -#on_finish: -# - do something - - -#---------------------------------# -# notifications # -#---------------------------------# - -notifications: - - # Email - - provider: Email - to: - - retrosharephenom@gmail.com - subject: 'Build {{status}}' # optional - message: "{{message}}, {{commitId}}, ..." # optional - on_build_status_changed: true diff --git a/build_scripts/Debian+Ubuntu/Linux_InstallGuide.md b/build_scripts/Debian+Ubuntu/Linux_InstallGuide.md new file mode 100644 index 000000000..b1591d9e9 --- /dev/null +++ b/build_scripts/Debian+Ubuntu/Linux_InstallGuide.md @@ -0,0 +1,170 @@ + +## Compilation on Linux + + +### Install package dependencies: +#### Debian / Ubuntu / Linux Mint +```bash + sudo apt-get install git g++ cmake libbz2-dev libjson-c-dev libssl-dev libsqlcipher-dev \ + libupnp-dev doxygen libxss-dev rapidjson-dev libbotan-2-dev libasio-dev +``` + +To compile with Qt5: +```bash + sudo apt-get install qt5-qmake qtmultimedia5-dev libqt5x11extras5-dev +``` + +To compile with Qt6: +```bash + sudo apt-get install qt6-base-dev qt6-multimedia-dev qt6-5compat-dev +``` + +Additional dependencies for Feedreader plugin: +```bash + sudo apt-get install libxml2-dev libxslt1-dev libcurl4-openssl-dev +``` + +Additional dependencies for Voip plugin: +```bash + sudo apt-get install libavcodec-dev libcurl4-openssl-dev \ + libqt5multimedia5-plugins libspeexdsp-dev +``` + +Autologin: +```bash + sudo apt install libsecret-1-dev +``` + +#### openSUSE +```bash + sudo zypper install git gcc-c++ cmake libqt5-qtbase-devel \ + libqt5-qtmultimedia-devel libqt5-qtx11extras-devel libbz2-devel \ + libopenssl-devel libupnp-devel libXss-devel sqlcipher-devel rapidjson-devel \ + json-c botan bzip2 +``` + +Additional packages to compile with Qt6: +```bash + sudo zypper install qt6-base-devel qt6-multimedia-devel qt6-qt5compat-devel +``` + +Additional dependencies for plugins: +```bash + sudo zypper install ffmpeg-4-libavcodec-devel libcurl-devel libxml2-devel \ + libxslt-devel speex-devel speexdsp-devel +``` + +#### Arch Linux / Manjaro / EndeavourOS +```bash + sudo pacman -S base-devel libgnome-keyring cmake qt5-tools qt5-multimedia qt5-x11extras \ + rapidjson doxygen libupnp libxslt libxss sqlcipher botan2 bzip2 json-c +``` + +To compile with Qt6: +```bash + sudo pacman -S qt6-base qt6-multimedia qt6-5compat +``` + +### Checkout the source code +```bash + cd ~ + git clone https://github.com/RetroShare/RetroShare.git retroshare +``` + +### Checkout the submodules +```bash + cd retroshare + git submodule update --init --remote libbitdht/ libretroshare/ openpgpsdk/ retroshare-webui/ + git submodule update --init --remote supportlibs/librnp supportlibs/restbed supportlibs/rapidjson +``` + +### Compile +```bash + qmake CONFIG+=release CONFIG+=rs_jsonapi CONFIG+=rs_webui + make +``` + +The executable produced will be: +```bash + ./retroshare-gui/src/retroshare +``` + +### Install +```bash + sudo make install +``` + +The executable produced will be: +```bash + ~/usr/bin/RetroShare +``` + +### For packagers + +Packagers can use PREFIX and LIB\_DIR to customize the installation paths: +```bash + qmake PREFIX=/usr LIB_DIR=/usr/lib64 "CONFIG-=debug" "CONFIG+=release" + make + make INSTALL_ROOT=${PKGDIR} install +``` + + +### libsqlcipher +If libsqlcipher is not available as a package + +You need to place sqlcipher so that the hierarchy is: + + ~Home + | + +--- retroshare + | + +--- lib + | + +---- sqlcipher +```bash + mkdir lib + cd lib + git clone https://github.com/sqlcipher/sqlcipher.git --depth=1 --branch v3.4.1 + cd sqlcipher + ./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" LDFLAGS="-lcrypto" + make + cd .. +``` + +### Build infos + +Note: If you installed Qt6 you need to use `qmake6` on the command line. + +For the `FeedReader` it is required to append the config option `CONFIG+=retroshare_plugins`. +Make sure `plugins/plugins.pro` contains `FeedReader` in the list of plugins to compile. + +Do not mix plugins compiled with Qt5 with those compiled with Qt6. They work only if they are compiled +with the same Qt version as RetroShare. + +Voip is outdated and is not compileable on the latest Debian. + +For `Autologin` it is required to append the config option `CONFIG+=rs_autologin`. + + +### Build options + +* Mandatory + * release or debug: normally you would like to use the release option +* Extra features (optional) + * rs_autologin: enable autologin + * retroshare_plugins: build plugins + * rs_webui: enable Web interface + * rs_jsonapi: enable json api interface, required by rs_webui + * gxsthewire: enable Wire service (experimental) + * wikipoos: enable Wiki service (experimental) + * rs_use_native_dialogs: enable native dialogs (may cause crashes with some versions of Gtk) + * rs_deep_channels_index: build with deep channel indexing support + * rs_deep_files_index: build with deep file indexing support + * "CONFIG+=..." enable other extra compile time features, you can find the almost complete list in file *<sourcefolder>\retroshare.pri* + +### Examples: + +```batch +qmake CONFIG+=debug CONFIG+=release CONFIG+=rs_use_native_dialog CONFIG+=rs_gui_cmark +qmake CONFIG+=rs_jsonapi CONFIG+=rs_webui CONFIG+=rs_autologin +``` \ No newline at end of file diff --git a/build_scripts/OBS b/build_scripts/OBS index 0a3997cc1..9dd9d7f94 160000 --- a/build_scripts/OBS +++ b/build_scripts/OBS @@ -1 +1 @@ -Subproject commit 0a3997cc1355b2c848161dca015b7e2df039707b +Subproject commit 9dd9d7f94a600e8c8478887a4f7784fdc3294034 diff --git a/build_scripts/RedHat+Fedora/Linux_RedHat_InstallGuide.md b/build_scripts/RedHat+Fedora/Linux_RedHat_InstallGuide.md new file mode 100644 index 000000000..12c365804 --- /dev/null +++ b/build_scripts/RedHat+Fedora/Linux_RedHat_InstallGuide.md @@ -0,0 +1,129 @@ + +## Compilation on Red Hat-based Linux + + +### Install package dependencies: +#### RedHat/Fedora +```bash + sudo dnf install mesa-libGL-devel gcc cmake rapidjson-devel \ + libupnp openssl sqlcipher sqlcipher-devel \ + botan2 botan2-devel json-c-devel bzip2-devel asio-devel libsecret libXScrnSaver-devel +``` + +To compile with Qt5: +```bash + sudo dnf install qt5-qtbase-devel qt5-qtmultimedia qt5-qtx11extras +``` + +To compile with Qt6: +```bash + sudo dnf install qt6-qtbase-devel qt6-qtmultimedia-devel qt6-qt5compat-devel +``` + +Additional dependencies for Feedreader plugin: +```bash + sudo dnf install libxml2-devel libxslt-devel libcurl-devel +``` + +### Checkout the source code +```bash + cd ~ + git clone https://github.com/RetroShare/RetroShare.git retroshare +``` + +### Checkout the submodules +```bash + cd retroshare + git submodule update --init --remote libbitdht/ libretroshare/ openpgpsdk/ retroshare-webui/ + git submodule update --init --remote supportlibs/librnp supportlibs/restbed supportlibs/rapidjson +``` + +### Compile +```bash + qmake CONFIG+=release CONFIG+=rs_jsonapi CONFIG+=rs_webui + make +``` + +The executable produced will be: +```bash + ./retroshare-gui/src/retroshare +``` + +### Install +```bash + sudo make install +``` + +The executable produced will be: +```bash + ~/usr/bin/RetroShare +``` + +### For packagers + +Packagers can use PREFIX and LIB\_DIR to customize the installation paths: +```bash + qmake PREFIX=/usr LIB_DIR=/usr/lib64 "CONFIG-=debug" "CONFIG+=release" + make + make INSTALL_ROOT=${PKGDIR} install +``` + +### SQLCipher +If libsqlcipher is not available as a package + +You need to place sqlcipher so that the hierarchy is: + + ~Home + | + +--- retroshare + | + +--- lib + | + +---- sqlcipher +```bash + mkdir lib + cd lib + git clone https://github.com/sqlcipher/sqlcipher.git --depth=1 --branch v3.4.1 + cd sqlcipher + ./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" LDFLAGS="-lcrypto" + make + cd .. +``` + +### Build infos + +Note: If you installed Qt6 you need to use `qmake6` on the command line. + +For the `FeedReader` it is required to append the config option `CONFIG+=retroshare_plugins`. +Make sure `plugins/plugins.pro` contains `FeedReader` in the list of plugins to compile. + +Do not mix plugins compiled with Qt5 with those compiled with Qt6. They work only if they are compiled +with the same Qt version as RetroShare. + +Voip is outdated and is not compileable on the latest Debian. + +For `Autologin` it is required to append the config option `CONFIG+=rs_autologin`. + + +### Build options + +* Mandatory + * release or debug: normally you would like to use the release option +* Extra features (optional) + * rs_autologin: enable autologin + * retroshare_plugins: build plugins + * rs_webui: enable Web interface + * rs_jsonapi: enable json api interface, required by rs_webui + * gxsthewire: enable Wire service (experimental) + * wikipoos: enable Wiki service (experimental) + * rs_use_native_dialogs: enable native dialogs (may cause crashes with some versions of Gtk) + * rs_deep_channels_index: build with deep channel indexing support + * rs_deep_files_index: build with deep file indexing support + * "CONFIG+=..." enable other extra compile time features, you can find the almost complete list in file *<sourcefolder>\retroshare.pri* + +Example: + +```batch +qmake CONFIG+=debug CONFIG+=release CONFIG+=rs_use_native_dialog CONFIG+=rs_gui_cmark +qmake CONFIG+=rs_jsonapi CONFIG+=rs_webui CONFIG+=rs_autologin +``` \ No newline at end of file diff --git a/build_scripts/RedHat+Fedora/data/retroshare.desktop b/build_scripts/RedHat+Fedora/data/retroshare.desktop index 95056d54a..fa590dba3 100644 --- a/build_scripts/RedHat+Fedora/data/retroshare.desktop +++ b/build_scripts/RedHat+Fedora/data/retroshare.desktop @@ -4,7 +4,7 @@ Version=1.0 Name=RetroShare Comment=Securely communicate with your friends Exec=/usr/bin/retroshare %U -Icon=/usr/share/pixmaps/retroshare.xpm +Icon=retroshare.xpm Terminal=false Type=Application Categories=Network;Email;InstantMessaging;Chat;Feed;FileTransfer;P2P diff --git a/build_scripts/Windows-msys2/WindowsMSys2_InstallGuide.md b/build_scripts/Windows-msys2/WindowsMSys2_InstallGuide.md index a0d1b67b6..eba8edf19 100644 --- a/build_scripts/Windows-msys2/WindowsMSys2_InstallGuide.md +++ b/build_scripts/Windows-msys2/WindowsMSys2_InstallGuide.md @@ -8,7 +8,7 @@ Requirements: about 12 GB of free space The resulting binary is a 32-bit build of Retroshare which will also work fine on a 64-bit system. -**If you want to make complet solution without debugging it, prefer to use \build_scripts\Windows-msys2\build.bat** +**If you want to make complete solution without debugging it, prefer to use \build_scripts\Windows-msys2\build.bat** This batch will install and build all for you. diff --git a/build_scripts/Windows-msys2/build/build-installer.bat b/build_scripts/Windows-msys2/build/build-installer.bat index 192b2d025..1840d7202 100644 --- a/build_scripts/Windows-msys2/build/build-installer.bat +++ b/build_scripts/Windows-msys2/build/build-installer.bat @@ -43,7 +43,9 @@ set NSIS_PARAM=%NSIS_PARAM% /DDEPLOYDIR="%RsDeployPath%" set NSIS_PARAM=%NSIS_PARAM% /DOUTDIR="%RsPackPath%" set NSIS_PARAM=%NSIS_PARAM% /DINSTALLERADD="%RsArchiveAdd%" set NSIS_PARAM=%NSIS_PARAM% /DARCHITECTURE="%RsArchitecture%" +set NSIS_PARAM=%NSIS_PARAM% /DTOOLCHAIN="%RsToolchain%" set NSIS_PARAM=%NSIS_PARAM% /DREVISION=%RsVersion.Extra% +set NSIS_PARAM=%NSIS_PARAM% /DQTVERSION=%QtVersion% set QtMainVersion=%QtVersion:~0,1% @@ -53,7 +55,10 @@ rem makensis %NSIS_PARAM% "%SourcePath%\build_scripts\Windows-msys2\installer\re rem pushd "%SourcePath%\build_scripts\Windows-msys2\installer" rem %EnvMSYS2Cmd% "makensis $0 retroshare-Qt%QtMainVersion%.nsi" "%NSIS_PARAM%" rem popd -"%RsMinGWPath%\bin\makensis" %NSIS_PARAM% "%SourcePath%\build_scripts\Windows-msys2\installer\retroshare-Qt%QtMainVersion%.nsi" + +rem Currently no need for separate nsi files +rem "%RsMinGWPath%\bin\makensis" %NSIS_PARAM% "%SourcePath%\build_scripts\Windows-msys2\installer\retroshare-Qt%QtMainVersion%.nsi" +"%RsMinGWPath%\bin\makensis" %NSIS_PARAM% "%SourcePath%\build_scripts\Windows-msys2\installer\retroshare.nsi" exit /B %ERRORLEVEL% diff --git a/build_scripts/Windows-msys2/build/build.bat b/build_scripts/Windows-msys2/build/build.bat index e72ab3d1d..c2341d301 100644 --- a/build_scripts/Windows-msys2/build/build.bat +++ b/build_scripts/Windows-msys2/build/build.bat @@ -15,9 +15,11 @@ call "%~dp0env-base.bat" %* if errorlevel 2 exit /B 2 if errorlevel 1 goto error_env +title Build - %SourceName%-%RsBuildConfig% Qt-%QtVersion% %RsToolchain% [Prerequisites] + if not "%ParamNoupdate%"=="1" ( :: Install needed things - %EnvMSYS2Cmd% "pacman --noconfirm --needed -S make git mingw-w64-%RsMSYS2Architecture%-toolchain mingw-w64-%RsMSYS2Architecture%-qt5 mingw-w64-%RsMSYS2Architecture%-miniupnpc mingw-w64-%RsMSYS2Architecture%-sqlcipher mingw-w64-%RsMSYS2Architecture%-cmake mingw-w64-%RsMSYS2Architecture%-rapidjson" + %EnvMSYS2Cmd% "pacman --noconfirm --needed -S make git mingw-w64-%RsMSYS2Architecture%-toolchain mingw-w64-%RsMSYS2Architecture%-qt%ParamQtVersion% mingw-w64-%RsMSYS2Architecture%-miniupnpc mingw-w64-%RsMSYS2Architecture%-sqlcipher mingw-w64-%RsMSYS2Architecture%-cmake mingw-w64-%RsMSYS2Architecture%-rapidjson" :: rnp %EnvMSYS2Cmd% "pacman --noconfirm --needed -S mingw-w64-%RsMSYS2Architecture%-json-c mingw-w64-%RsMSYS2Architecture%-libbotan" @@ -28,7 +30,7 @@ if not "%ParamNoupdate%"=="1" ( if "%ParamPlugins%"=="1" %EnvMSYS2Cmd% "pacman --noconfirm --needed -S mingw-w64-%RsMSYS2Architecture%-speex mingw-w64-%RsMSYS2Architecture%-speexdsp mingw-w64-%RsMSYS2Architecture%-curl mingw-w64-%RsMSYS2Architecture%-libxslt mingw-w64-%RsMSYS2Architecture%-opencv mingw-w64-%RsMSYS2Architecture%-ffmpeg" :: Clang - if "%ParamClang%"=="1" %EnvMSYS2Cmd% "pacman --noconfirm --needed -S mingw-w64-%RsMSYS2Architecture%-clang" + if "%ClangCompiler%"=="1" %EnvMSYS2Cmd% "pacman --noconfirm --needed -S mingw-w64-%RsMSYS2Architecture%-clang" :: Indexing if "%ParamIndexing%"=="1" %EnvMSYS2Cmd% "pacman --noconfirm --needed -S mingw-w64-%RsMSYS2Architecture%-xapian-core mingw-w64-%RsMSYS2Architecture%-libvorbis mingw-w64-%RsMSYS2Architecture%-flac mingw-w64-%RsMSYS2Architecture%-taglib" @@ -53,7 +55,7 @@ echo. echo === Version echo. -title Build - %SourceName%-%RsBuildConfig% [Version] +title Build - %SourceName%-%RsBuildConfig% Qt-%QtVersion% %RsToolchain% [Version] pushd "%SourcePath%\retroshare-gui\src\gui\images" :: Touch resource file @@ -67,7 +69,7 @@ echo. echo === qmake echo. -title Build - %SourceName%-%RsBuildConfig% [qmake] +title Build - %SourceName%-%RsBuildConfig% Qt-%QtVersion% %RsToolchain% [qmake] set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% "CONFIG+=%RsBuildConfig%" if "%ParamAutologin%"=="1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% "CONFIG+=rs_autologin" @@ -79,14 +81,13 @@ echo %RsBuildConfig% >> buildinfo.txt echo %RsArchitecture% >> buildinfo.txt echo Qt %QtVersion% >> buildinfo.txt echo %RsToolchain% >> buildinfo.txt -echo %RsCompiler% >> buildinfo.txt call "%ToolsPath%\msys2-path.bat" "%SourcePath%" MSYS2SourcePath call "%ToolsPath%\msys2-path.bat" "%EnvMSYS2Path%" MSYS2EnvMSYS2Path -if "%ParamClang%"=="1" ( - %EnvMSYS2Cmd% "qmake "%MSYS2SourcePath%/RetroShare.pro" -r -spec win32-clang-g++ %RS_QMAKE_CONFIG%" +if "%ClangCompiler%"=="1" ( + %EnvMSYS2Cmd% "%QMakeCmd% "%MSYS2SourcePath%/RetroShare.pro" -r -spec win32-clang-g++ %RS_QMAKE_CONFIG%" ) else ( - %EnvMSYS2Cmd% "qmake "%MSYS2SourcePath%/RetroShare.pro" -r -spec win32-g++ %RS_QMAKE_CONFIG%" + %EnvMSYS2Cmd% "%QMakeCmd% "%MSYS2SourcePath%/RetroShare.pro" -r -spec win32-g++ %RS_QMAKE_CONFIG%" ) if errorlevel 1 goto error @@ -94,7 +95,7 @@ echo. echo === make echo. -title Build - %SourceName%-%RsBuildConfig% [make] +title Build - %SourceName%-%RsBuildConfig% Qt-%QtVersion% %RsToolchain% [make] %EnvMSYS2Cmd% "make -j %CoreCount%" if errorlevel 1 goto error diff --git a/build_scripts/Windows-msys2/build/env-base.bat b/build_scripts/Windows-msys2/build/env-base.bat index 01a7a8f12..2269e1294 100644 --- a/build_scripts/Windows-msys2/build/env-base.bat +++ b/build_scripts/Windows-msys2/build/env-base.bat @@ -5,14 +5,16 @@ set ParamAutologin=0 set ParamPlugins=0 set ParamTor=0 set ParamWebui=0 -set ParamClang=0 +set ClangCompiler=0 set ParamIndexing=0 set ParamFriendserver=0 set ParamNoupdate=0 set CoreCount=%NUMBER_OF_PROCESSORS% set RS_QMAKE_CONFIG= set RsToolchain= +set ParamQtVersion=5 set tcc=0 +set QtVersionCount=0 :parameter_loop if "%~1" NEQ "" ( @@ -43,6 +45,12 @@ if "%~1" NEQ "" ( set /A tcc=tcc+1 ) else if "%%~a"=="release" ( set ParamRelease=1 + ) else if "%%~a"=="qt5" ( + set ParamQtVersion=5 + set /A QtVersionCount+=1 + ) else if "%%~a"=="qt6" ( + set ParamQtVersion=6 + set /A QtVersionCount+=1 ) else if "%%~a"=="debug" ( set ParamDebug=1 ) else if "%%~a"=="autologin" ( @@ -55,8 +63,6 @@ if "%~1" NEQ "" ( set ParamWebui=1 ) else if "%%~a"=="singlethread" ( set CoreCount=1 - ) else if "%%~a"=="clang" ( - set ParamClang=1 ) else if "%%~a"=="indexing" ( set ParamIndexing=1 ) else if "%%~a"=="friendserver" ( @@ -80,6 +86,16 @@ if %tcc% NEQ 1 ( goto :usage ) +if %QtVersionCount% GTR 1 ( + echo Multiple Qt versions specified + goto :usage +) + +if "%ParamQtVersion%" NEQ "5" if "%ParamQtVersion%" NEQ "6" ( + echo Wrong Qt version specified + goto :usage +) + if "%RsToolchain%"=="mingw32" ( set RsArchitecture=x86 set RsMSYS2Architecture=i686 @@ -96,24 +112,18 @@ if "%RsToolchain%"=="mingw32" ( set RsArchitecture=x64 set RsMSYS2Architecture=clang-x86_64 set MSYSTEM=CLANG64 - set ParamClang=1 + set ClangCompiler=1 ) else if "%RsToolchain%"=="clang32" ( set RsArchitecture=x86 set RsMSYS2Architecture=clang-i686 set MSYSTEM=CLANG32 - set ParamClang=1 + set ClangCompiler=1 ) else if "%RsToolchain%"=="clangarm64" ( set RsArchitecture=arm64 set RsMSYS2Architecture=clang-aarch64 set MSYSTEM=CLANGARM64 ) -if "%ParamClang%"=="1" ( - set RsCompiler=Clang -) else ( - set RsCompiler=GCC -) - if "%ParamRelease%"=="1" ( if "%ParamDebug%"=="1" ( echo. @@ -148,7 +158,7 @@ exit /B 0 :usage echo. -echo Usage: 32^|64^|other release^|debug [autologin plugins webui singlethread clang indexing friendserver noupdate] ["CONFIG+=..."] +echo Usage: 32^|64^|other release^|debug qt5^|qt6 [autologin plugins webui singlethread clang indexing friendserver noupdate] ["CONFIG+=..."] echo. echo Mandatory parameter echo 32^|64 32-bit or 64-bit version (same as mingw32 or mingw64) @@ -156,13 +166,13 @@ echo Or you can specify any other toolchain supported by msys echo mingw32^|mingw64^|clang32^|clang64^|ucrt64^|clangarm64 echo More info: https://www.msys2.org/docs/environments echo release^|debug Build release or debug version +echo qt5^|qt6 Build with Qt 5 (default) or Qt 6 echo. echo Optional parameter (need clean when changed) echo autologin Build with autologin echo plugins Build plugins echo webui Enable JsonAPI and pack webui files echo singlethread Use only 1 thread for building -echo clang Use clang compiler instead of GCC echo indexing Build with deep channel and file indexing support echo friendserver Enable friendserver support echo noupdate Skip updating the libraries diff --git a/build_scripts/Windows-msys2/build/env.bat b/build_scripts/Windows-msys2/build/env.bat index ccba33db3..e760179e3 100644 --- a/build_scripts/Windows-msys2/build/env.bat +++ b/build_scripts/Windows-msys2/build/env.bat @@ -1,6 +1,6 @@ call "%~dp0env-base.bat" %* if errorlevel 2 exit /B 2 -if errorlevel 1 goto error_env +if errorlevel 1 exit /B 1 set BuildPath=%EnvRootPath%\builds set DeployPath=%EnvRootPath%\deploy @@ -8,14 +8,20 @@ set DeployPath=%EnvRootPath%\deploy if not exist "%BuildPath%" mkdir "%BuildPath%" if not exist "%DeployPath%" mkdir "%DeployPath%" +set QMakeCmd= +if "%ParamQtVersion%"=="5" set QMakeCmd=qmake +if "%ParamQtVersion%"=="6" set QMakeCmd=qmake6 +if "%QMakeCmd%"=="" %cecho% error "Unknown Qt version %ParamQtVersion%." & exit /B 1 + :: Get Qt version -call "%ToolsPath%\get-qt-version.bat" QtVersion +call "%ToolsPath%\get-qt-version.bat" QtVersion %QMakeCmd% +if errorlevel 1 %cecho% error "Cannot get Qt version." & exit /B 1 if "%QtVersion%"=="" %cecho% error "Cannot get Qt version." & exit /B 1 set RsMinGWPath=%EnvMSYS2BasePath%\%RsToolchain% -set RsBuildPath=%BuildPath%\Qt-%QtVersion%-%RsToolchain%-%RsCompiler%-%RsBuildConfig% -set RsDeployPath=%DeployPath%\Qt-%QtVersion%%RsType%-%RsToolchain%-%RsCompiler%-%RsBuildConfig% +set RsBuildPath=%BuildPath%\Qt-%QtVersion%-%RsToolchain%-%RsBuildConfig% +set RsDeployPath=%DeployPath%\Qt-%QtVersion%-%RsToolchain%%RsType%-%RsBuildConfig% set RsPackPath=%DeployPath% set RsArchiveAdd= set RsWebuiBuildPath=%RsBuildPath%\retroshare-webui\webui diff --git a/build_scripts/Windows-msys2/build/pack.bat b/build_scripts/Windows-msys2/build/pack.bat index a898832f7..bf1533a05 100644 --- a/build_scripts/Windows-msys2/build/pack.bat +++ b/build_scripts/Windows-msys2/build/pack.bat @@ -55,25 +55,28 @@ set RsVersion=%RsVersion.Major%.%RsVersion.Minor%.%RsVersion.Mini% :: Check WMIC is available wmic.exe alias /? >nul 2>&1 || echo WMIC is not available.&& goto error -:: Use WMIC to retrieve date in format YYYYMMDD -set RsDate= -for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /format:list') do set RsDate=%%I -set RsDate=%RsDate:~0,4%%RsDate:~4,2%%RsDate:~6,2% +:: Get date +call "%ToolsPath%\get-rs-date.bat" "%SourcePath%" RsDate +if errorlevel 1 %cecho% error "Could not get date."& goto error + +if "%RsDate%"=="" %cecho% error "Could not get date."& goto error set QtMainVersion=%QtVersion:~0,1% set QtSharePath=%RsMinGWPath%\share\qt%QtMainVersion%\ rem Qt 4 = QtSvg4.dll rem Qt 5 = Qt5Svg.dll +rem Qt 6 = Qt6Svg.dll set QtMainVersion1= set QtMainVersion2= if "%QtMainVersion%"=="4" set QtMainVersion2=4 if "%QtMainVersion%"=="5" set QtMainVersion1=5 +if "%QtMainVersion%"=="6" set QtMainVersion1=6 if "%RsBuildConfig%" NEQ "release" ( - set Archive=%RsPackPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsVersion.Extra%-%RsArchitecture%-msys2%RsType%%RsArchiveAdd%-%RsBuildConfig%.7z + set Archive=%RsPackPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsVersion.Extra%-Qt-%QtVersion%-%RsToolchain%-msys2%RsType%%RsArchiveAdd%-%RsBuildConfig%.7z ) else ( - set Archive=%RsPackPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsVersion.Extra%-%RsArchitecture%-msys2%RsType%%RsArchiveAdd%.7z + set Archive=%RsPackPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsVersion.Extra%-Qt-%QtVersion%-%RsToolchain%-msys2%RsType%%RsArchiveAdd%.7z ) if exist "%Archive%" del /Q "%Archive%" @@ -81,7 +84,7 @@ if exist "%Archive%" del /Q "%Archive%" :: Create deploy path mkdir "%RsDeployPath%" -title Pack - %SourceName%%RsType%-%RsBuildConfig% [copy files] +title Pack - %SourceName%%RsType%-%RsBuildConfig% Qt-%QtVersion% %RsToolchain% [copy files] set ExtensionsFile=%SourcePath%\libretroshare\src\rsserver\rsinit.cc set Extensions= @@ -118,18 +121,24 @@ for /D %%D in ("%RsBuildPath%\plugins\*") do ( echo copy Qt DLL's copy "%RsMinGWPath%\bin\Qt%QtMainVersion1%Svg%QtMainVersion2%.dll" "%RsDeployPath%" %Quite% -if "%QtMainVersion%"=="5" ( +if %QtMainVersion% GEQ 5 ( mkdir "%RsDeployPath%\platforms" copy "%QtSharePath%\plugins\platforms\qwindows.dll" "%RsDeployPath%\platforms" %Quite% +) + +if "%QtMainVersion%"=="5" ( mkdir "%RsDeployPath%\audio" copy "%QtSharePath%\plugins\audio\qtaudio_windows.dll" "%RsDeployPath%\audio" %Quite% ) -if exist "%QtSharePath%\plugins\styles\qwindowsvistastyle.dll" ( - echo copy styles - mkdir "%RsDeployPath%\styles" %Quite% +echo copy styles +mkdir "%RsDeployPath%\styles" %Quite% +if "%QtMainVersion%"=="5" ( copy "%QtSharePath%\plugins\styles\qwindowsvistastyle.dll" "%RsDeployPath%\styles" %Quite% ) +if "%QtMainVersion%"=="6" ( + copy "%QtSharePath%\plugins\styles\qmodernwindowsstyle.dll" "%RsDeployPath%\styles" %Quite% +) copy "%QtSharePath%\plugins\imageformats\*.dll" "%RsDeployPath%\imageformats" %Quite% del /Q "%RsDeployPath%\imageformats\*d?.dll" %Quite% @@ -170,11 +179,13 @@ xcopy /S "%SourcePath%\retroshare-gui\src\license" "%RsDeployPath%\license" %Qui echo copy translation copy "%SourcePath%\retroshare-gui\src\translations\qt_tr.qm" "%RsDeployPath%\translations" %Quite% copy "%QtSharePath%\translations\qt_*.qm" "%RsDeployPath%\translations" %Quite% -if "%QtMainVersion%"=="5" ( +if "%QtMainVersion%"=="6" ( copy "%QtSharePath%\translations\qtbase_*.qm" "%RsDeployPath%\translations" %Quite% - copy "%QtSharePath%\translations\qtscript_*.qm" "%RsDeployPath%\translations" %Quite% copy "%QtSharePath%\translations\qtquick1_*.qm" "%RsDeployPath%\translations" %Quite% copy "%QtSharePath%\translations\qtmultimedia_*.qm" "%RsDeployPath%\translations" %Quite% +) +if "%QtMainVersion%"=="5" ( + copy "%QtSharePath%\translations\qtscript_*.qm" "%RsDeployPath%\translations" %Quite% copy "%QtSharePath%\translations\qtxmlpatterns_*.qm" "%RsDeployPath%\translations" %Quite% ) @@ -199,7 +210,7 @@ if "%ParamWebui%"=="1" ( ) rem pack files -title Pack - %SourceName%%RsType%-%RsBuildConfig% [pack files] +title Pack - %SourceName%%RsType%-%RsBuildConfig% Qt-%QtVersion% %RsToolchain% [pack files] "%EnvSevenZipExe%" a -mx=9 -t7z "%Archive%" "%RsDeployPath%\*" diff --git a/build_scripts/Windows-msys2/env/tools/prepare-msys2.bat b/build_scripts/Windows-msys2/env/tools/prepare-msys2.bat index cea1df073..2f1b6b706 100644 --- a/build_scripts/Windows-msys2/env/tools/prepare-msys2.bat +++ b/build_scripts/Windows-msys2/env/tools/prepare-msys2.bat @@ -16,7 +16,7 @@ if "%~1"=="clean" ( goto exit ) -set MSYS2Version=20241208 +set MSYS2Version=20250622 set MSYS2Install=msys2-base-x86_64-%MSYS2Version%.sfx.exe set MSYS2Url=https://github.com/msys2/msys2-installer/releases/download/%MSYS2Version:~0,4%-%MSYS2Version:~4,2%-%MSYS2Version:~6,2%/%MSYS2Install% diff --git a/build_scripts/Windows-msys2/installer/retroshare-Qt5.nsi b/build_scripts/Windows-msys2/installer/retroshare.nsi similarity index 98% rename from build_scripts/Windows-msys2/installer/retroshare-Qt5.nsi rename to build_scripts/Windows-msys2/installer/retroshare.nsi index cd4a7867e..dcbe1b808 100644 --- a/build_scripts/Windows-msys2/installer/retroshare-Qt5.nsi +++ b/build_scripts/Windows-msys2/installer/retroshare.nsi @@ -9,6 +9,7 @@ ;!define REVISION "" ;!define DEPLOYDIR "" ;!define ARCHITECTURE "" +;!define TOOLCHAIN "" # Optional defines ;!define OUTDIR "" @@ -21,6 +22,9 @@ !ifndef ARCHITECTURE !error "ARCHITECTURE is not defined" !endif +!ifndef TOOLCHAIN +!error "TOOLCHAIN is not defined" +!endif # Check optional defines !ifdef OUTDIR @@ -72,7 +76,7 @@ ${!defineifexist} TOR_EXISTS "${DEPLOYDIR}\tor.exe" # Main Install settings Name "${APPNAMEANDVERSION}" InstallDirRegKey HKLM "Software\${APPNAME}" "" -OutFile "${OUTDIR_}RetroShare-${VERSION}-${Date}-${REVISION}-${ARCHITECTURE}${RSTYPE}${INSTALLERADD}-setup.exe" +OutFile "${OUTDIR_}RetroShare-${VERSION}-${Date}-${REVISION}-Qt-${QTVERSION}-${TOOLCHAIN}-msys2${RSTYPE}${INSTALLERADD}-setup.exe" BrandingText "${APPNAMEANDVERSION}" RequestExecutionlevel highest # Use compression diff --git a/build_scripts/Windows-msys2/readme.md b/build_scripts/Windows-msys2/readme.md index 5582ec451..e140cf0fa 100644 --- a/build_scripts/Windows-msys2/readme.md +++ b/build_scripts/Windows-msys2/readme.md @@ -44,8 +44,9 @@ Run the scripts in this order: **Always delete the build artifacts folder if you enable or disable extra features after the build command: <sourcefolder>-msys2\deploy\builds** * Mandatory - * 32 or 64: 32 or 64 bit version + * 32, 64, mingw32, mingw64, ucrt64, clang32, clang64 or clangarm64: It sets the msys2 build environment to the selected value. 32 is a shortcut for mingw32, 64 is a shortcut for mingw64. Default in build.bat and buil-tor.bat is 64. * release or debug: normally you would like to use the release option + * qt5 or qt6: build with Qt 5 (default) or Qt 6 * Extra features (optional) * autologin: enable autologin * plugins: build plugins @@ -55,7 +56,6 @@ Run the scripts in this order: * "CONFIG+=..." enable other extra compile time features, you can find the almost complete list in file *<sourcefolder>\retroshare.pri* * For fixing compile problems (optional) * singlethread: use only 1 thread for building, slow but useful if you don't find the error message in the console - * clang: use clang compiler instead of GCC * noupdate: skip the msys2 update step, sometimes some msys2 packages are broken, you can manually switch back to the older package, and this option will prevent updating to the broken version again Example: diff --git a/build_scripts/Windows-msys2/tools/get-qt-version.bat b/build_scripts/Windows-msys2/tools/get-qt-version.bat index 4124770ee..99607211b 100644 --- a/build_scripts/Windows-msys2/tools/get-qt-version.bat +++ b/build_scripts/Windows-msys2/tools/get-qt-version.bat @@ -1,5 +1,5 @@ :: Usage: -:: call get-qt-version.bat variable +:: call get-qt-version.bat variable qmake setlocal @@ -10,9 +10,16 @@ if "%Var%"=="" ( exit /B 1 ) +set QMakeCmd=%~2 +if "%QMakeCmd%"=="" ( + echo. + echo Parameter error. + exit /B 1 +) + set QtVersion= -%EnvMSYS2Cmd% "qmake -version" >"%~dp0qtversion.tmp" +%EnvMSYS2Cmd% "%QMakeCmd% -version" >"%~dp0qtversion.tmp" for /F "tokens=1,2,3,4" %%A in (%~sdp0qtversion.tmp) do ( if "%%A"=="Using" ( set QtVersion=%%D diff --git a/build_scripts/Windows-msys2/tools/get-rs-date.bat b/build_scripts/Windows-msys2/tools/get-rs-date.bat new file mode 100644 index 000000000..e2b5e93aa --- /dev/null +++ b/build_scripts/Windows-msys2/tools/get-rs-date.bat @@ -0,0 +1,32 @@ +REM Usage: +REM call get-rs-date.bat SourcePath Variable + +setlocal + +set SourcePath=%~1 +set Variable=%~2 +if "%Variable%"=="" ( + echo. + echo Parameter error + exit /B 1 +) + +:: Check git executable +set GitPath= +call "%~dp0find-in-path.bat" GitPath git.exe +if "%GitPath%"=="" ( + echo. + echo Git executable not found in PATH. + exit /B 1 +) + +set Date= + +pushd "%SourcePath%" +rem This doesn't work: git log -1 --date=format:"%Y%m%d" --format="%ad" +for /F "tokens=1,2,3* delims=-" %%A in ('git log -1 --date^=short --format^="%%ad"') do set Date=%%A%%B%%C +popd + +:exit +endlocal & set %Variable%=%Date% +exit /B 0 diff --git a/build_scripts/Windows/Windows-QtCreator-InstallGuide.md b/build_scripts/Windows/Windows-QtCreator-InstallGuide.md new file mode 100644 index 000000000..5d2ca1aa9 --- /dev/null +++ b/build_scripts/Windows/Windows-QtCreator-InstallGuide.md @@ -0,0 +1,35 @@ +## Build Retroshare with QtCreator & Qt 6.9 on Windows + +### Qt 6.9 Installation + +Download Qt 6.9 from: https://www.qt.io/download-dev + +Run the installer and install Qt 6.9 + +Add GCC.exe to Path + + C:\Qt\Tools\mingw1310_64\bin + +Compile the external libs start build-libs.bat: + +Open Qt Command Prompt: + + cd C:\Users\User\Documents\GitHub\RetroShare\build_scripts\Windows\build-libs + +Type (this will take some time to build all libs): + + build-libs.bat + +Open Qt Creator + + Open project -> RetroShare.pro + +After Project loaded, go to: + + Projects->Build->Build Steps->Additional arguments: + +Add EXTERNAL_LIB_DIR: + + "EXTERNAL_LIB_DIR=%{sourceDir}\..\RetroShare-env\build-libs\gcc-13.1.0\x64\libs" + +After done, Build Project \ No newline at end of file diff --git a/build_scripts/Windows/build-libs/Makefile b/build_scripts/Windows/build-libs/Makefile index f1649d91f..79a424a44 100644 --- a/build_scripts/Windows/build-libs/Makefile +++ b/build_scripts/Windows/build-libs/Makefile @@ -2,17 +2,18 @@ ZLIB_VERSION=1.2.11 BZIP2_VERSION=1.0.8 MINIUPNPC_VERSION=2.2.3 OPENSSL_VERSION=1.1.1w -SPEEX_VERSION=1.2.0 -SPEEXDSP_VERSION=1.2.0 -LIBXML2_VERSION=2.9.12 -LIBXSLT_VERSION=1.1.34 -CURL_VERSION=7.81.0 +SPEEX_VERSION=1.2.1 +SPEEXDSP_VERSION=1.2.1 +LIBXML2_MAIN_VERSION=2.14 +LIBXML2_VERSION=$(LIBXML2_MAIN_VERSION).5 +LIBXSLT_MAIN_VERSION=1.1 +LIBXSLT_VERSION=$(LIBXSLT_MAIN_VERSION).43 +CURL_VERSION=8.9.1 TCL_VERSION=8.6.10 SQLCIPHER_VERSION=4.5.0 -LIBMICROHTTPD_VERSION=0.9.75 -FFMPEG_VERSION=4.4 +FFMPEG_VERSION=4.4.6 RAPIDJSON_VERSION=1.1.0 -XAPIAN_VERSION=1.4.19 +XAPIAN_VERSION=1.4.29 ASIO_VERSION=1-34-2 #RNP_VERSION=0.17.1 @@ -24,7 +25,7 @@ DOWNLOAD_PATH?=download BUILD_PATH=build LIBS_PATH?=libs -all: dirs zlib bzip2 miniupnpc openssl speex speexdsp libxml2 libxslt curl sqlcipher libmicrohttpd ffmpeg rapidjson xapian jsonc botan asio copylibs +all: dirs zlib bzip2 miniupnpc openssl speex speexdsp libxml curl sqlcipher ffmpeg rapidjson xapian jsonc botan asio copylibs #rnp download: \ @@ -34,13 +35,12 @@ download: \ $(DOWNLOAD_PATH)/openssl-$(OPENSSL_VERSION).tar.gz \ $(DOWNLOAD_PATH)/speex-$(SPEEX_VERSION).tar.gz \ $(DOWNLOAD_PATH)/speexdsp-$(SPEEXDSP_VERSION).tar.gz \ - $(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.gz \ - $(DOWNLOAD_PATH)/libxslt-$(LIBXSLT_VERSION).tar.gz \ + $(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.xz \ + $(DOWNLOAD_PATH)/libxslt-$(LIBXSLT_VERSION).tar.xz \ $(DOWNLOAD_PATH)/curl-$(CURL_VERSION).tar.gz \ $(DOWNLOAD_PATH)/tcl$(TCL_VERSION)-src.tar.gz \ $(DOWNLOAD_PATH)/sqlcipher-$(SQLCIPHER_VERSION).tar.gz \ - $(DOWNLOAD_PATH)/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz \ - $(DOWNLOAD_PATH)/ffmpeg-$(FFMPEG_VERSION).tar.gz \ + $(DOWNLOAD_PATH)/ffmpeg-$(FFMPEG_VERSION).tar.xz \ $(DOWNLOAD_PATH)/rapidjson-$(RAPIDJSON_VERSION).tar.gz \ $(DOWNLOAD_PATH)/xapian-core-$(XAPIAN_VERSION).tar.xz @@ -63,8 +63,7 @@ $(BUILD_PATH)/zlib-$(ZLIB_VERSION): $(DOWNLOAD_PATH)/zlib-$(ZLIB_VERSION).tar.gz rm -r -f $(BUILD_PATH)/zlib-* tar xvf $(DOWNLOAD_PATH)/zlib-$(ZLIB_VERSION).tar.gz # build - cd zlib-$(ZLIB_VERSION) && make -f win32/Makefile.gcc libz.a - cd zlib-$(ZLIB_VERSION) && make + cd zlib-$(ZLIB_VERSION) && make -j -f win32/Makefile.gcc libz.a # copy files mkdir -p $(BUILD_PATH)/zlib-$(ZLIB_VERSION).tmp/include cp zlib-$(ZLIB_VERSION)/zlib.h $(BUILD_PATH)/zlib-$(ZLIB_VERSION).tmp/include/ @@ -86,7 +85,7 @@ $(BUILD_PATH)/bzip2-$(BZIP2_VERSION): $(DOWNLOAD_PATH)/bzip2-$(BZIP2_VERSION).ta tar xvf $(DOWNLOAD_PATH)/bzip2-$(BZIP2_VERSION).tar.gz # build #cd bzip2-$(BZIP2_VERSION) && make install PREFIX="`pwd`/../$(BUILD_PATH)" - cd bzip2-$(BZIP2_VERSION) && make + cd bzip2-$(BZIP2_VERSION) && make -j # copy files mkdir -p $(BUILD_PATH)/bzip2-$(BZIP2_VERSION).tmp/include cp bzip2-$(BZIP2_VERSION)/bzlib.h $(BUILD_PATH)/bzip2-$(BZIP2_VERSION).tmp/include/ @@ -106,7 +105,7 @@ $(BUILD_PATH)/miniupnpc-$(MINIUPNPC_VERSION): $(DOWNLOAD_PATH)/miniupnpc-$(MINIU rm -r -f $(BUILD_PATH)/miniupnpc-* tar xvf $(DOWNLOAD_PATH)/miniupnpc-$(MINIUPNPC_VERSION).tar.gz # build - cd miniupnpc-$(MINIUPNPC_VERSION) && export CC=gcc && export PATH=.:$$PATH && make -f Makefile.mingw libminiupnpc.a miniupnpc.dll + cd miniupnpc-$(MINIUPNPC_VERSION) && export CC=gcc && export PATH=.:$$PATH && make -j -f Makefile.mingw libminiupnpc.a miniupnpc.dll # copy files mkdir -p $(BUILD_PATH)/miniupnpc-$(MINIUPNPC_VERSION).tmp/include/miniupnpc cp miniupnpc-$(MINIUPNPC_VERSION)/include/*.h $(BUILD_PATH)/miniupnpc-$(MINIUPNPC_VERSION).tmp/include/miniupnpc/ @@ -131,7 +130,7 @@ $(BUILD_PATH)/openssl-$(OPENSSL_VERSION): $(DOWNLOAD_PATH)/openssl-$(OPENSSL_VER #cd openssl-$(OPENSSL_VERSION) && ./config --prefix="`pwd`/../$(BUILD_PATH)" #cd openssl-$(OPENSSL_VERSION) && make install cd openssl-$(OPENSSL_VERSION) && ./config shared - cd openssl-$(OPENSSL_VERSION) && make + cd openssl-$(OPENSSL_VERSION) && make -j # copy files mkdir -p $(BUILD_PATH)/openssl-$(OPENSSL_VERSION).tmp/include/openssl cp openssl-$(OPENSSL_VERSION)/include/openssl/*.h $(BUILD_PATH)/openssl-$(OPENSSL_VERSION).tmp/include/openssl/ @@ -160,7 +159,7 @@ $(BUILD_PATH)/speex-$(SPEEX_VERSION): $(DOWNLOAD_PATH)/speex-$(SPEEX_VERSION).ta # build cd speex-$(SPEEX_VERSION) && ./configure #cd speex-$(SPEEX_VERSION) && make install exec_prefix="`pwd`/../$(BUILD_PATH)" - cd speex-$(SPEEX_VERSION) && make + cd speex-$(SPEEX_VERSION) && make -j # copy files mkdir -p $(BUILD_PATH)/speex-$(SPEEX_VERSION).tmp/include/speex cp speex-$(SPEEX_VERSION)/include/speex/*.h $(BUILD_PATH)/speex-$(SPEEX_VERSION).tmp/include/speex/ @@ -181,7 +180,7 @@ $(BUILD_PATH)/speexdsp-$(SPEEXDSP_VERSION): $(DOWNLOAD_PATH)/speexdsp-$(SPEEXDSP tar xvf $(DOWNLOAD_PATH)/speexdsp-$(SPEEXDSP_VERSION).tar.gz # build cd speexdsp-$(SPEEXDSP_VERSION) && ./configure - cd speexdsp-$(SPEEXDSP_VERSION) && make + cd speexdsp-$(SPEEXDSP_VERSION) && make -j # copy files mkdir -p $(BUILD_PATH)/speexdsp-$(SPEEXDSP_VERSION).tmp/include/speex cp speexdsp-$(SPEEXDSP_VERSION)/include/speex/*.h $(BUILD_PATH)/speexdsp-$(SPEEXDSP_VERSION).tmp/include/speex/ @@ -191,50 +190,52 @@ $(BUILD_PATH)/speexdsp-$(SPEEXDSP_VERSION): $(DOWNLOAD_PATH)/speexdsp-$(SPEEXDSP rm -r -f speexdsp-$(SPEEXDSP_VERSION) mv $(BUILD_PATH)/speexdsp-$(SPEEXDSP_VERSION).tmp $(BUILD_PATH)/speexdsp-$(SPEEXDSP_VERSION) -libxml2: $(BUILD_PATH)/libxml2-$(LIBXML2_VERSION) +libxml: \ + $(BUILD_PATH)/libxml2-$(LIBXML2_VERSION) \ + $(BUILD_PATH)/libxslt-$(LIBXSLT_VERSION) -$(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.gz: - wget ftp://xmlsoft.org/libxml2/libxml2-$(LIBXML2_VERSION).tar.gz -O $(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.gz +$(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.xz: + wget --no-check-certificate https://download.gnome.org/sources/libxml2/$(LIBXML2_MAIN_VERSION)/libxml2-$(LIBXML2_VERSION).tar.xz -O $(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.xz -$(BUILD_PATH)/libxml2-$(LIBXML2_VERSION): $(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.gz - # prepare +$(DOWNLOAD_PATH)/libxslt-$(LIBXSLT_VERSION).tar.xz: + wget --no-check-certificate https://download.gnome.org/sources/libxslt/$(LIBXSLT_MAIN_VERSION)/libxslt-$(LIBXSLT_VERSION).tar.xz -O $(DOWNLOAD_PATH)/libxslt-$(LIBXSLT_VERSION).tar.xz + +$(BUILD_PATH)/libxml2-$(LIBXML2_VERSION) $(BUILD_PATH)/libxslt-$(LIBXSLT_VERSION): \ + $(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.xz \ + $(DOWNLOAD_PATH)/libxslt-$(LIBXSLT_VERSION).tar.xz + # libxml2: prepare + pacman --needed --noconfirm -S python3 pkg-config rm -r -f $(BUILD_PATH)/libxml2-* - tar xvf $(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.gz - # build + tar xvf $(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.xz + # libxslt: prepare + rm -r -f $(BUILD_PATH)/libxslt-* + tar xvf $(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.xz + tar xvf $(DOWNLOAD_PATH)/libxslt-$(LIBXSLT_VERSION).tar.xz + # libxml2: build cd libxml2-$(LIBXML2_VERSION) && ./configure --without-iconv -enable-shared=no #cd libxml2-$(LIBXML2_VERSION) && make install exec_prefix="`pwd`/../$(BUILD_PATH)" - cd libxml2-$(LIBXML2_VERSION) && make - # copy files + cd libxml2-$(LIBXML2_VERSION) && make -j libxml2.la + # libxslt: build + cd libxslt-$(LIBXSLT_VERSION) && ./configure --with-libxml-src=../libxml2-$(LIBXML2_VERSION) -enable-shared=no CFLAGS=-DLIBXML_STATIC + cd libxslt-$(LIBXSLT_VERSION)/libxslt && make -j + cd libxslt-$(LIBXSLT_VERSION)/libexslt && make -j + # libxml2: copy files mkdir -p $(BUILD_PATH)/libxml2-$(LIBXML2_VERSION).tmp/include/libxml cp libxml2-$(LIBXML2_VERSION)/include/libxml/*.h $(BUILD_PATH)/libxml2-$(LIBXML2_VERSION).tmp/include/libxml/ mkdir -p $(BUILD_PATH)/libxml2-$(LIBXML2_VERSION).tmp/lib cp libxml2-$(LIBXML2_VERSION)/.libs/libxml2.a $(BUILD_PATH)/libxml2-$(LIBXML2_VERSION).tmp/lib/ - # cleanup - #rm -r -f libxml2-$(LIBXML2_VERSION) # see libxslt - mv $(BUILD_PATH)/libxml2-$(LIBXML2_VERSION).tmp $(BUILD_PATH)/libxml2-$(LIBXML2_VERSION) - -libxslt: $(BUILD_PATH)/libxslt-$(LIBXSLT_VERSION) - -$(DOWNLOAD_PATH)/libxslt-$(LIBXSLT_VERSION).tar.gz: - wget ftp://xmlsoft.org/libxml2/libxslt-$(LIBXSLT_VERSION).tar.gz -O $(DOWNLOAD_PATH)/libxslt-$(LIBXSLT_VERSION).tar.gz - -$(BUILD_PATH)/libxslt-$(LIBXSLT_VERSION): $(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.gz $(DOWNLOAD_PATH)/libxslt-$(LIBXSLT_VERSION).tar.gz - # prepare - rm -r -f $(BUILD_PATH)/libxslt-* - tar xvf $(DOWNLOAD_PATH)/libxml2-$(LIBXML2_VERSION).tar.gz - tar xvf $(DOWNLOAD_PATH)/libxslt-$(LIBXSLT_VERSION).tar.gz - # build - cd libxslt-$(LIBXSLT_VERSION) && ./configure --with-libxml-src=../libxml2-$(LIBXML2_VERSION) -enable-shared=no CFLAGS=-DLIBXML_STATIC - cd libxslt-$(LIBXSLT_VERSION) && make - # copy files + # libxslt: copy files mkdir -p $(BUILD_PATH)/libxslt-$(LIBXSLT_VERSION).tmp/include/libxslt cp libxslt-$(LIBXSLT_VERSION)/libxslt/*.h $(BUILD_PATH)/libxslt-$(LIBXSLT_VERSION).tmp/include/libxslt/ mkdir -p $(BUILD_PATH)/libxslt-$(LIBXSLT_VERSION).tmp/lib cp libxslt-$(LIBXSLT_VERSION)/libxslt/.libs/libxslt.a $(BUILD_PATH)/libxslt-$(LIBXSLT_VERSION).tmp/lib/ cp libxslt-$(LIBXSLT_VERSION)/libexslt/.libs/libexslt.a $(BUILD_PATH)/libxslt-$(LIBXSLT_VERSION).tmp/lib/ - # cleanup + # libxml2: cleanup rm -r -f libxml2-$(LIBXML2_VERSION) + # libxslt: cleanup rm -r -f libxslt-$(LIBXSLT_VERSION) + # finish + mv $(BUILD_PATH)/libxml2-$(LIBXML2_VERSION).tmp $(BUILD_PATH)/libxml2-$(LIBXML2_VERSION) mv $(BUILD_PATH)/libxslt-$(LIBXSLT_VERSION).tmp $(BUILD_PATH)/libxslt-$(LIBXSLT_VERSION) curl: $(BUILD_PATH)/curl-$(CURL_VERSION) @@ -249,7 +250,7 @@ $(BUILD_PATH)/curl-$(CURL_VERSION): $(DOWNLOAD_PATH)/curl-$(CURL_VERSION).tar.gz # build cd curl-$(CURL_VERSION) && ./configure --disable-shared --with-ssl="`pwd`/../$(BUILD_PATH)/openssl-$(OPENSSL_VERSION)" #cd curl-$(CURL_VERSION) && make install exec_prefix="`pwd`/../$(BUILD_PATH)" - cd curl-$(CURL_VERSION) && make + cd curl-$(CURL_VERSION)/lib && make -j # copy files mkdir -p $(BUILD_PATH)/curl-$(CURL_VERSION).tmp/include/curl cp curl-$(CURL_VERSION)/include/curl/*.h $(BUILD_PATH)/curl-$(CURL_VERSION).tmp/include/curl/ @@ -274,14 +275,14 @@ $(BUILD_PATH)/sqlcipher-$(SQLCIPHER_VERSION): $(DOWNLOAD_PATH)/tcl$(TCL_VERSION) tar xvf $(DOWNLOAD_PATH)/tcl$(TCL_VERSION)-src.tar.gz mkdir -p tcl$(TCL_VERSION)/build cd tcl$(TCL_VERSION)/build && ../win/configure - cd tcl$(TCL_VERSION)/build && make + cd tcl$(TCL_VERSION)/build && make -j #sqlcipher tar xvf $(DOWNLOAD_PATH)/sqlcipher-$(SQLCIPHER_VERSION).tar.gz cd sqlcipher-$(SQLCIPHER_VERSION) && ln -s ../tcl$(TCL_VERSION)/build/tclsh86.exe tclsh mkdir -p tcl$(TCL_VERSION)/lib ln -s `pwd`/tcl$(TCL_VERSION)/library `pwd`/tcl$(TCL_VERSION)/lib/tcl8.6 # build - cd sqlcipher-$(SQLCIPHER_VERSION) && PATH=.:$$PATH:`pwd`/../tcl$(TCL_VERSION)/build && export LIBS="-L`pwd`/../$(BUILD_PATH)/openssl-$(OPENSSL_VERSION)/lib -lgdi32 $$LIBS" && ./configure --disable-shared --enable-static --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC -I`pwd`/../$(BUILD_PATH)/openssl-$(OPENSSL_VERSION)/include -I`pwd`/../tcl$(TCL_VERSION)/generic" LDFLAGS="-L`pwd`/../$(BUILD_PATH)/openssl-$(OPENSSL_VERSION)/lib -lcrypto -lgdi32" --with-tcl="`pwd`/../tcl$(TCL_VERSION)/build" && make install prefix="`pwd`/install" + cd sqlcipher-$(SQLCIPHER_VERSION) && PATH=.:$$PATH:`pwd`/../tcl$(TCL_VERSION)/build && export LIBS="-L`pwd`/../$(BUILD_PATH)/openssl-$(OPENSSL_VERSION)/lib -lgdi32 $$LIBS" && ./configure --disable-shared --enable-static --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC -I`pwd`/../$(BUILD_PATH)/openssl-$(OPENSSL_VERSION)/include -I`pwd`/../tcl$(TCL_VERSION)/generic" LDFLAGS="-L`pwd`/../$(BUILD_PATH)/openssl-$(OPENSSL_VERSION)/lib -lcrypto -lgdi32" --with-tcl="`pwd`/../tcl$(TCL_VERSION)/build" && make -j install prefix="`pwd`/install" # copy files mkdir -p $(BUILD_PATH)/sqlcipher-$(SQLCIPHER_VERSION).tmp/include cp -r sqlcipher-$(SQLCIPHER_VERSION)/install/include/* $(BUILD_PATH)/sqlcipher-$(SQLCIPHER_VERSION).tmp/include/ @@ -294,34 +295,18 @@ $(BUILD_PATH)/sqlcipher-$(SQLCIPHER_VERSION): $(DOWNLOAD_PATH)/tcl$(TCL_VERSION) rm -r -f tcl$(TCL_VERSION) mv $(BUILD_PATH)/sqlcipher-$(SQLCIPHER_VERSION).tmp $(BUILD_PATH)/sqlcipher-$(SQLCIPHER_VERSION) -libmicrohttpd: $(BUILD_PATH)/libmicrohttpd-$(LIBMICROHTTPD_VERSION) - -$(DOWNLOAD_PATH)/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz: - wget --no-check-certificate http://ftp.gnu.org/gnu/libmicrohttpd/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz -O $(DOWNLOAD_PATH)/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz - -$(BUILD_PATH)/libmicrohttpd-$(LIBMICROHTTPD_VERSION): $(DOWNLOAD_PATH)/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz - # prepare - rm -r -f $(BUILD_PATH)/libmicrohttpd-* - tar xvf $(DOWNLOAD_PATH)/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tar.gz - # build - cd libmicrohttpd-$(LIBMICROHTTPD_VERSION) && ./configure --disable-shared --enable-static --prefix="`pwd`/../$(BUILD_PATH)/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tmp" - cd libmicrohttpd-$(LIBMICROHTTPD_VERSION) && make install - # cleanup - rm -r -f libmicrohttpd-$(LIBMICROHTTPD_VERSION) - mv $(BUILD_PATH)/libmicrohttpd-$(LIBMICROHTTPD_VERSION).tmp $(BUILD_PATH)/libmicrohttpd-$(LIBMICROHTTPD_VERSION) - ffmpeg: $(BUILD_PATH)/ffmpeg-$(FFMPEG_VERSION) -$(DOWNLOAD_PATH)/ffmpeg-$(FFMPEG_VERSION).tar.gz: - wget --no-check-certificate https://ffmpeg.org/releases/ffmpeg-$(FFMPEG_VERSION).tar.gz -O $(DOWNLOAD_PATH)/ffmpeg-$(FFMPEG_VERSION).tar.gz +$(DOWNLOAD_PATH)/ffmpeg-$(FFMPEG_VERSION).tar.xz: + wget --no-check-certificate https://ffmpeg.org/releases/ffmpeg-$(FFMPEG_VERSION).tar.xz -O $(DOWNLOAD_PATH)/ffmpeg-$(FFMPEG_VERSION).tar.xz -$(BUILD_PATH)/ffmpeg-$(FFMPEG_VERSION): $(DOWNLOAD_PATH)/ffmpeg-$(FFMPEG_VERSION).tar.gz +$(BUILD_PATH)/ffmpeg-$(FFMPEG_VERSION): $(DOWNLOAD_PATH)/ffmpeg-$(FFMPEG_VERSION).tar.xz # prepare rm -r -f $(BUILD_PATH)/ffmpeg-* - tar xvf $(DOWNLOAD_PATH)/ffmpeg-$(FFMPEG_VERSION).tar.gz + tar xvf $(DOWNLOAD_PATH)/ffmpeg-$(FFMPEG_VERSION).tar.xz # build cd ffmpeg-$(FFMPEG_VERSION) && ./configure --disable-shared --enable-static --disable-programs --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-yasm --disable-everything --enable-encoder=mpeg4 --enable-decoder=mpeg4 --prefix="`pwd`/../$(BUILD_PATH)/ffmpeg-$(FFMPEG_VERSION).tmp" - cd ffmpeg-$(FFMPEG_VERSION) && make install + cd ffmpeg-$(FFMPEG_VERSION) && make -j install # cleanup rm -r -f ffmpeg-$(FFMPEG_VERSION) mv $(BUILD_PATH)/ffmpeg-$(FFMPEG_VERSION).tmp $(BUILD_PATH)/ffmpeg-$(FFMPEG_VERSION) @@ -359,7 +344,7 @@ $(BUILD_PATH)/xapian-core-$(XAPIAN_VERSION): $(DOWNLOAD_PATH)/xapian-core-$(XAPI #cd xapian-core-$(XAPIAN_VERSION) && ./configure --disable-shared --enable-static --prefix="`pwd`/../$(BUILD_PATH)/xapian-core-$(XAPIAN_VERSION).tmp" #cd xapian-core-$(XAPIAN_VERSION) && make install cd xapian-core-$(XAPIAN_VERSION) && ./configure --disable-shared --enable-static - cd xapian-core-$(XAPIAN_VERSION) && make + cd xapian-core-$(XAPIAN_VERSION) && make -j # copy files mkdir -p $(BUILD_PATH)/xapian-core-$(XAPIAN_VERSION).tmp/include cp -r xapian-core-$(XAPIAN_VERSION)/include/* $(BUILD_PATH)/xapian-core-$(XAPIAN_VERSION).tmp/include/ @@ -379,7 +364,7 @@ $(BUILD_PATH)/json-c-$(JSON_C_VERSION): # build mkdir -p json-c-$(JSON_C_VERSION)/build cd json-c-$(JSON_C_VERSION)/build && cmake .. -G"MSYS Makefiles" -Wno-dev -DCMAKE_BUILD_TYPE="release" -DBUILD_SHARED_LIBS=off -DBUILD_STATIC_LIBS=on -DBUILD_TESTING=off -DCMAKE_CXX_FLAGS="-D__MINGW_USE_VC2005_COMPAT" -DCMAKE_INSTALL_PREFIX="`pwd`/install" -DCMAKE_INSTALL_PREFIX="`pwd`/../../$(BUILD_PATH)/json-c-$(JSON_C_VERSION).tmp" - cd json-c-$(JSON_C_VERSION)/build && make install + cd json-c-$(JSON_C_VERSION)/build && make -j install # cleanup rm -r -f json-c-$(JSON_C_VERSION) mv $(BUILD_PATH)/json-c-$(JSON_C_VERSION).tmp $(BUILD_PATH)/json-c-$(JSON_C_VERSION) @@ -394,7 +379,7 @@ $(BUILD_PATH)/botan-$(BOTAN_VERSION): # build if [ $(MSYSTEM) = "MINGW32" ] ; then cd botan-$(BOTAN_VERSION) && ./configure.py --os=mingw --cpu=x86_32 --disable-shared-library --enable-static-library --extra-cxxflags="-D__MINGW_USE_VC2005_COMPAT" --prefix="`pwd`/../$(BUILD_PATH)/botan-$(BOTAN_VERSION).tmp" ; fi if [ $(MSYSTEM) = "MINGW64" ] ; then cd botan-$(BOTAN_VERSION) && ./configure.py --os=mingw --cpu=x86_64 --disable-shared-library --enable-static-library --prefix="`pwd`/../$(BUILD_PATH)/botan-$(BOTAN_VERSION).tmp" ; fi - cd botan-$(BOTAN_VERSION) && make install + cd botan-$(BOTAN_VERSION) && make -j install # cleanup rm -r -f botan-$(BOTAN_VERSION) mv $(BUILD_PATH)/botan-$(BOTAN_VERSION).tmp $(BUILD_PATH)/botan-$(BOTAN_VERSION) @@ -438,5 +423,5 @@ $(BUILD_PATH)/rnp-$(RNP_VERSION): copylibs: rm -r -f $(LIBS_PATH) ; \ mkdir -p $(LIBS_PATH) ; \ - cp $(BUILD_PATH)/gcc-version $(LIBS_PATH) ; \ - find $(BUILD_PATH) -mindepth 1 -maxdepth 1 -type d -not -name "*.tmp" -print -exec cp -r {}/. $(LIBS_PATH) \; ; \ + cp -p $(BUILD_PATH)/gcc-version $(LIBS_PATH) ; \ + find $(BUILD_PATH) -mindepth 1 -maxdepth 1 -type d -not -name "*.tmp" -print -exec cp -r -p {}/. $(LIBS_PATH) \; ; \ diff --git a/build_scripts/Windows/build/build.bat b/build_scripts/Windows/build/build.bat index 91ff71382..4685d3a5e 100644 --- a/build_scripts/Windows/build/build.bat +++ b/build_scripts/Windows/build/build.bat @@ -33,7 +33,7 @@ echo. echo === Version echo. -title Build - %SourceName%-%RsBuildConfig% [Version] +title Build - %SourceName%-%RsBuildConfig% Qt-%QtVersion%-%GCCArchitecture% [Version] pushd "%SourcePath%\retroshare-gui\src\gui\images" :: Touch resource file @@ -47,7 +47,7 @@ echo. echo === qmake echo. -title Build - %SourceName%-%RsBuildConfig% [qmake] +title Build - %SourceName%-%RsBuildConfig% Qt-%QtVersion%-%GCCArchitecture% [qmake] set RS_QMAKE_CONFIG=%RsBuildConfig% if "%ParamAutologin%"=="1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% rs_autologin @@ -66,7 +66,7 @@ echo. echo === make echo. -title Build - %SourceName%-%RsBuildConfig% [make] +title Build - %SourceName%-%RsBuildConfig% Qt-%QtVersion%-%GCCArchitecture% [make] mingw32-make -j %CoreCount% if errorlevel 1 goto error @@ -75,7 +75,7 @@ echo. echo === Changelog echo. -title Build - %SourceName%-%RsBuildConfig% [changelog] +title Build - %SourceName%-%RsBuildConfig% Qt-%QtVersion%-%GCCArchitecture% [changelog] call "%ToolsPath%\generate-changelog.bat" "%SourcePath%" "%RsBuildPath%\changelog.txt" :error diff --git a/build_scripts/Windows/build/pack.bat b/build_scripts/Windows/build/pack.bat index ff347babf..3fb3c540a 100644 --- a/build_scripts/Windows/build/pack.bat +++ b/build_scripts/Windows/build/pack.bat @@ -59,10 +59,12 @@ set QtMainVersion=%QtVersion:~0,1% rem Qt 4 = QtSvg4.dll rem Qt 5 = Qt5Svg.dll +rem Qt 6 = Qt6Svg.dll set QtMainVersion1= set QtMainVersion2= if "%QtMainVersion%"=="4" set QtMainVersion2=4 if "%QtMainVersion%"=="5" set QtMainVersion1=5 +if "%QtMainVersion%"=="6" set QtMainVersion1=6 if "%RsBuildConfig%" NEQ "release" ( set Archive=%RsPackPath%\RetroShare-%RsVersion%-Windows-Portable-%RsDate%-%RsVersion.Extra%-Qt-%QtVersion%-%GCCArchitecture%%RsType%%RsArchiveAdd%-%RsBuildConfig%.7z @@ -75,7 +77,7 @@ if exist "%Archive%" del /Q "%Archive%" :: Create deploy path mkdir "%RsDeployPath%" -title Pack - %SourceName%%RsType%-%RsBuildConfig% [copy files] +title Pack - %SourceName%%RsType%-%RsBuildConfig% Qt-%QtVersion%-%GCCArchitecture% [copy files] set ExtensionsFile=%SourcePath%\libretroshare\src\rsserver\rsinit.cc set Extensions= @@ -131,18 +133,24 @@ if exist "%RsDeployPath%\retroshare.dll" call :copy_dependencies "%RsDeployPath% echo copy Qt DLL's copy "%QtPath%\Qt%QtMainVersion1%Svg%QtMainVersion2%.dll" "%RsDeployPath%" %Quite% -if "%QtMainVersion%"=="5" ( +if %QtMainVersion% GEQ 5 ( mkdir "%RsDeployPath%\platforms" copy "%QtPath%\..\plugins\platforms\qwindows.dll" "%RsDeployPath%\platforms" %Quite% +) + +if "%QtMainVersion%"=="5" ( mkdir "%RsDeployPath%\audio" copy "%QtPath%\..\plugins\audio\qtaudio_windows.dll" "%RsDeployPath%\audio" %Quite% ) -if exist "%QtPath%\..\plugins\styles\qwindowsvistastyle.dll" ( - echo Copy styles - mkdir "%RsDeployPath%\styles" %Quite% +echo Copy styles +mkdir "%RsDeployPath%\styles" %Quite% +if "%QtMainVersion%"=="5" ( copy "%QtPath%\..\plugins\styles\qwindowsvistastyle.dll" "%RsDeployPath%\styles" %Quite% ) +if "%QtMainVersion%"=="6" ( + copy "%QtPath%\..\plugins\styles\qmodernwindowsstyle.dll" "%RsDeployPath%\styles" %Quite% +) copy "%QtPath%\..\plugins\imageformats\*.dll" "%RsDeployPath%\imageformats" %Quite% del /Q "%RsDeployPath%\imageformats\*d?.dll" %Quite% @@ -169,10 +177,12 @@ xcopy /S "%SourcePath%\retroshare-gui\src\license" "%RsDeployPath%\license" %Qui echo copy translation copy "%SourcePath%\retroshare-gui\src\translations\qt_tr.qm" "%RsDeployPath%\translations" %Quite% copy "%QtPath%\..\translations\qt_*.qm" "%RsDeployPath%\translations" %Quite% -if "%QtMainVersion%"=="5" ( +if %QtMainVersion% GEQ 5 ( copy "%QtPath%\..\translations\qtbase_*.qm" "%RsDeployPath%\translations" %Quite% - copy "%QtPath%\..\translations\qtscript_*.qm" "%RsDeployPath%\translations" %Quite% copy "%QtPath%\..\translations\qtmultimedia_*.qm" "%RsDeployPath%\translations" %Quite% +) +if "%QtMainVersion%"=="5" ( + copy "%QtPath%\..\translations\qtscript_*.qm" "%RsDeployPath%\translations" %Quite% copy "%QtPath%\..\translations\qtxmlpatterns_*.qm" "%RsDeployPath%\translations" %Quite% ) @@ -196,7 +206,7 @@ if "%ParamTor%"=="1" ( ) rem pack files -title Pack - %SourceName%%RsType%-%RsBuildConfig% [pack files] +title Pack - %SourceName%%RsType%-%RsBuildConfig% Qt-%QtVersion%-%GCCArchitecture% [pack files] "%EnvSevenZipExe%" a -mx=9 -t7z "%Archive%" "%RsDeployPath%\*" diff --git a/build_scripts/Windows/env/tools/prepare-msys2.bat b/build_scripts/Windows/env/tools/prepare-msys2.bat index ba2f12ce6..e4b90cd75 100644 --- a/build_scripts/Windows/env/tools/prepare-msys2.bat +++ b/build_scripts/Windows/env/tools/prepare-msys2.bat @@ -16,7 +16,7 @@ if "%~1"=="clean" ( goto exit ) -set MSYS2Version=20241208 +set MSYS2Version=20250622 set MSYS2Install=msys2-base-x86_64-%MSYS2Version%.sfx.exe set MSYS2Url=https://github.com/msys2/msys2-installer/releases/download/%MSYS2Version:~0,4%-%MSYS2Version:~4,2%-%MSYS2Version:~6,2%/%MSYS2Install% diff --git a/build_scripts/Windows/installer/retroshare-Qt5.nsi b/build_scripts/Windows/installer/retroshare-Qt5.nsi index c7a5b9554..511fec9d4 100644 --- a/build_scripts/Windows/installer/retroshare-Qt5.nsi +++ b/build_scripts/Windows/installer/retroshare-Qt5.nsi @@ -232,7 +232,7 @@ Section $(Section_Main) Section_Main ; Qt styles SetOutPath "$INSTDIR\styles" - File /NONFATAL "${QTDIR}\plugins\styles\qwindowsvistastyle.dll" + File "${QTDIR}\plugins\styles\qwindowsvistastyle.dll" ; MinGW binaries SetOutPath "$INSTDIR" diff --git a/build_scripts/Windows/installer/retroshare-Qt6.nsi b/build_scripts/Windows/installer/retroshare-Qt6.nsi new file mode 100644 index 000000000..2ef3fb54f --- /dev/null +++ b/build_scripts/Windows/installer/retroshare-Qt6.nsi @@ -0,0 +1,622 @@ +; Script generated with the Venis Install Wizard & modified by defnax +; Reworked by Thunder + +!include ifexist.nsh + +# Needed defines +;!define REVISION "" +;!define RELEASEDIR "" +;!define QTDIR "" +;!define MINGWDIR "" + +# Optional defines +;!define OUTDIR "" + +# Check needed defines +!ifndef RELEASEDIR +!error "RELEASEDIR is not defined" +!endif +!ifndef QTDIR +!error "QTDIR is not defined" +!endif +!ifndef MINGWDIR +!error "MINGWDIR is not defined" +!endif +!ifndef ARCHITECTURE +!error "Architecture is not defined" +!endif + +# Check optional defines +!ifdef OUTDIR +!define OUTDIR_ "${OUTDIR}\" +!else +!define OUTDIR "" +!define OUTDIR_ "" +!endif + +!ifndef INSTALLERADD +!define INSTALLERADD "" +!endif + +# Source directory +!define SOURCEDIR "..\..\.." + +# Get version from executable +!GetDllVersion "${RELEASEDIR}\retroshare-gui\src\release\retroshare.exe" VERSION_ +!define VERSION ${VERSION_1}.${VERSION_2}.${VERSION_3} +;!define REVISION ${VERSION_4} + +# Get version of Qt +!GetDllVersion "${QTDIR}\bin\Qt6Core.dll" QTVERSION_ +!define QTVERSION ${QTVERSION_1}.${QTVERSION_2}.${QTVERSION_3} + +# Check version +!ifndef REVISION +!error "REVISION is not defined" +!endif + +# Date +!ifndef DATE +!define /date DATE "%Y%m%d" +!endif + +# Service +${!defineifexist} SERVICE_EXISTS "${RELEASEDIR}\retroshare-service\src\release\retroshare-service.exe" + +# Tor +!ifdef TORDIR +${!defineifexist} TOR_EXISTS "${TORDIR}\tor.exe" +!ifndef TOR_EXISTS +!error "tor.exe not found" +!endif +!endif + +# WebUI +!ifdef WEBUIDIR +${!defineifexist} WEBUI_EXISTS "${WEBUIDIR}\index.html" +!ifndef WEBUI_EXISTS +!error "WebUI files not found" +!endif +!endif + +# Friend Server +!ifdef TOR_EXISTS +# Add Friend Server with Tor only +#${!defineifexist} FRIENDSERVER_EXISTS "${RELEASEDIR}\retroshare-friendserver\src\release\retroshare-friendserver.exe" +!endif + +# Application name and version +!define APPNAME "RetroShare" +!define APPNAMEANDVERSION "${APPNAME} ${VERSION}" +!define PUBLISHER "RetroShare Team" + +# Install path +!if ${ARCHITECTURE} == "x86" + !define INSTDIR_NORMAL "$ProgramFiles32\${APPNAME}" +!endif +!if ${ARCHITECTURE} == "x64" + !define INSTDIR_NORMAL "$ProgramFiles64\${APPNAME}" +!endif +!define INSTDIR_PORTABLE "$Desktop\${APPNAME}" + +!define DATADIR_NORMAL "$APPDATA\${APPNAME}" +!define DATADIR_PORTABLE "$INSTDIR\Data" + +# Main Install settings +Name "${APPNAMEANDVERSION}" +InstallDirRegKey HKLM "Software\${APPNAME}" "" +OutFile "${OUTDIR_}RetroShare-${VERSION}-${DATE}-${REVISION}-Qt-${QTVERSION}-${ARCHITECTURE}${INSTALLERADD}-setup.exe" +BrandingText "${APPNAMEANDVERSION}" +RequestExecutionlevel highest +# Use compression +SetCompressor /SOLID LZMA + +# Global variables +Var PortableMode +Var InstDirNormal +Var InstDirPortable +Var DataDir +Var StyleSheetDir + +# Modern interface settings +!include Sections.nsh +!include nsDialogs.nsh +!include "MUI.nsh" + +# Interface Settings +!define MUI_ABORTWARNING +!define MUI_HEADERIMAGE +!define MUI_HEADERIMAGE_BITMAP "${SOURCEDIR}\build_scripts\Windows\installer\HeaderImage.bmp" +;!define MUI_WELCOMEFINISHPAGE_BITMAP "...bmp" + +# MUI defines +!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\orange-install.ico" +!define MUI_FINISHPAGE_NOAUTOCLOSE +!define MUI_LICENSEPAGE_RADIOBUTTONS +!define MUI_COMPONENTSPAGE_SMALLDESC +!define MUI_FINISHPAGE_LINK "Visit the RetroShare forum for the latest news and support" +!define MUI_FINISHPAGE_LINK_LOCATION "http://retroshare.sourceforge.net/forum/" +!define MUI_FINISHPAGE_RUN "$INSTDIR\retroshare.exe" +!define MUI_FINISHPAGE_SHOWREADME $INSTDIR\changelog.txt +!define MUI_FINISHPAGE_SHOWREADME_TEXT changelog.txt +;!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED +!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall.ico" +!define MUI_UNFINISHPAGE_NOAUTOCLOSE +;!define MUI_LANGDLL_REGISTRY_ROOT HKLM +;!define MUI_LANGDLL_REGISTRY_KEY ${REGKEY} +;!define MUI_LANGDLL_REGISTRY_VALUENAME InstallerLanguage + +# Defines the un-/installer logo of RetroShare +!insertmacro MUI_DEFAULT MUI_WELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\orange.bmp" +!insertmacro MUI_DEFAULT MUI_UNWELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\orange-uninstall.bmp" + +# Installer pages +!insertmacro MUI_PAGE_WELCOME +!insertmacro MUI_PAGE_LICENSE "$(myLicenseData)" +Page Custom PortableModePageCreate PortableModePageLeave +!define MUI_PAGE_CUSTOMFUNCTION_LEAVE dir_leave +!insertmacro MUI_PAGE_DIRECTORY +!insertmacro MUI_PAGE_COMPONENTS +!insertmacro MUI_PAGE_INSTFILES +!insertmacro MUI_PAGE_FINISH +!insertmacro MUI_UNPAGE_CONFIRM +!insertmacro MUI_UNPAGE_INSTFILES + +# Set languages (first is default language) +!insertmacro MUI_RESERVEFILE_LANGDLL + +# Installer languages +!define MUI_LANGDLL_ALLLANGUAGES + +# Translations +!macro LANG_LOAD LANGUAGE LANGCODE LANGID LICENCEFILE + !insertmacro MUI_LANGUAGE "${LANGUAGE}" +; !verbose off + !define LANG "${LANGUAGE}" + !include "lang\${LANGCODE}.nsh" + LangString LANGUAGEID "${LANG_${LANG}}" "1031" + LicenseLangString myLicenseData ${LANGCODE} ${LICENCEFILE} +; !verbose on + !undef LANG +!macroend + +!macro LANG_STRING NAME VALUE + LangString "${NAME}" "${LANG_${LANG}}" "${VALUE}" +!macroend + +!insertmacro LANG_LOAD "English" "en" "1033" "${SOURCEDIR}\retroshare-gui\src\license\license.txt" +!insertmacro LANG_LOAD "French" "fr" "1036" "${SOURCEDIR}\retroshare-gui\src\license\license-FR.txt" +!insertmacro LANG_LOAD "German" "de" "1031" "${SOURCEDIR}\retroshare-gui\src\license\license-GER.txt" +!insertmacro LANG_LOAD "Turkish" "tr" "1055" "${SOURCEDIR}\retroshare-gui\src\license\license-TR.txt" +!insertmacro LANG_LOAD "SimpChinese" "zh_CN" "2052" "${SOURCEDIR}\retroshare-gui\src\license\license.txt" +!insertmacro LANG_LOAD "Polish" "pl" "1045" "${SOURCEDIR}\retroshare-gui\src\license\license.txt" +!insertmacro LANG_LOAD "Spanish" "es" "1034" "${SOURCEDIR}\retroshare-gui\src\license\license.txt" +!insertmacro LANG_LOAD "Russian" "ru" "1049" "${SOURCEDIR}\retroshare-gui\src\license\license.txt" +!insertmacro LANG_LOAD "Catalan" "ca_ES" "1027" "${SOURCEDIR}\retroshare-gui\src\license\license.txt" + +LicenseData $(myLicenseData) + +# Main binaries +Section $(Section_Main) Section_Main + ;Set Section required + SectionIn RO + + ; Set Section properties + SetOverwrite on + + ; Clears previous error logs +; Delete "$INSTDIR\*.log" + + ; Main binaries + SetOutPath "$INSTDIR" + File "${RELEASEDIR}\retroshare-gui\src\release\retroshare.exe" + File /nonfatal "${RELEASEDIR}\libretroshare\src\lib\retroshare.dll" + + ; Qt binaries + File "${QTDIR}\bin\Qt6Core.dll" + File "${QTDIR}\bin\Qt6Core5Compat.dll" + File "${QTDIR}\bin\Qt6Gui.dll" + File "${QTDIR}\bin\Qt6Multimedia.dll" + File "${QTDIR}\bin\Qt6Network.dll" + File "${QTDIR}\bin\Qt6PrintSupport.dll" + File "${QTDIR}\bin\Qt6Svg.dll" + File "${QTDIR}\bin\Qt6Widgets.dll" + File "${QTDIR}\bin\Qt6Xml.dll" + + ; Qt platforms + SetOutPath "$INSTDIR\platforms" + File "${QTDIR}\plugins\platforms\qwindows.dll" + + ; Qt styles + SetOutPath "$INSTDIR\styles" + File "${QTDIR}\plugins\styles\qmodernwindowsstyle.dll" + + ; MinGW binaries + SetOutPath "$INSTDIR" + File "${MINGWDIR}\bin\libstdc++-6.dll" + !if ${ARCHITECTURE} == "x86" + File "${MINGWDIR}\bin\libgcc_s_dw2-1.dll" + !endif + !if ${ARCHITECTURE} == "x64" + File "${MINGWDIR}\bin\libgcc_s_seh-1.dll" + !endif + File "${MINGWDIR}\bin\libwinpthread-1.dll" + + ; External binaries + File "${EXTERNAL_LIB_DIR}\bin\miniupnpc.dll" + File "${RELEASEDIR}\supportlibs\librnp\Build\src\lib\librnp.dll" + !if ${ARCHITECTURE} == "x86" + File "${EXTERNAL_LIB_DIR}\bin\libcrypto-1_1.dll" + File "${EXTERNAL_LIB_DIR}\bin\libssl-1_1.dll" + !endif + !if ${ARCHITECTURE} == "x64" + File "${EXTERNAL_LIB_DIR}\bin\libcrypto-1_1-x64.dll" + File "${EXTERNAL_LIB_DIR}\bin\libssl-1_1-x64.dll" + !endif + + ; Other files + File "${RELEASEDIR}\changelog.txt" + File "${SOURCEDIR}\libbitdht\src\bitdht\bdboot.txt" + + ; License + SetOutPath "$INSTDIR\license" + File "${SOURCEDIR}\retroshare-gui\src\license\*.*" + + ; Image formats + SetOutPath "$INSTDIR\imageformats" + File /r "${QTDIR}\plugins\imageformats\qgif.dll" + File /r "${QTDIR}\plugins\imageformats\qicns.dll" + File /r "${QTDIR}\plugins\imageformats\qico.dll" + File /r "${QTDIR}\plugins\imageformats\qjpeg.dll" + File /r "${QTDIR}\plugins\imageformats\qsvg.dll" + File /r "${QTDIR}\plugins\imageformats\qtga.dll" + File /r "${QTDIR}\plugins\imageformats\qtiff.dll" + File /r "${QTDIR}\plugins\imageformats\qwbmp.dll" + File /r "${QTDIR}\plugins\imageformats\qwebp.dll" + + ; Sounds + SetOutPath "$INSTDIR\sounds" + File /r "${SOURCEDIR}\retroshare-gui\src\sounds\*.*" + + ; Translations + SetOutPath "$INSTDIR\translations" + File /r "${SOURCEDIR}\retroshare-gui\src\translations\*.qm" + File /r "${QTDIR}\translations\qt_*.qm" + File /r "${QTDIR}\translations\qtbase_*.qm" + File /r "${QTDIR}\translations\qtmultimedia_*.qm" + + ; WebUI +; SetOutPath "$INSTDIR\webui" +; File /r "${SOURCEDIR}\libresapi\src\webui\*.*" + + ; License + SetOutPath "$INSTDIR\license" + File /r "${SOURCEDIR}\retroshare-gui\src\license\*.*" +SectionEnd + +# Service +!ifdef SERVICE_EXISTS + Section /o $(Section_Service) Section_Service + SetOutPath "$INSTDIR" + File "${RELEASEDIR}\retroshare-service\src\release\retroshare-service.exe" + SectionEnd +!endif + +# Friend Server +!ifdef FRIENDSERVER_EXISTS + Section /o $(Section_FriendServer) Section_FriendServer + SetOutPath "$INSTDIR" + File "${RELEASEDIR}\retroshare-friendserver\src\release\retroshare-friendserver.exe" + SectionEnd +!endif + +# Tor +!ifdef TOR_EXISTS + Section /o $(Section_Tor) Section_Tor + SetOutPath "$INSTDIR\tor" + File "${TORDIR}\*" + SectionEnd +!endif + +# WebUI +!ifdef WEBUI_EXISTS + Section /o $(Section_WebUI) Section_WebUI + SetOutPath "$INSTDIR\webui" + File /r "${WEBUIDIR}\*" + SectionEnd +!endif + +# Plugins +${!defineifexist} PLUGIN_FEEDREADER_EXISTS "${RELEASEDIR}\plugins\FeedReader\lib\FeedReader.dll" +${!defineifexist} PLUGIN_VOIP_EXISTS "${RELEASEDIR}\plugins\VOIP\lib\VOIP.dll" + +!ifdef PLUGIN_FEEDREADER_EXISTS +!define /ifndef PLUGIN_EXISTS +!endif +!ifdef PLUGIN_VOIP_EXISTS +!define /ifndef PLUGIN_EXISTS +!endif + +!ifdef PLUGIN_EXISTS + SectionGroup $(Section_Plugins) Section_Plugins + !ifdef PLUGIN_FEEDREADER_EXISTS + Section $(Section_Plugin_FeedReader) Section_Plugin_FeedReader + SetOutPath "$DataDir\extensions6" + File "${RELEASEDIR}\plugins\FeedReader\lib\FeedReader.dll" + SectionEnd + !endif + + !ifdef PLUGIN_VOIP_EXISTS + Section $(Section_Plugin_VOIP) Section_Plugin_VOIP + SetOutPath "$DataDir\extensions6" + File "${RELEASEDIR}\plugins\VOIP\lib\VOIP.dll" + SetOutPath "$INSTDIR\sounds" + File /r "${SOURCEDIR}\plugins\VOIP\gui\sounds\*.*" + SectionEnd + !endif + SectionGroupEnd +!endif + +# Data (Styles) +Section $(Section_Data) Section_Data + ; Set Section properties + SetOverwrite on + + ; Chat style + SetOutPath "$StyleSheetDir\stylesheets\Bubble" + File /r "${SOURCEDIR}\retroshare-gui\src\gui\qss\chat\Bubble\*.*" + SetOutPath "$StyleSheetDir\stylesheets\Bubble_Compact" + File /r "${SOURCEDIR}\retroshare-gui\src\gui\qss\chat\Bubble_Compact\*.*" + + ; Stylesheets + SetOutPath "$INSTDIR\qss" + File /nonfatal /r "${SOURCEDIR}\retroshare-gui\src\qss\*.*" +SectionEnd + +;Section $(Section_Link) Section_Link + ; Delete any existing keys + + ; Write the file association +; WriteRegStr HKCR .pqi "" retroshare +; WriteRegStr HKCR retroshare "" "PQI File" +; WriteRegBin HKCR retroshare EditFlags 00000100 +; WriteRegStr HKCR "retroshare\shell" "" open +; WriteRegStr HKCR "retroshare\shell\open\command" "" `"$INSTDIR\retroshare.exe" "%1"` +;SectionEnd + +# Shortcuts +SectionGroup $(Section_Shortcuts) Section_Shortcuts +Section $(Section_StartMenu) Section_StartMenu + SetOutPath "$INSTDIR" + CreateDirectory "$SMPROGRAMS\${APPNAME}" + CreateShortCut "$SMPROGRAMS\${APPNAME}\$(Link_Uninstall).lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 + CreateShortCut "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk" "$INSTDIR\retroshare.exe" "" "$INSTDIR\retroshare.exe" 0 + +!ifdef SERVICE_EXISTS + SectionGetFlags ${Section_Service} $0 + IntOp $0 $0 & ${SF_SELECTED} + ${If} $0 == ${SF_SELECTED} + CreateShortCut "$SMPROGRAMS\${APPNAME}\${APPNAME} Service.lnk" "$INSTDIR\retroshare-service.exe" "" "$INSTDIR\retroshare-service.exe" 0 + ${EndIf} +!endif + +!ifdef FRIENDSERVER_EXISTS + SectionGetFlags ${Section_FriendServer} $0 + IntOp $0 $0 & ${SF_SELECTED} + ${If} $0 == ${SF_SELECTED} + CreateShortCut "$SMPROGRAMS\${APPNAME}\${APPNAME} Friend Server.lnk" "$INSTDIR\retroshare-friendserver.exe" "" "$INSTDIR\retroshare-friendserver.exe" 0 + ${EndIf} +!endif +SectionEnd + +Section $(Section_Desktop) Section_Desktop + CreateShortCut "$DESKTOP\${APPNAME}.lnk" "$INSTDIR\retroshare.exe" "" "$INSTDIR\retroshare.exe" 0 +SectionEnd + +Section $(Section_QuickLaunch) Section_QuickLaunch + CreateShortCut "$QUICKLAUNCH\${APPNAME}.lnk" "$INSTDIR\retroshare.exe" "" "$INSTDIR\retroshare.exe" 0 +SectionEnd +SectionGroupEnd + +Section $(Section_AutoStart) Section_AutoStart + WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "RetroShare" "$INSTDIR\retroshare.exe -m" +SectionEnd + +;Section $(Section_AutoStart) Section_AutoStart +; CreateShortCut "$SMSTARTUP\${APPNAME}.lnk" "$INSTDIR\retroshare.exe" "" "$INSTDIR\retroshare.exe -m" 0 +;SectionEnd + +Section -FinishSection + ${If} $PortableMode = 0 + WriteRegStr HKLM "Software\${APPNAME}" "" "$INSTDIR" + WriteRegStr HKLM "Software\${APPNAME}" "Version" "${VERSION}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayName" "${APPNAME}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayVersion" "${VERSION}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayIcon" "$INSTDIR\retroshare.exe" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "Publisher" "${PUBLISHER}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "NoModify" "1" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "NoRepair" "1" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "UninstallString" "$INSTDIR\uninstall.exe" + WriteUninstaller "$INSTDIR\uninstall.exe" + ${Else} + ; Create the file the application uses to detect portable mode + FileOpen $0 "$INSTDIR\portable" w + FileClose $0 + ${EndIf} +SectionEnd + +# Descriptions +!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN + !insertmacro MUI_DESCRIPTION_TEXT ${Section_Main} $(Section_Main_Desc) + !insertmacro MUI_DESCRIPTION_TEXT ${Section_Data} $(Section_Data_Desc) + !insertmacro MUI_DESCRIPTION_TEXT ${Section_Shortcuts} $(Section_Shortcuts_Desc) + !insertmacro MUI_DESCRIPTION_TEXT ${Section_StartMenu} $(Section_StartMenu_Desc) + !insertmacro MUI_DESCRIPTION_TEXT ${Section_Desktop} $(Section_Desktop_Desc) + !insertmacro MUI_DESCRIPTION_TEXT ${Section_QuickLaunch} $(Section_QuickLaunch_Desc) + !insertmacro MUI_DESCRIPTION_TEXT ${Section_Plugins} $(Section_Plugins_Desc) + !insertmacro MUI_DESCRIPTION_TEXT ${Section_Plugin_FeedReader} $(Section_Plugin_FeedReader_Desc) + !insertmacro MUI_DESCRIPTION_TEXT ${Section_Plugin_VOIP} $(Section_Plugin_VOIP_Desc) +; !insertmacro MUI_DESCRIPTION_TEXT ${Section_Link} $(Section_Link_Desc) + !insertmacro MUI_DESCRIPTION_TEXT ${Section_AutoStart} $(Section_AutoStart_Desc) + !insertmacro MUI_DESCRIPTION_TEXT ${Section_Tor} $(Section_Tor_Desc) + !insertmacro MUI_DESCRIPTION_TEXT ${Section_WebUI} $(Section_WebUI_Desc) + !insertmacro MUI_DESCRIPTION_TEXT ${Section_Service} $(Section_Service_Desc) + !insertmacro MUI_DESCRIPTION_TEXT ${Section_FriendServer} $(Section_FriendServer_Desc) +!insertmacro MUI_FUNCTION_DESCRIPTION_END + +# Uninstall +Section "Uninstall" + ; Remove file association registry keys +; DeleteRegKey HKCR .pqi + DeleteRegKey HKCR RetroShare + + ; Remove program/uninstall regsitry keys + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" + DeleteRegKey HKLM SOFTWARE\${APPNAME} + + DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "RetroShare" + + ; Remove shortcuts, if any + Delete "$SMPROGRAMS\${APPNAME}\*.*" + + ; Remove desktop shortcut + Delete "$DESKTOP\${APPNAME}.lnk" + + ; Remove Quicklaunch shortcut + Delete "$QUICKLAUNCH\${APPNAME}.lnk" + + ; Remove Autstart + Delete "$SMSTARTUP\${APPNAME}.lnk" + + ; Remove directories used + RMDir "$SMPROGRAMS\${APPNAME}" + RMDir /r "$INSTDIR" + + ; Don't remove the directory, otherwise + ; we lose the XPGP keys. + ; Should make this an option though... + RMDir /r "${DATADIR_NORMAL}\extensions6" + RMDir /r "${DATADIR_NORMAL}\stylesheets" +SectionEnd + +Function .onInit + StrCpy $InstDirNormal "${INSTDIR_NORMAL}" + StrCpy $InstDirPortable "${INSTDIR_PORTABLE}" + + StrCpy $PortableMode 0 + StrCpy $INSTDIR "$InstDirNormal" + StrCpy $DataDir "${DATADIR_NORMAL}" + + InitPluginsDir + Push $R1 + File /oname=$PLUGINSDIR\spltmp.bmp "${SOURCEDIR}\retroshare-gui\src\gui\images\logo\logo_splash.png" + advsplash::show 1200 1000 1000 -1 $PLUGINSDIR\spltmp + Pop $R1 + Pop $R1 + !insertmacro MUI_LANGDLL_DISPLAY +FunctionEnd + +!ifdef FRIENDSERVER_EXISTS +Function .onSelChange + SectionGetFlags ${Section_FriendServer} $0 + IntOp $0 $0 & ${SF_SELECTED} + ${If} $0 == ${SF_SELECTED} + # Activate Tor and set readonly + SectionGetFlags ${Section_Tor} $1 + IntOp $1 $1 | ${SF_SELECTED} + IntOp $1 $1 | ${SF_RO} + SectionSetFlags ${Section_Tor} $1 + ${Else} + # Remove readonly from Tor + SectionGetFlags ${Section_Tor} $1 + IntOp $2 ${SF_RO} ~ + IntOp $1 $1 & $2 + SectionSetFlags ${Section_Tor} $1 + ${EndIf} +FunctionEnd +!endif + +# Installation mode + +Function RequireAdmin + UserInfo::GetAccountType + Pop $8 + ${If} $8 != "admin" + MessageBox MB_ICONSTOP "You need administrator rights to install ${APPNAME}" + SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED + Abort + ${EndIf} +FunctionEnd + +Function SetModeDestinationFromInstdir + ${If} $PortableMode = 0 + StrCpy $InstDirNormal $INSTDIR + ${Else} + StrCpy $InstDirPortable $INSTDIR + ${EndIf} +FunctionEnd + +Function PortableModePageCreate + Call SetModeDestinationFromInstdir ; If the user clicks BACK on the directory page we will remember their mode specific directory + !insertmacro MUI_HEADER_TEXT $(Page_InstallMode) $(Page_InstallMode_Desc) + nsDialogs::Create 1018 + Pop $0 + ${NSD_CreateRadioButton} 5u 25u -10u 8u $(Page_InstallMode_Standard) + Pop $1 + ${NSD_CreateLabel} 18u 40u -10u 24u $(Page_InstallMode_Standard_Desc) + Pop $0 + ${NSD_CreateRadioButton} 5u 75u -10u 8u $(Page_InstallMode_Portable) + Pop $2 + ${NSD_CreateLabel} 18u 90u -10u 24u $(Page_InstallMode_Portable_Desc) + Pop $0 + ${If} $PortableMode = 0 + SendMessage $1 ${BM_SETCHECK} ${BST_CHECKED} 0 + ${Else} + SendMessage $2 ${BM_SETCHECK} ${BST_CHECKED} 0 + ${EndIf} + nsDialogs::Show +FunctionEnd + +Function PortableModePageLeave + ${NSD_GetState} $1 $0 + ${If} $0 <> ${BST_UNCHECKED} + StrCpy $PortableMode 0 + StrCpy $INSTDIR $InstDirNormal + Call RequireAdmin + ; Enable sections + SectionSetText ${Section_Shortcuts} $(Section_Shortcuts) + SectionSetText ${Section_StartMenu} $(Section_StartMenu) + SectionSetText ${Section_Desktop} $(Section_Desktop) + SectionSetText ${Section_QuickLaunch} $(Section_QuickLaunch) + SectionSetText ${Section_AutoStart} $(Section_AutoStart) + !insertmacro SelectSection ${Section_Shortcuts} + !insertmacro SelectSection ${Section_AutoStart} + !insertmacro SelectSection ${Section_StartMenu} + !insertmacro SelectSection ${Section_Desktop} + !insertmacro SelectSection ${Section_QuickLaunch} + ${Else} + StrCpy $PortableMode 1 + StrCpy $INSTDIR $InstDirPortable + ; Disable sections + !insertmacro UnselectSection ${Section_Shortcuts} + !insertmacro UnselectSection ${Section_AutoStart} + !insertmacro UnselectSection ${Section_StartMenu} + !insertmacro UnselectSection ${Section_Desktop} + !insertmacro UnselectSection ${Section_QuickLaunch} + SectionSetText ${Section_Shortcuts} "" + SectionSetText ${Section_StartMenu} "" + SectionSetText ${Section_Desktop} "" + SectionSetText ${Section_QuickLaunch} "" + SectionSetText ${Section_AutoStart} "" + ${EndIf} +FunctionEnd + +Function dir_leave + ${If} $PortableMode = 0 + StrCpy $DataDir "${DATADIR_NORMAL}" + StrCpy $StyleSheetDir $DataDir + ${Else} + StrCpy $DataDir "${DATADIR_PORTABLE}" + StrCpy $StyleSheetDir $INSTDIR + ${EndIf} +FunctionEnd diff --git a/data/retroshare.desktop b/data/retroshare.desktop index 95056d54a..fa590dba3 100644 --- a/data/retroshare.desktop +++ b/data/retroshare.desktop @@ -4,7 +4,7 @@ Version=1.0 Name=RetroShare Comment=Securely communicate with your friends Exec=/usr/bin/retroshare %U -Icon=/usr/share/pixmaps/retroshare.xpm +Icon=retroshare.xpm Terminal=false Type=Application Categories=Network;Email;InstantMessaging;Chat;Feed;FileTransfer;P2P diff --git a/libretroshare b/libretroshare index ac83e00ea..96e249a06 160000 --- a/libretroshare +++ b/libretroshare @@ -1 +1 @@ -Subproject commit ac83e00ea7a26cd6cf57cefef745d6dcfd07e5da +Subproject commit 96e249a06d8f30c2aace38beecc8fb7271159a88 diff --git a/openpgpsdk b/openpgpsdk index 178aa8ebc..634f701d4 160000 --- a/openpgpsdk +++ b/openpgpsdk @@ -1 +1 @@ -Subproject commit 178aa8ebcef47e3271d5a5ca5c07e45d3b71c81d +Subproject commit 634f701d44585e4648b898be99d26e288db1881e diff --git a/plugins/FeedReader/FeedReader.pro b/plugins/FeedReader/FeedReader.pro index e9a352b33..4b0cae546 100644 --- a/plugins/FeedReader/FeedReader.pro +++ b/plugins/FeedReader/FeedReader.pro @@ -28,6 +28,8 @@ greaterThan(QT_MAJOR_VERSION, 4) { QT += widgets } +greaterThan(QT_MAJOR_VERSION,5): QT += core5compat + target.files = lib/libFeedReader.so SOURCES = FeedReaderPlugin.cpp \ @@ -128,7 +130,7 @@ win32 { isEmpty(QMAKE_SH) { # MinGW - LIBS += -lcrypt32 + LIBS += -lcrypt32 -lbcrypt } # Check for msys2 diff --git a/plugins/FeedReader/gui/AddFeedDialog.cpp b/plugins/FeedReader/gui/AddFeedDialog.cpp index b6e781c4b..0951de7f5 100644 --- a/plugins/FeedReader/gui/AddFeedDialog.cpp +++ b/plugins/FeedReader/gui/AddFeedDialog.cpp @@ -28,6 +28,7 @@ #include "FeedReaderStringDefs.h" #include "gui/settings/rsharesettings.h" #include "gui/common/UIStateHelper.h" +#include "util/DateTime.h" #include #include @@ -339,8 +340,7 @@ bool AddFeedDialog::fillFeed(uint32_t feedId) ui->useStandardUpdateInterval->setChecked(feedInfo.flag.standardUpdateInterval); ui->updateIntervalSpinBox->setValue(feedInfo.updateInterval / 60); - QDateTime dateTime; - dateTime.setTime_t(feedInfo.lastUpdate); + QDateTime dateTime = DateTime::DateTimeFromTime_t(feedInfo.lastUpdate); ui->lastUpdate->setText(dateTime.toString()); ui->useStandardStorageTimeCheckBox->setChecked(feedInfo.flag.standardStorageTime); diff --git a/plugins/FeedReader/gui/FeedReaderConfig.h b/plugins/FeedReader/gui/FeedReaderConfig.h index af31fe33f..6339b6ce6 100644 --- a/plugins/FeedReader/gui/FeedReaderConfig.h +++ b/plugins/FeedReader/gui/FeedReaderConfig.h @@ -36,7 +36,7 @@ class FeedReaderConfig : public ConfigPage public: /** Default Constructor */ - FeedReaderConfig(QWidget *parent = 0, Qt::WindowFlags flags = 0); + FeedReaderConfig(QWidget *parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); /** Default Destructor */ virtual ~FeedReaderConfig(); diff --git a/plugins/FeedReader/gui/FeedReaderDialog.cpp b/plugins/FeedReader/gui/FeedReaderDialog.cpp index 87db9cf9c..b560ed2f6 100644 --- a/plugins/FeedReader/gui/FeedReaderDialog.cpp +++ b/plugins/FeedReader/gui/FeedReaderDialog.cpp @@ -34,7 +34,7 @@ #include "FeedReaderStringDefs.h" #include "gui/common/RSTreeWidgetItem.h" #include "gui/settings/rsharesettings.h" -#include "gui/notifyqt.h" +#include "gui/RsGUIEventManager.h" #include "FeedReaderUserNotify.h" #include "gui/Posted/PostedCreatePostDialog.h" #include "util/imageutil.h" @@ -73,7 +73,7 @@ FeedReaderDialog::FeedReaderDialog(RsFeedReader *feedReader, FeedReaderNotify *n connect(mNotify, &FeedReaderNotify::feedChanged, this, &FeedReaderDialog::feedChanged, Qt::QueuedConnection); connect(mNotify, &FeedReaderNotify::optimizeImage, this, &FeedReaderDialog::optimizeImage, Qt::QueuedConnection); - connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); + connect(RsGUIEventManager::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); /* connect signals */ connect(ui->feedTreeWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)), this, SLOT(feedTreeItemActivated(QTreeWidgetItem*))); @@ -570,7 +570,7 @@ void FeedReaderDialog::feedChanged(uint32_t feedId, int type) } FeedInfo feedInfo; - if (type != NOTIFY_TYPE_DEL) { + if (type != FeedReaderNotify::NOTIFY_TYPE_DEL) { if (!mFeedReader->getFeedInfo(feedId, feedInfo)) { return; } @@ -580,12 +580,12 @@ void FeedReaderDialog::feedChanged(uint32_t feedId, int type) } } - if (type == NOTIFY_TYPE_MOD || type == NOTIFY_TYPE_DEL) { + if (type == FeedReaderNotify::NOTIFY_TYPE_MOD || type == FeedReaderNotify::NOTIFY_TYPE_DEL) { QTreeWidgetItemIterator it(ui->feedTreeWidget); QTreeWidgetItem *item; while ((item = *it) != NULL) { if (item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toUInt() == feedId) { - if (type == NOTIFY_TYPE_MOD) { + if (type == FeedReaderNotify::NOTIFY_TYPE_MOD) { updateFeedItem(item, feedInfo); } else { delete(item); @@ -596,7 +596,7 @@ void FeedReaderDialog::feedChanged(uint32_t feedId, int type) } } - if (type == NOTIFY_TYPE_ADD) { + if (type == FeedReaderNotify::NOTIFY_TYPE_ADD) { QTreeWidgetItemIterator it(ui->feedTreeWidget); QTreeWidgetItem *itemParent; while ((itemParent = *it) != NULL) { diff --git a/plugins/FeedReader/gui/FeedReaderDialog.h b/plugins/FeedReader/gui/FeedReaderDialog.h index a9672bc76..ab9b61007 100644 --- a/plugins/FeedReader/gui/FeedReaderDialog.h +++ b/plugins/FeedReader/gui/FeedReaderDialog.h @@ -40,15 +40,15 @@ class FeedReaderDialog : public MainPage Q_OBJECT public: - FeedReaderDialog(RsFeedReader *feedReader, FeedReaderNotify *notify, QWidget *parent = 0); + FeedReaderDialog(RsFeedReader *feedReader, FeedReaderNotify *notify, QWidget *parent = 0); ~FeedReaderDialog(); static QIcon iconFromFeed(const FeedInfo &feedInfo); protected: virtual UserNotify *createUserNotify(QObject *parent) override; - virtual void showEvent(QShowEvent *event); - bool eventFilter(QObject *obj, QEvent *ev); + virtual void showEvent(QShowEvent *event) override; + bool eventFilter(QObject *obj, QEvent *ev) override; private slots: void settingsChanged(); diff --git a/plugins/FeedReader/gui/FeedReaderFeedNotify.cpp b/plugins/FeedReader/gui/FeedReaderFeedNotify.cpp index 23d95f50e..424e74ff6 100644 --- a/plugins/FeedReader/gui/FeedReaderFeedNotify.cpp +++ b/plugins/FeedReader/gui/FeedReaderFeedNotify.cpp @@ -27,6 +27,7 @@ #include "FeedReaderFeedItem.h" #include "gui/settings/rsharesettings.h" #include "retroshare/rsiface.h" +#include "util/DateTime.h" FeedReaderFeedNotify::FeedReaderFeedNotify(RsFeedReader *feedReader, FeedReaderNotify *notify, QObject *parent) : FeedNotify(parent), mFeedReader(feedReader), mNotify(notify) @@ -71,7 +72,7 @@ void FeedReaderFeedNotify::msgChanged(uint32_t feedId, const QString &msgId, int return; } - if (type != NOTIFY_TYPE_ADD) { + if (type != FeedReaderNotify::NOTIFY_TYPE_ADD) { return; } @@ -135,7 +136,7 @@ FeedItem *FeedReaderFeedNotify::testFeedItem(FeedHolder */*parent*/) FeedMsgInfo msgInfo; msgInfo.title = tr("Test message").toUtf8().constData(); msgInfo.description = tr("This is a test message.").toUtf8().constData(); - msgInfo.pubDate = QDateTime::currentDateTime().toTime_t(); + msgInfo.pubDate = DateTime::DateTimeToTime_t(QDateTime::currentDateTime()); //TODO: parent? return new FeedReaderFeedItem(mFeedReader, mNotify, feedInfo, msgInfo); diff --git a/plugins/FeedReader/gui/FeedReaderMessageWidget.cpp b/plugins/FeedReader/gui/FeedReaderMessageWidget.cpp index ec0e3d0e2..b97aa4e8e 100644 --- a/plugins/FeedReader/gui/FeedReaderMessageWidget.cpp +++ b/plugins/FeedReader/gui/FeedReaderMessageWidget.cpp @@ -36,11 +36,12 @@ #include "gui/common/RSTreeWidgetItem.h" #include "gui/settings/rsharesettings.h" #include "util/HandleRichText.h" -#include "util/QtVersion.h" +#include "util/RsQtVersion.h" #include "gui/Posted/PostedCreatePostDialog.h" #include "gui/gxsforums/CreateGxsForumMsg.h" #include "gui/common/FilesDefs.h" #include "util/imageutil.h" +#include "util/DateTime.h" #include "retroshare/rsiface.h" #include "retroshare/rsgxsforums.h" @@ -476,8 +477,7 @@ void FeedReaderMessageWidget::calculateMsgIconsAndFonts(QTreeWidgetItem *item) void FeedReaderMessageWidget::updateMsgItem(QTreeWidgetItem *item, FeedMsgInfo &info) { QString title = QString::fromUtf8(info.title.c_str()); - QDateTime qdatetime; - qdatetime.setTime_t(info.pubDate); + QDateTime qdatetime = DateTime::DateTimeFromTime_t(info.pubDate); /* add string to all data */ QString sort = QString("%1_%2_%3").arg(title, qdatetime.toString("yyyyMMdd_hhmmss")).arg(info.feedId); @@ -515,12 +515,12 @@ void FeedReaderMessageWidget::feedChanged(uint32_t feedId, int type) return; } - if (type == NOTIFY_TYPE_DEL) { + if (type == FeedReaderNotify::NOTIFY_TYPE_DEL) { setFeedId(0); return; } - if (type == NOTIFY_TYPE_MOD) { + if (type == FeedReaderNotify::NOTIFY_TYPE_MOD) { if (!mFeedReader->getFeedInfo(mFeedId, mFeedInfo)) { setFeedId(0); return; @@ -555,18 +555,18 @@ void FeedReaderMessageWidget::msgChanged(uint32_t feedId, const QString &msgId, } FeedMsgInfo msgInfo; - if (type != NOTIFY_TYPE_DEL) { + if (type != FeedReaderNotify::NOTIFY_TYPE_DEL) { if (!mFeedReader->getMsgInfo(feedId, msgId.toStdString(), msgInfo)) { return; } } - if (type == NOTIFY_TYPE_MOD || type == NOTIFY_TYPE_DEL) { + if (type == FeedReaderNotify::NOTIFY_TYPE_MOD || type == FeedReaderNotify::NOTIFY_TYPE_DEL) { QTreeWidgetItemIterator it(ui->msgTreeWidget); QTreeWidgetItem *item; while ((item = *it) != NULL) { if (item->data(COLUMN_MSG_DATA, ROLE_MSG_ID).toString() == msgId) { - if (type == NOTIFY_TYPE_MOD) { + if (type == FeedReaderNotify::NOTIFY_TYPE_MOD) { updateMsgItem(item, msgInfo); filterItem(item); } else { @@ -578,13 +578,13 @@ void FeedReaderMessageWidget::msgChanged(uint32_t feedId, const QString &msgId, } } - if (type == NOTIFY_TYPE_MOD) { + if (type == FeedReaderNotify::NOTIFY_TYPE_MOD) { if (msgId.toStdString() == currentMsgId()) { updateCurrentMessage(); } } - if (type == NOTIFY_TYPE_ADD) { + if (type == FeedReaderNotify::NOTIFY_TYPE_ADD) { QTreeWidgetItem *item = new RSTreeWidgetItem(mMsgCompareRole); updateMsgItem(item, msgInfo); ui->msgTreeWidget->addTopLevelItem(item); diff --git a/plugins/FeedReader/gui/FeedReaderNotify.h b/plugins/FeedReader/gui/FeedReaderNotify.h index 5913f1985..723f94f64 100644 --- a/plugins/FeedReader/gui/FeedReaderNotify.h +++ b/plugins/FeedReader/gui/FeedReaderNotify.h @@ -29,6 +29,13 @@ class FeedReaderNotify : public QObject, public RsFeedReaderNotify Q_OBJECT public: + // These replace the variables from the old notify system. It's simpler than switching the entire + // feedreader plugin to the new rsEvents system + + static const int NOTIFY_TYPE_ADD = 0x01; + static const int NOTIFY_TYPE_DEL = 0x02; + static const int NOTIFY_TYPE_MOD = 0x03; + FeedReaderNotify(); /* RsFeedReaderNotify */ diff --git a/plugins/FeedReader/gui/FeedReaderUserNotify.cpp b/plugins/FeedReader/gui/FeedReaderUserNotify.cpp index 68c23a7c6..8d0ea2194 100644 --- a/plugins/FeedReader/gui/FeedReaderUserNotify.cpp +++ b/plugins/FeedReader/gui/FeedReaderUserNotify.cpp @@ -67,7 +67,7 @@ void FeedReaderUserNotify::iconClicked() void FeedReaderUserNotify::feedChanged(uint32_t /*feedId*/, int type) { - if (type == NOTIFY_TYPE_DEL) { + if (type == FeedReaderNotify::NOTIFY_TYPE_DEL) { updateIcon(); } } diff --git a/plugins/FeedReader/gui/PreviewFeedDialog.cpp b/plugins/FeedReader/gui/PreviewFeedDialog.cpp index ea582c04f..44d27a297 100644 --- a/plugins/FeedReader/gui/PreviewFeedDialog.cpp +++ b/plugins/FeedReader/gui/PreviewFeedDialog.cpp @@ -294,13 +294,13 @@ void PreviewFeedDialog::feedChanged(uint32_t feedId, int type) return; } - if (type == NOTIFY_TYPE_DEL) { + if (type == FeedReaderNotify::NOTIFY_TYPE_DEL) { /* feed deleted */ mFeedId = 0; return; } - if (type == NOTIFY_TYPE_ADD || type == NOTIFY_TYPE_MOD) { + if (type == FeedReaderNotify::NOTIFY_TYPE_ADD || type == FeedReaderNotify::NOTIFY_TYPE_MOD) { FeedInfo feedInfo; if (!mFeedReader->getFeedInfo(mFeedId, feedInfo)) { return; @@ -320,18 +320,18 @@ void PreviewFeedDialog::msgChanged(uint32_t feedId, const QString &msgId, int ty } switch (type) { - case NOTIFY_TYPE_ADD: + case FeedReaderNotify::NOTIFY_TYPE_ADD: if (mMsgId.empty()) { mMsgId = msgId.toStdString(); updateMsg(); } break; - case NOTIFY_TYPE_MOD: + case FeedReaderNotify::NOTIFY_TYPE_MOD: if (mMsgId == msgId.toStdString()) { updateMsg(); } break; - case NOTIFY_TYPE_DEL: + case FeedReaderNotify::NOTIFY_TYPE_DEL: if (mMsgId == msgId.toStdString()) { std::list::iterator it = std::find(mMsgIds.begin(), mMsgIds.end(), mMsgId); if (it != mMsgIds.end()) { diff --git a/plugins/FeedReader/services/p3FeedReader.cc b/plugins/FeedReader/services/p3FeedReader.cc index 3e46a027c..10d54ac08 100644 --- a/plugins/FeedReader/services/p3FeedReader.cc +++ b/plugins/FeedReader/services/p3FeedReader.cc @@ -20,6 +20,7 @@ #include "rsFeedReaderItems.h" #include "p3FeedReader.h" +#include "gui/FeedReaderNotify.h" #include "p3FeedReaderThread.h" #include "rsitems/rsconfigitems.h" #include "retroshare/rsiface.h" @@ -415,7 +416,7 @@ RsFeedResult p3FeedReader::addFolder(uint32_t parentId, const std::string &name, IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_NOW); if (mNotify) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_ADD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_ADD); } return RS_FEED_RESULT_SUCCESS; @@ -455,7 +456,7 @@ RsFeedResult p3FeedReader::setFolder(uint32_t feedId, const std::string &name) IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_NOW); if (mNotify) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD); } return RS_FEED_RESULT_SUCCESS; @@ -502,7 +503,7 @@ RsFeedResult p3FeedReader::addFeed(const FeedInfo &feedInfo, uint32_t &feedId) IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_NOW); if (mNotify) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_ADD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_ADD); } return RS_FEED_RESULT_SUCCESS; @@ -587,7 +588,7 @@ RsFeedResult p3FeedReader::setFeed(uint32_t feedId, const FeedInfo &feedInfo) IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_NOW); if (mNotify) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD); } if (!forumId.empty()) { @@ -658,7 +659,7 @@ RsFeedResult p3FeedReader::setParent(uint32_t feedId, uint32_t parentId) IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_NOW); if (mNotify) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD); } } @@ -756,7 +757,7 @@ bool p3FeedReader::removeFeed(uint32_t feedId) /* only notify remove of feed */ std::list::iterator it; for (it = removedFeedIds.begin(); it != removedFeedIds.end(); ++it) { - mNotify->notifyFeedChanged(*it, NOTIFY_TYPE_DEL); + mNotify->notifyFeedChanged(*it, FeedReaderNotify::NOTIFY_TYPE_DEL); } } @@ -803,7 +804,7 @@ bool p3FeedReader::addPreviewFeed(const FeedInfo &feedInfo, uint32_t &feedId) } if (mNotify) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_ADD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_ADD); } { @@ -925,8 +926,8 @@ bool p3FeedReader::removeMsg(uint32_t feedId, const std::string &msgId) } if (mNotify) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); - mNotify->notifyMsgChanged(feedId, msgId, NOTIFY_TYPE_DEL); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD); + mNotify->notifyMsgChanged(feedId, msgId, FeedReaderNotify::NOTIFY_TYPE_DEL); } return true; @@ -977,11 +978,11 @@ bool p3FeedReader::removeMsgs(uint32_t feedId, const std::list &msg } if (mNotify && !removedMsgs.empty()) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD); std::list::iterator it; for (it = removedMsgs.begin(); it != removedMsgs.end(); ++it) { - mNotify->notifyMsgChanged(feedId, *it, NOTIFY_TYPE_DEL); + mNotify->notifyMsgChanged(feedId, *it, FeedReaderNotify::NOTIFY_TYPE_DEL); } } @@ -1224,7 +1225,7 @@ bool p3FeedReader::processFeed(uint32_t feedId) if (mNotify) { for (it = notifyIds.begin(); it != notifyIds.end(); ++it) { - mNotify->notifyFeedChanged(*it, NOTIFY_TYPE_MOD); + mNotify->notifyFeedChanged(*it, FeedReaderNotify::NOTIFY_TYPE_MOD); } } @@ -1273,8 +1274,8 @@ bool p3FeedReader::setMessageRead(uint32_t feedId, const std::string &msgId, boo if (changed) { IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_OFTEN); if (mNotify) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); - mNotify->notifyMsgChanged(feedId, msgId, NOTIFY_TYPE_MOD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD); + mNotify->notifyMsgChanged(feedId, msgId, FeedReaderNotify::NOTIFY_TYPE_MOD); } } @@ -1328,10 +1329,10 @@ bool p3FeedReader::retransformMsg(uint32_t feedId, const std::string &msgId) IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_NOW); if (mNotify) { if (feedChanged) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD); } if (msgChanged) { - mNotify->notifyMsgChanged(feedId, msgId, NOTIFY_TYPE_MOD); + mNotify->notifyMsgChanged(feedId, msgId, FeedReaderNotify::NOTIFY_TYPE_MOD); } } } @@ -1466,7 +1467,7 @@ int p3FeedReader::tick() if (mNotify) { for (it = notifyIds.begin(); it != notifyIds.end(); ++it) { - mNotify->notifyFeedChanged(*it, NOTIFY_TYPE_MOD); + mNotify->notifyFeedChanged(*it, FeedReaderNotify::NOTIFY_TYPE_MOD); } if (imageToOptimze) { mNotify->notifyOptimizeImage(); @@ -1526,7 +1527,7 @@ void p3FeedReader::cleanFeeds() if (mNotify) { std::list >::iterator it; for (it = removedMsgIds.begin(); it != removedMsgIds.end(); ++it) { - mNotify->notifyMsgChanged(it->first, it->second, NOTIFY_TYPE_DEL); + mNotify->notifyMsgChanged(it->first, it->second, FeedReaderNotify::NOTIFY_TYPE_DEL); } } } @@ -1801,7 +1802,7 @@ bool p3FeedReader::getFeedToDownload(RsFeedReaderFeed &feed, uint32_t neededFeed } if (mNotify) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD); } return true; @@ -1852,7 +1853,7 @@ void p3FeedReader::onDownloadSuccess(uint32_t feedId, const std::string &content } if (mNotify) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD); } } @@ -1889,7 +1890,7 @@ void p3FeedReader::onDownloadError(uint32_t feedId, RsFeedReaderErrorState resul } if (mNotify) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD); } } @@ -1944,7 +1945,7 @@ bool p3FeedReader::getFeedToProcess(RsFeedReaderFeed &feed, uint32_t neededFeedI } if (mNotify) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD); } return true; @@ -2323,11 +2324,11 @@ void p3FeedReader::onProcessSuccess_addMsgs(uint32_t feedId, std::listnotifyFeedChanged(feedId, NOTIFY_TYPE_MOD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD); std::list::iterator it; for (it = addedMsgs.begin(); it != addedMsgs.end(); ++it) { - mNotify->notifyMsgChanged(feedId, *it, NOTIFY_TYPE_ADD); + mNotify->notifyMsgChanged(feedId, *it, FeedReaderNotify::NOTIFY_TYPE_ADD); } } } @@ -2365,7 +2366,7 @@ void p3FeedReader::onProcessError(uint32_t feedId, RsFeedReaderErrorState result } if (mNotify) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD); } } @@ -2433,7 +2434,7 @@ void p3FeedReader::setFeedInfo(uint32_t feedId, const std::string &name, const s } if (mNotify) { - mNotify->notifyFeedChanged(feedId, NOTIFY_TYPE_MOD); + mNotify->notifyFeedChanged(feedId, FeedReaderNotify::NOTIFY_TYPE_MOD); } } diff --git a/plugins/FeedReader/services/p3FeedReader.h b/plugins/FeedReader/services/p3FeedReader.h index 0df9bf79e..0bea5de82 100644 --- a/plugins/FeedReader/services/p3FeedReader.h +++ b/plugins/FeedReader/services/p3FeedReader.h @@ -32,9 +32,9 @@ class RsFeedReaderMsg; class p3FeedReaderThread; class RsGxsForums; -struct RsGxsForumGroup; +class RsGxsForumGroup; class RsPosted; -struct RsPostedGroup; +class RsPostedGroup; class RsGxsIfaceHelper; class p3FeedReader : public RsPQIService, public RsFeedReader diff --git a/plugins/VOIP/gui/QVideoDevice.cpp b/plugins/VOIP/gui/QVideoDevice.cpp index 51e3a83bf..fb81b84e2 100644 --- a/plugins/VOIP/gui/QVideoDevice.cpp +++ b/plugins/VOIP/gui/QVideoDevice.cpp @@ -37,6 +37,7 @@ QVideoInputDevice::QVideoInputDevice(QWidget *parent) _capture_device = NULL ; _video_processor = NULL ; _echo_output_device = NULL ; + _image_capture = NULL; } QVideoInputDevice::~QVideoInputDevice() diff --git a/plugins/VOIP/gui/VOIPToasterItem.cpp b/plugins/VOIP/gui/VOIPToasterItem.cpp index c250f67c3..6468aa34b 100644 --- a/plugins/VOIP/gui/VOIPToasterItem.cpp +++ b/plugins/VOIP/gui/VOIPToasterItem.cpp @@ -27,7 +27,7 @@ /*Retroshare-Gui*/ #include "gui/chat/ChatDialog.h" -#include "gui/notifyqt.h" +#include "gui/RsGUIEventManager.h" #include "util/HandleRichText.h" VOIPToasterItem::VOIPToasterItem(const RsPeerId &peer_id, const QString &msg, const voipToasterItem_Type type) diff --git a/plugins/plugins.pro b/plugins/plugins.pro index 7ecbc32c7..692f3c766 100644 --- a/plugins/plugins.pro +++ b/plugins/plugins.pro @@ -18,6 +18,10 @@ TEMPLATE = subdirs +win32-g++:isEmpty(QMAKE_SH):lessThan(QT_MAJOR_VERSION,6) { + # Qt 5 Windows native build SUBDIRS += \ VOIP \ +} +SUBDIRS += \ FeedReader diff --git a/retroshare-gui/CMakeLists.txt b/retroshare-gui/CMakeLists.txt index 314edf1ab..9b5240e17 100644 --- a/retroshare-gui/CMakeLists.txt +++ b/retroshare-gui/CMakeLists.txt @@ -77,14 +77,24 @@ set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) -find_package( Qt5 COMPONENTS Core REQUIRED) -find_package( Qt5 COMPONENTS Widgets REQUIRED) -find_package( Qt5 COMPONENTS Xml REQUIRED) -find_package( Qt5 COMPONENTS Network REQUIRED) -find_package( Qt5 COMPONENTS Multimedia REQUIRED) -find_package( Qt5 COMPONENTS PrintSupport REQUIRED) +find_package( Qt6 COMPONENTS Core REQUIRED) +find_package( Qt6 COMPONENTS Widgets REQUIRED) +find_package( Qt6 COMPONENTS Xml REQUIRED) +find_package( Qt6 COMPONENTS Network REQUIRED) +find_package( Qt6 COMPONENTS Multimedia REQUIRED) +find_package( Qt6 COMPONENTS PrintSupport REQUIRED) -list( APPEND RS_LINK_LIBRARIES Qt5::Multimedia Qt5::Widgets Qt5::Xml Qt5::Network Qt5::PrintSupport) +list( APPEND RS_LINK_LIBRARIES Qt6::Multimedia Qt6::Widgets Qt6::Xml Qt6::Network Qt6::PrintSupport) +if (NOT Qt6_FOUND) + find_package( Qt5 COMPONENTS Core REQUIRED) + find_package( Qt5 COMPONENTS Widgets REQUIRED) + find_package( Qt5 COMPONENTS Xml REQUIRED) + find_package( Qt5 COMPONENTS Network REQUIRED) + find_package( Qt5 COMPONENTS Multimedia REQUIRED) + find_package( Qt5 COMPONENTS PrintSupport REQUIRED) + + list( APPEND RS_LINK_LIBRARIES Qt5::Multimedia Qt5::Widgets Qt5::Xml Qt5::Network Qt5::PrintSupport) +endif() ################################################################################ @@ -104,7 +114,10 @@ endif(RS_DEVELOPMENT_BUILD) include(src/CMakeLists.txt) -qt5_wrap_ui(RS_UI_HEADERS ${RS_GUI_FORMS}) +qt_wrap_ui(RS_UI_HEADERS ${RS_GUI_FORMS}) +if (NOT Qt6_FOUND) + qt5_wrap_ui(RS_UI_HEADERS ${RS_GUI_FORMS}) +endif() add_executable(${PROJECT_NAME} ${RS_GUI_SOURCES} ${RS_UI_HEADERS} ${RS_GUI_QTRESOURCES}) install(TARGETS ${PROJECT_NAME} DESTINATION ${RS_BIN_INSTALL_DIR}) diff --git a/retroshare-gui/src/CMakeLists.txt b/retroshare-gui/src/CMakeLists.txt index b936552ed..dc70d7c09 100644 --- a/retroshare-gui/src/CMakeLists.txt +++ b/retroshare-gui/src/CMakeLists.txt @@ -512,7 +512,7 @@ list( src/util/misc.h src/util/HandleRichText.h src/util/ObjectPainter.h - src/util/QtVersion.h + src/util/RsQtVersion.h src/util/RsFile.h src/util/qtthreadsutils.h src/util/ClickableLabel.h diff --git a/retroshare-gui/src/gui/AboutWidget.cpp b/retroshare-gui/src/gui/AboutWidget.cpp index 1c4ae6827..5ed017d24 100644 --- a/retroshare-gui/src/gui/AboutWidget.cpp +++ b/retroshare-gui/src/gui/AboutWidget.cpp @@ -33,6 +33,7 @@ #include #include #include "settings/rsharesettings.h" +#include "util/RsQtVersion.h" #include #include @@ -42,6 +43,9 @@ #include #include #include +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) +#include +#endif AboutWidget::AboutWidget(QWidget* parent) : QWidget(parent) @@ -49,7 +53,7 @@ AboutWidget::AboutWidget(QWidget* parent) setupUi(this); QHBoxLayout* l = new QHBoxLayout(); - l->setMargin(0); + l->setContentsMargins(0, 0, 0, 0); l->addStretch(1); l->addStretch(1); specialFrame->setContentsMargins(0, 0, 0, 0); @@ -211,7 +215,7 @@ void AWidget::initImages() if(height() == 0) return ; image1 = QImage(width(),height(),QImage::Format_ARGB32); - image1.fill(palette().color(QPalette::Background)); + image1.fill(palette().color(QPalette::Window)); //QImage image(":/images/logo/logo_info.png"); QPixmap image(":/images/logo/logo_splash.png"); @@ -267,7 +271,7 @@ void AWidget::initGoL() void AWidget::drawBitField() { - image2.fill(palette().color(QPalette::Background)); + image2.fill(palette().color(QPalette::Window)); QPainter p(&image2) ; p.setPen(QColor(200,200,200)); @@ -306,7 +310,7 @@ void AWidget::drawBitField() AWidget::AWidget() : page(0), density(5) , mImagesReady(false), mState(0), mTimerId(0) - , mStep(1.0f), mMaxStep(QFontMetricsF(font()).width(' ')) + , mStep(1.0f), mMaxStep(QFontMetrics_horizontalAdvance(QFontMetricsF(font()), ' ')) { setMouseTracking(true); //startTimer(15); @@ -774,7 +778,7 @@ void TBoard::showNextPiece() { QPixmap pixmap(dx * squareWidth(), dy * squareHeight()); QPainter painter(&pixmap); - painter.fillRect(pixmap.rect(), nextPieceLabel->palette().background()); + painter.fillRect(pixmap.rect(), nextPieceLabel->palette().window()); for (int i = 0; i < 4; ++i) { int x = nextPiece.x(i) - nextPiece.minX(); @@ -809,18 +813,23 @@ void TBoard::drawSquare(QPainter &painter, int x, int y, TPiece::Shape shape) { QColor color = colorTable[int(shape)]; painter.fillRect(x + 1, y + 1, squareWidth() - 2, squareHeight() - 2, color); - painter.setPen(color.light()); + painter.setPen(color.lighter()); painter.drawLine(x, y + squareHeight() - 1, x, y); painter.drawLine(x, y, x + squareWidth() - 1, y); - painter.setPen(color.dark()); + painter.setPen(color.darker()); painter.drawLine(x + 1, y + squareHeight() - 1, x + squareWidth() - 1, y + squareHeight() - 1); painter.drawLine(x + squareWidth() - 1, y + squareHeight() - 1, x + squareWidth() - 1, y + 1); } void TPiece::setRandomShape() { - setShape(TPiece::Shape(qrand() % 7 + 1)); +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) + int rand = QRandomGenerator::global()->generate(); +#else + int rand = qrand(); +#endif + setShape(TPiece::Shape(rand % 7 + 1)); } @@ -905,7 +914,7 @@ TPiece TPiece::rotatedRight() const { NextPieceLabel::NextPieceLabel( QWidget* parent /* = 0*/ ) : QLabel(parent) { QPalette p = palette(); - p.setColor(QPalette::Background, Qt::white); + p.setColor(QPalette::Window, Qt::white); setPalette(p); setFrameShape(QFrame::Box); setAlignment(Qt::AlignCenter); diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.cpp b/retroshare-gui/src/gui/ChatLobbyWidget.cpp index 60ed255a8..529d953fa 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.cpp +++ b/retroshare-gui/src/gui/ChatLobbyWidget.cpp @@ -21,7 +21,6 @@ #include "ChatLobbyWidget.h" -#include "notifyqt.h" #include "RetroShareLink.h" #include "chat/ChatLobbyDialog.h" #include "chat/ChatLobbyUserNotify.h" @@ -35,11 +34,11 @@ #include "settings/rsharesettings.h" #include "util/HandleRichText.h" #include "util/misc.h" -#include "util/QtVersion.h" +#include "util/qtthreadsutils.h" +#include "util/RsQtVersion.h" #include "retroshare/rsmsgs.h" #include "retroshare/rspeers.h" -#include "retroshare/rsnotify.h" #include "retroshare/rsidentity.h" #include @@ -105,9 +104,39 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WindowFlags flags) myInviteYesButton = NULL; myInviteIdChooser = NULL; - QObject::connect( NotifyQt::getInstance(), SIGNAL(lobbyListChanged()), SLOT(lobbyChanged())); - QObject::connect( NotifyQt::getInstance(), SIGNAL(chatLobbyEvent(qulonglong,int,RsGxsId,QString)), this, SLOT(displayChatLobbyEvent(qulonglong,int,RsGxsId,QString))); - QObject::connect( NotifyQt::getInstance(), SIGNAL(chatLobbyInviteReceived()), this, SLOT(readChatLobbyInvites())); + mEventHandlerId = 0; + + rsEvents->registerEventsHandler( [this](std::shared_ptr event) + { + RsQThreadUtils::postToObject([=](){ + auto ev = dynamic_cast(event.get()); + + if(!ev) return; + + switch(ev->mEventCode) + { + case RsChatLobbyEventCode::CHAT_LOBBY_INVITE_RECEIVED: + readChatLobbyInvites(); + break; + + case RsChatLobbyEventCode::CHAT_LOBBY_LIST_CHANGED: + lobbyChanged(); + break; + + case RsChatLobbyEventCode::CHAT_LOBBY_EVENT_PEER_LEFT: + case RsChatLobbyEventCode::CHAT_LOBBY_EVENT_PEER_STATUS: + case RsChatLobbyEventCode::CHAT_LOBBY_EVENT_PEER_JOINED: + case RsChatLobbyEventCode::CHAT_LOBBY_EVENT_PEER_CHANGE_NICKNAME: + case RsChatLobbyEventCode::CHAT_LOBBY_EVENT_KEEP_ALIVE: + + handleChatLobbyEvent(ev->mLobbyId,ev->mEventCode,ev->mGxsId,QString::fromUtf8(ev->mStr.c_str())); + break; + + default: + break; + } + }, this ); + }, mEventHandlerId, RsEventType::CHAT_SERVICE ); QObject::connect( ui.lobbyTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(lobbyTreeWidgetCustomPopupMenu(QPoint))); QObject::connect( ui.lobbyTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(itemDoubleClicked(QTreeWidgetItem*,int))); @@ -236,6 +265,7 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WindowFlags flags) ChatLobbyWidget::~ChatLobbyWidget() { + rsEvents->unregisterEventsHandler(mEventHandlerId); // save settings processSettings(false); @@ -650,7 +680,7 @@ void ChatLobbyWidget::updateDisplay() if (autoSubscribe && subscribed && _lobby_infos.find(lobby.lobby_id) == _lobby_infos.end()) { - ChatDialog *cd = ChatDialog::getChat(ChatId(lobby.lobby_id), RS_CHAT_OPEN); + ChatDialog *cd = ChatDialog::getChat(ChatId(lobby.lobby_id), RsChatFlags::RS_CHAT_OPEN); addChatPage(dynamic_cast(cd)); } @@ -753,7 +783,7 @@ void ChatLobbyWidget::showLobby(QTreeWidgetItem *item) showBlankPage(id) ; else { - _lobby_infos[id].dialog->showDialog(RS_CHAT_FOCUS); + _lobby_infos[id].dialog->showDialog(RsChatFlags::RS_CHAT_FOCUS); if (_lobby_infos[id].dialog->isWindowed()) showBlankPage(id, true); } @@ -816,7 +846,7 @@ bool ChatLobbyWidget::showLobbyAnchor(ChatLobbyId id, QString anchor) if(_lobby_infos.find(id) == _lobby_infos.end()) { showBlankPage(id) ; } else { - _lobby_infos[id].dialog->showDialog(RS_CHAT_FOCUS); + _lobby_infos[id].dialog->showDialog(RsChatFlags::RS_CHAT_FOCUS); if (_lobby_infos[id].dialog->isWindowed()) showBlankPage(id, true); @@ -1158,10 +1188,10 @@ void ChatLobbyWidget::itemDoubleClicked(QTreeWidgetItem *item, int /*column*/) subscribeChatLobbyAtItem(item); } -void ChatLobbyWidget::displayChatLobbyEvent(qulonglong lobby_id, int event_type, const RsGxsId &gxs_id, const QString& str) +void ChatLobbyWidget::handleChatLobbyEvent(uint64_t lobby_id, RsChatLobbyEventCode event_type, const RsGxsId &gxs_id, const QString& str) { if (ChatLobbyDialog *cld = dynamic_cast(ChatDialog::getExistingChat(ChatId(lobby_id)))) { - cld->displayLobbyEvent(event_type, gxs_id, str); + cld->handleLobbyEvent(event_type, gxs_id, str); } } diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.h b/retroshare-gui/src/gui/ChatLobbyWidget.h index 424780dac..8b355515a 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.h +++ b/retroshare-gui/src/gui/ChatLobbyWidget.h @@ -89,8 +89,8 @@ protected slots: void unsubscribeItem(); void itemDoubleClicked(QTreeWidgetItem *item, int column); void updateCurrentLobby() ; - void displayChatLobbyEvent(qulonglong lobby_id, int event_type, const RsGxsId& gxs_id, const QString& str); - void readChatLobbyInvites(); + void handleChatLobbyEvent(uint64_t lobby_id, RsChatLobbyEventCode event_type, const RsGxsId &gxs_id, const QString& str); + void readChatLobbyInvites(); void showLobby(QTreeWidgetItem *lobby_item) ; void showBlankPage(ChatLobbyId id, bool subscribed = false) ; void unsubscribeChatLobby(ChatLobbyId id) ; @@ -151,5 +151,7 @@ private: /* UI - from Designer */ Ui::ChatLobbyWidget ui; + + RsEventsHandlerId_t mEventHandlerId; }; diff --git a/retroshare-gui/src/gui/Circles/CreateCircleDialog.cpp b/retroshare-gui/src/gui/Circles/CreateCircleDialog.cpp index 92003e0a6..af8d128b7 100644 --- a/retroshare-gui/src/gui/Circles/CreateCircleDialog.cpp +++ b/retroshare-gui/src/gui/Circles/CreateCircleDialog.cpp @@ -38,6 +38,7 @@ #include "gui/gxs/GxsIdDetails.h" #include "gui/Identity/IdDialog.h" #include "gui/Identity/IdEditDialog.h" +#include "util/RsQtVersion.h" //#define DEBUG_CREATE_CIRCLE_DIALOG 1 @@ -74,7 +75,7 @@ CreateCircleDialog::CreateCircleDialog() ui.IdFilter->addFilter(QIcon(), headerText, RSCIRCLEID_COL_KEYID, QString("%1 %2").arg(tr("Search"), headerText)); /* Set initial column width */ - int fontWidth = QFontMetricsF(ui.treeWidget_IdList->font()).width("W"); + int fontWidth = QFontMetrics_horizontalAdvance(QFontMetricsF(ui.treeWidget_IdList->font()), "W"); ui.treeWidget_IdList->setColumnWidth(RSCIRCLEID_COL_NICKNAME, 17 * fontWidth); ui.treeWidget_membership->setColumnWidth(RSCIRCLEID_COL_NICKNAME, 17 * fontWidth); diff --git a/retroshare-gui/src/gui/FileTransfer/BannedFilesDialog.cpp b/retroshare-gui/src/gui/FileTransfer/BannedFilesDialog.cpp index baa75c667..38591ed0d 100644 --- a/retroshare-gui/src/gui/FileTransfer/BannedFilesDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/BannedFilesDialog.cpp @@ -24,6 +24,7 @@ #include "retroshare/rsfiles.h" #include "BannedFilesDialog.h" +#include "util/DateTime.h" #define COLUMN_FILE_NAME 0 #define COLUMN_FILE_HASH 1 @@ -80,7 +81,7 @@ void BannedFilesDialog::fillFilesList() ui.bannedFiles_TW->setItem(row, COLUMN_FILE_NAME, new QTableWidgetItem(QIcon(),QString::fromUtf8(it->second.mFilename.c_str()),0)); ui.bannedFiles_TW->setItem(row, COLUMN_FILE_HASH, new QTableWidgetItem(QIcon(),QString::fromStdString(it->first.toStdString()),0)); ui.bannedFiles_TW->setItem(row, COLUMN_FILE_SIZE, new QTableWidgetItem(QIcon(),QString::number(it->second.mSize),0)); - ui.bannedFiles_TW->setItem(row, COLUMN_FILE_TIME, new QTableWidgetItem(QIcon(),QDateTime::fromTime_t(it->second.mBanTimeStamp).toString(),0)); + ui.bannedFiles_TW->setItem(row, COLUMN_FILE_TIME, new QTableWidgetItem(QIcon(),DateTime::DateTimeFromTime_t(it->second.mBanTimeStamp).toString(),0)); ui.bannedFiles_TW->item(row, COLUMN_FILE_HASH)->setData(Qt::UserRole, QString::fromStdString(it->first.toStdString())); diff --git a/retroshare-gui/src/gui/FileTransfer/DLListDelegate.cpp b/retroshare-gui/src/gui/FileTransfer/DLListDelegate.cpp index 319c284d5..726ec205b 100755 --- a/retroshare-gui/src/gui/FileTransfer/DLListDelegate.cpp +++ b/retroshare-gui/src/gui/FileTransfer/DLListDelegate.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include @@ -29,6 +29,8 @@ #include #include "DLListDelegate.h" +#include "util/DateTime.h" +#include "util/RsQtVersion.h" Q_DECLARE_METATYPE(FileProgressInfo) @@ -42,7 +44,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti { QString byteUnits[4] = {tr("B"), tr("KB"), tr("MB"), tr("GB")}; QStyleOptionViewItem opt = option; - QStyleOptionProgressBarV2 newopt; + QStyleOptionProgressBar newopt; QRect pixmapRect; QPixmap pixmap; qlonglong fileSize; @@ -59,7 +61,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti painter->setClipRect(opt.rect); //set text color - QVariant value = index.data(Qt::TextColorRole); + QVariant value = index.data(Qt::ForegroundRole); if(value.isValid() && qvariant_cast(value).isValid()) { opt.palette.setColor(QPalette::Text, qvariant_cast(value)); } @@ -94,7 +96,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti for(int i = 0; i < 4; ++i) { if (fileSize < 1024) { fileSize = index.data().toLongLong(); - temp.sprintf("%.2f ", fileSize / multi); + temp = QString::asprintf("%.2f ", fileSize / multi); temp += byteUnits[i]; break; } @@ -113,7 +115,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti for(int i = 0; i < 4; ++i) { if (remaining < 1024) { remaining = index.data().toLongLong(); - temp.sprintf("%.2f ", remaining / multi); + temp = QString::asprintf("%.2f ", remaining / multi); temp += byteUnits[i]; break; } @@ -132,7 +134,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti for(int i = 0; i < 4; ++i) { if (completed < 1024) { completed = index.data().toLongLong(); - temp.sprintf("%.2f ", completed / multi); + temp = QString::asprintf("%.2f ", completed / multi); temp += byteUnits[i]; break; } @@ -148,7 +150,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti temp = ""; } else { temp.clear(); - temp.sprintf("%.2f", dlspeed/1024.); + temp = QString::asprintf("%.2f", dlspeed/1024.); temp += " KB/s"; } painter->drawText(option.rect, Qt::AlignRight | Qt::AlignVCenter, temp); @@ -261,7 +263,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti break; qi64Value = index.data().value(); if (qi64Value < std::numeric_limits::max()){ - QDateTime qdtLastDL = QDateTime::fromTime_t(qi64Value); + QDateTime qdtLastDL = DateTime::DateTimeFromTime_t(qi64Value); painter->drawText(option.rect, Qt::AlignCenter, qdtLastDL.toString("yyyy-MM-dd_hh:mm:ss")); } else { painter->drawText(option.rect, Qt::AlignCenter, tr("File Never Seen")); @@ -277,7 +279,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti QSize DLListDelegate::sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const { - float w = QFontMetricsF(option.font).width(index.data(Qt::DisplayRole).toString()); + float w = QFontMetrics_horizontalAdvance(QFontMetricsF(option.font), index.data(Qt::DisplayRole).toString()); int S = QFontMetricsF(option.font).height()*1.5 ; return QSize(w,S); diff --git a/retroshare-gui/src/gui/FileTransfer/FileTransferInfoWidget.cpp b/retroshare-gui/src/gui/FileTransfer/FileTransferInfoWidget.cpp index 6adb61a68..076f87ab2 100644 --- a/retroshare-gui/src/gui/FileTransfer/FileTransferInfoWidget.cpp +++ b/retroshare-gui/src/gui/FileTransfer/FileTransferInfoWidget.cpp @@ -29,6 +29,7 @@ #include "FileTransferInfoWidget.h" #include "gui/RetroShareLink.h" #include "gui/common/FilesDefs.h" +#include "gui/settings/rsharesettings.h" // Variables to decide of display behaviour. All variables are expressed as a factor of font height // @@ -84,7 +85,7 @@ void FileTransferInfoWidget::updateDisplay() setFixedHeight(maxHeight); QPainter painter(&pixmap); - painter.initFrom(this); + painter.begin(this); float S = QFontMetricsF(font()).height(); int chunk_square_size = S*chunk_square_size_factor; @@ -132,7 +133,13 @@ void FileTransferInfoWidget::draw(const FileInfo& nfo,const FileChunksInfo& info int ch_num_size = ch_num_size_factor*S ; int tab_size = tab_size_factor*S ; - painter->setPen(QColor::fromRgb(0,0,0)) ; + if (Settings->getSheetName() == ":Standard_Dark"){ + penColor = Qt::gray ; + } else { + penColor = Qt::black ; + } + + painter->setPen(penColor) ; y += text_height ; painter->drawText(0,y,tr("Chunk map") + ":") ; y += block_sep ; @@ -176,13 +183,13 @@ void FileTransferInfoWidget::draw(const FileInfo& nfo,const FileChunksInfo& info uint32_t sizeY = 1*S ; y += block_sep ; y += text_height ; - painter->setPen(QColor::fromRgb(0,0,0)) ; + painter->setPen(penColor) ; painter->drawText(0,y,tr("Active chunks") + ":") ; y += block_sep ; for(uint i=0;isetPen(QColor::fromRgb(0,0,0)) ; + painter->setPen(penColor) ; painter->drawText(0.5*S,y+text_height*0.9,QString::number(info.active_chunks[i].first)) ; int size_of_this_chunk = ( info.active_chunks[i].first == info.chunks.size()-1 && ((info.file_size % blockSize)>0) )?(info.file_size % blockSize):blockSize ; @@ -212,7 +219,7 @@ void FileTransferInfoWidget::draw(const FileInfo& nfo,const FileChunksInfo& info } - painter->setPen(QColor::fromRgb(0,0,0)) ; + painter->setPen(penColor) ; float percent = (size_of_this_chunk - info.active_chunks[i].second)*100.0/size_of_this_chunk ; painter->drawText(sizeX+5.5*S,y+text_height*0.9,QString::number(percent,'f',2) + " %") ; @@ -227,7 +234,7 @@ void FileTransferInfoWidget::draw(const FileInfo& nfo,const FileChunksInfo& info y += block_sep ; y += text_height ; - painter->setPen(QColor::fromRgb(0,0,0)) ; + painter->setPen(penColor) ; painter->drawText(0,y,(info.compressed_peer_availability_maps.size() == 1 ? tr("Availability map (%1 active source)") : tr("Availability map (%1 active sources)")).arg(info.compressed_peer_availability_maps.size())) ; y += block_sep ; @@ -254,7 +261,8 @@ void FileTransferInfoWidget::draw(const FileInfo& nfo,const FileChunksInfo& info // various info: // - painter->setPen(QColor::fromRgb(0,0,0)) ; + painter->setPen(penColor) ; + y += text_height ; painter->drawText(0,y,tr("File info") + ":") ; y += block_sep ; y += text_height ; painter->drawText(2*S,y,tr("File name") + ":") ; painter->drawText(tab_size,y,QString::fromUtf8(nfo.fname.c_str())) ; diff --git a/retroshare-gui/src/gui/FileTransfer/FileTransferInfoWidget.h b/retroshare-gui/src/gui/FileTransfer/FileTransferInfoWidget.h index fdf45f2ff..e1f9ece8d 100644 --- a/retroshare-gui/src/gui/FileTransfer/FileTransferInfoWidget.h +++ b/retroshare-gui/src/gui/FileTransfer/FileTransferInfoWidget.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -36,7 +37,7 @@ class FileTransferInfoWidget : public RsAutoUpdatePage Q_OBJECT public: - FileTransferInfoWidget(QWidget * parent = 0, Qt::WindowFlags f = 0 ); + FileTransferInfoWidget(QWidget * parent = 0, Qt::WindowFlags f = Qt::WindowFlags() ); void setFileHash(const RsFileHash& hash) { _file_hash = hash ; } @@ -58,6 +59,7 @@ private: QPixmap downloadingPixmap; QPixmap notDownloadPixmap; QPixmap checkingPixmap; + QColor penColor; RsFileHash _file_hash ; }; diff --git a/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp b/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp index c5b7ba04d..aa7125764 100644 --- a/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp @@ -36,7 +36,7 @@ #include "gui/settings/rsharesettings.h" #include "gui/advsearch/advancedsearchdialog.h" #include "gui/common/RSTreeWidgetItem.h" -#include "util/QtVersion.h" +#include "util/RsQtVersion.h" #include "util/qtthreadsutils.h" #include "util/misc.h" @@ -898,7 +898,7 @@ void SearchDialog::searchKeywords(const QString& keywords) if (keywords.length() < 3) return ; - QStringList qWords = keywords.split(" ", QString::SkipEmptyParts); + QStringList qWords = keywords.split(" ", QtSkipEmptyParts); std::list words; QStringListIterator qWordsIter(qWords); while (qWordsIter.hasNext()) @@ -1236,7 +1236,7 @@ void SearchDialog::insertFile(qulonglong searchId, const FileDetail& file, int s int friendSource = 0; int anonymousSource = 0; QString resultCount = it->text(SR_SOURCES_COL); - QStringList modifiedResultCount = resultCount.split("/", QString::SkipEmptyParts); + QStringList modifiedResultCount = resultCount.split("/", QtSkipEmptyParts); if(searchType == FRIEND_SEARCH) { friendSource = modifiedResultCount.at(0).toInt() + 1; diff --git a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp index 8978ccf71..7e1477864 100644 --- a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp @@ -22,7 +22,6 @@ #include "rshare.h" #include "gui/MainWindow.h" -#include "gui/notifyqt.h" #include "gui/RemoteDirModel.h" #include "gui/RetroShareLink.h" #include "gui/ShareManager.h" @@ -33,8 +32,9 @@ #include "gui/gxsforums/GxsForumsDialog.h" #include "gui/settings/AddFileAssociationDialog.h" #include "gui/settings/rsharesettings.h" -#include "util/QtVersion.h" +#include "util/RsQtVersion.h" #include "util/RsAction.h" +#include "util/qtthreadsutils.h" #include "util/misc.h" #include "util/rstime.h" #include "util/rsdir.h" @@ -145,7 +145,7 @@ public: { Q_ASSERT(index.isValid()); - QStyleOptionViewItemV4 opt = option; + QStyleOptionViewItem opt = option; initStyleOption(&opt, index); // disable default icon opt.icon = QIcon(); @@ -166,6 +166,7 @@ public: SharedFilesDialog::~SharedFilesDialog() { + rsEvents->unregisterEventsHandler(mEventHandlerId); delete tree_model; delete flat_model; delete tree_proxyModel; @@ -177,9 +178,36 @@ SharedFilesDialog::SharedFilesDialog(bool remote_mode, QWidget *parent) /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); - NotifyQt *notify = NotifyQt::getInstance(); - connect(notify, SIGNAL(filesPreModChanged(bool)), this, SLOT(preModDirectories(bool))); - connect(notify, SIGNAL(filesPostModChanged(bool)), this, SLOT(postModDirectories(bool))); + //connect(notify, SIGNAL(filesPreModChanged(bool)), this, SLOT(preModDirectories(bool))); + //connect(notify, SIGNAL(filesPostModChanged(bool)), this, SLOT(postModDirectories(bool))); + + mEventHandlerId = 0; + + rsEvents->registerEventsHandler([this](std::shared_ptr event) + { + RsQThreadUtils::postToObject([=](){ + + auto e = dynamic_cast(event.get()); + + switch(e->mEventCode) + { + case RsSharedDirectoriesEventCode::OWN_DIR_LIST_PROCESSING: + preModDirectories(true); + break; + + case RsSharedDirectoriesEventCode::OWN_DIR_LIST_UPDATED: + postModDirectories(true); + break; + + case RsSharedDirectoriesEventCode::FRIEND_DIR_LIST_UPDATED: + preModDirectories(false); + postModDirectories(false); + break; + + default: + break; + };}, this); + }, mEventHandlerId,RsEventType::SHARED_DIRECTORIES); connect(ui.viewType_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(changeCurrentViewModel(int))); connect(ui.dirTreeView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT( spawnCustomPopupMenu( QPoint ) ) ); @@ -199,7 +227,7 @@ SharedFilesDialog::SharedFilesDialog(bool remote_mode, QWidget *parent) tree_proxyModel->setSortRole(RetroshareDirModel::SortRole); tree_proxyModel->sort(SHARED_FILES_DIALOG_COLUMN_NAME); tree_proxyModel->setFilterRole(RetroshareDirModel::FilterRole); - tree_proxyModel->setFilterRegExp(QRegExp(QString(SHARED_FILES_DIALOG_FILTER_STRING))) ; + QSortFilterProxyModel_setFilterRegularExpression(tree_proxyModel, QString(SHARED_FILES_DIALOG_FILTER_STRING)) ; flat_proxyModel = new SFDSortFilterProxyModel(flat_model, this); flat_proxyModel->setSourceModel(flat_model); @@ -207,7 +235,7 @@ SharedFilesDialog::SharedFilesDialog(bool remote_mode, QWidget *parent) flat_proxyModel->setSortRole(RetroshareDirModel::SortRole); flat_proxyModel->sort(SHARED_FILES_DIALOG_COLUMN_NAME); flat_proxyModel->setFilterRole(RetroshareDirModel::FilterRole); - flat_proxyModel->setFilterRegExp(QRegExp(QString(SHARED_FILES_DIALOG_FILTER_STRING))) ; + QSortFilterProxyModel_setFilterRegularExpression(flat_proxyModel, QString(SHARED_FILES_DIALOG_FILTER_STRING)) ; connect(ui.filterClearButton, SIGNAL(clicked()), this, SLOT(clearFilter())); connect(ui.filterStartButton, SIGNAL(clicked()), this, SLOT(startFilter())); @@ -739,7 +767,6 @@ void SharedFilesDialog::collCreate() model->getDirDetailsFromSelect(lst, dirVec); auto RemoteMode = isRemote(); - FileSearchFlags f = RemoteMode?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL ; QString dir_name; @@ -1018,7 +1045,7 @@ void SharedFilesDialog::recursExpandAll(const QModelIndex& index) for(int row=0;rowmodel()->rowCount(index);++row) { - QModelIndex idx(index.child(row,0)) ; + QModelIndex idx(ui.dirTreeView->model()->index(row,0,index)) ; if(ui.dirTreeView->model()->rowCount(idx) > 0) recursExpandAll(idx) ; @@ -1131,7 +1158,10 @@ void SharedFilesDialog::postModDirectories(bool local) #ifdef DEBUG_SHARED_FILES_DIALOG std::cerr << "****** updated directories! Re-enabling sorting ******" << std::endl; #endif + +#if QT_VERSION < QT_VERSION_CHECK (6, 0, 0) QCoreApplication::flush(); +#endif } class ChannelCompare @@ -1619,7 +1649,7 @@ void SharedFilesDialog::FilterItems() return ; //FileSearchFlags flags = isRemote()?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL; - QStringList lst = text.split(" ",QString::SkipEmptyParts) ; + QStringList lst = text.split(" ",QtSkipEmptyParts) ; std::list keywords ; for(auto it(lst.begin());it!=lst.end();++it) diff --git a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h index 7524d5035..375b6c075 100644 --- a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h +++ b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h @@ -21,6 +21,7 @@ #ifndef _SHAREDFILESDIALOG_H #define _SHAREDFILESDIALOG_H +#include #include "ui_SharedFilesDialog.h" #include @@ -145,6 +146,8 @@ protected: QString lastFilterString; QString mLastFilterText ; RsProtectedTimer* mFilterTimer; + + RsEventsHandlerId_t mEventHandlerId ; }; class LocalSharedFilesDialog : public SharedFilesDialog diff --git a/retroshare-gui/src/gui/FileTransfer/TransferUserNotify.cpp b/retroshare-gui/src/gui/FileTransfer/TransferUserNotify.cpp index fa0c33046..dcb093a7b 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransferUserNotify.cpp +++ b/retroshare-gui/src/gui/FileTransfer/TransferUserNotify.cpp @@ -20,7 +20,6 @@ #include "retroshare/rsfiles.h" #include "TransferUserNotify.h" -#include "gui/notifyqt.h" #include "gui/MainWindow.h" TransferUserNotify::TransferUserNotify(QObject *parent) : diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp index 3ee120162..ad7e86637 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp @@ -20,7 +20,6 @@ #include "TransfersDialog.h" -#include "gui/notifyqt.h" #include "gui/SoundManager.h" #include "gui/RetroShareLink.h" #include "gui/common/FilesDefs.h" @@ -37,9 +36,10 @@ #include "gui/FileTransfer/xprogressbar.h" #include "gui/settings/rsharesettings.h" #include "util/misc.h" -#include "util/QtVersion.h" +#include "util/RsQtVersion.h" #include "util/RsFile.h" #include "util/qtthreadsutils.h" +#include "util/DateTime.h" #include "retroshare/rsdisc.h" #include "retroshare/rsfiles.h" @@ -286,7 +286,7 @@ public: { case Qt::SizeHintRole: return sizeHintRole(index.column()) ; case Qt::TextAlignmentRole: - case Qt::TextColorRole: + case Qt::ForegroundRole: case Qt::WhatsThisRole: case Qt::EditRole: case Qt::ToolTipRole: @@ -434,7 +434,7 @@ public: //Get Last Access on File if (file.exists()) - qi64LastDL = file.lastModified().toTime_t(); + qi64LastDL = DateTime::DateTimeToTime_t(file.lastModified()); } return QVariant(qi64LastDL) ; } @@ -1009,7 +1009,6 @@ TransfersDialog::TransfersDialog(QWidget *parent) connect(collViewAct,SIGNAL(triggered()),this,SLOT(collView())); collOpenAct = new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COLLOPEN), tr( "Download from collection file..." ), this ); connect(collOpenAct, SIGNAL(triggered()), this, SLOT(collOpen())); - connect(NotifyQt::getInstance(), SIGNAL(downloadComplete(QString)), this, SLOT(collAutoOpen(QString))); /** Setup the actions for the download header context menu */ showDLSizeAct= new QAction(tr("Size"),this); @@ -1114,14 +1113,8 @@ void TransfersDialog::handleEvent_main_thread(std::shared_ptr eve switch (fe->mFileTransferEventCode) { case RsFileTransferEventCode::DOWNLOAD_COMPLETE: - { - FileInfo nfo ; - if(!rsFiles->FileDetails(fe->mHash, RS_FILE_HINTS_DOWNLOAD, nfo)) - break; + collAutoOpen(fe->mHash); - SoundManager::play(SOUND_DOWNLOAD_COMPLETE); - NotifyQt::getInstance()->addToaster(RS_POPUP_DOWNLOAD, fe->mHash.toStdString(), nfo.fname.c_str(),""); - } [[fallthrough]]; case RsFileTransferEventCode::COMPLETED_FILES_REMOVED: @@ -2577,11 +2570,10 @@ void TransfersDialog::collOpen() QMessageBox::information(nullptr,tr("Error openning collection file"),RsCollection::errorString(code)); } -void TransfersDialog::collAutoOpen(const QString &fileHash) +void TransfersDialog::collAutoOpen(const RsFileHash& hash) { if (Settings->valueFromGroup("Transfer","AutoDLColl").toBool()) { - RsFileHash hash = RsFileHash(fileHash.toStdString()); FileInfo info; if (rsFiles->FileDetails(hash, RS_FILE_HINTS_DOWNLOAD, info)) { @@ -2646,5 +2638,5 @@ void TransfersDialog::filterChanged(const QString& /*text*/) int filterColumn = ui.filterLineEdit->currentFilter(); QString text = ui.filterLineEdit->text(); DLLFilterModel->setFilterKeyColumn(filterColumn); - DLLFilterModel->setFilterRegExp(text); + QSortFilterProxyModel_setFilterRegularExpression(DLLFilterModel, text); } diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h index 19e2df363..8d167643e 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h +++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h @@ -145,7 +145,7 @@ private slots: void collModif(); void collView(); void collOpen(); - void collAutoOpen(const QString& fileHash); + void collAutoOpen(const RsFileHash &hash); void setShowDLSizeColumn(bool show); void setShowDLCompleteColumn(bool show); diff --git a/retroshare-gui/src/gui/FileTransfer/ULListDelegate.cpp b/retroshare-gui/src/gui/FileTransfer/ULListDelegate.cpp index 8bddc5017..a22591574 100755 --- a/retroshare-gui/src/gui/FileTransfer/ULListDelegate.cpp +++ b/retroshare-gui/src/gui/FileTransfer/ULListDelegate.cpp @@ -22,6 +22,7 @@ #include "ULListDelegate.h" #include "xprogressbar.h" +#include "util/RsQtVersion.h" Q_DECLARE_METATYPE(FileProgressInfo) @@ -39,7 +40,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti { QString byteUnits[4] = {tr("B"), tr("KB"), tr("MB"), tr("GB")}; QStyleOptionViewItem opt = option; - QStyleOptionProgressBarV2 newopt; + QStyleOptionProgressBar newopt; QRect pixmapRect; QPixmap pixmap; qlonglong fileSize; @@ -52,7 +53,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti painter->setClipRect(opt.rect); //set text color - QVariant value = index.data(Qt::TextColorRole); + QVariant value = index.data(Qt::ForegroundRole); if(value.isValid() && qvariant_cast(value).isValid()) { opt.palette.setColor(QPalette::Text, qvariant_cast(value)); } @@ -93,7 +94,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti for(int i = 0; i < 4; ++i) { if (fileSize < 1024) { fileSize = index.data().toLongLong(); - temp.sprintf("%.2f ", fileSize / multi); + temp = QString::asprintf("%.2f ", fileSize / multi); temp += byteUnits[i]; break; } @@ -112,7 +113,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti for(int i = 0; i < 4; ++i) { if (transferred < 1024) { transferred = index.data().toLongLong(); - temp.sprintf("%.2f ", transferred / multi); + temp = QString::asprintf("%.2f ", transferred / multi); temp += byteUnits[i]; break; } @@ -128,7 +129,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti temp = ""; } else { temp.clear(); - temp.sprintf("%.2f", ulspeed/1024.); + temp = QString::asprintf("%.2f", ulspeed/1024.); temp += " KB/s"; } painter->drawText(option.rect, Qt::AlignRight | Qt::AlignVCenter, temp); @@ -179,7 +180,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti QSize ULListDelegate::sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const { - float w = QFontMetricsF(option.font).width(index.data(Qt::DisplayRole).toString()); + float w = QFontMetrics_horizontalAdvance(QFontMetricsF(option.font), index.data(Qt::DisplayRole).toString()); int S = QFontMetricsF(option.font).height()*1.5 ; return QSize(w,S); diff --git a/retroshare-gui/src/gui/FriendServerControl.cpp b/retroshare-gui/src/gui/FriendServerControl.cpp index 7b031e7e2..eb5988589 100644 --- a/retroshare-gui/src/gui/FriendServerControl.cpp +++ b/retroshare-gui/src/gui/FriendServerControl.cpp @@ -118,7 +118,7 @@ FriendServerControl::FriendServerControl(QWidget *parent) rsEvents->registerEventsHandler( [this](std::shared_ptr event) { RsQThreadUtils::postToObject([=](){ handleEvent_main_thread(event); }, this ); - }, mEventHandlerId_peer, RsEventType::PEER_CONNECTION ); + }, mEventHandlerId_peer, RsEventType::FRIEND_LIST ); } void FriendServerControl::onAutoAddFriends(bool b) @@ -145,14 +145,14 @@ void FriendServerControl::handleEvent_main_thread(std::shared_ptr } { - const RsConnectionEvent *pe = dynamic_cast(event.get()); + const RsFriendListEvent *pe = dynamic_cast(event.get()); if(pe) - switch(pe->mConnectionInfoCode) + switch(pe->mEventCode) { - case RsConnectionEventCode::PEER_ADDED: - case RsConnectionEventCode::PEER_REMOVED: - case RsConnectionEventCode::PEER_CONNECTED: updateContactsStatus(); + case RsFriendListEventCode::NODE_ADDED: + case RsFriendListEventCode::NODE_REMOVED: + case RsFriendListEventCode::NODE_CONNECTED: updateContactsStatus(); break; default: ; @@ -169,7 +169,7 @@ FriendServerControl::~FriendServerControl() rsEvents->unregisterEventsHandler(mEventHandlerId_peer); } -void FriendServerControl::launchStatusContextMenu(QPoint p) +void FriendServerControl::launchStatusContextMenu(QPoint /* p */) { RsPeerId peer_id = getCurrentPeer(); diff --git a/retroshare-gui/src/gui/FriendsDialog.cpp b/retroshare-gui/src/gui/FriendsDialog.cpp index 532a87f4a..3bc7965e4 100644 --- a/retroshare-gui/src/gui/FriendsDialog.cpp +++ b/retroshare-gui/src/gui/FriendsDialog.cpp @@ -34,12 +34,12 @@ #include "groups/CreateGroup.h" #include "MainWindow.h" #include "NewsFeed.h" -#include "notifyqt.h" #include "profile/ProfileWidget.h" #include "profile/StatusMessage.h" #include "RetroShareLink.h" #include "settings/rsharesettings.h" #include "util/misc.h" +#include "util/qtthreadsutils.h" #include "util/DateTime.h" #include "FriendsDialog.h" #include "NetworkView.h" @@ -77,12 +77,49 @@ FriendsDialog::FriendsDialog(QWidget *parent) : MainPage(parent) ui.chatWidget->setWelcomeMessage(msg); ui.chatWidget->init(ChatId::makeBroadcastId(), tr("Broadcast")); - connect(NotifyQt::getInstance(), SIGNAL(chatMessageReceived(ChatMessage)), this, SLOT(chatMessageReceived(ChatMessage))); - connect(NotifyQt::getInstance(), SIGNAL(chatStatusChanged(ChatId,QString)), this, SLOT(chatStatusReceived(ChatId,QString))); + mEventHandlerId_chat = 0; + + rsEvents->registerEventsHandler( [this](std::shared_ptr e) + { + RsQThreadUtils::postToObject([=]() + { + auto fe = dynamic_cast(e.get()); if(!fe) return; + + switch(fe->mEventCode) + { + case RsChatServiceEventCode::CHAT_MESSAGE_RECEIVED: chatMessageReceived(fe->mMsg); break; + case RsChatServiceEventCode::CHAT_STATUS_CHANGED: chatStatusReceived(fe->mCid,QString::fromUtf8(fe->mStr.c_str())); break; + default: + break; + } + + } + , this ); + }, mEventHandlerId_chat, RsEventType::CHAT_SERVICE ); + #else // def RS_DIRECT_CHAT - ui.tabWidget->removeTab(ui.tabWidget->indexOf(ui.groupChatTab)); + ui.tabWidget->removeTab(ui.tabWidget->indexOf(ui.groupChatTab)); #endif // def RS_DIRECT_CHAT + rsEvents->registerEventsHandler( [this](std::shared_ptr e) + { + RsQThreadUtils::postToObject([=]() + { + auto fe = dynamic_cast(e.get()); if(!fe) return; + + switch(fe->mEventCode) + { + case RsFriendListEventCode::OWN_STATUS_CHANGED: loadmypersonalstatus(); + break; + default: // OWN_AVATAR_CHANGED is handled in AvatarWidget + break; + } + + } + , this ); + }, mEventHandlerId_friends, RsEventType::FRIEND_LIST ); + + mEventHandlerId_friends = 0; connect( ui.mypersonalstatusLabel, SIGNAL(clicked()), SLOT(statusmessage())); connect( ui.actionSet_your_Avatar, SIGNAL(triggered()), this, SLOT(getAvatar())); @@ -153,6 +190,8 @@ FriendsDialog::~FriendsDialog () if (this == instance) { instance = NULL; } + rsEvents->unregisterEventsHandler(mEventHandlerId_friends); + rsEvents->unregisterEventsHandler(mEventHandlerId_chat); } void FriendsDialog::activatePage(FriendsDialog::Page page) @@ -200,10 +239,20 @@ void FriendsDialog::processSettings(bool bLoad) void FriendsDialog::chatMessageReceived(const ChatMessage &msg) { - if(msg.chat_id.isBroadcast()) + if(!msg.chat_id.isBroadcast()) + return; + + QDateTime sendTime = QDateTime::fromTime_t(msg.sendTime); + QDateTime recvTime = QDateTime::fromTime_t(msg.recvTime); + QString message = QString::fromUtf8(msg.msg.c_str()); + QString name = QString::fromUtf8(rsPeers->getPeerName(msg.broadcast_peer_id).c_str()); + + ui.chatWidget->addChatMsg(msg.incoming, name, sendTime, recvTime, message, ChatWidget::MSGTYPE_NORMAL); + + if(ui.chatWidget->isActive()) { - QDateTime sendTime = QDateTime::fromTime_t(msg.sendTime); - QDateTime recvTime = QDateTime::fromTime_t(msg.recvTime); + QDateTime sendTime = DateTime::DateTimeFromTime_t(msg.sendTime); + QDateTime recvTime = DateTime::DateTimeFromTime_t(msg.recvTime); QString message = QString::fromUtf8(msg.msg.c_str()); QString name = QString::fromUtf8(rsPeers->getPeerName(msg.broadcast_peer_id).c_str()); @@ -220,11 +269,11 @@ void FriendsDialog::chatMessageReceived(const ChatMessage &msg) void FriendsDialog::chatStatusReceived(const ChatId &chat_id, const QString &status_string) { - if(chat_id.isBroadcast()) - { - QString name = QString::fromUtf8(rsPeers->getPeerName(chat_id.broadcast_status_peer_id).c_str()); - ui.chatWidget->updateStatusString(name + " %1", status_string); - } + if(!chat_id.isBroadcast()) + return; + + QString name = QString::fromUtf8(rsPeers->getPeerName(chat_id.broadcast_status_peer_id).c_str()); + ui.chatWidget->updateStatusString(name + " %1", status_string); } void FriendsDialog::addFriend() diff --git a/retroshare-gui/src/gui/FriendsDialog.h b/retroshare-gui/src/gui/FriendsDialog.h index 7e86669b8..f6ec0e0a8 100644 --- a/retroshare-gui/src/gui/FriendsDialog.h +++ b/retroshare-gui/src/gui/FriendsDialog.h @@ -70,9 +70,6 @@ public: IdDialog *idDialog; private slots: - void chatMessageReceived(const ChatMessage& msg); - void chatStatusReceived(const ChatId& chat_id, const QString& status_string); - void addFriend(); void statusmessage(); @@ -89,10 +86,17 @@ signals: void notifyGroupChat(const QString&,const QString&) ; private: + void chatMessageReceived(const ChatMessage& msg); + void chatStatusReceived(const ChatId& chat_id, const QString& status_string); + void processSettings(bool bLoad); /** Qt Designer generated object */ Ui::FriendsDialog ui; + RsEventsHandlerId_t mEventHandlerId_friends ; +#ifdef RS_DIRECT_CHAT + RsEventsHandlerId_t mEventHandlerId_chat ; +#endif }; #endif diff --git a/retroshare-gui/src/gui/GenCertDialog.cpp b/retroshare-gui/src/gui/GenCertDialog.cpp index cb1dfc034..be2b86351 100644 --- a/retroshare-gui/src/gui/GenCertDialog.cpp +++ b/retroshare-gui/src/gui/GenCertDialog.cpp @@ -39,7 +39,6 @@ #include "retroshare/rstor.h" #include "retroshare/rsidentity.h" #include "retroshare/rsinit.h" -#include "retroshare/rsnotify.h" #include "rsserver/rsaccounts.h" #include "util/rsrandom.h" @@ -633,7 +632,9 @@ void GenCertDialog::genPerson() std::cout << "Waiting ed->processEvents()" << std::endl; #endif time_t waitEnd = time(NULL) + 10;//Wait no more than 10 sec to processEvents +#if QT_VERSION < QT_VERSION_CHECK (6, 0, 0) if (ed->hasPendingEvents()) +#endif while(ed->processEvents(QEventLoop::AllEvents) && (time(NULL) < waitEnd)); std::string email_str = "" ; @@ -661,7 +662,7 @@ void GenCertDialog::genPerson() std::cout << "RsAccounts::GenerateSSLCertificate" << std::endl; // now cache the PGP password so that it's not asked again for immediately signing the key - rsNotify->cachePgpPassphrase(ui.password_input->text().toUtf8().constData()) ; + rsLoginHelper->cachePgpPassphrase(ui.password_input->text().toUtf8().constData()) ; bool okGen = RsAccounts::createNewAccount(PGPId, "", genLoc, "", isHiddenLoc, isAutoTor, sslPasswd, sslId, err); @@ -674,7 +675,7 @@ void GenCertDialog::genPerson() // Normally we should clear the cached passphrase as soon as possible. However,some other GUI components may still need it at start. // (csoler) This is really bad: we have to guess that 30 secs will be enough. I have no better way to do this. - QTimer::singleShot(30000, []() { rsNotify->clearPgpPassphrase(); } ); + QTimer::singleShot(30000, []() { RsLoginHelper::clearPgpPassphrase(); } ); accept(); } @@ -682,7 +683,7 @@ void GenCertDialog::genPerson() else { // Now clear the cached passphrase - rsNotify->clearPgpPassphrase(); + RsLoginHelper::clearPgpPassphrase(); /* Message Dialog */ QMessageBox::warning(this, diff --git a/retroshare-gui/src/gui/GetStartedDialog.cpp b/retroshare-gui/src/gui/GetStartedDialog.cpp index 399cc36d7..954189997 100644 --- a/retroshare-gui/src/gui/GetStartedDialog.cpp +++ b/retroshare-gui/src/gui/GetStartedDialog.cpp @@ -332,95 +332,8 @@ void GetStartedDialog::emailSupport() QString text = QString("Hello") + "\n"; text += "\n"; - QString sysVersion; + QString sysVersion = QSysInfo::prettyProductName(); -#ifdef __APPLE__ - - #ifdef Q_OS_MAC - switch(QSysInfo::MacintoshVersion) - { - case QSysInfo::MV_9: - sysVersion = "Mac OS 9"; - break; - case QSysInfo::MV_10_0: - sysVersion = "Mac OSX 10.0"; - break; - case QSysInfo::MV_10_1: - sysVersion = "Mac OSX 10.1"; - break; - case QSysInfo::MV_10_2: - sysVersion = "Mac OSX 10.2"; - break; - case QSysInfo::MV_10_3: - sysVersion = "Mac OSX 10.3"; - break; - case QSysInfo::MV_10_4: - sysVersion = "Mac OSX 10.4"; - break; - case QSysInfo::MV_10_5: - sysVersion = "Mac OSX 10.5"; - break; - case QSysInfo::MV_10_6: - sysVersion = "Mac OSX 10.6"; - break; -// case QSysInfo::MV_10_7: -// sysVersion = "Mac OSX 10.7"; -// break; - default: - sysVersion = "Mac Unknown"; - break; - } - #else - sysVersion = "OSX Unknown"; - #endif -#else - #if defined(_WIN32) || defined(__MINGW32__) - // Windows - #ifdef Q_OS_WIN - switch(QSysInfo::windowsVersion()) - { - case QSysInfo::WV_32s: - sysVersion = "Windows 2.1"; - break; - case QSysInfo::WV_95: - sysVersion = "Windows 95"; - break; - case QSysInfo::WV_98: - sysVersion = "Windows 98"; - break; - case QSysInfo::WV_Me: - sysVersion = "Windows Me"; - break; - case QSysInfo::WV_NT: - sysVersion = "Windows NT"; - break; - case QSysInfo::WV_2000: - sysVersion = "Windows 2000"; - break; - case QSysInfo::WV_XP: - sysVersion = "Windows XP"; - break; - case QSysInfo::WV_2003: - sysVersion = "Windows 2003"; - break; - case QSysInfo::WV_VISTA: - sysVersion = "Windows Vista"; - break; - case QSysInfo::WV_WINDOWS7: - sysVersion = "Windows 7"; - break; - default: - sysVersion = "Windows"; - break; - } - #else - sysVersion = "Windows Unknown"; - #endif - #else - // Linux - sysVersion = "Linux"; - #endif -#endif text += QString("My RetroShare Configuration is: (%1, %2, %3)").arg(RsApplication::retroshareVersion(true) , sysVersion ).arg(static_cast::type>(userLevel)) + "\n"; diff --git a/retroshare-gui/src/gui/HomePage.cpp b/retroshare-gui/src/gui/HomePage.cpp index 914fde3e9..115281538 100644 --- a/retroshare-gui/src/gui/HomePage.cpp +++ b/retroshare-gui/src/gui/HomePage.cpp @@ -26,7 +26,6 @@ #include "util/qtthreadsutils.h" #include "util/misc.h" -#include "gui/notifyqt.h" #include "gui/common/FilesDefs.h" #include "gui/msgs/MessageComposer.h" #include "gui/connect/ConnectFriendWizard.h" @@ -65,6 +64,9 @@ HomePage::HomePage(QWidget *parent) : QAction *RecAction = new QAction(QIcon(),tr("Recommend friends to each others"), this); connect(RecAction, SIGNAL(triggered()), this, SLOT(recommendFriends())); + QAction *SaveAction = new QAction(QIcon(),tr("Save to File"), this); + connect(SaveAction, SIGNAL(triggered()), this, SLOT(saveCert())); + QAction *SendAction = new QAction(QIcon(),tr("Send via Email"), this); connect(SendAction, SIGNAL(triggered()), this, SLOT(runEmailClient())); @@ -75,6 +77,7 @@ HomePage::HomePage(QWidget *parent) : menu->addAction(CopyIdAction); menu->addSeparator(); + menu->addAction(SaveAction); menu->addAction(SendAction); menu->addAction(WebMailAction); menu->addAction(RecAction); @@ -348,7 +351,11 @@ void HomePage::saveCert() //Todo: move save to file to p3Peers::SaveCertificateToFile QTextStream ts(&file); +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) + ts.setEncoding(QStringConverter::Utf8); +#else ts.setCodec(QTextCodec::codecForName("UTF-8")); +#endif ts << ui->retroshareid->text(); } diff --git a/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp b/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp index 9056b5f31..c3e3129cb 100644 --- a/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDetailsDialog.cpp @@ -28,6 +28,7 @@ #include "gui/common/FilesDefs.h" #include "gui/msgs/MessageComposer.h" #include "gui/RetroShareLink.h" +#include "util/DateTime.h" #include @@ -148,7 +149,7 @@ void IdDetailsDialog::loadIdentity(RsGxsIdGroup data) ui->autoBanIdentities_CB->setVisible(!data.mPgpId.isNull()) ; ui->banoption_label->setVisible(!data.mPgpId.isNull()) ; - ui->lineEdit_Created->setText(QDateTime::fromMSecsSinceEpoch(qint64(1000)*data.mMeta.mPublishTs).toString(Qt::SystemLocaleShortDate)); + ui->lineEdit_Created->setText(QLocale::system().toString(DateTime::DateTimeFromTime_t(data.mMeta.mPublishTs), QLocale::ShortFormat)); time_t now = time(NULL) ; ui->lineEdit_LastUsed->setText(getHumanReadableDuration(now - data.mLastUsageTS)) ; diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index a2d588d3e..f363f898b 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -47,9 +47,10 @@ #include "util/qtthreadsutils.h" #include "retroshare-gui/RsAutoUpdatePage.h" #include "util/misc.h" -#include "util/QtVersion.h" +#include "util/RsQtVersion.h" #include "util/rstime.h" #include "util/rsdebug.h" +#include "util/DateTime.h" #include "retroshare/rsgxsflags.h" #include "retroshare/rsmsgs.h" @@ -230,7 +231,7 @@ IdDialog::IdDialog(QWidget *parent) mProxyModel->setSortRole(RsIdentityListModel::SortRole); mProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); mProxyModel->setFilterRole(RsIdentityListModel::FilterRole); - mProxyModel->setFilterRegExp(QRegExp(RsIdentityListModel::FilterString)); + QSortFilterProxyModel_setFilterRegularExpression(mProxyModel, RsIdentityListModel::FilterString); ui->idTreeWidget->setModel(mProxyModel); //ui->idTreeWidget->setSelectionModel(new QItemSelectionModel(mProxyModel));// useless in Qt5. @@ -393,7 +394,7 @@ IdDialog::IdDialog(QWidget *parent) /* Set initial section sizes */ QHeaderView * circlesheader = ui->treeWidget_membership->header () ; - circlesheader->resizeSection (CIRCLEGROUP_CIRCLE_COL_GROUPNAME, fm.width("Circle name")*1.5) ; + circlesheader->resizeSection (CIRCLEGROUP_CIRCLE_COL_GROUPNAME, QFontMetrics_horizontalAdvance(fm, "Circle name")*1.5) ; ui->treeWidget_membership->setColumnWidth(CIRCLEGROUP_CIRCLE_COL_GROUPNAME, 270); /* Setup tree */ @@ -1653,7 +1654,7 @@ void IdDialog::loadIdentity(RsGxsIdGroup data) /* get GPG Details from rsPeers */ RsPgpId ownPgpId = rsPeers->getGPGOwnId(); - ui->lineEdit_PublishTS->setText(QDateTime::fromMSecsSinceEpoch(qint64(1000)*data.mMeta.mPublishTs).toString(Qt::SystemLocaleShortDate)); + ui->lineEdit_PublishTS->setText(QLocale::system().toString(DateTime::DateTimeFromTime_t(data.mMeta.mPublishTs), QLocale::ShortFormat)); //ui->lineEdit_Nickname->setText(QString::fromUtf8(data.mMeta.mGroupName.c_str()).left(RSID_MAXIMUM_NICKNAME_SIZE)); ui->lineEdit_KeyId->setText(QString::fromStdString(data.mMeta.mGroupId.toStdString())); //ui->lineEdit_GpgHash->setText(QString::fromStdString(data.mPgpIdHash.toStdString())); @@ -2165,7 +2166,7 @@ void IdDialog::headerContextMenuRequested(QPoint) // create menu header //QHBoxLayout *hbox = new QHBoxLayout(widget); - //hbox->setMargin(0); + //hbox->setContentsMargins(0, 0, 0, 0); //hbox->setSpacing(6); auto addEntry = [&](const QString& name,RsIdentityListModel::Columns col) @@ -2264,7 +2265,7 @@ void IdDialog::IdListCustomPopupMenu( QPoint ) // create menu header QHBoxLayout *hbox = new QHBoxLayout(widget); - hbox->setMargin(0); + hbox->setContentsMargins(0, 0, 0, 0); hbox->setSpacing(6); QLabel *iconLabel = new QLabel(widget); @@ -2719,7 +2720,7 @@ void IdDialog::recursSaveExpandedItems_idTreeView(const QModelIndex& proxy_index expanded.insert(local_path) ; for(int row=0;rowrowCount(proxy_index);++row) - recursSaveExpandedItems_idTreeView(proxy_index.child(row,0),local_path,expanded,selected) ; + recursSaveExpandedItems_idTreeView(mProxyModel->index(row,0,proxy_index),local_path,expanded,selected) ; } if(ui->idTreeWidget->selectionModel()->isSelected(proxy_index)) @@ -2751,7 +2752,7 @@ void IdDialog::recursRestoreExpandedItems_idTreeView(const QModelIndex& proxy_in ui->idTreeWidget->setExpanded(proxy_index,true) ; for(int row=0;rowrowCount(proxy_index);++row) - recursRestoreExpandedItems_idTreeView(proxy_index.child(row,0),local_path,expanded,selected) ; + recursRestoreExpandedItems_idTreeView(mProxyModel->index(row,0,proxy_index),local_path,expanded,selected) ; } if(selected.find(local_path) != selected.end()) diff --git a/retroshare-gui/src/gui/Identity/IdEditDialog.cpp b/retroshare-gui/src/gui/Identity/IdEditDialog.cpp index 7e5544413..bb8530a05 100644 --- a/retroshare-gui/src/gui/Identity/IdEditDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdEditDialog.cpp @@ -29,12 +29,13 @@ #include "gui/gxs/GxsIdDetails.h" #include "util/qtthreadsutils.h" #include "util/misc.h" -#include "gui/notifyqt.h" #include "retroshare/rsidentity.h" #include "retroshare/rspeers.h" +#include "retroshare/rsinit.h" #include "gui/common/FilesDefs.h" #include "util/imageutil.h" +#include "util/RsQtVersion.h" #include @@ -595,9 +596,9 @@ void IdEditDialog::createId() std::string gpg_name = rsPeers->getGPGName(rsPeers->getGPGOwnId()); bool cancelled; - rsNotify->clearPgpPassphrase(); // just in case + RsLoginHelper::clearPgpPassphrase(); // just in case - if(!NotifyQt::getInstance()->askForPassword(tr("Profile password needed.").toStdString(), + if(!RsLoginHelper::askForPassword(tr("Profile password needed.").toStdString(), gpg_name + " (" + rsPeers->getOwnId().toStdString() + ")", false, gpg_password,cancelled)) @@ -669,9 +670,9 @@ void IdEditDialog::updateId() std::string gpg_name = rsPeers->getGPGName(rsPeers->getGPGOwnId()); bool cancelled; - rsNotify->clearPgpPassphrase(); // just in case + RsLoginHelper::clearPgpPassphrase(); // just in case - if(!NotifyQt::getInstance()->askForPassword(tr("Profile password needed.").toStdString(), + if(!RsLoginHelper::askForPassword(tr("Profile password needed.").toStdString(), gpg_name + " (" + rsPeers->getOwnId().toStdString() + ")", false, gpg_password,cancelled)) @@ -700,8 +701,8 @@ void IdEditDialog::removeAvatar() void IdEditDialog::updateInterface() { - const QPixmap *pixmap = ui->avatarLabel->pixmap(); - if (pixmap && !pixmap->isNull()) { + QPixmap pixmap = QLabel_pixmap(ui->avatarLabel); + if (!pixmap.isNull()) { ui->removeButton->setEnabled(true); } else if (mEditGroup.mImage.mSize > 0) { ui->removeButton->setEnabled(true); diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.h b/retroshare-gui/src/gui/Identity/IdentityListModel.h index 4c3cb43e2..0e1fb5e28 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.h +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.h @@ -168,7 +168,7 @@ public: /* Color definitions (for standard see default.qss) */ QColor mTextColorGroup; - QColor mTextColorStatus[RS_STATUS_COUNT]; + QColor mTextColorStatus[(int)RsStatusValue::RS_STATUS_COUNT]; void setIdentities(const std::list& identities_meta); diff --git a/retroshare-gui/src/gui/LogoBar.cpp b/retroshare-gui/src/gui/LogoBar.cpp index 081eb2c31..a5759ed16 100644 --- a/retroshare-gui/src/gui/LogoBar.cpp +++ b/retroshare-gui/src/gui/LogoBar.cpp @@ -80,7 +80,7 @@ void LogoBar::init() { ); QGridLayout * layout = new QGridLayout(this); - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); layout->addWidget(FillLabel1, 0, 0); diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 0a438107a..3eed34bb4 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -29,10 +29,13 @@ #include #include #include +#include -#include -#include -#include +#include "retroshare/rsplugin.h" +#include "retroshare/rsconfig.h" +#include "retroshare/rsevents.h" +#include "util/argstream.h" +#include "util/qtthreadsutils.h" #if defined(Q_OS_DARWIN) #include "gui/common/MacDockIconHandler.h" @@ -64,7 +67,6 @@ #include "chat/ChatDialog.h" #include "RetroShareLink.h" #include "SoundManager.h" -#include "notifyqt.h" #include "common/UserNotify.h" #include "gui/ServicePermissionDialog.h" @@ -98,7 +100,6 @@ #include "retroshare/rsiface.h" #include "retroshare/rspeers.h" #include "retroshare/rsfiles.h" -#include "retroshare/rsnotify.h" #include "retroshare/rsinit.h" #include "gui/gxschannels/GxsChannelDialog.h" @@ -120,11 +121,11 @@ #include "gui/statistics/StatisticsWindow.h" #include "gui/connect/ConnectFriendWizard.h" +#include "gui/RsGUIEventManager.h" #include "gui/common/RsCollectionDialog.h" #include "settings/rsettingswin.h" #include "settings/rsharesettings.h" #include "common/StatusDefs.h" -#include "gui/notifyqt.h" #ifdef RS_WEBUI # include "settings/WebuiPage.h" @@ -270,7 +271,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags) QWidget *widget = new QWidget(); widget->setObjectName("trans_statusComboBoxFrame"); QHBoxLayout *hbox = new QHBoxLayout(); - hbox->setMargin(0); + hbox->setContentsMargins(0, 0, 0, 0); hbox->setSpacing(6); hbox->addWidget(statusComboBox); widget->setLayout(hbox); @@ -350,10 +351,8 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags) createNotifyIcons(); - /* calculate friend count */ + /* intialize friend count */ updateFriends(); - connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateFriends())); - connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()), this, SLOT(updateFriends())); loadOwnStatus(); @@ -368,10 +367,28 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags) timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus())); timer->start(1000); - connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); + connect(RsGUIEventManager::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); settingsChanged(); mFontSizeHandler.registerFontSize(ui->listWidget, 1.5f); + + mEventHandlerId_friends = 0; + + rsEvents->registerEventsHandler( [this](std::shared_ptr e) + { + RsQThreadUtils::postToObject([=]() + { + auto fe = dynamic_cast(e.get()); + + if(!fe) + return; + + updateFriends(); + } + , this ); + }, mEventHandlerId_friends, RsEventType::FRIEND_LIST ); + + } /** Destructor. */ @@ -382,6 +399,8 @@ MainWindow::~MainWindow() Settings->setValueToGroup("MainWindow", "SplitterState", ui->splitter->saveState()); Settings->setValueToGroup("MainWindow", "State", saveState()); + rsEvents->unregisterEventsHandler(mEventHandlerId_friends); + delete statusComboBox; delete peerstatus; delete natstatus; @@ -606,28 +625,6 @@ void MainWindow::setNewPage(int page) } } -void MainWindow::displayDiskSpaceWarning(int loc,int size_limit_mb) -{ - QString locString ; - switch(loc) - { - case RS_PARTIALS_DIRECTORY: locString = "Partials" ; - break ; - - case RS_CONFIG_DIRECTORY: locString = "Config" ; - break ; - - case RS_DOWNLOAD_DIRECTORY: locString = "Download" ; - break ; - - default: - std::cerr << "Error: " << __PRETTY_FUNCTION__ << " was called with an unknown parameter loc=" << loc << std::endl ; - return ; - } - QMessageBox::critical(NULL,tr("Low disk space warning"), - tr("The disk space in your")+" "+locString +" "+tr("directory is running low (current limit is")+" "+QString::number(size_limit_mb)+tr("MB). \n\n RetroShare will now safely suspend any disk access to this directory. \n\n Please make some free space and click Ok.")) ; -} - /** Creates a tray icon with a context menu and adds it to the system * notification area. */ void MainWindow::createTrayIcon() @@ -967,7 +964,9 @@ void MainWindow::postModDirectories(bool /*update_local*/) { //RSettingsPage::postModDirectories(update_local); +#if QT_VERSION < QT_VERSION_CHECK (6, 0, 0) QCoreApplication::flush(); +#endif } #ifdef WINDOWS_SYS @@ -1378,11 +1377,6 @@ void MainWindow::receiveNewArgs(QStringList args) retroshareLinkActivated(link.toUrl()); } -void MainWindow::displayErrorMessage(int /*a*/,int /*b*/,const QString& error_msg) -{ - QMessageBox::critical(NULL, tr("Internal Error"),error_msg) ; -} - void MainWindow::closeEvent(QCloseEvent *e) { e->ignore(); @@ -1480,7 +1474,7 @@ MainWindow::retranslateUi() } /* set status object to status value */ -static void setStatusObject(QObject *pObject, int nStatus) +static void setStatusObject(QObject *pObject, RsStatusValue nStatus) { QMenu *pMenu = dynamic_cast(pObject); if (pMenu) { @@ -1491,7 +1485,7 @@ static void setStatusObject(QObject *pObject, int nStatus) continue; } - if (pAction->data().toInt() == nStatus) { + if (pAction->data().toInt() == (int)nStatus) { pAction->setChecked(true); break; } @@ -1501,7 +1495,7 @@ static void setStatusObject(QObject *pObject, int nStatus) RSComboBox *pComboBox = dynamic_cast(pObject); if (pComboBox) { /* set index of combobox */ - int nIndex = pComboBox->findData(nStatus, Qt::UserRole); + int nIndex = pComboBox->findData((int)nStatus, Qt::UserRole); if (nIndex != -1) { pComboBox->setCurrentIndex(nIndex); } @@ -1564,20 +1558,20 @@ void MainWindow::initializeStatusObject(QObject *pObject, bool bConnect) /* initialize menu */ QActionGroup *pGroup = new QActionGroup(pMenu); - QAction *pAction = new QAction(QIcon(StatusDefs::imageStatus(RS_STATUS_ONLINE)), StatusDefs::name(RS_STATUS_ONLINE), pMenu); - pAction->setData(RS_STATUS_ONLINE); + QAction *pAction = new QAction(QIcon(StatusDefs::imageStatus(RsStatusValue::RS_STATUS_ONLINE)), StatusDefs::name(RsStatusValue::RS_STATUS_ONLINE), pMenu); + pAction->setData((int)RsStatusValue::RS_STATUS_ONLINE); pAction->setCheckable(true); pMenu->addAction(pAction); pGroup->addAction(pAction); - pAction = new QAction(QIcon(StatusDefs::imageStatus(RS_STATUS_BUSY)), StatusDefs::name(RS_STATUS_BUSY), pMenu); - pAction->setData(RS_STATUS_BUSY); + pAction = new QAction(QIcon(StatusDefs::imageStatus(RsStatusValue::RS_STATUS_BUSY)), StatusDefs::name(RsStatusValue::RS_STATUS_BUSY), pMenu); + pAction->setData((int)RsStatusValue::RS_STATUS_BUSY); pAction->setCheckable(true); pMenu->addAction(pAction); pGroup->addAction(pAction); - pAction = new QAction(QIcon(StatusDefs::imageStatus(RS_STATUS_AWAY)), StatusDefs::name(RS_STATUS_AWAY), pMenu); - pAction->setData(RS_STATUS_AWAY); + pAction = new QAction(QIcon(StatusDefs::imageStatus(RsStatusValue::RS_STATUS_AWAY)), StatusDefs::name(RsStatusValue::RS_STATUS_AWAY), pMenu); + pAction->setData((int)RsStatusValue::RS_STATUS_AWAY); pAction->setCheckable(true); pMenu->addAction(pAction); pGroup->addAction(pAction); @@ -1589,9 +1583,9 @@ void MainWindow::initializeStatusObject(QObject *pObject, bool bConnect) /* initialize combobox */ RSComboBox *pComboBox = dynamic_cast(pObject); if (pComboBox) { - pComboBox->addItem(QIcon(StatusDefs::imageStatus(RS_STATUS_ONLINE)), StatusDefs::name(RS_STATUS_ONLINE), RS_STATUS_ONLINE); - pComboBox->addItem(QIcon(StatusDefs::imageStatus(RS_STATUS_BUSY)), StatusDefs::name(RS_STATUS_BUSY), RS_STATUS_BUSY); - pComboBox->addItem(QIcon(StatusDefs::imageStatus(RS_STATUS_AWAY)), StatusDefs::name(RS_STATUS_AWAY), RS_STATUS_AWAY); + pComboBox->addItem(QIcon(StatusDefs::imageStatus(RsStatusValue::RS_STATUS_ONLINE)), StatusDefs::name(RsStatusValue::RS_STATUS_ONLINE), (int)RsStatusValue::RS_STATUS_ONLINE); + pComboBox->addItem(QIcon(StatusDefs::imageStatus(RsStatusValue::RS_STATUS_BUSY)), StatusDefs::name(RsStatusValue::RS_STATUS_BUSY), (int)RsStatusValue::RS_STATUS_BUSY); + pComboBox->addItem(QIcon(StatusDefs::imageStatus(RsStatusValue::RS_STATUS_AWAY)), StatusDefs::name(RsStatusValue::RS_STATUS_AWAY), (int)RsStatusValue::RS_STATUS_AWAY); if (bConnect) { connect(pComboBox, SIGNAL(activated(int)), this, SLOT(statusChangedComboBox(int))); @@ -1619,11 +1613,11 @@ void MainWindow::removeStatusObject(QObject *pObject) } /** Save own status Online,Away,Busy **/ -void MainWindow::setStatus(QObject *pObject, int nStatus) +void MainWindow::setStatus(QObject *pObject, RsStatusValue nStatus) { - if (isIdle && nStatus == (int) RS_STATUS_ONLINE) { + if (isIdle && nStatus == RsStatusValue::RS_STATUS_ONLINE) { /* set idle only when I am online */ - nStatus = RS_STATUS_INACTIVE; + nStatus = RsStatusValue::RS_STATUS_INACTIVE; } rsStatus->sendStatus(RsPeerId(), nStatus); @@ -1643,7 +1637,7 @@ void MainWindow::statusChangedMenu(QAction *pAction) return; } - setStatus(pAction->parent(), pAction->data().toInt()); + setStatus(pAction->parent(), RsStatusValue(pAction->data().toInt())); } /* new status from combobox in statusbar */ @@ -1654,7 +1648,7 @@ void MainWindow::statusChangedComboBox(int index) } /* no object known */ - setStatus(NULL, statusComboBox->itemData(index, Qt::UserRole).toInt()); + setStatus(NULL, RsStatusValue(statusComboBox->itemData(index, Qt::UserRole).toInt())); } /*new setting*/ diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h index b435524f0..59f927ac6 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -25,6 +25,9 @@ #include #include +#include "retroshare/rsevents.h" +#include "retroshare/rsstatus.h" + #include "gui/common/rwindow.h" #include "gui/common/RSComboBox.h" #include "util/FontSizeHandler.h" @@ -183,7 +186,7 @@ public: /* initialize widget with status informations, status constant stored in data or in Qt::UserRole */ void initializeStatusObject(QObject *pObject, bool bConnect); void removeStatusObject(QObject *pObject); - void setStatus(QObject *pObject, int nStatus); + void setStatus(QObject *pObject, RsStatusValue nStatus); RSComboBox *statusComboBoxInstance(); PeerStatus *peerstatusInstance(); @@ -207,9 +210,7 @@ public: public slots: void receiveNewArgs(QStringList args); - void displayErrorMessage(int,int,const QString&) ; void postModDirectories(bool update_local); - void displayDiskSpaceWarning(int loc,int size_limit_mb) ; void checkAndSetIdle(int idleTime); void externalLinkActivated(const QUrl &url); @@ -375,6 +376,7 @@ private: FontSizeHandler mFontSizeHandler; Ui::MainWindow *ui ; -}; + RsEventsHandlerId_t mEventHandlerId_friends; +}; #endif diff --git a/retroshare-gui/src/gui/MessengerWindow.cpp b/retroshare-gui/src/gui/MessengerWindow.cpp index 77396a928..fca08966f 100644 --- a/retroshare-gui/src/gui/MessengerWindow.cpp +++ b/retroshare-gui/src/gui/MessengerWindow.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include "rshare.h" #include "MessengerWindow.h" @@ -37,9 +36,9 @@ #include "MainWindow.h" #include "ShareManager.h" -#include "notifyqt.h" #include "connect/ConnectFriendWizard.h" #include "util/PixmapMerging.h" +#include "util/qtthreadsutils.h" #include "LogoBar.h" #include "util/Widget.h" #include "util/misc.h" @@ -95,8 +94,26 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WindowFlags flags) connect(ui.messagelineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(savestatusmessage())); - connect(NotifyQt::getInstance(), SIGNAL(ownStatusMessageChanged()), this, SLOT(loadmystatusmessage())); - connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateOwnStatus(QString,int))); + mEventHandlerId = 0; + rsEvents->registerEventsHandler( [this](std::shared_ptr e) + { + RsQThreadUtils::postToObject([=](){ + auto fe = dynamic_cast(e.get()); + + if(!fe) return; + + switch(fe->mEventCode) + { + case RsFriendListEventCode::NODE_STATUS_CHANGED: updateOwnStatus(QString::fromStdString(fe->mSslId.toStdString()),fe->mStatus); + break; + case RsFriendListEventCode::OWN_STATUS_CHANGED: loadmystatusmessage(); + break; + default: + break; + } + + }, this ); + },mEventHandlerId,RsEventType::FRIEND_LIST); for (std::set::iterator peerIt = expandedPeers.begin(); peerIt != expandedPeers.end(); ++peerIt) { ui.friendList->addPeerToExpand(*peerIt); @@ -159,6 +176,7 @@ MessengerWindow::~MessengerWindow () { // save settings processSettings(false); + rsEvents->unregisterEventsHandler(mEventHandlerId); MainWindow *pMainWindow = MainWindow::getInstance(); if (pMainWindow) { @@ -214,7 +232,7 @@ void MessengerWindow::savestatusmessage() rsMsgs->setCustomStateString(ui.messagelineEdit->currentText().toUtf8().constData()); } -void MessengerWindow::updateOwnStatus(const QString &peer_id, int status) +void MessengerWindow::updateOwnStatus(const QString &peer_id, RsStatusValue status) { // add self nick + own status if (peer_id == QString::fromStdString(rsPeers->getOwnId().toStdString())) diff --git a/retroshare-gui/src/gui/MessengerWindow.h b/retroshare-gui/src/gui/MessengerWindow.h index d683ec744..e6a0c10db 100644 --- a/retroshare-gui/src/gui/MessengerWindow.h +++ b/retroshare-gui/src/gui/MessengerWindow.h @@ -39,7 +39,7 @@ public slots: protected: /** Default Constructor */ - MessengerWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0); + MessengerWindow(QWidget *parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); /** Default Destructor */ ~MessengerWindow(); @@ -52,7 +52,7 @@ private slots: /** Open Shared Manager **/ void openShareManager(); - void updateOwnStatus(const QString &peer_id, int status); + void updateOwnStatus(const QString &peer_id, RsStatusValue status); void savestatusmessage(); @@ -68,6 +68,7 @@ private: static std::set expandedPeers ; static std::set expandedGroups ; + RsEventsHandlerId_t mEventHandlerId ; }; #endif diff --git a/retroshare-gui/src/gui/NetworkDialog.cpp b/retroshare-gui/src/gui/NetworkDialog.cpp index 7c2b3fd14..e0e7f2494 100644 --- a/retroshare-gui/src/gui/NetworkDialog.cpp +++ b/retroshare-gui/src/gui/NetworkDialog.cpp @@ -42,7 +42,7 @@ #include "connect/PGPKeyDialog.h" #include "settings/rsharesettings.h" #include "RetroShareLink.h" -#include "util/QtVersion.h" +#include "util/RsQtVersion.h" #include diff --git a/retroshare-gui/src/gui/NetworkDialog/pgpid_item_proxy.cpp b/retroshare-gui/src/gui/NetworkDialog/pgpid_item_proxy.cpp index e7b81ef2b..9da32fe2a 100644 --- a/retroshare-gui/src/gui/NetworkDialog/pgpid_item_proxy.cpp +++ b/retroshare-gui/src/gui/NetworkDialog/pgpid_item_proxy.cpp @@ -44,7 +44,7 @@ pgpid_item_proxy::pgpid_item_proxy(QObject *parent) : void pgpid_item_proxy::use_only_trusted_keys(bool val) { only_trusted_keys = val; - filterChanged(); + invalidateFilter(); } bool pgpid_item_proxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const diff --git a/retroshare-gui/src/gui/NetworkView.cpp b/retroshare-gui/src/gui/NetworkView.cpp index 402e14063..0a41c82ef 100644 --- a/retroshare-gui/src/gui/NetworkView.cpp +++ b/retroshare-gui/src/gui/NetworkView.cpp @@ -28,6 +28,7 @@ #include #include "gui/elastic/elnode.h" +#include "util/qtthreadsutils.h" /******** * #define DEBUG_NETWORKVIEW @@ -60,12 +61,32 @@ NetworkView::NetworkView(QWidget *parent) connect( ui.nameBox, SIGNAL(textChanged(QString)), this, SLOT(setNameSearch(QString))); _should_update = true ; + + rsEvents->registerEventsHandler( [this](std::shared_ptr event) + { + RsQThreadUtils::postToObject([=](){ + auto ev = dynamic_cast(event.get()); + + if(!ev) return; + + switch(ev->mGossipDiscoveryEventType) + { + case RsGossipDiscoveryEventType::DISCOVERY_INFO_RECEIVED: update(); + [[fallthrough]]; + default: + break; + } + }, this ); + }, mEventHandlerId, RsEventType::GOSSIP_DISCOVERY ); + } NetworkView::~NetworkView() { - if(mScene != NULL) - delete mScene ; + rsEvents->unregisterEventsHandler(mEventHandlerId); + + if(mScene != NULL) + delete mScene ; } void NetworkView::setEdgeLength(int l) diff --git a/retroshare-gui/src/gui/NetworkView.h b/retroshare-gui/src/gui/NetworkView.h index f6fcfe0b1..c439cb6c4 100644 --- a/retroshare-gui/src/gui/NetworkView.h +++ b/retroshare-gui/src/gui/NetworkView.h @@ -24,6 +24,7 @@ #include #include +#include #include #include "ui_NetworkView.h" @@ -65,6 +66,7 @@ class NetworkView : public RsAutoUpdatePage std::map _node_ids ; bool _should_update ; + RsEventsHandlerId_t mEventHandlerId; }; #endif diff --git a/retroshare-gui/src/gui/NewsFeed.cpp b/retroshare-gui/src/gui/NewsFeed.cpp index dc0834e71..1b67c92a9 100644 --- a/retroshare-gui/src/gui/NewsFeed.cpp +++ b/retroshare-gui/src/gui/NewsFeed.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -35,6 +34,7 @@ #include "util/misc.h" #include "util/qtthreadsutils.h" #include "feeds/BoardsCommentsItem.h" +#include "feeds/BoardsPostItem.h" #include "feeds/ChatMsgItem.h" #include "feeds/GxsCircleItem.h" #include "feeds/ChannelsCommentsItem.h" @@ -58,7 +58,6 @@ #include "msgs/MessageInterface.h" #include "common/FeedNotify.h" -#include "notifyqt.h" #define ROLE_RECEIVED FEED_TREEWIDGET_SORTROLE @@ -76,7 +75,7 @@ static NewsFeed* instance = nullptr; NewsFeed::NewsFeed(QWidget *parent) : MainPage(parent), ui(new Ui::NewsFeed), mEventTypes({ RsEventType::AUTHSSL_CONNECTION_AUTENTICATION, - RsEventType::PEER_CONNECTION , + RsEventType::FRIEND_LIST , RsEventType::GXS_CIRCLES , RsEventType::GXS_CHANNELS , RsEventType::GXS_FORUMS , @@ -192,27 +191,27 @@ void NewsFeed::handleEvent(std::shared_ptr event) void NewsFeed::handleEvent_main_thread(std::shared_ptr event) { - uint flags = Settings->getNewsFeedFlags(); + RsFeedTypeFlags flags = (RsFeedTypeFlags)Settings->getNewsFeedFlags(); - if(event->mType == RsEventType::AUTHSSL_CONNECTION_AUTENTICATION && (flags & RS_FEED_TYPE_SECURITY)) + if(event->mType == RsEventType::AUTHSSL_CONNECTION_AUTENTICATION && (!!(flags & RsFeedTypeFlags::RS_FEED_TYPE_SECURITY))) handleSecurityEvent(event); - if(event->mType == RsEventType::PEER_CONNECTION && (flags & RS_FEED_TYPE_PEER)) + if(event->mType == RsEventType::FRIEND_LIST && (!!(flags & RsFeedTypeFlags::RS_FEED_TYPE_PEER))) handleConnectionEvent(event); - if(event->mType == RsEventType::GXS_CIRCLES && (flags & RS_FEED_TYPE_CIRCLE)) + if(event->mType == RsEventType::GXS_CIRCLES && (!!(flags & RsFeedTypeFlags::RS_FEED_TYPE_CIRCLE))) handleCircleEvent(event); - if(event->mType == RsEventType::GXS_CHANNELS && (flags & RS_FEED_TYPE_CHANNEL)) + if(event->mType == RsEventType::GXS_CHANNELS && (!!(flags & RsFeedTypeFlags::RS_FEED_TYPE_CHANNEL))) handleChannelEvent(event); - if(event->mType == RsEventType::GXS_FORUMS && (flags & RS_FEED_TYPE_FORUM)) + if(event->mType == RsEventType::GXS_FORUMS && (!!(flags & RsFeedTypeFlags::RS_FEED_TYPE_FORUM))) handleForumEvent(event); - if(event->mType == RsEventType::GXS_POSTED && (flags & RS_FEED_TYPE_POSTED)) + if(event->mType == RsEventType::GXS_POSTED && (!!(flags & RsFeedTypeFlags::RS_FEED_TYPE_POSTED))) handlePostedEvent(event); - if(event->mType == RsEventType::MAIL_STATUS && (flags & RS_FEED_TYPE_MSG)) + if(event->mType == RsEventType::MAIL_STATUS && (!!(flags & RsFeedTypeFlags::RS_FEED_TYPE_MSG))) handleMailEvent(event); } @@ -241,11 +240,12 @@ void NewsFeed::handlePostedEvent(std::shared_ptr event) switch(pe->mPostedEventCode) { + case RsPostedEventCode::UPDATED_POSTED_GROUP: case RsPostedEventCode::NEW_POSTED_GROUP: addFeedItem( new PostedGroupItem(this, NEWSFEED_POSTEDNEWLIST, pe->mPostedGroupId, false, true)); break; case RsPostedEventCode::NEW_MESSAGE: - addFeedItem( new PostedItem(this, NEWSFEED_POSTEDMSGLIST, pe->mPostedGroupId, pe->mPostedMsgId, false, true)); + addFeedItem( new BoardsPostItem(this, NEWSFEED_POSTEDMSGLIST, pe->mPostedGroupId, pe->mPostedMsgId, false, true)); break; case RsPostedEventCode::NEW_COMMENT: addFeedItem( new BoardsCommentsItem(this, NEWSFEED_POSTEDMSGLIST, pe->mPostedGroupId, pe->mPostedMsgId, false, true)); @@ -389,25 +389,25 @@ void NewsFeed::handleCircleEvent(std::shared_ptr event) case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_REQUEST: // only show membership requests if we're an admin of that circle if(details.isIdInInviteeList(pe->mGxsId)) - addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_JOIN),true); + addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_MEMB_JOIN),true); else if(details.mAmIAdmin) - addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_REQ),true); + addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_MEMB_REQ),true); break; case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_LEAVE: if(details.isIdInInviteeList(pe->mGxsId)) - addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_LEAVE),true); + addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_MEMB_LEAVE),true); break; case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_ID_ADDED_TO_INVITEE_LIST: if(rsIdentity->isOwnId(pe->mGxsId)) { if(details.isIdRequestingMembership(pe->mGxsId)) - addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_ACCEPTED),true); + addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_MEMB_ACCEPTED),true); else - addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_INVITE_REC),true); + addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_INVITE_REC),true); } break; @@ -415,9 +415,9 @@ void NewsFeed::handleCircleEvent(std::shared_ptr event) if(rsIdentity->isOwnId(pe->mGxsId)) { if(details.isIdRequestingMembership(pe->mGxsId)) - addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_REVOKED),true); + addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_MEMB_REVOKED),true); else - addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_INVITE_CANCELLED),true); + addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_INVITE_CANCELLED),true); } break; @@ -428,31 +428,26 @@ void NewsFeed::handleCircleEvent(std::shared_ptr event) void NewsFeed::handleConnectionEvent(std::shared_ptr event) { - const RsConnectionEvent *pe = dynamic_cast(event.get()); + const RsFriendListEvent *pe = dynamic_cast(event.get()); if(!pe) return; auto& e(*pe); -#ifdef NEWS_DEBUG - std::cerr << "NotifyQt: handling connection event from peer " << e.mSslId << std::endl; -#endif - - switch(e.mConnectionInfoCode) + switch(e.mEventCode) { - case RsConnectionEventCode::PEER_CONNECTED: + case RsFriendListEventCode::NODE_CONNECTED: addFeedItemIfUnique(new PeerItem(this, NEWSFEED_PEERLIST, e.mSslId, PEER_TYPE_CONNECT, false), true); - NotifyQt::getInstance()->addToaster(RS_POPUP_CONNECT, e.mSslId.toStdString().c_str(), "", ""); break; - case RsConnectionEventCode::PEER_DISCONNECTED: // not handled yet + case RsFriendListEventCode::NODE_DISCONNECTED: // not handled yet break; - case RsConnectionEventCode::PEER_TIME_SHIFT: + case RsFriendListEventCode::NODE_TIME_SHIFT: addFeedItemIfUnique(new PeerItem(this, NEWSFEED_PEERLIST, e.mSslId, PEER_TYPE_OFFSET, false),false); break; - case RsConnectionEventCode::PEER_REPORTS_WRONG_IP: + case RsFriendListEventCode::NODE_REPORTS_WRONG_IP: addFeedItemIfUnique(new SecurityIpItem( this, e.mSslId, e.mOwnLocator.toString(), e.mReportedLocator.toString(), - RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED, + RsFeedTypeFlags::RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED, false ), false); break; default: break; @@ -467,34 +462,31 @@ void NewsFeed::handleSecurityEvent(std::shared_ptr event) return; auto& e(*pe); -#ifdef NEWS_DEBUG - std::cerr << "NotifyQt: handling security event from (" << e.mSslId << "," << e.mPgpId << ") error code: " << (int)e.mErrorCode << std::endl; -#endif - uint flags = Settings->getNewsFeedFlags(); + RsFeedTypeFlags flags = (RsFeedTypeFlags)Settings->getNewsFeedFlags(); - if(e.mErrorCode == RsAuthSslError::PEER_REFUSED_CONNECTION && (flags & RS_FEED_TYPE_SECURITY_IP)) + if(e.mErrorCode == RsAuthSslError::PEER_REFUSED_CONNECTION && (!!(flags & RsFeedTypeFlags::RS_FEED_TYPE_SECURITY_IP))) { addFeedItemIfUnique(new PeerItem(this, NEWSFEED_PEERLIST, e.mSslId, PEER_TYPE_HELLO, false), true ); return; } - uint32_t FeedItemType=0; + RsFeedTypeFlags FeedItemType(RsFeedTypeFlags::RS_FEED_TYPE_NONE); switch(e.mErrorCode) { case RsAuthSslError::NO_CERTIFICATE_SUPPLIED: // fallthrough case RsAuthSslError::MISMATCHED_PGP_ID: // fallthrough case RsAuthSslError::MISSING_AUTHENTICATION_INFO: - FeedItemType = RS_FEED_ITEM_SEC_BAD_CERTIFICATE; break; + FeedItemType = RsFeedTypeFlags::RS_FEED_ITEM_SEC_BAD_CERTIFICATE; break; case RsAuthSslError::PGP_SIGNATURE_VALIDATION_FAILED: - FeedItemType = RS_FEED_ITEM_SEC_WRONG_SIGNATURE; break; + FeedItemType = RsFeedTypeFlags::RS_FEED_ITEM_SEC_WRONG_SIGNATURE; break; case RsAuthSslError::NOT_A_FRIEND: - FeedItemType = RS_FEED_ITEM_SEC_CONNECT_ATTEMPT; break; + FeedItemType = RsFeedTypeFlags::RS_FEED_ITEM_SEC_CONNECT_ATTEMPT; break; case RsAuthSslError::IP_IS_BLACKLISTED: - FeedItemType = RS_FEED_ITEM_SEC_IP_BLACKLISTED; break; + FeedItemType = RsFeedTypeFlags::RS_FEED_ITEM_SEC_IP_BLACKLISTED; break; case RsAuthSslError::MISSING_CERTIFICATE: - FeedItemType = RS_FEED_ITEM_SEC_MISSING_CERTIFICATE; break; + FeedItemType = RsFeedTypeFlags::RS_FEED_ITEM_SEC_MISSING_CERTIFICATE; break; default: return; // display nothing } @@ -504,14 +496,50 @@ void NewsFeed::handleSecurityEvent(std::shared_ptr event) addFeedItemIfUnique(new SecurityItem(this, NEWSFEED_SECLIST, e.mPgpId, e.mSslId, det.location, e.mLocator.toString(), FeedItemType, false), true ); - if (Settings->getMessageFlags() & RS_MESSAGE_CONNECT_ATTEMPT) + if (Settings->getMessageFlags() & RshareSettings::RS_MESSAGE_CONNECT_ATTEMPT) MessageComposer::addConnectAttemptMsg(e.mPgpId, e.mSslId, QString::fromStdString(det.name + "(" + det.location + ")")); - - NotifyQt::getInstance()->addToaster(RS_POPUP_CONNECT_ATTEMPT, e.mPgpId.toStdString().c_str(), det.location, e.mSslId.toStdString().c_str()); } -void NewsFeed::testFeeds(uint /*notifyFlags*/) +void NewsFeed::testFeeds(RsFeedTypeFlags /*notifyFlags*/) { + RsFeedTypeFlags flags = RsFeedTypeFlags(Settings->getNewsFeedFlags()); + + //For test your feed add valid ID's for RsGxsGroupId & RsGxsMessageId, else test feed will be not displayed + + if (!!(flags & RsFeedTypeFlags::RS_FEED_TYPE_PEER)) + instance->addFeedItemIfUnique(new PeerItem(instance, NEWSFEED_PEERLIST, RsPeerId(""), PEER_TYPE_CONNECT, false), true); + + if (!!(flags & RsFeedTypeFlags::RS_FEED_TYPE_MSG)) + instance->addFeedItemIfUnique(new MsgItem(instance, NEWSFEED_MESSAGELIST, std::string(""), false), true); + + if (!!(flags & RsFeedTypeFlags::RS_FEED_TYPE_CHANNEL)){ + instance->addFeedItem(new GxsChannelGroupItem(instance, NEWSFEED_CHANNELNEWLIST, RsGxsGroupId(""), false, true)); + instance->addFeedItem(new GxsChannelPostItem(instance, NEWSFEED_CHANNELNEWLIST, RsGxsGroupId(""), RsGxsMessageId(""), false, true)); + instance->addFeedItem(new ChannelsCommentsItem(instance, NEWSFEED_CHANNELNEWLIST, RsGxsGroupId(""), RsGxsMessageId(""), RsGxsMessageId(""), false, true)); + } + + if(!!(flags & RsFeedTypeFlags::RS_FEED_TYPE_FORUM)){ + instance->addFeedItem(new GxsForumGroupItem(instance, NEWSFEED_NEW_FORUM, RsGxsGroupId(""), false, true)); + instance->addFeedItem(new GxsForumMsgItem(instance, NEWSFEED_NEW_FORUM, RsGxsGroupId(""), RsGxsMessageId(""), false, true )); + } + + if(!!(flags & RsFeedTypeFlags::RS_FEED_TYPE_POSTED)){ + instance->addFeedItem( new PostedGroupItem(instance, NEWSFEED_POSTEDNEWLIST, RsGxsGroupId(""), false, true)); + instance->addFeedItem( new PostedItem(instance, NEWSFEED_POSTEDMSGLIST, RsGxsGroupId(""), RsGxsMessageId(""), false, true)); + instance->addFeedItem( new BoardsCommentsItem(instance, NEWSFEED_POSTEDMSGLIST, RsGxsGroupId(""), RsGxsMessageId(""), false, true)); + } + + if (!!(flags & RsFeedTypeFlags::RS_FEED_TYPE_CIRCLE)) + instance->addFeedItemIfUnique(new GxsCircleItem(instance, NEWSFEED_CIRCLELIST, RsGxsCircleId(""), RsGxsId(""), RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_MEMB_JOIN),true);; + + auto feedItem2 = new BoardsPostItem(instance, + NEWSFEED_CHANNELNEWLIST, + RsGxsGroupId ("00000000000000000000000000000000"), + RsGxsMessageId("0000000000000000000000000000000000000000") + , false, true); + + instance->addFeedItem(feedItem2); + #ifdef TO_REMOVE if (!instance) { return; diff --git a/retroshare-gui/src/gui/NewsFeed.h b/retroshare-gui/src/gui/NewsFeed.h index 2b246fb4c..fed1d41b5 100644 --- a/retroshare-gui/src/gui/NewsFeed.h +++ b/retroshare-gui/src/gui/NewsFeed.h @@ -24,6 +24,7 @@ #include #include "gui/feeds/FeedHolder.h" +#include "gui/feeds/FeedItem.h" #include #define IMAGE_NEWSFEED ":/icons/png/newsfeed.png" @@ -67,19 +68,19 @@ public: /** Default Destructor */ virtual ~NewsFeed(); - virtual QIcon iconPixmap() const { return QIcon(IMAGE_NEWSFEED) ; } //MainPage - virtual QString pageName() const { return tr("Activity") ; } //MainPage - virtual QString helpText() const { return ""; } //MainPage + virtual QIcon iconPixmap() const override { return QIcon(IMAGE_NEWSFEED) ; } //MainPage + virtual QString pageName() const override { return tr("Activity") ; } //MainPage + virtual QString helpText() const override { return ""; } //MainPage virtual UserNotify *createUserNotify(QObject *parent) override; /* FeedHolder Functions (for FeedItem functionality) */ - virtual QScrollArea *getScrollArea(); - virtual void deleteFeedItem(FeedItem *item, uint32_t type); - virtual void openChat(const RsPeerId& peerId); - virtual void openComments(uint32_t type, const RsGxsGroupId &groupId, const QVector &versions, const RsGxsMessageId &msgId, const QString &title); + virtual QScrollArea *getScrollArea()override ; + virtual void deleteFeedItem(FeedItem *item, uint32_t type)override ; + virtual void openChat(const RsPeerId& peerId)override ; + virtual void openComments(uint32_t type, const RsGxsGroupId &groupId, const QVector &versions, const RsGxsMessageId &msgId, const QString &title)override ; - static void testFeeds(uint notifyFlags); + static void testFeeds(RsFeedTypeFlags notifyFlags); static void testFeed(FeedNotify *feedNotify); void handleEvent(std::shared_ptr event); // get events from libretroshare diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index 541cecac0..6bcf7a83f 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -35,6 +35,7 @@ #include "util/HandleRichText.h" #include "gui/Identity/IdDialog.h" #include "gui/MainWindow.h" +#include "util/DateTime.h" #include "ui_BoardPostDisplayWidget_compact.h" #include "ui_BoardPostDisplayWidget_card.h" @@ -194,16 +195,14 @@ void BoardPostDisplayWidgetBase::baseSetup() voteDownButton()->setDisabled(true); fromLabel()->setId(mPost.mMeta.mAuthorId); titleLabel()->setText(tr( "

The author of this message (with ID %1) is banned.").arg(QString::fromStdString(mPost.mMeta.mAuthorId.toStdString()))) ; - QDateTime qtime; - qtime.setTime_t(mPost.mMeta.mPublishTs); + QDateTime qtime = DateTime::DateTimeFromTime_t(mPost.mMeta.mPublishTs); QString timestamp = qtime.toString("hh:mm dd-MMM-yyyy"); dateLabel()->setText(timestamp); pictureLabel()->setDisabled(true); } else { - QDateTime qtime; - qtime.setTime_t(mPost.mMeta.mPublishTs); + QDateTime qtime = DateTime::DateTimeFromTime_t(mPost.mMeta.mPublishTs); QString timestamp = qtime.toString("hh:mm dd-MMM-yyyy"); QString timestamp2 = misc::timeRelativeToNow(mPost.mMeta.mPublishTs) + " " + tr("ago"); dateLabel()->setText(timestamp); diff --git a/retroshare-gui/src/gui/Posted/PostedCardView.cpp b/retroshare-gui/src/gui/Posted/PostedCardView.cpp index 9824cfda2..c63996b3a 100644 --- a/retroshare-gui/src/gui/Posted/PostedCardView.cpp +++ b/retroshare-gui/src/gui/Posted/PostedCardView.cpp @@ -31,6 +31,7 @@ #include "gui/common/FilesDefs.h" #include "util/qtthreadsutils.h" #include "util/HandleRichText.h" +#include "util/DateTime.h" #include "ui_PostedCardView.h" @@ -44,14 +45,14 @@ PostedCardView::PostedCardView(FeedHolder *feedHolder, uint32_t feedId, const RsGroupMetaData &group_meta, const RsGxsMessageId &post_id, bool isHome, bool autoUpdate) : BasePostedItem(feedHolder, feedId, group_meta, post_id, isHome, autoUpdate) { - setup(); + PostedCardView::setup(); } PostedCardView::PostedCardView(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId& post_id, bool isHome, bool autoUpdate) : BasePostedItem(feedHolder, feedId, groupId, post_id, isHome, autoUpdate) { - setup(); - loadGroup(); + PostedCardView::setup(); + PostedCardView::loadGroup(); } void PostedCardView::setCommentsSize(int comNb) @@ -186,8 +187,7 @@ void PostedCardView::fill() ui->picture_frame->hide(); ui->fromLabel->setId(mPost.mMeta.mAuthorId); ui->titleLabel->setText(tr( "

The author of this message (with ID %1) is banned.").arg(QString::fromStdString(mPost.mMeta.mAuthorId.toStdString()))) ; - QDateTime qtime; - qtime.setTime_t(mPost.mMeta.mPublishTs); + QDateTime qtime = DateTime::DateTimeFromTime_t(mPost.mMeta.mPublishTs); QString timestamp = qtime.toString("hh:mm dd-MMM-yyyy"); ui->dateLabel->setText(timestamp); } else { @@ -198,8 +198,7 @@ void PostedCardView::fill() //int desired_height = 1.5*(ui->voteDownButton->height() + ui->voteUpButton->height() + ui->scoreLabel->height()); //int desired_width = sqpixmap2.width()*desired_height/(float)sqpixmap2.height(); - QDateTime qtime; - qtime.setTime_t(mPost.mMeta.mPublishTs); + QDateTime qtime = DateTime::DateTimeFromTime_t(mPost.mMeta.mPublishTs); QString timestamp = qtime.toString("hh:mm dd-MMM-yyyy"); QString timestamp2 = misc::timeRelativeToNow(mPost.mMeta.mPublishTs); ui->dateLabel->setText(timestamp2); diff --git a/retroshare-gui/src/gui/Posted/PostedItem.cpp b/retroshare-gui/src/gui/Posted/PostedItem.cpp index 8f1cddf7d..a592b0058 100644 --- a/retroshare-gui/src/gui/Posted/PostedItem.cpp +++ b/retroshare-gui/src/gui/Posted/PostedItem.cpp @@ -37,6 +37,7 @@ #include "PhotoView.h" #include "gui/Posted/PostedDialog.h" #include "ui_PostedItem.h" +#include "util/DateTime.h" #include @@ -366,14 +367,14 @@ void BasePostedItem::showAuthorInPeople() PostedItem::PostedItem(FeedHolder *feedHolder, uint32_t feedId, const RsGroupMetaData &group_meta, const RsGxsMessageId& post_id, bool isHome, bool autoUpdate) : BasePostedItem(feedHolder, feedId, group_meta, post_id, isHome, autoUpdate) { - setup(); + PostedItem::setup(); } PostedItem::PostedItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId& post_id, bool isHome, bool autoUpdate) : BasePostedItem(feedHolder, feedId, groupId, post_id, isHome, autoUpdate) { - setup(); - loadGroup(); + PostedItem::setup(); + PostedItem::loadGroup(); } @@ -498,8 +499,7 @@ void PostedItem::fill() ui->thumbnailLabel->setPicture( FilesDefs::getPixmapFromQtResourcePath(":/images/thumb-default.png")); ui->fromLabel->setId(mPost.mMeta.mAuthorId); ui->titleLabel->setText(tr( "

The author of this message (with ID %1) is banned.").arg(QString::fromStdString(mPost.mMeta.mAuthorId.toStdString()))) ; - QDateTime qtime; - qtime.setTime_t(mPost.mMeta.mPublishTs); + QDateTime qtime = DateTime::DateTimeFromTime_t(mPost.mMeta.mPublishTs); QString timestamp = qtime.toString("hh:mm dd-MMM-yyyy"); ui->dateLabel->setText(timestamp); } else { @@ -514,8 +514,7 @@ void PostedItem::fill() ui->thumbnailLabel->setFixedSize(desired_width,desired_height); - QDateTime qtime; - qtime.setTime_t(mPost.mMeta.mPublishTs); + QDateTime qtime = DateTime::DateTimeFromTime_t(mPost.mMeta.mPublishTs); QString timestamp = qtime.toString("hh:mm dd-MMM-yyyy"); QString timestamp2 = misc::timeRelativeToNow(mPost.mMeta.mPublishTs); ui->dateLabel->setText(timestamp2); diff --git a/retroshare-gui/src/gui/Posted/PostedItem.h b/retroshare-gui/src/gui/Posted/PostedItem.h index a2f432dc0..2f1bc51b1 100644 --- a/retroshare-gui/src/gui/Posted/PostedItem.h +++ b/retroshare-gui/src/gui/Posted/PostedItem.h @@ -24,7 +24,7 @@ #include #include -#include "gui/gxs/GxsFeedItem.h" +#include "gui/feeds/GxsFeedItem.h" namespace Ui { class PostedItem; diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index 9245706d1..625f743a7 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -37,14 +37,15 @@ #include "gui/common/UIStateHelper.h" #include "gui/common/RSTabWidget.h" #include "gui/settings/rsharesettings.h" +#include "gui/RsGUIEventManager.h" #include "gui/feeds/SubFileItem.h" -#include "gui/notifyqt.h" #include "gui/Identity/IdDialog.h" #include "gui/RetroShareLink.h" #include "util/HandleRichText.h" #include "util/DateTime.h" #include "util/qtthreadsutils.h" #include "gui/common/FilesDefs.h" +#include "util/RsQtVersion.h" #include "gui/MainWindow.h" @@ -288,7 +289,7 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI connect(ui->submitPostButton, SIGNAL(clicked()), this, SLOT(createMsg())); connect(ui->subscribeToolButton, SIGNAL(subscribe(bool)), this, SLOT(subscribeGroup(bool))); connect(ui->filter_LE, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString))); - connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()),this, SLOT(settingsChanged())); + connect(RsGUIEventManager::getInstance(), SIGNAL(settingsChanged()),this, SLOT(settingsChanged())); /* add filter actions */ ui->postsTree->setPlaceholderText(tr("No posts available in this board")); @@ -417,7 +418,7 @@ void PostedListWidgetWithModel::updateShowLabel() void PostedListWidgetWithModel::filterItems(QString text) { - QStringList lst = text.split(" ",QString::SkipEmptyParts) ; + QStringList lst = text.split(" ",QtSkipEmptyParts) ; uint32_t count; mPostedPostsModel->setFilter(lst,count) ; @@ -876,13 +877,15 @@ void PostedListWidgetWithModel::insertBoardDetails(const RsPostedGroup& group) QString sync_string; switch(current_sync_time) { - case 5: sync_string = tr("5 days"); break; - case 15: sync_string = tr("2 weeks"); break; - case 30: sync_string = tr("1 month"); break; - case 90: sync_string = tr("3 months"); break; - case 180: sync_string = tr("6 months"); break; - case 365: sync_string = tr("1 year"); break; - case 0: sync_string = tr("indefinitly"); break; + case 5: sync_string = tr("5 days"); break; + case 15: sync_string = tr("2 weeks"); break; + case 30: sync_string = tr("1 month"); break; + case 90: sync_string = tr("3 months"); break; + case 180: sync_string = tr("6 months"); break; + case 365: sync_string = tr("1 year"); break; + case 1095: sync_string = tr("3 years"); break; + case 1825: sync_string = tr("5 years"); break; + case 0: sync_string = tr("indefinitly"); break; default: sync_string = tr("Unknown"); } @@ -939,196 +942,10 @@ void PostedListWidgetWithModel::insertBoardDetails(const RsPostedGroup& group) } ui->infoDistribution->setText(distrib_string); -#ifdef TODO - ui->infoWidget->show(); - ui->feedWidget->hide(); - ui->fileWidget->hide(); - - //ui->feedToolButton->setEnabled(false); - //ui->fileToolButton->setEnabled(false); -#endif } -#ifdef TODO -int PostedListWidgetWithModel::viewMode() -{ - if (ui->feedToolButton->isChecked()) { - return VIEW_MODE_FEEDS; - } else if (ui->fileToolButton->isChecked()) { - return VIEW_MODE_FILES; - } - - /* Default */ - return VIEW_MODE_FEEDS; -} -#endif - -#ifdef TODO -/*static*/ bool PostedListWidgetWithModel::filterItem(FeedItem *feedItem, const QString &text, int filter) -{ - GxsChannelPostItem *item = dynamic_cast(feedItem); - if (!item) { - return true; - } - - bool bVisible = text.isEmpty(); - - if (!bVisible) - { - switch(filter) - { - case FILTER_TITLE: - bVisible = item->getTitleLabel().contains(text,Qt::CaseInsensitive); - break; - case FILTER_MSG: - bVisible = item->getMsgLabel().contains(text,Qt::CaseInsensitive); - break; - case FILTER_FILE_NAME: - { - std::list fileItems = item->getFileItems(); - std::list::iterator lit; - for(lit = fileItems.begin(); lit != fileItems.end(); ++lit) - { - SubFileItem *fi = *lit; - QString fileName = QString::fromUtf8(fi->FileName().c_str()); - bVisible = (bVisible || fileName.contains(text,Qt::CaseInsensitive)); - } - break; - } - default: - bVisible = true; - break; - } - } - - return bVisible; -} - -void PostedListWidget::createPostItemFromMetaData(const RsGxsMsgMetaData& meta,bool related) -{ - GxsChannelPostItem *item = NULL; - RsGxsChannelPost post; - - if(!meta.mOrigMsgId.isNull()) - { - FeedItem *feedItem = ui->feedWidget->findFeedItem(GxsChannelPostItem::computeIdentifier(meta.mOrigMsgId)) ; - item = dynamic_cast(feedItem); - - if(item) - { - post = feedItem->post(); - ui->feedWidget->removeFeedItem(item) ; - - post.mOlderVersions.insert(post.mMeta.mMsgId); - - GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, post, true, false,post.mOlderVersions); - ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(post.mMeta.mPublishTs)); - - return ; - } - } - - if (related) - { - FeedItem *feedItem = ui->feedWidget->findFeedItem(GxsChannelPostItem::computeIdentifier(meta.mMsgId)) ; - item = dynamic_cast(feedItem); - } - if (item) - { - item->setPost(post); - ui->feedWidget->setSort(item, ROLE_PUBLISH, QDateTime::fromTime_t(meta.mPublishTs)); - } - else - { - GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, meta.mGroupId,meta.mMsgId, true, true); - ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(post.mMeta.mPublishTs)); - } -#ifdef TODO - ui->fileWidget->addFiles(post, related); -#endif -} - -void PostedListWidget::createPostItem(const RsGxsChannelPost& post, bool related) -{ - GxsChannelPostItem *item = NULL; - - const RsMsgMetaData& meta(post.mMeta); - - if(!meta.mOrigMsgId.isNull()) - { - FeedItem *feedItem = ui->feedWidget->findFeedItem(GxsChannelPostItem::computeIdentifier(meta.mOrigMsgId)) ; - item = dynamic_cast(feedItem); - - if(item) - { - std::set older_versions(item->olderVersions()); // we make a copy because the item will be deleted - ui->feedWidget->removeFeedItem(item) ; - - older_versions.insert(meta.mMsgId); - - GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, mGroup.mMeta,meta.mMsgId, true, false,older_versions); - ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(meta.mPublishTs)); - - return ; - } - } - - if (related) - { - FeedItem *feedItem = ui->feedWidget->findFeedItem(GxsChannelPostItem::computeIdentifier(meta.mMsgId)) ; - item = dynamic_cast(feedItem); - } - if (item) - { - item->setPost(post); - ui->feedWidget->setSort(item, ROLE_PUBLISH, QDateTime::fromTime_t(meta.mPublishTs)); - } - else - { - GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, mGroup.mMeta,meta.mMsgId, true, true); - ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(meta.mPublishTs)); - } - - ui->fileWidget->addFiles(post, related); -} - -void PostedListWidget::fillThreadCreatePost(const QVariant &post, bool related, int current, int count) -{ - /* show fill progress */ - if (count) { - ui->progressBar->setValue(current * ui->progressBar->maximum() / count); - } - - if (!post.canConvert()) { - return; - } - - createPostItem(post.value(), related); -} -#endif - void PostedListWidgetWithModel::blank() { -#ifdef TODO - ui->postButton->setEnabled(false); - ui->subscribeToolButton->setEnabled(false); - - ui->channelName_LB->setText(tr("No Channel Selected")); - ui->logoLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/channels.png")); - ui->infoPosts->setText(""); - ui->infoLastPost->setText(""); - ui->infoAdministrator->setText(""); - ui->infoDistribution->setText(""); - ui->infoCreated->setText(""); - ui->infoDescription->setText(""); - - mChannelPostsModel->clear(); - mChannelPostFilesModel->clear(); - ui->postDetails_TE->clear(); - ui->postLogo_LB->hide(); - ui->postName_LB->hide(); - ui->postTime_LB->hide(); -#endif groupNameChanged(QString()); } diff --git a/retroshare-gui/src/gui/QuickStartWizard.cpp b/retroshare-gui/src/gui/QuickStartWizard.cpp index ce953a32e..1b74bbb34 100644 --- a/retroshare-gui/src/gui/QuickStartWizard.cpp +++ b/retroshare-gui/src/gui/QuickStartWizard.cpp @@ -25,7 +25,7 @@ #include "gui/common/RSComboBox.h" #endif #include "settings/rsharesettings.h" -#include "util/QtVersion.h" +#include "util/RsQtVersion.h" #include "retroshare/rsfiles.h" #include "retroshare/rsconfig.h" diff --git a/retroshare-gui/src/gui/RSHumanReadableDelegate.h b/retroshare-gui/src/gui/RSHumanReadableDelegate.h index 1b3995cd7..1688ce782 100644 --- a/retroshare-gui/src/gui/RSHumanReadableDelegate.h +++ b/retroshare-gui/src/gui/RSHumanReadableDelegate.h @@ -54,7 +54,7 @@ class RSHumanReadableDelegate: public QAbstractItemDelegate // This part of the code is copied from DLListDelegate.cpp // QPalette::ColorGroup cg = option.state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled; - QVariant value = index.data(Qt::TextColorRole); + QVariant value = index.data(Qt::ForegroundRole); if(value.isValid() && qvariant_cast(value).isValid()) option.palette.setColor(QPalette::Text, qvariant_cast(value)); @@ -75,7 +75,7 @@ class RSHumanReadableDelegate: public QAbstractItemDelegate } else { - value = index.data(Qt::BackgroundColorRole); + value = index.data(Qt::BackgroundRole); if(value.isValid() && qvariant_cast(value).isValid()) painter->fillRect(option.rect, qvariant_cast(value)); diff --git a/retroshare-gui/src/gui/RemoteDirModel.cpp b/retroshare-gui/src/gui/RemoteDirModel.cpp index 962001a76..14cf490a9 100644 --- a/retroshare-gui/src/gui/RemoteDirModel.cpp +++ b/retroshare-gui/src/gui/RemoteDirModel.cpp @@ -825,7 +825,7 @@ QVariant RetroshareDirModel::data(const QModelIndex &index, int role) const if (role == RetroshareDirModel::FileNameRole) /* end of FileNameRole */ return QString::fromUtf8(details.name.c_str()) ; - if (role == Qt::TextColorRole) + if (role == Qt::ForegroundRole) { if((details.type == DIR_TYPE_FILE || details.type == DIR_TYPE_EXTRA_FILE) && details.hash.isNull()) return QVariant(QColor(Qt::green)) ; diff --git a/retroshare-gui/src/gui/RetroShareLink.cpp b/retroshare-gui/src/gui/RetroShareLink.cpp index 0001cd9bc..a22f9ced8 100644 --- a/retroshare-gui/src/gui/RetroShareLink.cpp +++ b/retroshare-gui/src/gui/RetroShareLink.cpp @@ -41,7 +41,6 @@ #include #include #include -#include #include #include @@ -1758,7 +1757,7 @@ static void processList(const QStringList &list, const QString &textSingular, co } else { - ChatDialog* chatDialog = ChatDialog::getChat(chatId, Settings->getChatFlags()); + ChatDialog* chatDialog = ChatDialog::getChat(chatId, (RsChatFlags)Settings->getChatFlags()); if (chatDialog) { chatroomFound.append(link.name()); } else { diff --git a/retroshare-gui/src/gui/RsGUIEventManager.cpp b/retroshare-gui/src/gui/RsGUIEventManager.cpp new file mode 100644 index 000000000..82d66e799 --- /dev/null +++ b/retroshare-gui/src/gui/RsGUIEventManager.cpp @@ -0,0 +1,741 @@ +/******************************************************************************* + * gui/RsGUIEventManager.cpp * + * * + * Copyright (c) 2010 Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#include "gui/common/FilesDefs.h" +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include "rshare.h" +#include "MainWindow.h" +#include "toaster/OnlineToaster.h" +#include "toaster/MessageToaster.h" +#include "toaster/DownloadToaster.h" +#include "toaster/ChatToaster.h" +#include "toaster/GroupChatToaster.h" +#include "toaster/ChatLobbyToaster.h" +#include "toaster/FriendRequestToaster.h" +#include "toaster/ToasterItem.h" +#include "common/ToasterNotify.h" +#include "RsGUIEventManager.h" + +#include "chat/ChatDialog.h" +#include "chat/ChatLobbyDialog.h" +#include "chat/ChatWidget.h" +#include "FriendsDialog.h" +#include "gui/settings/rsharesettings.h" +#include "SoundManager.h" + +#include "retroshare/rsplugin.h" + +#include +#include +//#include +#include +#include + +/***** + * #define NOTIFY_DEBUG + ****/ + +/*static*/ RsGUIEventManager *RsGUIEventManager::_instance = nullptr; +/*static*/ bool RsGUIEventManager::_disableAllToaster = false; + +/*static*/ void RsGUIEventManager::Create () +{ + if (_instance == nullptr) + _instance = new RsGUIEventManager (); +} + +/*static*/ RsGUIEventManager *RsGUIEventManager::getInstance () +{ + return _instance; +} + +/*static*/ bool RsGUIEventManager::isAllDisable () +{ + return _disableAllToaster; +} + +void RsGUIEventManager::SetDisableAll(bool bValue) +{ + if (bValue!=_disableAllToaster) + { + _disableAllToaster=bValue; + emit disableAllChanged(bValue); + } +} + +RsGUIEventManager::RsGUIEventManager() : cDialog(NULL) +{ + runningToasterTimer = new QTimer(this); + connect(runningToasterTimer, SIGNAL(timeout()), this, SLOT(runningTick())); + runningToasterTimer->setInterval(10); // tick 100 times a second + runningToasterTimer->setSingleShot(true); + { + QMutexLocker m(&_mutex) ; + _enabled = false ; + } + +#warning TODO: do we need a timer anymore?? + + // Catch all events that require toasters and + + mEventHandlerId = 0; + rsEvents->registerEventsHandler( [this](std::shared_ptr event) + { + if(event->mType == RsEventType::SYSTEM + && (dynamic_cast(event.get())->mEventCode == RsSystemEventCode::PASSWORD_REQUESTED + ||dynamic_cast(event.get())->mEventCode == RsSystemEventCode::NEW_PLUGIN_FOUND)) + + sync_handleIncomingEvent(event); + else + RsQThreadUtils::postToObject([=](){ async_handleIncomingEvent(event); }, this ); + }, mEventHandlerId); // No event type means we expect to catch all possible events +} + +bool RsGUIEventManager::GUI_askForPassword(const std::string& title, const std::string& key_details, bool prev_is_bad) +{ + RsAutoUpdatePage::lockAllEvents() ; + + QString windowTitle; + if (title == "") + windowTitle = tr("Passphrase required"); + else if (title == "AuthSSLimpl::SignX509ReqWithGPG()") + windowTitle = tr("You need to sign your node's certificate."); + else if (title == "p3IdService::service_CreateGroup()") + windowTitle = tr("You need to sign your forum/chatrooms identity."); + else + windowTitle = QString::fromStdString(title); + + QString labelText = ( prev_is_bad ? QString("%1

").arg(tr("Wrong password !")) : QString() ) + + QString("%1
Profile: %2\n") + .arg( tr("Please enter your Retroshare passphrase") + , QString::fromUtf8(key_details.c_str()) ); + + QLineEdit::EchoMode textEchoMode = QLineEdit::Password; + bool modal = true; + + bool sameThread = QThread::currentThread() == qApp->thread(); + Gui_InputDialogReturn ret; + qRegisterMetaType("Gui_InputDialogReturn"); + QMetaObject::invokeMethod( MainWindow::getInstance() + , "guiInputDialog" + , sameThread ? Qt::DirectConnection : Qt::BlockingQueuedConnection + , Q_RETURN_ARG(Gui_InputDialogReturn, ret) + , Q_ARG(QString, windowTitle) + , Q_ARG(QString, labelText) + , Q_ARG(QLineEdit::EchoMode, textEchoMode) + , Q_ARG(bool, modal) + ); + //cancelled = false ; + + RsAutoUpdatePage::unlockAllEvents() ; + + if (ret.execReturn == QDialog::Rejected) { + RsLoginHelper::clearPgpPassphrase(); + //cancelled = true ; + return true ; + } + + if (ret.execReturn == QDialog::Accepted) { + auto password = ret.textValue.toUtf8().constData(); + RsLoginHelper::cachePgpPassphrase(password); + return true; + } + + RsLoginHelper::clearPgpPassphrase(); + return false; +} +bool RsGUIEventManager::GUI_askForPluginConfirmation(const std::string& plugin_file_name, const RsFileHash& plugin_file_hash, bool first_time) +{ + // By default, when no information is known about plugins, just dont load them. They will be enabled from the GUI by the user. + // Note: the code below is not running in the Qt thread, which is likely to cause a crash. If needed, we should use + // the same mechanism than GUI_askForPassword. As far as testing goes, it seems that because there is no other window running + // at the time plugin confirmation is required, this is not a problem for Qt. + + if(first_time) + return false ; + + RsAutoUpdatePage::lockAllEvents() ; + + QMessageBox dialog; + dialog.setWindowTitle(tr("Unregistered plugin/executable")); + + QString text ; + text += tr( "RetroShare has detected an unregistered plugin. This happens in two cases:

  • Your RetroShare executable has changed.
  • The plugin has changed
Click on Yes to authorize this plugin, or No to deny it. You can change your mind later in Options -> Plugins, then restart." ) ; + text += "
    " ; + text += "
  • Hash:\t" + QString::fromStdString(plugin_file_hash.toStdString()) + "
  • " ; + text += "
  • File:\t" + QString::fromStdString(plugin_file_name) + "
  • "; + text += "
" ; + + dialog.setText(text) ; + dialog.setWindowIcon(FilesDefs::getIconFromQtResourcePath(":/icons/logo_128.png")); + dialog.setStandardButtons(QMessageBox::Yes | QMessageBox::No) ; + + int ret = dialog.exec(); + + RsAutoUpdatePage::unlockAllEvents() ; + + if (ret == QMessageBox::Yes) + { + rsPlugins->enablePlugin(plugin_file_hash); + return true; + } + else + { + rsPlugins->disablePlugin(plugin_file_hash); + return false; + } +} + +void RsGUIEventManager::enable() +{ + QMutexLocker m(&_mutex) ; + std::cerr << "Enabling notification system" << std::endl; + _enabled = true ; +} + +void RsGUIEventManager::sync_handleIncomingEvent(std::shared_ptr event) +{ + auto ev6 = dynamic_cast(event.get()); + + if(ev6->mEventCode == RsSystemEventCode::PASSWORD_REQUESTED) + GUI_askForPassword(ev6->passwd_request_title, ev6->passwd_request_key_details, ev6->passwd_request_prev_is_bad); + else if(ev6->mEventCode == RsSystemEventCode::NEW_PLUGIN_FOUND) + GUI_askForPluginConfirmation(ev6->plugin_file_name, ev6->plugin_file_hash, ev6->plugin_first_time); +} + +void RsGUIEventManager::async_handleIncomingEvent(std::shared_ptr event) +{ + /* Finally Check for PopupMessages / System Error Messages */ + + RsNotifyPopupFlags popupflags = (RsNotifyPopupFlags)Settings->getNotifyFlags(); + + auto insertToaster = [this](ToasterItem *toaster) { + + /* init attributes */ + toaster->widget->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint); + + /* add toaster to waiting list */ + waitingToasterList.push_back(toaster); + }; + + // check for all possibly handled events + + auto ev1 = dynamic_cast(event.get()); + + if(ev1) + { + if(ev1->mMailStatusEventCode == RsMailStatusEventCode::NEW_MESSAGE) + { + SoundManager::play(SOUND_MESSAGE_ARRIVED); + + if((!!(popupflags & RsNotifyPopupFlags::RS_POPUP_MSG)) && !_disableAllToaster) + { + for(auto msgid:ev1->mChangedMsgIds) + { + Rs::Msgs::MessageInfo msgInfo; + if(rsMsgs->getMessage(msgid, msgInfo)) + insertToaster(new ToasterItem(new MessageToaster(msgInfo.from.toStdString(), QString::fromUtf8(msgInfo.title.c_str()), QString::fromUtf8(msgInfo.msg.c_str())))); + } + } + } + return; + } + + auto ev2 = dynamic_cast(event.get()); + + if(ev2) + { + if(ev2->mEventCode == RsFriendListEventCode::NODE_CONNECTED) + { + SoundManager::play(SOUND_USER_ONLINE); + + if ((!!(popupflags & RsNotifyPopupFlags::RS_POPUP_CONNECT)) && !_disableAllToaster) + insertToaster(new ToasterItem(new OnlineToaster(ev2->mSslId))); + } + return; + } + + auto ev3 = dynamic_cast(event.get()); + + if(ev3) + { + if(ev3->mFileTransferEventCode == RsFileTransferEventCode::DOWNLOAD_COMPLETE) + { + SoundManager::play(SOUND_DOWNLOAD_COMPLETE); + + if ((!!(popupflags & RsNotifyPopupFlags::RS_POPUP_DOWNLOAD)) && !_disableAllToaster) + insertToaster(new ToasterItem(new DownloadToaster(ev3->mHash))); + } + return; + } + + auto ev4 = dynamic_cast(event.get()); + + if(ev4) + { + if(ev4->mErrorCode == RsAuthSslError::NOT_A_FRIEND) + { + if ((!!(popupflags & RsNotifyPopupFlags::RS_POPUP_CONNECT_ATTEMPT)) && !_disableAllToaster) + // id = gpgid + // title = ssl name + // msg = peer id + insertToaster(new ToasterItem(new FriendRequestToaster(ev4->mPgpId, ev4->mSslId))); + } + return; + } + + auto ev5 = dynamic_cast(event.get()); + + if(ev5) + { + // This code below should be simplified. In particular GroupChatToaster, ChatToaster and ChatLobbyToaster should be only one class. + + if(ev5->mEventCode == RsChatServiceEventCode::CHAT_MESSAGE_RECEIVED) + { + if (ev5->mCid.isPeerId() && (!!(popupflags & RsNotifyPopupFlags::RS_POPUP_CHAT)) && !_disableAllToaster) + { + // TODO: fix for distant chat, look up if dstant chat uses RS_POPUP_CHAT + ChatDialog *chatDialog = ChatDialog::getChat(ev5->mCid); + ChatWidget *chatWidget; + + if (chatDialog && (chatWidget = chatDialog->getChatWidget()) && chatWidget->isActive()) // do not show when active + return; + + insertToaster(new ToasterItem(new ChatToaster(ev5->mCid.toPeerId(), QString::fromUtf8(ev5->mMsg.msg.c_str())))); + } +#ifdef RS_DIRECT_CHAT + else if (ev5->mCid.isBroadcast() && (!!(popupflags & RsNotifyPopupFlags::RS_POPUP_GROUPCHAT)) && !_disableAllToaster) + { + MainWindow *mainWindow = MainWindow::getInstance(); + if (mainWindow && mainWindow->isActiveWindow() && !mainWindow->isMinimized() + && (MainWindow::getActivatePage() == MainWindow::Friends) && (FriendsDialog::isGroupChatActive())) + return; + + insertToaster(new ToasterItem(new GroupChatToaster(ev5->mCid.toPeerId(), QString::fromUtf8(ev5->mMsg.msg.c_str())))); + } +#endif + else if (ev5->mCid.isLobbyId() && (!!(popupflags & RsNotifyPopupFlags::RS_POPUP_CHATLOBBY)) && !_disableAllToaster) + { + ChatDialog *chatDialog = ChatDialog::getChat(ev5->mCid); + ChatWidget *chatWidget; + + if (chatDialog && (chatWidget = chatDialog->getChatWidget()) && chatWidget->isActive()) + return; + + ChatLobbyDialog *chatLobbyDialog = dynamic_cast(chatDialog); + + if (!chatLobbyDialog || chatLobbyDialog->isParticipantMuted(ev5->mMsg.lobby_peer_gxs_id)) + return; + + insertToaster(new ToasterItem(new ChatLobbyToaster(ev5->mCid.toLobbyId(), ev5->mMsg.lobby_peer_gxs_id, QString::fromUtf8(ev5->mMsg.msg.c_str())))); + } + else + return; + } + + return; + } + + auto ev6 = dynamic_cast(event.get()); + + if(ev6) + { + switch(ev6->mEventCode) + { + case RsSystemEventCode::TIME_SHIFT_PROBLEM: + displayErrorMessage(RsNotifySysFlags::RS_SYS_WARNING,tr("System time mismatch"),tr("Time shift problem notification. Make sure your machine is on time, because it will break chat rooms.")); + break; + + case RsSystemEventCode::DISK_SPACE_ERROR: + displayDiskSpaceWarning(ev6->mDiskErrorLocation,ev6->mDiskErrorSizeLimit); + break; + + case RsSystemEventCode::DATA_STREAMING_ERROR: + case RsSystemEventCode::GENERAL_ERROR: + displayErrorMessage(RsNotifySysFlags::RS_SYS_WARNING,tr("Internal error"),QString::fromUtf8(ev6->mErrorMsg.c_str())); + break; + default: break; + } + return; + }; + + + /*Now check Plugins*/ + + if(rsPlugins) // rsPlugins may not be initialized yet if we're handlign TorManager events. + { + int pluginCount = rsPlugins->nbPlugins(); + + for (int i = 0; i < pluginCount; ++i) { + RsPlugin *rsPlugin = rsPlugins->plugin(i); + if (rsPlugin) { + ToasterNotify *toasterNotify = rsPlugin->qt_toasterNotify(); + if (toasterNotify) { + insertToaster(toasterNotify->toasterItem()); + continue; + } + } + } + } + + /* Now start the waiting toasters */ + startWaitingToasters(); +} + +void RsGUIEventManager::testToasters(RsNotifyPopupFlags notifyFlags, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin) +{ + QString title = tr("Test"); + QString message = tr("This is a test."); + + RsPeerId id = rsPeers->getOwnId(); + RsPgpId pgpid = rsPeers->getGPGOwnId(); + + uint pos = 0; + uint nf = (uint)notifyFlags; + + while (nf) { + uint type = nf & (1 << pos); + nf &= ~(1 << pos); + ++pos; + + ToasterItem *toaster = NULL; + + switch(type) + { + case (int)RsNotifyPopupFlags::RS_POPUP_ENCRYPTED_MSG: + toaster = new ToasterItem(new MessageToaster(std::string(), tr("Unknown title"), QString("[%1]").arg(tr("Encrypted message")))); + break; + case (int)RsNotifyPopupFlags::RS_POPUP_MSG: + toaster = new ToasterItem(new MessageToaster(id.toStdString(), title, message)); + break; + case (int)RsNotifyPopupFlags::RS_POPUP_CONNECT: + toaster = new ToasterItem(new OnlineToaster(id)); + break; + case (int)RsNotifyPopupFlags::RS_POPUP_DOWNLOAD: + toaster = new ToasterItem(new DownloadToaster(RsFileHash::random())); + break; + case (int)RsNotifyPopupFlags::RS_POPUP_CHAT: + toaster = new ToasterItem(new ChatToaster(id, message)); + break; + case (int)RsNotifyPopupFlags::RS_POPUP_GROUPCHAT: +#ifdef RS_DIRECT_CHAT + toaster = new ToasterItem(new GroupChatToaster(id, message)); +#endif // RS_DIRECT_CHAT + break; + case (int)RsNotifyPopupFlags::RS_POPUP_CHATLOBBY: + { + std::list gxsid; + if(rsIdentity->getOwnIds(gxsid) && (gxsid.size() > 0)){ + toaster = new ToasterItem(new ChatLobbyToaster(0, gxsid.front(), message)); + } + break; + } + case (int)RsNotifyPopupFlags::RS_POPUP_CONNECT_ATTEMPT: + toaster = new ToasterItem(new FriendRequestToaster(pgpid, id)); + break; + } + + if (toaster) { + /* init attributes */ + toaster->widget->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint); + toaster->position = (RshareSettings::enumToasterPosition) position; + toaster->margin = margin; + + /* add toaster to waiting list */ + + waitingToasterList.push_back(toaster); + } + } +} + +void RsGUIEventManager::testToaster(ToasterNotify *toasterNotify, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin) +{ + + if (!toasterNotify) { + return; + } + + ToasterItem *toaster = toasterNotify->testToasterItem(); + + if (toaster) { + /* init attributes */ + toaster->widget->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint); + toaster->position = (RshareSettings::enumToasterPosition) position; + toaster->margin = margin; + + /* add toaster to waiting list */ + //QMutexLocker lock(&waitingToasterMutex); + waitingToasterList.push_back(toaster); + } +} + +void RsGUIEventManager::testToaster(QString tag, ToasterNotify *toasterNotify, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin) +{ + + if (!toasterNotify) { + return; + } + + ToasterItem *toaster = toasterNotify->testToasterItem(tag); + + if (toaster) { + /* init attributes */ + toaster->widget->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint); + toaster->position = (RshareSettings::enumToasterPosition) position; + toaster->margin = margin; + + /* add toaster to waiting list */ + + waitingToasterList.push_back(toaster); + } +} + +void RsGUIEventManager::notifyChatFontChanged() +{ + { + QMutexLocker m(&_mutex) ; + if(!_enabled) + return ; + } + + emit chatFontChanged(); +} +void RsGUIEventManager::notifyChatStyleChanged(int /*ChatStyle::enumStyleType*/ styleType) +{ + { + QMutexLocker m(&_mutex) ; + if(!_enabled) + return ; + } + + emit chatStyleChanged(styleType); +} + +void RsGUIEventManager::notifySettingsChanged() +{ + emit settingsChanged(); +} + +void RsGUIEventManager::startWaitingToasters() +{ + { + if (waitingToasterList.empty()) { + /* No toasters are waiting */ + return; + } + } + + { + if (runningToasterList.size() >= 3) { + /* Don't show more than 3 toasters at once */ + return; + } + } + + ToasterItem *toaster = NULL; + + { + if (waitingToasterList.size()) { + /* Take one toaster of the waiting list */ + toaster = waitingToasterList.front(); + waitingToasterList.pop_front(); + } + } + + if (toaster) { + + /* Calculate positions */ + QSize size = toaster->widget->size(); + + QRect desktopGeometry = RsApplication::primaryScreenGeometry(); + + switch (toaster->position) { + case RshareSettings::TOASTERPOS_TOPLEFT: + toaster->startPos = QPoint(desktopGeometry.left() + toaster->margin.x(), desktopGeometry.top() - size.height()); + toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.top() + toaster->margin.y()); + break; + case RshareSettings::TOASTERPOS_TOPRIGHT: + toaster->startPos = QPoint(desktopGeometry.right() - size.width() - toaster->margin.x(), desktopGeometry.top() - size.height()); + toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.top() + toaster->margin.y()); + break; + case RshareSettings::TOASTERPOS_BOTTOMLEFT: + toaster->startPos = QPoint(desktopGeometry.left() + toaster->margin.x(), desktopGeometry.bottom()); + toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.bottom() - size.height() - toaster->margin.y()); + break; + case RshareSettings::TOASTERPOS_BOTTOMRIGHT: // default + default: + toaster->startPos = QPoint(desktopGeometry.right() - size.width() - toaster->margin.x(), desktopGeometry.bottom()); + toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.bottom() - size.height() - toaster->margin.y()); + break; + } + + /* Initialize widget */ + toaster->widget->move(toaster->startPos); + + /* Initialize toaster */ + toaster->elapsedTimeToShow = 0; + toaster->elapsedTimeToLive = 0; + toaster->elapsedTimeToHide = 0; + + /* Add toaster to the running list */ + runningToasterList.push_front(toaster); + if (runningToasterTimer->isActive() == false) { + /* Start the toaster timer */ + runningToasterTimer->start(); + } + } +} + +void RsGUIEventManager::runningTick() +{ + //QMutexLocker lock(&runningToasterMutex); + + int interval = runningToasterTimer->interval(); + QPoint diff; + + QList::iterator it = runningToasterList.begin(); + while (it != runningToasterList.end()) { + ToasterItem *toaster = *it; + + bool visible = true; + if (toaster->elapsedTimeToShow) { + /* Toaster is started, check for visible */ + visible = toaster->widget->isVisible(); + } + + QPoint newPos; + enum { NOTHING, SHOW, HIDE } operation = NOTHING; + + if (visible && toaster->elapsedTimeToShow <= toaster->timeToShow) { + /* Toaster is showing */ + if (toaster->elapsedTimeToShow == 0) { + /* Toaster is not visible, show it now */ + operation = SHOW; + } + + toaster->elapsedTimeToShow += interval; + + newPos = QPoint(toaster->startPos.x() - (toaster->startPos.x() - toaster->endPos.x()) * toaster->elapsedTimeToShow / toaster->timeToShow, + toaster->startPos.y() - (toaster->startPos.y() - toaster->endPos.y()) * toaster->elapsedTimeToShow / toaster->timeToShow); + } else if (visible && toaster->elapsedTimeToLive <= toaster->timeToLive) { + /* Toaster is living */ + toaster->elapsedTimeToLive += interval; + + newPos = toaster->endPos; + } else if (visible && toaster->elapsedTimeToHide <= toaster->timeToHide) { + /* Toaster is hiding */ + toaster->elapsedTimeToHide += interval; + + if (toaster->elapsedTimeToHide == toaster->timeToHide) { + /* Toaster is back at the start position, hide it */ + operation = HIDE; + } + + newPos = QPoint(toaster->startPos.x() - (toaster->startPos.x() - toaster->endPos.x()) * (toaster->timeToHide - toaster->elapsedTimeToHide) / toaster->timeToHide, + toaster->startPos.y() - (toaster->startPos.y() - toaster->endPos.y()) * (toaster->timeToHide - toaster->elapsedTimeToHide) / toaster->timeToHide); + } else { + /* Toaster is hidden, delete it */ + it = runningToasterList.erase(it); + //delete(toaster->widget); + delete(toaster); + continue; + } + + toaster->widget->move(newPos + diff); + diff += newPos - toaster->startPos; + + QRect mask = QRect(0, 0, toaster->widget->width(), qAbs(toaster->startPos.y() - newPos.y())); + if (newPos.y() > toaster->startPos.y()) { + /* Toaster is moving from top */ + mask.moveTop(toaster->widget->height() - (newPos.y() - toaster->startPos.y())); + } + toaster->widget->setMask(QRegion(mask)); + + switch (operation) { + case NOTHING: + break; + case SHOW: + toaster->widget->show(); + break; + case HIDE: + toaster->widget->hide(); + break; + } + + ++it; + } + + if (runningToasterList.size()) { + /* There are more running toasters, start the timer again */ + runningToasterTimer->start(); + } +} + +void RsGUIEventManager::displayErrorMessage(RsNotifySysFlags type,const QString& title,const QString& error_msg) +{ + /* make a warning message */ + switch(type) + { + case RsNotifySysFlags::RS_SYS_ERROR: QMessageBox::critical(MainWindow::getInstance(),title,error_msg); + break; + + case RsNotifySysFlags::RS_SYS_WARNING: QMessageBox::warning(MainWindow::getInstance(),title,error_msg); + break; + + case RsNotifySysFlags::RS_SYS_INFO: QMessageBox::information(MainWindow::getInstance(),title,error_msg); + break; + + default: std::cerr << "Warning: unhandled system error type " << type << std::endl; + break; + } +} + +void RsGUIEventManager::displayDiskSpaceWarning(int loc,int size_limit_mb) +{ + QString locString ; + switch(loc) + { + case RS_PARTIALS_DIRECTORY: locString = "Partials" ; + break ; + + case RS_CONFIG_DIRECTORY: locString = "Config" ; + break ; + + case RS_DOWNLOAD_DIRECTORY: locString = "Download" ; + break ; + + default: + std::cerr << "Error: " << __PRETTY_FUNCTION__ << " was called with an unknown parameter loc=" << loc << std::endl ; + return ; + } + QMessageBox::critical(NULL,tr("Low disk space warning"), + tr("The disk space in your")+" "+locString +" "+tr("directory is running low (current limit is")+" "+QString::number(size_limit_mb)+tr("MB). \n\n RetroShare will now safely suspend any disk access to this directory. \n\n Please make some free space and click Ok.")) ; +} + diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/RsGUIEventManager.h similarity index 50% rename from retroshare-gui/src/gui/notifyqt.h rename to retroshare-gui/src/gui/RsGUIEventManager.h index 5782ef5b7..2ae4ab464 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/RsGUIEventManager.h @@ -1,5 +1,5 @@ /******************************************************************************* - * gui/NotifyQt.h * + * gui/RsGUIEventManager.h * * * * Copyright (c) 2010 Retroshare Team * * * @@ -23,13 +23,14 @@ #include #include -#include #include #include #include #include //#include +#include "settings/rsharesettings.h" + #include class QTimer; @@ -47,92 +48,40 @@ class SignatureEventData ; struct TurtleFileInfo; struct TurtleGxsInfo; -class NotifyQt: public QObject, public NotifyClient +class RsGUIEventManager: public QObject { Q_OBJECT public: - static NotifyQt *Create (); - static NotifyQt *getInstance (); + static void Create(); + static RsGUIEventManager *getInstance (); static bool isAllDisable(); void enable() ; - virtual ~NotifyQt() = default; + virtual ~RsGUIEventManager() = default; - void setNetworkDialog(NetworkDialog *c) { cDialog = c; } - - virtual void notifyListPreChange(int list, int type); - virtual void notifyListChange(int list, int type); - virtual void notifyErrorMsg(int list, int sev, std::string msg); - virtual void notifyChatMessage(const ChatMessage& /* msg */); - virtual void notifyChatStatus(const ChatId &chat_id,const std::string& status_string); - virtual void notifyChatCleared(const ChatId &chat_id); - virtual void notifyCustomState(const std::string& peer_id, const std::string& status_string); -#ifdef TO_REMOVE - virtual void notifyTurtleSearchResult(const RsPeerId &pid, uint32_t search_id, const std::list& found_files); -#endif - virtual void notifyTurtleSearchResult(uint32_t search_id,const std::list& found_groups); - virtual void notifyPeerHasNewAvatar(std::string peer_id) ; - virtual void notifyOwnAvatarChanged() ; - virtual void notifyChatLobbyEvent(uint64_t /* lobby id */, uint32_t /* event type */, const RsGxsId & /*nickname*/, const std::string& /* any string */) ; - virtual void notifyChatLobbyTimeShift(int time_shift) ; - - virtual void notifyOwnStatusMessageChanged() ; - virtual void notifyDiskFull(uint32_t loc,uint32_t size_in_mb) ; - /* peer has changed the state */ - virtual void notifyPeerStatusChanged(const std::string& peer_id, uint32_t state); - /* one or more peers has changed the states */ - virtual void notifyPeerStatusChangedSummary(); - - virtual void notifyHistoryChanged(uint32_t msgId, int type); - - virtual void notifyDiscInfoChanged() ; - virtual bool askForPassword(const std::string& title, const std::string& key_details, bool prev_is_bad, std::string& password, bool &cancelled); - virtual bool askForPluginConfirmation(const std::string& plugin_filename, const std::string& plugin_file_hash,bool first_time); + virtual bool GUI_askForPassword(const std::string& title, const std::string& key_details, bool prev_is_bad); + virtual bool GUI_askForPluginConfirmation(const std::string& plugin_filename, const RsFileHash& plugin_file_hash,bool first_time); /* Notify from GUI */ void notifyChatFontChanged(); void notifyChatStyleChanged(int /*ChatStyle::enumStyleType*/ styleType); - void testToasters(uint notifyFlags, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin); + void testToasters(RsNotifyPopupFlags notifyFlags, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin); void testToaster(ToasterNotify *toasterNotify, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin); void testToaster(QString tag, ToasterNotify *toasterNotify, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin); - +#ifdef TO_REMOVE void addToaster(uint notifyFlags, const std::string& id, const std::string& title, const std::string& msg); +#endif void notifySettingsChanged(); signals: // It's beneficial to send info to the GUI using signals, because signals are thread-safe // as they get queued by Qt. // - void hashingInfoChanged(const QString&) const ; - void filesPreModChanged(bool) const ; - void filesPostModChanged(bool) const ; - void transfersChanged() const ; - void friendsChanged() const ; - void lobbyListChanged() const ; - void chatLobbyEvent(qulonglong,int,const RsGxsId&,const QString&) ; - void neighboursChanged() const ; void configChanged() const ; void logInfoChanged(const QString&) const ; - void chatStatusChanged(const ChatId&,const QString&) const ; void chatCleared(const ChatId&) const ; - void peerHasNewCustomStateString(const QString& /* peer_id */, const QString& /* status_string */) const ; - void peerHasNewAvatar(const QString& peer_id) const ; - void ownAvatarChanged() const ; - void ownStatusMessageChanged() const ; - void errorOccurred(int,int,const QString&) const ; - void diskFull(int,int) const ; - void peerStatusChanged(const QString& /* peer_id */, int /* status */); - void peerStatusChangedSummary() const; - void gxsChange(const RsGxsChanges& /* changes */); - void chatMessageReceived(ChatMessage msg); - void groupsChanged(int type) const ; - void discInfoChanged() const ; void historyChanged(uint msgId, int type); - void chatLobbyInviteReceived() ; - void deferredSignatureHandlingRequested() ; - void chatLobbyTimeShift(int time_shift) ; - void connectionWithoutCert(); /* Notify from GUI */ void chatFontChanged(); @@ -141,25 +90,24 @@ class NotifyQt: public QObject, public NotifyClient void disableAllChanged(bool disableAll) const; public slots: - void UpdateGUI(); /* called by timer */ void SetDisableAll(bool bValue); private slots: void runningTick(); - void handleSignatureEvent() ; - void handleChatLobbyTimeShift(int) ; private: - NotifyQt(); + RsGUIEventManager(); - static NotifyQt *_instance; + static void displayDiskSpaceWarning(int loc,int size_limit_mb); + static void displayErrorMessage(RsNotifySysFlags type,const QString& title,const QString& error_msg); + + static RsGUIEventManager *_instance; static bool _disableAllToaster; /* system notifications */ void startWaitingToasters(); -// QMutex waitingToasterMutex; // for lock of the waiting toaster list QList waitingToasterList; QTimer *runningToasterTimer; @@ -172,6 +120,11 @@ class NotifyQt: public QObject, public NotifyClient /* so we can update windows */ NetworkDialog *cDialog; + + void async_handleIncomingEvent(std::shared_ptr e); + void sync_handleIncomingEvent(std::shared_ptr e); + + RsEventsHandlerId_t mEventHandlerId; }; #endif diff --git a/retroshare-gui/src/gui/ShareManager.cpp b/retroshare-gui/src/gui/ShareManager.cpp index 6681e30c5..d4426d3ae 100644 --- a/retroshare-gui/src/gui/ShareManager.cpp +++ b/retroshare-gui/src/gui/ShareManager.cpp @@ -35,9 +35,9 @@ #include "gui/common/GroupFlagsWidget.h" #include "gui/common/GroupSelectionBox.h" #include "gui/common/GroupDefs.h" -#include "gui/notifyqt.h" -#include "util/QtVersion.h" +#include "util/RsQtVersion.h" #include "util/misc.h" +#include "util/qtthreadsutils.h" #include "gui/common/FilesDefs.h" /* Images for context menu icons */ @@ -73,7 +73,21 @@ ShareManager::ShareManager() connect(ui.shareddirList, SIGNAL(cellDoubleClicked(int,int)), this, SLOT(doubleClickedCell(int,int))); connect(ui.shareddirList, SIGNAL(cellChanged(int,int)), this, SLOT(handleCellChange(int,int))); - connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(reload())); + mEventHandlerId = 0; + + rsEvents->registerEventsHandler( [this](std::shared_ptr e) + { + RsQThreadUtils::postToObject([=]() + { + auto fe = dynamic_cast(e.get()); + + if(!fe) + return; + + reload(); + } + , this ); + }, mEventHandlerId, RsEventType::FRIEND_LIST ); QHeaderView* header = ui.shareddirList->horizontalHeader(); QHeaderView_setSectionResizeModeColumn(header, COLUMN_PATH, QHeaderView::Stretch); @@ -152,6 +166,7 @@ ShareManager::~ShareManager() { _instance = NULL; + rsEvents->unregisterEventsHandler(mEventHandlerId); Settings->saveWidgetInformation(this); } @@ -242,7 +257,7 @@ void ShareManager::load() listWidget->setCellWidget(row, COLUMN_SHARE_FLAGS, widget); listWidget->setItem(row, COLUMN_GROUPS, new QTableWidgetItem()) ; - listWidget->item(row,COLUMN_GROUPS)->setBackgroundColor(QColor(183,236,181)) ; + listWidget->item(row,COLUMN_GROUPS)->setBackground(QColor(183,236,181)) ; connect(widget,SIGNAL(flagsChanged(FileStorageFlags)),this,SLOT(updateFlags())) ; diff --git a/retroshare-gui/src/gui/ShareManager.h b/retroshare-gui/src/gui/ShareManager.h index 1ddfaa0a9..b6d579894 100644 --- a/retroshare-gui/src/gui/ShareManager.h +++ b/retroshare-gui/src/gui/ShareManager.h @@ -77,6 +77,7 @@ private: Ui::ShareManager ui; std::vector mDirInfos ; + RsEventsHandlerId_t mEventHandlerId; }; #endif diff --git a/retroshare-gui/src/gui/SoundManager.cpp b/retroshare-gui/src/gui/SoundManager.cpp index 69ba9e64b..3fc60dd87 100644 --- a/retroshare-gui/src/gui/SoundManager.cpp +++ b/retroshare-gui/src/gui/SoundManager.cpp @@ -21,12 +21,22 @@ #include #include #include -#include #include +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) +#include +#include +#include +#elif QT_VERSION >= QT_VERSION_CHECK (5, 0, 0) +#include +#endif + +#if QT_VERSION < QT_VERSION_CHECK (6, 0, 0) +#include +#endif + #if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0) #include -#include #endif // #ifdef QMEDIAPLAYER @@ -241,15 +251,25 @@ void SoundManager::playFile(const QString &filename) QString playFilename = realFilename(filename); bool played = false ; - -#if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0) + +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) + if (!QMediaDevices::audioOutputs().isEmpty()) +#elif QT_VERSION >= QT_VERSION_CHECK (5, 0, 0) if (!QAudioDeviceInfo::availableDevices(QAudio::AudioOutput).isEmpty()) #else if (QSound::isAvailable()) #endif { +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) + if (soundManager) { + soundManager->mSoundEffect.setSource(QUrl::fromLocalFile(playFilename)); + soundManager->mSoundEffect.play(); + played = true; + } +#else QSound::play(playFilename); played = true ; +#endif } if(!played) // let's go for the hard core stuff diff --git a/retroshare-gui/src/gui/SoundManager.h b/retroshare-gui/src/gui/SoundManager.h index 41db55ce4..eeceb3048 100644 --- a/retroshare-gui/src/gui/SoundManager.h +++ b/retroshare-gui/src/gui/SoundManager.h @@ -24,6 +24,10 @@ #include #include +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) +#include +#endif + #define SOUND_NEW_CHAT_MESSAGE "NewChatMessage" #define SOUND_USER_ONLINE "User_go_Online" #define SOUND_MESSAGE_ARRIVED "MessageArrived" @@ -91,6 +95,10 @@ public: private: SoundManager(); + +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) + QSoundEffect mSoundEffect; +#endif }; extern SoundManager *soundManager; diff --git a/retroshare-gui/src/gui/StartDialog.cpp b/retroshare-gui/src/gui/StartDialog.cpp index 237d1bb83..f52179c39 100644 --- a/retroshare-gui/src/gui/StartDialog.cpp +++ b/retroshare-gui/src/gui/StartDialog.cpp @@ -25,11 +25,9 @@ #include "settings/rsharesettings.h" #include "retroshare/rsinit.h" -#include "retroshare/rsnotify.h" #include #include -#include #include @@ -49,7 +47,7 @@ StartDialog::StartDialog(QWidget *parent) Settings->loadWidgetInformation(this); /* Put the Login dialog in the screen center */ - const QRect screen = QApplication::desktop()->screenGeometry(); + const QRect screen = RsApplication::primaryScreenGeometry(); this->move( screen.center() - this->rect().center() ); /* get all available pgp private certificates.... @@ -120,13 +118,11 @@ void StartDialog::loadPerson() RsPeerId accountId = RsPeerId((data.toString()).toStdString()); // Cache the passphrase, so that it is not asked again. - rsNotify->cachePgpPassphrase(ui.password_input->text().toUtf8().constData()) ; - rsNotify->setDisableAskPassword(true); + RsLoginHelper::cachePgpPassphrase(ui.password_input->text().toUtf8().constData()) ; bool res = RsApplication::loadCertificate(accountId, ui.autologin_checkbox->isChecked()) ; - rsNotify->setDisableAskPassword(false); - rsNotify->clearPgpPassphrase(); + RsLoginHelper::clearPgpPassphrase(); if(res) accept(); diff --git a/retroshare-gui/src/gui/TheWire/PulseViewItem.cpp b/retroshare-gui/src/gui/TheWire/PulseViewItem.cpp index 5a309f94b..b46737bfd 100644 --- a/retroshare-gui/src/gui/TheWire/PulseViewItem.cpp +++ b/retroshare-gui/src/gui/TheWire/PulseViewItem.cpp @@ -450,15 +450,15 @@ QString ToNumberUnits(uint32_t count) QString ans; if (count > 1000000) { - ans.sprintf("%6.2fm", count / 1000000.0); + ans = QString::asprintf("%6.2fm", count / 1000000.0); } else if (count > 1000) { - ans.sprintf("%6.2fk", count / 1000.0); + ans = QString::asprintf("%6.2fk", count / 1000.0); } else { - ans.sprintf("%6d", count); + ans = QString::asprintf("%6d", count); } return ans; } diff --git a/retroshare-gui/src/gui/WikiPoos/WikiDialog.cpp b/retroshare-gui/src/gui/WikiPoos/WikiDialog.cpp index 876130c94..7f411a25e 100644 --- a/retroshare-gui/src/gui/WikiPoos/WikiDialog.cpp +++ b/retroshare-gui/src/gui/WikiPoos/WikiDialog.cpp @@ -30,6 +30,7 @@ #include "gui/WikiPoos/WikiEditDialog.h" #include "gui/settings/rsharesettings.h" #include "gui/gxs/WikiGroupDialog.h" +#include "util/DateTime.h" #include @@ -715,7 +716,7 @@ void WikiDialog::GroupMetaDataToGroupItemInfo(const RsGroupMetaData &groupInfo, groupItemInfo.name = QString::fromUtf8(groupInfo.mGroupName.c_str()); //groupItemInfo.description = QString::fromUtf8(groupInfo.forumDesc); groupItemInfo.popularity = groupInfo.mPop; - groupItemInfo.lastpost = QDateTime::fromTime_t(groupInfo.mLastPost); + groupItemInfo.lastpost = DateTime::DateTimeFromTime_t(groupInfo.mLastPost); groupItemInfo.subscribeFlags = groupInfo.mSubscribeFlags; groupItemInfo.icon = QIcon(IMAGE_WIKI); diff --git a/retroshare-gui/src/gui/WikiPoos/WikiEditDialog.cpp b/retroshare-gui/src/gui/WikiPoos/WikiEditDialog.cpp index 8dd0404d6..857ad0da8 100644 --- a/retroshare-gui/src/gui/WikiPoos/WikiEditDialog.cpp +++ b/retroshare-gui/src/gui/WikiPoos/WikiEditDialog.cpp @@ -22,6 +22,7 @@ #include "gui/gxs/GxsIdTreeWidgetItem.h" #include "gui/WikiPoos/WikiEditDialog.h" +#include "util/DateTime.h" #include @@ -727,10 +728,9 @@ void WikiEditDialog::loadBaseHistory(const uint32_t &token) { // From Forum stuff. - QDateTime qtime; + QDateTime qtime = DateTime::DateTimeFromTime_t(page.mMeta.mPublishTs); QString text; QString sort; - qtime.setTime_t(page.mMeta.mPublishTs); sort = qtime.toString("yyyyMMdd_hhmmss"); text = qtime.toString("dd/MM/yy hh:mm"); @@ -841,10 +841,9 @@ void WikiEditDialog::loadEditTreeData(const uint32_t &token) { // From Forum stuff. - QDateTime qtime; + QDateTime qtime = DateTime::DateTimeFromTime_t(snapshot.mMeta.mPublishTs); QString text; QString sort; - qtime.setTime_t(snapshot.mMeta.mPublishTs); sort = qtime.toString("yyyyMMdd_hhmmss"); text = qtime.toString("dd/MM/yy hh:mm"); diff --git a/retroshare-gui/src/gui/advsearch/expressionwidget.cpp b/retroshare-gui/src/gui/advsearch/expressionwidget.cpp index f6b150065..8127ff93d 100644 --- a/retroshare-gui/src/gui/advsearch/expressionwidget.cpp +++ b/retroshare-gui/src/gui/advsearch/expressionwidget.cpp @@ -20,6 +20,7 @@ * * *******************************************************************************/ #include "expressionwidget.h" +#include "util/RsQtVersion.h" ExpressionWidget::ExpressionWidget(QWidget * parent, bool initial) : QWidget(parent) @@ -109,11 +110,7 @@ RsRegularExpression::Expression* ExpressionWidget::getRsExpression() if (isStringSearchExpression()) { QString txt = exprParamElem->getStrSearchValue(); -#if QT_VERSION < QT_VERSION_CHECK(5,15,0) - QStringList words = txt.split(" ", QString::SkipEmptyParts); -#else - QStringList words = txt.split(" ", Qt::SkipEmptyParts); -#endif + QStringList words = txt.split(" ", QtSkipEmptyParts); for (int i = 0; i < words.size(); ++i) wordList.push_back(words.at(i).toUtf8().constData()); } else if (inRangedConfig){ diff --git a/retroshare-gui/src/gui/advsearch/guiexprelement.cpp b/retroshare-gui/src/gui/advsearch/guiexprelement.cpp index 5dd138186..26d623bde 100644 --- a/retroshare-gui/src/gui/advsearch/guiexprelement.cpp +++ b/retroshare-gui/src/gui/advsearch/guiexprelement.cpp @@ -20,7 +20,11 @@ * * *******************************************************************************/ +#include + #include "guiexprelement.h" +#include "util/DateTime.h" + #define STR_FIELDS_MIN_WFACTOR 20.0 #define SIZE_FIELDS_MIN_WFACTOR 8.0 #define DATE_FIELDS_MIN_WFACTOR 10.0 @@ -219,7 +223,7 @@ QStringList GuiExprElement::getConditionOptions(ExprSearchType t) QHBoxLayout * GuiExprElement::createLayout(QWidget * parent /*= nullptr*/) { QHBoxLayout * hboxLayout = new QHBoxLayout(parent); - hboxLayout->setMargin(0); + hboxLayout->setContentsMargins(0, 0, 0, 0); hboxLayout->setSpacing(0); return hboxLayout; } @@ -398,10 +402,10 @@ void ExprParamElement::adjustForSearchType(ExprSearchType type) { // record which search type is active searchType = type; - QRegExp regExp("0|[1-9][0-9]*"); - numValidator = new QRegExpValidator(regExp, this); - QRegExp hexRegExp("[A-Fa-f0-9]*"); - hexValidator = new QRegExpValidator(hexRegExp, this); + QRegularExpression regExp("0|[1-9][0-9]*"); + numValidator = new QRegularExpressionValidator(regExp, this); + QRegularExpression hexRegExp("[A-Fa-f0-9]*"); + hexValidator = new QRegularExpressionValidator(hexRegExp, this); QHBoxLayout* hbox = static_cast(layout()); clearLayout(hbox); @@ -607,7 +611,7 @@ uint64_t ExprParamElement::getIntValueFromField(QString fieldName, bool isToFiel #else QDateTime time = dateEdit->date().startOfDay(); #endif - val = (uint64_t)time.toTime_t(); + val = (uint64_t) DateTime::DateTimeToTime_t(time); break; } case SizeSearch: diff --git a/retroshare-gui/src/gui/advsearch/guiexprelement.h b/retroshare-gui/src/gui/advsearch/guiexprelement.h index 50ebeaa15..c64e15bcb 100644 --- a/retroshare-gui/src/gui/advsearch/guiexprelement.h +++ b/retroshare-gui/src/gui/advsearch/guiexprelement.h @@ -34,6 +34,8 @@ #include +class QRegularExpressionValidator; + enum ExprSearchType { NameSearch, @@ -191,8 +193,8 @@ public: virtual QString toString(); private: - QRegExpValidator * numValidator; - QRegExpValidator * hexValidator; + QRegularExpressionValidator * numValidator; + QRegularExpressionValidator * hexValidator; QFrame * rangeParamsFrame; bool inRangedConfig; uint64_t getIntValueFromField(QString fieldName, bool isToField=false,bool *ok = NULL); diff --git a/retroshare-gui/src/gui/chat/ChatDialog.cpp b/retroshare-gui/src/gui/chat/ChatDialog.cpp index d7edd2152..9f91bc782 100644 --- a/retroshare-gui/src/gui/chat/ChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatDialog.cpp @@ -35,7 +35,6 @@ #include "gui/SoundManager.h" #include -#include #include static std::map chatDialogsList; @@ -86,7 +85,7 @@ void ChatDialog::init(const ChatId &id, const QString &title) return NULL; } -/*static*/ ChatDialog* ChatDialog::getChat(ChatId id, uint chatflags) +/*static*/ ChatDialog* ChatDialog::getChat(ChatId id, RsChatFlags chatflags) { if(id.isBroadcast() || id.isNotSet()) return NULL; // broadcast is not handled by a chat dialog @@ -97,9 +96,9 @@ void ChatDialog::init(const ChatId &id, const QString &title) if (cd == NULL) { if(id.isDistantChatId()) - chatflags = RS_CHAT_OPEN | RS_CHAT_FOCUS; // force open for distant chat + chatflags = RsChatFlags::RS_CHAT_OPEN | RsChatFlags::RS_CHAT_FOCUS; // force open for distant chat - if (chatflags & RS_CHAT_OPEN) { + if (!!(chatflags & RsChatFlags::RS_CHAT_OPEN)) { if (id.isLobbyId()) { ChatLobbyDialog* cld = new ChatLobbyDialog(id.toLobbyId()); cld->init(ChatId(), ""); @@ -176,7 +175,7 @@ void ChatDialog::init(const ChatId &id, const QString &title) // play sound when recv a message SoundManager::play(SOUND_NEW_CHAT_MESSAGE); - ChatDialog *cd = getChat(msg.chat_id, Settings->getChatFlags()); + ChatDialog *cd = getChat(msg.chat_id, (RsChatFlags)Settings->getChatFlags()); if(cd) cd->addChatMsg(msg); else @@ -185,7 +184,7 @@ void ChatDialog::init(const ChatId &id, const QString &title) /*static*/ void ChatDialog::chatFriend(const ChatId &peerId, const bool forceFocus) { - getChat(peerId, forceFocus ? RS_CHAT_OPEN | RS_CHAT_FOCUS : RS_CHAT_OPEN); + getChat(peerId, forceFocus ? (RsChatFlags::RS_CHAT_OPEN | RsChatFlags::RS_CHAT_FOCUS) : RsChatFlags::RS_CHAT_OPEN); // below is the old code witch does lots of error checking. // because there are many different chat types, there are also different ways to check if the id is valid @@ -330,7 +329,7 @@ QString ChatDialog::getOwnName() const return "ChatDialog::getOwnName(): invalid id type passed (RsPeerId is required). This is a bug."; } -void ChatDialog::setPeerStatus(uint32_t status) +void ChatDialog::setPeerStatus(RsStatusValue status) { ChatWidget *cw = getChatWidget(); if (cw) @@ -338,22 +337,17 @@ void ChatDialog::setPeerStatus(uint32_t status) // convert to virtual peer id // this is only required for private and distant chat, // because lobby and broadcast does not have a status - RsPeerId vpid; - if(mChatId.isPeerId()) - vpid = mChatId.toPeerId(); - if(mChatId.isDistantChatId()) - vpid = RsPeerId(mChatId.toDistantChatId()); - cw->updateStatus(QString::fromStdString(vpid.toStdString()), status); + cw->updateStatus(mChatId, status); } } -int ChatDialog::getPeerStatus() +RsStatusValue ChatDialog::getPeerStatus() { ChatWidget *cw = getChatWidget(); if (cw) { return cw->getPeerStatus(); } - return 0; + return RsStatusValue::RS_STATUS_OFFLINE; } QString ChatDialog::getTitle() diff --git a/retroshare-gui/src/gui/chat/ChatDialog.h b/retroshare-gui/src/gui/chat/ChatDialog.h index 7bfbc16ec..9db8e76d1 100644 --- a/retroshare-gui/src/gui/chat/ChatDialog.h +++ b/retroshare-gui/src/gui/chat/ChatDialog.h @@ -23,10 +23,13 @@ #ifndef CHATDIALOG_H #define CHATDIALOG_H +#include "retroshare/rsstatus.h" + #include #include -class ChatWidget; +#include "gui/chat/ChatWidget.h" + class RSStyle; class ChatDialog : public QWidget @@ -35,14 +38,14 @@ class ChatDialog : public QWidget public: static ChatDialog *getExistingChat(ChatId id); - static ChatDialog *getChat(ChatId id, uint chatflags = 0); + static ChatDialog *getChat(ChatId id, RsChatFlags chatflags = RsChatFlags::RS_CHAT_NONE); static void cleanupChat(); static void chatFriend(const ChatId &peerId, bool forceFocus = true); static void chatFriend(const RsPgpId &gpgId, bool forceFocus = true); static void closeChat(const ChatId &chat_id); static void chatMessageReceived(ChatMessage msg); - virtual void showDialog(uint /*chatflags*/) {} + virtual void showDialog(RsChatFlags /*chatflags*/) {} virtual ChatWidget *getChatWidget() = 0; virtual bool hasPeerStatus() = 0; @@ -58,8 +61,8 @@ public: bool setStyle(); const RSStyle *getStyle(); - int getPeerStatus(); - void setPeerStatus(uint32_t state); + RsStatusValue getPeerStatus(); + void setPeerStatus(RsStatusValue state); void focusDialog(); @@ -75,7 +78,7 @@ private slots: void chatNewMessage(ChatWidget*); protected: - explicit ChatDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0); + explicit ChatDialog(QWidget *parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); virtual ~ChatDialog(); void closeEvent(QCloseEvent *event); diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index dd4a128a4..71f884ed5 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include "ChatLobbyDialog.h" @@ -42,10 +43,10 @@ #include "gui/settings/RsharePeerSettings.h" #include "gui/settings/rsharesettings.h" #include "util/HandleRichText.h" -#include "util/QtVersion.h" +#include "util/RsQtVersion.h" -#include "retroshare/rsnotify.h" #include "util/rstime.h" +#include "util/DateTime.h" #include #include @@ -529,8 +530,8 @@ void ChatLobbyDialog::changeNickname() */ void ChatLobbyDialog::addChatMsg(const ChatMessage& msg) { - QDateTime sendTime = QDateTime::fromTime_t(msg.sendTime); - QDateTime recvTime = QDateTime::fromTime_t(msg.recvTime); + QDateTime sendTime = DateTime::DateTimeFromTime_t(msg.sendTime); + QDateTime recvTime = DateTime::DateTimeFromTime_t(msg.recvTime); QString message = QString::fromUtf8(msg.msg.c_str()); RsGxsId gxs_id = msg.lobby_peer_gxs_id ; @@ -846,25 +847,26 @@ QString ChatLobbyDialog::getParticipantName(const RsGxsId& gxs_id) const } -void ChatLobbyDialog::displayLobbyEvent(int event_type, const RsGxsId& gxs_id, const QString& str) +void ChatLobbyDialog::handleLobbyEvent(RsChatLobbyEventCode event_type, const RsGxsId& gxs_id, const QString& str) { RsGxsId qsParticipant; QString name= getParticipantName(gxs_id) ; + //std::cerr << "Received ChatLobby event " << (int)event_type << " for lobby " << (void*)lobbyId << std::endl; switch (event_type) { - case RS_CHAT_LOBBY_EVENT_PEER_LEFT: + case RsChatLobbyEventCode::CHAT_LOBBY_EVENT_PEER_LEFT: qsParticipant=gxs_id; ui.chatWidget->addChatMsg(true, tr("Chat room management"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), tr("%1 has left the room.").arg(RsHtml::plainText(name)), ChatWidget::MSGTYPE_SYSTEM); emit peerLeft(id()) ; break; - case RS_CHAT_LOBBY_EVENT_PEER_JOINED: + case RsChatLobbyEventCode::CHAT_LOBBY_EVENT_PEER_JOINED: qsParticipant=gxs_id; ui.chatWidget->addChatMsg(true, tr("Chat room management"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), tr("%1 joined the room.").arg(RsHtml::plainText(name)), ChatWidget::MSGTYPE_SYSTEM); emit peerJoined(id()) ; break; - case RS_CHAT_LOBBY_EVENT_PEER_STATUS: + case RsChatLobbyEventCode::CHAT_LOBBY_EVENT_PEER_STATUS: { qsParticipant=gxs_id; @@ -876,7 +878,7 @@ void ChatLobbyDialog::displayLobbyEvent(int event_type, const RsGxsId& gxs_id, c } break; - case RS_CHAT_LOBBY_EVENT_PEER_CHANGE_NICKNAME: + case RsChatLobbyEventCode::CHAT_LOBBY_EVENT_PEER_CHANGE_NICKNAME: { qsParticipant=gxs_id; @@ -892,11 +894,11 @@ void ChatLobbyDialog::displayLobbyEvent(int event_type, const RsGxsId& gxs_id, c muteParticipant(RsGxsId(str.toStdString())) ; } break; - case RS_CHAT_LOBBY_EVENT_KEEP_ALIVE: + case RsChatLobbyEventCode::CHAT_LOBBY_EVENT_KEEP_ALIVE: //std::cerr << "Received keep alive packet from " << nickname.toStdString() << " in chat room " << getPeerId() << std::endl; break; default: - std::cerr << "ChatLobbyDialog::displayLobbyEvent() Unhandled chat room event type " << event_type << std::endl; + std::cerr << "ChatLobbyDialog::handledLobbyEvent() Unhandled chat room event type " << (int)event_type << std::endl; } if (!qsParticipant.isNull()) @@ -927,9 +929,9 @@ bool ChatLobbyDialog::canClose() return false; } -void ChatLobbyDialog::showDialog(uint chatflags) +void ChatLobbyDialog::showDialog(RsChatFlags chatflags) { - if (chatflags & RS_CHAT_FOCUS) + if (!!(chatflags & RsChatFlags::RS_CHAT_FOCUS)) { if (isWindowed() && mPCWindow) { mPCWindow->showDialog(this, chatflags); @@ -1017,5 +1019,5 @@ void ChatLobbyDialog::setWindowed(bool windowed) } show(); if (chatLobbyPage)// If not defined, we are on autosubscribe loop of lobby widget constructor. So don't recall it. - showDialog(RS_CHAT_FOCUS); + showDialog(RsChatFlags::RS_CHAT_FOCUS); } diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.h b/retroshare-gui/src/gui/chat/ChatLobbyDialog.h index c3572cc4b..973509fe7 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.h +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.h @@ -42,12 +42,12 @@ class ChatLobbyDialog: public ChatDialog friend class ChatDialog; public: - void displayLobbyEvent(int event_type, const RsGxsId &gxs_id, const QString& str); + void handleLobbyEvent(RsChatLobbyEventCode event_type, const RsGxsId& gxs_id, const QString& str); - virtual void showDialog(uint chatflags); - virtual ChatWidget *getChatWidget(); - virtual bool hasPeerStatus() { return false; } - virtual bool notifyBlink(); + virtual void showDialog(RsChatFlags chatflags) override; + virtual ChatWidget *getChatWidget() override; + virtual bool hasPeerStatus() override{ return false; } + virtual bool notifyBlink() override; void setIdentity(const RsGxsId& gxs_id); bool isParticipantMuted(const RsGxsId &participant); ChatLobbyId id() const { return lobbyId ;} @@ -74,7 +74,7 @@ signals: protected: /** Default constructor */ - ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent = 0, Qt::WindowFlags flags = 0); + ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); /** Default destructor */ virtual ~ChatLobbyDialog(); diff --git a/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.cpp b/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.cpp index 719ad7d2d..13957fffe 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.cpp @@ -28,7 +28,6 @@ #include "gui/ChatLobbyWidget.h" #include "gui/MainWindow.h" -#include "gui/notifyqt.h" #include "gui/SoundManager.h" #include "gui/settings/rsharesettings.h" #include "util/DateTime.h" @@ -229,7 +228,7 @@ void ChatLobbyUserNotify::iconClicked() QString strName=tr("Remove All"); QAction *pAction = new QAction( QIcon(), strName, trayMenu); ActionTag actionTag={0x0, "", true}; - pAction->setData(qVariantFromValue(actionTag)); + pAction->setData(QVariant::fromValue(actionTag)); trayMenu->addAction(pAction); trayMenu->exec(QCursor::pos()); @@ -268,14 +267,14 @@ void ChatLobbyUserNotify::makeSubMenu(QMenu* parentMenu, QIcon icoLobby, QString QAction *pAction = new QAction( icoLobby, strName, lobbyMenu); pAction->setToolTip(doc.toPlainText()); ActionTag actionTag={itCL->first, itMsg->first, false}; - pAction->setData(qVariantFromValue(actionTag)); + pAction->setData(QVariant::fromValue(actionTag)); lobbyMenu->addAction(pAction); } QString strName=tr("Remove All"); QAction *pAction = new QAction( icoLobby, strName, lobbyMenu); ActionTag actionTag={itCL->first, "", true}; - pAction->setData(qVariantFromValue(actionTag)); + pAction->setData(QVariant::fromValue(actionTag)); lobbyMenu->addAction(pAction); } diff --git a/retroshare-gui/src/gui/chat/ChatStyle.cpp b/retroshare-gui/src/gui/chat/ChatStyle.cpp index 481f87e95..97759e837 100644 --- a/retroshare-gui/src/gui/chat/ChatStyle.cpp +++ b/retroshare-gui/src/gui/chat/ChatStyle.cpp @@ -103,10 +103,11 @@ #include #include #include +#include #include "ChatStyle.h" #include "gui/settings/rsharesettings.h" -#include "gui/notifyqt.h" +#include "gui/RsGUIEventManager.h" #include "util/DateTime.h" #include "util/HandleRichText.h" @@ -129,7 +130,7 @@ ChatStyle::ChatStyle() : QObject() { m_styleType = TYPE_UNKNOWN; - connect(NotifyQt::getInstance(), SIGNAL(chatStyleChanged(int)), SLOT(styleChanged(int))); + connect(RsGUIEventManager::getInstance(), SIGNAL(chatStyleChanged(int)), SLOT(styleChanged(int))); } /* Destructor. */ @@ -376,7 +377,7 @@ QString ChatStyle::formatMessage(enumFormatMessage type QString strDate = DateTime::formatDate(timestamp.date()).prepend(QString("")).append(QString("")); QString strTime = DateTime::formatTime(timestamp.time()).prepend(QString("")).append(QString("")); - int bi = name.lastIndexOf(QRegExp(" \\(.*\\)")); //trim location from the end + int bi = name.lastIndexOf(QRegularExpression(" \\(.*\\)")); //trim location from the end QString strShortName = RsHtml::plainText(name.left(bi)).prepend(QString("")).append(QString("")); //handle /me @@ -384,9 +385,9 @@ QString ChatStyle::formatMessage(enumFormatMessage type //meName class for modifying the style of the name in the palce of /me if(me){ messageBody = messageBody.replace(messageBody.indexOf("/me "), 3, strShortName.prepend(QString("")).append(QString(""))); //replace only the first /me - style = style.remove(QRegExp("%nome%.*%/nome%")).remove("%me%").remove("%/me%"); + style = style.remove(QRegularExpression("%nome%.*%/nome%")).remove("%me%").remove("%/me%"); } else { - style = style.remove(QRegExp("%me%.*%/me%")).remove("%nome%").remove("%/nome%"); + style = style.remove(QRegularExpression("%me%.*%/me%")).remove("%nome%").remove("%/nome%"); } QString formatMsg = style.replace("%name%", strName) @@ -425,8 +426,8 @@ static bool getStyleInfo(QString stylePath, QString stylePathRelative, ChatStyle while (reader.atEnd() == false) { reader.readNext(); if (reader.isStartElement()) { - if (reader.name() == "RetroShare_Style") { - if (reader.attributes().value("version") == "1.0") { + if (reader.name() == QString("RetroShare_Style")) { + if (reader.attributes().value("version") == QString("1.0")) { info.stylePath = stylePathRelative; continue; } @@ -438,22 +439,22 @@ static bool getStyleInfo(QString stylePath, QString stylePathRelative, ChatStyle continue; } - if (reader.name() == "style") { + if (reader.name() == QString("style")) { // read style information while (reader.atEnd() == false) { reader.readNext(); if (reader.isEndElement()) { - if (reader.name() == "style") { + if (reader.name() == QString("style")) { break; } continue; } if (reader.isStartElement()) { - if (reader.name() == "name") { + if (reader.name() == QString("name")) { info.styleName = reader.readElementText(); continue; } - if (reader.name() == "description") { + if (reader.name() == QString("description")) { info.styleDescription = reader.readElementText(); continue; } @@ -463,22 +464,22 @@ static bool getStyleInfo(QString stylePath, QString stylePathRelative, ChatStyle continue; } - if (reader.name() == "author") { + if (reader.name() == QString("author")) { // read author information while (reader.atEnd() == false) { reader.readNext(); if (reader.isEndElement()) { - if (reader.name() == "author") { + if (reader.name() == QString("author")) { break; } continue; } if (reader.isStartElement()) { - if (reader.name() == "name") { + if (reader.name() == QString("name")) { info.authorName = reader.readElementText(); continue; } - if (reader.name() == "email") { + if (reader.name() == QString("email")) { info.authorEmail = reader.readElementText(); continue; } diff --git a/retroshare-gui/src/gui/chat/ChatTabWidget.cpp b/retroshare-gui/src/gui/chat/ChatTabWidget.cpp index 03357a3e4..9008b250c 100644 --- a/retroshare-gui/src/gui/chat/ChatTabWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatTabWidget.cpp @@ -113,7 +113,7 @@ void ChatTabWidget::tabInfoChanged(ChatDialog *dialog) } } else if (dialog->hasPeerStatus()) { setBlinking(tab, false); - setTabIcon(tab, QIcon(StatusDefs::imageIM(dialog->getPeerStatus()))); + setTabIcon(tab, QIcon(StatusDefs::imageIM((RsStatusValue)dialog->getPeerStatus()))); } else { setBlinking(tab, false); setTabIcon(tab, QIcon()); @@ -155,7 +155,7 @@ void ChatTabWidget::getInfo(bool &isTyping, bool &hasNewMessage, QIcon *icon) } else { cd = dynamic_cast(currentWidget()); if (cd && cd->hasPeerStatus()) { - *icon = QIcon(StatusDefs::imageIM(cd->getPeerStatus())); + *icon = QIcon(StatusDefs::imageIM((RsStatusValue)cd->getPeerStatus())); } else { *icon = QIcon(); } diff --git a/retroshare-gui/src/gui/chat/ChatUserNotify.cpp b/retroshare-gui/src/gui/chat/ChatUserNotify.cpp index dcafae59a..3cfdd9b88 100644 --- a/retroshare-gui/src/gui/chat/ChatUserNotify.cpp +++ b/retroshare-gui/src/gui/chat/ChatUserNotify.cpp @@ -22,13 +22,12 @@ #include "gui/common/FilesDefs.h" #include "ChatUserNotify.h" -#include "gui/notifyqt.h" #include "gui/MainWindow.h" #include "gui/chat/ChatDialog.h" #include "gui/settings/rsharesettings.h" +#include "util/qtthreadsutils.h" #include -#include #include static std::map waitingChats; @@ -57,8 +56,30 @@ static ChatUserNotify* instance = 0; ChatUserNotify::ChatUserNotify(QObject *parent) : UserNotify(parent) { - connect(NotifyQt::getInstance(), SIGNAL(chatMessageReceived(ChatMessage)), this, SLOT(chatMessageReceived(ChatMessage))); instance = this; + + mEventHandlerId = 0; + + rsEvents->registerEventsHandler( [this](std::shared_ptr e) + { + RsQThreadUtils::postToObject([=]() + { + auto fe = dynamic_cast(e.get()); if(!fe) return; + + if(!fe) + return; + + switch(fe->mEventCode) + { + case RsChatServiceEventCode::CHAT_MESSAGE_RECEIVED: chatMessageReceived(fe->mMsg); break; + default: + break; + } + + } + , this ); + }, mEventHandlerId, RsEventType::CHAT_SERVICE ); + } ChatUserNotify::~ChatUserNotify() @@ -108,7 +129,7 @@ void ChatUserNotify::iconClicked() { ChatDialog *chatDialog = NULL; // ChatWidget removes the waiting chat from the list with clearWaitingChat() - chatDialog = ChatDialog::getChat(waitingChats.begin()->first, RS_CHAT_OPEN | RS_CHAT_FOCUS); + chatDialog = ChatDialog::getChat(waitingChats.begin()->first, RsChatFlags::RS_CHAT_OPEN | RsChatFlags::RS_CHAT_FOCUS); if (chatDialog == NULL) { MainWindow::showWindow(MainWindow::Friends); @@ -120,7 +141,7 @@ void ChatUserNotify::chatMessageReceived(ChatMessage msg) { if(!msg.chat_id.isBroadcast() &&( ChatDialog::getExistingChat(msg.chat_id) - || (Settings->getChatFlags() & RS_CHAT_OPEN) + || (Settings->getChatFlags() & (uint32_t)RsChatFlags::RS_CHAT_OPEN) || msg.chat_id.isDistantChatId())) { ChatDialog::chatMessageReceived(msg); diff --git a/retroshare-gui/src/gui/chat/ChatUserNotify.h b/retroshare-gui/src/gui/chat/ChatUserNotify.h index 5ce8cb10a..2824acf5f 100644 --- a/retroshare-gui/src/gui/chat/ChatUserNotify.h +++ b/retroshare-gui/src/gui/chat/ChatUserNotify.h @@ -42,11 +42,10 @@ public: virtual bool hasSetting(QString *name, QString *group) override; -private slots: - void chatMessageReceived(ChatMessage msg); - private: - virtual QIcon getIcon() override; + void chatMessageReceived(ChatMessage msg); + + virtual QIcon getIcon() override; virtual QIcon getMainIcon(bool hasNew) override; virtual unsigned int getNewCount() override; @@ -54,6 +53,8 @@ private: virtual QString getNotifyMessage(bool plural) override; virtual void iconClicked() override; + + RsEventsHandlerId_t mEventHandlerId; }; #endif // CHATUSERNOTIFY_H diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index abab8336a..3f61badda 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -23,7 +23,6 @@ #include "ui_ChatWidget.h" #include "gui/MainWindow.h" -#include "gui/notifyqt.h" #include "gui/RetroShareLink.h" #include "gui/settings/rsharesettings.h" #include "gui/settings/rsettingswin.h" @@ -33,11 +32,14 @@ #include "gui/common/Emoticons.h" #include "gui/chat/ChatLobbyDialog.h" #include "gui/gxs/GxsIdDetails.h" +#include "gui/RsGUIEventManager.h" #include "util/misc.h" +#include "util/qtthreadsutils.h" #include "util/HandleRichText.h" #include "gui/chat/ChatUserNotify.h"//For BradCast #include "util/DateTime.h" #include "util/imageutil.h" +#include "util/qtthreadsutils.h" #include "gui/im_history/ImHistoryBrowser.h" #include @@ -61,6 +63,7 @@ #include #include #include +#include #include @@ -74,7 +77,7 @@ ChatWidget::ChatWidget(QWidget *parent) : QWidget(parent) - , completionPosition(0), newMessages(false), typing(false), peerStatus(0) + , completionPosition(0), newMessages(false), typing(false), peerStatus(RsStatusValue::RS_STATUS_OFFLINE) , sendingBlocked(false), useCMark(false) , lastStatusSendTime(0) , firstShow(true), inChatCharFormatChanged(false), firstSearch(true) @@ -171,9 +174,32 @@ ChatWidget::ChatWidget(QWidget *parent) connect(ui->hashBox, SIGNAL(fileHashingFinished(QList)), this, SLOT(fileHashingFinished(QList))); - connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(const QString&, int)), this, SLOT(updateStatus(const QString&, int))); - connect(NotifyQt::getInstance(), SIGNAL(peerHasNewCustomStateString(const QString&, const QString&)), this, SLOT(updatePeersCustomStateString(const QString&, const QString&))); - connect(NotifyQt::getInstance(), SIGNAL(chatFontChanged()), this, SLOT(resetFonts())); + mEventHandlerId_friends = 0; + + rsEvents->registerEventsHandler( [this](std::shared_ptr e) + { + RsQThreadUtils::postToObject([=](){ + auto fe = dynamic_cast(e.get()); + + if(!fe) + return; + + switch(fe->mEventCode) + { + case RsFriendListEventCode::NODE_STATUS_CHANGED: updateStatus(ChatId(fe->mSslId),fe->mStatus); + break; + + case RsFriendListEventCode::NODE_STATE_STRING_CHANGED: updatePeersCustomStateString(ChatId(fe->mSslId),QString::fromUtf8(fe->mStateString.c_str())); + break; + + default: + break; + } + + }, this ); + },mEventHandlerId_friends,RsEventType::FRIEND_LIST); + + connect(RsGUIEventManager::getInstance(), SIGNAL(chatFontChanged()), this, SLOT(resetFonts())); connect(ui->textBrowser, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuTextBrowser(QPoint))); @@ -254,6 +280,7 @@ ChatWidget::ChatWidget(QWidget *parent) ChatWidget::~ChatWidget() { processSettings(false); + rsEvents->unregisterEventsHandler(mEventHandlerId_friends); /* Cleanup plugin functions */ foreach (ChatWidgetHolder *chatWidgetHolder, mChatWidgetHolder) { @@ -368,11 +395,11 @@ void ChatWidget::init(const ChatId &chat_id, const QString &title) StatusInfo peerStatusInfo; // No check of return value. Non existing status info is handled as offline. rsStatus->getStatus(chatId.toPeerId(), peerStatusInfo); - updateStatus(QString::fromStdString(chatId.toPeerId().toStdString()), peerStatusInfo.status); + updateStatus(chatId, peerStatusInfo.status); // initialize first custom state string QString customStateString = QString::fromUtf8(rsMsgs->getCustomStateString(chatId.toPeerId()).c_str()); - updatePeersCustomStateString(QString::fromStdString(chatId.toPeerId().toStdString()), customStateString); + updatePeersCustomStateString(chatId, customStateString); } else if (chatType() == CHATTYPE_DISTANT){ hist_chat_type = RS_HISTORY_TYPE_DISTANT ; messageCount = Settings->getDistantChatHistoryCount(); @@ -416,7 +443,7 @@ void ChatWidget::init(const ChatId &chat_id, const QString &title) name = QString::fromUtf8(historyIt->peerId.toStdString().c_str()); } - addChatMsg(historyIt->incoming, name, RsGxsId(historyIt->peerId.toStdString().c_str()), QDateTime::fromTime_t(historyIt->sendTime), QDateTime::fromTime_t(historyIt->recvTime), QString::fromUtf8(historyIt->message.c_str()), MSGTYPE_HISTORY); + addChatMsg(historyIt->incoming, name, RsGxsId(historyIt->peerId.toStdString().c_str()), DateTime::DateTimeFromTime_t(historyIt->sendTime), DateTime::DateTimeFromTime_t(historyIt->recvTime), QString::fromUtf8(historyIt->message.c_str()), MSGTYPE_HISTORY); } } } @@ -1507,10 +1534,9 @@ void ChatWidget::on_markButton_clicked(bool bValue) void ChatWidget::chooseColor() { - bool ok; - QRgb color = QColorDialog::getRgba(currentColor.rgba(), &ok, window()); - if (ok) { - currentColor = QColor(color); + QColor color = QColorDialog::getColor(currentColor, window(), "", QColorDialog::ShowAlphaChannel); + if (color.isValid()) { + currentColor = color; PeerSettings->setPrivateChatColor(chatId, currentColor.name()); colorChanged(); setColorAndFont(false); @@ -1763,7 +1789,11 @@ bool ChatWidget::fileSave() if (!file.open(QFile::WriteOnly)) return false; QTextStream ts(&file); +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) + ts.setEncoding(QStringConverter::Utf8); +#else ts.setCodec(QTextCodec::codecForName("UTF-8")); +#endif ts << ui->textBrowser->document()->toPlainText(); ui->textBrowser->document()->setModified(false); return true; @@ -1788,108 +1818,106 @@ void ChatWidget::setCurrentFileName(const QString &fileName) setWindowModified(false); } -void ChatWidget::updateStatus(const QString &peer_id, int status) +void ChatWidget::updateStatus(const ChatId& cid, RsStatusValue status) { if (! (chatType() == CHATTYPE_PRIVATE || chatType() == CHATTYPE_DISTANT)) { - // updateTitle is used - return; + // updateTitle is used + return; } - // make virtual peer id from gxs id in case of distant chat - RsPeerId vpid; + // // make virtual peer id from gxs id in case of distant chat + // RsPeerId vpid; + // if(chatId.isDistantChatId()) + // vpid = RsPeerId(chatId.toDistantChatId()); + // else + // vpid = chatId.toPeerId(); + + /* set font size for status */ + if (!(cid == chatId)) + return; + + // the peers status has changed + + QString tooltip_info ; + QString peerName ; + if(chatId.isDistantChatId()) - vpid = RsPeerId(chatId.toDistantChatId()); - else - vpid = chatId.toPeerId(); - - /* set font size for status */ - if (peer_id.toStdString() == vpid.toStdString()) { - // the peers status has changed + DistantChatPeerInfo dcpinfo ; + RsIdentityDetails details ; - QString tooltip_info ; - QString peerName ; + if(rsMsgs->getDistantChatStatus(chatId.toDistantChatId(),dcpinfo)) + { + if(rsIdentity->getIdDetails(dcpinfo.to_id,details)) + peerName = QString::fromUtf8( details.mNickname.c_str() ) ; + else + peerName = QString::fromStdString(dcpinfo.to_id.toStdString()) ; - if(chatId.isDistantChatId()) - { - DistantChatPeerInfo dcpinfo ; - RsIdentityDetails details ; - - if(rsMsgs->getDistantChatStatus(chatId.toDistantChatId(),dcpinfo)) - { - if(rsIdentity->getIdDetails(dcpinfo.to_id,details)) - peerName = QString::fromUtf8( details.mNickname.c_str() ) ; - else - peerName = QString::fromStdString(dcpinfo.to_id.toStdString()) ; - - tooltip_info = QString("Identity Id: ")+QString::fromStdString(dcpinfo.to_id.toStdString()); - } - else - { - peerName = QString::fromStdString(chatId.toDistantChatId().toStdString()) ; - tooltip_info = QString("Identity Id: unknown (bug?)"); - } - } - else - { - peerName = QString::fromUtf8(rsPeers->getPeerName(chatId.toPeerId()).c_str()); - tooltip_info = QString("Peer Id: ") + QString::fromStdString(chatId.toPeerId().toStdString()); - } - - // is scrollbar at the end? - QScrollBar *scrollbar = ui->textBrowser->verticalScrollBar(); - bool atEnd = (scrollbar->value() == scrollbar->maximum()); - - switch (status) { - case RS_STATUS_OFFLINE: - ui->info_Frame->setVisible(true); - ui->infoLabel->setText(peerName + " " + tr("appears to be Offline.") +"\n" + tr("Messages you send will be delivered after Friend is again Online.")); - break; - - case RS_STATUS_INACTIVE: - ui->info_Frame->setVisible(true); - ui->infoLabel->setText(peerName + " " + tr("is Idle and may not reply")); - break; - - case RS_STATUS_ONLINE: - ui->info_Frame->setVisible(false); - break; - - case RS_STATUS_AWAY: - ui->infoLabel->setText(peerName + " " + tr("is Away and may not reply")); - ui->info_Frame->setVisible(true); - break; - - case RS_STATUS_BUSY: - ui->infoLabel->setText(peerName + " " + tr("is Busy and may not reply")); - ui->info_Frame->setVisible(true); - break; - } - - ui->titleLabel->setText(peerName); - ui->titleLabel->setToolTip(tooltip_info); - ui->statusLabel->setText(QString("(%1)").arg(StatusDefs::name(status))); - - peerStatus = status; - - if (atEnd) { - // scroll to the end - scrollbar->setValue(scrollbar->maximum()); - } - - emit infoChanged(this); - emit statusChanged(status); - - // Notify all ChatWidgetHolder - foreach (ChatWidgetHolder *chatWidgetHolder, mChatWidgetHolder) { - chatWidgetHolder->updateStatus(status); - } - - return; + tooltip_info = QString("Identity Id: ")+QString::fromStdString(dcpinfo.to_id.toStdString()); + } + else + { + peerName = QString::fromStdString(chatId.toDistantChatId().toStdString()) ; + tooltip_info = QString("Identity Id: unknown (bug?)"); + } + } + else + { + peerName = QString::fromUtf8(rsPeers->getPeerName(chatId.toPeerId()).c_str()); + tooltip_info = QString("Peer Id: ") + QString::fromStdString(chatId.toPeerId().toStdString()); } - // ignore status change + // is scrollbar at the end? + QScrollBar *scrollbar = ui->textBrowser->verticalScrollBar(); + bool atEnd = (scrollbar->value() == scrollbar->maximum()); + + switch (status) { + default: + case RsStatusValue::RS_STATUS_OFFLINE: + ui->info_Frame->setVisible(true); + ui->infoLabel->setText(peerName + " " + tr("appears to be Offline.") +"\n" + tr("Messages you send will be delivered after Friend is again Online.")); + break; + + case RsStatusValue::RS_STATUS_INACTIVE: + ui->info_Frame->setVisible(true); + ui->infoLabel->setText(peerName + " " + tr("is Idle and may not reply")); + break; + + case RsStatusValue::RS_STATUS_ONLINE: + ui->info_Frame->setVisible(false); + break; + + case RsStatusValue::RS_STATUS_AWAY: + ui->infoLabel->setText(peerName + " " + tr("is Away and may not reply")); + ui->info_Frame->setVisible(true); + break; + + case RsStatusValue::RS_STATUS_BUSY: + ui->infoLabel->setText(peerName + " " + tr("is Busy and may not reply")); + ui->info_Frame->setVisible(true); + break; + } + + ui->titleLabel->setText(peerName); + ui->titleLabel->setToolTip(tooltip_info); +#warning inconsistent conversion here + ui->statusLabel->setText(QString("(%1)").arg(StatusDefs::name((RsStatusValue)status))); + + peerStatus = status; + + if (atEnd) { + // scroll to the end + scrollbar->setValue(scrollbar->maximum()); + } + + emit infoChanged(this); + emit statusChanged(status); + + // Notify all ChatWidgetHolder + foreach (ChatWidgetHolder *chatWidgetHolder, mChatWidgetHolder) { + chatWidgetHolder->updateStatus(status); + } } void ChatWidget::updateTitle() @@ -1902,7 +1930,7 @@ void ChatWidget::updateTitle() ui->titleLabel->setText(RsHtml::plainText(name) + "@" + RsHtml::plainText(title)); } -void ChatWidget::updatePeersCustomStateString(const QString& peer_id, const QString& status_string) +void ChatWidget::updatePeersCustomStateString(const ChatId& id, const QString& status_string) { if (chatType() != CHATTYPE_PRIVATE ) { @@ -1911,7 +1939,7 @@ void ChatWidget::updatePeersCustomStateString(const QString& peer_id, const QStr QString status_text; - if (RsPeerId(peer_id.toStdString()) == chatId.toPeerId()) { + if (id.toPeerId() == chatId.toPeerId()) { // the peers status string has changed if (status_string.isEmpty()) { ui->statusMessageLabel->hide(); @@ -1930,7 +1958,7 @@ void ChatWidget::updatePeersCustomStateString(const QString& peer_id, const QStr void ChatWidget::updateStatusString(const QString &statusMask, const QString &statusString, bool permanent) { - ui->typingLabel->setText(QString(statusMask).arg(trUtf8(statusString.toUtf8()))); // displays info for 5 secs. + ui->typingLabel->setText(QString(statusMask).arg(tr(statusString.toUtf8()))); // displays info for 5 secs. ui->typingPixmapLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":icons/png/typing.png") ); if (statusString == "is typing...") { diff --git a/retroshare-gui/src/gui/chat/ChatWidget.h b/retroshare-gui/src/gui/chat/ChatWidget.h index e42df06fe..cdef805c8 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.h +++ b/retroshare-gui/src/gui/chat/ChatWidget.h @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -52,6 +53,17 @@ namespace Ui { class ChatWidget; } +enum class RsChatFlags: uint32_t { + RS_CHAT_NONE = 0x0000, + RS_CHAT_OPEN = 0x0001, + RS_CHAT_FOCUS = 0x0004, + RS_CHAT_TABBED_WINDOW = 0x0008, + RS_CHAT_BLINK = 0x0010, +}; + +RS_REGISTER_ENUM_FLAGS_TYPE(RsChatFlags); + + // a Container for the logic behind buttons in a PopupChatDialog // Plugins can implement this interface to provide their own buttons class ChatWidgetHolder @@ -62,7 +74,7 @@ public: // status comes from notifyPeerStatusChanged // see rststaus.h for possible values - virtual void updateStatus(int /*status*/) {} + virtual void updateStatus(RsStatusValue /*status*/) {} protected: ChatWidget *mChatWidget; @@ -105,7 +117,7 @@ public: void addToolsAction(QAction *action); QString getTitle() { return title; } - int getPeerStatus() { return peerStatus; } + RsStatusValue getPeerStatus() { return peerStatus; } void setName(const QString &name); bool setStyle(); @@ -130,7 +142,7 @@ public: const QList &chatWidgetHolderList() { return mChatWidgetHolder; } public slots: - void updateStatus(const QString &peer_id, int status); + void updateStatus(const ChatId &cid, RsStatusValue status); void setUseCMark(const bool bUseCMark); void updateCMPreview(); @@ -144,7 +156,7 @@ private slots: signals: void infoChanged(ChatWidget*); void newMessage(ChatWidget*); - void statusChanged(int); + void statusChanged(RsStatusValue); void textBrowserAskContextMenu(QMenu* contextMnu, QString anchorForPosition, const QPoint point); protected: @@ -189,7 +201,7 @@ private slots: void updateLenOfChatTextEdit(); void sendChat(); - void updatePeersCustomStateString(const QString& peer_id, const QString& status_string) ; + void updatePeersCustomStateString(const ChatId& id, const QString& status_string) ; bool fileSave(); bool fileSaveAs(); @@ -229,7 +241,7 @@ private: bool newMessages; bool typing; - int peerStatus; + RsStatusValue peerStatus; bool sendingBlocked; bool useCMark; @@ -272,6 +284,9 @@ private: ChatLobbyUserNotify* notify; Ui::ChatWidget *ui; + +// RsEventsHandlerId_t mEventHandlerId_chat ; + RsEventsHandlerId_t mEventHandlerId_friends ; }; #endif // CHATWIDGET_H diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp index 9cb422a8f..b16a7e226 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp @@ -26,11 +26,11 @@ #include "gui/common/FilesDefs.h" #include "gui/settings/rsharesettings.h" #include "gui/settings/RsharePeerSettings.h" -#include "gui/notifyqt.h" +#include "util/DateTime.h" +#include "util/qtthreadsutils.h" #include #include -#include #include @@ -49,7 +49,25 @@ PopupChatDialog::PopupChatDialog(QWidget *parent, Qt::WindowFlags flags) connect(ui.avatarFrameButton, SIGNAL(toggled(bool)), this, SLOT(showAvatarFrame(bool))); connect(ui.actionClearOfflineMessages, SIGNAL(triggered()), this, SLOT(clearOfflineMessages())); - connect(NotifyQt::getInstance(), SIGNAL(chatStatusChanged(ChatId,QString)), this, SLOT(chatStatusChanged(ChatId,QString))); + + mEventHandlerId_chat =0; + + rsEvents->registerEventsHandler( [this](std::shared_ptr e) + { + RsQThreadUtils::postToObject([=]() + { + auto fe = dynamic_cast(e.get()); if(!fe) return; + + switch(fe->mEventCode) + { + case RsChatServiceEventCode::CHAT_STATUS_CHANGED: chatStatusChanged(fe->mCid,QString::fromUtf8(fe->mStr.c_str())); break; + default: + break; + } + + } + , this ); + }, mEventHandlerId_chat, RsEventType::CHAT_SERVICE ); } void PopupChatDialog::init(const ChatId &chat_id, const QString &title) @@ -80,6 +98,7 @@ void PopupChatDialog::init(const ChatId &chat_id, const QString &title) /** Destructor. */ PopupChatDialog::~PopupChatDialog() { + rsEvents->unregisterEventsHandler(mEventHandlerId_chat); // save settings processSettings(false); } @@ -91,7 +110,7 @@ ChatWidget *PopupChatDialog::getChatWidget() bool PopupChatDialog::notifyBlink() { - return (Settings->getChatFlags() & RS_CHAT_BLINK); + return (Settings->getChatFlags() & (uint32_t)RsChatFlags::RS_CHAT_BLINK); } void PopupChatDialog::processSettings(bool load) @@ -107,7 +126,7 @@ void PopupChatDialog::processSettings(bool load) Settings->endGroup(); } -void PopupChatDialog::showDialog(uint chatflags) +void PopupChatDialog::showDialog(RsChatFlags chatflags) { PopupChatWindow *window = WINDOW(this); if (window) { @@ -130,8 +149,8 @@ void PopupChatDialog::addChatMsg(const ChatMessage &msg) { ChatWidget *cw = getChatWidget(); if (cw) { - QDateTime sendTime = QDateTime::fromTime_t(msg.sendTime); - QDateTime recvTime = QDateTime::fromTime_t(msg.recvTime); + QDateTime sendTime = DateTime::DateTimeFromTime_t(msg.sendTime); + QDateTime recvTime = DateTime::DateTimeFromTime_t(msg.recvTime); QString additional_info ; QString message = QString::fromUtf8(msg.msg.c_str()); QString name = msg.incoming? getPeerName(msg.chat_id,additional_info): getOwnName(); diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.h b/retroshare-gui/src/gui/chat/PopupChatDialog.h index 91fa17091..7c2711971 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.h +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.h @@ -42,15 +42,15 @@ private slots: protected: /** Default constructor */ - PopupChatDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0); + PopupChatDialog(QWidget *parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); /** Default destructor */ virtual ~PopupChatDialog(); - virtual void init(const ChatId &chat_id, const QString &title); - virtual void showDialog(uint chatflags); - virtual ChatWidget *getChatWidget(); - virtual bool hasPeerStatus() { return true; } - virtual bool notifyBlink(); + virtual void init(const ChatId &chat_id, const QString &title) override; + virtual void showDialog(RsChatFlags chatflags) override; + virtual ChatWidget *getChatWidget() override; + virtual bool hasPeerStatus() override{ return true; } + virtual bool notifyBlink() override; virtual void updateStatus(int /*status*/) {} @@ -65,6 +65,8 @@ protected: /** Qt Designer generated object */ Ui::PopupChatDialog ui; + + RsEventsHandlerId_t mEventHandlerId_chat; }; #endif diff --git a/retroshare-gui/src/gui/chat/PopupChatWindow.cpp b/retroshare-gui/src/gui/chat/PopupChatWindow.cpp index 1f15345b1..eb2f6d7a0 100644 --- a/retroshare-gui/src/gui/chat/PopupChatWindow.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatWindow.cpp @@ -23,6 +23,9 @@ #include #include #include +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) +#include +#endif #include "gui/common/FilesDefs.h" #include "PopupChatWindow.h" @@ -36,7 +39,6 @@ #include #include -#include #define IMAGE_TYPING ":/images/white-bubble-64.png" @@ -46,7 +48,7 @@ static PopupChatWindow *instance = NULL; /*static*/ PopupChatWindow *PopupChatWindow::getWindow(bool needSingleWindow) { - if (needSingleWindow == false && (Settings->getChatFlags() & RS_CHAT_TABBED_WINDOW)) { + if (needSingleWindow == false && (Settings->getChatFlags() & (uint32_t)RsChatFlags::RS_CHAT_TABBED_WINDOW)) { if (instance == NULL) { instance = new PopupChatWindow(true); } @@ -159,7 +161,7 @@ void PopupChatWindow::showContextMenu(QPoint) } } - if (Settings->getChatFlags() & RS_CHAT_TABBED_WINDOW) + if (Settings->getChatFlags() & (uint32_t)RsChatFlags::RS_CHAT_TABBED_WINDOW) { if(tabbedWindow) contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/tab-dock.png"),tr("Dock window"),this,SLOT(docTab())); @@ -205,7 +207,14 @@ void PopupChatWindow::showEvent(QShowEvent */*event*/) if (tabbedWindow) { Settings->loadWidgetInformation(this); } else { - this->move(qrand()%100, qrand()%100); //avoid to stack multiple popup chat windows on the same position +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) + int x = QRandomGenerator::global()->generate(); + int y = QRandomGenerator::global()->generate(); +#else + int x = qrand(); + int y = qrand(); +#endif + this->move(x % 100, y % 100); //avoid to stack multiple popup chat windows on the same position PeerSettings->loadWidgetInformation(chatId, this); } } @@ -290,9 +299,9 @@ void PopupChatWindow::removeDialog(ChatDialog *dialog) } } -void PopupChatWindow::showDialog(ChatDialog *dialog, uint chatflags) +void PopupChatWindow::showDialog(ChatDialog *dialog, RsChatFlags chatflags) { - if (chatflags & RS_CHAT_FOCUS) { + if (!!(chatflags & RsChatFlags::RS_CHAT_FOCUS)) { if (tabbedWindow) { ui.tabWidget->setCurrentWidget(dialog); } @@ -342,7 +351,7 @@ void PopupChatWindow::calculateTitle(ChatDialog *dialog) icon = FilesDefs::getIconFromQtResourcePath(IMAGE_TYPING); } else if (hasNewMessages) { icon = FilesDefs::getIconFromQtResourcePath(IMAGE_CHAT); - if (Settings->getChatFlags() & RS_CHAT_BLINK) { + if (Settings->getChatFlags() & (uint32_t)RsChatFlags::RS_CHAT_BLINK) { mBlinkIcon = icon; } else { mBlinkIcon = QIcon(); @@ -350,7 +359,7 @@ void PopupChatWindow::calculateTitle(ChatDialog *dialog) } else { mBlinkIcon = QIcon(); if (cd && cd->hasPeerStatus()) { - icon = QIcon(StatusDefs::imageIM(cd->getPeerStatus())); + icon = QIcon(StatusDefs::imageIM((RsStatusValue)cd->getPeerStatus())); } else { icon = qApp->windowIcon(); } @@ -361,7 +370,7 @@ void PopupChatWindow::calculateTitle(ChatDialog *dialog) if (cd) { QString title = cd->getTitle(); if (cd->hasPeerStatus()) { - title += " (" + StatusDefs::name(cd->getPeerStatus()) + ")"; + title += " (" + StatusDefs::name((RsStatusValue)cd->getPeerStatus()) + ")"; } setWindowTitle(title); } else { @@ -413,7 +422,7 @@ void PopupChatWindow::tabNewMessage(ChatDialog *dialog) void PopupChatWindow::dockTab() { - if ((Settings->getChatFlags() & RS_CHAT_TABBED_WINDOW) && chatDialog) { + if ((Settings->getChatFlags() & (uint32_t)RsChatFlags::RS_CHAT_TABBED_WINDOW) && chatDialog) { PopupChatWindow *pcw = getWindow(false); if (pcw) { ChatDialog *pcd = chatDialog; diff --git a/retroshare-gui/src/gui/chat/PopupChatWindow.h b/retroshare-gui/src/gui/chat/PopupChatWindow.h index 968531ea1..036df8924 100644 --- a/retroshare-gui/src/gui/chat/PopupChatWindow.h +++ b/retroshare-gui/src/gui/chat/PopupChatWindow.h @@ -27,6 +27,9 @@ #include "ui_PopupChatWindow.h" #include #include + +#include "gui/chat/ChatWidget.h" + Q_DECLARE_METATYPE(RsGxsId) Q_DECLARE_METATYPE(QList) @@ -43,13 +46,13 @@ public: public: void addDialog(ChatDialog *dialog); void removeDialog(ChatDialog *dialog); - void showDialog(ChatDialog *dialog, uint chatflags); + void showDialog(ChatDialog *dialog, RsChatFlags chatflags); void alertDialog(ChatDialog *dialog); void calculateTitle(ChatDialog *dialog); protected: /** Default constructor */ - PopupChatWindow(bool tabbed, QWidget *parent = 0, Qt::WindowFlags flags = 0); + PopupChatWindow(bool tabbed, QWidget *parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); /** Default destructor */ ~PopupChatWindow(); diff --git a/retroshare-gui/src/gui/chat/PopupChatWindow.ui b/retroshare-gui/src/gui/chat/PopupChatWindow.ui index 0394a1c31..7f1dc2f24 100644 --- a/retroshare-gui/src/gui/chat/PopupChatWindow.ui +++ b/retroshare-gui/src/gui/chat/PopupChatWindow.ui @@ -85,7 +85,7 @@ - + :/images/tab-dock.png:/images/tab-dock.png @@ -97,7 +97,7 @@ - + :/images/tab-undock.png:/images/tab-undock.png diff --git a/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp index c5ab40cbf..0e8faba80 100644 --- a/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp @@ -121,7 +121,7 @@ void PopupDistantChatDialog::updateDisplay() getChatWidget()->blockSending(tr( "Can't send message immediately, " "because there is no tunnel " "available." )); - setPeerStatus(RS_STATUS_OFFLINE); + setPeerStatus(RsStatusValue::RS_STATUS_OFFLINE); break ; case RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED: std::cerr << "Chat remotely closed. " << std::endl; @@ -131,7 +131,7 @@ void PopupDistantChatDialog::updateDisplay() getChatWidget()->updateStatusString("%1", tr( "Your partner closed the conversation." ), true ); getChatWidget()->blockSending(tr( "Your partner closed the conversation.")); - setPeerStatus(RS_STATUS_OFFLINE) ; + setPeerStatus(RsStatusValue::RS_STATUS_OFFLINE) ; break ; case RS_DISTANT_CHAT_STATUS_TUNNEL_DN: @@ -145,7 +145,7 @@ void PopupDistantChatDialog::updateDisplay() _status_label->setToolTip(msg); getChatWidget()->updateStatusString("%1", msg, true); getChatWidget()->blockSending(msg); - setPeerStatus(RS_STATUS_OFFLINE); + setPeerStatus(RsStatusValue::RS_STATUS_OFFLINE); break; case RS_DISTANT_CHAT_STATUS_CAN_TALK: @@ -153,7 +153,7 @@ void PopupDistantChatDialog::updateDisplay() msg = QObject::tr( "End-to-end encrypted conversation established"); _status_label->setToolTip(msg); getChatWidget()->unblockSending(); - setPeerStatus(RS_STATUS_ONLINE); + setPeerStatus(RsStatusValue::RS_STATUS_ONLINE); break; } } diff --git a/retroshare-gui/src/gui/chat/PopupDistantChatDialog.h b/retroshare-gui/src/gui/chat/PopupDistantChatDialog.h index 15a83232f..b9f57ab25 100644 --- a/retroshare-gui/src/gui/chat/PopupDistantChatDialog.h +++ b/retroshare-gui/src/gui/chat/PopupDistantChatDialog.h @@ -34,7 +34,7 @@ class PopupDistantChatDialog: public PopupChatDialog protected: /** Default constructor */ - PopupDistantChatDialog(const DistantChatPeerId &tunnel_id, QWidget *parent = 0, Qt::WindowFlags flags = 0); + PopupDistantChatDialog(const DistantChatPeerId &tunnel_id, QWidget *parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); /** Default destructor */ virtual ~PopupDistantChatDialog(); diff --git a/retroshare-gui/src/gui/common/AvatarDialog.cpp b/retroshare-gui/src/gui/common/AvatarDialog.cpp index dd302b570..c89483499 100644 --- a/retroshare-gui/src/gui/common/AvatarDialog.cpp +++ b/retroshare-gui/src/gui/common/AvatarDialog.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -41,6 +42,7 @@ #include "gui/common/FilesDefs.h" #include "util/HandleRichText.h" #include "util/imageutil.h" +#include "util/RsQtVersion.h" #include "retroshare/rsinit.h" #define ICONNAME "groupicon.png" @@ -106,8 +108,8 @@ void AvatarDialog::removeAvatar() void AvatarDialog::updateInterface() { - const QPixmap *pixmap = ui->avatarLabel->pixmap(); - if (pixmap && !pixmap->isNull()) { + QPixmap pixmap = QLabel_pixmap(ui->avatarLabel); + if (!pixmap.isNull()) { ui->removeButton->setEnabled(true); } else { ui->removeButton->setEnabled(false); @@ -122,13 +124,7 @@ void AvatarDialog::setAvatar(const QPixmap &avatar) void AvatarDialog::getAvatar(QPixmap &avatar) { - const QPixmap *pixmap = ui->avatarLabel->pixmap(); - if (!pixmap) { - avatar = QPixmap(); - return; - } - - avatar = *pixmap; + avatar = QLabel_pixmap(ui->avatarLabel); } void AvatarDialog::getAvatar(QByteArray &avatar) diff --git a/retroshare-gui/src/gui/common/AvatarWidget.cpp b/retroshare-gui/src/gui/common/AvatarWidget.cpp index 02151730a..b19917c8b 100644 --- a/retroshare-gui/src/gui/common/AvatarWidget.cpp +++ b/retroshare-gui/src/gui/common/AvatarWidget.cpp @@ -25,8 +25,8 @@ #include #include -#include "gui/notifyqt.h" #include "util/misc.h" +#include "util/qtthreadsutils.h" #include "gui/common/AvatarDefs.h" #include "gui/common/AvatarDialog.h" @@ -39,21 +39,44 @@ AvatarWidget::AvatarWidget(QWidget *parent) : QLabel(parent), ui(new Ui::AvatarWidget) { - ui->setupUi(this); + ui->setupUi(this); - mFlag.isOwnId = false; - defaultAvatar = ":/images/no_avatar_background.png"; - mPeerState = RS_STATUS_OFFLINE ; + mFlag.isOwnId = false; + defaultAvatar = ":/images/no_avatar_background.png"; + mPeerState = RsStatusValue::RS_STATUS_OFFLINE ; - setFrameType(NO_FRAME); + setFrameType(NO_FRAME); + + mEventHandlerId = 0; + + rsEvents->registerEventsHandler( [this](std::shared_ptr event) + { + RsQThreadUtils::postToObject([=](){ + + const RsFriendListEvent *e = dynamic_cast(event.get()); + if(!e) + return; + + switch(e->mEventCode) + { + case RsFriendListEventCode::OWN_AVATAR_CHANGED: + case RsFriendListEventCode::NODE_AVATAR_CHANGED: updateAvatar(QString::fromStdString(e->mSslId.toStdString())); + break; + case RsFriendListEventCode::OWN_STATUS_CHANGED: + case RsFriendListEventCode::NODE_STATUS_CHANGED: updateStatus(QString::fromStdString(e->mSslId.toStdString()),e->mStatus); + default: + break; + } + + + }, this ); + }, mEventHandlerId, RsEventType::FRIEND_LIST ); - /* connect signals */ - connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(const QString&)), this, SLOT(updateAvatar(const QString&))); - connect(NotifyQt::getInstance(), SIGNAL(ownAvatarChanged()), this, SLOT(updateOwnAvatar())); } AvatarWidget::~AvatarWidget() { + rsEvents->unregisterEventsHandler(mEventHandlerId); delete ui; } @@ -68,16 +91,18 @@ QString AvatarWidget::frameState() case STATUS_FRAME: switch (mPeerState) { - case RS_STATUS_OFFLINE: + case RsStatusValue::RS_STATUS_OFFLINE: return "OFFLINE"; - case RS_STATUS_INACTIVE: + case RsStatusValue::RS_STATUS_INACTIVE: return "INACTIVE"; - case RS_STATUS_ONLINE: + case RsStatusValue::RS_STATUS_ONLINE: return "ONLINE"; - case RS_STATUS_AWAY: + case RsStatusValue::RS_STATUS_AWAY: return "AWAY"; - case RS_STATUS_BUSY: + case RsStatusValue::RS_STATUS_BUSY: return "BUSY"; + default: + break; } } return "NOTHING"; @@ -107,18 +132,6 @@ void AvatarWidget::setFrameType(FrameType type) { mFrameType = type; - switch (mFrameType) { - case NO_FRAME: - disconnect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateStatus(const QString&, int))); - break; - case NORMAL_FRAME: - disconnect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateStatus(const QString&, int))); - break; - case STATUS_FRAME: - connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateStatus(const QString&, int))); - break; - } - //refreshAvatarImage(); refreshStatus(); RsApplication::refreshStyleSheet(this, false); @@ -179,7 +192,7 @@ void AvatarWidget::refreshStatus() } case STATUS_FRAME: { - uint32_t status = 0; + RsStatusValue status = RsStatusValue::RS_STATUS_OFFLINE; if (mId.isNotSet()) return; @@ -193,7 +206,7 @@ void AvatarWidget::refreshStatus() status = statusInfo.status ; } else if(mId.isDistantChatId()) - status = RS_STATUS_ONLINE ; + status = RsStatusValue::RS_STATUS_ONLINE ; else { std::cerr << "Unhandled chat id type in AvatarWidget::refreshStatus()" << std::endl; @@ -217,10 +230,10 @@ void AvatarWidget::refreshStatus() { switch (dcpinfo.status) { - case RS_DISTANT_CHAT_STATUS_CAN_TALK : status = RS_STATUS_ONLINE ; break; + case RS_DISTANT_CHAT_STATUS_CAN_TALK : status = RsStatusValue::RS_STATUS_ONLINE ; break; case RS_DISTANT_CHAT_STATUS_UNKNOWN : // Fall-through case RS_DISTANT_CHAT_STATUS_TUNNEL_DN : // Fall-through - case RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED : status = RS_STATUS_OFFLINE; + case RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED : status = RsStatusValue::RS_STATUS_OFFLINE; } } else @@ -238,20 +251,20 @@ void AvatarWidget::refreshStatus() } } -void AvatarWidget::updateStatus(const QString& peerId, int status) +void AvatarWidget::updateStatus(const QString& peerId, RsStatusValue status) { if (mId.isPeerId() && mId.toPeerId() == RsPeerId(peerId.toStdString())) updateStatus(status) ; } -void AvatarWidget::updateStatus(int status) +void AvatarWidget::updateStatus(RsStatusValue status) { if (mFrameType != STATUS_FRAME) return; mPeerState = status; - setEnabled(((uint32_t) status == RS_STATUS_OFFLINE) ? false : true); + setEnabled((status == RsStatusValue::RS_STATUS_OFFLINE) ? false : true); RsApplication::refreshStyleSheet(this, false); } diff --git a/retroshare-gui/src/gui/common/AvatarWidget.h b/retroshare-gui/src/gui/common/AvatarWidget.h index e3b90022b..4e81b3ef1 100644 --- a/retroshare-gui/src/gui/common/AvatarWidget.h +++ b/retroshare-gui/src/gui/common/AvatarWidget.h @@ -24,7 +24,9 @@ #include #include #include +#include #include +#include namespace Ui { class AvatarWidget; @@ -57,14 +59,14 @@ protected: void mouseReleaseEvent(QMouseEvent *event); private slots: - void updateStatus(const QString& peerId, int status); + void updateStatus(const QString& peerId, RsStatusValue status); void updateAvatar(const QString& peerId); void updateOwnAvatar(); private: void refreshAvatarImage() ; void refreshStatus(); - void updateStatus(int status); + void updateStatus(RsStatusValue status); QString defaultAvatar; Ui::AvatarWidget *ui; @@ -77,7 +79,9 @@ private: // bool isGpg : 1; } mFlag; FrameType mFrameType; - uint32_t mPeerState; + RsStatusValue mPeerState; + + RsEventsHandlerId_t mEventHandlerId; }; #endif // AVATARWIDGET_H diff --git a/retroshare-gui/src/gui/common/Emoticons.cpp b/retroshare-gui/src/gui/common/Emoticons.cpp index 2341039cd..423149164 100644 --- a/retroshare-gui/src/gui/common/Emoticons.cpp +++ b/retroshare-gui/src/gui/common/Emoticons.cpp @@ -19,7 +19,6 @@ *******************************************************************************/ #include -#include #include #include #include @@ -34,6 +33,7 @@ #include #include +#include "rshare.h" #include "Emoticons.h" #include "util/HandleRichText.h" #include "retroshare/rsinit.h" @@ -261,7 +261,7 @@ void Emoticons::showSmileyWidget(QWidget *parent, QWidget *button, const char *s //Get widget's size QSize sizeWidget = smWidget->sizeHint(); //Get screen's size - QSize sizeScreen = QApplication::desktop()->size(); + QSize sizeScreen = RsApplication::primaryScreenGeometry().size(); //Calculate left distance to screen start int distToScreenLeft = butTopLeft.x(); @@ -437,7 +437,7 @@ void Emoticons::showStickerWidget(QWidget *parent, QWidget *button, const char * //Get widget's size QSize sizeWidget = smWidget->sizeHint(); //Get screen's size - QSize sizeScreen = QApplication::desktop()->size(); + QSize sizeScreen = RsApplication::primaryScreenGeometry().size(); //Calculate left distance to screen start int distToScreenLeft = butTopLeft.x(); diff --git a/retroshare-gui/src/gui/common/FlowLayout.cpp b/retroshare-gui/src/gui/common/FlowLayout.cpp index aca787c22..de29ca029 100644 --- a/retroshare-gui/src/gui/common/FlowLayout.cpp +++ b/retroshare-gui/src/gui/common/FlowLayout.cpp @@ -23,6 +23,7 @@ #include #include #include +#include //*** FlowLayoutItem ********************************************************** @@ -598,7 +599,8 @@ QSize FlowLayout::minimumSize() const foreach (item, m_itemList) size = size.expandedTo(item->minimumSize()); - size += QSize(2*margin(), 2*margin()); + QMargins margins = contentsMargins(); + size += QSize(margins.left() + margins.right(), margins.top() + margins.bottom()); return size; } @@ -645,7 +647,7 @@ void FlowLayout::performDrag() if (curs==0) dragPixmap = itemPixmap; QPixmap oldPixmap = dragPixmap; if (curs!=0) dragPixmap = QPixmap(oldPixmap.width() + 20 , oldPixmap.height()); - dragPixmap.fill(widget->palette().background().color()); + dragPixmap.fill(widget->palette().window().color()); QPainter painter(&dragPixmap); painter.drawPixmap(0, 0, oldPixmap); if (curs!=0) painter.drawPixmap((20 * curs), 0, itemPixmap); diff --git a/retroshare-gui/src/gui/common/FlowLayout.h b/retroshare-gui/src/gui/common/FlowLayout.h index ff21f266a..585c98717 100644 --- a/retroshare-gui/src/gui/common/FlowLayout.h +++ b/retroshare-gui/src/gui/common/FlowLayout.h @@ -81,7 +81,7 @@ public: void paintEvent(QPaintEvent *) { QStyleOption opt; - opt.init(this); + opt.initFrom(this); QPainter p(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); } diff --git a/retroshare-gui/src/gui/common/FriendList.cpp b/retroshare-gui/src/gui/common/FriendList.cpp index dd2d17875..7057e8418 100644 --- a/retroshare-gui/src/gui/common/FriendList.cpp +++ b/retroshare-gui/src/gui/common/FriendList.cpp @@ -51,7 +51,7 @@ #include "StatusDefs.h" #include "util/misc.h" #include "vmessagebox.h" -#include "util/QtVersion.h" +#include "util/RsQtVersion.h" #include "gui/chat/ChatUserNotify.h" #include "gui/connect/ConnectProgressDialog.h" #include "gui/common/ElidedLabel.h" @@ -304,7 +304,7 @@ void FriendList::peerTreeWidgetCustomPopupMenu() // create menu header QHBoxLayout *hbox = new QHBoxLayout(widget); - hbox->setMargin(0); + hbox->setContentsMargins(0, 0, 0, 0); hbox->setSpacing(6); QLabel *iconLabel = new QLabel(widget); @@ -936,7 +936,7 @@ void FriendList::insertPeers() AvatarDefs::getAvatarFromSslId(RsPeerId(sslDetail.id.toStdString()), sslAvatar); /* last contact */ - QDateTime sslLastContact = QDateTime::fromTime_t(sslDetail.lastConnect); + QDateTime sslLastContact = DateTime::DateTimeFromTime_t(sslDetail.lastConnect); sslItem->setData(COLUMN_LAST_CONTACT, Qt::DisplayRole, QVariant(sslLastContact)); sslItem->setData(COLUMN_LAST_CONTACT, ROLE_SORT_NAME, QVariant(sslLastContact)); if (sslLastContact > bestLastContact) { diff --git a/retroshare-gui/src/gui/common/FriendListModel.cpp b/retroshare-gui/src/gui/common/FriendListModel.cpp index 45c054698..54f1f3cb2 100644 --- a/retroshare-gui/src/gui/common/FriendListModel.cpp +++ b/retroshare-gui/src/gui/common/FriendListModel.cpp @@ -422,7 +422,7 @@ QVariant RsFriendListModel::data(const QModelIndex &index, int role) const case Qt::SizeHintRole: return sizeHintRole(entry,index.column()) ; case Qt::DisplayRole: return displayRole(entry,index.column()) ; case Qt::FontRole: return fontRole(entry,index.column()) ; - case Qt::TextColorRole: return textColorRole(entry,index.column()) ; + case Qt::ForegroundRole: return textColorRole(entry,index.column()) ; case Qt::DecorationRole: return decorationRole(entry,index.column()) ; case FilterRole: return filterRole(entry,index.column()) ; @@ -458,7 +458,7 @@ QVariant RsFriendListModel::statusRole(const EntryIndex& fmpe,int /*column*/) co StatusInfo status; rsStatus->getStatus(node->node_info.id, status); - return QVariant(status.status); + return QVariant((int)status.status); } return QVariant(); } @@ -603,7 +603,7 @@ QVariant RsFriendListModel::onlineRole(const EntryIndex& e, int /*col*/) const for(uint32_t i=0;ichild_node_indices.size();++i) if(mLocations[prof->child_node_indices[i]].node_info.state & RS_PEER_STATE_CONNECTED) - return QVariant(RS_STATUS_ONLINE); + return QVariant((int)RsStatusValue::RS_STATUS_ONLINE); } } break; @@ -626,12 +626,12 @@ QVariant RsFriendListModel::onlineRole(const EntryIndex& e, int /*col*/) const const HierarchicalNodeInformation *node = getNodeInfo(e); if(node && bool(node->node_info.state & RS_PEER_STATE_CONNECTED)) - return QVariant(RS_STATUS_ONLINE); + return QVariant((int)RsStatusValue::RS_STATUS_ONLINE); else - return QVariant(RS_STATUS_OFFLINE); + return QVariant((int)RsStatusValue::RS_STATUS_OFFLINE); } } - return QVariant(RS_STATUS_OFFLINE); + return QVariant((int)RsStatusValue::RS_STATUS_OFFLINE); } QVariant RsFriendListModel::fontRole(const EntryIndex& e, int col) const @@ -640,14 +640,14 @@ QVariant RsFriendListModel::fontRole(const EntryIndex& e, int col) const std::cerr << " font role " << e.type << ", (" << (int)e.group_index << ","<< (int)e.profile_index << ","<< (int)e.node_index << ") col="<< col<<": " << std::endl; #endif - int status = onlineRole(e,col).toInt(); + auto status = RsStatusValue(onlineRole(e,col).toInt()); switch (status) { - case RS_STATUS_AWAY: - case RS_STATUS_BUSY: - case RS_STATUS_ONLINE: - case RS_STATUS_INACTIVE: + case RsStatusValue::RS_STATUS_AWAY: + case RsStatusValue::RS_STATUS_BUSY: + case RsStatusValue::RS_STATUS_ONLINE: + case RsStatusValue::RS_STATUS_INACTIVE: { QFont font ; QTreeView* myParent = dynamic_cast(QAbstractItemModel::parent()); @@ -730,13 +730,13 @@ QVariant RsFriendListModel::displayRole(const EntryIndex& e, int col) const { const HierarchicalProfileInformation *hn = getProfileInfo(e); - QDateTime most_recent_time = QDateTime::fromTime_t(0); + QDateTime most_recent_time = DateTime::DateTimeFromTime_t(0); QString most_recent_ip("---"); for(uint32_t i=0;ichild_node_indices.size();++i) { const HierarchicalNodeInformation& node = mLocations[hn->child_node_indices[i]]; - auto node_time = QDateTime::fromTime_t(node.node_info.lastConnect); + auto node_time = DateTime::DateTimeFromTime_t(node.node_info.lastConnect); if(most_recent_time < node_time) { @@ -781,13 +781,13 @@ QVariant RsFriendListModel::displayRole(const EntryIndex& e, int col) const else { return QVariant(QString::fromUtf8(node->node_info.location.c_str())+"\n" - + "(" + StatusDefs::name(statusRole(e,col).toInt()) + ")"); + + "(" + StatusDefs::name(RsStatusValue(statusRole(e,col).toInt())) + ")"); } else return QVariant(QString::fromUtf8(node->node_info.location.c_str())); } - case COLUMN_THREAD_LAST_CONTACT: return QVariant(QDateTime::fromTime_t(node->node_info.lastConnect).toString()); + case COLUMN_THREAD_LAST_CONTACT: return QVariant(DateTime::DateTimeFromTime_t(node->node_info.lastConnect).toString()); case COLUMN_THREAD_IP: return QVariant( (node->node_info.state & RS_PEER_STATE_CONNECTED) ? StatusDefs::connectStateIpString(node->node_info) : QString("---")); case COLUMN_THREAD_ID: return QVariant( QString::fromStdString(node->node_info.id.toStdString()) ); @@ -900,10 +900,10 @@ bool RsFriendListModel::getPeerOnlineStatus(const EntryIndex& e) const return (noded && (noded->node_info.state & RS_PEER_STATE_CONNECTED)); } -const RsFriendListModel::HierarchicalNodeInformation *RsFriendListModel::getBestNodeInformation(const HierarchicalProfileInformation *profileInfo, uint32_t *status) const +const RsFriendListModel::HierarchicalNodeInformation *RsFriendListModel::getBestNodeInformation(const HierarchicalProfileInformation *profileInfo, RsStatusValue *status) const { if (status) { - *status = RS_STATUS_OFFLINE; + *status = RsStatusValue::RS_STATUS_OFFLINE; } if (!profileInfo) { @@ -921,28 +921,28 @@ const RsFriendListModel::HierarchicalNodeInformation *RsFriendListModel::getBest int statusIndex = 0; switch (statusInfo.status) { - case RS_STATUS_OFFLINE: + case RsStatusValue::RS_STATUS_OFFLINE: statusIndex = 1; break; - case RS_STATUS_INACTIVE: + case RsStatusValue::RS_STATUS_INACTIVE: statusIndex = 2; break; - case RS_STATUS_AWAY: + case RsStatusValue::RS_STATUS_AWAY: statusIndex = 3; break; - case RS_STATUS_BUSY: + case RsStatusValue::RS_STATUS_BUSY: statusIndex = 4; break; - case RS_STATUS_ONLINE: + case RsStatusValue::RS_STATUS_ONLINE: statusIndex = 5; break; default: - std::cerr << "FriendListModel: Unknown status " << statusInfo.status << std::endl; + std::cerr << "FriendListModel: Unknown status " << (int)statusInfo.status << std::endl; } if (bestStatusIndex == 0 || statusIndex > bestStatusIndex) { @@ -999,7 +999,7 @@ QVariant RsFriendListModel::decorationRole(const EntryIndex& entry,int col) cons QPixmap sslAvatar; bool foundAvatar = false; const HierarchicalProfileInformation *hn = getProfileInfo(entry); - uint32_t status = RS_STATUS_OFFLINE; + RsStatusValue status = RsStatusValue::RS_STATUS_OFFLINE; const HierarchicalNodeInformation *bestNodeInformation = NULL; if (mDisplayStatusIcon) { @@ -1049,7 +1049,7 @@ QVariant RsFriendListModel::decorationRole(const EntryIndex& entry,int col) cons QPixmap sslAvatar; AvatarDefs::getAvatarFromSslId(RsPeerId(hn->node_info.id.toStdString()), sslAvatar); if (mDisplayStatusIcon) { - QPixmap sslOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(StatusDefs::imageStatus(statusRole(entry, col).toInt())); + QPixmap sslOverlayIcon = FilesDefs::getPixmapFromQtResourcePath(StatusDefs::imageStatus(RsStatusValue(statusRole(entry, col).toInt()))); return QVariant(QIcon(createAvatar(sslAvatar, sslOverlayIcon))); } diff --git a/retroshare-gui/src/gui/common/FriendListModel.h b/retroshare-gui/src/gui/common/FriendListModel.h index e19a84f04..4020e6fc7 100644 --- a/retroshare-gui/src/gui/common/FriendListModel.h +++ b/retroshare-gui/src/gui/common/FriendListModel.h @@ -162,7 +162,7 @@ public: /* Color definitions (for standard see default.qss) */ QColor mTextColorGroup; - QColor mTextColorStatus[RS_STATUS_COUNT]; + QColor mTextColorStatus[(int)RsStatusValue::RS_STATUS_COUNT]; private: const HierarchicalGroupInformation *getGroupInfo (const EntryIndex&) const; @@ -223,7 +223,7 @@ private: uint32_t updateFilterStatus(ForumModelIndex i,int column,const QStringList& strings); - const HierarchicalNodeInformation *getBestNodeInformation(const HierarchicalProfileInformation *profileInfo, uint32_t *status = NULL) const; + const HierarchicalNodeInformation *getBestNodeInformation(const HierarchicalProfileInformation *profileInfo, RsStatusValue *status = NULL) const; QStringList mFilterStrings; FilterType mFilterType; diff --git a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp index d9fc4b8dc..e792518f0 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp +++ b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp @@ -25,7 +25,6 @@ #include "ui_FriendSelectionWidget.h" #include "gui/gxs/GxsIdDetails.h" #include -#include "gui/notifyqt.h" #include "gui/common/RSTreeWidgetItem.h" #include "gui/common/StatusDefs.h" #include "util/qtthreadsutils.h" @@ -101,9 +100,6 @@ FriendSelectionWidget::FriendSelectionWidget(QWidget *parent) connect(ui->friendList, SIGNAL(itemSelectionChanged()), this, SIGNAL(itemSelectionChanged())); connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString))); - connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(groupsChanged(int))); - connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(const QString&,int)), this, SLOT(peerStatusChanged(const QString&,int))); - mCompareRole = new RSTreeWidgetItemCompareRole; mActionSortByState = new QAction(tr("Sort by state"), this); mActionSortByState->setCheckable(true); @@ -134,7 +130,7 @@ FriendSelectionWidget::FriendSelectionWidget(QWidget *parent) RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }) ;}, mEventHandlerId_identities, RsEventType::GXS_IDENTITY ); mEventHandlerId_peers = 0; rsEvents->registerEventsHandler( [this](std::shared_ptr event) { - RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }) ;}, mEventHandlerId_peers, RsEventType::PEER_CONNECTION ); + RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }) ;}, mEventHandlerId_peers, RsEventType::FRIEND_LIST ); mFontSizeHandler.registerFontSize(ui->friendList); } @@ -149,17 +145,31 @@ void FriendSelectionWidget::handleEvent_main_thread(std::shared_ptr(event.get()); + const RsFriendListEvent *fp = dynamic_cast(event.get()); if(fp) - switch(fp->mConnectionInfoCode) + switch(fp->mEventCode) { - case RsConnectionEventCode::PEER_REMOVED: - case RsConnectionEventCode::PEER_ADDED: + case RsFriendListEventCode::NODE_REMOVED: + case RsFriendListEventCode::NODE_ADDED: updateDisplay(true); update(); // Qt flush break; - default: break ; + case RsFriendListEventCode::GROUP_ADDED: + case RsFriendListEventCode::GROUP_REMOVED: + case RsFriendListEventCode::GROUP_CHANGED: + groupsChanged(); + break; + + case RsFriendListEventCode::NODE_STATUS_CHANGED: + { + StatusInfo i; + rsStatus->getStatus(fp->mSslId,i); + + peerStatusChanged(fp->mSslId,i.status); + } + default: + break ; } } @@ -241,7 +251,7 @@ static void initSslItem(QTreeWidgetItem *item, const RsPeerDetails &detail, cons QString name = PeerDefs::nameWithLocation(detail); item->setText(COLUMN_NAME, name); - int state = RS_STATUS_OFFLINE; + RsStatusValue state = RsStatusValue::RS_STATUS_OFFLINE; if (detail.state & RS_PEER_STATE_CONNECTED) { std::list::const_iterator it; for (it = statusInfo.begin(); it != statusInfo.end() ; ++it) { @@ -252,7 +262,7 @@ static void initSslItem(QTreeWidgetItem *item, const RsPeerDetails &detail, cons } } - if (state != (int) RS_STATUS_OFFLINE) { + if (state != RsStatusValue::RS_STATUS_OFFLINE) { item->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline); } @@ -262,7 +272,7 @@ static void initSslItem(QTreeWidgetItem *item, const RsPeerDetails &detail, cons item->setData(COLUMN_NAME, ROLE_SORT_GROUP, 1); item->setData(COLUMN_NAME, ROLE_SORT_STANDARD_GROUP, 0); item->setData(COLUMN_NAME, ROLE_SORT_NAME, name); - item->setData(COLUMN_NAME, ROLE_SORT_STATE, state); + item->setData(COLUMN_NAME, ROLE_SORT_STATE, (int)state); } void FriendSelectionWidget::fillList() @@ -501,17 +511,17 @@ void FriendSelectionWidget::secured_fillList() sslIds.clear(); rsPeers->getAssociatedSSLIds(*gpgIt, sslIds); - int state = RS_STATUS_OFFLINE; + RsStatusValue state = RsStatusValue::RS_STATUS_OFFLINE; for (statusIt = statusInfo.begin(); statusIt != statusInfo.end() ; ++statusIt) { if (std::find(sslIds.begin(), sslIds.end(), statusIt->id) != sslIds.end()) { - if (statusIt->status != RS_STATUS_OFFLINE) { - state = RS_STATUS_ONLINE; + if (statusIt->status != RsStatusValue::RS_STATUS_OFFLINE) { + state = RsStatusValue::RS_STATUS_ONLINE; break; } } } - if (state != (int) RS_STATUS_OFFLINE) { + if (state != RsStatusValue::RS_STATUS_OFFLINE) { gpgItem->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline()); } @@ -522,7 +532,7 @@ void FriendSelectionWidget::secured_fillList() gpgItem->setData(COLUMN_NAME, ROLE_SORT_GROUP, 1); gpgItem->setData(COLUMN_NAME, ROLE_SORT_STANDARD_GROUP, 0); gpgItem->setData(COLUMN_NAME, ROLE_SORT_NAME, name); - gpgItem->setData(COLUMN_NAME, ROLE_SORT_STATE, state); + gpgItem->setData(COLUMN_NAME, ROLE_SORT_STATE, (int)state); if (mListModus == MODUS_CHECK) { gpgItem->setCheckState(0, Qt::Unchecked); @@ -770,23 +780,20 @@ template<> inline void FriendSelectionWidget::setSelectedIds sslIds; rsPeers->getAssociatedSSLIds(detail.gpg_id, sslIds); @@ -806,15 +813,15 @@ void FriendSelectionWidget::peerStatusChanged(const QString& peerId, int status) for (statusIt = statusInfo.begin(); statusIt != statusInfo.end() ; ++statusIt) { if (std::find(sslIds.begin(), sslIds.end(), statusIt->id) != sslIds.end()) { - if (statusIt->status != RS_STATUS_OFFLINE) { - gpgStatus = RS_STATUS_ONLINE; + if (statusIt->status != RsStatusValue::RS_STATUS_OFFLINE) { + gpgStatus = RsStatusValue::RS_STATUS_ONLINE; break; } } } } else { /* one node is online */ - gpgStatus = RS_STATUS_ONLINE; + gpgStatus = RsStatusValue::RS_STATUS_ONLINE; } } } @@ -834,7 +841,7 @@ void FriendSelectionWidget::peerStatusChanged(const QString& peerId, int status) case IDTYPE_GPG: { if (item->data(COLUMN_DATA, ROLE_ID).toString() == gpgId) { - if (status != (int) RS_STATUS_OFFLINE) { + if (status != RsStatusValue::RS_STATUS_OFFLINE) { item->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline()); } else { item->setData(COLUMN_NAME, Qt::ForegroundRole, QVariant()); @@ -842,7 +849,7 @@ void FriendSelectionWidget::peerStatusChanged(const QString& peerId, int status) item->setIcon(COLUMN_NAME, FilesDefs::getIconFromQtResourcePath(StatusDefs::imageUser(gpgStatus))); - item->setData(COLUMN_NAME, ROLE_SORT_STATE, gpgStatus); + item->setData(COLUMN_NAME, ROLE_SORT_STATE, (int)gpgStatus); bFoundGPG = true; } @@ -850,8 +857,9 @@ void FriendSelectionWidget::peerStatusChanged(const QString& peerId, int status) break; case IDTYPE_SSL: { - if (item->data(COLUMN_DATA, ROLE_ID).toString() == peerId) { - if (status != (int) RS_STATUS_OFFLINE) { + if (RsPeerId(item->data(COLUMN_DATA, ROLE_ID).toString().toStdString()) == peerid) + { + if (status != RsStatusValue::RS_STATUS_OFFLINE) { item->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline()); } else { item->setData(COLUMN_NAME, Qt::ForegroundRole, QVariant()); @@ -859,7 +867,7 @@ void FriendSelectionWidget::peerStatusChanged(const QString& peerId, int status) item->setIcon(COLUMN_NAME, FilesDefs::getIconFromQtResourcePath(StatusDefs::imageUser(status))); - item->setData(COLUMN_NAME, ROLE_SORT_STATE, status); + item->setData(COLUMN_NAME, ROLE_SORT_STATE, (int)status); bFoundSSL = true; } @@ -1262,7 +1270,7 @@ bool FriendSelectionWidget::isSortByState() void FriendSelectionWidget::filterConnected(bool filter) { - ui->friendList->filterMinValItems(COLUMN_NAME, filter ? RS_STATUS_AWAY : RS_STATUS_OFFLINE, ROLE_SORT_STATE); + ui->friendList->filterMinValItems(COLUMN_NAME, filter ? double(RsStatusValue::RS_STATUS_AWAY) : double(RsStatusValue::RS_STATUS_OFFLINE), ROLE_SORT_STATE); mActionFilterConnected->setChecked(filter); diff --git a/retroshare-gui/src/gui/common/FriendSelectionWidget.h b/retroshare-gui/src/gui/common/FriendSelectionWidget.h index 425e16774..c9be4bf6b 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionWidget.h +++ b/retroshare-gui/src/gui/common/FriendSelectionWidget.h @@ -25,6 +25,7 @@ #include #include "retroshare/rsevents.h" +#include "retroshare/rsstatus.h" #include #include "util/FontSizeHandler.h" @@ -137,8 +138,7 @@ public slots: void filterConnected(bool filter); private slots: - void groupsChanged(int type); - void peerStatusChanged(const QString& peerId, int status); + void peerStatusChanged(const RsPeerId &peerid, RsStatusValue status); void filterItems(const QString &text); void contextMenuRequested(const QPoint &pos); void itemDoubleClicked(QTreeWidgetItem *item, int column); @@ -147,7 +147,8 @@ private slots: void deselectAll() ; private: - void fillList(); + void groupsChanged(); + void fillList(); void secured_fillList(); void selectedIds_internal(IdType idType, std::set &ids, bool onlyDirectSelected); diff --git a/retroshare-gui/src/gui/common/GroupSelectionBox.cpp b/retroshare-gui/src/gui/common/GroupSelectionBox.cpp index 18cdff34d..469dd9db2 100644 --- a/retroshare-gui/src/gui/common/GroupSelectionBox.cpp +++ b/retroshare-gui/src/gui/common/GroupSelectionBox.cpp @@ -23,7 +23,7 @@ #include #include "GroupSelectionBox.h" #include "GroupDefs.h" -#include "gui/notifyqt.h" +#include "util/qtthreadsutils.h" #include @@ -34,11 +34,38 @@ GroupSelectionBox::GroupSelectionBox(QWidget *parent) { setSelectionMode(QAbstractItemView::SingleSelection); - connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(fillGroups())); + mEventHandlerId = 0; + + rsEvents->registerEventsHandler( [this](std::shared_ptr e) + { + RsQThreadUtils::postToObject([=]() + { + auto fe = dynamic_cast(e.get()); + + if(!fe) + return; + + switch(fe->mEventCode) + { + case RsFriendListEventCode::GROUP_ADDED: + case RsFriendListEventCode::GROUP_REMOVED: + case RsFriendListEventCode::GROUP_CHANGED: fillGroups(); + + default: + break; + } + } + , this ); + }, mEventHandlerId, RsEventType::FRIEND_LIST ); // Fill with available groups fillGroups(); } + +GroupSelectionBox::~GroupSelectionBox() +{ + rsEvents->unregisterEventsHandler(mEventHandlerId); +} void GroupSelectionBox::fillGroups() { std::list selectedIds; @@ -52,7 +79,7 @@ void GroupSelectionBox::fillGroups() for (std::list::const_iterator it(groupIds.begin()); it != groupIds.end(); ++it) { QListWidgetItem *item = new QListWidgetItem(GroupDefs::name(*it)); item->setData(ROLE_ID, QString::fromStdString(it->id.toStdString())); - item->setBackgroundColor(QColor(183,236,181)); + item->setBackground(QColor(183,236,181)); addItem(item); } diff --git a/retroshare-gui/src/gui/common/GroupSelectionBox.h b/retroshare-gui/src/gui/common/GroupSelectionBox.h index 09ae741c2..6cd4ac9cb 100644 --- a/retroshare-gui/src/gui/common/GroupSelectionBox.h +++ b/retroshare-gui/src/gui/common/GroupSelectionBox.h @@ -21,6 +21,7 @@ #include #include #include +#include class GroupSelectionBox: public QListWidget { @@ -28,6 +29,7 @@ class GroupSelectionBox: public QListWidget public: GroupSelectionBox(QWidget *parent); + virtual ~GroupSelectionBox(); static void selectGroups(const std::list& default_groups) ; @@ -38,6 +40,9 @@ public: private slots: void fillGroups(); + +private: + RsEventsHandlerId_t mEventHandlerId ; }; class GroupSelectionDialog: public QDialog diff --git a/retroshare-gui/src/gui/common/GroupTreeWidget.cpp b/retroshare-gui/src/gui/common/GroupTreeWidget.cpp index 43861c4c6..49675913c 100644 --- a/retroshare-gui/src/gui/common/GroupTreeWidget.cpp +++ b/retroshare-gui/src/gui/common/GroupTreeWidget.cpp @@ -28,12 +28,12 @@ #include "RSElidedItemDelegate.h" #include "RSTreeWidgetItem.h" #include "gui/settings/rsharesettings.h" -#include "util/QtVersion.h" +#include "util/RsQtVersion.h" #include "util/DateTime.h" -#include #include #include +#include #include @@ -192,8 +192,11 @@ void GroupTreeWidget::addToolButton(QToolButton *toolButton) /* Initialize button */ int i = qt_defaultDpi(); - auto desktopWidget = QApplication::desktop(); - auto y = desktopWidget->logicalDpiY(); + QScreen *primaryScreen = QGuiApplication::primaryScreen(); + int y = i; + if (primaryScreen) { + y = primaryScreen->logicalDotsPerInchY(); + } toolButton->setAutoRaise(true); toolButton->setIconSize(QSize(24*y/i,24*y/i)); @@ -424,7 +427,7 @@ void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList< } /* Set last post */ - if(itemInfo.lastpost == QDateTime::fromTime_t(0)) + if(itemInfo.lastpost == DateTime::DateTimeFromTime_t(0)) { item->setText(GTW_COLUMN_LAST_POST, tr("Never")); item->setData(GTW_COLUMN_LAST_POST, ROLE_SORT, QVariant());// To allow them not be sorted with ->setNoDataAsLast(true) @@ -432,7 +435,7 @@ void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList< else { item->setText(GTW_COLUMN_LAST_POST, itemInfo.lastpost.toString(Qt::ISODate).replace("T"," ")); - item->setData(GTW_COLUMN_LAST_POST, ROLE_SORT, itemInfo.lastpost.toTime_t()); + item->setData(GTW_COLUMN_LAST_POST, ROLE_SORT, (qint64) DateTime::DateTimeToTime_t(itemInfo.lastpost)); } @@ -458,7 +461,7 @@ void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList< if(!IS_GROUP_SUBSCRIBED(itemInfo.subscribeFlags)) tooltip += "\n" + QString::number(itemInfo.max_visible_posts) + " messages available" ; // if(itemInfo.max_visible_posts) // wtf? this=0 when there are some posts definitely exist - lastpost is recent - if(itemInfo.lastpost == QDateTime::fromTime_t(0)) + if(itemInfo.lastpost == DateTime::DateTimeFromTime_t(0)) tooltip += "\n" + tr("Last Post") + ": " + tr("Never") ; else tooltip += "\n" + tr("Last Post") + ": " + DateTime::formatLongDateTime(itemInfo.lastpost) ; diff --git a/retroshare-gui/src/gui/common/HashBox.cpp b/retroshare-gui/src/gui/common/HashBox.cpp index 0a96068e5..c4c6cbf4a 100644 --- a/retroshare-gui/src/gui/common/HashBox.cpp +++ b/retroshare-gui/src/gui/common/HashBox.cpp @@ -174,7 +174,7 @@ void HashBox::addAttachments(const QStringList& files,TransferRequestFlags tfl, hashingInfo.item = file; hashingInfo.flag = flag; mHashingInfos.push_back(hashingInfo); - ui->verticalLayout->addWidget(file, 1, 0); + ui->verticalLayout->addWidget(file, 1); } QApplication::processEvents(); @@ -259,7 +259,7 @@ void HashBox::checkAttachmentReady() emit fileHashingFinished(hashedFiles); auto ev = std::make_shared(); - ev->mEventCode = RsSharedDirectoriesEventCode::DIRECTORY_SWEEP_ENDED; + ev->mEventCode = RsSharedDirectoriesEventCode::HASHING_PROCESS_FINISHED; if(rsEvents) rsEvents->postEvent(ev); } diff --git a/retroshare-gui/src/gui/common/LineEditClear.cpp b/retroshare-gui/src/gui/common/LineEditClear.cpp index a6ba67bfa..1a91db591 100644 --- a/retroshare-gui/src/gui/common/LineEditClear.cpp +++ b/retroshare-gui/src/gui/common/LineEditClear.cpp @@ -20,10 +20,12 @@ #include "gui/common/FilesDefs.h" #include "LineEditClear.h" +#include "util/RsQtVersion.h" #include #include #include +#include //#if QT_VERSION < 0x040700 #if QT_VERSION < 0x050000//PlaceHolder text only shown when not have focus in Qt4 #include @@ -236,7 +238,7 @@ void LineEditClear::setFilterButtonIcon(const QIcon &icon) ensurePolished(); #if !defined(Q_OS_DARWIN) QFontMetrics fm(this->font()); - QSize size(fm.width("___"), fm.height()); + QSize size(QFontMetrics_horizontalAdvance(fm, "___"), fm.height()); mFilterButton->setFixedSize(size); mFilterButton->setIconSize(size); #endif diff --git a/retroshare-gui/src/gui/common/NewFriendList.cpp b/retroshare-gui/src/gui/common/NewFriendList.cpp index 38e141e86..22f960a9d 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.cpp +++ b/retroshare-gui/src/gui/common/NewFriendList.cpp @@ -50,11 +50,10 @@ #include "util/misc.h" #include "util/qtthreadsutils.h" #include "vmessagebox.h" -#include "util/QtVersion.h" +#include "util/RsQtVersion.h" #include "gui/chat/ChatUserNotify.h" #include "gui/connect/ConnectProgressDialog.h" #include "gui/common/ElidedLabel.h" -#include "gui/notifyqt.h" #include "NewFriendList.h" #include "ui_NewFriendList.h" @@ -132,8 +131,8 @@ public: if(is_group_1 ^ is_group_2) // if the two are different, put the group first. return is_group_1 ; - bool online1 = (left .data(RsFriendListModel::OnlineRole).toInt() != RS_STATUS_OFFLINE); - bool online2 = (right.data(RsFriendListModel::OnlineRole).toInt() != RS_STATUS_OFFLINE); + bool online1 = (left .data(RsFriendListModel::OnlineRole).toInt() != (int)RsStatusValue::RS_STATUS_OFFLINE); + bool online2 = (right.data(RsFriendListModel::OnlineRole).toInt() != (int)RsStatusValue::RS_STATUS_OFFLINE); if((online1 != online2) && m_sortByState) return (m_header->sortIndicatorOrder()==Qt::AscendingOrder)?online1:online2 ; // always put online nodes first @@ -155,7 +154,7 @@ public: // Filter offline friends - if(!m_showOfflineNodes && (index.data(RsFriendListModel::OnlineRole).toInt() == RS_STATUS_OFFLINE)) + if(!m_showOfflineNodes && (RsStatusValue(index.data(RsFriendListModel::OnlineRole).toInt()) == RsStatusValue::RS_STATUS_OFFLINE)) return false; return index.data(RsFriendListModel::FilterRole).toString() == RsFriendListModel::FilterString ; @@ -195,17 +194,14 @@ NewFriendList::NewFriendList(QWidget */*parent*/) : /* RsAutoUpdatePage(5000,par ui->filterLineEdit->setPlaceholderText(tr("Search")) ; ui->filterLineEdit->showFilterIcon(); +// mEventHandlerId_pssc=0; // forces initialization mEventHandlerId_peer=0; // forces initialization mEventHandlerId_gssp=0; // forces initialization - mEventHandlerId_pssc=0; // forces initialization - rsEvents->registerEventsHandler( [this](std::shared_ptr e) { handleEvent(e); }, mEventHandlerId_pssc, RsEventType::PEER_STATE_CHANGED ); - rsEvents->registerEventsHandler( [this](std::shared_ptr e) { handleEvent(e); }, mEventHandlerId_peer, RsEventType::PEER_CONNECTION ); +// rsEvents->registerEventsHandler( [this](std::shared_ptr e) { handleEvent(e); }, mEventHandlerId_pssc, RsEventType::PEER_STATE_CHANGED ); + rsEvents->registerEventsHandler( [this](std::shared_ptr e) { handleEvent(e); }, mEventHandlerId_peer, RsEventType::FRIEND_LIST ); rsEvents->registerEventsHandler( [this](std::shared_ptr e) { handleEvent(e); }, mEventHandlerId_gssp, RsEventType::GOSSIP_DISCOVERY ); - connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(QString)), this, SLOT(forceUpdateDisplay())); - connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(forceUpdateDisplay())); - mModel = new RsFriendListModel(ui->peerTreeWidget); mProxyModel = new FriendListSortFilterProxyModel(ui->peerTreeWidget->header(),this); @@ -213,7 +209,7 @@ NewFriendList::NewFriendList(QWidget */*parent*/) : /* RsAutoUpdatePage(5000,par mProxyModel->setSortRole(RsFriendListModel::SortRole); mProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); mProxyModel->setFilterRole(RsFriendListModel::FilterRole); - mProxyModel->setFilterRegExp(QRegExp(RsFriendListModel::FilterString)); + QSortFilterProxyModel_setFilterRegularExpression(mProxyModel, RsFriendListModel::FilterString); ui->peerTreeWidget->setModel(mProxyModel); RSElidedItemDelegate *itemDelegate = new RSElidedItemDelegate(this); @@ -293,7 +289,7 @@ NewFriendList::~NewFriendList() { rsEvents->unregisterEventsHandler(mEventHandlerId_peer); rsEvents->unregisterEventsHandler(mEventHandlerId_gssp); - rsEvents->unregisterEventsHandler(mEventHandlerId_pssc); +// rsEvents->unregisterEventsHandler(mEventHandlerId_pssc); delete mModel; delete mProxyModel; @@ -319,7 +315,7 @@ void NewFriendList::headerContextMenuRequested(QPoint /*p*/) // create menu header QHBoxLayout *hbox = new QHBoxLayout(widget); - hbox->setMargin(0); + hbox->setContentsMargins(0, 0, 0, 0); hbox->setSpacing(6); QLabel *iconLabel = new QLabel(widget); @@ -448,7 +444,7 @@ void NewFriendList::recursSaveExpandedItems(const QModelIndex& index,const QMode exp.insert(local_path) ; for(int row=0;rowrowCount(index);++row) - recursSaveExpandedItems(index.child(row,0),current_index,local_path,exp,sel,indx+1) ; + recursSaveExpandedItems(mProxyModel->index(row,0,index),current_index,local_path,exp,sel,indx+1) ; } #ifdef DEBUG_NEW_FRIEND_LIST else @@ -479,7 +475,7 @@ void NewFriendList::recursRestoreExpandedItems(const QModelIndex& index, const Q ui->peerTreeWidget->setExpanded(index,true) ; for(int row=0;rowrowCount(index);++row) - recursRestoreExpandedItems(index.child(row,0),local_path,exp,sel,selected_index,indx+1) ; + recursRestoreExpandedItems(mProxyModel->index(row,0,index),local_path,exp,sel,selected_index,indx+1) ; } #ifdef DEBUG_NEW_FRIEND_LIST else @@ -558,7 +554,7 @@ void NewFriendList::processSettings(bool load) void NewFriendList::toggleSortByState(bool sort) { mProxyModel->setSortByState(sort); - mProxyModel->setFilterRegExp(QRegExp(QString(RsFriendListModel::FilterString))) ;// triggers a re-display. + QSortFilterProxyModel_setFilterRegularExpression(mProxyModel, QString(RsFriendListModel::FilterString)) ;// triggers a re-display. processSettings(false); } @@ -591,7 +587,7 @@ void NewFriendList::peerTreeWidgetCustomPopupMenu() // create menu header QHBoxLayout *hbox = new QHBoxLayout(widget); - hbox->setMargin(0); + hbox->setContentsMargins(0, 0, 0, 0); hbox->setSpacing(6); QLabel *iconLabel = new QLabel(widget); @@ -1419,7 +1415,11 @@ bool NewFriendList::exportFriendlist(QString &fileName) root.appendChild(groups); QTextStream ts(&file); +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) + ts.setEncoding(QStringConverter::Utf8); +#else ts.setCodec("UTF-8"); +#endif ts << doc.toString(); file.close(); @@ -1468,7 +1468,7 @@ bool NewFriendList::importFriendlist(QString &fileName, bool &errorPeers, bool & return false; } - bool ok = doc.setContent(&file); + bool ok = (bool) doc.setContent(&file); file.close(); if(!ok) { @@ -1623,7 +1623,7 @@ bool NewFriendList::getOrCreateGroup(const std::string& name, uint flag, RsNodeG void NewFriendList::setShowUnconnected(bool show) { mProxyModel->setShowOfflineNodes(show); - mProxyModel->setFilterRegExp(QRegExp(QString(RsFriendListModel::FilterString))) ;// triggers a re-display. + QSortFilterProxyModel_setFilterRegularExpression(mProxyModel, QString(RsFriendListModel::FilterString)) ;// triggers a re-display. } bool NewFriendList::isColumnVisible(int col) const @@ -1673,7 +1673,7 @@ void NewFriendList::setShowGroups(bool show) */ void NewFriendList::filterItems(const QString &text) { - QStringList lst = text.split(' ',QString::SkipEmptyParts); + QStringList lst = text.split(' ',QtSkipEmptyParts); int filterColumn = ui->filterLineEdit->currentFilter(); if(filterColumn == 0) @@ -1682,7 +1682,7 @@ void NewFriendList::filterItems(const QString &text) mModel->setFilter(RsFriendListModel::FILTER_TYPE_ID,lst); // We do this in order to trigger a new filtering action in the proxy model. - mProxyModel->setFilterRegExp(QRegExp(QString(RsFriendListModel::FilterString))) ; + QSortFilterProxyModel_setFilterRegularExpression(mProxyModel, QString(RsFriendListModel::FilterString)) ; if(!lst.empty()) ui->peerTreeWidget->expandAll(); diff --git a/retroshare-gui/src/gui/common/NewFriendList.h b/retroshare-gui/src/gui/common/NewFriendList.h index cf4c68e6f..204d984d5 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.h +++ b/retroshare-gui/src/gui/common/NewFriendList.h @@ -66,18 +66,18 @@ public: //void updateDisplay() override; QColor textColorGroup() const { return mModel->mTextColorGroup; } - QColor textColorStatusOffline() const { return mModel->mTextColorStatus[RS_STATUS_OFFLINE ]; } - QColor textColorStatusAway() const { return mModel->mTextColorStatus[RS_STATUS_AWAY ]; } - QColor textColorStatusBusy() const { return mModel->mTextColorStatus[RS_STATUS_BUSY ]; } - QColor textColorStatusOnline() const { return mModel->mTextColorStatus[RS_STATUS_ONLINE ]; } - QColor textColorStatusInactive() const { return mModel->mTextColorStatus[RS_STATUS_INACTIVE]; } + QColor textColorStatusOffline() const { return mModel->mTextColorStatus[(uint8_t)RsStatusValue::RS_STATUS_OFFLINE ]; } + QColor textColorStatusAway() const { return mModel->mTextColorStatus[(uint8_t)RsStatusValue::RS_STATUS_AWAY ]; } + QColor textColorStatusBusy() const { return mModel->mTextColorStatus[(uint8_t)RsStatusValue::RS_STATUS_BUSY ]; } + QColor textColorStatusOnline() const { return mModel->mTextColorStatus[(uint8_t)RsStatusValue::RS_STATUS_ONLINE ]; } + QColor textColorStatusInactive() const { return mModel->mTextColorStatus[(uint8_t)RsStatusValue::RS_STATUS_INACTIVE]; } void setTextColorGroup(QColor color) { mModel->mTextColorGroup = color; } - void setTextColorStatusOffline(QColor color) { mModel->mTextColorStatus[RS_STATUS_OFFLINE ] = color; } - void setTextColorStatusAway(QColor color) { mModel->mTextColorStatus[RS_STATUS_AWAY ] = color; } - void setTextColorStatusBusy(QColor color) { mModel->mTextColorStatus[RS_STATUS_BUSY ] = color; } - void setTextColorStatusOnline(QColor color) { mModel->mTextColorStatus[RS_STATUS_ONLINE ] = color; } - void setTextColorStatusInactive(QColor color) { mModel->mTextColorStatus[RS_STATUS_INACTIVE] = color; } + void setTextColorStatusOffline(QColor color) { mModel->mTextColorStatus[(uint8_t)RsStatusValue::RS_STATUS_OFFLINE ] = color; } + void setTextColorStatusAway(QColor color) { mModel->mTextColorStatus[(uint8_t)RsStatusValue::RS_STATUS_AWAY ] = color; } + void setTextColorStatusBusy(QColor color) { mModel->mTextColorStatus[(uint8_t)RsStatusValue::RS_STATUS_BUSY ] = color; } + void setTextColorStatusOnline(QColor color) { mModel->mTextColorStatus[(uint8_t)RsStatusValue::RS_STATUS_ONLINE ] = color; } + void setTextColorStatusInactive(QColor color) { mModel->mTextColorStatus[(uint8_t)RsStatusValue::RS_STATUS_INACTIVE] = color; } public slots: void filterItems(const QString &text); @@ -127,7 +127,7 @@ private: bool mShowState; RsEventsHandlerId_t mEventHandlerId_peer; RsEventsHandlerId_t mEventHandlerId_gssp; - RsEventsHandlerId_t mEventHandlerId_pssc; +// RsEventsHandlerId_t mEventHandlerId_pssc; std::set openGroups; std::set openPeers; diff --git a/retroshare-gui/src/gui/common/RSGraphWidget.cpp b/retroshare-gui/src/gui/common/RSGraphWidget.cpp index dab0645c4..2304e0128 100644 --- a/retroshare-gui/src/gui/common/RSGraphWidget.cpp +++ b/retroshare-gui/src/gui/common/RSGraphWidget.cpp @@ -33,7 +33,9 @@ #include #include +#include "rshare.h" #include "RSGraphWidget.h" +#include "util/RsQtVersion.h" #if QT_VERSION < 0x040700 #include @@ -314,8 +316,7 @@ void RSGraphWidget::setFiltering(bool b) int RSGraphWidget::getNumPoints() { - QDesktopWidget *desktop = QApplication::desktop(); - int width = desktop->width(); + int width = RsApplication::primaryScreenGeometry().width(); return width; } @@ -655,12 +656,12 @@ void RSGraphWidget::paintScale1() if (_flags & RSGRAPH_FLAGS_DARK_STYLE){ _painter->setPen(SCALE_COLOR_DARK); - _painter->drawText(QPointF(SCALE_WIDTH*fact - QFontMetricsF(font()).width(text) - 4*fact, pos+0.4*FS), text); + _painter->drawText(QPointF(SCALE_WIDTH*fact - QFontMetrics_horizontalAdvance(QFontMetricsF(font()), text) - 4*fact, pos+0.4*FS), text); _painter->setPen(GRID_COLOR_DARK); _painter->drawLine(QPointF(SCALE_WIDTH*fact, pos), QPointF(_rec.width(), pos)); }else{ _painter->setPen(SCALE_COLOR); - _painter->drawText(QPointF(SCALE_WIDTH*fact - QFontMetricsF(font()).width(text) - 4*fact, pos+0.4*FS), text); + _painter->drawText(QPointF(SCALE_WIDTH*fact - QFontMetrics_horizontalAdvance(QFontMetricsF(font()), text) - 4*fact, pos+0.4*FS), text); _painter->setPen(GRID_COLOR); _painter->drawLine(QPointF(SCALE_WIDTH*fact, pos), QPointF(_rec.width(), pos)); } @@ -696,18 +697,24 @@ void RSGraphWidget::paintScale2() void RSGraphWidget::wheelEvent(QWheelEvent *e) { +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) + int delta = e->angleDelta().y(); +#else + int delta = e->delta(); +#endif + if(e->modifiers() & Qt::ShiftModifier) - if(e->delta() > 0) + if(delta > 0) _time_filter *= 1.1 ; else _time_filter /= 1.1 ; else if(e->modifiers() & Qt::ControlModifier) - if(e->delta() > 0) + if(delta > 0) _linewidthscale *= 1.2 ; else _linewidthscale /= 1.2 ; else - if(e->delta() > 0) + if(delta > 0) _time_scale *= 1.1 ; else _time_scale /= 1.1 ; diff --git a/retroshare-gui/src/gui/common/RSGraphWidget.h b/retroshare-gui/src/gui/common/RSGraphWidget.h index e08a45eb9..6a5c35901 100644 --- a/retroshare-gui/src/gui/common/RSGraphWidget.h +++ b/retroshare-gui/src/gui/common/RSGraphWidget.h @@ -26,7 +26,6 @@ #include #include -#include #include #include diff --git a/retroshare-gui/src/gui/common/RSTextBrowser.cpp b/retroshare-gui/src/gui/common/RSTextBrowser.cpp index c11d4edef..4a203ea1b 100644 --- a/retroshare-gui/src/gui/common/RSTextBrowser.cpp +++ b/retroshare-gui/src/gui/common/RSTextBrowser.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include @@ -284,10 +285,10 @@ void RSTextBrowser::contextMenuEvent(QContextMenuEvent *event) QMenu *RSTextBrowser::createStandardContextMenuFromPoint(const QPoint &widgetPos) { - QMatrix matrix; - matrix.translate(horizontalScrollBar()->value(), verticalScrollBar()->value()); + QTransform transform; + transform.translate(horizontalScrollBar()->value(), verticalScrollBar()->value()); - QMenu *menu = QTextBrowser::createStandardContextMenu(matrix.map(widgetPos)); + QMenu *menu = QTextBrowser::createStandardContextMenu(transform.map(widgetPos)); menu->addSeparator(); QAction *a = menu->addAction(FilesDefs::getIconFromQtResourcePath("://icons/textedit/code.png"), tr("View &Source"), this, SLOT(viewSource())); diff --git a/retroshare-gui/src/gui/common/RSTreeWidget.cpp b/retroshare-gui/src/gui/common/RSTreeWidget.cpp index 7e3a8b216..ab4004633 100644 --- a/retroshare-gui/src/gui/common/RSTreeWidget.cpp +++ b/retroshare-gui/src/gui/common/RSTreeWidget.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include "gui/settings/rsharesettings.h" #include "gui/common/FilesDefs.h" @@ -259,7 +260,7 @@ QMenu *RSTreeWidget::createStandardContextMenu(QMenu *contextMenu) // create menu header QHBoxLayout *hbox = new QHBoxLayout(widget); - hbox->setMargin(0); + hbox->setContentsMargins(0, 0, 0, 0); hbox->setSpacing(6); QLabel *iconLabel = new QLabel(widget); diff --git a/retroshare-gui/src/gui/common/RsButtonOnText.cpp b/retroshare-gui/src/gui/common/RsButtonOnText.cpp index 95466c9d4..8774f84bd 100644 --- a/retroshare-gui/src/gui/common/RsButtonOnText.cpp +++ b/retroshare-gui/src/gui/common/RsButtonOnText.cpp @@ -107,7 +107,7 @@ bool RSButtonOnText::eventFilter(QObject *obj, QEvent *event) } if (event->type() == QEvent::MouseButtonPress) { QMouseEvent* mouseEvent = new QMouseEvent(QEvent::MouseButtonPress - ,QPoint(1,1),Qt::LeftButton,Qt::LeftButton,0); + ,QPoint(1,1),Qt::LeftButton,Qt::LeftButton,Qt::KeyboardModifier::NoModifier); QPushButton::mousePressEvent(mouseEvent); delete mouseEvent; if (guard) _pressed = true; @@ -116,7 +116,7 @@ bool RSButtonOnText::eventFilter(QObject *obj, QEvent *event) } if (event->type() == QEvent::MouseButtonRelease) { QMouseEvent* mouseEvent = new QMouseEvent(QEvent::MouseButtonPress - ,QPoint(1,1),Qt::LeftButton,Qt::LeftButton,0); + ,QPoint(1,1),Qt::LeftButton,Qt::LeftButton,Qt::KeyboardModifier::NoModifier); QPushButton::mouseReleaseEvent(mouseEvent); delete mouseEvent; if (guard) _pressed = false; @@ -152,7 +152,7 @@ bool RSButtonOnText::eventFilter(QObject *obj, QEvent *event) } if (_pressed){ QMouseEvent* mouseEvent = new QMouseEvent(QEvent::MouseButtonPress - ,QPoint(1,1),Qt::LeftButton,Qt::LeftButton,0); + ,QPoint(1,1),Qt::LeftButton,Qt::LeftButton,Qt::KeyboardModifier::NoModifier); QPushButton::mouseReleaseEvent(mouseEvent); delete mouseEvent; //if (guard) emit released(); diff --git a/retroshare-gui/src/gui/common/RsCollection.cpp b/retroshare-gui/src/gui/common/RsCollection.cpp index e13452038..6daa54de8 100644 --- a/retroshare-gui/src/gui/common/RsCollection.cpp +++ b/retroshare-gui/src/gui/common/RsCollection.cpp @@ -194,7 +194,7 @@ RsCollection::RsCollection(const QString& fileName, RsCollectionErrorCode& error } QDomDocument xml_doc; - bool ok = xml_doc.setContent(&file) ; + bool ok = (bool) xml_doc.setContent(&file); if(!ok) { @@ -311,7 +311,11 @@ bool RsCollection::save(const QString& fileName) const xml_doc.appendChild(root); QTextStream stream(&file) ; +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) + stream.setEncoding(QStringConverter::Utf8); +#else stream.setCodec("UTF-8") ; +#endif stream << xml_doc.toString() ; file.close(); diff --git a/retroshare-gui/src/gui/common/RsCollectionDialog.cpp b/retroshare-gui/src/gui/common/RsCollectionDialog.cpp index b71616678..5eb56506d 100644 --- a/retroshare-gui/src/gui/common/RsCollectionDialog.cpp +++ b/retroshare-gui/src/gui/common/RsCollectionDialog.cpp @@ -362,7 +362,7 @@ void RsCollectionDialog::directoryLoaded(QString dirLoaded) if(!_dirLoaded) { - QFileInfo lastDir = Settings->getLastDir(RshareSettings::LASTDIR_EXTRAFILE); + QFileInfo lastDir = QFileInfo(Settings->getLastDir(RshareSettings::LASTDIR_EXTRAFILE)); if (lastDir.absoluteFilePath() == "") return; if (lastDir.absoluteFilePath() == dirLoaded) _dirLoaded = true; @@ -513,7 +513,7 @@ void RsCollectionDialog::addSelectionRecursive() static void recursBuildFileTree(const QString& path,RsFileTree& tree,RsFileTree::DirIndex dir_index,bool recursive,std::map& paths_to_hash) { - QFileInfo fileInfo = path; + QFileInfo fileInfo = QFileInfo(path); if (fileInfo.isDir()) { diff --git a/retroshare-gui/src/gui/common/RsCollectionModel.cpp b/retroshare-gui/src/gui/common/RsCollectionModel.cpp index 8c7fa9283..0d4e19000 100644 --- a/retroshare-gui/src/gui/common/RsCollectionModel.cpp +++ b/retroshare-gui/src/gui/common/RsCollectionModel.cpp @@ -239,7 +239,7 @@ QVariant RsCollectionModel::data(const QModelIndex& index, int role) const case Qt::DisplayRole: return displayRole(i,index.column()); case Qt::DecorationRole: return decorationRole(i,index.column()); case Qt::CheckStateRole: return checkStateRole(i,index.column()); - case Qt::TextColorRole: return textColorRole(i,index.column()); + case Qt::ForegroundRole: return textColorRole(i,index.column()); default: return QVariant(); } diff --git a/retroshare-gui/src/gui/common/StatusDefs.cpp b/retroshare-gui/src/gui/common/StatusDefs.cpp index 5d0db8395..a9fa4e3f9 100644 --- a/retroshare-gui/src/gui/common/StatusDefs.cpp +++ b/retroshare-gui/src/gui/common/StatusDefs.cpp @@ -24,118 +24,124 @@ #include "StatusDefs.h" -QString StatusDefs::name(unsigned int status) +QString StatusDefs::name(RsStatusValue status) { switch (status) { - case RS_STATUS_OFFLINE: + default: + case RsStatusValue::RS_STATUS_OFFLINE: return qApp->translate("StatusDefs", "Offline"); - case RS_STATUS_AWAY: + case RsStatusValue::RS_STATUS_AWAY: return qApp->translate("StatusDefs", "Away"); - case RS_STATUS_BUSY: + case RsStatusValue::RS_STATUS_BUSY: return qApp->translate("StatusDefs", "Busy"); - case RS_STATUS_ONLINE: + case RsStatusValue::RS_STATUS_ONLINE: return qApp->translate("StatusDefs", "Online"); - case RS_STATUS_INACTIVE: + case RsStatusValue::RS_STATUS_INACTIVE: return qApp->translate("StatusDefs", "Idle"); } - std::cerr << "StatusDefs::name: Unknown status requested " << status; + RsErr() << "StatusDefs::name: Unknown status requested " << (int)status; return ""; } -const char *StatusDefs::imageIM(unsigned int status) +const char *StatusDefs::imageIM(RsStatusValue status) { switch (status) { - case RS_STATUS_OFFLINE: + default: + case RsStatusValue::RS_STATUS_OFFLINE: return ":/images/im-user-offline.png"; - case RS_STATUS_AWAY: + case RsStatusValue::RS_STATUS_AWAY: return ":/images/im-user-away.png"; - case RS_STATUS_BUSY: + case RsStatusValue::RS_STATUS_BUSY: return ":/images/im-user-busy.png"; - case RS_STATUS_ONLINE: + case RsStatusValue::RS_STATUS_ONLINE: return ":/images/im-user.png"; - case RS_STATUS_INACTIVE: + case RsStatusValue::RS_STATUS_INACTIVE: return ":/images/im-user-inactive.png"; } - std::cerr << "StatusDefs::imageIM: Unknown status requested " << status; + RsErr() << "StatusDefs::imageIM: Unknown status requested " << (int)status; return ""; } -const char *StatusDefs::imageUser(unsigned int status) +const char *StatusDefs::imageUser(RsStatusValue status) { switch (status) { - case RS_STATUS_OFFLINE: + default: + case RsStatusValue::RS_STATUS_OFFLINE: return ":/images/user/identityoffline24.png"; - case RS_STATUS_AWAY: + case RsStatusValue::RS_STATUS_AWAY: return ":/images/user/identity24away.png"; - case RS_STATUS_BUSY: + case RsStatusValue::RS_STATUS_BUSY: return ":/images/user/identity24busy.png"; - case RS_STATUS_ONLINE: + case RsStatusValue::RS_STATUS_ONLINE: return ":/images/user/identity24.png"; - case RS_STATUS_INACTIVE: + case RsStatusValue::RS_STATUS_INACTIVE: return ":/images/user/identity24idle.png"; } - std::cerr << "StatusDefs::imageUser: Unknown status requested " << status; + RsErr() << "StatusDefs::imageUser: Unknown status requested " << (int)status; return ""; } -const char *StatusDefs::imageStatus(unsigned int status) +const char *StatusDefs::imageStatus(RsStatusValue status) { switch (status) { - case RS_STATUS_OFFLINE: + default: + case RsStatusValue::RS_STATUS_OFFLINE: return ":/icons/user-offline_64.png"; - case RS_STATUS_AWAY: + case RsStatusValue::RS_STATUS_AWAY: return ":/icons/user-away_64.png"; - case RS_STATUS_BUSY: + case RsStatusValue::RS_STATUS_BUSY: return ":/icons/user-busy_64.png"; - case RS_STATUS_ONLINE: + case RsStatusValue::RS_STATUS_ONLINE: return ":/icons/user-online_64.png"; - case RS_STATUS_INACTIVE: + case RsStatusValue::RS_STATUS_INACTIVE: return ":/icons/user-away-extended_64.png"; } - std::cerr << "StatusDefs::imageUser: Unknown status requested " << status; + RsErr() << "StatusDefs::imageUser: Unknown status requested " << (int)status; return ""; } -QString StatusDefs::tooltip(unsigned int status) +QString StatusDefs::tooltip(RsStatusValue status) { switch (status) { - case RS_STATUS_OFFLINE: + default: + case RsStatusValue::RS_STATUS_OFFLINE: return qApp->translate("StatusDefs", "Friend is offline"); - case RS_STATUS_AWAY: + case RsStatusValue::RS_STATUS_AWAY: return qApp->translate("StatusDefs", "Friend is away"); - case RS_STATUS_BUSY: + case RsStatusValue::RS_STATUS_BUSY: return qApp->translate("StatusDefs", "Friend is busy"); - case RS_STATUS_ONLINE: + case RsStatusValue::RS_STATUS_ONLINE: return qApp->translate("StatusDefs", "Friend is online"); - case RS_STATUS_INACTIVE: + case RsStatusValue::RS_STATUS_INACTIVE: return qApp->translate("StatusDefs", "Friend is idle"); } - std::cerr << "StatusDefs::tooltip: Unknown status requested " << status; + RsErr() << "StatusDefs::tooltip: Unknown status requested " << (int)status; return ""; } -QFont StatusDefs::font(unsigned int status) +QFont StatusDefs::font(RsStatusValue status) { QFont font; switch (status) { - case RS_STATUS_AWAY: - case RS_STATUS_BUSY: - case RS_STATUS_ONLINE: - case RS_STATUS_INACTIVE: + default: + case RsStatusValue::RS_STATUS_AWAY: + case RsStatusValue::RS_STATUS_BUSY: + case RsStatusValue::RS_STATUS_ONLINE: + case RsStatusValue::RS_STATUS_INACTIVE: font.setBold(true); return font; - case RS_STATUS_OFFLINE: + case RsStatusValue::RS_STATUS_OFFLINE: font.setBold(false); return font; } - std::cerr << "StatusDefs::font: Unknown status requested " << status; + RsErr() << "StatusDefs::font: Unknown status requested " << (int)status; return font; } diff --git a/retroshare-gui/src/gui/common/StatusDefs.h b/retroshare-gui/src/gui/common/StatusDefs.h index b922e28e4..3a167930b 100644 --- a/retroshare-gui/src/gui/common/StatusDefs.h +++ b/retroshare-gui/src/gui/common/StatusDefs.h @@ -24,18 +24,20 @@ #include #include +#include "retroshare/rsstatus.h" + struct RsPeerDetails; class StatusDefs { public: - static QString name(unsigned int status); - static const char* imageIM(unsigned int status); - static const char* imageUser(unsigned int status); - static const char* imageStatus(unsigned int status); - static QString tooltip(unsigned int status); + static QString name(RsStatusValue status); + static const char* imageIM(RsStatusValue status); + static const char* imageUser(RsStatusValue status); + static const char* imageStatus(RsStatusValue status); + static QString tooltip(RsStatusValue status); - static QFont font(unsigned int status); + static QFont font(RsStatusValue status); static QString peerStateString(int peerState); static QString connectStateString(RsPeerDetails &details); diff --git a/retroshare-gui/src/gui/common/rwindow.cpp b/retroshare-gui/src/gui/common/rwindow.cpp index 31fe12d9e..5d819c9cc 100644 --- a/retroshare-gui/src/gui/common/rwindow.cpp +++ b/retroshare-gui/src/gui/common/rwindow.cpp @@ -24,7 +24,6 @@ #include #include #include -#include #include #include "rwindow.h" diff --git a/retroshare-gui/src/gui/common/rwindow.h b/retroshare-gui/src/gui/common/rwindow.h index 55441e45f..31ff68c21 100644 --- a/retroshare-gui/src/gui/common/rwindow.h +++ b/retroshare-gui/src/gui/common/rwindow.h @@ -35,7 +35,7 @@ class RWindow : public QMainWindow public: /** Default constructor. */ - RWindow(QString name, QWidget *parent = 0, Qt::WindowFlags flags = 0); + RWindow(QString name, QWidget *parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); /** Destructor. */ ~RWindow(); diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp index 6a407cb49..32eeaebae 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include @@ -38,7 +39,6 @@ #include "gui/common/PeerDefs.h" #include "gui/common/StatusDefs.h" #include "gui/RetroShareLink.h" -#include "gui/notifyqt.h" #include "gui/common/AvatarDefs.h" #include "gui/common/FilesDefs.h" #include "gui/MainWindow.h" diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp index 7ffdcd687..efdf4cd15 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp @@ -41,11 +41,11 @@ #include "ui_ConnectFriendWizard.h" #include "gui/common/PeerDefs.h" #include "gui/connect/ConfCertDialog.h" -#include "gui/notifyqt.h" #include "gui/common/GroupDefs.h" #include "gui/msgs/MessageComposer.h" #include +#include #include #include @@ -767,7 +767,7 @@ void ConnectFriendWizard::accept() bool cancelled; std::string pgp_password; - if(!NotifyQt::getInstance()->askForPassword(tr("Profile password needed.").toStdString(), pgp_name + " (" + rsPeers->getOwnId().toStdString() + ")", prev_is_bad, pgp_password,cancelled)) + if(!RsLoginHelper::askForPassword(tr("Profile password needed.").toStdString(), pgp_name + " (" + rsPeers->getOwnId().toStdString() + ")", prev_is_bad, pgp_password,cancelled)) { QMessageBox::critical(NULL,tr("Identity creation failed"),tr("Cannot create an identity linked to your profile without your profile password.")); return; @@ -855,7 +855,12 @@ void ConnectFriendWizard::accept() ConnectProgressDialog::showProgress(ssl_id); } - NotifyQt::getInstance()->notifyListChange(NOTIFY_LIST_NEIGHBOURS,1) ; + auto ev = std::make_shared(); + ev->mEventCode = RsFriendListEventCode::NODE_ADDED; + ev->mSslId = peerDetails.id; + ev->mPgpId = peerDetails.gpg_id; + rsEvents->postEvent(ev); + QDialog::accept(); } @@ -968,190 +973,6 @@ void ConnectFriendWizard::openCert() } } -#ifdef TO_BE_REMOVED -//========================== CertificatePage ================================= - -void ConnectFriendWizard::loadFriendCert() -{ - QString fileName ; - if(!misc::getOpenFileName(this, RshareSettings::LASTDIR_CERT, tr("Select Certificate"), tr("RetroShare Certificate (*.rsc );;All Files (*)"),fileName)) - return ; - - if (!fileName.isNull()) { - ui->friendFileNameEdit->setText(fileName); - } -} - -void ConnectFriendWizard::generateCertificateCalled() -{ -#ifdef FRIEND_WIZARD_DEBUG - std::cerr << " generateCertificateCalled" << std::endl; -#endif - - std::string cert = rsPeers->GetRetroshareInvite(); - if (cert.empty()) { - QMessageBox::information(this, "RetroShare", tr("Sorry, create certificate failed"), QMessageBox::Ok, QMessageBox::Ok); - return; - } - - QString qdir = QFileDialog::getSaveFileName(this, tr("Please choose a filename"), QDir::homePath(), tr("RetroShare Certificate (*.rsc );;All Files (*)")); - - //Todo: move save to file to p3Peers::SaveCertificateToFile - - if (qdir.isEmpty() == false) { - QFile CertFile(qdir); - if (CertFile.open(QIODevice::WriteOnly/* | QIODevice::Text*/)) { - if (CertFile.write(QByteArray(cert.c_str())) > 0) { - QMessageBox::information(this, "RetroShare", tr("Certificate file successfully created"), QMessageBox::Ok, QMessageBox::Ok); - } else { - QMessageBox::information(this, "RetroShare", tr("Sorry, certificate file creation failed"), QMessageBox::Ok, QMessageBox::Ok); - } - CertFile.close(); - } else { - QMessageBox::information(this, "RetroShare", tr("Sorry, certificate file creation failed"), QMessageBox::Ok, QMessageBox::Ok); - } - } -} - -//============================= FofPage ====================================== - -void ConnectFriendWizard::updatePeersList(int index) -{ - - ui->selectedPeersTW->clearContents(); - ui->selectedPeersTW->setRowCount(0); - - RsPgpId ownId = rsPeers->getGPGOwnId(); - - int row = 0; - - _id_boxes.clear(); - - // We have to use this trick because signers are given by their names instead of their ids. That's a cause - // for some confusion when two peers have the same name. - // - std::list gpg_ids; - rsPeers->getGPGAllList(gpg_ids); - for (std::list::const_iterator it(gpg_ids.begin()); it != gpg_ids.end(); ++it) { - if (*it == ownId) { - // its me - continue; - } - -#ifdef FRIEND_WIZARD_DEBUG - std::cerr << "examining peer " << *it << " (name=" << rsPeers->getPeerName(*it); -#endif - - RsPeerDetails details ; - if (!rsPeers->getGPGDetails(*it,details)) { -#ifdef FRIEND_WIZARD_DEBUG - std::cerr << " no details." << std::endl ; -#endif - continue; - } - - // determine common friends - - std::list common_friends; - - for (std::list::const_iterator it2(details.gpgSigners.begin()); it2 != details.gpgSigners.end(); ++it2) { - if(rsPeers->isGPGAccepted(*it2)) { - common_friends.push_back(*it2); - } - } - bool show = false; - - switch(index) { - case 0: // "All unsigned friends of my friends" - show = !details.ownsign; -#ifdef FRIEND_WIZARD_DEBUG - std::cerr << "case 0: ownsign=" << details.ownsign << ", show=" << show << std::endl; -#endif - break ; - case 1: // "Unsigned peers who already signed my certificate" - show = details.hasSignedMe && !(details.state & RS_PEER_STATE_FRIEND); -#ifdef FRIEND_WIZARD_DEBUG - std::cerr << "case 1, ownsign=" << details.ownsign << ", is_authed_me=" << details.hasSignedMe << ", show=" << show << std::endl; -#endif - break ; - case 2: // "Peers shown as denied" - show = details.ownsign && !(details.state & RS_PEER_STATE_FRIEND); -#ifdef FRIEND_WIZARD_DEBUG - std::cerr << "case 2, ownsign=" << details.ownsign << ", state_friend=" << (details.state & RS_PEER_STATE_FRIEND) << ", show=" << show << std::endl; -#endif - break ; - } - - if (show) { - ui->selectedPeersTW->insertRow(row); - - QCheckBox *cb = new QCheckBox; - cb->setChecked(true); - _id_boxes[cb] = details.id; - _gpg_id_boxes[cb] = details.gpg_id; - - ui->selectedPeersTW->setCellWidget(row, 0, cb); - ui->selectedPeersTW->setItem(row, 1, new QTableWidgetItem(QString::fromUtf8(details.name.c_str()))); - - QComboBox *qcb = new QComboBox; - - if (common_friends.empty()) { - qcb->addItem(tr("*** None ***")); - } else { - for (std::list::const_iterator it2(common_friends.begin()); it2 != common_friends.end(); ++it2) { - qcb->addItem(QString::fromStdString( (*it2).toStdString())); - } - } - - ui->selectedPeersTW->setCellWidget(row, 2, qcb); - ui->selectedPeersTW->setItem(row, 3, new QTableWidgetItem(QString::fromStdString(details.id.toStdString()))); - ++row; - } - } -#ifdef FRIEND_WIZARD_DEBUG - std::cerr << "FofPage::updatePeersList() finished iterating over peers" << std::endl; -#endif - - if (row>0) { - ui->selectedPeersTW->resizeColumnsToContents(); - ui->makeFriendButton->setEnabled(true); - } else { - ui->makeFriendButton->setEnabled(false); - } -} - -void ConnectFriendWizard::signAllSelectedUsers() -{ -#ifdef FRIEND_WIZARD_DEBUG - std::cerr << "making lots of friends !!" << std::endl; -#endif - - for (std::map::const_iterator it(_id_boxes.begin()); it != _id_boxes.end(); ++it) { - if (it->first->isChecked()) { -#ifdef FRIEND_WIZARD_DEBUG - std::cerr << "Making friend with " << it->second << std::endl ; -#endif - //rsPeers->AuthCertificate(it->second, ""); - rsPeers->addFriend(it->second, _gpg_id_boxes[it->first]); - } - } - - ui->FofPage->setComplete(true); - - ui->userSelectionCB->setEnabled(false); - ui->selectedPeersTW->setEnabled(false); - ui->makeFriendButton->setEnabled(false); - - NotifyQt::getInstance()->notifyListChange(NOTIFY_LIST_NEIGHBOURS,0); - NotifyQt::getInstance()->notifyListChange(NOTIFY_LIST_FRIENDS,0); -} - -//============================= RsidPage ===================================== - - -//============================ Emailpage ===================================== -#endif - //========================= ErrorMessagePage ================================= //========================== ConclusionPage ================================== diff --git a/retroshare-gui/src/gui/connect/ConnectProgressDialog.h b/retroshare-gui/src/gui/connect/ConnectProgressDialog.h index 61951474c..cd05b0135 100644 --- a/retroshare-gui/src/gui/connect/ConnectProgressDialog.h +++ b/retroshare-gui/src/gui/connect/ConnectProgressDialog.h @@ -36,7 +36,7 @@ public: static void showProgress(const RsPeerId& id); private: - ConnectProgressDialog(const RsPeerId& id, QWidget *parent = 0, Qt::WindowFlags flags = 0); + ConnectProgressDialog(const RsPeerId& id, QWidget *parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); ~ConnectProgressDialog(); static ConnectProgressDialog *instance(const RsPeerId& peer_id); diff --git a/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp b/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp index 36b6057b4..ce410f47e 100644 --- a/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp +++ b/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include @@ -39,7 +40,6 @@ #include "gui/common/PeerDefs.h" #include "gui/common/StatusDefs.h" #include "gui/RetroShareLink.h" -#include "gui/notifyqt.h" #include "gui/common/AvatarDefs.h" #include "gui/MainWindow.h" #include "util/DateTime.h" @@ -364,13 +364,13 @@ void PGPKeyDialog::signGPGKey() bool cancelled; std::string gpg_password; - if(!NotifyQt::getInstance()->askForPassword(tr("Profile password needed.").toStdString(), gpg_name + " (" + rsPeers->getOwnId().toStdString() + ")", false, gpg_password,cancelled)) + if(!RsLoginHelper::askForPassword(tr("Profile password needed.").toStdString(), gpg_name + " (" + rsPeers->getOwnId().toStdString() + ")", false, gpg_password,cancelled)) { QMessageBox::critical(NULL,tr("Identity creation failed"),tr("Cannot create an identity linked to your profile without your profile password.")); return; } - rsNotify->clearPgpPassphrase(); // just in case + RsLoginHelper::clearPgpPassphrase(); // just in case if(!rsPeers->signGPGCertificate(pgpId,gpg_password)) QMessageBox::warning ( NULL, tr("Signature Failure"), tr("Check the password!"), QMessageBox::Ok); diff --git a/retroshare-gui/src/gui/elastic/arrow.cpp b/retroshare-gui/src/gui/elastic/arrow.cpp index 6a95f2041..22c706ed8 100644 --- a/retroshare-gui/src/gui/elastic/arrow.cpp +++ b/retroshare-gui/src/gui/elastic/arrow.cpp @@ -21,6 +21,7 @@ // This code is inspired from http://doc.qt.io/qt-5/qtwidgets-graphicsview-diagramscene-arrow-cpp.html #include +#include "gui/settings/rsharesettings.h" #include "arrow.h" #include "elnode.h" @@ -33,7 +34,7 @@ static double TwoPi = 2.0 * Pi; Arrow::Arrow(Node *sourceNode, Node *destNode) : arrowSize(10) { - setAcceptedMouseButtons(0); + setAcceptedMouseButtons(Qt::MouseButton::NoButton); source = sourceNode; dest = destNode; #ifdef SUSP @@ -121,8 +122,11 @@ void Arrow::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget * cos(angle - Pi / 3) * arrowSize); QPointF destArrowP2 = destPoint + QPointF(sin(angle - Pi + Pi / 3) * arrowSize, cos(angle - Pi + Pi / 3) * arrowSize); - - painter->setBrush(Qt::black); + if (Settings->getSheetName() == ":Standard_Dark"){ + painter->setBrush(Qt::white); + } else { + painter->setBrush(Qt::black); + } painter->drawPolygon(QPolygonF() << line.p1() << sourceArrowP1 << sourceArrowP2); painter->drawPolygon(QPolygonF() << line.p2() << destArrowP1 << destArrowP2); } diff --git a/retroshare-gui/src/gui/elastic/edge.cpp b/retroshare-gui/src/gui/elastic/edge.cpp index 0fd8707d2..820d7c79a 100644 --- a/retroshare-gui/src/gui/elastic/edge.cpp +++ b/retroshare-gui/src/gui/elastic/edge.cpp @@ -21,6 +21,7 @@ // This code is inspired from http://doc.qt.io/qt-5/qtwidgets-graphicsview-elasticnodes-edge-cpp.html #include +#include "gui/settings/rsharesettings.h" #include "edge.h" #include "elnode.h" @@ -32,7 +33,7 @@ Edge::Edge(Node *sourceNode, Node *destNode) : arrowSize(10) { - setAcceptedMouseButtons(0); + setAcceptedMouseButtons(Qt::MouseButton::NoButton); source = sourceNode; dest = destNode; source->addEdge(this); @@ -103,7 +104,11 @@ void Edge::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) // Draw the line itself QLineF line(sourcePoint, destPoint); - painter->setPen(QPen(Qt::black, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + if (Settings->getSheetName() == ":Standard_Dark"){ + painter->setPen(QPen(Qt::white, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + } else { + painter->setPen(QPen(Qt::black, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + } painter->drawLine(line); return ; @@ -146,7 +151,11 @@ void Edge::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) QPointF destArrowP1 = destPoint + QPointF( sin_theta_mins_pi_over_3 * arrowSize, cos_theta_mins_pi_over_3 * arrowSize); QPointF destArrowP2 = destPoint + QPointF(sin_theta_mins_2_pi_over_3 * arrowSize, cos_theta_mins_2_pi_over_3 * arrowSize); - painter->setBrush(Qt::black); + if (Settings->getSheetName() == ":Standard_Dark"){ + painter->setBrush(Qt::white); + }else { + painter->setBrush(Qt::black); + } painter->drawConvexPolygon(QPolygonF() << line.p1() << sourceArrowP1 << sourceArrowP2); painter->drawConvexPolygon(QPolygonF() << line.p2() << destArrowP1 << destArrowP2); } diff --git a/retroshare-gui/src/gui/elastic/elnode.cpp b/retroshare-gui/src/gui/elastic/elnode.cpp index 86bb4e31e..326c469fa 100644 --- a/retroshare-gui/src/gui/elastic/elnode.cpp +++ b/retroshare-gui/src/gui/elastic/elnode.cpp @@ -21,6 +21,7 @@ // This code is inspired from http://doc.qt.io/qt-5/qtwidgets-graphicsview-elasticnodes-node-cpp.html #include "gui/common/FilesDefs.h" +#include "gui/settings/rsharesettings.h" #include #include @@ -38,6 +39,7 @@ #include "edge.h" #include "elnode.h" #include "graphwidget.h" +#include "util/RsQtVersion.h" #define IMAGE_AUTHED ":/images/accepted16.png" #define IMAGE_DENIED ":/images/denied16.png" @@ -302,7 +304,11 @@ void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid #endif } painter->setBrush(gradient); - painter->setPen(QPen(Qt::black, 0)); + if (Settings->getSheetName() == ":Standard_Dark"){ + painter->setPen(QPen(Qt::white, 0)); + } else { + painter->setPen(QPen(Qt::black, 0)); + } painter->drawEllipse(-mNodeDrawSize2, -mNodeDrawSize2, mNodeDrawSize, mNodeDrawSize); QString txt = QString::fromUtf8(_desc_string.c_str()); @@ -313,7 +319,7 @@ void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid if (!mDeterminedBB) { - QRect textBox = painter->boundingRect(-10, 5*f, QFontMetricsF(graph->font()).width(txt), 1.5*m, Qt::AlignVCenter, QString::fromUtf8(_desc_string.c_str())); + QRect textBox = painter->boundingRect(-10, 5*f, QFontMetrics_horizontalAdvance(QFontMetricsF(graph->font()), txt), 1.5*m, Qt::AlignVCenter, QString::fromUtf8(_desc_string.c_str())); mBBWidth = textBox.width()+40*f; mDeterminedBB = true; } diff --git a/retroshare-gui/src/gui/elastic/graphwidget.cpp b/retroshare-gui/src/gui/elastic/graphwidget.cpp index d0f90050f..deb4dff2d 100644 --- a/retroshare-gui/src/gui/elastic/graphwidget.cpp +++ b/retroshare-gui/src/gui/elastic/graphwidget.cpp @@ -29,6 +29,9 @@ #include #include #include +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) +#include +#endif #include @@ -131,8 +134,16 @@ void GraphWidget::keyPressEvent(QKeyEvent *event) case Qt::Key_Space: case Qt::Key_Enter: foreach (QGraphicsItem *item, scene()->items()) { - if (qgraphicsitem_cast(item)) - item->setPos(-150 + qrand() % 300, -150 + qrand() % 300); + if (qgraphicsitem_cast(item)) { +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) + int x = QRandomGenerator::global()->generate(); + int y = QRandomGenerator::global()->generate(); +#else + int x = qrand(); + int y = qrand(); +#endif + item->setPos(-150 + x % 300, -150 + y % 300); + } } break; default: @@ -331,12 +342,18 @@ void GraphWidget::resizeEvent(QResizeEvent *event) void GraphWidget::wheelEvent(QWheelEvent *event) { - scaleView(pow((double)2, -event->delta() / 240.0)); +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) + int delta = event->angleDelta().y(); +#else + int delta = event->delta(); +#endif + + scaleView(pow((double)2, -delta / 240.0)); } void GraphWidget::scaleView(qreal scaleFactor) { - qreal factor = matrix().scale(scaleFactor, scaleFactor).mapRect(QRectF(0, 0, 1, 1)).width(); + qreal factor = transform().scale(scaleFactor, scaleFactor).mapRect(QRectF(0, 0, 1, 1)).width(); if (factor < 0.07 || factor > 100) return; diff --git a/retroshare-gui/src/gui/feeds/BoardsCommentsItem.cpp b/retroshare-gui/src/gui/feeds/BoardsCommentsItem.cpp index 57adbb39d..59082a8fd 100644 --- a/retroshare-gui/src/gui/feeds/BoardsCommentsItem.cpp +++ b/retroshare-gui/src/gui/feeds/BoardsCommentsItem.cpp @@ -78,7 +78,8 @@ BaseBoardsCommentsItem::BaseBoardsCommentsItem( FeedHolder *feedHolder, uint32_t BaseBoardsCommentsItem::~BaseBoardsCommentsItem() { - auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(200); + auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(GROUP_ITEM_LOADING_TIMEOUT_ms); + while( (mIsLoadingGroup || mIsLoadingMessage || mIsLoadingComment) && std::chrono::steady_clock::now() < timeout) { @@ -126,6 +127,7 @@ bool BaseBoardsCommentsItem::setPost(const RsPostedPost &post, bool doFill) void BaseBoardsCommentsItem::loadGroup() { mIsLoadingGroup = true; + RsThread::async([this]() { // 1 - get group data @@ -141,6 +143,7 @@ void BaseBoardsCommentsItem::loadGroup() { RsErr() << "GxsPostedGroupItem::loadGroup() ERROR getting data" << std::endl; mIsLoadingGroup = false; + deferred_update(); return; } @@ -148,7 +151,8 @@ void BaseBoardsCommentsItem::loadGroup() { std::cerr << "GxsPostedGroupItem::loadGroup() Wrong number of Items" << std::endl; mIsLoadingGroup = false; - return; + deferred_update(); + return; } RsPostedGroup group(groups[0]); @@ -180,7 +184,8 @@ void BaseBoardsCommentsItem::loadMessage() { RsErr() << "BaseBoardsCommentsItem::loadMessage() ERROR getting data" << std::endl; mIsLoadingMessage = false; - return; + deferred_update(); + return; } if (posts.size() == 1) @@ -241,7 +246,8 @@ void BaseBoardsCommentsItem::loadComment() { RsErr() << "BaseBoardsCommentsItem::loadGroup() ERROR getting data" << std::endl; mIsLoadingComment = false; - return; + deferred_update(); + return; } int comNb = comments.size(); diff --git a/retroshare-gui/src/gui/feeds/BoardsCommentsItem.h b/retroshare-gui/src/gui/feeds/BoardsCommentsItem.h index d5bff44b7..bffbf5bf6 100644 --- a/retroshare-gui/src/gui/feeds/BoardsCommentsItem.h +++ b/retroshare-gui/src/gui/feeds/BoardsCommentsItem.h @@ -24,7 +24,7 @@ #include #include -#include "gui/gxs/GxsFeedItem.h" +#include "gui/feeds/GxsFeedItem.h" namespace Ui { class BoardsCommentsItem; diff --git a/retroshare-gui/src/gui/feeds/BoardsPostItem.cpp b/retroshare-gui/src/gui/feeds/BoardsPostItem.cpp new file mode 100644 index 000000000..9fcf15bff --- /dev/null +++ b/retroshare-gui/src/gui/feeds/BoardsPostItem.cpp @@ -0,0 +1,536 @@ +/******************************************************************************* + * gui/feeds/BoardsPostItem.cpp * + * * + * Copyright (c) 2012, Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#include +#include +#include + +#include "gui/gxs/GxsIdDetails.h" +#include "gui/common/FilesDefs.h" +#include "gui/Posted/PhotoView.h" +#include "rshare.h" +#include "BoardsPostItem.h" +#include "ui_BoardsPostItem.h" + +#include "FeedHolder.h" +#include "SubFileItem.h" +#include "util/misc.h" +#include "util/qtthreadsutils.h" +#include "gui/RetroShareLink.h" +#include "util/HandleRichText.h" +#include "util/DateTime.h" +#include "util/stringutil.h" + +#include +#include + +/**** + * #define DEBUG_ITEM 1 + ****/ + +BoardsPostItem::BoardsPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId& groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate,const std::set& older_versions) : + GxsFeedItem(feedHolder, feedId, groupId, messageId, isHome, rsPosted, autoUpdate) // this one should be in GxsFeedItem +{ + QVector v; + //bool self = false; + + for(std::set::const_iterator it(older_versions.begin());it!=older_versions.end();++it) + v.push_back(*it) ; + + if(older_versions.find(messageId) == older_versions.end()) + v.push_back(messageId); + + mLoadingStatus = LOADING_STATUS_NO_DATA; + mLoadingMessage = false; + mLoadingGroup = false; + + setMessageVersions(v) ; + setup(); +} + +void BoardsPostItem::paintEvent(QPaintEvent *e) +{ + /* This method employs a trick to trigger a deferred loading. The post and group is requested only + * when actually displayed on the screen. */ + + if(mLoadingStatus != LOADING_STATUS_FILLED && !mGroupMeta.mGroupId.isNull() && !mPost.mMeta.mMsgId.isNull() ) + mLoadingStatus = LOADING_STATUS_HAS_DATA; + + if(mGroupMeta.mGroupId.isNull() && !mLoadingGroup) + requestGroup(); + + if(mPost.mMeta.mMsgId.isNull() && !mLoadingMessage) + requestMessage(); + + switch(mLoadingStatus) + { + case LOADING_STATUS_FILLED: + case LOADING_STATUS_NO_DATA: + default: + break; + + case LOADING_STATUS_HAS_DATA: + fill(); + mLoadingStatus = LOADING_STATUS_FILLED; + break; + } + + GxsFeedItem::paintEvent(e) ; +} + +BoardsPostItem::~BoardsPostItem() +{ + auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(GROUP_ITEM_LOADING_TIMEOUT_ms); + + while( (mLoadingGroup || mLoadingMessage) + && std::chrono::steady_clock::now() < timeout) + { + RsDbg() << __PRETTY_FUNCTION__ << " is Waiting for " + << (mLoadingGroup ? "Group " : "") + << (mLoadingMessage ? "Message " : "") + << "loading." << std::endl; + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } + + delete(ui); +} + +bool BoardsPostItem::isUnread() const +{ + return IS_MSG_UNREAD(mPost.mMeta.mMsgStatus) ; +} + +void BoardsPostItem::setup() +{ + /* Invoke the Qt Designer generated object setup routine */ + + ui = new Ui::BoardsPostItem; + ui->setupUi(this); + + // Manually set icons to allow to use clever resource sharing that is missing in Qt for Icons loaded from Qt resource file. + // This is particularly important here because a channel may contain many posts, so duplicating the QImages here is deadly for the + // memory. + + ui->logoLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/thumb-default-video.png")); + //ui->warn_image_label->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/status_unknown.png")); + //ui->readButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/message-state-unread.png")); + //ui->voteUpButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/vote_up.png")); + //ui->voteDownButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/vote_down.png")); + //ui->downloadButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/download.png")); + //ui->playButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/play.png")); + ui->commentButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/comment.png")); + //ui->editButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/pencil-edit-button.png")); + //ui->copyLinkButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/copy.png")); + ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/down-arrow.png")); + ui->readAndClearButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/correct.png")); + ui->clearButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/exit2.png")); + + setAttribute(Qt::WA_DeleteOnClose, true); + + mCloseOnRead = false; + + /* clear ui */ + ui->titleLabel->setText(tr("Loading...")); + ui->datetimelabel->clear(); + //ui->filelabel->hide(); + //ui->newCommentLabel->hide(); + //ui->commLabel->hide(); + + /* general ones */ + connect(ui->expandButton, SIGNAL(clicked()), this, SLOT(toggle())); + connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(removeItem())); + connect(ui->logoLabel, SIGNAL(clicked()), this, SLOT(viewPicture())); + + /* specific */ + connect(ui->readAndClearButton, SIGNAL(clicked()), this, SLOT(readAndClearItem())); + //connect(ui->unsubscribeButton, SIGNAL(clicked()), this, SLOT(unsubscribeChannel())); + + //connect(ui->downloadButton, SIGNAL(clicked()), this, SLOT(download())); + // HACK FOR NOW. + ui->commentButton->hide();// hidden until properly enabled. +// connect(ui->commentButton, SIGNAL(clicked()), this, SLOT(loadComments())); + + //connect(ui->playButton, SIGNAL(clicked()), this, SLOT(play(void))); + //connect(ui->editButton, SIGNAL(clicked()), this, SLOT(edit(void))); + //connect(ui->copyLinkButton, SIGNAL(clicked()), this, SLOT(copyMessageLink())); + + //connect(ui->readButton, SIGNAL(toggled(bool)), this, SLOT(readToggled(bool))); + + // hide voting buttons, backend is not implemented yet + //ui->voteUpButton->hide(); + //ui->voteDownButton->hide(); + + //ui->scoreLabel->hide(); + + // hide unsubscribe button not necessary + //ui->unsubscribeButton->hide(); + + //ui->downloadButton->hide(); + //ui->playButton->hide(); + //ui->warn_image_label->hide(); + //ui->warning_label->hide(); + + ui->titleLabel->setMinimumWidth(100); + //ui->subjectLabel->setMinimumWidth(100); + //ui->warning_label->setMinimumWidth(100); + + ui->feedFrame->setProperty("new", false); + ui->feedFrame->style()->unpolish(ui->feedFrame); + ui->feedFrame->style()->polish( ui->feedFrame); + + ui->expandFrame->hide(); +} + +QString BoardsPostItem::groupName() +{ + return QString::fromUtf8(mGroupMeta.mGroupName.c_str()); +} + +void BoardsPostItem::loadGroup() +{ + std::cerr << "BoardsGroupItem::loadGroup()" << std::endl; + + mLoadingGroup = true; + + RsThread::async([this]() + { + // 1 - get group data + + std::vector groups; + const std::list groupIds = { groupId() }; + + if(!rsPosted->getBoardsInfo(groupIds,groups)) // would be better to call channel Summaries for a single group + { + RsErr() << "BoardsPostItem::loadGroup() ERROR getting data for group " << groupId() << std::endl; + mLoadingGroup = false; + deferred_update(); + return; + } + + if (groups.size() != 1) + { + std::cerr << "BoardsPostItem::loadGroup() Wrong number of Items for group " << groupId() ; + std::cerr << std::endl; + mLoadingGroup = false; + deferred_update(); + return; + } + RsPostedGroup group(groups[0]); + + RsQThreadUtils::postToObject( [group,this]() + { + /* Here it goes any code you want to be executed on the Qt Gui + * thread, for example to update the data model with new information + * after a blocking call to RetroShare API complete */ + + mGroupMeta = group.mMeta; + mLoadingGroup = false; + + update(); // this triggers a paintEvent if needed. + + }, this ); + }); +} +void BoardsPostItem::loadMessage() +{ +#ifdef DEBUG_ITEM + std::cerr << "BoardsPostItem::loadMessage()"; + std::cerr << std::endl; +#endif + mLoadingMessage = true; + + RsThread::async([this]() + { + // 1 - get group data + + std::vector posts; + std::vector comments; + std::vector votes; + + if(! rsPosted->getBoardContent( groupId(), std::set( { messageId() } ),posts,comments,votes)) + { + RsErr() << "BoardsPostedItem::loadMessage() ERROR getting data" << std::endl; + mLoadingMessage = false; + deferred_update(); + return; + } + + if (posts.size() == 1) + { +#ifdef DEBUG_ITEM + std::cerr << (void*)this << ": Obtained post, with msgId = " << posts[0].mMeta.mMsgId << std::endl; +#endif + const RsPostedPost& post(posts[0]); + + RsQThreadUtils::postToObject( [post,this]() + { + mPost = post; + mLoadingMessage = false; + update(); // this triggers a paintEvent if needed. + + }, this ); + } + else + { +#ifdef DEBUG_ITEM + std::cerr << "BoardsPostItem::loadMessage() Wrong number of Items. Remove It."; + std::cerr << std::endl; +#endif + + RsQThreadUtils::postToObject( [this]() + { + removeItem(); + mLoadingMessage = false; + update(); // this triggers a paintEvent if needed. + }, this ); + } + }); +} + +void BoardsPostItem::fill() +{ +#ifdef DEBUG_ITEM + std::cerr << "BoardsPostItem::fill()"; + std::cerr << std::endl; +#endif + + QString title; + QString msgText; + //float f = QFontMetricsF(font()).height()/14.0 ; + + ui->logoLabel->setEnableZoom(false); + int desired_height = QFontMetricsF(font()).height() * ITEM_HEIGHT_FACTOR; + ui->logoLabel->setFixedSize(ITEM_PICTURE_FORMAT_RATIO*desired_height,desired_height); + + if(mPost.mImage.mData != NULL) + { + QPixmap thumbnail; + GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, thumbnail,GxsIdDetails::ORIGINAL); + // Wiping data - as its been passed to thumbnail. + + ui->logoLabel->setPicture(thumbnail); + } + else + ui->logoLabel->setPicture( FilesDefs::getPixmapFromQtResourcePath(":/images/thumb-default-video.png") ); + + //if( !IS_GROUP_PUBLISHER(mGroupMeta.mSubscribeFlags) ) + //ui->editButton->hide() ; // never show this button. Feeds are not the place to edit posts. + + if(mPost.mNotes.empty()) + ui->expandButton->hide() ; // never show this button. + + if (mCloseOnRead && !IS_MSG_NEW(mPost.mMeta.mMsgStatus)) { + removeItem(); + } + + title = tr("Board") + ": "; + RetroShareLink link = RetroShareLink::createGxsGroupLink(RetroShareLink::TYPE_POSTED, mPost.mMeta.mGroupId, groupName()); + title += link.toHtml(); + ui->titleLabel->setText(title); + + msgText = tr("Post") + ": "; + RetroShareLink msgLink = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_POSTED, mPost.mMeta.mGroupId, mPost.mMeta.mMsgId, messageName()); + msgText += msgLink.toHtml(); + msgText += " By: "; + + RsIdentityDetails detail; + rsIdentity->getIdDetails(mPost.mMeta.mAuthorId,detail); + msgText += GxsIdDetails::getName(detail); + + ui->subjectLabel->setText(msgText); + + //std::cerr << "Copying 1 line from \"" << mPost.mNotes << "\"" << std::endl; + //ui->newCommentLabel->setText(RsStringUtil::CopyLines(QString::fromUtf8(mPost.mNotes.c_str()), 1)) ; + //ui->newCommentLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mNotes.c_str()), /* RSHTML_FORMATTEXT_EMBED_SMILEYS |*/ RSHTML_FORMATTEXT_EMBED_LINKS)); + +// if (IS_GROUP_SUBSCRIBED(mGroupMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroupMeta.mSubscribeFlags)) +// { +// ui->unsubscribeButton->setEnabled(true); +// } +// else +// { +// ui->unsubscribeButton->setEnabled(false); +// } + //ui->readButton->hide(); + ui->newLabel->hide(); + //ui->copyLinkButton->hide(); + + if (IS_MSG_NEW(mPost.mMeta.mMsgStatus)) + mCloseOnRead = true; + + // differences between Feed or Top of Comment. + if(mFeedHolder) + { + if (mIsHome) { + ui->commentButton->show(); + } else if (ui->commentButton->icon().isNull()){ + //Icon is seted if a comment received. + ui->commentButton->hide(); + } + } + else + { + ui->commentButton->hide(); + } + + // disable voting buttons - if they have already voted. + /*if (post.mMeta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_VOTE_MASK) + { + voteUpButton->setEnabled(false); + voteDownButton->setEnabled(false); + }*/ + + { + QTextDocument doc; + doc.setHtml( QString::fromUtf8(mPost.mNotes.c_str()) ); + + ui->msgFrame->setVisible(doc.toPlainText().length() > 0); + } + + ui->datetimelabel->setText(DateTime::formatLongDateTime(mPost.mMeta.mPublishTs)); +} + +QString BoardsPostItem::messageName() +{ + return QString::fromUtf8(mPost.mMeta.mMsgName.c_str()); +} + +void BoardsPostItem::viewPicture() +{ + if(mPost.mImage.mData == NULL) { + return; + } + + QString timestamp = misc::timeRelativeToNow(mPost.mMeta.mPublishTs); + QPixmap pixmap; + GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL); + RsGxsId authorID = mPost.mMeta.mAuthorId; + + PhotoView *PView = new PhotoView(this); + + PView->setPixmap(pixmap); + PView->setTitle(messageName()); + PView->setName(authorID); + PView->setTime(timestamp); + PView->setGroupId(groupId()); + PView->setMessageId(messageId()); + + PView->show(); + + /* window will destroy itself! */ +} +void BoardsPostItem::setReadStatus(bool isNew, bool isUnread) +{ +#ifdef TODO + if (isNew) + mPost.mMeta.mMsgStatus |= GXS_SERV::GXS_MSG_STATUS_GUI_NEW; + else + mPost.mMeta.mMsgStatus &= ~GXS_SERV::GXS_MSG_STATUS_GUI_NEW; + + if (isUnread) + { + mPost.mMeta.mMsgStatus |= GXS_SERV::GXS_MSG_STATUS_GUI_UNREAD; + whileBlocking(ui->readButton)->setChecked(true); + ui->readButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/message-state-unread.png")); + } + else + { + mPost.mMeta.mMsgStatus &= ~GXS_SERV::GXS_MSG_STATUS_GUI_UNREAD; + whileBlocking(ui->readButton)->setChecked(false); + ui->readButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/message-state-read.png")); + } + + ui->newLabel->setVisible(isNew); + + ui->feedFrame->setProperty("new", isNew); + ui->feedFrame->style()->unpolish(ui->feedFrame); + ui->feedFrame->style()->polish( ui->feedFrame); +#endif +} +void BoardsPostItem::toggle() +{ + expand(ui->expandFrame->isHidden()); +} + +/*********** SPECIFIC FUNCTIONS ***********************/ + +void BoardsPostItem::readAndClearItem() +{ +#ifdef DEBUG_ITEM + std::cerr << "BoardsPostItem::readAndClearItem()"; + std::cerr << std::endl; +#endif + readToggled(false); + removeItem(); +} + +void BoardsPostItem::readToggled(bool /*checked*/) +{ + mCloseOnRead = false; + + RsGxsGrpMsgIdPair msgPair = std::make_pair(groupId(), messageId()); + + rsPosted->setPostReadStatus(msgPair, isUnread()); +} + +void BoardsPostItem::fillExpandFrame() +{ + ui->msgLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mNotes.c_str()), /* RSHTML_FORMATTEXT_EMBED_SMILEYS |*/ RSHTML_FORMATTEXT_EMBED_LINKS)); +} + +void BoardsPostItem::doExpand(bool open) +{ + if (mFeedHolder) + { + mFeedHolder->lockLayout(this, true); + } + + if (open) + { + ui->expandFrame->show(); + ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/up-arrow.png"))); + ui->expandButton->setToolTip(tr("Hide")); + + readToggled(false); + } + else + { + ui->expandFrame->hide(); + ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/down-arrow.png"))); + ui->expandButton->setToolTip(tr("Expand")); + } + + emit sizeChanged(this); + + if (mFeedHolder) + { + mFeedHolder->lockLayout(this, false); + } +} + +void BoardsPostItem::expandFill(bool first) +{ + GxsFeedItem::expandFill(first); + + if (first) { + fillExpandFrame(); + } +} + diff --git a/retroshare-gui/src/gui/feeds/BoardsPostItem.h b/retroshare-gui/src/gui/feeds/BoardsPostItem.h new file mode 100644 index 000000000..3b8845f63 --- /dev/null +++ b/retroshare-gui/src/gui/feeds/BoardsPostItem.h @@ -0,0 +1,106 @@ +/******************************************************************************* + * gui/feeds/BoardsPostItem.h * + * * + * Copyright (c) 2012, Robert Fernie * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#ifndef _BOARDS_POST_ITEM_H +#define _BOARDS_POST_ITEM_H + +#include + +#include +#include "gui/feeds/GxsFeedItem.h" + +namespace Ui { +class BoardsPostItem; +} + +class FeedHolder; +class SubFileItem; + +class BoardsPostItem : public GxsFeedItem +{ + Q_OBJECT + +public: + // This one is used in NewFeed for incoming channel posts. Only the group and msg ids are known at this point. + // It can be used for all apparences of channel posts. But in rder to merge comments from the previous versions of the post, the list of + // previous posts should be supplied. It's optional. If not supplied only the comments of the new version will be displayed. + + BoardsPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId& groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate, const std::set& older_versions = std::set()); + virtual ~BoardsPostItem(); + + uint64_t uniqueIdentifier() const override { return hash_64bits("BoardsPostItem " + messageId().toStdString()) ; } + +protected: + + bool isUnread() const ; + void setReadStatus(bool isNew, bool isUnread); + + static uint64_t computeIdentifier(const RsGxsMessageId& msgid) { return hash64("BoardsPostItem " + msgid.toStdString()) ; } + + /* FeedItem */ + virtual void doExpand(bool open) override ; + virtual void expandFill(bool first) override ; + + // This does nothing except triggering the loading of the post data and comments. This function is mainly used to detect + // when the post is actually made visible. + + virtual void paintEvent(QPaintEvent *) override; + + /* GxsGroupFeedItem */ + virtual QString groupName() override; + virtual void loadGroup() override; + virtual RetroShareLink::enumType getLinkType() override{ return RetroShareLink::TYPE_CHANNEL; } + + /* GxsFeedItem */ + virtual QString messageName() override; + virtual void loadMessage() override; + virtual void loadComment() override {} + +private slots: + /* default stuff */ + void toggle() override; + void readAndClearItem(); + void readToggled(bool checked); + void viewPicture(); + +signals: + void vote(const RsGxsGrpMsgIdPair& msgId, bool up); + +private: + void setup(); + void fill(); + void fillExpandFrame(); + +private: + bool mCloseOnRead; + + LoadingStatus mLoadingStatus; + + bool mLoadingMessage; + bool mLoadingGroup; + + RsGroupMetaData mGroupMeta; + RsPostedPost mPost; + + /** Qt Designer generated object */ + Ui::BoardsPostItem *ui; +}; + +#endif diff --git a/retroshare-gui/src/gui/feeds/BoardsPostItem.ui b/retroshare-gui/src/gui/feeds/BoardsPostItem.ui new file mode 100644 index 000000000..3a7a890f6 --- /dev/null +++ b/retroshare-gui/src/gui/feeds/BoardsPostItem.ui @@ -0,0 +1,334 @@ + + + BoardsPostItem + + + + 0 + 0 + 803 + 175 + + + + + 1 + + + 1 + + + 1 + + + 1 + + + 6 + + + 1 + + + + + + 0 + 0 + + + + true + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + + 0 + 0 + + + + + + + false + + + Qt::AlignCenter + + + + + + + + + + + + + + 0 + 0 + + + + + 11 + 75 + true + true + + + + Board label + + + false + + + true + + + + + + + + 75 + true + + + + DateTime + + + + + + + New + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + 0 + + + + + + 11 + 75 + false + true + + + + TextLabel + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Comments + + + + + + + + 0 + 0 + + + + Qt::NoFocus + + + Expand + + + + + + + + 0 + 0 + + + + Qt::NoFocus + + + Set as read and remove item + + + + + + + + 0 + 0 + + + + Qt::NoFocus + + + Remove Item + + + + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::Box + + + QFrame::Sunken + + + + 5 + + + 5 + + + 5 + + + 5 + + + + + + 0 + 0 + + + + true + + + 6 + + + -1 + + + true + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 0 + + + + + + + + + + + + ZoomableLabel + QLabel +
gui/gxschannels/GxsChannelPostThumbnail.h
+
+
+ + + + +
diff --git a/retroshare-gui/src/gui/feeds/ChannelsCommentsItem.cpp b/retroshare-gui/src/gui/feeds/ChannelsCommentsItem.cpp index 5b0e0b264..75a6106fc 100644 --- a/retroshare-gui/src/gui/feeds/ChannelsCommentsItem.cpp +++ b/retroshare-gui/src/gui/feeds/ChannelsCommentsItem.cpp @@ -49,39 +49,17 @@ * #define DEBUG_ITEM 1 ****/ -// ChannelsCommentsItem::ChannelsCommentsItem(FeedHolder *feedHolder, uint32_t feedId, const RsGroupMetaData& group_meta, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate,const std::set& older_versions) : -// GxsFeedItem(feedHolder, feedId, group_meta.mGroupId, messageId, isHome, rsGxsChannels, autoUpdate), -// mGroupMeta(group_meta) -// { -// mLoadingGroup = false; -// mLoadingMessage = false; -// mLoadingComment = false; -// -// mPost.mMeta.mMsgId = messageId; // useful for uniqueIdentifer() before the post is loaded -// mPost.mMeta.mGroupId = mGroupMeta.mGroupId; -// -// QVector v; -// //bool self = false; -// -// for(std::set::const_iterator it(older_versions.begin());it!=older_versions.end();++it) -// v.push_back(*it) ; -// -// if(older_versions.find(messageId) == older_versions.end()) -// v.push_back(messageId); -// -// setMessageVersions(v) ; -// setup(); -// -// // no call to loadGroup() here because we have it already. -// } - ChannelsCommentsItem::ChannelsCommentsItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId& groupId, const RsGxsMessageId &commentId, const RsGxsMessageId &threadId, bool isHome, bool autoUpdate) : GxsFeedItem(feedHolder, feedId, groupId, commentId, isHome, rsGxsChannels, autoUpdate), // this one should be in GxsFeedItem mThreadId(threadId) { - mLoading= false; + mGroupMeta.mGroupId.clear(); // safety measure + mComment.mMeta.mMsgId.clear(); - QVector v; + mLoadingStatus = LOADING_STATUS_NO_DATA; + mLoadingComment = false; + mLoadingGroup = false; + mLoadingMessage = false; setup(); } @@ -91,10 +69,28 @@ void ChannelsCommentsItem::paintEvent(QPaintEvent *e) /* This method employs a trick to trigger a deferred loading. The post and group is requested only * when actually displayed on the screen. */ - if(!mLoaded) - { - mLoaded = true ; - load(); + if(mLoadingStatus != LOADING_STATUS_FILLED && !mGroupMeta.mGroupId.isNull() && !mComment.mMeta.mMsgId.isNull() && !mPost.mMeta.mMsgId.isNull()) + mLoadingStatus = LOADING_STATUS_HAS_DATA; + + if(mGroupMeta.mGroupId.isNull() && !mLoadingGroup) + loadGroupData(); + + if(mComment.mMeta.mMsgId.isNull() && !mLoadingComment) + loadCommentData(); + + if(mPost.mMeta.mMsgId.isNull() && !mLoadingMessage) + loadMessageData(); + + switch(mLoadingStatus) + { + case LOADING_STATUS_FILLED: + case LOADING_STATUS_NO_DATA: + default: + break; + case LOADING_STATUS_HAS_DATA: + fill(); + mLoadingStatus = LOADING_STATUS_FILLED; + break; } GxsFeedItem::paintEvent(e) ; @@ -102,11 +98,16 @@ void ChannelsCommentsItem::paintEvent(QPaintEvent *e) ChannelsCommentsItem::~ChannelsCommentsItem() { - auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(300); + auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(GROUP_ITEM_LOADING_TIMEOUT_ms); - while( mLoading && std::chrono::steady_clock::now() < timeout ) + while( (mLoadingGroup || mLoadingComment) + && std::chrono::steady_clock::now() < timeout ) { - RsDbg() << __PRETTY_FUNCTION__ << " is Waiting for data to load " << std::endl; + RsDbg() << __PRETTY_FUNCTION__ << " is Waiting for data to load " + << (mLoadingGroup ? "Group " : "") + << (mLoadingMessage ? "Message " : "") + << (mLoadingComment ? "Comment " : "") + << std::endl; std::this_thread::sleep_for(std::chrono::milliseconds(100)); } @@ -115,7 +116,7 @@ ChannelsCommentsItem::~ChannelsCommentsItem() bool ChannelsCommentsItem::isUnread() const { - return IS_MSG_UNREAD(mPost.mMeta.mMsgStatus) ; + return IS_MSG_UNREAD(mComment.mMeta.mMsgStatus) ; } void ChannelsCommentsItem::setup() @@ -141,9 +142,7 @@ void ChannelsCommentsItem::setup() setAttribute(Qt::WA_DeleteOnClose, true); - mInFill = false; mCloseOnRead = false; - mLoaded = false; /* clear ui */ ui->datetimeLabel->clear(); @@ -178,33 +177,6 @@ void ChannelsCommentsItem::setup() ui->expandFrame->hide(); } -bool ChannelsCommentsItem::setPost(const RsGxsChannelPost& post, bool doFill) -{ - mPost = post; - - if (doFill) - fill(); - - return true; -} -bool ChannelsCommentsItem::setMissingPost() -{ - fill(true); - return true; -} - -QString ChannelsCommentsItem::getTitleLabel() -{ - return QString::fromUtf8(mPost.mMeta.mMsgName.c_str()); -} - -QString ChannelsCommentsItem::getMsgLabel() -{ - //return RsHtml().formatText(NULL, QString::fromUtf8(mPost.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS); - // Disabled, because emoticon replacement kills performance. - return QString::fromUtf8(mPost.mMsg.c_str()); -} - QString ChannelsCommentsItem::groupName() { return QString::fromUtf8(mGroupMeta.mGroupName.c_str()); @@ -219,91 +191,112 @@ void ChannelsCommentsItem::loadComments() return ; MainWindow::showWindow(MainWindow::Channels); - channelDialog->navigate(mPost.mMeta.mGroupId, mPost.mMeta.mMsgId); + channelDialog->navigate(mComment.mMeta.mGroupId, mComment.mMeta.mMsgId); } -void ChannelsCommentsItem::loadGroup() +void ChannelsCommentsItem::loadGroupData() { -//#ifdef DEBUG_ITEM -// std::cerr << "GxsChannelGroupItem::loadGroup()"; -// std::cerr << std::endl; -//#endif -// if(mLoading) -// return; -// -// mLoading= true; -// -// std::cerr << "Loading group" << std::endl; -// RsThread::async([this]() -// { -// // 1 - get group data -// -// std::vector groups; -// const std::list groupIds = { groupId() }; -// -// if(!rsGxsChannels->getChannelsInfo(groupIds,groups)) // would be better to call channel Summaries for a single group -// { -// RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl; -// return; -// } -// -// if (groups.size() != 1) -// { -// std::cerr << "GxsGxsChannelGroupItem::loadGroup() Wrong number of Items"; -// std::cerr << std::endl; -// return; -// } -// RsGxsChannelGroup group(groups[0]); -// -// RsQThreadUtils::postToObject( [group,this]() -// { -// /* Here it goes any code you want to be executed on the Qt Gui -// * thread, for example to update the data model with new information -// * after a blocking call to RetroShare API complete */ -// -// mGroupMeta = group.mMeta; -// mLoading= false; -// -// std::cerr << "End loading group" << std::endl; -// }, this ); -// }); -} -void ChannelsCommentsItem::load() -{ - // This function loads everything that's needed: - // - the comment text - // - the comment parent message + std::cerr << "GxsChannelGroupItem::loadGroup()" << std::endl; -#ifdef DEBUG_ITEM - std::cerr << "ChannelsCommentsItem::loadMessage()"; - std::cerr << std::endl; -#endif - if(mLoading) - return; - - mLoading= true; + mLoadingGroup = true; RsThread::async([this]() - { - // 1 - get group meta data + { + // 1 - get group data std::vector groups; const std::list groupIds = { groupId() }; if(!rsGxsChannels->getChannelsInfo(groupIds,groups)) // would be better to call channel Summaries for a single group { - RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl; + RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data for group " << groupId() << std::endl; + mLoadingGroup = false; + deferred_update(); return; } if (groups.size() != 1) { - std::cerr << "GxsGxsChannelGroupItem::loadGroup() Wrong number of Items" << std::endl; + std::cerr << "GxsGxsChannelGroupItem::loadGroup() Wrong number of Items for group " << groupId() ; + std::cerr << std::endl; + mLoadingGroup = false; + deferred_update(); return; } RsGxsChannelGroup group(groups[0]); - // 2 - get message and comment data + RsQThreadUtils::postToObject( [group,this]() + { + /* Here it goes any code you want to be executed on the Qt Gui + * thread, for example to update the data model with new information + * after a blocking call to RetroShare API complete */ + + mGroupMeta = group.mMeta; + mLoadingGroup = false; + + update(); // this triggers a paintEvent if needed. + + }, this ); + }); +} +void ChannelsCommentsItem::loadMessageData() +{ +#ifdef DEBUG_ITEM + std::cerr << "ChannelsCommentsItem::loadCommentData()"; + std::cerr << std::endl; +#endif + mLoadingMessage = true; + + RsThread::async([this]() + { + // 1 - get message and comment data + + std::vector posts; + std::vector comments; + std::vector votes; + + if(! rsGxsChannels->getChannelContent( groupId(), std::set( { mThreadId } ),posts,comments,votes)) + { + RsErr() << "GxsGxsChannelGroupItem::loadMessage() ERROR getting data" << std::endl; + mLoadingMessage = false; + deferred_update(); + return; + } + + // now that everything is in place, update the UI + + RsQThreadUtils::postToObject( [posts,this]() + { + /* Here it goes any code you want to be executed on the Qt Gui + * thread, for example to update the data model with new information + * after a blocking call to RetroShare API complete */ + + if(posts.size()!=1) // the original post cannot be found. Removing the comment item. + { + mLoadingMessage = false; + removeItem(); + return; + } + + mPost = posts[0]; + mLoadingMessage = false; + + update(); + + }, this ); + }); +} +void ChannelsCommentsItem::loadCommentData() +{ +#ifdef DEBUG_ITEM + std::cerr << "ChannelsCommentsItem::loadCommentData()"; + std::cerr << std::endl; +#endif + mLoadingComment = true; + + RsThread::async([this]() + { + // 1 - get message and comment data std::vector posts; std::vector comments; @@ -311,54 +304,30 @@ void ChannelsCommentsItem::load() if(! rsGxsChannels->getChannelContent( groupId(), std::set( { messageId(),mThreadId } ),posts,comments,votes)) { - RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl; - return; + RsErr() << "GxsGxsChannelGroupItem::loadComment() ERROR getting data" << std::endl; + mLoadingComment = false; + deferred_update(); + return; } + if(comments.size()!=1) + { + mLoadingComment = false; + deferred_update(); + return; + } - // now that everything is in place, update the UI + // now that everything is in place, update the UI - RsQThreadUtils::postToObject( [group,posts,comments,this]() + RsQThreadUtils::postToObject( [comments,this]() { /* Here it goes any code you want to be executed on the Qt Gui * thread, for example to update the data model with new information * after a blocking call to RetroShare API complete */ - mGroupMeta = group.mMeta; + mComment = comments[0]; + mLoadingComment = false; - if(comments.size()==1) - { - RsGxsComment cmt(comments[0]); - - uint32_t autorized_lines = (int)floor( (ui->avatarLabel->height() - ui->button_HL->sizeHint().height()) - / QFontMetricsF(ui->subjectLabel->font()).height()); - - ui->commLabel->setText(RsHtml().formatText(NULL, RsStringUtil::CopyLines(QString::fromUtf8(cmt.mComment.c_str()), autorized_lines), RSHTML_FORMATTEXT_EMBED_LINKS)); - ui->nameLabel->setId(cmt.mMeta.mAuthorId); - ui->datetimeLabel->setText(DateTime::formatLongDateTime(cmt.mMeta.mPublishTs)); - - RsIdentityDetails idDetails ; - rsIdentity->getIdDetails(cmt.mMeta.mAuthorId,idDetails); - QPixmap pixmap ; - - if(idDetails.mAvatar.mSize == 0 || !GxsIdDetails::loadPixmapFromData(idDetails.mAvatar.mData, idDetails.mAvatar.mSize, pixmap,GxsIdDetails::SMALL)) - pixmap = GxsIdDetails::makeDefaultIcon(cmt.mMeta.mAuthorId,GxsIdDetails::LARGE); - ui->avatarLabel->setPixmap(pixmap); - - //Change this item to be uploaded with thread element. This is really bad practice. - } - else - { - mLoading=false; - removeItem(); - } - - if (posts.size() == 1) - setPost(posts[0]); - else - setMissingPost(); - - emit sizeChanged(this); - mLoading=false; + update(); }, this ); }); @@ -367,87 +336,68 @@ void ChannelsCommentsItem::load() void ChannelsCommentsItem::fill(bool missing_post) { #ifdef DEBUG_ITEM - std::cerr << "ChannelsCommentsItem::fill()"; - std::cerr << std::endl; + std::cerr << "ChannelsCommentsItem::fill()"; + std::cerr << std::endl; #endif - mInFill = true; - if (!mIsHome) - { - if (mCloseOnRead && !IS_MSG_NEW(mPost.mMeta.mMsgStatus)) { - removeItem(); - } + if (mCloseOnRead && !IS_MSG_NEW(mComment.mMeta.mMsgStatus)) { + removeItem(); + } - //RetroShareLink link = RetroShareLink::createGxsGroupLink(RetroShareLink::TYPE_CHANNEL, mPost.mMeta.mGroupId, groupName()); - //title += link.toHtml(); - //ui->titleLabel->setText(title); + RetroShareLink grplink = RetroShareLink::createGxsGroupLink(RetroShareLink::TYPE_CHANNEL, mGroupMeta.mGroupId, groupName()); + RetroShareLink msgLink = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_CHANNEL, mPost.mMeta.mGroupId, mPost.mMeta.mMsgId, messageName()); - RetroShareLink msgLink = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_CHANNEL, mPost.mMeta.mGroupId, mPost.mMeta.mMsgId, messageName()); + if(missing_post) + ui->subjectLabel->setText("[" + QObject::tr("Missing channel post")+"]"); + else + ui->subjectLabel->setText(msgLink.toHtml()); - if(missing_post) - ui->subjectLabel->setText("[" + QObject::tr("Missing channel post")+"]"); - else - ui->subjectLabel->setText(msgLink.toHtml()); + ui->readButton->hide(); - ui->readButton->hide(); + if (IS_MSG_NEW(mComment.mMeta.mMsgStatus)) { + mCloseOnRead = true; + } - if (IS_MSG_NEW(mPost.mMeta.mMsgStatus)) { - mCloseOnRead = true; - } - } - else - { - if(missing_post) - ui->subjectLabel->setText("[" + QObject::tr("Missing channel post")+"]"); - else - ui->subjectLabel->setText(RsStringUtil::CopyLines(QString::fromUtf8(mPost.mMsg.c_str()), 2)) ; + ui->newCommentLabel->setText(groupName()+": "); - /* disable buttons: deletion facility not enabled with cache services yet */ - ui->clearButton->setEnabled(false); - ui->clearButton->hide(); - ui->readAndClearButton->hide(); - ui->copyLinkButton->show(); - //ui->titleLabel->hide(); + uint32_t autorized_lines = (int)floor( (ui->avatarLabel->height() - ui->button_HL->sizeHint().height()) + / QFontMetricsF(ui->subjectLabel->font()).height()); - if (IS_GROUP_SUBSCRIBED(mGroupMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroupMeta.mSubscribeFlags)) - { - ui->readButton->setVisible(true); + ui->commLabel->setText(RsHtml().formatText(NULL, RsStringUtil::CopyLines(QString::fromUtf8(mComment.mComment.c_str()), autorized_lines), RSHTML_FORMATTEXT_EMBED_LINKS)); + ui->nameLabel->setId(mComment.mMeta.mAuthorId); + ui->datetimeLabel->setText(DateTime::formatLongDateTime(mComment.mMeta.mPublishTs)); - setReadStatus(IS_MSG_NEW(mPost.mMeta.mMsgStatus), IS_MSG_UNREAD(mPost.mMeta.mMsgStatus) || IS_MSG_NEW(mPost.mMeta.mMsgStatus)); - } - else - { - ui->readButton->setVisible(false); - } + RsIdentityDetails idDetails ; + rsIdentity->getIdDetails(mComment.mMeta.mAuthorId,idDetails); + QPixmap pixmap ; - mCloseOnRead = false; - } - - mInFill = false; + if(idDetails.mAvatar.mSize == 0 || !GxsIdDetails::loadPixmapFromData(idDetails.mAvatar.mData, idDetails.mAvatar.mSize, pixmap,GxsIdDetails::SMALL)) + pixmap = GxsIdDetails::makeDefaultIcon(mComment.mMeta.mAuthorId,GxsIdDetails::LARGE); + ui->avatarLabel->setPixmap(pixmap); } QString ChannelsCommentsItem::messageName() { - return QString::fromUtf8(mPost.mMeta.mMsgName.c_str()); + return QString::fromUtf8(mPost.mMeta.mMsgName.c_str()); } void ChannelsCommentsItem::setReadStatus(bool isNew, bool isUnread) { if (isNew) - mPost.mMeta.mMsgStatus |= GXS_SERV::GXS_MSG_STATUS_GUI_NEW; + mComment.mMeta.mMsgStatus |= GXS_SERV::GXS_MSG_STATUS_GUI_NEW; else - mPost.mMeta.mMsgStatus &= ~GXS_SERV::GXS_MSG_STATUS_GUI_NEW; + mComment.mMeta.mMsgStatus &= ~GXS_SERV::GXS_MSG_STATUS_GUI_NEW; if (isUnread) { - mPost.mMeta.mMsgStatus |= GXS_SERV::GXS_MSG_STATUS_GUI_UNREAD; + mComment.mMeta.mMsgStatus |= GXS_SERV::GXS_MSG_STATUS_GUI_UNREAD; whileBlocking(ui->readButton)->setChecked(true); ui->readButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/message-state-unread.png")); } else { - mPost.mMeta.mMsgStatus &= ~GXS_SERV::GXS_MSG_STATUS_GUI_UNREAD; + mComment.mMeta.mMsgStatus &= ~GXS_SERV::GXS_MSG_STATUS_GUI_UNREAD; whileBlocking(ui->readButton)->setChecked(false); ui->readButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/message-state-read.png")); } @@ -521,24 +471,18 @@ void ChannelsCommentsItem::unsubscribeChannel() void ChannelsCommentsItem::readToggled(bool /*checked*/) { - if (mInFill) { - return; - } - mCloseOnRead = false; RsGxsGrpMsgIdPair msgPair = std::make_pair(groupId(), messageId()); rsGxsChannels->setCommentReadStatus(msgPair, isUnread()); - - //setReadStatus(false, checked); // Updated by events } void ChannelsCommentsItem::makeDownVote() { RsGxsGrpMsgIdPair msgId; - msgId.first = mPost.mMeta.mGroupId; - msgId.second = mPost.mMeta.mMsgId; + msgId.first = mComment.mMeta.mGroupId; + msgId.second = mComment.mMeta.mMsgId; ui->voteUpButton->setEnabled(false); ui->voteDownButton->setEnabled(false); @@ -549,8 +493,8 @@ void ChannelsCommentsItem::makeDownVote() void ChannelsCommentsItem::makeUpVote() { RsGxsGrpMsgIdPair msgId; - msgId.first = mPost.mMeta.mGroupId; - msgId.second = mPost.mMeta.mMsgId; + msgId.first = mComment.mMeta.mGroupId; + msgId.second = mComment.mMeta.mMsgId; ui->voteUpButton->setEnabled(false); ui->voteDownButton->setEnabled(false); diff --git a/retroshare-gui/src/gui/feeds/ChannelsCommentsItem.h b/retroshare-gui/src/gui/feeds/ChannelsCommentsItem.h index c245cbca7..87192c7d0 100644 --- a/retroshare-gui/src/gui/feeds/ChannelsCommentsItem.h +++ b/retroshare-gui/src/gui/feeds/ChannelsCommentsItem.h @@ -24,7 +24,7 @@ #include #include -#include "gui/gxs/GxsFeedItem.h" +#include "gui/feeds/GxsFeedItem.h" namespace Ui { class ChannelsCommentsItem; @@ -50,34 +50,20 @@ public: bool isHome, bool autoUpdate); - // This one is used in channel thread widget. We don't want the group data to reload at every post, so we load it in the hosting - // GxsChannelsPostsWidget and pass it to created items. - // ChannelsCommentsItem(FeedHolder *feedHolder, uint32_t feedId, const RsGroupMetaData& group, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate, const std::set& older_versions = std::set()); - virtual ~ChannelsCommentsItem(); uint64_t uniqueIdentifier() const override { return hash_64bits("ChannelsCommentsItem " + messageId().toStdString()) ; } - bool setGroup(const RsGxsChannelGroup& group, bool doFill = true); - bool setPost(const RsGxsChannelPost& post, bool doFill = true); - bool setMissingPost(); +protected: - QString getTitleLabel(); - QString getMsgLabel(); - - bool isLoaded() const {return mLoaded;}; bool isUnread() const ; void setReadStatus(bool isNew, bool isUnread); - const std::set& olderVersions() const { return mPost.mOlderVersions; } - static uint64_t computeIdentifier(const RsGxsMessageId& msgid) { return hash64("ChannelsCommentsItem " + msgid.toStdString()) ; } -protected: - //void init(const RsGxsMessageId& messageId,const std::set& older_versions); /* FeedItem */ - virtual void doExpand(bool open); - virtual void expandFill(bool first); + virtual void doExpand(bool open) override; + virtual void expandFill(bool first) override; // This does nothing except triggering the loading of the post data and comments. This function is mainly used to detect // when the post is actually made visible. @@ -85,12 +71,12 @@ protected: virtual void paintEvent(QPaintEvent *) override; /* GxsGroupFeedItem */ - virtual QString groupName(); - virtual void loadGroup() override; - virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_CHANNEL; } + virtual QString groupName() override; + virtual void loadGroup() override {} + virtual RetroShareLink::enumType getLinkType() override { return RetroShareLink::TYPE_CHANNEL; } /* GxsFeedItem */ - virtual QString messageName(); + virtual QString messageName() override; virtual void loadMessage() override {} virtual void loadComment() override {} @@ -110,19 +96,23 @@ signals: void vote(const RsGxsGrpMsgIdPair& msgId, bool up); private: - void load(); void setup(); void fill(bool missing_post=false); + void loadGroupData(); + void loadMessageData(); + void loadCommentData(); -private: - bool mInFill; bool mCloseOnRead; - bool mLoaded; - bool mLoading; + LoadingStatus mLoadingStatus; + + bool mLoadingComment; + bool mLoadingGroup; + bool mLoadingMessage; RsGroupMetaData mGroupMeta; - RsGxsChannelPost mPost; + RsGxsComment mComment; + RsGxsChannelPost mPost; RsGxsMessageId mThreadId; /** Qt Designer generated object */ diff --git a/retroshare-gui/src/gui/feeds/ChannelsCommentsItem.ui b/retroshare-gui/src/gui/feeds/ChannelsCommentsItem.ui index db4ac6b1a..c5643f7de 100644 --- a/retroshare-gui/src/gui/feeds/ChannelsCommentsItem.ui +++ b/retroshare-gui/src/gui/feeds/ChannelsCommentsItem.ui @@ -50,202 +50,6 @@ 3 - - - - 8 - - - - - - - I like this - - - - - - - - - - - 75 - true - - - - 0 - - - - - - - I dislike this - - - - - - - - - - - - - 24 - 16777215 - - - - Qt::NoFocus - - - Toggle Message Read Status - - - true - - - false - - - false - - - - - - - Avatar - - - - - - - - 0 - 0 - - - - - 12 - 75 - true - - - - New Comment - - - true - - - - - - - - 12 - 75 - true - - - - POST TITLE - - - true - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - Qt::NoFocus - - - Copy RetroShare Link - - - - - - - - - - - 0 - 0 - - - - Qt::NoFocus - - - Expand - - - - - - - - 0 - 0 - - - - Qt::NoFocus - - - Set as read and remove item - - - - - - - - 0 - 0 - - - - Qt::NoFocus - - - Remove Item - - - - - @@ -257,79 +61,91 @@ - - - 3 - - - 0 - - - 9 - - - 0 - - - 3 - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 288 - 17 - - - + + + + + + + + 0 + 0 + + + + + 12 + 75 + true + + + + New Comment from + + + true + + + + + + + + 0 + 0 + + + + + 11 + 75 + true + true + + + + Name + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 288 + 17 + + + + + + + + + 75 + true + + + + DateTime + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + - - - - - 75 - true - - - - DateTime - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - 0 - 0 - - - - - 11 - 75 - true - true - - - - Name - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - + @@ -360,6 +176,202 @@ + + + + 8 + + + + + + + I like this + + + + + + + + + + + 75 + true + + + + 0 + + + + + + + I dislike this + + + + + + + + + + + + + 24 + 16777215 + + + + Qt::NoFocus + + + Toggle Message Read Status + + + true + + + false + + + false + + + + + + + Avatar + + + + + + + + 0 + 0 + + + + + 12 + 75 + true + + + + New Comment + + + true + + + + + + + + 12 + 75 + true + + + + POST TITLE + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + Qt::NoFocus + + + Copy RetroShare Link + + + + + + + + + + + 0 + 0 + + + + Qt::NoFocus + + + Expand + + + + + + + + 0 + 0 + + + + Qt::NoFocus + + + Set as read and remove item + + + + + + + + 0 + 0 + + + + Qt::NoFocus + + + Remove Item + + + + + diff --git a/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp b/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp index 573c65c9d..07d2f696d 100644 --- a/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp @@ -30,7 +30,6 @@ #include "gui/common/AvatarDefs.h" #include "gui/settings/rsharesettings.h" -#include "gui/notifyqt.h" #include #include diff --git a/retroshare-gui/src/gui/feeds/FeedItem.cpp b/retroshare-gui/src/gui/feeds/FeedItem.cpp index e9991e6d0..df8c82c5d 100644 --- a/retroshare-gui/src/gui/feeds/FeedItem.cpp +++ b/retroshare-gui/src/gui/feeds/FeedItem.cpp @@ -22,6 +22,11 @@ #include "FeedItem.h" #include "FeedHolder.h" +// Height of feed items as a factor of font size height. + +const int FeedItem::ITEM_HEIGHT_FACTOR = 8; +const float FeedItem::ITEM_PICTURE_FORMAT_RATIO = 16.0/9.0; + /** Constructor */ FeedItem::FeedItem(FeedHolder *fh, uint32_t feedId, QWidget *parent) : QWidget(parent),mFeedHolder(fh),mFeedId(feedId),mHash(0) { @@ -48,7 +53,7 @@ uint64_t FeedItem::hash_64bits(const std::string& s) const if(mHash == 0) mHash = hash64(s); - return mHash; + return mHash; } uint64_t FeedItem::hash64(const std::string& s) diff --git a/retroshare-gui/src/gui/feeds/FeedItem.h b/retroshare-gui/src/gui/feeds/FeedItem.h index 7739ac122..f11424520 100644 --- a/retroshare-gui/src/gui/feeds/FeedItem.h +++ b/retroshare-gui/src/gui/feeds/FeedItem.h @@ -21,10 +21,70 @@ #ifndef _FEED_ITEM_H #define _FEED_ITEM_H +#include #include class FeedHolder; +enum class RsFeedTypeFlags: uint32_t { + RS_FEED_TYPE_NONE = 0x0000, + RS_FEED_TYPE_PEER = 0x0010, + RS_FEED_TYPE_CHANNEL = 0x0020, + RS_FEED_TYPE_FORUM = 0x0040, + RS_FEED_TYPE_CHAT = 0x0100, + RS_FEED_TYPE_MSG = 0x0200, + RS_FEED_TYPE_FILES = 0x0400, + RS_FEED_TYPE_SECURITY = 0x0800, + RS_FEED_TYPE_POSTED = 0x1000, + RS_FEED_TYPE_SECURITY_IP = 0x2000, + RS_FEED_TYPE_CIRCLE = 0x4000, + + RS_FEED_ITEM_PEER_CONNECT = RS_FEED_TYPE_PEER | 0x0001, + RS_FEED_ITEM_PEER_DISCONNECT = RS_FEED_TYPE_PEER | 0x0002, + RS_FEED_ITEM_PEER_HELLO = RS_FEED_TYPE_PEER | 0x0003, + RS_FEED_ITEM_PEER_NEW = RS_FEED_TYPE_PEER | 0x0004, + RS_FEED_ITEM_PEER_OFFSET = RS_FEED_TYPE_PEER | 0x0005, + RS_FEED_ITEM_PEER_DENIES_CONNEXION = RS_FEED_TYPE_PEER | 0x0006, + + RS_FEED_ITEM_SEC_CONNECT_ATTEMPT = RS_FEED_TYPE_SECURITY | 0x0001, + RS_FEED_ITEM_SEC_AUTH_DENIED = RS_FEED_TYPE_SECURITY | 0x0002, // locally denied connection + RS_FEED_ITEM_SEC_UNKNOWN_IN = RS_FEED_TYPE_SECURITY | 0x0003, + RS_FEED_ITEM_SEC_UNKNOWN_OUT = RS_FEED_TYPE_SECURITY | 0x0004, + RS_FEED_ITEM_SEC_WRONG_SIGNATURE = RS_FEED_TYPE_SECURITY | 0x0005, + RS_FEED_ITEM_SEC_BAD_CERTIFICATE = RS_FEED_TYPE_SECURITY | 0x0006, + RS_FEED_ITEM_SEC_INTERNAL_ERROR = RS_FEED_TYPE_SECURITY | 0x0007, + RS_FEED_ITEM_SEC_MISSING_CERTIFICATE = RS_FEED_TYPE_SECURITY | 0x0008, + + RS_FEED_ITEM_SEC_IP_BLACKLISTED = RS_FEED_TYPE_SECURITY_IP | 0x0001, + RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED = RS_FEED_TYPE_SECURITY_IP | 0x0002, + + RS_FEED_ITEM_CHANNEL_NEW = RS_FEED_TYPE_CHANNEL | 0x0002, + RS_FEED_ITEM_CHANNEL_MSG = RS_FEED_TYPE_CHANNEL | 0x0003, + RS_FEED_ITEM_CHANNEL_PUBLISHKEY = RS_FEED_TYPE_CHANNEL| 0x0004, + + RS_FEED_ITEM_FORUM_NEW = RS_FEED_TYPE_FORUM | 0x0001, + RS_FEED_ITEM_FORUM_MSG = RS_FEED_TYPE_FORUM | 0x0003, + RS_FEED_ITEM_FORUM_PUBLISHKEY = RS_FEED_TYPE_FORUM | 0x0004, + + RS_FEED_ITEM_POSTED_NEW = RS_FEED_TYPE_POSTED | 0x0001, + RS_FEED_ITEM_POSTED_MSG = RS_FEED_TYPE_POSTED | 0x0003, + + RS_FEED_ITEM_CHAT_NEW = RS_FEED_TYPE_CHAT | 0x0001, + RS_FEED_ITEM_MESSAGE = RS_FEED_TYPE_MSG | 0x0001, + RS_FEED_ITEM_FILES_NEW = RS_FEED_TYPE_FILES | 0x0001, + + RS_FEED_ITEM_CIRCLE_MEMB_REQ = RS_FEED_TYPE_CIRCLE | 0x0001, + RS_FEED_ITEM_CIRCLE_INVITE_REC = RS_FEED_TYPE_CIRCLE | 0x0002, + RS_FEED_ITEM_CIRCLE_MEMB_LEAVE = RS_FEED_TYPE_CIRCLE | 0x0003, + RS_FEED_ITEM_CIRCLE_MEMB_JOIN = RS_FEED_TYPE_CIRCLE | 0x0004, + RS_FEED_ITEM_CIRCLE_MEMB_ACCEPTED = RS_FEED_TYPE_CIRCLE | 0x0005, + RS_FEED_ITEM_CIRCLE_MEMB_REVOKED = RS_FEED_TYPE_CIRCLE | 0x0006, + RS_FEED_ITEM_CIRCLE_INVITE_CANCELLED= RS_FEED_TYPE_CIRCLE | 0x0007, +}; + + +RS_REGISTER_ENUM_FLAGS_TYPE(RsFeedTypeFlags); + class FeedItem : public QWidget { Q_OBJECT @@ -60,6 +120,9 @@ protected: FeedHolder *mFeedHolder; uint32_t mFeedId; + static const int ITEM_HEIGHT_FACTOR ; + static const float ITEM_PICTURE_FORMAT_RATIO ; + signals: void sizeChanged(FeedItem *feedItem); void feedItemNeedsClosing(qulonglong); diff --git a/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.cpp b/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.cpp index a6213e740..0adafe8e9 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.cpp @@ -36,16 +36,11 @@ GxsChannelGroupItem::GxsChannelGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, bool isHome, bool autoUpdate) : GxsGroupFeedItem(feedHolder, feedId, groupId, isHome, rsGxsChannels, autoUpdate) { - setup(); - requestGroup(); - addEventHandler(); -} + mLoadingGroup = false; + mLoadingStatus = LOADING_STATUS_NO_DATA; -GxsChannelGroupItem::GxsChannelGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelGroup &group, bool isHome, bool autoUpdate) : - GxsGroupFeedItem(feedHolder, feedId, group.mMeta.mGroupId, isHome, rsGxsChannels, autoUpdate) -{ setup(); - setGroup(group); + requestGroup(); addEventHandler(); } @@ -66,7 +61,8 @@ void GxsChannelGroupItem::addEventHandler() case RsChannelEventCode::SUBSCRIBE_STATUS_CHANGED: case RsChannelEventCode::UPDATED_CHANNEL: case RsChannelEventCode::RECEIVED_PUBLISH_KEY: - loadGroup(); + mLoadingStatus = LOADING_STATUS_NO_DATA; + mGroup = RsGxsChannelGroup(); break; default: break; @@ -75,8 +71,42 @@ void GxsChannelGroupItem::addEventHandler() }, mEventHandlerId, RsEventType::GXS_CHANNELS ); } +void GxsChannelGroupItem::paintEvent(QPaintEvent *e) +{ + /* This method employs a trick to trigger a deferred loading. The post and group is requested only + * when actually displayed on the screen. */ + + if(mLoadingStatus != LOADING_STATUS_FILLED && !mGroup.mMeta.mGroupId.isNull()) + mLoadingStatus = LOADING_STATUS_HAS_DATA; + + if(mGroup.mMeta.mGroupId.isNull() && !mLoadingGroup) + loadGroup(); + + switch(mLoadingStatus) + { + case LOADING_STATUS_FILLED: + case LOADING_STATUS_NO_DATA: + default: + break; + + case LOADING_STATUS_HAS_DATA: + fill(); + mLoadingStatus = LOADING_STATUS_FILLED; + break; + } + + GxsGroupFeedItem::paintEvent(e) ; +} GxsChannelGroupItem::~GxsChannelGroupItem() { + auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(GROUP_ITEM_LOADING_TIMEOUT_ms); + + while( mLoadingGroup && std::chrono::steady_clock::now() < timeout ) + { + RsDbg() << __PRETTY_FUNCTION__ << " is Waiting for data to load " << std::endl; + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } + rsEvents->unregisterEventsHandler(mEventHandlerId); delete(ui); } @@ -105,22 +135,10 @@ void GxsChannelGroupItem::setup() ui->expandFrame->hide(); } -bool GxsChannelGroupItem::setGroup(const RsGxsChannelGroup &group) -{ - if (groupId() != group.mMeta.mGroupId) { - std::cerr << "GxsChannelGroupItem::setContent() - Wrong id, cannot set post"; - std::cerr << std::endl; - return false; - } - - mGroup = group; - fill(); - - return true; -} - void GxsChannelGroupItem::loadGroup() { + mLoadingGroup = true; + RsThread::async([this]() { // 1 - get group data @@ -131,14 +149,18 @@ void GxsChannelGroupItem::loadGroup() if(!rsGxsChannels->getChannelsInfo(groupIds,groups)) { RsErr() << "PostedItem::loadGroup() ERROR getting data" << std::endl; - return; + mLoadingGroup = false; + deferred_update(); + return; } if (groups.size() != 1) { std::cerr << "GxsGxsChannelGroupItem::loadGroup() Wrong number of Items"; std::cerr << std::endl; - return; + deferred_update(); + mLoadingGroup = false; + return; } RsGxsChannelGroup group(groups[0]); @@ -148,7 +170,8 @@ void GxsChannelGroupItem::loadGroup() * thread, for example to update the data model with new information * after a blocking call to RetroShare API complete */ - setGroup(group); + mGroup = group; + mLoadingGroup = false; }, this ); }); @@ -171,11 +194,16 @@ void GxsChannelGroupItem::fill() RetroShareLink link = RetroShareLink::createGxsGroupLink(RetroShareLink::TYPE_CHANNEL, mGroup.mMeta.mGroupId, groupName()); ui->nameLabel->setText(link.toHtml()); - ui->descLabel->setText(QString::fromUtf8(mGroup.mDescription.c_str())); + ui->logoLabel->setEnableZoom(false); + int desired_height = QFontMetricsF(font()).height() * ITEM_HEIGHT_FACTOR; + ui->logoLabel->setFixedSize(ITEM_PICTURE_FORMAT_RATIO*desired_height,desired_height); + + ui->descLabel->setText(QString::fromUtf8(mGroup.mDescription.c_str())); if (mGroup.mImage.mData != NULL) { QPixmap chanImage; GxsIdDetails::loadPixmapFromData(mGroup.mImage.mData, mGroup.mImage.mSize, chanImage,GxsIdDetails::ORIGINAL); + ui->logoLabel->setPixmap(chanImage); } diff --git a/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.h b/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.h index b0366bc98..ab9aaf088 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.h +++ b/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.h @@ -22,7 +22,7 @@ #define _GXSCHANNELGROUPITEM_H #include -#include "gui/gxs/GxsGroupFeedItem.h" +#include "gui/feeds/GxsGroupFeedItem.h" namespace Ui { class GxsChannelGroupItem; @@ -37,19 +37,22 @@ class GxsChannelGroupItem : public GxsGroupFeedItem public: /** Default Constructor */ GxsChannelGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, bool isHome, bool autoUpdate); - GxsChannelGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelGroup &group, bool isHome, bool autoUpdate); - ~GxsChannelGroupItem(); + //GxsChannelGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelGroup &group, bool isHome, bool autoUpdate); + virtual ~GxsChannelGroupItem(); - bool setGroup(const RsGxsChannelGroup &group); uint64_t uniqueIdentifier() const override { return hash_64bits("GxsChannelGroupItem " + groupId().toStdString()) ; } -protected: - /* FeedItem */ - virtual void doExpand(bool open); - /* GxsGroupFeedItem */ - virtual QString groupName(); +protected: + + /* FeedItem */ + virtual void doExpand(bool open) override; + + virtual void paintEvent(QPaintEvent *) override; + + /* GxsGroupFeedItem */ + virtual QString groupName() override; virtual void loadGroup() override; - virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_CHANNEL; } + virtual RetroShareLink::enumType getLinkType() override { return RetroShareLink::TYPE_CHANNEL; } private slots: /* default stuff */ @@ -62,6 +65,9 @@ private: void setup(); void addEventHandler(); + LoadingStatus mLoadingStatus; + bool mLoadingGroup; + private: RsGxsChannelGroup mGroup; diff --git a/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.ui b/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.ui index 43537d061..d828571b0 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.ui +++ b/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.ui @@ -143,7 +143,7 @@ - + 70 @@ -391,6 +391,13 @@ + + + ZoomableLabel + QLabel +
gui/gxschannels/GxsChannelPostThumbnail.h
+
+
diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp index 17036a15e..9d6a9992f 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp @@ -45,37 +45,9 @@ * #define DEBUG_ITEM 1 ****/ -GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGroupMetaData& group_meta, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate,const std::set& older_versions) : - GxsFeedItem(feedHolder, feedId, group_meta.mGroupId, messageId, isHome, rsGxsChannels, autoUpdate), - mGroupMeta(group_meta) -{ - mLoadingGroup = false; - mLoadingMessage = false; - mLoadingComment = false; - - mPost.mMeta.mMsgId = messageId; // useful for uniqueIdentifer() before the post is loaded - mPost.mMeta.mGroupId = mGroupMeta.mGroupId; - - QVector v; - //bool self = false; - - for(std::set::const_iterator it(older_versions.begin());it!=older_versions.end();++it) - v.push_back(*it) ; - - if(older_versions.find(messageId) == older_versions.end()) - v.push_back(messageId); - - setMessageVersions(v) ; - setup(); - - // no call to loadGroup() here because we have it already. -} - GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId& groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate,const std::set& older_versions) : GxsFeedItem(feedHolder, feedId, groupId, messageId, isHome, rsGxsChannels, autoUpdate) // this one should be in GxsFeedItem { - mPost.mMeta.mMsgId = messageId; // useful for uniqueIdentifer() before the post is loaded - QVector v; //bool self = false; @@ -85,70 +57,54 @@ GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, if(older_versions.find(messageId) == older_versions.end()) v.push_back(messageId); - setMessageVersions(v) ; + mLoadingStatus = LOADING_STATUS_NO_DATA; + mLoadingMessage = false; + mLoadingGroup = false; + + setMessageVersions(v) ; setup(); - - loadGroup(); } -// GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelPost& post, bool isHome, bool autoUpdate,const std::set& older_versions) : -// GxsFeedItem(feedHolder, feedId, post.mMeta.mGroupId, post.mMeta.mMsgId, isHome, rsGxsChannels, autoUpdate) -// { -// mPost.mMeta.mMsgId.clear(); // security -// init(post.mMeta.mMsgId,older_versions) ; -// mPost = post ; -// } - -// void GxsChannelPostItem::init(const RsGxsMessageId& messageId,const std::set& older_versions) -// { -// QVector v; -// //bool self = false; -// -// for(std::set::const_iterator it(older_versions.begin());it!=older_versions.end();++it) -// v.push_back(*it) ; -// -// if(older_versions.find(messageId) == older_versions.end()) -// v.push_back(messageId); -// -// setMessageVersions(v) ; -// -// setup(); -// -// mLoaded = false ; -// } - void GxsChannelPostItem::paintEvent(QPaintEvent *e) { /* This method employs a trick to trigger a deferred loading. The post and group is requested only * when actually displayed on the screen. */ - if(!mLoaded) - { - mLoaded = true ; + if(mLoadingStatus != LOADING_STATUS_FILLED && !mGroupMeta.mGroupId.isNull() && !mPost.mMeta.mMsgId.isNull() ) + mLoadingStatus = LOADING_STATUS_HAS_DATA; - std::set older_versions; // not so nice. We need to use std::set everywhere - for(auto& m:messageVersions()) - older_versions.insert(m); + if(mGroupMeta.mGroupId.isNull() && !mLoadingGroup) + requestGroup(); - fill(); - requestMessage(); - requestComment(); - } + if(mPost.mMeta.mMsgId.isNull() && !mLoadingMessage) + requestMessage(); + + switch(mLoadingStatus) + { + case LOADING_STATUS_FILLED: + case LOADING_STATUS_NO_DATA: + default: + break; + + case LOADING_STATUS_HAS_DATA: + fill(); + mLoadingStatus = LOADING_STATUS_FILLED; + break; + } GxsFeedItem::paintEvent(e) ; } GxsChannelPostItem::~GxsChannelPostItem() { - auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(300); + auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(GROUP_ITEM_LOADING_TIMEOUT_ms); - while( (mLoadingGroup || mLoadingMessage || mLoadingComment) + while( (mLoadingGroup || mLoadingMessage) && std::chrono::steady_clock::now() < timeout) { RsDbg() << __PRETTY_FUNCTION__ << " is Waiting for " << (mLoadingGroup ? "Group " : "") << (mLoadingMessage ? "Message " : "") - << (mLoadingComment ? "Comment " : "") << "loading." << std::endl; std::this_thread::sleep_for(std::chrono::milliseconds(100)); } @@ -188,9 +144,7 @@ void GxsChannelPostItem::setup() setAttribute(Qt::WA_DeleteOnClose, true); - mInFill = false; mCloseOnRead = false; - mLoaded = false; /* clear ui */ ui->titleLabel->setText(tr("Loading...")); @@ -210,7 +164,7 @@ void GxsChannelPostItem::setup() connect(ui->downloadButton, SIGNAL(clicked()), this, SLOT(download())); // HACK FOR NOW. ui->commentButton->hide();// hidden until properly enabled. - connect(ui->commentButton, SIGNAL(clicked()), this, SLOT(loadComments())); +// connect(ui->commentButton, SIGNAL(clicked()), this, SLOT(loadComments())); connect(ui->playButton, SIGNAL(clicked()), this, SLOT(play(void))); //connect(ui->editButton, SIGNAL(clicked()), this, SLOT(edit(void))); @@ -221,8 +175,6 @@ void GxsChannelPostItem::setup() // hide voting buttons, backend is not implemented yet ui->voteUpButton->hide(); ui->voteDownButton->hide(); - //connect(ui-> voteUpButton, SIGNAL(clicked()), this, SLOT(makeUpVote())); - //connect(ui->voteDownButton, SIGNAL(clicked()), this, SLOT(makeDownVote())); ui->scoreLabel->hide(); @@ -245,55 +197,15 @@ void GxsChannelPostItem::setup() ui->expandFrame->hide(); } - -bool GxsChannelPostItem::setPost(const RsGxsChannelPost &post, bool doFill) -{ - if (groupId() != post.mMeta.mGroupId || messageId() != post.mMeta.mMsgId) { - std::cerr << "GxsChannelPostItem::setPost() - Wrong id, cannot set post"; - std::cerr << std::endl; - return false; - } - - mPost = post; - - if (doFill) { - fill(); - } - - updateItem(); - - return true; -} - -QString GxsChannelPostItem::getTitleLabel() -{ - return QString::fromUtf8(mPost.mMeta.mMsgName.c_str()); -} - -QString GxsChannelPostItem::getMsgLabel() -{ - //return RsHtml().formatText(NULL, QString::fromUtf8(mPost.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS); - // Disabled, because emoticon replacement kills performance. - return QString::fromUtf8(mPost.mMsg.c_str()); -} - QString GxsChannelPostItem::groupName() { return QString::fromUtf8(mGroupMeta.mGroupName.c_str()); } -void GxsChannelPostItem::loadComments() -{ - QString title = QString::fromUtf8(mPost.mMeta.mMsgName.c_str()); - comments(title); -} - void GxsChannelPostItem::loadGroup() { -#ifdef DEBUG_ITEM - std::cerr << "GxsChannelGroupItem::loadGroup()"; - std::cerr << std::endl; -#endif + std::cerr << "GxsChannelGroupItem::loadGroup()" << std::endl; + mLoadingGroup = true; RsThread::async([this]() @@ -305,15 +217,19 @@ void GxsChannelPostItem::loadGroup() if(!rsGxsChannels->getChannelsInfo(groupIds,groups)) // would be better to call channel Summaries for a single group { - RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl; - return; + RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data for group " << groupId() << std::endl; + mLoadingGroup = false; + deferred_update(); + return; } if (groups.size() != 1) { - std::cerr << "GxsGxsChannelGroupItem::loadGroup() Wrong number of Items"; + std::cerr << "GxsGxsChannelGroupItem::loadGroup() Wrong number of Items for group " << groupId() ; std::cerr << std::endl; - return; + mLoadingGroup = false; + deferred_update(); + return; } RsGxsChannelGroup group(groups[0]); @@ -326,6 +242,8 @@ void GxsChannelPostItem::loadGroup() mGroupMeta = group.mMeta; mLoadingGroup = false; + update(); // this triggers a paintEvent if needed. + }, this ); }); } @@ -348,7 +266,9 @@ void GxsChannelPostItem::loadMessage() if(! rsGxsChannels->getChannelContent( groupId(), std::set( { messageId() } ),posts,comments,votes)) { RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl; - return; + mLoadingMessage = false; + deferred_update(); + return; } if (posts.size() == 1) @@ -360,30 +280,11 @@ void GxsChannelPostItem::loadMessage() RsQThreadUtils::postToObject( [post,this]() { - setPost(post); + mPost = post; mLoadingMessage = false; + update(); // this triggers a paintEvent if needed. + }, this ); - } - else if(comments.size() == 1) - { - const RsGxsComment& cmt = comments[0]; -#ifdef DEBUG_ITEM - std::cerr << (void*)this << ": Obtained comment, setting messageId to threadID = " << cmt.mMeta.mThreadId << std::endl; -#endif - - RsQThreadUtils::postToObject( [cmt,this]() - { - ui->newCommentLabel->show(); - ui->commLabel->show(); - ui->commLabel->setText(QString::fromUtf8(cmt.mComment.c_str())); - - //Change this item to be uploaded with thread element. - setMessageId(cmt.mMeta.mThreadId); - requestMessage(); - - mLoadingMessage = false; - }, this ); - } else { @@ -396,77 +297,26 @@ void GxsChannelPostItem::loadMessage() { removeItem(); mLoadingMessage = false; + update(); // this triggers a paintEvent if needed. }, this ); } }); } -void GxsChannelPostItem::loadComment() -{ -#ifdef DEBUG_ITEM - std::cerr << "GxsChannelPostItem::loadComment()"; - std::cerr << std::endl; -#endif - mLoadingComment = true; - - RsThread::async([this]() - { - // 1 - get group data - - std::set msgIds; - - for(auto MsgId: messageVersions()) - msgIds.insert(MsgId); - - std::vector posts; - std::vector comments; - - if(! rsGxsChannels->getChannelComments( groupId(),msgIds,comments)) - { - RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl; - return; - } - - int comNb = comments.size(); - - RsQThreadUtils::postToObject( [comNb,this]() - { - QString sComButText = tr("Comment"); - if (comNb == 1) - sComButText = sComButText.append("(1)"); - else if(comNb > 1) - sComButText = tr("Comments ").append("(%1)").arg(comNb); - - ui->commentButton->setText(sComButText); - mLoadingComment = false; - - }, this ); - }); -} - void GxsChannelPostItem::fill() { - /* fill in */ - -// if (isLoading()) { - // /* Wait for all requests */ - //return; -// } - #ifdef DEBUG_ITEM std::cerr << "GxsChannelPostItem::fill()"; std::cerr << std::endl; #endif - mInFill = true; - QString title; QString msgText; //float f = QFontMetricsF(font()).height()/14.0 ; ui->logoLabel->setEnableZoom(false); - int desired_height = QFontMetricsF(font()).height() * 8; - ui->logoLabel->setFixedSize(4/3.0*desired_height,desired_height); + int desired_height = QFontMetricsF(font()).height() * ITEM_HEIGHT_FACTOR; + ui->logoLabel->setFixedSize(ITEM_PICTURE_FORMAT_RATIO*desired_height,desired_height); if(mPost.mThumbnail.mData != NULL) { @@ -526,7 +376,7 @@ void GxsChannelPostItem::fill() ui->subjectLabel->setText(RsStringUtil::CopyLines(QString::fromUtf8(mPost.mMsg.c_str()), 2)) ; - //QString score = QString::number(post.mTopScore); + //QString score = QString::number(post.mTopScore); // scoreLabel->setText(score); /* disable buttons: deletion facility not enabled with cache services yet */ @@ -562,21 +412,6 @@ void GxsChannelPostItem::fill() ui->commentButton->hide(); } -// THIS CODE IS doesn't compile - disabling until fixed. -#if 0 - if (post.mComments) - { - QString commentText = QString::number(post.mComments); - commentText += " "; - commentText += tr("Comments"); - ui->commentButton->setText(commentText); - } - else - { - ui->commentButton->setText(tr("Comment")); - } -#endif - } else { @@ -642,8 +477,6 @@ void GxsChannelPostItem::fill() QLayout *layout = ui->expandFrame->layout(); layout->addWidget(fi); } - - mInFill = false; } void GxsChannelPostItem::fillExpandFrame() @@ -684,22 +517,6 @@ void GxsChannelPostItem::setReadStatus(bool isNew, bool isUnread) ui->feedFrame->style()->polish( ui->feedFrame); } -// void GxsChannelPostItem::setFileCleanUpWarning(uint32_t time_left) -// { -// int hours = (int)time_left/3600; -// int minutes = (time_left - hours*3600)%60; -// -// ui->warning_label->setText(tr("Warning! You have less than %1 hours and %2 minute before this file is deleted Consider saving it.").arg( -// QString::number(hours)).arg(QString::number(minutes))); -// -// QFont warnFont = ui->warning_label->font(); -// warnFont.setBold(true); -// ui->warning_label->setFont(warnFont); -// -// ui->warn_image_label->setVisible(true); -// ui->warning_label->setVisible(true); -// } - void GxsChannelPostItem::updateItem() { /* fill in */ @@ -874,10 +691,6 @@ void GxsChannelPostItem::play() void GxsChannelPostItem::readToggled(bool /*checked*/) { - if (mInFill) { - return; - } - mCloseOnRead = false; RsGxsGrpMsgIdPair msgPair = std::make_pair(groupId(), messageId()); @@ -887,28 +700,3 @@ void GxsChannelPostItem::readToggled(bool /*checked*/) //setReadStatus(false, checked); // Updated by events } -void GxsChannelPostItem::makeDownVote() -{ - RsGxsGrpMsgIdPair msgId; - msgId.first = mPost.mMeta.mGroupId; - msgId.second = mPost.mMeta.mMsgId; - - ui->voteUpButton->setEnabled(false); - ui->voteDownButton->setEnabled(false); - - emit vote(msgId, false); -} - -void GxsChannelPostItem::makeUpVote() -{ - RsGxsGrpMsgIdPair msgId; - msgId.first = mPost.mMeta.mGroupId; - msgId.second = mPost.mMeta.mMsgId; - - ui->voteUpButton->setEnabled(false); - ui->voteDownButton->setEnabled(false); - - emit vote(msgId, true); -} - - diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h index b3e7843c0..4c4503ec0 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h @@ -24,7 +24,7 @@ #include #include -#include "gui/gxs/GxsFeedItem.h" +#include "gui/feeds/GxsFeedItem.h" namespace Ui { class GxsChannelPostItem; @@ -44,37 +44,32 @@ public: GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId& groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate, const std::set& older_versions = std::set()); +#ifdef UNUSED // This one is used in channel thread widget. We don't want the group data to reload at every post, so we load it in the hosting // GxsChannelsPostsWidget and pass it to created items. GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGroupMetaData& group, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate, const std::set& older_versions = std::set()); +#endif virtual ~GxsChannelPostItem(); uint64_t uniqueIdentifier() const override { return hash_64bits("GxsChannelPostItem " + messageId().toStdString()) ; } - bool setGroup(const RsGxsChannelGroup& group, bool doFill = true); - bool setPost(const RsGxsChannelPost& post, bool doFill = true); - +protected: //void setFileCleanUpWarning(uint32_t time_left); - QString getTitleLabel(); - QString getMsgLabel(); const std::list &getFileItems() {return mFileItems; } - bool isLoaded() const {return mLoaded;}; bool isUnread() const ; void setReadStatus(bool isNew, bool isUnread); const std::set& olderVersions() const { return mPost.mOlderVersions; } static uint64_t computeIdentifier(const RsGxsMessageId& msgid) { return hash64("GxsChannelPostItem " + msgid.toStdString()) ; } -protected: - //void init(const RsGxsMessageId& messageId,const std::set& older_versions); /* FeedItem */ - virtual void doExpand(bool open); - virtual void expandFill(bool first); + virtual void doExpand(bool open) override; + virtual void expandFill(bool first) override; // This does nothing except triggering the loading of the post data and comments. This function is mainly used to detect // when the post is actually made visible. @@ -82,14 +77,14 @@ protected: virtual void paintEvent(QPaintEvent *) override; /* GxsGroupFeedItem */ - virtual QString groupName(); + virtual QString groupName() override; virtual void loadGroup() override; - virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_CHANNEL; } + virtual RetroShareLink::enumType getLinkType() override{ return RetroShareLink::TYPE_CHANNEL; } /* GxsFeedItem */ - virtual QString messageName(); - virtual void loadMessage(); - virtual void loadComment(); + virtual QString messageName() override; + virtual void loadMessage() override; + virtual void loadComment() override {} private slots: /* default stuff */ @@ -98,16 +93,12 @@ private slots: void download(); void play(); void edit(); - void loadComments(); void readToggled(bool checked); void unsubscribeChannel(); void updateItem(); - void makeUpVote(); - void makeDownVote(); - signals: void vote(const RsGxsGrpMsgIdPair& msgId, bool up); @@ -117,14 +108,12 @@ private: void fillExpandFrame(); private: - bool mInFill; bool mCloseOnRead; - bool mLoaded; + + LoadingStatus mLoadingStatus; bool mLoadingMessage; bool mLoadingGroup; - bool mLoadingComment; - RsGroupMetaData mGroupMeta; RsGxsChannelPost mPost; diff --git a/retroshare-gui/src/gui/feeds/GxsCircleItem.cpp b/retroshare-gui/src/gui/feeds/GxsCircleItem.cpp index aa7dfa705..99825a078 100644 --- a/retroshare-gui/src/gui/feeds/GxsCircleItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsCircleItem.cpp @@ -22,7 +22,6 @@ #include "ui_GxsCircleItem.h" #include "FeedHolder.h" -#include "gui/notifyqt.h" #include "gui/Circles/CreateCircleDialog.h" #include "gui/gxs/GxsIdDetails.h" #include "gui/common/FilesDefs.h" @@ -40,7 +39,7 @@ #define CIRCLESDIALOG_GROUPUPDATE 3 -GxsCircleItem::GxsCircleItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsCircleId &circleId, const RsGxsId &gxsId, const uint32_t type) +GxsCircleItem::GxsCircleItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsCircleId &circleId, const RsGxsId &gxsId, RsFeedTypeFlags type) :FeedItem(feedHolder,feedId,NULL), mType(type), mCircleId(circleId), mGxsId(gxsId) { setup(); @@ -92,7 +91,7 @@ void GxsCircleItem::setup() // from here we can figure out if we already have requested membership or not - if (mType == RS_FEED_ITEM_CIRCLE_MEMB_REQ) + if (mType == RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_MEMB_REQ) { ui->titleLabel->setText(tr("You received a membership request a circle you're administrating:")); ui->iconLabel->setPixmap(pixmap); @@ -105,7 +104,7 @@ void GxsCircleItem::setup() ui->membershipButton->setHidden(true); } - else if (mType == RS_FEED_ITEM_CIRCLE_INVITE_REC) + else if (mType == RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_INVITE_REC) { ui->titleLabel->setText(tr("You received an invitation to join this circle:")); ui->iconLabel->setPixmap(pixmap); @@ -118,7 +117,7 @@ void GxsCircleItem::setup() connect(ui->membershipButton, SIGNAL(clicked()), this, SLOT(requestCircleSubscription())); ui->inviteeButton->setHidden(true); } - else if (mType == RS_FEED_ITEM_CIRCLE_MEMB_LEAVE) + else if (mType == RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_MEMB_LEAVE) { ui->titleLabel->setText(idName + tr(" has left this circle.")); ui->iconLabel->setPixmap(pixmap); @@ -127,7 +126,7 @@ void GxsCircleItem::setup() ui->membershipButton->setHidden(true); ui->inviteeButton->setHidden(true); } - else if (mType == RS_FEED_ITEM_CIRCLE_MEMB_JOIN) + else if (mType == RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_MEMB_JOIN) { if(circleDetails.mAmIAdmin) { @@ -148,7 +147,7 @@ void GxsCircleItem::setup() ui->membershipButton->setHidden(true); } - else if (mType == RS_FEED_ITEM_CIRCLE_MEMB_REVOKED) + else if (mType == RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_MEMB_REVOKED) { ui->titleLabel->setText(tr("Your identity %1 has been revoked from this circle.").arg(idName)); @@ -162,7 +161,7 @@ void GxsCircleItem::setup() ui->inviteeButton->setHidden(true); } - else if (mType == RS_FEED_ITEM_CIRCLE_MEMB_ACCEPTED) + else if (mType == RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_MEMB_ACCEPTED) { ui->titleLabel->setText(tr("Your identity %1 as been accepted in this circle.").arg(idName)); @@ -198,7 +197,7 @@ void GxsCircleItem::showCircleDetails() { CreateCircleDialog dlg; - dlg.editExistingId(RsGxsGroupId(mCircleId), true, mType != RS_FEED_ITEM_CIRCLE_MEMB_REQ) ; + dlg.editExistingId(RsGxsGroupId(mCircleId), true, mType != RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_MEMB_REQ) ; dlg.exec(); } @@ -215,9 +214,9 @@ void GxsCircleItem::toggleCircleMembership() return; } - if(mType == RS_FEED_ITEM_CIRCLE_INVITE_REC) + if(mType == RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_INVITE_REC) rsGxsCircles->requestCircleMembership(mGxsId,mCircleId); - else if(mType == RS_FEED_ITEM_CIRCLE_MEMB_REVOKED) + else if(mType == RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_MEMB_REVOKED) rsGxsCircles->cancelCircleMembership(mGxsId,mCircleId); else RsErr() << __PRETTY_FUNCTION__ << ": inconsistent call. mType is " << mType << std::endl; @@ -225,12 +224,12 @@ void GxsCircleItem::toggleCircleMembership() void GxsCircleItem::toggleCircleInvite() { - if(mType == RS_FEED_ITEM_CIRCLE_MEMB_JOIN) + if(mType == RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_MEMB_JOIN) RsThread::async([this]() { rsGxsCircles->revokeIdsFromCircle(std::set( { mGxsId } ),mCircleId); }); - else if(mType == RS_FEED_ITEM_CIRCLE_MEMB_REQ) + else if(mType == RsFeedTypeFlags::RS_FEED_ITEM_CIRCLE_MEMB_REQ) RsThread::async([this]() { rsGxsCircles->inviteIdsToCircle(std::set( { mGxsId } ),mCircleId); diff --git a/retroshare-gui/src/gui/feeds/GxsCircleItem.h b/retroshare-gui/src/gui/feeds/GxsCircleItem.h index 74f2cf44a..8133b8fa7 100644 --- a/retroshare-gui/src/gui/feeds/GxsCircleItem.h +++ b/retroshare-gui/src/gui/feeds/GxsCircleItem.h @@ -37,7 +37,7 @@ class GxsCircleItem : public FeedItem public: /** Default Constructor */ - GxsCircleItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsCircleId &circleId, const RsGxsId &gxsId, const uint32_t type); + GxsCircleItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsCircleId &circleId, const RsGxsId &gxsId, RsFeedTypeFlags type); virtual ~GxsCircleItem(); uint64_t uniqueIdentifier() const override; @@ -60,7 +60,7 @@ private slots: private: void setup(); - uint32_t mType; + RsFeedTypeFlags mType; RsGxsCircleId mCircleId; RsGxsId mGxsId; diff --git a/retroshare-gui/src/gui/gxs/GxsFeedItem.cpp b/retroshare-gui/src/gui/feeds/GxsFeedItem.cpp similarity index 98% rename from retroshare-gui/src/gui/gxs/GxsFeedItem.cpp rename to retroshare-gui/src/gui/feeds/GxsFeedItem.cpp index b9f2e68ee..524ecc578 100644 --- a/retroshare-gui/src/gui/gxs/GxsFeedItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsFeedItem.cpp @@ -18,7 +18,7 @@ * * *******************************************************************************/ -#include "gui/gxs/GxsFeedItem.h" +#include "gui/feeds/GxsFeedItem.h" #include "gui/feeds/FeedHolder.h" #include "gui/gxs/RsGxsUpdateBroadcastBase.h" diff --git a/retroshare-gui/src/gui/gxs/GxsFeedItem.h b/retroshare-gui/src/gui/feeds/GxsFeedItem.h similarity index 97% rename from retroshare-gui/src/gui/gxs/GxsFeedItem.h rename to retroshare-gui/src/gui/feeds/GxsFeedItem.h index bc75d1837..b33db7f18 100644 --- a/retroshare-gui/src/gui/gxs/GxsFeedItem.h +++ b/retroshare-gui/src/gui/feeds/GxsFeedItem.h @@ -1,5 +1,5 @@ /******************************************************************************* - * retroshare-gui/src/gui/gxs/GxsFeedItem.h * + * retroshare-gui/src/gui/feeds/GxsFeedItem.h * * * * Copyright 2012-2013 by Robert Fernie * * * diff --git a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp index 663951a6c..c3592b958 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp @@ -34,8 +34,9 @@ GxsForumGroupItem::GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, bool isHome, bool autoUpdate) : GxsGroupFeedItem(feedHolder, feedId, groupId, isHome, rsGxsForums, autoUpdate) { - setup(); - requestGroup(); + mLoadingGroup = false; + mLoadingStatus = LOADING_STATUS_NO_DATA; + setup(); addEventHandler(); } @@ -44,8 +45,9 @@ GxsForumGroupItem::GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, co mAddedModerators(added_moderators), mRemovedModerators(removed_moderators) { - setup(); - requestGroup(); + mLoadingGroup = false; + mLoadingStatus = LOADING_STATUS_NO_DATA; + setup(); addEventHandler(); } @@ -66,7 +68,8 @@ void GxsForumGroupItem::addEventHandler() case RsForumEventCode::SUBSCRIBE_STATUS_CHANGED: case RsForumEventCode::UPDATED_FORUM: case RsForumEventCode::MODERATOR_LIST_CHANGED: - loadGroup(); + mLoadingStatus = LOADING_STATUS_NO_DATA; + mGroup = RsGxsForumGroup(); break; default: break; @@ -75,16 +78,42 @@ void GxsForumGroupItem::addEventHandler() }, mEventHandlerId, RsEventType::GXS_FORUMS ); } -GxsForumGroupItem::GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsForumGroup &group, bool isHome, bool autoUpdate) : - GxsGroupFeedItem(feedHolder, feedId, group.mMeta.mGroupId, isHome, rsGxsForums, autoUpdate) +void GxsForumGroupItem::paintEvent(QPaintEvent *e) { - setup(); - setGroup(group); - addEventHandler(); -} + /* This method employs a trick to trigger a deferred loading. The post and group is requested only + * when actually displayed on the screen. */ + if(mLoadingStatus != LOADING_STATUS_FILLED && !mGroup.mMeta.mGroupId.isNull()) + mLoadingStatus = LOADING_STATUS_HAS_DATA; + + if(mGroup.mMeta.mGroupId.isNull() && !mLoadingGroup) + loadGroup(); + + switch(mLoadingStatus) + { + case LOADING_STATUS_FILLED: + case LOADING_STATUS_NO_DATA: + default: + break; + + case LOADING_STATUS_HAS_DATA: + fill(); + mLoadingStatus = LOADING_STATUS_FILLED; + break; + } + + GxsGroupFeedItem::paintEvent(e) ; +} GxsForumGroupItem::~GxsForumGroupItem() { + auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(GROUP_ITEM_LOADING_TIMEOUT_ms); + + while( mLoadingGroup && std::chrono::steady_clock::now() < timeout ) + { + RsDbg() << __PRETTY_FUNCTION__ << " is Waiting for data to load " << std::endl; + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } + rsEvents->unregisterEventsHandler(mEventHandlerId); delete(ui); } @@ -113,22 +142,10 @@ void GxsForumGroupItem::setup() ui->expandFrame->hide(); } -bool GxsForumGroupItem::setGroup(const RsGxsForumGroup &group) -{ - if (groupId() != group.mMeta.mGroupId) { - std::cerr << "GxsForumGroupItem::setContent() - Wrong id, cannot set post"; - std::cerr << std::endl; - return false; - } - - mGroup = group; - fill(); - - return true; -} - void GxsForumGroupItem::loadGroup() { + mLoadingGroup = true; + RsThread::async([this]() { // 1 - get group data @@ -143,14 +160,18 @@ void GxsForumGroupItem::loadGroup() if(!rsGxsForums->getForumsInfo(forumIds,groups)) { RsErr() << "GxsForumGroupItem::loadGroup() ERROR getting data" << std::endl; - return; + mLoadingGroup = false; + deferred_update(); + return; } if (groups.size() != 1) { std::cerr << "GxsForumGroupItem::loadGroup() Wrong number of Items"; std::cerr << std::endl; - return; + mLoadingGroup = false; + deferred_update(); + return; } RsGxsForumGroup group(groups[0]);// no reference to teporary accross threads! @@ -160,7 +181,8 @@ void GxsForumGroupItem::loadGroup() * thread, for example to update the data model with new information * after a blocking call to RetroShare API complete */ - setGroup(group); + mGroup = group; + mLoadingGroup = false; }, this ); }); @@ -185,7 +207,11 @@ void GxsForumGroupItem::fill() ui->descLabel->setText(QString::fromUtf8(mGroup.mDescription.c_str())); - if (IS_GROUP_PUBLISHER(mGroup.mMeta.mSubscribeFlags)) { + ui->forumlogo_label->setEnableZoom(false); + int desired_height = QFontMetricsF(font()).height() * ITEM_HEIGHT_FACTOR; + ui->forumlogo_label->setFixedSize(ITEM_PICTURE_FORMAT_RATIO*desired_height,desired_height); + + if (IS_GROUP_PUBLISHER(mGroup.mMeta.mSubscribeFlags)) { ui->forumlogo_label->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/forums.png")); } else { ui->forumlogo_label->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/forums-default.png")); diff --git a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.h b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.h index d80671e5a..31026f18c 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.h +++ b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.h @@ -23,7 +23,7 @@ #include #include -#include "gui/gxs/GxsGroupFeedItem.h" +#include "gui/feeds/GxsGroupFeedItem.h" namespace Ui { class GxsForumGroupItem; @@ -39,14 +39,15 @@ public: /** Default Constructor */ GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, bool isHome, bool autoUpdate); GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const std::list& added_moderators,const std::list& removed_moderators,bool isHome, bool autoUpdate); - GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsForumGroup &group, bool isHome, bool autoUpdate); - virtual ~GxsForumGroupItem() override; + //GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsForumGroup &group, bool isHome, bool autoUpdate); - bool setGroup(const RsGxsForumGroup &group); + virtual ~GxsForumGroupItem() override; uint64_t uniqueIdentifier() const override { return hash_64bits("GxsForumGroupItem " + groupId().toStdString()) ; } protected: - /* FeedItem */ + virtual void paintEvent(QPaintEvent *) override; + + /* FeedItem */ virtual void doExpand(bool open) override; /* GxsGroupFeedItem */ @@ -69,6 +70,9 @@ private: /** Qt Designer generated object */ Ui::GxsForumGroupItem *ui; + bool mLoadingGroup; + LoadingStatus mLoadingStatus; + std::list mAddedModerators; std::list mRemovedModerators; diff --git a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.ui b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.ui index aee325282..ff344158a 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.ui +++ b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.ui @@ -135,7 +135,7 @@ - + 70 @@ -406,6 +406,13 @@ + + + ZoomableLabel + QLabel +
gui/gxschannels/GxsChannelPostThumbnail.h
+
+
diff --git a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp index f4d091179..333a6a577 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp @@ -45,59 +45,60 @@ GxsForumMsgItem::GxsForumMsgItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate) : GxsFeedItem(feedHolder, feedId, groupId, messageId, isHome, rsGxsForums, autoUpdate) { - mMessage.mMeta.mMsgId = messageId; // useful for uniqueIdentifier() before the post is actually loaded - mMessage.mMeta.mGroupId = groupId; + mLoadingStatus = LOADING_STATUS_NO_DATA; mLoadingGroup = false; mLoadingMessage = false; mLoadingSetAsRead = false; - mLoadingParentMessage = false; setup(); - - requestGroup(); - requestMessage(); } -GxsForumMsgItem::GxsForumMsgItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsForumGroup &group, const RsGxsForumMsg &post, bool isHome, bool autoUpdate) : - GxsFeedItem(feedHolder, feedId, post.mMeta.mGroupId, post.mMeta.mMsgId, isHome, rsGxsForums, autoUpdate) +void GxsForumMsgItem::paintEvent(QPaintEvent *e) { -#ifdef DEBUG_ITEM - std::cerr << "GxsForumMsgItem::GxsForumMsgItem() Direct Load"; - std::cerr << std::endl; -#endif + /* This method employs a trick to trigger a deferred loading. The post and group is requested only + * when actually displayed on the screen. */ - setup(); + if(mLoadingStatus != LOADING_STATUS_FILLED && !mGroup.mMeta.mGroupId.isNull() && !mMessage.mMeta.mMsgId.isNull()) + mLoadingStatus = LOADING_STATUS_HAS_DATA; - setGroup(group, false); - setMessage(post); -} + if(mGroup.mMeta.mGroupId.isNull() && !mLoadingGroup) + requestGroup(); -GxsForumMsgItem::GxsForumMsgItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsForumMsg &post, bool isHome, bool autoUpdate) : - GxsFeedItem(feedHolder, feedId, post.mMeta.mGroupId, post.mMeta.mMsgId, isHome, rsGxsForums, autoUpdate) -{ -#ifdef DEBUG_ITEM - std::cerr << "GxsForumMsgItem::GxsForumMsgItem() Direct Load"; - std::cerr << std::endl; -#endif + if(mMessage.mMeta.mMsgId.isNull() && !mLoadingMessage) + requestMessage(); - setup(); + switch(mLoadingStatus) + { + case LOADING_STATUS_FILLED: + case LOADING_STATUS_NO_DATA: + default: + break; - requestGroup(); - setMessage(post); + case LOADING_STATUS_HAS_DATA: + fillGroup(); + fillMessage(); + + if(!mParentMessage.mMeta.mMsgId.isNull()) + fillParentMessage(); + + mLoadingStatus = LOADING_STATUS_FILLED; + break; + } + + GxsFeedItem::paintEvent(e) ; } GxsForumMsgItem::~GxsForumMsgItem() { - auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(300); + auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(GROUP_ITEM_LOADING_TIMEOUT_ms); - while( (mLoadingGroup || mLoadingMessage || mLoadingSetAsRead || mLoadingParentMessage) + while( (mLoadingGroup || mLoadingMessage || mLoadingSetAsRead) && std::chrono::steady_clock::now() < timeout) { RsDbg() << __PRETTY_FUNCTION__ << " is Waiting for " << (mLoadingGroup ? "Group " : "") << (mLoadingMessage ? "Message " : "") - << (mLoadingParentMessage ? "Parent message " : "") << (mLoadingSetAsRead ? "Set as read" : "") << "loading." << std::endl; std::this_thread::sleep_for(std::chrono::milliseconds(100)); @@ -113,7 +114,6 @@ void GxsForumMsgItem::setup() setAttribute(Qt::WA_DeleteOnClose, true); - mInFill = false; mCloseOnRead = false; /* clear ui */ @@ -144,41 +144,6 @@ void GxsForumMsgItem::setup() ui->parentFrame->hide(); } -bool GxsForumMsgItem::setGroup(const RsGxsForumGroup &group, bool doFill) -{ - if (groupId() != group.mMeta.mGroupId) { - std::cerr << "GxsForumMsgItem::setGroup() - Wrong id, cannot set post"; - std::cerr << std::endl; - return false; - } - - mGroup = group; - - if (doFill) - fillGroup(); - - return true; -} - -bool GxsForumMsgItem::setMessage(const RsGxsForumMsg &msg, bool doFill) -{ - if (groupId() != msg.mMeta.mGroupId || messageId() != msg.mMeta.mMsgId) { - std::cerr << "GxsForumMsgItem::setPost() - Wrong id, cannot set post"; - std::cerr << std::endl; - return false; - } - - mMessage = msg; - - if(! mMessage.mMeta.mParentId.isNull()) - loadParentMessage(mMessage.mMeta.mParentId); - - if(doFill) - fillMessage(); - - return true; -} - QString GxsForumMsgItem::groupName() { return QString::fromUtf8(mGroup.mMeta.mGroupName.c_str()); @@ -192,24 +157,27 @@ void GxsForumMsgItem::loadGroup() { // 1 - get group data -#ifdef DEBUG_FORUMS - std::cerr << "Retrieving post data for post " << mThreadId << std::endl; +#ifndef DEBUG_FORUMS + std::cerr << "Retrieving forum group data for forum " << groupId() << std::endl; #endif std::vector groups; - const std::list forumIds = { groupId() }; - if(!rsGxsForums->getForumsInfo(forumIds,groups)) + if(!rsGxsForums->getForumsInfo({ groupId() },groups)) { RsErr() << "GxsForumGroupItem::loadGroup() ERROR getting data" << std::endl; - return; + mLoadingGroup = false; + deferred_update(); + return; } if (groups.size() != 1) { std::cerr << "GxsForumGroupItem::loadGroup() Wrong number of Items"; std::cerr << std::endl; - return; + mLoadingGroup = false; + deferred_update(); + return; } RsGxsForumGroup group(groups[0]); @@ -219,7 +187,7 @@ void GxsForumMsgItem::loadGroup() * thread, for example to update the data model with new information * after a blocking call to RetroShare API complete */ - setGroup(group); + mGroup = group; mLoadingGroup = false; }, this ); @@ -242,89 +210,51 @@ void GxsForumMsgItem::loadMessage() std::cerr << "Retrieving post data for post " << mThreadId << std::endl; #endif - std::vector msgs; - const std::list forumIds = { groupId() }; + auto getMessageData = [](const RsGxsGroupId& gid,const RsGxsMessageId& msg_id,RsGxsForumMsg& msg) -> bool + { + std::vector msgs; - if(!rsGxsForums->getForumContent(groupId(),std::set( { messageId() } ),msgs)) - { - std::cerr << "GxsForumMsgItem::loadMessage() ERROR getting data"; - std::cerr << std::endl; - return; - } + if(!rsGxsForums->getForumContent(gid,std::set( { msg_id } ),msgs)) + return false; - if (msgs.size() != 1) - { - std::cerr << "GxsForumMsgItem::loadMessage() Wrong number of Items"; - std::cerr << std::endl; - return; - } - RsGxsForumMsg msg(msgs[0]); + if (msgs.size() != 1) + return false; - RsQThreadUtils::postToObject( [msg,this]() + msg = msgs[0]; + + return true; + }; + + RsGxsForumMsg msg,parent_msg; + + if(!getMessageData(groupId(),messageId(),msg)) + { + std::cerr << "GxsForumMsgItem::loadMessage() ERROR getting message data"; + mLoadingMessage = false; + deferred_update(); + return; + } + // now load the parent message. If not found, it's not a problem. + + if(!msg.mMeta.mParentId.isNull() && !getMessageData(groupId(),msg.mMeta.mParentId,parent_msg)) + std::cerr << "GxsForumMsgItem::loadMessage() ERROR getting parent message data. Maybe the parent msg is not available."; + + RsQThreadUtils::postToObject( [msg,parent_msg,this]() { /* Here it goes any code you want to be executed on the Qt Gui * thread, for example to update the data model with new information * after a blocking call to RetroShare API complete */ - setMessage(msg); + mMessage = msg; + mParentMessage = parent_msg; mLoadingMessage = false; }, this ); }); } -void GxsForumMsgItem::loadParentMessage(const RsGxsMessageId& parent_msg) -{ -#ifdef DEBUG_ITEM - std::cerr << "GxsForumMsgItem::loadParentMessage()"; - std::cerr << std::endl; -#endif - mLoadingParentMessage = true; - - RsThread::async([parent_msg,this]() - { - // 1 - get group data - -#ifdef DEBUG_FORUMS - std::cerr << "Retrieving post data for post " << mThreadId << std::endl; -#endif - - std::vector msgs; - const std::list forumIds = { groupId() }; - - if(!rsGxsForums->getForumContent(groupId(),std::set( { parent_msg } ),msgs)) - { - std::cerr << "GxsForumMsgItem::loadMessage() ERROR getting data"; - std::cerr << std::endl; - return; - } - - if (msgs.size() != 1) - { - std::cerr << "GxsForumMsgItem::loadMessage() Wrong number of Items"; - std::cerr << std::endl; - return; - } - RsGxsForumMsg msg(msgs[0]); - - RsQThreadUtils::postToObject( [msg,this]() - { - /* Here it goes any code you want to be executed on the Qt Gui - * thread, for example to update the data model with new information - * after a blocking call to RetroShare API complete */ - - mParentMessage = msg; - fillParentMessage(); - - mLoadingParentMessage = false; - - }, this ); - }); -} void GxsForumMsgItem::fillParentMessage() { - mInFill = true; - ui->parentFrame->hide(); RetroShareLink linkParent = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_FORUM, mParentMessage.mMeta.mGroupId, mParentMessage.mMeta.mMsgId, QString::fromUtf8(mParentMessage.mMeta.mMsgName.c_str())); @@ -341,8 +271,6 @@ void GxsForumMsgItem::fillParentMessage() pixmap = GxsIdDetails::makeDefaultIcon(mParentMessage.mMeta.mAuthorId,GxsIdDetails::SMALL); ui->parentAvatar->setPixmap(pixmap); - - mInFill = false; } void GxsForumMsgItem::fillMessage() { @@ -351,8 +279,6 @@ void GxsForumMsgItem::fillMessage() std::cerr << std::endl; #endif - mInFill = true; - if(!mIsHome && mCloseOnRead && !IS_MSG_NEW(mMessage.mMeta.mMsgStatus)) removeItem(); @@ -394,21 +320,15 @@ void GxsForumMsgItem::fillMessage() ui->clearButton->setEnabled(false); ui->clearButton->hide(); } - - mInFill = false; } void GxsForumMsgItem::fillGroup() { - mInFill = true; - ui->unsubscribeButton->setEnabled(IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroup.mMeta.mSubscribeFlags)) ; if (IS_GROUP_PUBLISHER(mGroup.mMeta.mSubscribeFlags)) ui->iconLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/forums.png")); else ui->iconLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/forums-default.png")); - - mInFill = false; } void GxsForumMsgItem::fillExpandFrame() @@ -502,12 +422,10 @@ void GxsForumMsgItem::unsubscribeForum() void GxsForumMsgItem::setAsRead(bool doUpdate) { - if (mInFill) { - return; - } - mCloseOnRead = false; - mLoadingSetAsRead = true; + + if(doUpdate) + mLoadingSetAsRead = true; RsThread::async( [this, doUpdate]() { RsGxsGrpMsgIdPair msgPair = std::make_pair(groupId(), messageId()); diff --git a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.h b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.h index ec933d96e..2c8e55292 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.h +++ b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.h @@ -22,7 +22,7 @@ #define _GXSFORUMMSGITEM_H #include -#include "gui/gxs/GxsFeedItem.h" +#include "gui/feeds/GxsFeedItem.h" namespace Ui { class GxsForumMsgItem; @@ -36,27 +36,20 @@ class GxsForumMsgItem : public GxsFeedItem public: GxsForumMsgItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate); - GxsForumMsgItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsForumGroup &group, const RsGxsForumMsg &post, bool isHome, bool autoUpdate); - GxsForumMsgItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsForumMsg &post, bool isHome, bool autoUpdate); - virtual ~GxsForumMsgItem(); - bool setGroup(const RsGxsForumGroup &group, bool doFill = true); - bool setMessage(const RsGxsForumMsg &msg, bool doFill = true); + virtual ~GxsForumMsgItem(); uint64_t uniqueIdentifier() const override { return hash_64bits("GxsForumMsgItem " + messageId().toStdString()) ; } protected: - /* FeedItem */ + virtual void paintEvent(QPaintEvent *e) override; + /* FeedItem */ virtual void doExpand(bool open) override; virtual void expandFill(bool first) override; - /* load message data */ - virtual void loadParentMessage(const RsGxsMessageId &parent_msg); - /* GxsGroupFeedItem */ virtual QString groupName() override; virtual void loadGroup() override; virtual RetroShareLink::enumType getLinkType() override { return RetroShareLink::TYPE_FORUM; } - //virtual bool isLoading(); /* GxsFeedItem */ virtual QString messageName() override; @@ -77,6 +70,7 @@ signals: private: void setup(); + void fillGroup(); void fillMessage(); void fillParentMessage(); @@ -85,16 +79,19 @@ private: void setAsRead(bool doUpdate); private: - bool mInFill; bool mCloseOnRead; + + LoadingStatus mLoadingStatus; + bool mLoadingMessage; - bool mLoadingParentMessage; bool mLoadingGroup; bool mLoadingSetAsRead; + bool mHasParentMessage; // set to false when we see that the msg does not have a parent. + RsGxsForumGroup mGroup; - RsGxsForumMsg mMessage; - RsGxsForumMsg mParentMessage; + RsGxsForumMsg mMessage; + RsGxsForumMsg mParentMessage; /** Qt Designer generated object */ Ui::GxsForumMsgItem *ui; diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFeedItem.cpp b/retroshare-gui/src/gui/feeds/GxsGroupFeedItem.cpp similarity index 83% rename from retroshare-gui/src/gui/gxs/GxsGroupFeedItem.cpp rename to retroshare-gui/src/gui/feeds/GxsGroupFeedItem.cpp index b4fe2273f..523f41076 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFeedItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsGroupFeedItem.cpp @@ -1,5 +1,5 @@ /******************************************************************************* - * retroshare-gui/src/gui/gxs/GxsGroupFeedItem.cpp * + * retroshare-gui/src/gui/feeds/GxsGroupFeedItem.cpp * * * * Copyright 2012-2013 by Robert Fernie * * * @@ -20,10 +20,13 @@ #include -#include "gui/gxs/GxsGroupFeedItem.h" +#include "GxsGroupFeedItem.h" + #include "gui/feeds/FeedHolder.h" #include "gui/gxs/RsGxsUpdateBroadcastBase.h" +#include "util/qtthreadsutils.h" + #include #include @@ -31,6 +34,8 @@ * #define DEBUG_ITEM 1 **/ +const uint GxsGroupFeedItem::GROUP_ITEM_LOADING_TIMEOUT_ms = 2000; + GxsGroupFeedItem::GxsGroupFeedItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, bool isHome, RsGxsIfaceHelper *iface, bool /*autoUpdate*/) : FeedItem(feedHolder,feedId,NULL) { @@ -41,6 +46,7 @@ GxsGroupFeedItem::GxsGroupFeedItem(FeedHolder *feedHolder, uint32_t feedId, cons /* this are just generally useful for all children */ mIsHome = isHome; + mLastDelay = 300; // re-update after 300ms on fail. See deferred_update() /* load data if we can */ mGroupId = groupId; @@ -114,3 +120,19 @@ void GxsGroupFeedItem::requestGroup() loadGroup(); } +void GxsGroupFeedItem::deferred_update() +{ + mLastDelay = (int)(float(mLastDelay)*1.2); + mLastDelay += 100.0*RsRandom::random_f32(); + + if(mLastDelay < 10000.0) + { + std::cerr << "Launching deferred update at " << mLastDelay << " ms." << std::endl; + RsQThreadUtils::postToObject( [this]() { QTimer::singleShot(mLastDelay,this,SLOT(update())); }, this ); + } +} + + + + + diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFeedItem.h b/retroshare-gui/src/gui/feeds/GxsGroupFeedItem.h similarity index 84% rename from retroshare-gui/src/gui/gxs/GxsGroupFeedItem.h rename to retroshare-gui/src/gui/feeds/GxsGroupFeedItem.h index 653d62bb1..c70879bbd 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFeedItem.h +++ b/retroshare-gui/src/gui/feeds/GxsGroupFeedItem.h @@ -1,5 +1,5 @@ /******************************************************************************* - * retroshare-gui/src/gui/gxs/GxsGroupFeedItem.h * + * retroshare-gui/src/gui/feeds/GxsGroupFeedItem.h * * * * Copyright 2012-2013 by Robert Fernie * * * @@ -45,6 +45,12 @@ public: uint32_t feedId() const { return mFeedId; } protected: + enum LoadingStatus { + LOADING_STATUS_NO_DATA = 0x00, + LOADING_STATUS_HAS_DATA = 0x01, + LOADING_STATUS_FILLED = 0x02 + }; + /* load group data */ void requestGroup(); @@ -52,6 +58,9 @@ protected: virtual RetroShareLink::enumType getLinkType() = 0; virtual QString groupName() = 0; + // This triggers an update in the main thread after a short waiting period. Help loading objects that havn't loaded yet. + void deferred_update(); + protected slots: void subscribe(); void unsubscribe(); @@ -60,6 +69,7 @@ protected slots: protected: bool mIsHome; RsGxsIfaceHelper *mGxsIface; + static const uint GROUP_ITEM_LOADING_TIMEOUT_ms ; private slots: /* RsGxsUpdateBroadcastBase */ @@ -67,6 +77,7 @@ private slots: private: RsGxsGroupId mGroupId; + int mLastDelay; }; Q_DECLARE_METATYPE(RsGxsGroupId) diff --git a/retroshare-gui/src/gui/feeds/MsgItem.cpp b/retroshare-gui/src/gui/feeds/MsgItem.cpp index 0789d98c9..f1e7a8a69 100644 --- a/retroshare-gui/src/gui/feeds/MsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/MsgItem.cpp @@ -30,7 +30,6 @@ #include "util/DateTime.h" #include "gui/common/AvatarDefs.h" #include "gui/common/FilesDefs.h" -#include "gui/notifyqt.h" #include "util/qtthreadsutils.h" #include diff --git a/retroshare-gui/src/gui/feeds/PeerItem.cpp b/retroshare-gui/src/gui/feeds/PeerItem.cpp index 7961abce2..f21f26c86 100644 --- a/retroshare-gui/src/gui/feeds/PeerItem.cpp +++ b/retroshare-gui/src/gui/feeds/PeerItem.cpp @@ -28,10 +28,9 @@ #include "gui/common/StatusDefs.h" #include "gui/common/FilesDefs.h" #include "gui/common/AvatarDefs.h" +#include "util/qtthreadsutils.h" #include "util/DateTime.h" -#include "gui/notifyqt.h" - #include #include #include @@ -58,7 +57,21 @@ PeerItem::PeerItem(FeedHolder *parent, uint32_t feedId, const RsPeerId &peerId, connect( chatButton, SIGNAL( clicked() ), this, SLOT( openChat() ) ); connect( sendmsgButton, SIGNAL( clicked() ), this, SLOT( sendMsg() ) ); - connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()), this, SLOT(updateItem())); + mEventHandlerId = 0; + + rsEvents->registerEventsHandler( [this](std::shared_ptr e) + { + RsQThreadUtils::postToObject([=]() + { + auto fe = dynamic_cast(e.get()); + + if(!fe) + return; + + updateItem(); + } + , this ); + }, mEventHandlerId, RsEventType::FRIEND_LIST ); avatar->setId(ChatId(mPeerId));// TODO: remove unnecesary converstation @@ -68,6 +81,10 @@ PeerItem::PeerItem(FeedHolder *parent, uint32_t feedId, const RsPeerId &peerId, updateItem(); } +PeerItem::~PeerItem() +{ + rsEvents->unregisterEventsHandler(mEventHandlerId); +} uint64_t PeerItem::uniqueIdentifier() const { return hash_64bits("PeerItem " + mPeerId.toStdString() + " " + QString::number(mType).toStdString()) ; diff --git a/retroshare-gui/src/gui/feeds/PeerItem.h b/retroshare-gui/src/gui/feeds/PeerItem.h index 22b9bbaf0..8a7a2abc3 100644 --- a/retroshare-gui/src/gui/feeds/PeerItem.h +++ b/retroshare-gui/src/gui/feeds/PeerItem.h @@ -40,6 +40,7 @@ class PeerItem : public FeedItem, private Ui::PeerItem public: /** Default Constructor */ PeerItem(FeedHolder *parent, uint32_t feedId, const RsPeerId &peerId, uint32_t type, bool isHome); + virtual ~PeerItem(); void updateItemStatic(); @@ -66,6 +67,7 @@ private: RsPeerId mPeerId; uint32_t mType; bool mIsHome; + RsEventsHandlerId_t mEventHandlerId ; }; #endif diff --git a/retroshare-gui/src/gui/feeds/PostedGroupItem.cpp b/retroshare-gui/src/gui/feeds/PostedGroupItem.cpp index f4abafb08..2e341a00a 100644 --- a/retroshare-gui/src/gui/feeds/PostedGroupItem.cpp +++ b/retroshare-gui/src/gui/feeds/PostedGroupItem.cpp @@ -35,21 +35,50 @@ PostedGroupItem::PostedGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, bool isHome, bool autoUpdate) : GxsGroupFeedItem(feedHolder, feedId, groupId, isHome, rsPosted, autoUpdate) { - setup(); + mLoadingGroup = false; + mLoadingStatus = LOADING_STATUS_NO_DATA; - requestGroup(); + setup(); } -PostedGroupItem::PostedGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsPostedGroup &group, bool isHome, bool autoUpdate) : - GxsGroupFeedItem(feedHolder, feedId, group.mMeta.mGroupId, isHome, rsPosted, autoUpdate) +void PostedGroupItem::paintEvent(QPaintEvent *e) { - setup(); + /* This method employs a trick to trigger a deferred loading. The post and group is requested only + * when actually displayed on the screen. */ - setGroup(group); + if(mLoadingStatus != LOADING_STATUS_FILLED && !mGroup.mMeta.mGroupId.isNull()) + mLoadingStatus = LOADING_STATUS_HAS_DATA; + + if(mGroup.mMeta.mGroupId.isNull() && !mLoadingGroup) + loadGroup(); + + switch(mLoadingStatus) + { + case LOADING_STATUS_FILLED: + case LOADING_STATUS_NO_DATA: + default: + break; + + case LOADING_STATUS_HAS_DATA: + fill(); + mLoadingStatus = LOADING_STATUS_FILLED; + break; + } + + GxsGroupFeedItem::paintEvent(e) ; } - PostedGroupItem::~PostedGroupItem() { + auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(GROUP_ITEM_LOADING_TIMEOUT_ms); + + while( mLoadingGroup && std::chrono::steady_clock::now() < timeout) + { + RsDbg() << __PRETTY_FUNCTION__ << " is Waiting " + << (mLoadingGroup ? "Group " : "") + << "loading finished." << std::endl; + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } delete(ui); } @@ -79,22 +108,10 @@ void PostedGroupItem::setup() ui->expandFrame->hide(); } -bool PostedGroupItem::setGroup(const RsPostedGroup &group) -{ - if (groupId() != group.mMeta.mGroupId) { - std::cerr << "PostedGroupItem::setContent() - Wrong id, cannot set post"; - std::cerr << std::endl; - return false; - } - - mGroup = group; - fill(); - - return true; -} - void PostedGroupItem::loadGroup() { + mLoadingGroup = true; + RsThread::async([this]() { // 1 - get group data @@ -109,14 +126,18 @@ void PostedGroupItem::loadGroup() if(!rsPosted->getBoardsInfo(groupIds,groups)) { RsErr() << "GxsPostedGroupItem::loadGroup() ERROR getting data" << std::endl; - return; + mLoadingGroup = false; + deferred_update(); + return; } if (groups.size() != 1) { std::cerr << "GxsPostedGroupItem::loadGroup() Wrong number of Items"; std::cerr << std::endl; - return; + mLoadingGroup = false; + deferred_update(); + return; } RsPostedGroup group(groups[0]); @@ -126,7 +147,8 @@ void PostedGroupItem::loadGroup() * thread, for example to update the data model with new information * after a blocking call to RetroShare API complete */ - setGroup(group); + mGroup = group; + mLoadingGroup = false; }, this ); }); @@ -153,7 +175,11 @@ void PostedGroupItem::fill() ui->descLabel->setText(QString::fromUtf8(mGroup.mDescription.c_str())); - if (mGroup.mGroupImage.mData != NULL) { + ui->logoLabel->setEnableZoom(false); + int desired_height = QFontMetricsF(font()).height() * ITEM_HEIGHT_FACTOR; + ui->logoLabel->setFixedSize(ITEM_PICTURE_FORMAT_RATIO*desired_height,desired_height); + + if (mGroup.mGroupImage.mData != NULL) { QPixmap postedImage; GxsIdDetails::loadPixmapFromData(mGroup.mGroupImage.mData, mGroup.mGroupImage.mSize, postedImage,GxsIdDetails::ORIGINAL); ui->logoLabel->setPixmap(QPixmap(postedImage)); diff --git a/retroshare-gui/src/gui/feeds/PostedGroupItem.h b/retroshare-gui/src/gui/feeds/PostedGroupItem.h index 642dc4be0..fdda04922 100644 --- a/retroshare-gui/src/gui/feeds/PostedGroupItem.h +++ b/retroshare-gui/src/gui/feeds/PostedGroupItem.h @@ -22,7 +22,7 @@ #define _POSTEDGROUPITEM_H #include -#include "gui/gxs/GxsGroupFeedItem.h" +#include "gui/feeds/GxsGroupFeedItem.h" namespace Ui { class PostedGroupItem; @@ -37,21 +37,20 @@ class PostedGroupItem : public GxsGroupFeedItem public: /** Default Constructor */ PostedGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, bool isHome, bool autoUpdate); - PostedGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsPostedGroup &group, bool isHome, bool autoUpdate); - ~PostedGroupItem(); - - bool setGroup(const RsPostedGroup &group); + virtual ~PostedGroupItem() override; uint64_t uniqueIdentifier() const override { return hash_64bits("PostedGroupItem " + groupId().toStdString()) ; } protected: + virtual void paintEvent(QPaintEvent *e) override; + /* FeedItem */ - virtual void doExpand(bool open); + virtual void doExpand(bool open) override; /* GxsGroupFeedItem */ - virtual QString groupName(); + virtual QString groupName() override; virtual void loadGroup() override; - virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_UNKNOWN; } + virtual RetroShareLink::enumType getLinkType() override { return RetroShareLink::TYPE_UNKNOWN; } private slots: void toggle() override; @@ -63,6 +62,8 @@ private: private: RsPostedGroup mGroup; + bool mLoadingGroup; + LoadingStatus mLoadingStatus; /** Qt Designer generated object */ Ui::PostedGroupItem *ui; diff --git a/retroshare-gui/src/gui/feeds/PostedGroupItem.ui b/retroshare-gui/src/gui/feeds/PostedGroupItem.ui index 6c043972f..b037b767a 100644 --- a/retroshare-gui/src/gui/feeds/PostedGroupItem.ui +++ b/retroshare-gui/src/gui/feeds/PostedGroupItem.ui @@ -135,7 +135,7 @@ - + 70 @@ -396,6 +396,13 @@ + + + ZoomableLabel + QLabel +
gui/gxschannels/GxsChannelPostThumbnail.h
+
+
diff --git a/retroshare-gui/src/gui/feeds/SecurityIpItem.cpp b/retroshare-gui/src/gui/feeds/SecurityIpItem.cpp index 6e543108d..6d03cbf56 100644 --- a/retroshare-gui/src/gui/feeds/SecurityIpItem.cpp +++ b/retroshare-gui/src/gui/feeds/SecurityIpItem.cpp @@ -23,7 +23,7 @@ #include "SecurityIpItem.h" #include "FeedHolder.h" -#include"ui_SecurityIpItem.h" +#include "ui_SecurityIpItem.h" #include "retroshare-gui/RsAutoUpdatePage.h" #include "gui/connect/ConfCertDialog.h" #include "util/DateTime.h" @@ -33,21 +33,20 @@ #include #include -#include /***** * #define DEBUG_ITEM 1 ****/ /** Constructor */ -SecurityIpItem::SecurityIpItem(FeedHolder *parent, const RsPeerId &sslId, const std::string &ipAddr, uint32_t result, uint32_t type, bool isTest) : +SecurityIpItem::SecurityIpItem(FeedHolder *parent, const RsPeerId &sslId, const std::string &ipAddr, uint32_t result, RsFeedTypeFlags type, bool isTest) : FeedItem(parent,0,NULL), mType(type), mSslId(sslId), mIpAddr(ipAddr), mResult(result), mIsTest(isTest), ui(new(Ui::SecurityIpItem)) { setup(); } -SecurityIpItem::SecurityIpItem(FeedHolder *parent, const RsPeerId &sslId, const std::string& ipAddr, const std::string& ipAddrReported, uint32_t type, bool isTest) : +SecurityIpItem::SecurityIpItem(FeedHolder *parent, const RsPeerId &sslId, const std::string& ipAddr, const std::string& ipAddrReported, RsFeedTypeFlags type, bool isTest) : FeedItem(parent,0,NULL), mType(type), mSslId(sslId), mIpAddr(ipAddr), mIpAddrReported(ipAddrReported), mResult(0), mIsTest(isTest), ui(new(Ui::SecurityIpItem)) { @@ -81,7 +80,7 @@ void SecurityIpItem::setup() uint64_t SecurityIpItem::uniqueIdentifier() const { - return hash_64bits("SecurityItem " + QString::number(mType).toStdString() + " " + mSslId.toStdString() + " " + mIpAddr + " " + mIpAddrReported) ; + return hash_64bits("SecurityItem " + QString::number((int)mType).toStdString() + " " + mSslId.toStdString() + " " + mIpAddr + " " + mIpAddrReported) ; } void SecurityIpItem::updateItemStatic() @@ -97,12 +96,12 @@ void SecurityIpItem::updateItemStatic() /* Specific type */ switch (mType) { - case RS_FEED_ITEM_SEC_IP_BLACKLISTED: + case RsFeedTypeFlags::RS_FEED_ITEM_SEC_IP_BLACKLISTED: ui->rsBanListButton->setDisabled(mIsTest); ui->ipAddrReported->hide(); ui->ipAddrReportedLabel->hide(); break; - case RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED: + case RsFeedTypeFlags::RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED: ui->rsBanListButton->hide(); break; default: @@ -110,7 +109,7 @@ void SecurityIpItem::updateItemStatic() } QDateTime currentTime = QDateTime::currentDateTime(); - ui->timeLabel->setText(DateTime::formatLongDateTime(currentTime.toTime_t())); + ui->timeLabel->setText(DateTime::formatLongDateTime(currentTime)); } void SecurityIpItem::updateItem() @@ -126,7 +125,7 @@ void SecurityIpItem::updateItem() if(!RsAutoUpdatePage::eventsLocked()) { switch (mType) { - case RS_FEED_ITEM_SEC_IP_BLACKLISTED: + case RsFeedTypeFlags::RS_FEED_ITEM_SEC_IP_BLACKLISTED: ui->titleLabel->setText(RsBanListDefs::resultString(mResult)); ui->ipAddr->setText(QString::fromStdString(mIpAddr)); @@ -145,7 +144,7 @@ void SecurityIpItem::updateItem() } } break; - case RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED: + case RsFeedTypeFlags::RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED: ui->titleLabel->setText(tr("Wrong external ip address reported")); ui->ipAddr->setText(QString::fromStdString(mIpAddr)); ui->ipAddr->setToolTip(tr("

This is the external IP your Retroshare node thinks it is using.

")) ; diff --git a/retroshare-gui/src/gui/feeds/SecurityIpItem.h b/retroshare-gui/src/gui/feeds/SecurityIpItem.h index bfef10634..506bb3de9 100644 --- a/retroshare-gui/src/gui/feeds/SecurityIpItem.h +++ b/retroshare-gui/src/gui/feeds/SecurityIpItem.h @@ -38,8 +38,8 @@ class SecurityIpItem : public FeedItem public: /** Default Constructor */ - SecurityIpItem(FeedHolder *parent, const RsPeerId &sslId, const std::string& ipAddr, uint32_t result, uint32_t type, bool isTest); - SecurityIpItem(FeedHolder *parent, const RsPeerId &sslId, const std::string& ipAddr, const std::string& ipAddrReported, uint32_t type, bool isTest); + SecurityIpItem(FeedHolder *parent, const RsPeerId &sslId, const std::string& ipAddr, uint32_t result, RsFeedTypeFlags type, bool isTest); + SecurityIpItem(FeedHolder *parent, const RsPeerId &sslId, const std::string& ipAddr, const std::string& ipAddrReported, RsFeedTypeFlags type, bool isTest); void updateItemStatic(); @@ -60,7 +60,7 @@ private slots: void banIpListChanged(const QString &ipAddress); private: - uint32_t mType; + RsFeedTypeFlags mType; RsPeerId mSslId; std::string mIpAddr; std::string mIpAddrReported; diff --git a/retroshare-gui/src/gui/feeds/SecurityItem.cpp b/retroshare-gui/src/gui/feeds/SecurityItem.cpp index 584eee212..bf9e0dce6 100644 --- a/retroshare-gui/src/gui/feeds/SecurityItem.cpp +++ b/retroshare-gui/src/gui/feeds/SecurityItem.cpp @@ -33,8 +33,7 @@ #include "gui/connect/ConnectFriendWizard.h" #include "gui/common/AvatarDefs.h" #include "util/DateTime.h" - -#include "gui/notifyqt.h" +#include "util/qtthreadsutils.h" #include #include @@ -44,7 +43,7 @@ ****/ /** Constructor */ -SecurityItem::SecurityItem(FeedHolder *parent, uint32_t feedId, const RsPgpId &gpgId, const RsPeerId &sslId, const std::string &sslCn, const std::string& ip_address,uint32_t type, bool isHome) : +SecurityItem::SecurityItem(FeedHolder *parent, uint32_t feedId, const RsPgpId &gpgId, const RsPeerId &sslId, const std::string &sslCn, const std::string& ip_address,RsFeedTypeFlags type, bool isHome) : FeedItem(parent,feedId,NULL), mGpgId(gpgId), mSslId(sslId), mSslCn(sslCn), mIP(ip_address), mType(type), mIsHome(isHome) { @@ -72,7 +71,21 @@ SecurityItem::SecurityItem(FeedHolder *parent, uint32_t feedId, const RsPgpId &g connect( peerDetailsButton, SIGNAL(clicked()), this, SLOT(peerDetails())); connect( friendRequesttoolButton, SIGNAL(clicked()), this, SLOT(friendRequest())); - connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()), this, SLOT(updateItem())); + mEventHandlerId = 0; + + rsEvents->registerEventsHandler( [this](std::shared_ptr e) + { + RsQThreadUtils::postToObject([=]() + { + auto fe = dynamic_cast(e.get()); + + if(!fe) + return; + + updateItem(); + } + , this ); + }, mEventHandlerId, RsEventType::FRIEND_LIST ); avatar->setId(ChatId(mSslId)); @@ -82,9 +95,13 @@ SecurityItem::SecurityItem(FeedHolder *parent, uint32_t feedId, const RsPgpId &g updateItem(); } +SecurityItem::~SecurityItem() +{ + rsEvents->unregisterEventsHandler(mEventHandlerId); +} uint64_t SecurityItem::uniqueIdentifier() const { - return hash_64bits("SecurityItem " + QString::number(mType).toStdString() + " " + mSslId.toStdString()); + return hash_64bits("SecurityItem " + QString::number((uint)mType).toStdString() + " " + mSslId.toStdString()); } void SecurityItem::updateItemStatic() @@ -101,35 +118,35 @@ void SecurityItem::updateItemStatic() switch(mType) { - case RS_FEED_ITEM_SEC_CONNECT_ATTEMPT: + case RsFeedTypeFlags::RS_FEED_ITEM_SEC_CONNECT_ATTEMPT: title = tr("Connect Attempt"); requestLabel->show(); avatar->setDefaultAvatar(":images/avatar_request.png"); break; - case RS_FEED_ITEM_SEC_AUTH_DENIED: + case RsFeedTypeFlags::RS_FEED_ITEM_SEC_AUTH_DENIED: title = tr("Connection refused by remote peer"); requestLabel->hide(); avatar->setDefaultAvatar(":images/avatar_refused.png"); break; - case RS_FEED_ITEM_SEC_UNKNOWN_IN: + case RsFeedTypeFlags::RS_FEED_ITEM_SEC_UNKNOWN_IN: title = tr("Unknown (Incoming) Connect Attempt"); requestLabel->hide(); avatar->setDefaultAvatar(":images/avatar_request_unknown.png"); break; - case RS_FEED_ITEM_SEC_UNKNOWN_OUT: + case RsFeedTypeFlags::RS_FEED_ITEM_SEC_UNKNOWN_OUT: title = tr("Unknown (Outgoing) Connect Attempt"); requestLabel->hide(); break; - case RS_FEED_ITEM_SEC_WRONG_SIGNATURE: + case RsFeedTypeFlags::RS_FEED_ITEM_SEC_WRONG_SIGNATURE: title = tr("Certificate has wrong signature!! This peer is not who he claims to be."); requestLabel->hide(); break; - case RS_FEED_ITEM_SEC_MISSING_CERTIFICATE: + case RsFeedTypeFlags::RS_FEED_ITEM_SEC_MISSING_CERTIFICATE: title = tr("Peer/node not in friendlist (PGP id=")+QString::fromStdString(mGpgId.toStdString())+")"; avatar->setDefaultAvatar(":images/avatar_request_unknown.png"); requestLabel->show(); break; - case RS_FEED_ITEM_SEC_BAD_CERTIFICATE: + case RsFeedTypeFlags::RS_FEED_ITEM_SEC_BAD_CERTIFICATE: { RsPeerDetails details ; if(rsPeers->getGPGDetails(mGpgId, details)) @@ -140,7 +157,7 @@ void SecurityItem::updateItemStatic() } avatar->setDefaultAvatar(":icons/ssl.png"); break; - case RS_FEED_ITEM_SEC_INTERNAL_ERROR: + case RsFeedTypeFlags::RS_FEED_ITEM_SEC_INTERNAL_ERROR: title = tr("Certificate caused an internal error."); requestLabel->hide(); break; @@ -153,7 +170,7 @@ void SecurityItem::updateItemStatic() titleLabel->setText(title); QDateTime currentTime = QDateTime::currentDateTime(); - timeLabel->setText(DateTime::formatLongDateTime(currentTime.toTime_t())); + timeLabel->setText(DateTime::formatLongDateTime(currentTime)); if (mIsHome) { @@ -211,7 +228,7 @@ void SecurityItem::updateItem() removeFriendButton->hide(); peerDetailsButton->setEnabled(false); - if(mType == RS_FEED_ITEM_SEC_BAD_CERTIFICATE) + if(mType == RsFeedTypeFlags::RS_FEED_ITEM_SEC_BAD_CERTIFICATE) { peerNameLabel->setText(tr("SSL request")); friendRequesttoolButton->hide(); diff --git a/retroshare-gui/src/gui/feeds/SecurityItem.h b/retroshare-gui/src/gui/feeds/SecurityItem.h index 7f99c8377..03887c121 100644 --- a/retroshare-gui/src/gui/feeds/SecurityItem.h +++ b/retroshare-gui/src/gui/feeds/SecurityItem.h @@ -38,7 +38,8 @@ class SecurityItem : public FeedItem, private Ui::SecurityItem public: /** Default Constructor */ - SecurityItem(FeedHolder *parent, uint32_t feedId, const RsPgpId &gpgId, const RsPeerId &sslId, const std::string &sslCn, const std::string& ip_addr,uint32_t type, bool isHome); + SecurityItem(FeedHolder *parent, uint32_t feedId, const RsPgpId &gpgId, const RsPeerId &sslId, const std::string &sslCn, const std::string& ip_addr,RsFeedTypeFlags type, bool isHome); + ~SecurityItem(); void updateItemStatic(); @@ -65,8 +66,10 @@ private: RsPeerId mSslId; std::string mSslCn; std::string mIP; - uint32_t mType; + RsFeedTypeFlags mType; bool mIsHome; + + RsEventsHandlerId_t mEventHandlerId; }; #endif diff --git a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp index 277b11e4f..85dc8826e 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp +++ b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp @@ -28,6 +28,7 @@ #include "gui/gxs/GxsCreateCommentDialog.h" #include "gui/gxs/GxsIdTreeWidgetItem.h" #include "util/qtthreadsutils.h" +#include "util/DateTime.h" #include #include @@ -798,8 +799,7 @@ void GxsCommentTreeWidget::insertComments(const std::vector& comme QString text; { - QDateTime qtime ; - qtime.setTime_t(comment.mMeta.mPublishTs) ; + QDateTime qtime = DateTime::DateTimeFromTime_t(comment.mMeta.mPublishTs) ; text = qtime.toString("yyyy-MM-dd hh:mm:ss") ; item->setText(PCITEM_COLUMN_DATE, text) ; diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp index 069c51b79..2a57147b6 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp @@ -31,12 +31,13 @@ #include "gui/gxs/GxsGroupShareKey.h" #include "gui/common/GroupTreeWidget.h" #include "gui/common/RSTreeWidget.h" -#include "gui/notifyqt.h" #include "gui/common/UIStateHelper.h" #include "gui/common/UserNotify.h" +#include "gui/RsGUIEventManager.h" #include "util/qtthreadsutils.h" #include "retroshare/rsgxsifacetypes.h" #include "GxsCommentDialog.h" +#include "util/DateTime.h" //#define DEBUG_GROUPFRAMEDIALOG @@ -172,7 +173,7 @@ void GxsGroupFrameDialog::initUi() processSettings(true); if (groupFrameSettingsType() != GroupFrameSettings::Nothing) { - connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); + connect(RsGUIEventManager::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); settingsChanged(); } @@ -331,7 +332,7 @@ void GxsGroupFrameDialog::updateSearchResults(const TurtleRequestId& sid) i.id = QString(it3->second.mGroupId.toStdString().c_str()); i.name = QString::fromUtf8(it3->second.mGroupName.c_str()); i.popularity = 0; // could be set to the number of hits - i.lastpost = QDateTime::fromTime_t(it3->second.mLastMessageTs); + i.lastpost = DateTime::DateTimeFromTime_t(it3->second.mLastMessageTs); i.subscribeFlags = 0; // irrelevant here i.publishKey = false ; // IS_GROUP_PUBLISHER(groupInfo.mSubscribeFlags); i.adminKey = false ; // IS_GROUP_ADMIN(groupInfo.mSubscribeFlags); @@ -403,8 +404,11 @@ uint32_t GxsGroupFrameDialog::checkDelay(uint32_t time_in_secs) return 90 * 86400; if(time_in_secs <= 250 * 86400) return 180 * 86400; - - return 365 * 86400; + if(time_in_secs <= 400 * 86400) + return 365 * 86400; + if(time_in_secs <= 1200 * 86400) + return 1095 * 86400; + return 1825 * 86400; } void GxsGroupFrameDialog::groupTreeCustomPopupMenu(QPoint point) @@ -472,23 +476,27 @@ void GxsGroupFrameDialog::groupTreeCustomPopupMenu(QPoint point) QAction *actnn = NULL; QMenu *ctxMenu2 = contextMnu.addMenu(tr("Synchronise posts of last...")) ; - actnn = ctxMenu2->addAction(tr(" 5 days" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 5)) ; if(current_sync_time == 5) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 2 weeks" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 15)) ; if(current_sync_time == 15) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 1 month" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 30)) ; if(current_sync_time == 30) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 3 months" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 90)) ; if(current_sync_time == 90) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 6 months" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant(180)) ; if(current_sync_time ==180) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 1 year " ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant(365)) ; if(current_sync_time ==365) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" Indefinitly"),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 0)) ; if(current_sync_time == 0) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr("5 days" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 5)) ; if(current_sync_time == 5) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr("2 weeks" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 15)) ; if(current_sync_time == 15) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr("1 month" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 30)) ; if(current_sync_time == 30) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr("3 months" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 90)) ; if(current_sync_time == 90) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr("6 months" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 180)) ; if(current_sync_time == 180) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr("1 year" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 365)) ; if(current_sync_time == 365) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr("3 years" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant(1095)) ; if(current_sync_time ==1095) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr("5 years" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant(1825)) ; if(current_sync_time ==1825) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr("Indefinitly"),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 0)) ; if(current_sync_time == 0) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} ctxMenu2->setEnabled(isSubscribed); ctxMenu2 = contextMnu.addMenu(tr("Store posts for at most...")) ; - actnn = ctxMenu2->addAction(tr(" 5 days" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 5)) ; if(current_store_time == 5) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 2 weeks" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 15)) ; if(current_store_time == 15) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 1 month" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 30)) ; if(current_store_time == 30) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 3 months" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 90)) ; if(current_store_time == 90) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 6 months" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant(180)) ; if(current_store_time ==180) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 1 year " ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant(365)) ; if(current_store_time ==365) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" Indefinitly"),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 0)) ; if(current_store_time == 0) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr("5 days" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 5)) ; if(current_store_time == 5) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr("2 weeks" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 15)) ; if(current_store_time == 15) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr("1 month" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 30)) ; if(current_store_time == 30) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr("3 months" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 90)) ; if(current_store_time == 90) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr("6 months" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 180)) ; if(current_store_time == 180) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr("1 year" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 365)) ; if(current_store_time == 365) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr("3 years" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant(1095)) ; if(current_store_time ==1095) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr("5 years" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant(1825)) ; if(current_store_time ==1825) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr("Indefinitly"),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 0)) ; if(current_store_time == 0) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} ctxMenu2->setEnabled(isSubscribed); if (shareKeyType()) { @@ -950,7 +958,7 @@ void GxsGroupFrameDialog::groupInfoToGroupItemInfo(const RsGxsGenericGroupData * groupItemInfo.id = QString::fromStdString(groupInfo->mMeta.mGroupId.toStdString()); groupItemInfo.name = QString::fromUtf8(groupInfo->mMeta.mGroupName.c_str()); groupItemInfo.popularity = groupInfo->mMeta.mPop; - groupItemInfo.lastpost = QDateTime::fromTime_t(groupInfo->mMeta.mLastPost); + groupItemInfo.lastpost = DateTime::DateTimeFromTime_t(groupInfo->mMeta.mLastPost); groupItemInfo.subscribeFlags = groupInfo->mMeta.mSubscribeFlags; groupItemInfo.publishKey = IS_GROUP_PUBLISHER(groupInfo->mMeta.mSubscribeFlags) ; groupItemInfo.adminKey = IS_GROUP_ADMIN(groupInfo->mMeta.mSubscribeFlags) ; diff --git a/retroshare-gui/src/gui/gxs/GxsMessageFrameWidget.cpp b/retroshare-gui/src/gui/gxs/GxsMessageFrameWidget.cpp index 1f55f514f..8a42911ac 100644 --- a/retroshare-gui/src/gui/gxs/GxsMessageFrameWidget.cpp +++ b/retroshare-gui/src/gui/gxs/GxsMessageFrameWidget.cpp @@ -35,7 +35,7 @@ GxsMessageFrameWidget::GxsMessageFrameWidget(RsGxsIfaceHelper *ifaceImpl, QWidge mAcknowledgeReadStatusToken = 0; /* Add dummy entry to store waiting status */ - mStateHelper->addWidget(mTokenTypeAcknowledgeReadStatus, NULL, 0); + mStateHelper->addWidget(mTokenTypeAcknowledgeReadStatus, NULL, UIStates()); } GxsMessageFrameWidget::~GxsMessageFrameWidget() diff --git a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.h b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.h index 2a983bf8d..4a97167ed 100644 --- a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.h +++ b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.h @@ -40,7 +40,7 @@ class RsGxsUpdateBroadcastPage : public MainPage Q_OBJECT public: - RsGxsUpdateBroadcastPage(RsGxsIfaceHelper* ifaceImpl, QWidget *parent = NULL, Qt::WindowFlags flags = 0); + RsGxsUpdateBroadcastPage(RsGxsIfaceHelper* ifaceImpl, QWidget *parent = NULL, Qt::WindowFlags flags = Qt::WindowFlags()); virtual ~RsGxsUpdateBroadcastPage(); void fillComplete(); diff --git a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.h b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.h index 016c58214..71ac4b75b 100644 --- a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.h +++ b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.h @@ -40,7 +40,7 @@ class RsGxsUpdateBroadcastWidget : public QWidget Q_OBJECT public: - RsGxsUpdateBroadcastWidget(RsGxsIfaceHelper* ifaceImpl, QWidget *parent = NULL, Qt::WindowFlags flags = 0); + RsGxsUpdateBroadcastWidget(RsGxsIfaceHelper* ifaceImpl, QWidget *parent = NULL, Qt::WindowFlags flags = Qt::WindowFlags()); virtual ~RsGxsUpdateBroadcastWidget(); void fillComplete(); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp index 47317c801..31dcc25a1 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp @@ -32,10 +32,10 @@ #include "gui/gxs/GxsGroupShareKey.h" #include "gui/feeds/GxsChannelPostItem.h" #include "gui/settings/rsharesettings.h" -#include "gui/notifyqt.h" #include "gui/common/GroupTreeWidget.h" #include "util/qtthreadsutils.h" #include "util/misc.h" +#include "util/RsQtVersion.h" // class GxsChannelGroupInfoData : public RsUserdata // { diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp index 16cf96195..dd0163371 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp @@ -283,7 +283,13 @@ void ZoomableLabel::wheelEvent(QWheelEvent *me) if(!mZoomEnabled) return; - float new_zoom_factor = (me->delta() > 0)?(mZoomFactor*1.05):(mZoomFactor/1.05); +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) + int delta = me->angleDelta().y(); +#else + int delta = me->delta(); +#endif + + float new_zoom_factor = (delta > 0)?(mZoomFactor*1.05):(mZoomFactor/1.05); float new_center_x = mCenterX; float new_center_y = mCenterY; @@ -309,6 +315,24 @@ void ZoomableLabel::wheelEvent(QWheelEvent *me) updateView(); } +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) +void ZoomableLabel::enterEvent(QEnterEvent* /*event*/) +#else +void ZoomableLabel::enterEvent(QEvent* /*event*/) +#endif +{ + if (mUseStyleSheet) { + setStyleSheet("QLabel { border: 2px solid #039bd5; }"); + } +} + +void ZoomableLabel::ZoomableLabel::leaveEvent(QEvent* /*event*/) +{ + if (mUseStyleSheet) { + setStyleSheet("QLabel { border: 2px solid #CCCCCC; border-radius: 3px; }"); + } +} + QPixmap ZoomableLabel::extractCroppedScaledPicture() const { QRect rect(mCenterX - 0.5 * width()*mZoomFactor, mCenterY - 0.5 * height()*mZoomFactor, width()*mZoomFactor, height()*mZoomFactor); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h index 7ee928f9e..da30f2083 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h @@ -64,8 +64,12 @@ protected: void resizeEvent(QResizeEvent *ev) override; void wheelEvent(QWheelEvent *me) override; - void enterEvent(QEvent * /* ev */ ) override { if(mUseStyleSheet) setStyleSheet("QLabel { border: 2px solid #039bd5; }");} - void leaveEvent(QEvent * /* ev */ ) override { if(mUseStyleSheet) setStyleSheet("QLabel { border: 2px solid #CCCCCC; border-radius: 3px; }");} +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) + void enterEvent(QEnterEvent *event) override; +#else + void enterEvent(QEvent *event) override; +#endif + void leaveEvent(QEvent *event) override; bool mUseStyleSheet; diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp index 8b5b7e707..45b465955 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp @@ -53,7 +53,7 @@ RsGxsChannelPostsModel::RsGxsChannelPostsModel(QObject *parent) RsGxsChannelPostsModel::~RsGxsChannelPostsModel() { - rsEvents->unregisterEventsHandler(mEventHandlerId); +// rsEvents->unregisterEventsHandler(mEventHandlerId); } void RsGxsChannelPostsModel::setMode(TreeMode mode) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h index c447f11a3..b0829c28c 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h @@ -256,6 +256,6 @@ private: QColor mTextColorNotSubscribed ; QColor mTextColorMissing ; - RsEventsHandlerId_t mEventHandlerId ; + //RsEventsHandlerId_t mEventHandlerId ; friend class const_iterator; }; diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 18aa2ad17..aa0525745 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -30,17 +30,18 @@ #include "gui/feeds/GxsChannelPostItem.h" #include "gui/gxs/GxsIdDetails.h" #include "gui/gxs/GxsGroupFrameDialog.h" +#include "gui/RsGUIEventManager.h" #include "util/misc.h" #include "gui/gxschannels/CreateGxsChannelMsg.h" #include "gui/common/UIStateHelper.h" #include "gui/settings/rsharesettings.h" #include "gui/feeds/SubFileItem.h" -#include "gui/notifyqt.h" #include "gui/RetroShareLink.h" #include "util/HandleRichText.h" #include "util/DateTime.h" #include "util/qtthreadsutils.h" #include "gui/common/FilesDefs.h" +#include "util/RsQtVersion.h" #include "GxsChannelPostsWidgetWithModel.h" #include "GxsChannelPostsModel.h" @@ -226,7 +227,7 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & y += font_height; y += font_height/2.0; - QString info_text = QDateTime::fromMSecsSinceEpoch(qint64(1000)*post.mMeta.mPublishTs).toString(Qt::DefaultLocaleShortDate); + QString info_text = QLocale::system().toString(DateTime::DateTimeFromTime_t(post.mMeta.mPublishTs), QLocale::ShortFormat); if(post.mAttachmentCount > 0) info_text += ", " + QString::number(post.mAttachmentCount)+ " " +((post.mAttachmentCount>1)?tr("files"):tr("file")) + " (" + misc::friendlyUnit(qulonglong(post.mSize)) + ")" ; @@ -354,9 +355,9 @@ QSize ChannelPostFilesDelegate::sizeHint(const QStyleOptionViewItem& option, con switch(index.column()) { - case RsGxsChannelPostFilesModel::COLUMN_FILES_NAME: return QSize(1.1*fm.width(QString::fromUtf8(file.mName.c_str())),fm.height()); - case RsGxsChannelPostFilesModel::COLUMN_FILES_SIZE: return QSize(1.1*fm.width(misc::friendlyUnit(qulonglong(file.mSize))),fm.height()); - case RsGxsChannelPostFilesModel::COLUMN_FILES_DATE: return QSize(1.1*fm.width(QDateTime::fromMSecsSinceEpoch(file.mPublishTime*1000).toString("MM/dd/yyyy, hh:mm")),fm.height()); + case RsGxsChannelPostFilesModel::COLUMN_FILES_NAME: return QSize(1.1*QFontMetrics_horizontalAdvance(fm, QString::fromUtf8(file.mName.c_str())),fm.height()); + case RsGxsChannelPostFilesModel::COLUMN_FILES_SIZE: return QSize(1.1*QFontMetrics_horizontalAdvance(fm, misc::friendlyUnit(qulonglong(file.mSize))),fm.height()); + case RsGxsChannelPostFilesModel::COLUMN_FILES_DATE: return QSize(1.1*QFontMetrics_horizontalAdvance(fm, QDateTime::fromMSecsSinceEpoch(file.mPublishTime*1000).toString("MM/dd/yyyy, hh:mm")),fm.height()); default: case RsGxsChannelPostFilesModel::COLUMN_FILES_FILE: return QSize(option.rect.width(),GxsChannelFilesStatusWidget(file).height()); } @@ -445,7 +446,7 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI /* Connect signals */ connect(ui->postButton, SIGNAL(clicked()), this, SLOT(createMsg())); connect(ui->subscribeToolButton, SIGNAL(subscribe(bool)), this, SLOT(subscribeGroup(bool))); - connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); + connect(RsGUIEventManager::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); ui->postButton->setText(tr("Add new post")); @@ -462,8 +463,8 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI QHeaderView * channelpostfilesheader = ui->channelPostFiles_TV->header () ; QHeaderView * channelfilesheader = ui->channelFiles_TV->header () ; - channelpostfilesheader->resizeSection (RsGxsChannelPostFilesModel::COLUMN_FILES_NAME, fm.width("RetroShare-v0.6.5-1487-g6714648e5-Windows-x64-portable-20200518-Qt-5.14.2.7z")); - channelfilesheader->resizeSection (RsGxsChannelPostFilesModel::COLUMN_FILES_NAME, fm.width("RetroShare-v0.6.5-1487-g6714648e5-Windows-x64-portable-20200518-Qt-5.14.2.7z")); + channelpostfilesheader->resizeSection (RsGxsChannelPostFilesModel::COLUMN_FILES_NAME, QFontMetrics_horizontalAdvance(fm, "RetroShare-v0.6.5-1487-g6714648e5-Windows-x64-portable-20200518-Qt-5.14.2.7z")); + channelfilesheader->resizeSection (RsGxsChannelPostFilesModel::COLUMN_FILES_NAME, QFontMetrics_horizontalAdvance(fm, "RetroShare-v0.6.5-1487-g6714648e5-Windows-x64-portable-20200518-Qt-5.14.2.7z")); /* Initialize feed widget */ //ui->feedWidget->setSortRole(ROLE_PUBLISH, Qt::DescendingOrder); @@ -1296,6 +1297,8 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou case 90: sync_string = tr("3 months"); break; case 180: sync_string = tr("6 months"); break; case 365: sync_string = tr("1 year"); break; + case 1095: sync_string = tr("3 years") ; break; + case 1825: sync_string = tr("5 years") ; break; case 0: sync_string = tr("indefinitly"); break; default: sync_string = tr("Unknown"); @@ -1454,7 +1457,7 @@ void GxsChannelPostsWidgetWithModel::switchOnlyUnread(bool) } void GxsChannelPostsWidgetWithModel::filterChanged(QString s) { - QStringList ql = s.split(' ',QString::SkipEmptyParts); + QStringList ql = s.split(' ',QtSkipEmptyParts); uint32_t count; mChannelPostsModel->setFilter(ql,ui->showUnread_TB->isChecked(),count); mChannelFilesModel->setFilter(ql,count); diff --git a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp index 4236b6f04..e7a3a3146 100644 --- a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp +++ b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp @@ -23,7 +23,6 @@ #include #include -#include #include #include #include @@ -449,7 +448,7 @@ void CreateGxsForumMsg::createMsg() default: std::cerr << "CreateGxsForumMsg::createMsg() ERROR GETTING AuthorId!"; std::cerr << std::endl; - QMessageBox::warning(this, tr("RetroShare"),tr("Congrats, you found a bug!")+" "+QString(__FILE__)+":"+QString(__LINE__), QMessageBox::Ok, QMessageBox::Ok); + QMessageBox::warning(this, tr("RetroShare"),tr("Congrats, you found a bug!")+" "+QString(__FILE__)+":"+QString::number(__LINE__), QMessageBox::Ok, QMessageBox::Ok); return; }//switch (ui->idChooser->getChosenId(authorId)) diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp index 18f518749..270a98a15 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp @@ -418,7 +418,7 @@ QVariant RsGxsForumModel::data(const QModelIndex &index, int role) const case Qt::DecorationRole: return decorationRole(fmpe,index.column()) ; case Qt::ToolTipRole: return toolTipRole (fmpe,index.column()) ; case Qt::UserRole: return userRole (fmpe,index.column()) ; - case Qt::TextColorRole: return textColorRole (fmpe,index.column()) ; + case Qt::ForegroundRole: return textColorRole (fmpe,index.column()) ; case Qt::BackgroundRole: return backgroundRole(fmpe,index.column()) ; case FilterRole: return filterRole (fmpe,index.column()) ; @@ -670,8 +670,7 @@ QVariant RsGxsForumModel::displayRole(const ForumModelPostEntry& fmpe,int col) c if(fmpe.mPostFlags & ForumModelPostEntry::FLAG_POST_IS_MISSING) return QVariant(QString()); - QDateTime qtime; - qtime.setTime_t(fmpe.mPublishTs); + QDateTime qtime = DateTime::DateTimeFromTime_t(fmpe.mPublishTs); return QVariant(DateTime::formatDateTime(qtime)); } diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index fd293560f..b8545b077 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -44,7 +44,7 @@ #include "gui/msgs/MessageComposer.h" #include "util/DateTime.h" #include "gui/common/UIStateHelper.h" -#include "util/QtVersion.h" +#include "util/RsQtVersion.h" #include "util/imageutil.h" #include @@ -219,7 +219,11 @@ public: if(left_is_not_pinned ^ right_is_not_pinned) return (m_header->sortIndicatorOrder()==Qt::AscendingOrder)?right_is_not_pinned:left_is_not_pinned ; // always put pinned posts on top +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) + return QVariant::compare(left.data(RsGxsForumModel::SortRole), right.data(RsGxsForumModel::SortRole)) < 0; +#else return left.data(RsGxsForumModel::SortRole) < right.data(RsGxsForumModel::SortRole) ; +#endif } bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override @@ -264,7 +268,7 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget ui->threadTreeWidget->setModel(mThreadProxyModel); mThreadProxyModel->setFilterRole(RsGxsForumModel::FilterRole); - mThreadProxyModel->setFilterRegExp(QRegExp(QString(RsGxsForumModel::FilterString))) ; + QSortFilterProxyModel_setFilterRegularExpression(mThreadProxyModel, QString(RsGxsForumModel::FilterString)) ; ui->threadTreeWidget->setSortingEnabled(true); @@ -540,7 +544,7 @@ void GxsForumThreadWidget::recursSaveExpandedItems(const QModelIndex& index, QLi if(ui->threadTreeWidget->isExpanded(index)) { for(int row=0;rowrowCount(index);++row) - recursSaveExpandedItems(index.child(row,0),expanded_items) ; + recursSaveExpandedItems(mThreadProxyModel->index(row,0,index),expanded_items) ; RsGxsMessageId message_id(index.sibling(index.row(),RsGxsForumModel::COLUMN_THREAD_MSGID).data(Qt::UserRole).toString().toStdString()); expanded_items.push_back(message_id); @@ -966,13 +970,15 @@ static QString getDurationString(uint32_t days) { switch(days) { - case 0: return QObject::tr("Indefinitely") ; - case 5: return QObject::tr("5 days") ; - case 15: return QObject::tr("2 weeks") ; - case 30: return QObject::tr("1 month") ; - case 60: return QObject::tr("2 month") ; - case 180: return QObject::tr("6 month") ; - case 365: return QObject::tr("1 year") ; + case 0: return QObject::tr("Indefinitely") ; break; + case 5: return QObject::tr("5 days") ; break; + case 15: return QObject::tr("2 weeks") ; break; + case 30: return QObject::tr("1 month") ; break; + case 60: return QObject::tr("2 month") ; break; + case 180: return QObject::tr("6 month") ; break; + case 365: return QObject::tr("1 year") ; break; + case 1095: return QObject::tr("3 years") ; break; + case 1825: return QObject::tr("5 years") ; break; default: return QString::number(days)+" " + QObject::tr("days") ; } @@ -1846,7 +1852,7 @@ void GxsForumThreadWidget::filterColumnChanged(int column) void GxsForumThreadWidget::filterItems(const QString& text) { - QStringList lst = text.split(" ",QString::SkipEmptyParts) ; + QStringList lst = text.split(" ",QtSkipEmptyParts) ; int filterColumn = ui->filterLineEdit->currentFilter(); @@ -1854,7 +1860,7 @@ void GxsForumThreadWidget::filterItems(const QString& text) mThreadModel->setFilter(filterColumn,lst,count) ; // We do this in order to trigger a new filtering action in the proxy model. - mThreadProxyModel->setFilterRegExp(QRegExp(QString(RsGxsForumModel::FilterString))) ; + QSortFilterProxyModel_setFilterRegularExpression(mThreadProxyModel, QString(RsGxsForumModel::FilterString)) ; if(!lst.empty()) ui->threadTreeWidget->expandAll(); diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp index 5733d5a39..a8a9f2b0a 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp @@ -23,7 +23,6 @@ #include "GxsForumThreadWidget.h" #include "CreateGxsForumMsg.h" #include "GxsForumUserNotify.h" -#include "gui/notifyqt.h" #include "gui/common/GroupTreeWidget.h" #include "gui/gxs/GxsGroupShareKey.h" #include "util/misc.h" diff --git a/retroshare-gui/src/gui/help/browser/helpbrowser.cpp b/retroshare-gui/src/gui/help/browser/helpbrowser.cpp index f062b908c..1da6fb4cf 100644 --- a/retroshare-gui/src/gui/help/browser/helpbrowser.cpp +++ b/retroshare-gui/src/gui/help/browser/helpbrowser.cpp @@ -104,7 +104,7 @@ HelpBrowser::HelpBrowser(QWidget *parent) /* Show the first help topic in the tree */ ui.treeContents->setCurrentItem(ui.treeContents->topLevelItem(0)); - ui.treeContents->setItemExpanded(ui.treeContents->topLevelItem(0), true); + ui.treeContents->topLevelItem(0)->setExpanded(true); } HelpBrowser::~HelpBrowser() @@ -231,7 +231,7 @@ HelpBrowser::contentsItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *prev QList selected = ui.treeSearch->selectedItems(); /* Deselect the selection in the search tree */ if (!selected.isEmpty()) { - ui.treeSearch->setItemSelected(selected[0], false); + selected[0]->setSelected(false); } currentItemChanged(current, prev); } @@ -243,7 +243,7 @@ HelpBrowser::searchItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *prev) QList selected = ui.treeContents->selectedItems(); /* Deselect the selection in the contents tree */ if (!selected.isEmpty()) { - ui.treeContents->setItemSelected(selected[0], false); + selected[0]->setSelected(false); } /* Change to selected page */ @@ -288,7 +288,7 @@ HelpBrowser::findTopicItem(QTreeWidgetItem *startItem, QString topic) if (subtopic == item->data(0, ROLE_TOPIC_ID).toString().toLower()) { /* Found a subtopic match, so expand this item */ - ui.treeContents->setItemExpanded(item, true); + item->setSelected(true); if (!topic.contains(".")) { /* Found the exact topic */ return item; @@ -314,10 +314,10 @@ HelpBrowser::showTopic(QString topic) * tree item. */ QTreeWidgetItem* selected = ui.treeContents->selectedItems()[0]; if (selected) { - ui.treeContents->setItemSelected(selected, false); + selected->setSelected(false); } - ui.treeContents->setItemExpanded(ui.treeContents->topLevelItem(0), true); - ui.treeContents->setItemSelected(item, true); + ui.treeContents->topLevelItem(0)->setExpanded(true); + item->setSelected(true); currentItemChanged(item, selected); } } @@ -348,7 +348,7 @@ HelpBrowser::find(bool forward) return; } - QTextDocument::FindFlags flags = 0; + QTextDocument::FindFlags flags = QTextDocument::FindFlags(); QTextCursor cursor = ui.txtBrowser->textCursor(); QString searchPhrase = ui.lineFind->text(); diff --git a/retroshare-gui/src/gui/im_history/IMHistoryItemPainter.cpp b/retroshare-gui/src/gui/im_history/IMHistoryItemPainter.cpp index b75af79d0..a015cf95e 100644 --- a/retroshare-gui/src/gui/im_history/IMHistoryItemPainter.cpp +++ b/retroshare-gui/src/gui/im_history/IMHistoryItemPainter.cpp @@ -44,7 +44,7 @@ void IMHistoryItemPainter::paint(QPainter *painter, const QStyleOptionViewItem & // if (mode == Editable) { // painter->setBrush(option.palette.highlight()); // } else { - painter->setBrush(option.palette.foreground()); + painter->setBrush(option.palette.windowText()); // } if (option.state & QStyle::State_Selected) { painter->fillRect(option.rect, option.palette.highlight()); diff --git a/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp b/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp index 9f5f88e74..8f006906a 100644 --- a/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp +++ b/retroshare-gui/src/gui/im_history/ImHistoryBrowser.cpp @@ -32,13 +32,14 @@ #include "IMHistoryItemDelegate.h" #include "IMHistoryItemPainter.h" #include "util/HandleRichText.h" +#include "util/qtthreadsutils.h" #include "gui/common/FilesDefs.h" #include "rshare.h" #include #include #include "gui/settings/rsharesettings.h" -#include "gui/notifyqt.h" +#include "util/DateTime.h" #define ROLE_MSGID Qt::UserRole #define ROLE_PLAINTEXT Qt::UserRole + 1 @@ -100,8 +101,6 @@ ImHistoryBrowser::ImHistoryBrowser(const ChatId &chatId, QTextEdit *edit,const Q m_chatId = chatId; textEdit = edit; - connect(NotifyQt::getInstance(), SIGNAL(historyChanged(uint, int)), this, SLOT(historyChanged(uint, int))); - connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString))); connect(ui.copyButton, SIGNAL(clicked()), SLOT(copyMessage())); @@ -137,6 +136,22 @@ ImHistoryBrowser::ImHistoryBrowser(const ChatId &chatId, QTextEdit *edit,const Q connect(m_createThread, SIGNAL(finished()), this, SLOT(createThreadFinished())); connect(m_createThread, SIGNAL(progress(int,int)), this, SLOT(createThreadProgress(int,int))); m_createThread->start(); + + mEventHandlerId = 0; + + rsEvents->registerEventsHandler( [this](std::shared_ptr event) + { + RsQThreadUtils::postToObject([=](){ + + auto ev = dynamic_cast(event.get()); + + if(!ev) + return; + + if(ev->mEventCode == RsChatServiceEventCode::CHAT_HISTORY_CHANGED) + historyChanged(ev->mMsgHistoryId,ev->mHistoryChangeType); + }, this ); + }, mEventHandlerId, RsEventType::CHAT_SERVICE ); } ImHistoryBrowser::~ImHistoryBrowser() @@ -220,9 +235,9 @@ void ImHistoryBrowser::historyAdd(HistoryMsg& msg) } } -void ImHistoryBrowser::historyChanged(uint msgId, int type) +void ImHistoryBrowser::historyChanged(uint msgId, RsChatHistoryChangeFlags type) { - if (type == NOTIFY_TYPE_ADD) { + if (type == RsChatHistoryChangeFlags::ADD) { /* history message added */ HistoryMsg msg; if (rsHistory->getMessage(msgId, msg) == false) { @@ -236,7 +251,7 @@ void ImHistoryBrowser::historyChanged(uint msgId, int type) return; } - if (type == NOTIFY_TYPE_DEL) { + if (type == RsChatHistoryChangeFlags::DEL) { /* history message removed */ int count = ui.listWidget->count(); for (int i = 0; i < count; ++i) { @@ -249,7 +264,7 @@ void ImHistoryBrowser::historyChanged(uint msgId, int type) return; } - if (type == NOTIFY_TYPE_MOD) { + if (type == RsChatHistoryChangeFlags::MOD) { /* clear history */ // As no ChatId nor msgId are send via Notify, // only check if history of this chat is empty before clear our list. @@ -292,9 +307,9 @@ void ImHistoryBrowser::fillItem(QListWidgetItem *itemWidget, HistoryMsg& msg) } QColor backgroundColor = ui.listWidget->palette().base().color(); - QString formatMsg = style.formatMessage(type, name, QDateTime::fromTime_t(msg.sendTime), messageText, 0, backgroundColor); + QString formatMsg = style.formatMessage(type, name, DateTime::DateTimeFromTime_t(msg.sendTime), messageText, 0, backgroundColor); - itemWidget->setData(Qt::DisplayRole, qVariantFromValue(IMHistoryItemPainter(formatMsg))); + itemWidget->setData(Qt::DisplayRole, QVariant::fromValue(IMHistoryItemPainter(formatMsg))); itemWidget->setData(ROLE_MSGID, msg.msgId); /* calculate plain text */ @@ -467,8 +482,8 @@ QString ImHistoryBrowser::getCurrentItemsQuotedText() ? QString::fromUtf8(details.mNickname.c_str()) : QString::fromUtf8(msg.peerName.c_str()); QDateTime date = msg.incoming - ? QDateTime::fromTime_t(msg.sendTime) - : QDateTime::fromTime_t(msg.recvTime); + ? DateTime::DateTimeFromTime_t(msg.sendTime) + : DateTime::DateTimeFromTime_t(msg.recvTime); QTextDocument doc; doc.setHtml(QString::fromUtf8(msg.message.c_str())); diff --git a/retroshare-gui/src/gui/im_history/ImHistoryBrowser.h b/retroshare-gui/src/gui/im_history/ImHistoryBrowser.h index 84ee95234..0ebf2353e 100644 --- a/retroshare-gui/src/gui/im_history/ImHistoryBrowser.h +++ b/retroshare-gui/src/gui/im_history/ImHistoryBrowser.h @@ -52,7 +52,7 @@ private slots: void createThreadFinished(); void createThreadProgress(int current, int count); - void historyChanged(uint msgId, int type); + void historyChanged(uint msgId, RsChatHistoryChangeFlags type); void filterChanged(const QString& text); @@ -86,6 +86,7 @@ private: /** Qt Designer generated object */ Ui::ImHistoryBrowser ui; + RsEventsHandlerId_t mEventHandlerId; }; class ImHistoryBrowserCreateItemsThread : public QThread diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index 0ee408685..de8863449 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include @@ -50,7 +51,6 @@ #include #include -#include "gui/notifyqt.h" #include "gui/common/RSTreeWidgetItem.h" #include "gui/common/GroupDefs.h" #include "gui/common/StatusDefs.h" @@ -65,7 +65,8 @@ #include "util/misc.h" #include "util/DateTime.h" #include "util/HandleRichText.h" -#include "util/QtVersion.h" +#include "util/qtthreadsutils.h" +#include "util/RsQtVersion.h" #include "textformat.h" #include "TagsMenu.h" @@ -214,7 +215,19 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags) connect(ui.addBccButton, SIGNAL(clicked()), this, SLOT(addBcc())); connect(ui.addRecommendButton, SIGNAL(clicked()), this, SLOT(addRecommend())); - connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(peerStatusChanged(QString,int))); + rsEvents->registerEventsHandler( [this](std::shared_ptr e) + { + RsQThreadUtils::postToObject([=](){ + auto fe = dynamic_cast(e.get()); + + if(!fe || fe->mEventCode != RsFriendListEventCode::NODE_STATUS_CHANGED) + return; + + peerStatusChanged(QString::fromStdString(fe->mSslId.toStdString()),fe->mStatus); + + }, this ); + },mEventHandlerId,RsEventType::FRIEND_LIST); + connect(ui.friendSelectionWidget, SIGNAL(contentChanged()), this, SLOT(buildCompleter())); connect(ui.friendSelectionWidget, SIGNAL(doubleClicked(int,QString)), this, SLOT(addTo())); connect(ui.friendSelectionWidget, SIGNAL(itemSelectionChanged()), this, SLOT(friendSelectionChanged())); @@ -420,6 +433,7 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags) MessageComposer::~MessageComposer() { + rsEvents->unregisterEventsHandler(mEventHandlerId); delete(m_compareRole); } @@ -811,7 +825,7 @@ void MessageComposer::buildCompleter() setNewCompleter(ui.recipientWidget, m_completer); } -void MessageComposer::peerStatusChanged(const QString& peer_id, int status) +void MessageComposer::peerStatusChanged(const QString& peer_id, RsStatusValue status) { int rowCount = ui.recipientWidget->rowCount(); int row; @@ -2402,8 +2416,13 @@ bool MessageComposer::fileSave() if (!file.open(QFile::WriteOnly)) return false; QTextStream ts(&file); +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) + ts.setEncoding(QStringConverter::Utf8); + ts << ui.msgText->document()->toHtml(); +#else ts.setCodec(QTextCodec::codecForName("UTF-8")); ts << ui.msgText->document()->toHtml("UTF-8"); +#endif std::cerr << "Setting modified 002 = false" << std::endl; ui.msgText->document()->setModified(false); return true; @@ -2432,7 +2451,7 @@ void MessageComposer::filePrint() printer.setFullPage(true); QPrintDialog *dlg = new QPrintDialog(&printer, this); if (ui.msgText->textCursor().hasSelection()) - dlg->addEnabledOption(QAbstractPrintDialog::PrintSelection); + dlg->setOption(QPrintDialog::PrintSelection); dlg->setWindowTitle(tr("Print Document")); if (dlg->exec() == QDialog::Accepted) { ui.msgText->print(&printer); diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.h b/retroshare-gui/src/gui/msgs/MessageComposer.h index 27bf28458..180840208 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.h +++ b/retroshare-gui/src/gui/msgs/MessageComposer.h @@ -52,7 +52,7 @@ public: public: /** Default Constructor */ - MessageComposer(QWidget *parent = 0, Qt::WindowFlags flags = 0); + MessageComposer(QWidget *parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); ~MessageComposer(); static void msgFriend(const RsPeerId &id); @@ -157,7 +157,7 @@ private slots: void editingRecipientFinished(); void contactDetails(); - void peerStatusChanged(const QString& peer_id, int status); + void peerStatusChanged(const QString& peer_id, RsStatusValue status); void friendSelectionChanged(); void tagAboutToShow(); @@ -274,6 +274,7 @@ private: Ui::MessageComposer ui; std::list _recList ; + RsEventsHandlerId_t mEventHandlerId; }; #endif diff --git a/retroshare-gui/src/gui/msgs/MessageModel.cpp b/retroshare-gui/src/gui/msgs/MessageModel.cpp index dc2f16c7c..17185771b 100644 --- a/retroshare-gui/src/gui/msgs/MessageModel.cpp +++ b/retroshare-gui/src/gui/msgs/MessageModel.cpp @@ -273,7 +273,7 @@ QVariant RsMessageModel::data(const QModelIndex &index, int role) const case Qt::DecorationRole: return decorationRole(fmpe,index.column()) ; case Qt::ToolTipRole: return toolTipRole (fmpe,index.column()) ; case Qt::UserRole: return userRole (fmpe,index.column()) ; - case Qt::TextColorRole: return textColorRole (fmpe,index.column()) ; + case Qt::ForegroundRole: return textColorRole (fmpe,index.column()) ; case Qt::BackgroundRole: return backgroundRole(fmpe,index.column()) ; case FilterRole: return filterRole (fmpe,index.column()) ; @@ -504,8 +504,7 @@ QVariant RsMessageModel::displayRole(const Rs::Msgs::MsgInfoSummary& fmpe,int co case COLUMN_THREAD_SPAM: case COLUMN_THREAD_READ:return QVariant(); case COLUMN_THREAD_DATE:{ - QDateTime qtime; - qtime.setTime_t(fmpe.ts); + QDateTime qtime = DateTime::DateTimeFromTime_t(fmpe.ts); return QVariant(DateTime::formatDateTime(qtime)); } diff --git a/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp b/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp index b29f264fb..dc338db3e 100644 --- a/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp +++ b/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp @@ -20,7 +20,6 @@ #include "gui/common/FilesDefs.h" #include "MessageUserNotify.h" -#include "gui/notifyqt.h" #include "gui/MainWindow.h" #include "util/qtthreadsutils.h" #include "gui/settings/rsharesettings.h" @@ -97,12 +96,7 @@ void MessageUserNotify::handleEvent_main_thread(std::shared_ptr e switch (fe->mMailStatusEventCode) { case RsMailStatusEventCode::NEW_MESSAGE: - for (it = fe->mChangedMsgIds.begin(); it != fe->mChangedMsgIds.end(); ++it) { - MessageInfo msgInfo; - if (rsMail->getMessage(*it, msgInfo)) { - NotifyQt::getInstance()->addToaster(RS_POPUP_MSG, msgInfo.msgId.c_str(), msgInfo.title.c_str(), msgInfo.msg.c_str() ); - } - } + updateIcon(); break; case RsMailStatusEventCode::MESSAGE_CHANGED: diff --git a/retroshare-gui/src/gui/msgs/MessageWidget.cpp b/retroshare-gui/src/gui/msgs/MessageWidget.cpp index 0d2e934f2..2f81b749d 100644 --- a/retroshare-gui/src/gui/msgs/MessageWidget.cpp +++ b/retroshare-gui/src/gui/msgs/MessageWidget.cpp @@ -31,7 +31,6 @@ #include #include -#include "gui/notifyqt.h" #include "gui/RetroShareLink.h" #include "gui/common/TagDefs.h" #include "gui/common/PeerDefs.h" @@ -45,7 +44,7 @@ #include "util/printpreview.h" #include "util/HandleRichText.h" #include "util/DateTime.h" -#include "util/QtVersion.h" +#include "util/RsQtVersion.h" #include "util/qtthreadsutils.h" #include @@ -261,7 +260,9 @@ void MessageWidget::handleEvent_main_thread(std::shared_ptr event case RsMailStatusEventCode::MESSAGE_RECEIVED_ACK: case RsMailStatusEventCode::SIGNATURE_FAILED: break; - } + default: + break; + } } void MessageWidget::connectAction(enumActionType actionType, QToolButton* button) @@ -640,7 +641,7 @@ void MessageWidget::fill(const std::string &msgId) ui.trans_ToText->setText(to_text); - int recipientsCount = ui.trans_ToText->toPlainText().split(QRegExp("(\\s|\\n|\\r)+"), QString::SkipEmptyParts).count(); + int recipientsCount = ui.trans_ToText->toPlainText().split(QRegularExpression("(\\s|\\n|\\r)+"), QtSkipEmptyParts).count(); ui.expandButton->setText( QString::number(recipientsCount)+ " " + tr("more")); if (recipientsCount >=20) { @@ -775,7 +776,7 @@ void MessageWidget::print() printer.setFullPage(true); QPrintDialog *dlg = new QPrintDialog(&printer, this); if (ui.msgText->textCursor().hasSelection()) - dlg->addEnabledOption(QAbstractPrintDialog::PrintSelection); + dlg->setOption(QPrintDialog::PrintSelection); dlg->setWindowTitle(tr("Print Document")); if (dlg->exec() == QDialog::Accepted) { ui.msgText->print(&printer); @@ -802,8 +803,13 @@ void MessageWidget::saveAs() if (!file.open(QFile::WriteOnly)) return; QTextStream ts(&file); +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) + ts.setEncoding(QStringConverter::Utf8); + ts << ui.msgText->document()->toHtml(); +#else ts.setCodec(QTextCodec::codecForName("UTF-8")); ts << ui.msgText->document()->toHtml("UTF-8"); +#endif ui.msgText->document()->setModified(false); } } diff --git a/retroshare-gui/src/gui/msgs/MessageWidget.h b/retroshare-gui/src/gui/msgs/MessageWidget.h index 53b043720..566cee2c7 100644 --- a/retroshare-gui/src/gui/msgs/MessageWidget.h +++ b/retroshare-gui/src/gui/msgs/MessageWidget.h @@ -45,7 +45,7 @@ public: }; public: - MessageWidget(bool controlled, QWidget *parent = 0, Qt::WindowFlags flags = 0); + MessageWidget(bool controlled, QWidget *parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); ~MessageWidget(); static MessageWidget *openMsg(const std::string &msgId, bool window); diff --git a/retroshare-gui/src/gui/msgs/MessageWindow.h b/retroshare-gui/src/gui/msgs/MessageWindow.h index c12b8ca3d..9f744ea8b 100644 --- a/retroshare-gui/src/gui/msgs/MessageWindow.h +++ b/retroshare-gui/src/gui/msgs/MessageWindow.h @@ -33,7 +33,7 @@ class MessageWindow : public RWindow public: /** Default Constructor */ - MessageWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0); + MessageWindow(QWidget *parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); ~MessageWindow(); void addWidget(MessageWidget *widget); diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp index 7cddc1b7d..f678adeb4 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp @@ -27,7 +27,6 @@ #include "MessagesDialog.h" -#include "gui/notifyqt.h" #include "gui/common/TagDefs.h" #include "gui/common/PeerDefs.h" #include "gui/common/RSElidedItemDelegate.h" @@ -45,7 +44,7 @@ #include "util/DateTime.h" #include "util/misc.h" -#include "util/QtVersion.h" +#include "util/RsQtVersion.h" #include "util/qtthreadsutils.h" #include "util/RsProtectedTimer.h" @@ -117,7 +116,11 @@ public: protected: bool lessThan(const QModelIndex& left, const QModelIndex& right) const override { +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) + return QVariant::compare(sourceModel()->data(left, RsMessageModel::SortRole), sourceModel()->data(right, RsMessageModel::SortRole)) < 0; +#else return sourceModel()->data(left, RsMessageModel::SortRole) < sourceModel()->data(right, RsMessageModel::SortRole) ; +#endif } bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override @@ -157,7 +160,7 @@ MessagesDialog::MessagesDialog(QWidget *parent) mMessageProxyModel->setSortRole(RsMessageModel::SortRole); mMessageProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); mMessageProxyModel->setFilterRole(RsMessageModel::FilterRole); - mMessageProxyModel->setFilterRegExp(QRegExp(RsMessageModel::FilterString)); + QSortFilterProxyModel_setFilterRegularExpression(mMessageProxyModel, RsMessageModel::FilterString); ui.messageTreeWidget->setModel(mMessageProxyModel); @@ -209,15 +212,15 @@ MessagesDialog::MessagesDialog(QWidget *parent) ui.messageTreeWidget->setColumnHidden(RsMessageModel::COLUMN_THREAD_CONTENT,true); ui.messageTreeWidget->setColumnHidden(RsMessageModel::COLUMN_THREAD_MSGID,true); - msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_STAR, fm.width('0')*1.5); - msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_ATTACHMENT, fm.width('0')*1.5); - msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_READ, fm.width('0')*1.5); - msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_SPAM, fm.width('0')*1.5); + msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_STAR, QFontMetrics_horizontalAdvance(fm, '0')*1.5); + msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_ATTACHMENT, QFontMetrics_horizontalAdvance(fm, '0')*1.5); + msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_READ, QFontMetrics_horizontalAdvance(fm, '0')*1.5); + msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_SPAM, QFontMetrics_horizontalAdvance(fm, '0')*1.5); - msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_SUBJECT, fm.width("You have a message")*3.0); - msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_AUTHOR, fm.width("[Retroshare]")*1.1); - msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_TO, fm.width("[Retroshare]")*1.1); - msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_DATE, fm.width("01/01/1970")*1.1); + msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_SUBJECT, QFontMetrics_horizontalAdvance(fm, "You have a message")*3.0); + msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_AUTHOR, QFontMetrics_horizontalAdvance(fm, "[Retroshare]")*1.1); + msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_TO, QFontMetrics_horizontalAdvance(fm, "[Retroshare]")*1.1); + msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_DATE, QFontMetrics_horizontalAdvance(fm, "01/01/1970")*1.1); msgwheader->setSectionResizeMode(RsMessageModel::COLUMN_THREAD_SUBJECT, QHeaderView::Interactive); msgwheader->setSectionResizeMode(RsMessageModel::COLUMN_THREAD_AUTHOR, QHeaderView::Interactive); @@ -305,7 +308,7 @@ MessagesDialog::MessagesDialog(QWidget *parent) rsEvents->registerEventsHandler( [this](std::shared_ptr event) { RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }); }, mEventHandlerId, RsEventType::MAIL_STATUS ); mTagEventHandlerId = 0; - rsEvents->registerEventsHandler( [this](std::shared_ptr event) { RsQThreadUtils::postToObject( [this,event]() { handleTagEvent_main_thread(event); }); }, mEventHandlerId, RsEventType::MAIL_TAG ); + rsEvents->registerEventsHandler( [this](std::shared_ptr event) { RsQThreadUtils::postToObject( [this,event]() { handleTagEvent_main_thread(event); }); }, mTagEventHandlerId, RsEventType::MAIL_TAG ); mFontSizeHandler.registerFontSize(ui.listWidget, 1.5f, [this] (QAbstractItemView*, int fontSize) { // Set new font size on all items @@ -347,6 +350,8 @@ void MessagesDialog::handleEvent_main_thread(std::shared_ptr even case RsMailStatusEventCode::MESSAGE_RECEIVED_ACK: case RsMailStatusEventCode::SIGNATURE_FAILED: break; + default: + break; } } @@ -1016,7 +1021,7 @@ void MessagesDialog::changeQuickView(int newrow) } mMessageModel->setQuickViewFilter(f); - mMessageProxyModel->setFilterRegExp(QRegExp(RsMessageModel::FilterString)); // this triggers the update of the proxy model + QSortFilterProxyModel_setFilterRegularExpression(mMessageProxyModel, RsMessageModel::FilterString); // this triggers the update of the proxy model } // click in messageTreeWidget @@ -1084,11 +1089,13 @@ void MessagesDialog::doubleClicked(const QModelIndex& proxy_index) } /* edit message */ - switch (Settings->getMsgOpen()) { - case RshareSettings::MSG_OPEN_TAB: + switch (Settings->getMsgOpen()) + { + default: + case RsSettingsMsgOptions::MSG_OPEN_TAB: openAsTab(); break; - case RshareSettings::MSG_OPEN_WINDOW: + case RsSettingsMsgOptions::MSG_OPEN_WINDOW: openAsWindow(); break; } @@ -1246,7 +1253,7 @@ void MessagesDialog::undeletemessage() void MessagesDialog::filterChanged(const QString& text) { - QStringList items = text.split(' ',QString::SkipEmptyParts); + QStringList items = text.split(' ',QtSkipEmptyParts); RsMessageModel::FilterType f = RsMessageModel::FILTER_TYPE_NONE; @@ -1263,7 +1270,7 @@ void MessagesDialog::filterChanged(const QString& text) } mMessageModel->setFilter(f,items); - mMessageProxyModel->setFilterRegExp(QRegExp(RsMessageModel::FilterString)); // this triggers the update of the proxy model + QSortFilterProxyModel_setFilterRegularExpression(mMessageProxyModel, RsMessageModel::FilterString); // this triggers the update of the proxy model QCoreApplication::processEvents(); } @@ -1287,9 +1294,9 @@ void MessagesDialog::filterColumnChanged(int column) default:break; } - QStringList items = ui.filterLineEdit->text().split(' ',QString::SkipEmptyParts); + QStringList items = ui.filterLineEdit->text().split(' ',QtSkipEmptyParts); mMessageModel->setFilter(f,items); - mMessageProxyModel->setFilterRegExp(QRegExp(RsMessageModel::FilterString)); // this triggers the update of the proxy model + QSortFilterProxyModel_setFilterRegularExpression(mMessageProxyModel, RsMessageModel::FilterString); // this triggers the update of the proxy model // save index Settings->setValueToGroup("MessageDialog", "filterColumn", column); diff --git a/retroshare-gui/src/gui/msgs/TagsMenu.cpp b/retroshare-gui/src/gui/msgs/TagsMenu.cpp index 881ec268d..986416514 100644 --- a/retroshare-gui/src/gui/msgs/TagsMenu.cpp +++ b/retroshare-gui/src/gui/msgs/TagsMenu.cpp @@ -29,7 +29,6 @@ #include "TagsMenu.h" #include "gui/common/TagDefs.h" #include "gui/settings/NewTag.h" -#include "gui/notifyqt.h" #include "util/qtthreadsutils.h" #include "gui/msgs/MessageInterface.h" diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp deleted file mode 100644 index d2dee5ac4..000000000 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ /dev/null @@ -1,1287 +0,0 @@ -/******************************************************************************* - * gui/NotifyQt.cpp * - * * - * Copyright (c) 2010 Retroshare Team * - * * - * This program is free software: you can redistribute it and/or modify * - * it under the terms of the GNU Affero General Public License as * - * published by the Free Software Foundation, either version 3 of the * - * License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Affero General Public License for more details. * - * * - * You should have received a copy of the GNU Affero General Public License * - * along with this program. If not, see . * - * * - *******************************************************************************/ - -#include "gui/common/FilesDefs.h" -#include - -#include "notifyqt.h" -#include -#include -#include -#include - -#include - -#include "MainWindow.h" -#include "toaster/OnlineToaster.h" -#include "toaster/MessageToaster.h" -#include "toaster/DownloadToaster.h" -#include "toaster/ChatToaster.h" -#include "toaster/GroupChatToaster.h" -#include "toaster/ChatLobbyToaster.h" -#include "toaster/FriendRequestToaster.h" -#include "toaster/ToasterItem.h" -#include "common/ToasterNotify.h" - -#include "chat/ChatDialog.h" -#include "chat/ChatLobbyDialog.h" -#include "chat/ChatWidget.h" -#include "FriendsDialog.h" -#include "gui/settings/rsharesettings.h" -#include "SoundManager.h" - -#include "retroshare/rsplugin.h" - -#include -#include -#include -//#include -#include -#include - -/***** - * #define NOTIFY_DEBUG - ****/ - -/*static*/ NotifyQt *NotifyQt::_instance = NULL; -/*static*/ bool NotifyQt::_disableAllToaster = false; - -/*static*/ NotifyQt *NotifyQt::Create () -{ - if (_instance == NULL) { - _instance = new NotifyQt (); - } - - return _instance; -} - -/*static*/ NotifyQt *NotifyQt::getInstance () -{ - return _instance; -} - -/*static*/ bool NotifyQt::isAllDisable () -{ - return _disableAllToaster; -} - -void NotifyQt::SetDisableAll(bool bValue) -{ - if (bValue!=_disableAllToaster) - { - _disableAllToaster=bValue; - emit disableAllChanged(bValue); - } -} - -NotifyQt::NotifyQt() : cDialog(NULL) -{ - runningToasterTimer = new QTimer(this); - connect(runningToasterTimer, SIGNAL(timeout()), this, SLOT(runningTick())); - runningToasterTimer->setInterval(10); // tick 100 times a second - runningToasterTimer->setSingleShot(true); - { - QMutexLocker m(&_mutex) ; - _enabled = false ; - } - - // register to allow sending over Qt::QueuedConnection - qRegisterMetaType("ChatId"); - qRegisterMetaType("ChatMessage"); - qRegisterMetaType("RsGxsChanges"); - qRegisterMetaType("RsGxsId"); -} - -void NotifyQt::notifyErrorMsg(int list, int type, std::string msg) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - emit errorOccurred(list,type,QString::fromUtf8(msg.c_str())) ; -} - -void NotifyQt::notifyChatMessage(const ChatMessage &msg) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - -#ifdef NOTIFY_DEBUG - std::cerr << "notifyQt: Received chat message " << std::endl ; -#endif - emit chatMessageReceived(msg); -} - -void NotifyQt::notifyOwnAvatarChanged() -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - -#ifdef NOTIFY_DEBUG - std::cerr << "Notifyqt:: notified that own avatar changed" << std::endl ; -#endif - emit ownAvatarChanged() ; -} - -class SignatureEventData -{ - public: - SignatureEventData(const void *_data,int32_t _len,unsigned int _signlen, std::string _reason) - { - // We need a new memory chnk because there's no guarranty _sign nor _signlen are not in the stack - - sign = (unsigned char *)rs_malloc(_signlen) ; - - if(!sign) - { - signlen = NULL ; - signature_result = SELF_SIGNATURE_RESULT_FAILED ; - return ; - } - - signlen = new unsigned int ; - *signlen = _signlen ; - signature_result = SELF_SIGNATURE_RESULT_PENDING ; - data = rs_malloc(_len) ; - - if(!data) - { - len = 0 ; - return ; - } - len = _len ; - memcpy(data,_data,len) ; - reason = _reason ; - } - - ~SignatureEventData() - { - free(sign) ; - delete signlen ; - free(data) ; - } - - void performSignature() - { - if(rsPeers->gpgSignData(data,len,sign,signlen,reason)) - signature_result = SELF_SIGNATURE_RESULT_SUCCESS ; - else - signature_result = SELF_SIGNATURE_RESULT_FAILED ; - } - - void *data ; - uint32_t len ; - unsigned char *sign ; - unsigned int *signlen ; - int signature_result ; // 0=pending, 1=done, 2=failed/cancelled. - std::string reason ; -}; - -void NotifyQt::handleSignatureEvent() -{ - std::cerr << "NotifyQt:: performing a deferred signature in the main GUI thread." << std::endl; - - static bool working = false ; - - if(!working) - { - working = true ; - - for(std::map::const_iterator it(_deferred_signature_queue.begin());it!=_deferred_signature_queue.end();++it) - it->second->performSignature() ; - - working = false ; - } -} - - - -bool NotifyQt::askForPassword(const std::string& title, const std::string& key_details, bool prev_is_bad, std::string& password,bool& cancelled) -{ - RsAutoUpdatePage::lockAllEvents() ; - - QString windowTitle; - if (title == "") { - windowTitle = tr("Passphrase required"); - } else if (title == "AuthSSLimpl::SignX509ReqWithGPG()") { - windowTitle = tr("You need to sign your node's certificate."); - } else if (title == "p3IdService::service_CreateGroup()") { - windowTitle = tr("You need to sign your forum/chatrooms identity."); - } else { - windowTitle = QString::fromStdString(title); - } - - QString labelText = ( prev_is_bad ? QString("%1

").arg(tr("Wrong password !")) : QString() ) - + QString("%1
Profile: %2\n") - .arg( tr("Please enter your Retroshare passphrase") - , QString::fromUtf8(key_details.c_str()) ); - QLineEdit::EchoMode textEchoMode = QLineEdit::Password; - bool modal = true; - - bool sameThread = QThread::currentThread() == qApp->thread(); - Gui_InputDialogReturn ret; - qRegisterMetaType("Gui_InputDialogReturn"); - QMetaObject::invokeMethod( MainWindow::getInstance() - , "guiInputDialog" - , sameThread ? Qt::DirectConnection : Qt::BlockingQueuedConnection - , Q_RETURN_ARG(Gui_InputDialogReturn, ret) - , Q_ARG(QString, windowTitle) - , Q_ARG(QString, labelText) - , Q_ARG(QLineEdit::EchoMode, textEchoMode) - , Q_ARG(bool, modal) - ); - - cancelled = false ; - - RsAutoUpdatePage::unlockAllEvents() ; - - if (ret.execReturn == QDialog::Rejected) { - password.clear() ; - cancelled = true ; - return true ; - } - - if (ret.execReturn == QDialog::Accepted) { - password = ret.textValue.toUtf8().constData(); - return true; - } - - return false; -} -bool NotifyQt::askForPluginConfirmation(const std::string& plugin_file_name, const std::string& plugin_file_hash, bool first_time) -{ - // By default, when no information is known about plugins, just dont load them. They will be enabled from the GUI by the user. - - if(first_time) - return false ; - - RsAutoUpdatePage::lockAllEvents() ; - - QMessageBox dialog; - dialog.setWindowTitle(tr("Unregistered plugin/executable")); - - QString text ; - text += tr( "RetroShare has detected an unregistered plugin. This happens in two cases:
  • Your RetroShare executable has changed.
  • The plugin has changed
Click on Yes to authorize this plugin, or No to deny it. You can change your mind later in Options -> Plugins, then restart." ) ; - text += "
    " ; - text += "
  • Hash:\t" + QString::fromStdString(plugin_file_hash) + "
  • " ; - text += "
  • File:\t" + QString::fromStdString(plugin_file_name) + "
  • "; - text += "
" ; - - dialog.setText(text) ; - dialog.setWindowIcon(FilesDefs::getIconFromQtResourcePath(":/icons/logo_128.png")); - dialog.setStandardButtons(QMessageBox::Yes | QMessageBox::No) ; - - int ret = dialog.exec(); - - RsAutoUpdatePage::unlockAllEvents() ; - - if (ret == QMessageBox::Yes) - return true ; - else - return false; -} - -void NotifyQt::notifyDiscInfoChanged() -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - -#ifdef NOTIFY_DEBUG - std::cerr << "Notifyqt:: notified that discoveryInfo changed" << std::endl ; -#endif - - emit discInfoChanged() ; -} - -void NotifyQt::notifyDiskFull(uint32_t loc,uint32_t size_in_mb) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - - std::cerr << "Notifyqt:: notified that disk is full" << std::endl ; - - emit diskFull(loc,size_in_mb) ; -} - -/* peer has changed the state */ -void NotifyQt::notifyPeerStatusChanged(const std::string& peer_id, uint32_t state) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - -#ifdef NOTIFY_DEBUG - std::cerr << "Notifyqt:: notified that peer " << peer_id << " has changed the state to " << state << std::endl; -#endif - - emit peerStatusChanged(QString::fromStdString(peer_id), state); -} - -/* one or more peers has changed the states */ -void NotifyQt::notifyPeerStatusChangedSummary() -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - -#ifdef NOTIFY_DEBUG - std::cerr << "Notifyqt:: notified that one peer has changed the state" << std::endl; -#endif - - emit peerStatusChangedSummary(); -} - -void NotifyQt::notifyOwnStatusMessageChanged() -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - -#ifdef NOTIFY_DEBUG - std::cerr << "Notifyqt:: notified that own avatar changed" << std::endl ; -#endif - emit ownStatusMessageChanged() ; -} - -void NotifyQt::notifyPeerHasNewAvatar(std::string peer_id) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } -#ifdef NOTIFY_DEBUG - std::cerr << "notifyQt: notification of new avatar." << std::endl ; -#endif - emit peerHasNewAvatar(QString::fromStdString(peer_id)) ; -} - -void NotifyQt::notifyCustomState(const std::string& peer_id, const std::string& status_string) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - -#ifdef NOTIFY_DEBUG - std::cerr << "notifyQt: Received custom status string notification" << std::endl ; -#endif - emit peerHasNewCustomStateString(QString::fromStdString(peer_id), QString::fromUtf8(status_string.c_str())) ; -} - -void NotifyQt::notifyChatLobbyTimeShift(int shift) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - -#ifdef NOTIFY_DEBUG - std::cerr << "notifyQt: Received chat lobby time shift message: shift = " << shift << std::endl; -#endif - emit chatLobbyTimeShift(shift) ; -} - -void NotifyQt::handleChatLobbyTimeShift(int /*shift*/) -{ - return ; // we say nothing. The help dialog of lobbies explains this already. - static bool already = false ; - - if(!already) - { - already = true ; - - QString string = tr("For the chat lobbies to work properly, the time of your computer needs to be correct. Please check that this is the case (A possible time shift of several minutes was detected with your friends).") ; - - QMessageBox::warning(NULL,tr("Please check your system clock."),string) ; - } -} - -void NotifyQt::notifyChatLobbyEvent(uint64_t lobby_id,uint32_t event_type,const RsGxsId& nickname,const std::string& str) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - -#ifdef NOTIFY_DEBUG - std::cerr << "notifyQt: Received chat lobby event message: lobby #" << std::hex << lobby_id << std::dec << ", event=" << event_type << ", str=\"" << str << "\"" << std::endl ; -#endif - emit chatLobbyEvent(lobby_id,event_type,nickname,QString::fromUtf8(str.c_str())) ; -} - -void NotifyQt::notifyChatStatus(const ChatId& chat_id,const std::string& status_string) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - -#ifdef NOTIFY_DEBUG - std::cerr << "notifyQt: Received chat status string: " << status_string << std::endl ; -#endif - emit chatStatusChanged(chat_id, QString::fromUtf8(status_string.c_str())); -} - -void NotifyQt::notifyChatCleared(const ChatId& chat_id) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - -#ifdef NOTIFY_DEBUG - std::cerr << "notifyQt: Received chat cleared." << std::endl ; -#endif - emit chatCleared(chat_id); -} - -void NotifyQt::notifyTurtleSearchResult(uint32_t /*search_id*/,const std::list& /*found_groups*/) -{ - std::cerr << "(EE) missing code to handle GXS turtle search result." << std::endl; -} - -#ifdef TO_REMOVE -// Mai 2023: distant turtle search now uses RsEvents. -void NotifyQt::notifyTurtleSearchResult(const RsPeerId& pid,uint32_t search_id,const std::list& files) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - -#ifdef NOTIFY_DEBUG - std::cerr << "in notify search result..." << std::endl ; -#endif - - for(std::list::const_iterator it(files.begin());it!=files.end();++it) - { - FileDetail det ; - det.rank = 0 ; - det.age = 0 ; - det.name = (*it).name ; - det.hash = (*it).hash ; - det.size = (*it).size ; - det.id = pid ; - - emit gotTurtleSearchResult(search_id,det) ; - } -} -#endif - -void NotifyQt::notifyHistoryChanged(uint32_t msgId, int type) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - - emit historyChanged(msgId, type); -} - -void NotifyQt::notifyListChange(int list, int type) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } -#ifdef NOTIFY_DEBUG - std::cerr << "NotifyQt::notifyListChange()" << std::endl; -#endif - switch(list) - { - case NOTIFY_LIST_NEIGHBOURS: -#ifdef NOTIFY_DEBUG - std::cerr << "received neighbours changed" << std::endl ; -#endif - emit neighboursChanged(); - break; - case NOTIFY_LIST_FRIENDS: -#ifdef NOTIFY_DEBUG - std::cerr << "received friends changed" << std::endl ; -#endif - emit friendsChanged() ; - break; - case NOTIFY_LIST_DIRLIST_LOCAL: -#ifdef NOTIFY_DEBUG - std::cerr << "received files changed" << std::endl ; -#endif - emit filesPostModChanged(true) ; /* Local */ - break; - case NOTIFY_LIST_CHAT_LOBBY_INVITATION: -#ifdef NOTIFY_DEBUG - std::cerr << "received files changed" << std::endl ; -#endif - emit chatLobbyInviteReceived() ; /* Local */ - break; - case NOTIFY_LIST_DIRLIST_FRIENDS: -#ifdef NOTIFY_DEBUG - std::cerr << "received files changed" << std::endl ; -#endif - emit filesPostModChanged(false) ; /* Local */ - break; - case NOTIFY_LIST_SEARCHLIST: - break; - case NOTIFY_LIST_CHANNELLIST: - break; - case NOTIFY_LIST_TRANSFERLIST: -#ifdef NOTIFY_DEBUG - std::cerr << "received transfer changed" << std::endl ; -#endif - emit transfersChanged() ; - break; - case NOTIFY_LIST_CONFIG: -#ifdef NOTIFY_DEBUG - std::cerr << "received config changed" << std::endl ; -#endif - emit configChanged() ; - break ; - -#ifdef REMOVE - case NOTIFY_LIST_FORUMLIST_LOCKED: -#ifdef NOTIFY_DEBUG - std::cerr << "received forum msg changed" << std::endl ; -#endif - emit forumsChanged(); // use connect with Qt::QueuedConnection - break; - case NOTIFY_LIST_CHANNELLIST_LOCKED: -#ifdef NOTIFY_DEBUG - std::cerr << "received channel msg changed" << std::endl ; -#endif - emit channelsChanged(type); // use connect with Qt::QueuedConnection - break; - case NOTIFY_LIST_PUBLIC_CHAT: -#ifdef NOTIFY_DEBUG - std::cerr << "received public chat changed" << std::endl ; -#endif - emit publicChatChanged(type); - break; - case NOTIFY_LIST_PRIVATE_INCOMING_CHAT: - case NOTIFY_LIST_PRIVATE_OUTGOING_CHAT: -#ifdef NOTIFY_DEBUG - std::cerr << "received private chat changed" << std::endl ; -#endif - emit privateChatChanged(list, type); - break; -#endif - - case NOTIFY_LIST_CHAT_LOBBY_LIST: -#ifdef NOTIFY_DEBUG - std::cerr << "received notify chat lobby list" << std::endl; -#endif - emit lobbyListChanged(); - break; - - case NOTIFY_LIST_GROUPLIST: -#ifdef NOTIFY_DEBUG - std::cerr << "received groups changed" << std::endl ; -#endif - emit groupsChanged(type); - break; - default: - break; - } - return; -} - -void NotifyQt::notifyListPreChange(int list, int /*type*/) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - -#ifdef NOTIFY_DEBUG - std::cerr << "NotifyQt::notifyListPreChange()" << std::endl; -#endif - switch(list) - { - case NOTIFY_LIST_NEIGHBOURS: - break; - case NOTIFY_LIST_FRIENDS: - emit friendsChanged() ; - break; - case NOTIFY_LIST_DIRLIST_FRIENDS: - emit filesPreModChanged(false) ; /* remote */ - break ; - case NOTIFY_LIST_DIRLIST_LOCAL: - emit filesPreModChanged(true) ; /* local */ - break; - case NOTIFY_LIST_SEARCHLIST: - break; - case NOTIFY_LIST_CHANNELLIST: - break; - case NOTIFY_LIST_TRANSFERLIST: - break; - default: - break; - } - return; -} - -void NotifyQt::enable() -{ - QMutexLocker m(&_mutex) ; - std::cerr << "Enabling notification system" << std::endl; - _enabled = true ; -} - -void NotifyQt::UpdateGUI() -{ - if(RsAutoUpdatePage::eventsLocked()) - return ; - - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - - static bool already_updated = false ; // these only update once at start because they may already have been set before - // the gui is running, then they get updated by callbacks. - if(!already_updated) - { - emit neighboursChanged(); - emit configChanged(); - - already_updated = true ; - } - - /* Finally Check for PopupMessages / System Error Messages */ - - if (rsNotify) - { - uint32_t sysid; - uint32_t type; - std::string title, id, msg; - - /* You can set timeToShow, timeToLive and timeToHide or can leave the standard */ - ToasterItem *toaster = NULL; - if (rsNotify->NotifyPopupMessage(type, id, title, msg)) - { - uint popupflags = Settings->getNotifyFlags(); - - switch(type) - { - case RS_POPUP_ENCRYPTED_MSG: - SoundManager::play(SOUND_MESSAGE_ARRIVED); - - if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster) - { - toaster = new ToasterItem(new MessageToaster("", tr("Encrypted message"), QString("[%1]").arg(tr("Encrypted message")))); - } - break; - case RS_POPUP_MSG: - SoundManager::play(SOUND_MESSAGE_ARRIVED); - - if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster) - { - toaster = new ToasterItem(new MessageToaster(id, QString::fromUtf8(title.c_str()), QString::fromUtf8(msg.c_str()))); - } - break; - case RS_POPUP_CONNECT: - SoundManager::play(SOUND_USER_ONLINE); - - if ((popupflags & RS_POPUP_CONNECT) && !_disableAllToaster) - { - toaster = new ToasterItem(new OnlineToaster(RsPeerId(id))); - } - break; - case RS_POPUP_DOWNLOAD: - SoundManager::play(SOUND_DOWNLOAD_COMPLETE); - - if ((popupflags & RS_POPUP_DOWNLOAD) && !_disableAllToaster) - { - /* id = file hash */ - toaster = new ToasterItem(new DownloadToaster(RsFileHash(id), QString::fromUtf8(title.c_str()))); - } - break; - case RS_POPUP_CHAT: - if ((popupflags & RS_POPUP_CHAT) && !_disableAllToaster) - { - // TODO: fix for distant chat, look up if dstant chat uses RS_POPUP_CHAT - ChatDialog *chatDialog = ChatDialog::getChat(ChatId(RsPeerId(id))); - ChatWidget *chatWidget; - if (chatDialog && (chatWidget = chatDialog->getChatWidget()) && chatWidget->isActive()) { - // do not show when active - break; - } - toaster = new ToasterItem(new ChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str()))); - } - break; - case RS_POPUP_GROUPCHAT: -#ifdef RS_DIRECT_CHAT - if ((popupflags & RS_POPUP_GROUPCHAT) && !_disableAllToaster) - { - MainWindow *mainWindow = MainWindow::getInstance(); - if (mainWindow && mainWindow->isActiveWindow() && !mainWindow->isMinimized()) { - if (MainWindow::getActivatePage() == MainWindow::Friends) { - if (FriendsDialog::isGroupChatActive()) { - // do not show when active - break; - } - } - } - toaster = new ToasterItem(new GroupChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str()))); - } -#endif // RS_DIRECT_CHAT - break; - case RS_POPUP_CHATLOBBY: - if ((popupflags & RS_POPUP_CHATLOBBY) && !_disableAllToaster) - { - ChatId chat_id(id); - - ChatDialog *chatDialog = ChatDialog::getChat(chat_id); - ChatWidget *chatWidget; - if (chatDialog && (chatWidget = chatDialog->getChatWidget()) && chatWidget->isActive()) { - // do not show when active - break; - } - ChatLobbyDialog *chatLobbyDialog = dynamic_cast(chatDialog); - - RsGxsId sender(title); - if (!chatLobbyDialog || chatLobbyDialog->isParticipantMuted(sender)) - break; // participant is muted - - toaster = new ToasterItem(new ChatLobbyToaster(chat_id.toLobbyId(), sender, QString::fromUtf8(msg.c_str()))); - } - break; - case RS_POPUP_CONNECT_ATTEMPT: - if ((popupflags & RS_POPUP_CONNECT_ATTEMPT) && !_disableAllToaster) - { - // id = gpgid - // title = ssl name - // msg = peer id - toaster = new ToasterItem(new FriendRequestToaster(RsPgpId(id), QString::fromUtf8(title.c_str()), RsPeerId(msg))); - } - break; - } - } - - /*Now check Plugins*/ - if (!toaster) { - int pluginCount = rsPlugins->nbPlugins(); - for (int i = 0; i < pluginCount; ++i) { - RsPlugin *rsPlugin = rsPlugins->plugin(i); - if (rsPlugin) { - ToasterNotify *toasterNotify = rsPlugin->qt_toasterNotify(); - if (toasterNotify) { - toaster = toasterNotify->toasterItem(); - continue; - } - } - } - } - - if (toaster) { - /* init attributes */ - toaster->widget->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint); - - /* add toaster to waiting list */ - //QMutexLocker lock(&waitingToasterMutex); - waitingToasterList.push_back(toaster); - } - - if (rsNotify->NotifySysMessage(sysid, type, title, msg)) - { - /* make a warning message */ - switch(type) - { - case RS_SYS_ERROR: - QMessageBox::critical(MainWindow::getInstance(), - QString::fromUtf8(title.c_str()), - QString::fromUtf8(msg.c_str())); - break; - case RS_SYS_WARNING: - QMessageBox::warning(MainWindow::getInstance(), - QString::fromUtf8(title.c_str()), - QString::fromUtf8(msg.c_str())); - break; - default: - case RS_SYS_INFO: - QMessageBox::information(MainWindow::getInstance(), - QString::fromUtf8(title.c_str()), - QString::fromUtf8(msg.c_str())); - break; - } - } - - if (rsNotify->NotifyLogMessage(sysid, type, title, msg)) - { - /* make a log message */ - std::string logMesString = title + " " + msg; - switch(type) - { - case RS_SYS_ERROR: - case RS_SYS_WARNING: - case RS_SYS_INFO: - emit logInfoChanged(QString::fromUtf8(logMesString.c_str())); - } - } - } - - /* Now start the waiting toasters */ - startWaitingToasters(); -} - -void NotifyQt::testToasters(uint notifyFlags, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin) -{ - QString title = tr("Test"); - QString message = tr("This is a test."); - - RsPeerId id = rsPeers->getOwnId(); - RsPgpId pgpid = rsPeers->getGPGOwnId(); - - uint pos = 0; - - while (notifyFlags) { - uint type = notifyFlags & (1 << pos); - notifyFlags &= ~(1 << pos); - ++pos; - - ToasterItem *toaster = NULL; - - switch(type) - { - case RS_POPUP_ENCRYPTED_MSG: - toaster = new ToasterItem(new MessageToaster(std::string(), tr("Unknown title"), QString("[%1]").arg(tr("Encrypted message")))); - break; - case RS_POPUP_MSG: - toaster = new ToasterItem(new MessageToaster(id.toStdString(), title, message)); - break; - case RS_POPUP_CONNECT: - toaster = new ToasterItem(new OnlineToaster(id)); - break; - case RS_POPUP_DOWNLOAD: - toaster = new ToasterItem(new DownloadToaster(RsFileHash::random(), title)); - break; - case RS_POPUP_CHAT: - toaster = new ToasterItem(new ChatToaster(id, message)); - break; - case RS_POPUP_GROUPCHAT: -#ifdef RS_DIRECT_CHAT - toaster = new ToasterItem(new GroupChatToaster(id, message)); -#endif // RS_DIRECT_CHAT - break; - case RS_POPUP_CHATLOBBY: - { - std::list gxsid; - if(rsIdentity->getOwnIds(gxsid) && (gxsid.size() > 0)){ - toaster = new ToasterItem(new ChatLobbyToaster(0, gxsid.front(), message)); - } - break; - } - case RS_POPUP_CONNECT_ATTEMPT: - toaster = new ToasterItem(new FriendRequestToaster(pgpid, title, id)); - break; - } - - if (toaster) { - /* init attributes */ - toaster->widget->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint); - toaster->position = (RshareSettings::enumToasterPosition) position; - toaster->margin = margin; - - /* add toaster to waiting list */ - //QMutexLocker lock(&waitingToasterMutex); - waitingToasterList.push_back(toaster); - } - } -} - -void NotifyQt::testToaster(ToasterNotify *toasterNotify, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin) -{ - - if (!toasterNotify) { - return; - } - - ToasterItem *toaster = toasterNotify->testToasterItem(); - - if (toaster) { - /* init attributes */ - toaster->widget->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint); - toaster->position = (RshareSettings::enumToasterPosition) position; - toaster->margin = margin; - - /* add toaster to waiting list */ - //QMutexLocker lock(&waitingToasterMutex); - waitingToasterList.push_back(toaster); - } -} - -void NotifyQt::testToaster(QString tag, ToasterNotify *toasterNotify, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin) -{ - - if (!toasterNotify) { - return; - } - - ToasterItem *toaster = toasterNotify->testToasterItem(tag); - - if (toaster) { - /* init attributes */ - toaster->widget->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint); - toaster->position = (RshareSettings::enumToasterPosition) position; - toaster->margin = margin; - - /* add toaster to waiting list */ - //QMutexLocker lock(&waitingToasterMutex); - waitingToasterList.push_back(toaster); - } -} - -void NotifyQt::notifyChatFontChanged() -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - - emit chatFontChanged(); -} -void NotifyQt::notifyChatStyleChanged(int /*ChatStyle::enumStyleType*/ styleType) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - - emit chatStyleChanged(styleType); -} - -void NotifyQt::notifySettingsChanged() -{ - emit settingsChanged(); -} - -void NotifyQt::startWaitingToasters() -{ - { - //QMutexLocker lock(&waitingToasterMutex); - - if (waitingToasterList.empty()) { - /* No toasters are waiting */ - return; - } - } - - { - //QMutexLocker lock(&runningToasterMutex); - - if (runningToasterList.size() >= 3) { - /* Don't show more than 3 toasters at once */ - return; - } - } - - ToasterItem *toaster = NULL; - - { - //QMutexLocker lock(&waitingToasterMutex); - - if (waitingToasterList.size()) { - /* Take one toaster of the waiting list */ - toaster = waitingToasterList.front(); - waitingToasterList.pop_front(); - } - } - - if (toaster) { - //QMutexLocker lock(&runningToasterMutex); - - /* Calculate positions */ - QSize size = toaster->widget->size(); - - QDesktopWidget *desktop = QApplication::desktop(); - QRect desktopGeometry = desktop->availableGeometry(desktop->primaryScreen()); - - switch (toaster->position) { - case RshareSettings::TOASTERPOS_TOPLEFT: - toaster->startPos = QPoint(desktopGeometry.left() + toaster->margin.x(), desktopGeometry.top() - size.height()); - toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.top() + toaster->margin.y()); - break; - case RshareSettings::TOASTERPOS_TOPRIGHT: - toaster->startPos = QPoint(desktopGeometry.right() - size.width() - toaster->margin.x(), desktopGeometry.top() - size.height()); - toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.top() + toaster->margin.y()); - break; - case RshareSettings::TOASTERPOS_BOTTOMLEFT: - toaster->startPos = QPoint(desktopGeometry.left() + toaster->margin.x(), desktopGeometry.bottom()); - toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.bottom() - size.height() - toaster->margin.y()); - break; - case RshareSettings::TOASTERPOS_BOTTOMRIGHT: // default - default: - toaster->startPos = QPoint(desktopGeometry.right() - size.width() - toaster->margin.x(), desktopGeometry.bottom()); - toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.bottom() - size.height() - toaster->margin.y()); - break; - } - - /* Initialize widget */ - toaster->widget->move(toaster->startPos); - - /* Initialize toaster */ - toaster->elapsedTimeToShow = 0; - toaster->elapsedTimeToLive = 0; - toaster->elapsedTimeToHide = 0; - - /* Add toaster to the running list */ - runningToasterList.push_front(toaster); - if (runningToasterTimer->isActive() == false) { - /* Start the toaster timer */ - runningToasterTimer->start(); - } - } -} - -void NotifyQt::runningTick() -{ - //QMutexLocker lock(&runningToasterMutex); - - int interval = runningToasterTimer->interval(); - QPoint diff; - - QList::iterator it = runningToasterList.begin(); - while (it != runningToasterList.end()) { - ToasterItem *toaster = *it; - - bool visible = true; - if (toaster->elapsedTimeToShow) { - /* Toaster is started, check for visible */ - visible = toaster->widget->isVisible(); - } - - QPoint newPos; - enum { NOTHING, SHOW, HIDE } operation = NOTHING; - - if (visible && toaster->elapsedTimeToShow <= toaster->timeToShow) { - /* Toaster is showing */ - if (toaster->elapsedTimeToShow == 0) { - /* Toaster is not visible, show it now */ - operation = SHOW; - } - - toaster->elapsedTimeToShow += interval; - - newPos = QPoint(toaster->startPos.x() - (toaster->startPos.x() - toaster->endPos.x()) * toaster->elapsedTimeToShow / toaster->timeToShow, - toaster->startPos.y() - (toaster->startPos.y() - toaster->endPos.y()) * toaster->elapsedTimeToShow / toaster->timeToShow); - } else if (visible && toaster->elapsedTimeToLive <= toaster->timeToLive) { - /* Toaster is living */ - toaster->elapsedTimeToLive += interval; - - newPos = toaster->endPos; - } else if (visible && toaster->elapsedTimeToHide <= toaster->timeToHide) { - /* Toaster is hiding */ - toaster->elapsedTimeToHide += interval; - - if (toaster->elapsedTimeToHide == toaster->timeToHide) { - /* Toaster is back at the start position, hide it */ - operation = HIDE; - } - - newPos = QPoint(toaster->startPos.x() - (toaster->startPos.x() - toaster->endPos.x()) * (toaster->timeToHide - toaster->elapsedTimeToHide) / toaster->timeToHide, - toaster->startPos.y() - (toaster->startPos.y() - toaster->endPos.y()) * (toaster->timeToHide - toaster->elapsedTimeToHide) / toaster->timeToHide); - } else { - /* Toaster is hidden, delete it */ - it = runningToasterList.erase(it); - //delete(toaster->widget); - delete(toaster); - continue; - } - - toaster->widget->move(newPos + diff); - diff += newPos - toaster->startPos; - - QRect mask = QRect(0, 0, toaster->widget->width(), qAbs(toaster->startPos.y() - newPos.y())); - if (newPos.y() > toaster->startPos.y()) { - /* Toaster is moving from top */ - mask.moveTop(toaster->widget->height() - (newPos.y() - toaster->startPos.y())); - } - toaster->widget->setMask(QRegion(mask)); - - switch (operation) { - case NOTHING: - break; - case SHOW: - toaster->widget->show(); - break; - case HIDE: - toaster->widget->hide(); - break; - } - - ++it; - } - - if (runningToasterList.size()) { - /* There are more running toasters, start the timer again */ - runningToasterTimer->start(); - } -} - -void NotifyQt::addToaster(uint notifyFlags, const std::string& id, const std::string& title, const std::string& msg) -{ - uint pos = 0; - - while (notifyFlags) { - uint type = notifyFlags & (1 << pos); - notifyFlags &= ~(1 << pos); - ++pos; - - ToasterItem *toaster = NULL; - - uint popupflags = Settings->getNotifyFlags(); - - switch(type) - { - case RS_POPUP_ENCRYPTED_MSG: - SoundManager::play(SOUND_MESSAGE_ARRIVED); - - if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster) - { - toaster = new ToasterItem(new MessageToaster(std::string(), tr("Unknown title"), QString("[%1]").arg(tr("Encrypted message")))); - } - break; - case RS_POPUP_MSG: - SoundManager::play(SOUND_MESSAGE_ARRIVED); - - if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster) - { - toaster = new ToasterItem(new MessageToaster(id, QString::fromUtf8(title.c_str()), QString::fromUtf8(msg.c_str()))); - } - break; - case RS_POPUP_CONNECT: - SoundManager::play(SOUND_USER_ONLINE); - - if ((popupflags & RS_POPUP_CONNECT) && !_disableAllToaster) - { - toaster = new ToasterItem(new OnlineToaster(RsPeerId(id))); - } - break; - case RS_POPUP_DOWNLOAD: - SoundManager::play(SOUND_DOWNLOAD_COMPLETE); - - if ((popupflags & RS_POPUP_DOWNLOAD) && !_disableAllToaster) - { - toaster = new ToasterItem(new DownloadToaster(RsFileHash(id), QString::fromUtf8(title.c_str()))); - } - break; - case RS_POPUP_CHAT: - if ((popupflags & RS_POPUP_CHAT) && !_disableAllToaster) - { - // TODO: fix for distant chat, look up if dstant chat uses RS_POPUP_CHAT - ChatDialog *chatDialog = ChatDialog::getChat(ChatId(RsPeerId(id))); - ChatWidget *chatWidget; - if (chatDialog && (chatWidget = chatDialog->getChatWidget()) && chatWidget->isActive()) { - // do not show when active - break; - } - toaster = new ToasterItem(new ChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str()))); - } - case RS_POPUP_GROUPCHAT: -#ifdef RS_DIRECT_CHAT - if ((popupflags & RS_POPUP_GROUPCHAT) && !_disableAllToaster) - { - MainWindow *mainWindow = MainWindow::getInstance(); - if (mainWindow && mainWindow->isActiveWindow() && !mainWindow->isMinimized()) { - if (MainWindow::getActivatePage() == MainWindow::Friends) { - if (FriendsDialog::isGroupChatActive()) { - // do not show when active - break; - } - } - } - toaster = new ToasterItem(new GroupChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str()))); - } -#endif // RS_DIRECT_CHAT - break; - case RS_POPUP_CHATLOBBY: - if ((popupflags & RS_POPUP_CHATLOBBY) && !_disableAllToaster) - { - ChatId chat_id(id); - - ChatDialog *chatDialog = ChatDialog::getChat(chat_id); - ChatWidget *chatWidget; - if (chatDialog && (chatWidget = chatDialog->getChatWidget()) && chatWidget->isActive()) { - // do not show when active - break; - } - - ChatLobbyDialog *chatLobbyDialog = dynamic_cast(chatDialog); - - RsGxsId sender(title); - if (!chatLobbyDialog || chatLobbyDialog->isParticipantMuted(sender)) - break; // participant is muted - - toaster = new ToasterItem(new ChatLobbyToaster(chat_id.toLobbyId(), sender, QString::fromUtf8(msg.c_str()))); - } - break; - case RS_POPUP_CONNECT_ATTEMPT: - if ((popupflags & RS_POPUP_CONNECT_ATTEMPT) && !_disableAllToaster) - { - // id = gpgid - // title = ssl name - // msg = peer id - toaster = new ToasterItem(new FriendRequestToaster(RsPgpId(id), QString::fromUtf8(title.c_str()), RsPeerId(msg))); - } - break; - } - - if (toaster) { - /* init attributes */ - toaster->widget->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint); - - /* add toaster to waiting list */ - //QMutexLocker lock(&waitingToasterMutex); - waitingToasterList.push_back(toaster); - } - } - /* Now start the waiting toasters */ - startWaitingToasters(); -} diff --git a/retroshare-gui/src/gui/profile/ProfileWidget.h b/retroshare-gui/src/gui/profile/ProfileWidget.h index 9c97fdbec..3b6eee327 100644 --- a/retroshare-gui/src/gui/profile/ProfileWidget.h +++ b/retroshare-gui/src/gui/profile/ProfileWidget.h @@ -32,7 +32,7 @@ class ProfileWidget : public QWidget public: /** Default constructor */ - ProfileWidget(QWidget *parent = 0, Qt::WindowFlags flags = 0); + ProfileWidget(QWidget *parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); private slots: void showEvent ( QShowEvent * event ); diff --git a/retroshare-gui/src/gui/qss/stylesheet/Standard_Dark.qss b/retroshare-gui/src/gui/qss/stylesheet/Standard_Dark.qss index ffea0a4d8..f9343c3ea 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/Standard_Dark.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/Standard_Dark.qss @@ -1243,6 +1243,7 @@ QComboBox { /* changed to 4px to fix #239 */ /* Fixes #103, #111 */ min-height: 1.5em; + min-width: 2em; /* padding-top: 2px; removed to fix #132 */ /* padding-bottom: 2px; removed to fix #132 */ /* min-width: 75px; removed to fix #109 */ diff --git a/retroshare-gui/src/gui/qss/stylesheet/Standard_Light.qss b/retroshare-gui/src/gui/qss/stylesheet/Standard_Light.qss index 40fe0b78c..a6698c637 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/Standard_Light.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/Standard_Light.qss @@ -1243,6 +1243,7 @@ QComboBox { /* changed to 4px to fix #239 */ /* Fixes #103, #111 */ min-height: 1.5em; + min-width: 2em; /* padding-top: 2px; removed to fix #132 */ /* padding-bottom: 2px; removed to fix #132 */ /* min-width: 75px; removed to fix #109 */ diff --git a/retroshare-gui/src/gui/settings/AboutPage.h b/retroshare-gui/src/gui/settings/AboutPage.h index 4881ca730..39b2da6ed 100644 --- a/retroshare-gui/src/gui/settings/AboutPage.h +++ b/retroshare-gui/src/gui/settings/AboutPage.h @@ -32,7 +32,7 @@ class AboutPage : public ConfigPage public: /** Default Constructor */ - AboutPage(QWidget * parent = 0, Qt::WindowFlags flags = 0); + AboutPage(QWidget * parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); /** Default Destructor */ ~AboutPage(); diff --git a/retroshare-gui/src/gui/settings/AppearancePage.cpp b/retroshare-gui/src/gui/settings/AppearancePage.cpp index 2aecd6024..0a767a20f 100755 --- a/retroshare-gui/src/gui/settings/AppearancePage.cpp +++ b/retroshare-gui/src/gui/settings/AppearancePage.cpp @@ -22,7 +22,7 @@ #include "rshare.h" #include "gui/MainWindow.h" -#include "gui/notifyqt.h" +#include "gui/RsGUIEventManager.h" #include "gui/common/FilesDefs.h" #include "gui/settings/rsharesettings.h" #include "gui/statusbar/peerstatus.h" @@ -173,7 +173,7 @@ void AppearancePage::updateRbtPageOnToolBar() ui.cmboTollButtonsStyle->show(); } - NotifyQt::getInstance()->notifySettingsChanged(); + RsGUIEventManager::getInstance()->notifySettingsChanged(); } void AppearancePage::updateStatusToolTip() { MainWindow::getInstance()->toggleStatusToolTip(ui.checkBoxDisableSysTrayToolTip->isChecked()); } @@ -194,7 +194,7 @@ void AppearancePage::updateCmboToolButtonStyle() default: Settings->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); } - NotifyQt::getInstance()->notifySettingsChanged(); + RsGUIEventManager::getInstance()->notifySettingsChanged(); } void AppearancePage::updateCmboToolButtonSize() @@ -226,7 +226,7 @@ void AppearancePage::updateCmboToolButtonSize() Settings->setToolButtonSize(128); Settings->setListItemIconSize(128); } - NotifyQt::getInstance()->notifySettingsChanged(); + RsGUIEventManager::getInstance()->notifySettingsChanged(); } // void AppearancePage::updateCmboListItemSize() // { @@ -369,5 +369,5 @@ void AppearancePage::updateFontSize() { Settings->setFontSize(ui.minimumFontSize_SB->value()); - NotifyQt::getInstance()->notifySettingsChanged(); + RsGUIEventManager::getInstance()->notifySettingsChanged(); } diff --git a/retroshare-gui/src/gui/settings/AppearancePage.h b/retroshare-gui/src/gui/settings/AppearancePage.h index 741bd752e..7a458139d 100755 --- a/retroshare-gui/src/gui/settings/AppearancePage.h +++ b/retroshare-gui/src/gui/settings/AppearancePage.h @@ -32,7 +32,7 @@ class AppearancePage : public ConfigPage public: /** Default Constructor */ - AppearancePage(QWidget * parent = 0, Qt::WindowFlags flags = 0); + AppearancePage(QWidget * parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); /** Loads the settings for this page */ virtual void load(); diff --git a/retroshare-gui/src/gui/settings/ChannelPage.cpp b/retroshare-gui/src/gui/settings/ChannelPage.cpp index 857cc972e..2a5f413d2 100644 --- a/retroshare-gui/src/gui/settings/ChannelPage.cpp +++ b/retroshare-gui/src/gui/settings/ChannelPage.cpp @@ -21,7 +21,6 @@ #include "ChannelPage.h" #include "rsharesettings.h" #include "util/misc.h" -#include "gui/notifyqt.h" #include "retroshare/rsgxschannels.h" ChannelPage::ChannelPage(QWidget * parent, Qt::WindowFlags flags) diff --git a/retroshare-gui/src/gui/settings/ChannelPage.h b/retroshare-gui/src/gui/settings/ChannelPage.h index adb573711..c89120a40 100644 --- a/retroshare-gui/src/gui/settings/ChannelPage.h +++ b/retroshare-gui/src/gui/settings/ChannelPage.h @@ -32,7 +32,7 @@ class ChannelPage : public ConfigPage Q_OBJECT public: - ChannelPage(QWidget * parent = 0, Qt::WindowFlags flags = 0); + ChannelPage(QWidget * parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); ~ChannelPage(); /** Loads the settings for this page */ diff --git a/retroshare-gui/src/gui/settings/ChatPage.cpp b/retroshare-gui/src/gui/settings/ChatPage.cpp index 1f35fe62c..344257480 100644 --- a/retroshare-gui/src/gui/settings/ChatPage.cpp +++ b/retroshare-gui/src/gui/settings/ChatPage.cpp @@ -22,15 +22,15 @@ #include "rsharesettings.h" #include "gui/MainWindow.h" -#include "gui/notifyqt.h" +#include "gui/RsGUIEventManager.h" #include "gui/RetroShareLink.h" #include "gui/chat/ChatDialog.h" #include "util/misc.h" +#include "util/DateTime.h" #include "retroshare/rsconfig.h" #include "retroshare/rshistory.h" #include "retroshare/rsmsgs.h" -#include "retroshare/rsnotify.h" #include "retroshare/rspeers.h" #include @@ -77,7 +77,7 @@ QString ChatPage::loadStyleInfo(ChatStyle::enumStyleType type, QComboBox *style_ { whileBlocking(style_CB)->insertItem(n,style->styleName); - style_CB->setItemData(n, qVariantFromValue(*style),Qt::UserRole); + style_CB->setItemData(n, QVariant::fromValue(*style),Qt::UserRole); if (style->stylePath == stylePath) { activeItem = n; @@ -115,7 +115,7 @@ void ChatPage::updateFontsAndEmotes() Settings->setValue("Emoteicons_GroupChat", ui.checkBox_emotegroupchat->isChecked()); Settings->setValue("EnableCustomFonts", ui.checkBox_enableCustomFonts->isChecked()); Settings->setValue("EnableCustomFontSize", ui.checkBox_enableCustomFontSize->isChecked()); - Settings->setValue("MinimumFontSize", ui.minimumFontSize->value()); + Settings->setValue("MinimumFontSize", ui.minimumFontSize->value()); Settings->setValue("EnableBold", ui.checkBox_enableBold->isChecked()); Settings->setValue("EnableItalics", ui.checkBox_enableItalics->isChecked()); Settings->setValue("MinimumContrast", ui.minimumContrast->value()); @@ -126,7 +126,7 @@ void ChatPage::updateFontsAndEmotes() void ChatPage::updateChatParams() { Settings->setChatScreenFont(fontTempChat.toString()); - NotifyQt::getInstance()->notifyChatFontChanged(); + RsGUIEventManager::getInstance()->notifyChatFontChanged(); Settings->setChatSendMessageWithCtrlReturn(ui.sendMessageWithCtrlReturn->isChecked()); Settings->setChatSendAsPlainTextByDef(ui.sendAsPlainTextByDef->isChecked()); @@ -186,7 +186,7 @@ void ChatPage::updatePublicStyle() if (publicStylePath != info.stylePath || publicStyleVariant != ui.publicComboBoxVariant->currentText()) { Settings->setPublicChatStyle(info.stylePath, ui.publicComboBoxVariant->currentText()); - NotifyQt::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_PUBLIC); + RsGUIEventManager::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_PUBLIC); } } @@ -196,7 +196,7 @@ void ChatPage::updatePrivateStyle() if (privateStylePath != info.stylePath || privateStyleVariant != ui.privateComboBoxVariant->currentText()) { Settings->setPrivateChatStyle(info.stylePath, ui.privateComboBoxVariant->currentText()); - NotifyQt::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_PRIVATE); + RsGUIEventManager::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_PRIVATE); } } @@ -206,7 +206,7 @@ void ChatPage::updateHistoryStyle() if (historyStylePath != info.stylePath || historyStyleVariant != ui.historyComboBoxVariant->currentText()) { Settings->setHistoryChatStyle(info.stylePath, ui.historyComboBoxVariant->currentText()); - NotifyQt::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_HISTORY); + RsGUIEventManager::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_HISTORY); } } @@ -233,13 +233,14 @@ ChatPage::ChatPage(QWidget * parent, Qt::WindowFlags flags) connect(ui.distantChatComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(distantChatComboBoxChanged(int))); - connect(ui.checkBox_emoteprivchat, SIGNAL(toggled(bool)), this, SLOT(updateFontsAndEmotes())); - connect(ui.checkBox_emotegroupchat, SIGNAL(toggled(bool)), this, SLOT(updateFontsAndEmotes())); - connect(ui.checkBox_enableCustomFonts, SIGNAL(toggled(bool)), this, SLOT(updateFontsAndEmotes())); - connect(ui.minimumFontSize, SIGNAL(valueChanged(int)), this, SLOT(updateFontsAndEmotes())); - connect(ui.checkBox_enableBold, SIGNAL(toggled(bool)), this, SLOT(updateFontsAndEmotes())); - connect(ui.checkBox_enableItalics, SIGNAL(toggled(bool)), this, SLOT(updateFontsAndEmotes())); - connect(ui.minimumContrast, SIGNAL(valueChanged(int)), this, SLOT(updateFontsAndEmotes())); + connect(ui.checkBox_emoteprivchat, SIGNAL(toggled(bool)), this, SLOT(updateFontsAndEmotes())); + connect(ui.checkBox_emotegroupchat, SIGNAL(toggled(bool)), this, SLOT(updateFontsAndEmotes())); + connect(ui.checkBox_enableCustomFonts, SIGNAL(toggled(bool)), this, SLOT(updateFontsAndEmotes())); + connect(ui.checkBox_enableCustomFontSize, SIGNAL(toggled(bool)), this, SLOT(updateFontsAndEmotes())); + connect(ui.minimumFontSize, SIGNAL(valueChanged(int)), this, SLOT(updateFontsAndEmotes())); + connect(ui.checkBox_enableBold, SIGNAL(toggled(bool)), this, SLOT(updateFontsAndEmotes())); + connect(ui.checkBox_enableItalics, SIGNAL(toggled(bool)), this, SLOT(updateFontsAndEmotes())); + connect(ui.minimumContrast, SIGNAL(valueChanged(int)), this, SLOT(updateFontsAndEmotes())); connect(ui.distantChatComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateChatParams())); connect(ui.sendMessageWithCtrlReturn, SIGNAL(toggled(bool)), this, SLOT(updateChatParams())); @@ -261,12 +262,12 @@ ChatPage::ChatPage(QWidget * parent, Qt::WindowFlags flags) connect(ui.privateChatLoadCount, SIGNAL(valueChanged(int)), this, SLOT(updateHistoryParams())); connect(ui.distantChatLoadCount, SIGNAL(valueChanged(int)), this, SLOT(updateHistoryParams())); connect(ui.lobbyChatLoadCount, SIGNAL(valueChanged(int)), this, SLOT(updateHistoryParams())); - + connect(ui.publicChatEnable, SIGNAL(toggled(bool)), this, SLOT(updateHistoryParams())); connect(ui.privateChatEnable, SIGNAL(toggled(bool)), this, SLOT(updateHistoryParams())); connect(ui.distantChatEnable, SIGNAL(toggled(bool)), this, SLOT(updateHistoryParams())); connect(ui.lobbyChatEnable, SIGNAL(toggled(bool)), this, SLOT(updateHistoryParams())); - + connect(ui.publicChatSaveCount, SIGNAL(valueChanged(int)), this, SLOT(updateHistoryParams())); connect(ui.privateChatSaveCount, SIGNAL(valueChanged(int)), this, SLOT(updateHistoryParams())); connect(ui.lobbyChatSaveCount, SIGNAL(valueChanged(int)), this, SLOT(updateHistoryParams())); @@ -353,18 +354,18 @@ void ChatPage::updateChatLobbyUserNotify() void ChatPage::updateChatFlags() { - uint chatflags = 0; + RsChatFlags chatflags(RsChatFlags::RS_CHAT_NONE); if (ui.chat_NewWindow->isChecked()) - chatflags |= RS_CHAT_OPEN; + chatflags |= RsChatFlags::RS_CHAT_OPEN; if (ui.chat_Focus->isChecked()) - chatflags |= RS_CHAT_FOCUS; + chatflags |= RsChatFlags::RS_CHAT_FOCUS; if (ui.chat_tabbedWindow->isChecked()) - chatflags |= RS_CHAT_TABBED_WINDOW; + chatflags |= RsChatFlags::RS_CHAT_TABBED_WINDOW; if (ui.chat_Blink->isChecked()) - chatflags |= RS_CHAT_BLINK; + chatflags |= RsChatFlags::RS_CHAT_BLINK; - Settings->setChatFlags(chatflags); + Settings->setChatFlags((uint32_t)chatflags); } void ChatPage::updateChatLobbyFlags() @@ -386,7 +387,7 @@ ChatPage::load() whileBlocking(ui.checkBox_emotegroupchat)->setChecked(Settings->value("Emoteicons_GroupChat", true).toBool()); whileBlocking(ui.checkBox_enableCustomFonts)->setChecked(Settings->value("EnableCustomFonts", true).toBool()); whileBlocking(ui.checkBox_enableCustomFontSize)->setChecked(Settings->value("EnableCustomFontSize", true).toBool()); - whileBlocking(ui.minimumFontSize)->setValue(Settings->value("MinimumFontSize", 10).toInt()); + whileBlocking(ui.minimumFontSize)->setValue(Settings->value("MinimumFontSize", 10).toInt()); whileBlocking(ui.checkBox_enableBold)->setChecked(Settings->value("EnableBold", true).toBool()); whileBlocking(ui.checkBox_enableItalics)->setChecked(Settings->value("EnableItalics", true).toBool()); whileBlocking(ui.minimumContrast)->setValue(Settings->value("MinimumContrast", 4.5).toDouble()); @@ -450,7 +451,7 @@ ChatPage::load() whileBlocking(ui.lobbyChatSaveCount)->setValue(rsHistory->getSaveCount(RS_HISTORY_TYPE_LOBBY)); whileBlocking(ui.distantChatSaveCount)->setValue(rsHistory->getSaveCount(RS_HISTORY_TYPE_DISTANT)); - + // using fontTempChat.rawname() does not always work! // see http://doc.qt.digia.com/qt-maemo/qfont.html#rawName QStringList fontname = fontTempChat.toString().split(","); @@ -472,12 +473,12 @@ ChatPage::load() if(!gxs_id.isNull()) ui.chatLobbyIdentity_IC->setChosenId(gxs_id); - uint chatflags = Settings->getChatFlags(); + RsChatFlags chatflags = (RsChatFlags) Settings->getChatFlags(); - whileBlocking(ui.chat_NewWindow)->setChecked(chatflags & RS_CHAT_OPEN); - whileBlocking(ui.chat_Focus)->setChecked(chatflags & RS_CHAT_FOCUS); - whileBlocking(ui.chat_tabbedWindow)->setChecked(chatflags & RS_CHAT_TABBED_WINDOW); - whileBlocking(ui.chat_Blink)->setChecked(chatflags & RS_CHAT_BLINK); + whileBlocking(ui.chat_NewWindow)->setChecked(!!(chatflags & RsChatFlags::RS_CHAT_OPEN)); + whileBlocking(ui.chat_Focus)->setChecked(!!(chatflags & RsChatFlags::RS_CHAT_FOCUS)); + whileBlocking(ui.chat_tabbedWindow)->setChecked(!!(chatflags & RsChatFlags::RS_CHAT_TABBED_WINDOW)); + whileBlocking(ui.chat_Blink)->setChecked(!!(chatflags & RsChatFlags::RS_CHAT_BLINK)); uint chatLobbyFlags = Settings->getChatLobbyFlags(); @@ -494,7 +495,7 @@ ChatPage::load() QString tt ; tt += tr("Name :")+" " + QString::fromUtf8(detail.name.c_str()) ; tt += "\n" + tr("PGP id :")+" " + QString::fromStdString(invites[i].destination_pgp_id.toStdString()) ; - tt += "\n" + tr("Valid until :")+" " + QDateTime::fromTime_t(invites[i].time_of_validity).toString() ; + tt += "\n" + tr("Valid until :")+" " + DateTime::DateTimeFromTime_t(invites[i].time_of_validity).toString() ; item->setData(Qt::UserRole,QString::fromStdString(invites[i].pid.toStdString())) ; item->setToolTip(tt) ; @@ -538,7 +539,7 @@ void ChatPage::setPreviewMessages(QString &stylePath, QString styleVariant, QTex QString nameIncoming = tr("Incoming"); QString nameOutgoing = tr("Outgoing"); - QDateTime timestmp = QDateTime::fromTime_t(time(NULL)); + QDateTime timestmp = DateTime::DateTimeFromTime_t(time(NULL)); QColor backgroundColor = textBrowser->palette().base().color(); textBrowser->append(style.formatMessage(ChatStyle::FORMATMSG_HINCOMING, nameIncoming, timestmp, tr("Incoming message in history"), 0, backgroundColor)); @@ -685,10 +686,9 @@ void ChatPage::on_cbSearch_WithoutLimit_toggled(bool checked) void ChatPage::on_btSearch_FoundColor_clicked() { - bool ok; - QRgb color = QColorDialog::getRgba(rgbChatSearchFoundColor, &ok, window()); - if (ok) { - rgbChatSearchFoundColor=color; + QColor color = QColorDialog::getColor(QColor::fromRgba(rgbChatSearchFoundColor), window(), "", QColorDialog::ShowAlphaChannel); + if (color.isValid()) { + rgbChatSearchFoundColor = color.rgba(); QPixmap pix(24, 24); pix.fill(color); ui.btSearch_FoundColor->setIcon(pix); @@ -711,4 +711,3 @@ void ChatPage::distantChatComboBoxChanged(int i) } } - diff --git a/retroshare-gui/src/gui/settings/CryptoPage.cpp b/retroshare-gui/src/gui/settings/CryptoPage.cpp index 296f6aec3..45e2a0b06 100755 --- a/retroshare-gui/src/gui/settings/CryptoPage.cpp +++ b/retroshare-gui/src/gui/settings/CryptoPage.cpp @@ -212,7 +212,11 @@ bool CryptoPage::fileSave() if (!file.open(QFile::WriteOnly)) return false; QTextStream ts(&file); +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) + ts.setEncoding(QStringConverter::Utf8); +#else ts.setCodec(QTextCodec::codecForName("UTF-8")); +#endif ts << ui.certplainTextEdit->document()->toPlainText(); return true; } diff --git a/retroshare-gui/src/gui/settings/CryptoPage.h b/retroshare-gui/src/gui/settings/CryptoPage.h index e10cbb97a..f45e4b29a 100755 --- a/retroshare-gui/src/gui/settings/CryptoPage.h +++ b/retroshare-gui/src/gui/settings/CryptoPage.h @@ -31,7 +31,7 @@ class CryptoPage : public ConfigPage public: /** Default Constructor */ - CryptoPage(QWidget * parent = 0, Qt::WindowFlags flags = 0); + CryptoPage(QWidget * parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); /** Default Destructor */ ~CryptoPage(); diff --git a/retroshare-gui/src/gui/settings/FileAssociationsPage.h b/retroshare-gui/src/gui/settings/FileAssociationsPage.h index 721c29969..0bf79d705 100755 --- a/retroshare-gui/src/gui/settings/FileAssociationsPage.h +++ b/retroshare-gui/src/gui/settings/FileAssociationsPage.h @@ -49,7 +49,7 @@ class FileAssociationsPage : public ConfigPage Q_OBJECT public: - FileAssociationsPage(QWidget * parent = 0, Qt::WindowFlags flags = 0); + FileAssociationsPage(QWidget * parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); virtual ~FileAssociationsPage(); virtual void load(); diff --git a/retroshare-gui/src/gui/settings/ForumPage.h b/retroshare-gui/src/gui/settings/ForumPage.h index 3827df0e4..0c8ed402f 100644 --- a/retroshare-gui/src/gui/settings/ForumPage.h +++ b/retroshare-gui/src/gui/settings/ForumPage.h @@ -30,7 +30,7 @@ class ForumPage : public ConfigPage Q_OBJECT public: - ForumPage(QWidget * parent = 0, Qt::WindowFlags flags = 0); + ForumPage(QWidget * parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); ~ForumPage(); /** Loads the settings for this page */ diff --git a/retroshare-gui/src/gui/settings/GeneralPage.h b/retroshare-gui/src/gui/settings/GeneralPage.h index b36471cbe..a2413e748 100755 --- a/retroshare-gui/src/gui/settings/GeneralPage.h +++ b/retroshare-gui/src/gui/settings/GeneralPage.h @@ -32,7 +32,7 @@ class GeneralPage : public ConfigPage public: /** Default Constructor */ - GeneralPage(QWidget * parent = 0, Qt::WindowFlags flags = 0); + GeneralPage(QWidget * parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); /** Default Destructor */ ~GeneralPage(); diff --git a/retroshare-gui/src/gui/settings/GroupFrameSettingsWidget.cpp b/retroshare-gui/src/gui/settings/GroupFrameSettingsWidget.cpp index 6bf4c1886..2ea51fd57 100644 --- a/retroshare-gui/src/gui/settings/GroupFrameSettingsWidget.cpp +++ b/retroshare-gui/src/gui/settings/GroupFrameSettingsWidget.cpp @@ -20,8 +20,8 @@ #include -#include "gui/notifyqt.h" #include "util/misc.h" +#include "gui/RsGUIEventManager.h" #include "GroupFrameSettingsWidget.h" #include "ui_GroupFrameSettingsWidget.h" @@ -78,6 +78,6 @@ void GroupFrameSettingsWidget::saveSettings() Settings->setGroupFrameSettings(mType, groupFrameSettings); - NotifyQt::getInstance()->notifySettingsChanged(); + RsGUIEventManager::getInstance()->notifySettingsChanged(); } } diff --git a/retroshare-gui/src/gui/settings/JsonApiPage.cc b/retroshare-gui/src/gui/settings/JsonApiPage.cc index ace092e0c..a7ad05574 100644 --- a/retroshare-gui/src/gui/settings/JsonApiPage.cc +++ b/retroshare-gui/src/gui/settings/JsonApiPage.cc @@ -28,6 +28,8 @@ #include #include #include +#include +#include #define IMAGE_LEDOFF ":/images/ledoff1.png" #define IMAGE_LEDON ":/images/ledon1.png" @@ -47,8 +49,8 @@ JsonApiPage::JsonApiPage(QWidget */*parent*/, Qt::WindowFlags /*flags*/) // This limits the possible tokens to alphanumeric QString anRange = "[a-zA-Z0-9]+"; - QRegExp anRegex ("^" + anRange + ":" + anRange + "$"); - QRegExpValidator *anValidator = new QRegExpValidator(anRegex, this); + QRegularExpression anRegex ("^" + anRange + ":" + anRange + "$"); + QRegularExpressionValidator *anValidator = new QRegularExpressionValidator(anRegex, this); ui.tokenLineEdit->setValidator(anValidator); @@ -56,8 +58,8 @@ JsonApiPage::JsonApiPage(QWidget */*parent*/, Qt::WindowFlags /*flags*/) QString ipRange = "(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])"; // You may want to use QRegularExpression for new code with Qt 5 (not mandatory). - QRegExp ipRegex ("^" + ipRange + "\\." + ipRange + "\\." + ipRange + "\\." + ipRange + "$"); - QRegExpValidator *ipValidator = new QRegExpValidator(ipRegex, this); + QRegularExpression ipRegex ("^" + ipRange + "\\." + ipRange + "\\." + ipRange + "\\." + ipRange + "$"); + QRegularExpressionValidator *ipValidator = new QRegularExpressionValidator(ipRegex, this); ui.listenAddressLineEdit->setValidator(ipValidator); ui.providersListView->setSelectionMode(QAbstractItemView::NoSelection); // prevents edition. @@ -232,22 +234,22 @@ void JsonApiPage::addTokenClicked() whileBlocking(ui.tokensListView)->setModel(new QStringListModel(newTk)); } -void JsonApiPage::removeTokenClicked() -{ - QString token(ui.tokenLineEdit->text()); - std::string tokenStr = token.toStdString(); - rsJsonApi->revokeAuthToken(tokenStr.substr(0, tokenStr.find_first_of(":"))); - - QStringList newTk; - - for(const auto& it : rsJsonApi->getAuthorizedTokens()) - newTk.push_back( - QString::fromStdString(it.first) + ":" + - QString::fromStdString(it.second) ); - - whileBlocking(ui.tokensListView)->setModel(new QStringListModel(Settings->getJsonApiAuthTokens()) ); -} - +void JsonApiPage::removeTokenClicked() +{ + QString token(ui.tokenLineEdit->text()); + std::string tokenStr = token.toStdString(); + rsJsonApi->revokeAuthToken(tokenStr.substr(0, tokenStr.find_first_of(":"))); + + QStringList newTk; + + for(const auto& it : rsJsonApi->getAuthorizedTokens()) + newTk.push_back( + QString::fromStdString(it.first) + ":" + + QString::fromStdString(it.second) ); + + whileBlocking(ui.tokensListView)->setModel(new QStringListModel(Settings->getJsonApiAuthTokens()) ); +} + void JsonApiPage::tokenClicked(const QModelIndex& index) { ui.tokenLineEdit->setText(ui.tokensListView->model()->data(index).toString()); diff --git a/retroshare-gui/src/gui/settings/JsonApiPage.h b/retroshare-gui/src/gui/settings/JsonApiPage.h index ef28a4294..9d5755213 100644 --- a/retroshare-gui/src/gui/settings/JsonApiPage.h +++ b/retroshare-gui/src/gui/settings/JsonApiPage.h @@ -32,7 +32,7 @@ class JsonApiPage : public ConfigPage public: - JsonApiPage(QWidget * parent = nullptr, Qt::WindowFlags flags = 0); + JsonApiPage(QWidget * parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); ~JsonApiPage() override ; virtual QPixmap iconPixmap() const override diff --git a/retroshare-gui/src/gui/settings/MessagePage.cpp b/retroshare-gui/src/gui/settings/MessagePage.cpp index be8b515ff..ac16048b2 100644 --- a/retroshare-gui/src/gui/settings/MessagePage.cpp +++ b/retroshare-gui/src/gui/settings/MessagePage.cpp @@ -27,10 +27,10 @@ #include "MessagePage.h" #include "util/misc.h" #include "gui/common/TagDefs.h" +#include "gui/RsGUIEventManager.h" #include #include "NewTag.h" #include "util/qtthreadsutils.h" -#include "gui/notifyqt.h" MessagePage::MessagePage(QWidget * parent, Qt::WindowFlags flags) : ConfigPage(parent, flags) @@ -49,8 +49,8 @@ MessagePage::MessagePage(QWidget * parent, Qt::WindowFlags flags) ui.editpushButton->setEnabled(false); ui.deletepushButton->setEnabled(false); - ui.openComboBox->addItem(tr("A new tab"), RshareSettings::MSG_OPEN_TAB); - ui.openComboBox->addItem(tr("A new window"), RshareSettings::MSG_OPEN_WINDOW); + ui.openComboBox->addItem(tr("A new tab"), (int)RsSettingsMsgOptions::MSG_OPEN_TAB); + ui.openComboBox->addItem(tr("A new window"), (int)RsSettingsMsgOptions::MSG_OPEN_WINDOW); // Font size QFontDatabase db; @@ -97,7 +97,7 @@ void MessagePage::distantMsgsComboBoxChanged(int i) void MessagePage::updateMsgToReadOnActivate() { Settings->setMsgSetToReadOnActivate(ui.setMsgToReadOnActivate->isChecked()); } void MessagePage::updateLoadEmbededImages() { Settings->setMsgLoadEmbeddedImages(ui.loadEmbeddedImages->isChecked()); } -void MessagePage::updateMsgOpen() { Settings->setMsgOpen( static_cast(ui.openComboBox->itemData(ui.openComboBox->currentIndex()).toInt()) ); } +void MessagePage::updateMsgOpen() { Settings->setMsgOpen( (RsSettingsMsgOptions)(ui.openComboBox->itemData(ui.openComboBox->currentIndex()).toInt()) ); } void MessagePage::updateDistantMsgs() { Settings->setValue("DistantMessages", ui.comboBox->currentIndex()); } void MessagePage::updateLoadEmoticons() { Settings->setValueToGroup("Messages", "Emoticons", ui.emoticonscheckBox->isChecked()); } @@ -128,7 +128,7 @@ MessagePage::load() { whileBlocking(ui.setMsgToReadOnActivate)->setChecked(Settings->getMsgSetToReadOnActivate()); whileBlocking(ui.loadEmbeddedImages)->setChecked(Settings->getMsgLoadEmbeddedImages()); - whileBlocking(ui.openComboBox)->setCurrentIndex(ui.openComboBox->findData(Settings->getMsgOpen())); + whileBlocking(ui.openComboBox)->setCurrentIndex(ui.openComboBox->findData((uint)Settings->getMsgOpen())); whileBlocking(ui.emoticonscheckBox)->setChecked(Settings->value("Emoticons", true).toBool()); whileBlocking(ui.minimumFontSize)->setCurrentIndex(ui.minimumFontSize->findData(Settings->getMessageFontSize())); @@ -311,5 +311,5 @@ void MessagePage::updateFontSize() { Settings->setMessageFontSize(ui.minimumFontSize->currentData().toInt()); - NotifyQt::getInstance()->notifySettingsChanged(); + RsGUIEventManager::getInstance()->notifySettingsChanged(); } diff --git a/retroshare-gui/src/gui/settings/MessagePage.h b/retroshare-gui/src/gui/settings/MessagePage.h index c5b9f7544..e226a4387 100644 --- a/retroshare-gui/src/gui/settings/MessagePage.h +++ b/retroshare-gui/src/gui/settings/MessagePage.h @@ -34,7 +34,7 @@ class MessagePage : public ConfigPage Q_OBJECT public: - MessagePage(QWidget * parent = 0, Qt::WindowFlags flags = 0); + MessagePage(QWidget * parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); ~MessagePage(); /** Loads the settings for this page */ diff --git a/retroshare-gui/src/gui/settings/NewTag.cpp b/retroshare-gui/src/gui/settings/NewTag.cpp index 09489ad89..bfc1b16b9 100644 --- a/retroshare-gui/src/gui/settings/NewTag.cpp +++ b/retroshare-gui/src/gui/settings/NewTag.cpp @@ -123,10 +123,9 @@ void NewTag::textChanged(const QString &text) void NewTag::setTagColor() { - bool ok; - QRgb color = QColorDialog::getRgba(m_Color, &ok, this); - if (ok) { - m_Color = color; + QColor color = QColorDialog::getColor(QColor::fromRgba(m_Color), this, "", QColorDialog::ShowAlphaChannel); + if (color.isValid()) { + m_Color = color.rgba(); showColor (m_Color); } } diff --git a/retroshare-gui/src/gui/settings/NewTag.h b/retroshare-gui/src/gui/settings/NewTag.h index 00266d2ae..f4ebe5479 100644 --- a/retroshare-gui/src/gui/settings/NewTag.h +++ b/retroshare-gui/src/gui/settings/NewTag.h @@ -35,7 +35,7 @@ class NewTag : public QDialog public: /** Default constructor */ - NewTag(MsgTagType &Tags, uint32_t nId = 0, QWidget *parent = 0, Qt::WindowFlags flags = 0); + NewTag(MsgTagType &Tags, uint32_t nId = 0, QWidget *parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); uint32_t m_nId; diff --git a/retroshare-gui/src/gui/settings/NotifyPage.cpp b/retroshare-gui/src/gui/settings/NotifyPage.cpp index 8fb6fda49..189a93cc2 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.cpp +++ b/retroshare-gui/src/gui/settings/NotifyPage.cpp @@ -21,15 +21,15 @@ #include #include "NotifyPage.h" -#include #include #include "rsharesettings.h" #include "gui/MainWindow.h" +#include "gui/RsGUIEventManager.h" #include "gui/common/UserNotify.h" #include "gui/common/FeedNotify.h" #include "gui/common/ToasterNotify.h" -#include "gui/notifyqt.h" +#include "gui/feeds/FeedItem.h" #include "gui/NewsFeed.h" #include "util/misc.h" @@ -44,8 +44,8 @@ NotifyPage::NotifyPage(QWidget * parent, Qt::WindowFlags flags) connect(ui.testFeedButton, SIGNAL(clicked()), this, SLOT(testFeed())); connect(ui.testToasterButton, SIGNAL(clicked()), this, SLOT(testToaster())); - connect(ui.pushButtonDisableAll,SIGNAL(toggled(bool)), NotifyQt::getInstance(), SLOT(SetDisableAll(bool))); - connect(NotifyQt::getInstance(),SIGNAL(disableAllChanged(bool)), ui.pushButtonDisableAll, SLOT(setChecked(bool))); + connect(ui.pushButtonDisableAll,SIGNAL(toggled(bool)), RsGUIEventManager::getInstance(), SLOT(SetDisableAll(bool))); + connect(RsGUIEventManager::getInstance(),SIGNAL(disableAllChanged(bool)), ui.pushButtonDisableAll, SLOT(setChecked(bool))); ui.notify_Blogs->hide(); @@ -129,7 +129,7 @@ NotifyPage::NotifyPage(QWidget * parent, Qt::WindowFlags flags) QCheckBox *enabledCheckBox = new QCheckBox(name, this); enabledCheckBox->setFont(font); - ui.notifyLayout->addWidget(enabledCheckBox, rowFeed, 0, 0); + ui.notifyLayout->addWidget(enabledCheckBox, rowFeed, 0); connect(enabledCheckBox, SIGNAL(toggled(bool)), this, SLOT(notifyToggled())); QCheckBox *combinedCheckBox = new QCheckBox(tr("Combined"), this); @@ -180,32 +180,32 @@ NotifyPage::~NotifyPage() { } -uint NotifyPage::getNewsFlags() +RsFeedTypeFlags NotifyPage::getNewsFlags() { - uint newsFlags = 0; + RsFeedTypeFlags newsFlags(RsFeedTypeFlags::RS_FEED_TYPE_NONE); if (ui.notify_Peers->isChecked()) - newsFlags |= RS_FEED_TYPE_PEER; + newsFlags |= RsFeedTypeFlags::RS_FEED_TYPE_PEER; if (ui.notify_Circles->isChecked()) - newsFlags |= RS_FEED_TYPE_CIRCLE; + newsFlags |= RsFeedTypeFlags::RS_FEED_TYPE_CIRCLE; if (ui.notify_Channels->isChecked()) - newsFlags |= RS_FEED_TYPE_CHANNEL; + newsFlags |= RsFeedTypeFlags::RS_FEED_TYPE_CHANNEL; if (ui.notify_Forums->isChecked()) - newsFlags |= RS_FEED_TYPE_FORUM; + newsFlags |= RsFeedTypeFlags::RS_FEED_TYPE_FORUM; if (ui.notify_Posted->isChecked()) - newsFlags |= RS_FEED_TYPE_POSTED; + newsFlags |= RsFeedTypeFlags::RS_FEED_TYPE_POSTED; #if 0 if (ui.notify_Blogs->isChecked()) newsFlags |= RS_FEED_TYPE_BLOG; #endif if (ui.notify_Messages->isChecked()) - newsFlags |= RS_FEED_TYPE_MSG; + newsFlags |= RsFeedTypeFlags::RS_FEED_TYPE_MSG; if (ui.notify_Chat->isChecked()) - newsFlags |= RS_FEED_TYPE_CHAT; + newsFlags |= RsFeedTypeFlags::RS_FEED_TYPE_CHAT; if (ui.notify_Security->isChecked()) - newsFlags |= RS_FEED_TYPE_SECURITY; + newsFlags |= RsFeedTypeFlags::RS_FEED_TYPE_SECURITY; if (ui.notify_SecurityIp->isChecked()) - newsFlags |= RS_FEED_TYPE_SECURITY_IP; + newsFlags |= RsFeedTypeFlags::RS_FEED_TYPE_SECURITY_IP; return newsFlags; } @@ -220,24 +220,24 @@ QString NotifyPage::helpText() const } -uint NotifyPage::getNotifyFlags() +RsNotifyPopupFlags NotifyPage::getNotifyFlags() { - uint notifyFlags = 0; + RsNotifyPopupFlags notifyFlags(RsNotifyPopupFlags::RS_POPUP_NONE); if (ui.popup_Connect->isChecked()) - notifyFlags |= RS_POPUP_CONNECT; + notifyFlags |= RsNotifyPopupFlags::RS_POPUP_CONNECT; if (ui.popup_NewMsg->isChecked()) - notifyFlags |= RS_POPUP_MSG; + notifyFlags |= RsNotifyPopupFlags::RS_POPUP_MSG; if (ui.popup_DownloadFinished->isChecked()) - notifyFlags |= RS_POPUP_DOWNLOAD; + notifyFlags |= RsNotifyPopupFlags::RS_POPUP_DOWNLOAD; if (ui.popup_PrivateChat->isChecked()) - notifyFlags |= RS_POPUP_CHAT; + notifyFlags |= RsNotifyPopupFlags::RS_POPUP_CHAT; if (ui.popup_GroupChat->isChecked()) - notifyFlags |= RS_POPUP_GROUPCHAT; + notifyFlags |= RsNotifyPopupFlags::RS_POPUP_GROUPCHAT; if (ui.popup_ChatLobby->isChecked()) - notifyFlags |= RS_POPUP_CHATLOBBY; + notifyFlags |= RsNotifyPopupFlags::RS_POPUP_CHATLOBBY; if (ui.popup_ConnectAttempt->isChecked()) - notifyFlags |= RS_POPUP_CONNECT_ATTEMPT; + notifyFlags |= RsNotifyPopupFlags::RS_POPUP_CONNECT_ATTEMPT; return notifyFlags; } @@ -273,9 +273,9 @@ void NotifyPage::updateUserNotifySettings() MainWindow::installNotifyIcons(); } -void NotifyPage::updateMessageFlags() { Settings->setMessageFlags( ui.message_ConnectAttempt->isChecked()? RS_MESSAGE_CONNECT_ATTEMPT : 0); } -void NotifyPage::updateNotifyFlags() { Settings->setNotifyFlags(getNotifyFlags()); } -void NotifyPage::updateNewsFeedFlags(){ Settings->setNewsFeedFlags(getNewsFlags()); } +void NotifyPage::updateMessageFlags() { Settings->setMessageFlags( ui.message_ConnectAttempt->isChecked()? uint(RshareSettings::RS_MESSAGE_CONNECT_ATTEMPT) : 0); } +void NotifyPage::updateNotifyFlags() { Settings->setNotifyFlags((int)getNotifyFlags()); } +void NotifyPage::updateNewsFeedFlags(){ Settings->setNewsFeedFlags((int)getNewsFlags()); } void NotifyPage::updateSystrayChatLobby() { Settings->setDisplayTrayChatLobby(ui.systray_ChatLobby->isChecked()); } void NotifyPage::updateSystrayGroupChat() { Settings->setDisplayTrayGroupChat(ui.systray_GroupChat->isChecked()); MainWindow::installGroupChatNotifier(); } @@ -292,40 +292,40 @@ void NotifyPage::updateToasterPosition() void NotifyPage::load() { /* Extract from rsNotify the flags */ - uint notifyflags = Settings->getNotifyFlags() ; - uint newsflags = Settings->getNewsFeedFlags() ; + RsNotifyPopupFlags notifyflags = (RsNotifyPopupFlags)Settings->getNotifyFlags() ; + RsFeedTypeFlags newsflags = (RsFeedTypeFlags)Settings->getNewsFeedFlags() ; uint messageflags = Settings->getMessageFlags() ; - whileBlocking(ui.popup_Connect)->setChecked(notifyflags & RS_POPUP_CONNECT); - whileBlocking(ui.popup_NewMsg)->setChecked(notifyflags & RS_POPUP_MSG); - whileBlocking(ui.popup_DownloadFinished)->setChecked(notifyflags & RS_POPUP_DOWNLOAD); - whileBlocking(ui.popup_PrivateChat)->setChecked(notifyflags & RS_POPUP_CHAT); + whileBlocking(ui.popup_Connect)->setChecked(!!(notifyflags & RsNotifyPopupFlags::RS_POPUP_CONNECT)); + whileBlocking(ui.popup_NewMsg)->setChecked(!!(notifyflags & RsNotifyPopupFlags::RS_POPUP_MSG)); + whileBlocking(ui.popup_DownloadFinished)->setChecked(!!(notifyflags & RsNotifyPopupFlags::RS_POPUP_DOWNLOAD)); + whileBlocking(ui.popup_PrivateChat)->setChecked(!!(notifyflags & RsNotifyPopupFlags::RS_POPUP_CHAT)); #ifdef RS_DIRECT_CHAT - whileBlocking(ui.popup_GroupChat)->setChecked(notifyflags & RS_POPUP_GROUPCHAT); + whileBlocking(ui.popup_GroupChat)->setChecked(!!(notifyflags & RsNotifyPopupFlags::RS_POPUP_GROUPCHAT)); #endif // def RS_DIRECT_CHAT - whileBlocking(ui.popup_ChatLobby)->setChecked(notifyflags & RS_POPUP_CHATLOBBY); - whileBlocking(ui.popup_ConnectAttempt)->setChecked(notifyflags & RS_POPUP_CONNECT_ATTEMPT); + whileBlocking(ui.popup_ChatLobby)->setChecked(!!(notifyflags & RsNotifyPopupFlags::RS_POPUP_CHATLOBBY)); + whileBlocking(ui.popup_ConnectAttempt)->setChecked(!!(notifyflags & RsNotifyPopupFlags::RS_POPUP_CONNECT_ATTEMPT)); - whileBlocking(ui.notify_Peers)->setChecked(newsflags & RS_FEED_TYPE_PEER); - whileBlocking(ui.notify_Circles)->setChecked(newsflags & RS_FEED_TYPE_CIRCLE); - whileBlocking(ui.notify_Channels)->setChecked(newsflags & RS_FEED_TYPE_CHANNEL); - whileBlocking(ui.notify_Forums)->setChecked(newsflags & RS_FEED_TYPE_FORUM); - whileBlocking(ui.notify_Posted)->setChecked(newsflags & RS_FEED_TYPE_POSTED); + whileBlocking(ui.notify_Peers )->setChecked(!!(newsflags & RsFeedTypeFlags::RS_FEED_TYPE_PEER)); + whileBlocking(ui.notify_Circles )->setChecked(!!(newsflags & RsFeedTypeFlags::RS_FEED_TYPE_CIRCLE)); + whileBlocking(ui.notify_Channels )->setChecked(!!(newsflags & RsFeedTypeFlags::RS_FEED_TYPE_CHANNEL)); + whileBlocking(ui.notify_Forums )->setChecked(!!(newsflags & RsFeedTypeFlags::RS_FEED_TYPE_FORUM)); + whileBlocking(ui.notify_Posted )->setChecked(!!(newsflags & RsFeedTypeFlags::RS_FEED_TYPE_POSTED)); #if 0 whileBlocking(ui.notify_Blogs)->setChecked(newsflags & RS_FEED_TYPE_BLOG); #endif - whileBlocking(ui.notify_Chat)->setChecked(newsflags & RS_FEED_TYPE_CHAT); - whileBlocking(ui.notify_Messages)->setChecked(newsflags & RS_FEED_TYPE_MSG); - whileBlocking(ui.notify_Chat)->setChecked(newsflags & RS_FEED_TYPE_CHAT); - whileBlocking(ui.notify_Security)->setChecked(newsflags & RS_FEED_TYPE_SECURITY); - whileBlocking(ui.notify_SecurityIp)->setChecked(newsflags & RS_FEED_TYPE_SECURITY_IP); + whileBlocking(ui.notify_Chat )->setChecked(!!(newsflags & RsFeedTypeFlags::RS_FEED_TYPE_CHAT)); + whileBlocking(ui.notify_Messages )->setChecked(!!(newsflags & RsFeedTypeFlags::RS_FEED_TYPE_MSG)); + whileBlocking(ui.notify_Chat )->setChecked(!!(newsflags & RsFeedTypeFlags::RS_FEED_TYPE_CHAT)); + whileBlocking(ui.notify_Security )->setChecked(!!(newsflags & RsFeedTypeFlags::RS_FEED_TYPE_SECURITY)); + whileBlocking(ui.notify_SecurityIp)->setChecked(!!(newsflags & RsFeedTypeFlags::RS_FEED_TYPE_SECURITY_IP)); - whileBlocking(ui.message_ConnectAttempt)->setChecked(messageflags & RS_MESSAGE_CONNECT_ATTEMPT); + whileBlocking(ui.message_ConnectAttempt)->setChecked(messageflags & RshareSettings::RS_MESSAGE_CONNECT_ATTEMPT); whileBlocking(ui.systray_GroupChat)->setChecked(Settings->getDisplayTrayGroupChat()); whileBlocking(ui.systray_ChatLobby)->setChecked(Settings->getDisplayTrayChatLobby()); - whileBlocking(ui.pushButtonDisableAll)->setChecked(NotifyQt::isAllDisable()); + whileBlocking(ui.pushButtonDisableAll)->setChecked(RsGUIEventManager::isAllDisable()); RshareSettings::enumToasterPosition toasterPosition = Settings->getToasterPosition(); ui.comboBoxToasterPosition->clear(); @@ -412,16 +412,16 @@ void NotifyPage::testToaster() { RshareSettings::enumToasterPosition pos = (RshareSettings::enumToasterPosition) ui.comboBoxToasterPosition->itemData(ui.comboBoxToasterPosition->currentIndex()).toInt(); QPoint margin = QPoint(ui.spinBoxToasterXMargin->value(), ui.spinBoxToasterYMargin->value()); - NotifyQt::getInstance()->testToasters(getNotifyFlags(), pos, margin); + RsGUIEventManager::getInstance()->testToasters(getNotifyFlags(), pos, margin); /* notify of plugins */ QList::iterator toasterNotifyIt; for (toasterNotifyIt = mToasterNotifySettingList.begin(); toasterNotifyIt != mToasterNotifySettingList.end(); ++toasterNotifyIt) { if (toasterNotifyIt->mEnabledCheckBox->isChecked()){ if (toasterNotifyIt->mEnabledCheckBox->accessibleName().isEmpty()){ - NotifyQt::getInstance()->testToaster(toasterNotifyIt->mToasterNotify, pos, margin) ; + RsGUIEventManager::getInstance()->testToaster(toasterNotifyIt->mToasterNotify, pos, margin) ; } else { - NotifyQt::getInstance()->testToaster(toasterNotifyIt->mEnabledCheckBox->accessibleName(), toasterNotifyIt->mToasterNotify, pos, margin) ; + RsGUIEventManager::getInstance()->testToaster(toasterNotifyIt->mEnabledCheckBox->accessibleName(), toasterNotifyIt->mToasterNotify, pos, margin) ; } } } diff --git a/retroshare-gui/src/gui/settings/NotifyPage.h b/retroshare-gui/src/gui/settings/NotifyPage.h index 66bf99e1d..3e240c1da 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.h +++ b/retroshare-gui/src/gui/settings/NotifyPage.h @@ -23,8 +23,10 @@ #include #include "ui_NotifyPage.h" +#include "rsharesettings.h" #include "gui/chat/ChatLobbyUserNotify.h" +#include "gui/feeds/FeedItem.h" #include "gui/common/FilesDefs.h" class UserNotify; @@ -72,7 +74,7 @@ class NotifyPage : public ConfigPage public: /** Default Constructor */ - NotifyPage(QWidget *parent = 0, Qt::WindowFlags flags = 0); + NotifyPage(QWidget *parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); /** Default Destructor */ ~NotifyPage(); @@ -102,8 +104,8 @@ private slots: void updateToasterPosition(); private: - uint getNewsFlags(); - uint getNotifyFlags(); + RsFeedTypeFlags getNewsFlags(); + RsNotifyPopupFlags getNotifyFlags(); QList mFeedNotifySettingList; QList mToasterNotifySettingList; diff --git a/retroshare-gui/src/gui/settings/PeoplePage.h b/retroshare-gui/src/gui/settings/PeoplePage.h index ec0af7927..dc88568c2 100644 --- a/retroshare-gui/src/gui/settings/PeoplePage.h +++ b/retroshare-gui/src/gui/settings/PeoplePage.h @@ -30,7 +30,7 @@ class PeoplePage : public ConfigPage Q_OBJECT public: - PeoplePage(QWidget * parent = 0, Qt::WindowFlags flags = 0); + PeoplePage(QWidget * parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); ~PeoplePage(); /** Loads the settings for this page */ diff --git a/retroshare-gui/src/gui/settings/PeoplePage.ui b/retroshare-gui/src/gui/settings/PeoplePage.ui index a654f8a28..3fd4575f6 100644 --- a/retroshare-gui/src/gui/settings/PeoplePage.ui +++ b/retroshare-gui/src/gui/settings/PeoplePage.ui @@ -100,7 +100,7 @@ Qt::RightToLeft
- Delete banned identities after (0 means indefinitely): + Delete banned identities after (0 means never): Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter diff --git a/retroshare-gui/src/gui/settings/PluginsPage.h b/retroshare-gui/src/gui/settings/PluginsPage.h index 00a63070a..1e46eb01a 100644 --- a/retroshare-gui/src/gui/settings/PluginsPage.h +++ b/retroshare-gui/src/gui/settings/PluginsPage.h @@ -31,7 +31,7 @@ class PluginsPage : public ConfigPage Q_OBJECT public: - PluginsPage(QWidget * parent = 0, Qt::WindowFlags flags = 0); + PluginsPage(QWidget * parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); ~PluginsPage(); /** Loads the settings for this page */ diff --git a/retroshare-gui/src/gui/settings/PostedPage.h b/retroshare-gui/src/gui/settings/PostedPage.h index b3c31c6ba..800588b9b 100644 --- a/retroshare-gui/src/gui/settings/PostedPage.h +++ b/retroshare-gui/src/gui/settings/PostedPage.h @@ -33,7 +33,7 @@ class PostedPage : public ConfigPage Q_OBJECT public: - PostedPage(QWidget * parent = 0, Qt::WindowFlags flags = 0); + PostedPage(QWidget * parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); ~PostedPage(); /** Loads the settings for this page */ diff --git a/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp b/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp index 76622625b..9286f4020 100644 --- a/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp +++ b/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp @@ -32,11 +32,13 @@ #include "RSPermissionMatrixWidget.h" #include "gui/settings/ServicePermissionsPage.h" +#include "gui/settings/rsharesettings.h" #include #include #include #include "rsitems/rsserviceids.h" #include +#include "util/RsQtVersion.h" #define NOT_IMPLEMENTED std::cerr << __PRETTY_FUNCTION__ << ": not yet implemented." << std::endl; @@ -246,9 +248,15 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *) _painter->setRenderHint(QPainter::TextAntialiasing); /* Fill in the background */ - _painter->fillRect(_rec, QBrush(BACK_COLOR)); + //_painter->fillRect(_rec, QBrush(BACK_COLOR)); _painter->drawRect(_rec); + if (Settings->getSheetName() == ":Standard_Dark"){ + brushColor = Qt::gray ; + } else { + brushColor = Qt::black ; + } + // draw one line per friend. std::list ssllist ; rsPeers->getFriendList(ssllist) ; @@ -300,13 +308,13 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *) if(name.length() > 20 + 3) name = name.left(20)+"..." ; - peer_name_size = std::max(peer_name_size, fm.width(name)) ; + peer_name_size = std::max(peer_name_size, QFontMetrics_horizontalAdvance(fm, name)) ; names.push_back(name) ; } QPen pen ; pen.setWidth(2) ; - pen.setBrush(FOREGROUND_COLOR) ; + pen.setBrush(brushColor) ; _painter->setPen(pen) ; int i=0; @@ -315,13 +323,13 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *) for(std::list::const_iterator it(ssllist.begin());it!=ssllist.end();++it,++i) { - float X = S*fMATRIX_START_X + peer_name_size - fm.width(names[i]) ; + float X = S*fMATRIX_START_X + peer_name_size - QFontMetrics_horizontalAdvance(fm, names[i]) ; float Y = S*fMATRIX_START_Y + (i+0.5)*S*fROW_SIZE + line_height/2.0f-2 ; _painter->drawText(QPointF(X,Y),names[i]) ; if(*it == _current_peer_id) - _painter->drawLine(QPointF(X,Y+3),QPointF(X+fm.width(names[i]),Y+3)) ; + _painter->drawLine(QPointF(X,Y+3),QPointF(X+QFontMetrics_horizontalAdvance(fm, names[i]),Y+3)) ; y += line_height ; } @@ -336,7 +344,7 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *) for(std::map::const_iterator it(ownServices.mServiceList.begin());it!=ownServices.mServiceList.end();++it,++i) { QString name = QString::fromUtf8(it->second.mServiceName.c_str()) ; - int text_width = fm.width(name) ; + int text_width = QFontMetrics_horizontalAdvance(fm, name) ; int X = matrix_start_x + S*fCOL_SIZE/2 - 2 + i*S*fCOL_SIZE - text_width/2; @@ -371,7 +379,7 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *) _painter->drawLine(QPointF(X,Y+3),QPointF(X+text_width,Y+3)) ; _painter->drawLine(QPointF(X+text_width/2, Y+3), QPointF(X+text_width/2,S*fMATRIX_START_Y+peer_ids.size()*S*fROW_SIZE - S*fROW_SIZE+5)) ; - pen.setBrush(FOREGROUND_COLOR) ; + pen.setBrush(brushColor) ; _painter->setPen(pen) ; _painter->drawText(QPointF(X,Y),name); @@ -490,11 +498,11 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *) QFontMetrics fm(font); int text_size_x = 0 ; - text_size_x = std::max(text_size_x,fm.width(service_name)); - text_size_x = std::max(text_size_x,fm.width(peer_name)); - text_size_x = std::max(text_size_x,fm.width(peer_id)); - text_size_x = std::max(text_size_x,fm.width(local_status)); - text_size_x = std::max(text_size_x,fm.width(remote_status)); + text_size_x = std::max(text_size_x,QFontMetrics_horizontalAdvance(fm, service_name)); + text_size_x = std::max(text_size_x,QFontMetrics_horizontalAdvance(fm, peer_name)); + text_size_x = std::max(text_size_x,QFontMetrics_horizontalAdvance(fm, peer_id)); + text_size_x = std::max(text_size_x,QFontMetrics_horizontalAdvance(fm, local_status)); + text_size_x = std::max(text_size_x,QFontMetrics_horizontalAdvance(fm, remote_status)); // draw a half-transparent rectangle @@ -553,12 +561,12 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *) brush.setStyle(Qt::SolidPattern) ; QPen pen ; pen.setWidth(1) ; - pen.setBrush(FOREGROUND_COLOR) ; + pen.setBrush(brushColor) ; _painter->setPen(pen) ; QRect position = computeNodePosition(0,i,false) ; int popup_x = position.x() + (50 * S / 14.0); int popup_y = position.y() - (10 * S / 14.0) + line_height; - int popup_width = std::max((int)td.size().width(), fm.width(service_name)) + S; + int popup_width = std::max((int)td.size().width(), QFontMetrics_horizontalAdvance(fm, service_name)) + S; int popup_height = td.size().height() + line_height*2; while (popup_x + popup_width > _max_width) popup_x -= S; @@ -604,20 +612,24 @@ bool RSPermissionMatrixWidget::computeServiceAndPeer(int x,int y,uint32_t& servi x -= matrix_start_x ; y -= S*fMATRIX_START_Y ; + float fi = x / (S*fCOL_SIZE); + float fj = y / (S*fROW_SIZE); + int i = (int)fi; + int j = (int)fj; + const float icoFracX = fICON_SIZE_X/fCOL_SIZE; + const float icoFracY = fICON_SIZE_Y/fROW_SIZE; - if(x < 0 || x >= service_ids.size() * S*fCOL_SIZE) return false ; - if(y < 0 || y >= peer_ids.size() * S*fROW_SIZE) return false ; - - if( (x % (int)(S*fCOL_SIZE)) < (S*fCOL_SIZE - S*fICON_SIZE_X)/2) return false ; - if( (x % (int)(S*fCOL_SIZE)) > (S*fCOL_SIZE + S*fICON_SIZE_X)/2) return false ; - - if( (y % (int)(S*fROW_SIZE)) < (S*fROW_SIZE - S*fICON_SIZE_Y)/2) return false ; - if( (y % (int)(S*fROW_SIZE)) > (S*fROW_SIZE + S*fICON_SIZE_Y)/2) return false ; + if( + fi < 0.f || i >= service_ids.size() || + fj < 0.f || j >= peer_ids.size() || + std::fmod(fi + icoFracX/2 + .5f, 1.f) >= icoFracX || + std::fmod(fj + icoFracY/2 + .5f, 1.f) >= icoFracY + ) return false; // 2 - find which widget, by looking into the service perm matrix - service_id = service_ids[x / (int)(S*fCOL_SIZE)] ; - peer_id = peer_ids[y / (int)(S*fCOL_SIZE)] ; + service_id = service_ids[i]; + peer_id = peer_ids[j]; return true ; } @@ -628,22 +640,23 @@ bool RSPermissionMatrixWidget::computeServiceGlobalSwitch(int x,int y,uint32_t& float S = QFontMetricsF(font()).height(); - x -= matrix_start_x ; - y -= S*fMATRIX_START_Y ; + x -= matrix_start_x; + y -= S*fMATRIX_START_Y; + float fi = x / (S*fCOL_SIZE); + int i = (int)fi; + const float icoFracX = fICON_SIZE_X/fCOL_SIZE; - if(x < 0 || x >= service_ids.size() * S*fCOL_SIZE) return false ; - - if( (x % (int)(S*fCOL_SIZE)) < (S*fCOL_SIZE - S*fICON_SIZE_X)/2) return false ; - if( (x % (int)(S*fCOL_SIZE)) > (S*fCOL_SIZE + S*fICON_SIZE_X)/2) return false ; - - if( y < -S*fROW_SIZE ) return false ; - if( y > 0 ) return false ; + if( + fi < 0.f || i >= service_ids.size() || + y >= 0.f || y < -S*fROW_SIZE || + std::fmod(fi + icoFracX/2 + .5f, 1.f) >= icoFracX + ) return false; // 2 - find which widget, by looking into the service perm matrix - service_id = service_ids[x / (int)(S*fCOL_SIZE)] ; + service_id = service_ids[i]; - return true ; + return true; } void RSPermissionMatrixWidget::defaultPermissionSwitched(uint32_t /* ServiceId */,bool /* b */) diff --git a/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.h b/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.h index ffc9a32b0..c72649a52 100644 --- a/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.h +++ b/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.h @@ -24,8 +24,8 @@ #include #include -#include #include +#include #include #include @@ -103,6 +103,7 @@ private: /** The current dimensions of the graph. */ QRect _rec; + QColor brushColor; bool mHideOffline; diff --git a/retroshare-gui/src/gui/settings/ServerPage.cpp b/retroshare-gui/src/gui/settings/ServerPage.cpp index be2404bc8..9fba74a84 100755 --- a/retroshare-gui/src/gui/settings/ServerPage.cpp +++ b/retroshare-gui/src/gui/settings/ServerPage.cpp @@ -20,7 +20,6 @@ #include "ServerPage.h" -#include #include "gui/MainWindow.h" #include "rshare.h" #include "rsharesettings.h" @@ -85,7 +84,6 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags) , manager(NULL), mOngoingConnectivityCheck(-1) , mIsHiddenNode(false), mHiddenType(RS_HIDDEN_TYPE_NONE) , mSamAccessible(false) - , mEventHandlerId(0) { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); @@ -202,8 +200,6 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags) QObject::connect(ui.hiddenpage_proxyAddress_i2p, SIGNAL(textChanged(QString)), this, SLOT(syncI2PProxyAddrNormal(QString))); QObject::connect(ui.hiddenpage_proxyAddress_i2p_2, SIGNAL(textChanged(QString)), this, SLOT(syncI2PProxyAddrSam(QString))); - connect(NotifyQt::getInstance(), SIGNAL(connectionWithoutCert()), this, SLOT(connectionWithoutCert())); - QObject::connect(ui.localPort,SIGNAL(valueChanged(int)),this,SLOT(saveAddresses())); QObject::connect(ui.extPort,SIGNAL(valueChanged(int)),this,SLOT(saveAddresses())); @@ -262,10 +258,15 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags) if (ui.tabWidget->currentIndex() == TAB_HIDDEN_SERVICE) updateOutProxyIndicator(); + mEventHandlerId = 0; rsEvents->registerEventsHandler( [this](std::shared_ptr event) { handleEvent(event); }, mEventHandlerId, RsEventType::NETWORK ); } +ServerPage::~ServerPage() +{ + rsEvents->unregisterEventsHandler(mEventHandlerId); +} void ServerPage::handleEvent(std::shared_ptr e) { if(e->mType != RsEventType::NETWORK) @@ -1666,14 +1667,6 @@ void ServerPage::taskFinished(taskTicket *&ticket) #endif //RS_USE_I2P_SAM3 } -void ServerPage::connectionWithoutCert() -{ - if (mOngoingConnectivityCheck > 0) { - mOngoingConnectivityCheck = -1; - updateInProxyIndicatorResult(true); - } -} - void ServerPage::loadCommon() { /* HIDDEN PAGE SETTINGS - only Proxy (outgoing) */ @@ -1771,8 +1764,6 @@ void ServerPage::updateStatusSam() ui.leBobB32Addr->hide(); ui.pbBobGenAddr->hide(); } - - saveAddresses(); } samStatus ss; diff --git a/retroshare-gui/src/gui/settings/ServerPage.h b/retroshare-gui/src/gui/settings/ServerPage.h index 7d82f2190..47d08a3f0 100755 --- a/retroshare-gui/src/gui/settings/ServerPage.h +++ b/retroshare-gui/src/gui/settings/ServerPage.h @@ -52,8 +52,8 @@ class ServerPage: public ConfigPage, public autoProxyCallback Q_OBJECT public: - ServerPage(QWidget * parent = 0, Qt::WindowFlags flags = 0); - ~ServerPage() {} + ServerPage(QWidget * parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); + ~ServerPage() ; /** Loads the settings for this page */ virtual void load(); @@ -111,8 +111,6 @@ private slots: void syncI2PProxyAddrNormal(QString); void syncI2PProxyAddrSam(QString); - void connectionWithoutCert(); - //Relay Tab void updateRelayOptions(); void updateEnabled(); diff --git a/retroshare-gui/src/gui/settings/ServicePermissionsPage.h b/retroshare-gui/src/gui/settings/ServicePermissionsPage.h index 94c22f9b0..493090e7e 100644 --- a/retroshare-gui/src/gui/settings/ServicePermissionsPage.h +++ b/retroshare-gui/src/gui/settings/ServicePermissionsPage.h @@ -32,7 +32,7 @@ class ServicePermissionsPage: public ConfigPage Q_OBJECT public: - ServicePermissionsPage(QWidget * parent = 0, Qt::WindowFlags flags = 0); + ServicePermissionsPage(QWidget * parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); ~ServicePermissionsPage() {} /** Loads the settings for this page */ diff --git a/retroshare-gui/src/gui/settings/SoundPage.h b/retroshare-gui/src/gui/settings/SoundPage.h index d20426d83..66a6abab5 100644 --- a/retroshare-gui/src/gui/settings/SoundPage.h +++ b/retroshare-gui/src/gui/settings/SoundPage.h @@ -33,7 +33,7 @@ class SoundPage : public ConfigPage public: /** Default Constructor */ - SoundPage(QWidget * parent = 0, Qt::WindowFlags flags = 0); + SoundPage(QWidget * parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); /** Default Destructor */ ~SoundPage(); diff --git a/retroshare-gui/src/gui/settings/TransferPage.h b/retroshare-gui/src/gui/settings/TransferPage.h index 077d5a6ec..6e9413366 100644 --- a/retroshare-gui/src/gui/settings/TransferPage.h +++ b/retroshare-gui/src/gui/settings/TransferPage.h @@ -32,7 +32,7 @@ class TransferPage: public ConfigPage Q_OBJECT public: - TransferPage(QWidget * parent = 0, Qt::WindowFlags flags = 0); + TransferPage(QWidget * parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); ~TransferPage() {} /** Loads the settings for this page */ diff --git a/retroshare-gui/src/gui/settings/WebuiPage.h b/retroshare-gui/src/gui/settings/WebuiPage.h index 391612cf8..760b695b1 100644 --- a/retroshare-gui/src/gui/settings/WebuiPage.h +++ b/retroshare-gui/src/gui/settings/WebuiPage.h @@ -39,7 +39,7 @@ class WebuiPage : public ConfigPage public: /** Default Constructor */ - WebuiPage(QWidget * parent = 0, Qt::WindowFlags flags = 0); + WebuiPage(QWidget * parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); /** Default Destructor */ ~WebuiPage(); diff --git a/retroshare-gui/src/gui/settings/rsettingswin.cpp b/retroshare-gui/src/gui/settings/rsettingswin.cpp index a9fab8895..98c6dbdcb 100644 --- a/retroshare-gui/src/gui/settings/rsettingswin.cpp +++ b/retroshare-gui/src/gui/settings/rsettingswin.cpp @@ -40,7 +40,7 @@ #include "PluginsPage.h" #include "ServicePermissionsPage.h" #include "rsharesettings.h" -#include "gui/notifyqt.h" +#include "gui/RsGUIEventManager.h" #include "gui/common/FloatingHelpBrowser.h" #include "gui/common/RSElidedItemDelegate.h" @@ -238,6 +238,6 @@ void SettingsPage::notifySettingsChanged() /* call to RsIface save function.... */ //rsicontrol -> ConfigSave(); - if (NotifyQt::getInstance()) - NotifyQt::getInstance()->notifySettingsChanged(); + if (RsGUIEventManager::getInstance()) + RsGUIEventManager::getInstance()->notifySettingsChanged(); } diff --git a/retroshare-gui/src/gui/settings/rsharesettings.cpp b/retroshare-gui/src/gui/settings/rsharesettings.cpp index d878d6c99..887d4276f 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.cpp +++ b/retroshare-gui/src/gui/settings/rsharesettings.cpp @@ -27,14 +27,16 @@ #include #include +#include "rsharesettings.h" #include "rsharesettings.h" #include "gui/MainWindow.h" +#include "gui/chat/ChatWidget.h" +#include "gui/feeds/FeedItem.h" #ifdef RS_JSONAPI #include #endif -#include #include #ifdef Q_OS_WIN @@ -133,15 +135,15 @@ void RshareSettings::initSettings() /* defaults here are not ideal.... but dusent matter */ - uint defChat = RS_CHAT_OPEN; + uint defChat = (uint32_t)RsChatFlags::RS_CHAT_OPEN; // This is not default... RS_CHAT_FOCUS. - uint defNotify = (RS_POPUP_CONNECT | RS_POPUP_MSG); - uint defNewsFeed = (RS_FEED_TYPE_MSG | RS_FEED_TYPE_FILES | RS_FEED_TYPE_SECURITY | RS_FEED_TYPE_SECURITY_IP | RS_FEED_TYPE_CIRCLE | RS_FEED_TYPE_CHANNEL |RS_FEED_TYPE_FORUM | RS_FEED_TYPE_POSTED); + RsNotifyPopupFlags defNotify = (RsNotifyPopupFlags::RS_POPUP_CONNECT | RsNotifyPopupFlags::RS_POPUP_MSG); + RsFeedTypeFlags defNewsFeed = (RsFeedTypeFlags::RS_FEED_TYPE_MSG | RsFeedTypeFlags::RS_FEED_TYPE_FILES | RsFeedTypeFlags::RS_FEED_TYPE_SECURITY | RsFeedTypeFlags::RS_FEED_TYPE_SECURITY_IP | RsFeedTypeFlags::RS_FEED_TYPE_CIRCLE | RsFeedTypeFlags::RS_FEED_TYPE_CHANNEL |RsFeedTypeFlags::RS_FEED_TYPE_FORUM | RsFeedTypeFlags::RS_FEED_TYPE_POSTED); - setDefault(SETTING_NEWSFEED_FLAGS, defNewsFeed); + setDefault(SETTING_NEWSFEED_FLAGS, (int)defNewsFeed); setDefault(SETTING_CHAT_FLAGS, defChat); - setDefault(SETTING_NOTIFY_FLAGS, defNotify); + setDefault(SETTING_NOTIFY_FLAGS, (int)defNotify); setDefault("DisplayTrayGroupChat", true); setDefault("AddFeedsAtEnd", false); @@ -1023,30 +1025,31 @@ void RshareSettings::setMsgLoadEmbeddedImages(bool value) setValueToGroup("Message", "LoadEmbeddedImages", value); } -RshareSettings::enumMsgOpen RshareSettings::getMsgOpen() +RsSettingsMsgOptions RshareSettings::getMsgOpen() { - enumMsgOpen value = (enumMsgOpen) valueFromGroup("Message", "msgOpen", MSG_OPEN_TAB).toInt(); + RsSettingsMsgOptions value = (RsSettingsMsgOptions) valueFromGroup("Message", "msgOpen", (int)RsSettingsMsgOptions::MSG_OPEN_TAB).toInt(); switch (value) { - case MSG_OPEN_TAB: - case MSG_OPEN_WINDOW: + default: + case RsSettingsMsgOptions::MSG_OPEN_TAB: + case RsSettingsMsgOptions::MSG_OPEN_WINDOW: return value; } - return MSG_OPEN_TAB; + return RsSettingsMsgOptions::MSG_OPEN_TAB; } -void RshareSettings::setMsgOpen(enumMsgOpen value) +void RshareSettings::setMsgOpen(RsSettingsMsgOptions value) { switch (value) { - case MSG_OPEN_TAB: - case MSG_OPEN_WINDOW: + case RsSettingsMsgOptions::MSG_OPEN_TAB: + case RsSettingsMsgOptions::MSG_OPEN_WINDOW: break; default: - value = MSG_OPEN_TAB; + value = RsSettingsMsgOptions::MSG_OPEN_TAB; } - setValueToGroup("Message", "msgOpen", value); + setValueToGroup("Message", "msgOpen", (int)value); } /* Forum */ diff --git a/retroshare-gui/src/gui/settings/rsharesettings.h b/retroshare-gui/src/gui/settings/rsharesettings.h index 317dedb56..d4b39be9a 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.h +++ b/retroshare-gui/src/gui/settings/rsharesettings.h @@ -28,6 +28,7 @@ #include #include +#include #include #include "rsettings.h" @@ -56,6 +57,38 @@ public: bool mOpenAllInNewTab; bool mHideTabBarWithOneTab; }; +enum class RsNotifyPopupFlags: uint32_t { + RS_POPUP_NONE = 0x0000, + RS_POPUP_MSG = 0x0001, + RS_POPUP_CHAT = 0x0002, + RS_POPUP_CONNECT = 0x0008, +// RS_SYSTRAY_GROUP_MSG = 0x0010, + RS_POPUP_DOWNLOAD = 0x0020, + RS_POPUP_GROUPCHAT = 0x0040, + RS_POPUP_CHATLOBBY = 0x0080, + RS_POPUP_CONNECT_ATTEMPT = 0x0100, + RS_POPUP_ENCRYPTED_MSG = 0x0200, +}; +RS_REGISTER_ENUM_FLAGS_TYPE(RsNotifyPopupFlags); + +//enum class RsNotifySystrayFlags: uint32_t { +// RS_SYSTRAY_GROUP_MSG = 0x0010, +//} +enum class RsNotifySysFlags: uint32_t { + RS_SYS_ERROR = 0x0001, + RS_SYS_WARNING = 0x0002, + RS_SYS_INFO = 0x0004, +}; +RS_REGISTER_ENUM_FLAGS_TYPE(RsNotifySysFlags); + +enum class RsSettingsMsgOptions: uint8_t +{ + MSG_OPEN_NONE = 0x00, + MSG_OPEN_TAB = 0x01, + MSG_OPEN_WINDOW = 0x02, +}; + +RS_REGISTER_ENUM_FLAGS_TYPE(RsSettingsMsgOptions); /** Handles saving and restoring RShares's settings * @@ -86,11 +119,10 @@ public: TOASTERPOS_BOTTOMRIGHT }; - enum enumMsgOpen - { - MSG_OPEN_TAB, - MSG_OPEN_WINDOW - }; + enum enumMsgOptions :uint32_t + { + RS_MESSAGE_CONNECT_ATTEMPT = 0x0001, + }; public: /* create settings object */ @@ -191,8 +223,8 @@ public: uint getNewsFeedFlags(); void setNewsFeedFlags(uint flags); - uint getChatFlags(); - void setChatFlags(uint flags); + uint getChatFlags(); + void setChatFlags(uint flags); uint getChatLobbyFlags(); void setChatLobbyFlags(uint flags); @@ -305,8 +337,8 @@ public: bool getMsgLoadEmbeddedImages(); void setMsgLoadEmbeddedImages(bool value); - enumMsgOpen getMsgOpen(); - void setMsgOpen(enumMsgOpen value); + RsSettingsMsgOptions getMsgOpen(); + void setMsgOpen(RsSettingsMsgOptions value); /* Forum */ bool getForumMsgSetToReadOnActivate(); diff --git a/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.cpp b/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.cpp index f621d355b..b1bc6814e 100644 --- a/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.cpp +++ b/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.cpp @@ -84,12 +84,6 @@ BandwidthGraph::BandwidthGraph(QWidget *parent, Qt::WindowFlags flags) /* Load the previously saved settings */ /* Turn off opacity group on unsupported platforms */ - #if defined(Q_OS_WIN) - if(!(QSysInfo::WV_2000 <= QSysInfo::WindowsVersion)) { - ui.frmOpacity->setVisible(false); - } - #endif - #if defined(Q_OS_LINUX) ui.frmOpacity->setVisible(false); ui.chkAlwaysOnTop->setVisible(false); @@ -283,10 +277,8 @@ void BandwidthGraph::setOpacity(int value) this->setWindowOpacity(newValue); ui.lblPercentOpacity->setText(QString::number(value)); #elif defined(Q_OS_WIN) - if(QSysInfo::WV_2000 <= QSysInfo::WindowsVersion) { - this->setWindowOpacity(newValue); - ui.lblPercentOpacity->setText(QString::number(value)); - } + this->setWindowOpacity(newValue); + ui.lblPercentOpacity->setText(QString::number(value)); #else Q_UNUSED(newValue); #endif diff --git a/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.h b/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.h index 276f7fa6a..5ec993f50 100644 --- a/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.h +++ b/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.h @@ -44,7 +44,7 @@ public: enum { DefaultDirection=0,Download=1 } ; /** Default constructor */ - BandwidthGraph(QWidget *parent = 0, Qt::WindowFlags flags = 0); + BandwidthGraph(QWidget *parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); virtual ~BandwidthGraph(); public slots: diff --git a/retroshare-gui/src/gui/statistics/BwCtrlWindow.cpp b/retroshare-gui/src/gui/statistics/BwCtrlWindow.cpp index 44f606318..adc65ab82 100644 --- a/retroshare-gui/src/gui/statistics/BwCtrlWindow.cpp +++ b/retroshare-gui/src/gui/statistics/BwCtrlWindow.cpp @@ -21,7 +21,7 @@ #include "BwCtrlWindow.h" #include "gui/common/RSGraphWidget.h" #include "ui_BwCtrlWindow.h" -#include "util/QtVersion.h" +#include "util/RsQtVersion.h" #include #include @@ -70,7 +70,7 @@ void BWListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti painter->setClipRect(opt.rect); //set text color - QVariant value = index.data(Qt::TextColorRole); + QVariant value = index.data(Qt::ForegroundRole); if(value.isValid() && qvariant_cast(value).isValid()) { opt.palette.setColor(QPalette::Text, qvariant_cast(value)); } @@ -96,12 +96,12 @@ void BWListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti switch(index.column()) { case COLUMN_IN_RATE: - temp.sprintf("%.3f ", index.data().toFloat()); + temp = QString::asprintf("%.3f ", index.data().toFloat()); //temp=QString::number(index.data().toFloat()); painter->drawText(option.rect, Qt::AlignRight, temp); break; case COLUMN_IN_MAX: - temp.sprintf("%.3f ", index.data().toFloat()); + temp = QString::asprintf("%.3f ", index.data().toFloat()); //temp=QString::number(index.data().toFloat()); painter->drawText(option.rect, Qt::AlignRight, temp); break; @@ -112,7 +112,7 @@ void BWListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti case COLUMN_IN_ALLOC: flValue = index.data().toFloat(); if (flValue < std::numeric_limits::max()){ - temp.sprintf("%.3f ", flValue); + temp = QString::asprintf("%.3f ", flValue); } else { temp=strNA; } @@ -128,12 +128,12 @@ void BWListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti painter->drawText(option.rect, Qt::AlignRight, temp); break; case COLUMN_OUT_RATE: - temp.sprintf("%.3f ", index.data().toFloat()); + temp = QString::asprintf("%.3f ", index.data().toFloat()); //temp=QString::number(index.data().toFloat()); painter->drawText(option.rect, Qt::AlignRight, temp); break; case COLUMN_OUT_MAX: - temp.sprintf("%.3f ", index.data().toFloat()); + temp = QString::asprintf("%.3f ", index.data().toFloat()); //temp=QString::number(index.data().toFloat()); painter->drawText(option.rect, Qt::AlignRight, temp); break; @@ -172,7 +172,7 @@ QSize BWListDelegate::sizeHint(const QStyleOptionViewItem & option/*option*/, co float FS = QFontMetricsF(option.font).height(); //float fact = FS/14.0 ; - float w = QFontMetricsF(option.font).width(index.data(Qt::DisplayRole).toString()); + float w = QFontMetrics_horizontalAdvance(QFontMetricsF(option.font), index.data(Qt::DisplayRole).toString()); return QSize(w,FS*1.2); //return QSize(50*fact,17*fact); diff --git a/retroshare-gui/src/gui/statistics/DhtWindow.cpp b/retroshare-gui/src/gui/statistics/DhtWindow.cpp index a2661955e..52d6b928f 100644 --- a/retroshare-gui/src/gui/statistics/DhtWindow.cpp +++ b/retroshare-gui/src/gui/statistics/DhtWindow.cpp @@ -20,7 +20,7 @@ #include "DhtWindow.h" #include "ui_DhtWindow.h" -#include "util/QtVersion.h" +#include "util/RsQtVersion.h" #include #include diff --git a/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp b/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp index e70044d9a..f0019e9ad 100644 --- a/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp +++ b/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp @@ -31,6 +31,9 @@ #include #include #include +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) +#include +#endif #include #include @@ -43,8 +46,9 @@ #include "gui/gxs/GxsIdDetails.h" #include "gui/gxs/GxsIdTreeWidgetItem.h" #include "util/DateTime.h" -#include "util/QtVersion.h" +#include "util/RsQtVersion.h" #include "util/misc.h" +#include "util/RsQtVersion.h" #define COL_ID 0 #define COL_NICKNAME 1 @@ -188,10 +192,8 @@ void GlobalRouterStatistics::updateContent() if(nicknames.isEmpty()) nicknames = tr("Unknown"); - QDateTime routingtime; - routingtime.setTime_t(cache_infos[i].routing_time); - QDateTime senttime; - senttime.setTime_t(cache_infos[i].last_sent_time); + QDateTime routingtime = DateTime::DateTimeFromTime_t(cache_infos[i].routing_time); + QDateTime senttime = DateTime::DateTimeFromTime_t(cache_infos[i].last_sent_time); item -> setId(cache_infos[i].destination,COL_NICKNAME, false) ; item -> setData(COL_ID, Qt::DisplayRole, QString::number(cache_infos[i].mid,16).rightJustified(16,'0')); @@ -266,7 +268,7 @@ void GlobalRouterStatisticsWidget::updateContent() setFixedHeight(maxHeight); QPainter painter(&tmppixmap); - painter.initFrom(this); + painter.begin(this); painter.setPen(QColor::fromRgb(0,0,0)) ; QFont times_f(font());//"Times") ; @@ -277,7 +279,7 @@ void GlobalRouterStatisticsWidget::updateContent() QFontMetricsF fm_monospace(monospace_f) ; QFontMetricsF fm_times(times_f) ; - static const int cellx = fm_monospace.width(QString(" ")) ; + static const int cellx = QFontMetrics_horizontalAdvance(fm_monospace, QString(" ")) ; static const int celly = fm_monospace.height() ; maxHeight = 500*fact ; @@ -318,11 +320,11 @@ void GlobalRouterStatisticsWidget::updateContent() for(int i=0;i<100*fact;++i) { painter.setPen(colorScale(i/100.0/fact)) ; - painter.drawLine(ox+fm_times.width(Q)+i,oy+fm_times.height()*0.5,ox+fm_times.width(Q)+i,oy+fm_times.height()) ; + painter.drawLine(ox+QFontMetrics_horizontalAdvance(fm_times, Q)+i,oy+fm_times.height()*0.5,ox+QFontMetrics_horizontalAdvance(fm_times, Q)+i,oy+fm_times.height()) ; } painter.setPen(QColor::fromRgb(0,0,0)) ; - painter.drawText(ox+fm_times.width(Q) + 102*fact,oy+celly,")") ; + painter.drawText(ox+QFontMetrics_horizontalAdvance(fm_times, Q) + 102*fact,oy+celly,")") ; oy += celly ; oy += celly ; @@ -372,21 +374,21 @@ void GlobalRouterStatisticsWidget::updateContent() painter.drawText(ox+2*cellx,oy+celly,ids) ; for(uint32_t i=0;isecond[i])) ; + painter.fillRect(ox+i*cellx+QFontMetrics_horizontalAdvance(fm_monospace, ids),oy+0.15*celly,cellx,celly,colorScale(it->second[i])) ; if(n == mCurrentN) { current_probs = it->second ; current_oy = oy ; current_id = it->first ; - current_width = ox+matrix_info.friend_ids.size()*cellx+fm_monospace.width(ids); + current_width = ox+matrix_info.friend_ids.size()*cellx+QFontMetrics_horizontalAdvance(fm_monospace, ids); } oy += celly ; //} } - mMaxWheelZoneX = ox+matrix_info.friend_ids.size()*cellx + fm_monospace.width(ids); + mMaxWheelZoneX = ox+matrix_info.friend_ids.size()*cellx + QFontMetrics_horizontalAdvance(fm_monospace, ids); RsIdentityDetails iddetails ; if(rsIdentity->getIdDetails(current_id,iddetails)) @@ -399,14 +401,14 @@ void GlobalRouterStatisticsWidget::updateContent() painter.setPen(QColor::fromRgb(0,0,0)) ; painter.setPen(QColor::fromRgb(127,127,127)); - painter.drawRect(ox+2*cellx,current_oy+0.15*celly,fm_monospace.width(ids)+cellx*matrix_info.friend_ids.size()- 2*cellx,celly) ; + painter.drawRect(ox+2*cellx,current_oy+0.15*celly,QFontMetrics_horizontalAdvance(fm_monospace, ids)+cellx*matrix_info.friend_ids.size()- 2*cellx,celly) ; float total_length = (matrix_info.friend_ids.size()+2)*cellx ; if(!current_probs.empty()) for(uint32_t i=0;ix() < mMinWheelZoneX || e->x() > mMaxWheelZoneX || e->y() < mMinWheelZoneY || e->y() > mMaxWheelZoneY) +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) + int x = e->position().toPoint().x(); + int y = e->position().toPoint().y(); + int delta = e->angleDelta().y(); +#else + int x = e->x(); + int y = e->y(); + int delta = e->delta(); +#endif + + if(x < mMinWheelZoneX || x > mMaxWheelZoneX || y < mMinWheelZoneY || y > mMaxWheelZoneY) { QWidget::wheelEvent(e) ; return ; } - if(e->delta() < 0 && mCurrentN+PARTIAL_VIEW_SIZE/2+1 < mNumberOfKnownKeys) + if(delta < 0 && mCurrentN+PARTIAL_VIEW_SIZE/2+1 < mNumberOfKnownKeys) mCurrentN++ ; - if(e->delta() > 0 && mCurrentN > PARTIAL_VIEW_SIZE/2+1) + if(delta > 0 && mCurrentN > PARTIAL_VIEW_SIZE/2+1) mCurrentN-- ; updateContent(); diff --git a/retroshare-gui/src/gui/statistics/GxsIdStatistics.cpp b/retroshare-gui/src/gui/statistics/GxsIdStatistics.cpp index 3037839c2..8a877a131 100644 --- a/retroshare-gui/src/gui/statistics/GxsIdStatistics.cpp +++ b/retroshare-gui/src/gui/statistics/GxsIdStatistics.cpp @@ -40,7 +40,7 @@ #include "GxsIdStatistics.h" #include "util/DateTime.h" -#include "util/QtVersion.h" +#include "util/RsQtVersion.h" #include "util/misc.h" #include "util/qtthreadsutils.h" @@ -258,7 +258,7 @@ void GxsIdStatisticsWidget::updateContent() setFixedHeight(mMaxHeight); QPainter painter(&tmppixmap); - painter.initFrom(this); + painter.begin(this); painter.setPen(QColor::fromRgb(0,0,0)) ; QFont times_f(font());//"Times") ; @@ -269,7 +269,7 @@ void GxsIdStatisticsWidget::updateContent() QFontMetricsF fm_monospace(monospace_f) ; QFontMetricsF fm_times(times_f) ; - int cellx = fm_monospace.width(QString(" ")) ; + int cellx = QFontMetrics_horizontalAdvance(fm_monospace, QString(" ")) ; int celly = fm_monospace.height() ; // Display general statistics @@ -336,13 +336,13 @@ void GxsIdStatisticsWidget::updateContent() for(size_t i=0;i setData(COL_PENDING_DATASTATUS, Qt::DisplayRole, getStatusString(rec.status)); item -> setData(COL_PENDING_DATASIZE, Qt::DisplayRole, misc::friendlyUnit(rec.data_size)); item -> setData(COL_PENDING_DATAHASH, Qt::DisplayRole, QString::fromStdString(rec.data_hash.toStdString())); - item -> setData(COL_PENDING_SEND, Qt::DisplayRole, QDateTime::fromTime_t(rec.send_TS).toString()); + item -> setData(COL_PENDING_SEND, Qt::DisplayRole, DateTime::DateTimeFromTime_t(rec.send_TS).toString()); item -> setData(COL_PENDING_GROUP_ID, Qt::DisplayRole, QString::fromStdString(rec.group_id.toStdString())); item -> setData(COL_PENDING_DESTINATION_ID, Qt::DisplayRole, QString::fromStdString(rec.recipient.toStdString())); item -> setData(COL_PENDING_SENDTIME, Qt::DisplayRole, QString::number(now - rec.send_TS)); @@ -272,7 +273,7 @@ void GxsTransportStatistics::updateContent() std::set openned_groups ; for(int i=0; itopLevelItemCount(); ++i) - if( groupTreeWidget->isItemExpanded(groupTreeWidget->topLevelItem(i)) ) + if( groupTreeWidget->topLevelItem(i)->isExpanded() ) openned_groups.insert(RsGxsGroupId(groupTreeWidget->topLevelItem(i)->data(COL_GROUP_GRP_ID, Qt::DisplayRole).toString().toStdString())); groupTreeWidget->clear(); @@ -294,9 +295,9 @@ void GxsTransportStatistics::updateContent() } groupTreeWidget->addTopLevelItem(item); - groupTreeWidget->setItemExpanded(item,openned_groups.find(it->first) != openned_groups.end()); + item->setExpanded(openned_groups.find(it->first) != openned_groups.end()); - QString msg_time_string = (stat.last_publish_TS>0)?QString("(Last msg: %1)").arg(QDateTime::fromTime_t((uint)stat.last_publish_TS).toString()):"" ; + QString msg_time_string = (stat.last_publish_TS>0)?QString("(Last msg: %1)").arg(DateTime::DateTimeFromTime_t((uint)stat.last_publish_TS).toString()):"" ; item->setData(COL_GROUP_PUBLISHTS, Qt::DisplayRole, msg_time_string) ; item->setData(COL_GROUP_NUM_MSGS, Qt::DisplayRole, QString::number(stat.mNumMsgs) ) ; @@ -330,8 +331,7 @@ void GxsTransportStatistics::updateContent() rsIdentity->getIdDetails(meta.mAuthorId,idDetails); QPixmap pixmap ; - QDateTime qdatetime; - qdatetime.setTime_t(meta.mPublishTs); + QDateTime qdatetime = DateTime::DateTimeFromTime_t(meta.mPublishTs); if(idDetails.mAvatar.mSize == 0 || !GxsIdDetails::loadPixmapFromData(idDetails.mAvatar.mData, idDetails.mAvatar.mSize, pixmap,GxsIdDetails::SMALL)) pixmap = GxsIdDetails::makeDefaultIcon(meta.mAuthorId,GxsIdDetails::SMALL); @@ -340,7 +340,7 @@ void GxsTransportStatistics::updateContent() sitem->setData(COL_GROUP_UNIQUE_ID, Qt::DisplayRole,QString::fromStdString(meta.mMsgId.toStdString())); sitem->setData(COL_GROUP_AUTHOR_ID, Qt::DisplayRole, QString::fromStdString(meta.mAuthorId.toStdString())) ; - sitem->setText(COL_GROUP_PUBLISHTS, QDateTime::fromTime_t(meta.mPublishTs).toString()); + sitem->setText(COL_GROUP_PUBLISHTS, DateTime::DateTimeFromTime_t(meta.mPublishTs).toString()); sitem->setData(COL_GROUP_PUBLISHTS, Qt::UserRole, qdatetime); } } diff --git a/retroshare-gui/src/gui/statistics/StatisticsWindow.cpp b/retroshare-gui/src/gui/statistics/StatisticsWindow.cpp index 48b1462cc..684fdc69d 100644 --- a/retroshare-gui/src/gui/statistics/StatisticsWindow.cpp +++ b/retroshare-gui/src/gui/statistics/StatisticsWindow.cpp @@ -22,6 +22,7 @@ #include "ui_StatisticsWindow.h" #include #include +#include #include #include diff --git a/retroshare-gui/src/gui/statistics/TurtleRouterDialog.cpp b/retroshare-gui/src/gui/statistics/TurtleRouterDialog.cpp index b866ae994..05759c3e1 100644 --- a/retroshare-gui/src/gui/statistics/TurtleRouterDialog.cpp +++ b/retroshare-gui/src/gui/statistics/TurtleRouterDialog.cpp @@ -402,7 +402,7 @@ void GxsAuthenticatedTunnelsDialog::updateDisplay() //setFixedHeight(maxHeight); QPainter painter(&tmppixmap); - painter.initFrom(this); + painter.begin(this); // extracts the height of the fonts in pixels. This is used to calibrate the size of the objects to draw. @@ -576,7 +576,7 @@ void GxsNetTunnelsDialog::updateDisplay() //setFixedHeight(maxHeight); QPainter painter(&tmppixmap); - painter.initFrom(this); + painter.begin(this); // extracts the height of the fonts in pixels. This is used to calibrate the size of the objects to draw. diff --git a/retroshare-gui/src/gui/statistics/TurtleRouterStatistics.cpp b/retroshare-gui/src/gui/statistics/TurtleRouterStatistics.cpp index 50015406b..3b45e753d 100644 --- a/retroshare-gui/src/gui/statistics/TurtleRouterStatistics.cpp +++ b/retroshare-gui/src/gui/statistics/TurtleRouterStatistics.cpp @@ -296,7 +296,7 @@ void TurtleRouterStatisticsWidget::updateTunnelStatistics(const std::vectorsetMargin(0); + hbox->setContentsMargins(0, 0, 0, 0); hbox->setSpacing(0); imageButton = new QPushButton(this); diff --git a/retroshare-gui/src/gui/statusbar/SysTrayStatus.cpp b/retroshare-gui/src/gui/statusbar/SysTrayStatus.cpp index 1f52163ec..c4144d67c 100644 --- a/retroshare-gui/src/gui/statusbar/SysTrayStatus.cpp +++ b/retroshare-gui/src/gui/statusbar/SysTrayStatus.cpp @@ -33,7 +33,7 @@ SysTrayStatus::SysTrayStatus(QWidget *parent) : QWidget(parent) { QHBoxLayout *hbox = new QHBoxLayout(this); - hbox->setMargin(0); + hbox->setContentsMargins(0, 0, 0, 0); hbox->setSpacing(0); imageButton = new QPushButton(this); diff --git a/retroshare-gui/src/gui/statusbar/ToasterDisable.cpp b/retroshare-gui/src/gui/statusbar/ToasterDisable.cpp index 273245972..2bfa458bd 100644 --- a/retroshare-gui/src/gui/statusbar/ToasterDisable.cpp +++ b/retroshare-gui/src/gui/statusbar/ToasterDisable.cpp @@ -22,7 +22,7 @@ #include #include "ToasterDisable.h" -#include "gui/notifyqt.h" +#include "gui/RsGUIEventManager.h" #include "gui/common/FilesDefs.h" #define IMAGE_TOASTERDISABLE ":/images/toasterDisable.png" @@ -32,7 +32,7 @@ ToasterDisable::ToasterDisable(QWidget *parent) : QWidget(parent) { QHBoxLayout *hbox = new QHBoxLayout(this); - hbox->setMargin(0); + hbox->setContentsMargins(0, 0, 0, 0); hbox->setSpacing(0); imageButton = new QPushButton(this); @@ -47,11 +47,11 @@ ToasterDisable::ToasterDisable(QWidget *parent) setLayout(hbox); - bool isDisable = NotifyQt::isAllDisable(); + bool isDisable = RsGUIEventManager::isAllDisable(); imageButton->setChecked(isDisable); - connect(NotifyQt::getInstance(), SIGNAL(disableAllChanged(bool)), this, SLOT(disable(bool))); - connect(imageButton, SIGNAL(toggled(bool)), NotifyQt::getInstance(), SLOT(SetDisableAll(bool))); + connect(RsGUIEventManager::getInstance(), SIGNAL(disableAllChanged(bool)), this, SLOT(disable(bool))); + connect(imageButton, SIGNAL(toggled(bool)), RsGUIEventManager::getInstance(), SLOT(SetDisableAll(bool))); disable(isDisable); } diff --git a/retroshare-gui/src/gui/statusbar/dhtstatus.cpp b/retroshare-gui/src/gui/statusbar/dhtstatus.cpp index 9d998137f..40790e4d6 100644 --- a/retroshare-gui/src/gui/statusbar/dhtstatus.cpp +++ b/retroshare-gui/src/gui/statusbar/dhtstatus.cpp @@ -37,7 +37,7 @@ DHTStatus::DHTStatus(QWidget *parent) : QWidget(parent) { QHBoxLayout *hbox = new QHBoxLayout(); - hbox->setMargin(0); + hbox->setContentsMargins(0, 0, 0, 0); hbox->setSpacing(6); statusDHT = new QLabel("" + tr("DHT") + ":", this ); diff --git a/retroshare-gui/src/gui/statusbar/discstatus.cpp b/retroshare-gui/src/gui/statusbar/discstatus.cpp index 64ac7813e..7475bf3a7 100644 --- a/retroshare-gui/src/gui/statusbar/discstatus.cpp +++ b/retroshare-gui/src/gui/statusbar/discstatus.cpp @@ -33,7 +33,7 @@ DiscStatus::DiscStatus(QWidget *parent) hide (); // show only, when pending operations are available QHBoxLayout *hbox = new QHBoxLayout(this); - hbox->setMargin(0); + hbox->setContentsMargins(0, 0, 0, 0); hbox->setSpacing(6); QLabel *iconLabel = new QLabel(this); diff --git a/retroshare-gui/src/gui/statusbar/hashingstatus.cpp b/retroshare-gui/src/gui/statusbar/hashingstatus.cpp index fc57bb286..fdbb5c4fa 100644 --- a/retroshare-gui/src/gui/statusbar/hashingstatus.cpp +++ b/retroshare-gui/src/gui/statusbar/hashingstatus.cpp @@ -27,14 +27,16 @@ #include "hashingstatus.h" #include "gui/common/ElidedLabel.h" #include "util/qtthreadsutils.h" -#include "gui/notifyqt.h" +#include "util/misc.h" #include "gui/common/FilesDefs.h" +//#define DEBUG_HASHING_STATUS 1 + HashingStatus::HashingStatus(QWidget *parent) : QWidget(parent) { QHBoxLayout *hbox = new QHBoxLayout(this); - hbox->setMargin(0); + hbox->setContentsMargins(0, 0, 0, 0); hbox->setSpacing(6); movie = new QMovie(":/images/loader/indicator-16.gif"); @@ -60,36 +62,98 @@ HashingStatus::HashingStatus(QWidget *parent) void HashingStatus::handleEvent_main_thread(std::shared_ptr event) { - // Warning: no GUI calls should happen here! - if(event->mType != RsEventType::SHARED_DIRECTORIES) return; - const RsSharedDirectoriesEvent *fe = dynamic_cast(event.get()); + const RsSharedDirectoriesEvent *fe = dynamic_cast(event.get()); + if(!fe) return; - QString info; - switch (fe->mEventCode) { default: - case RsSharedDirectoriesEventCode::STARTING_DIRECTORY_SWEEP: - info = tr("Examining shared files..."); - break; - case RsSharedDirectoriesEventCode::DIRECTORY_SWEEP_ENDED: - break; - case RsSharedDirectoriesEventCode::HASHING_FILE: - info = tr("Hashing file") + " " + QString::fromUtf8(fe->mMessage.c_str()); - break; + break; + + case RsSharedDirectoriesEventCode::HASHING_PROCESS_RESUMED: + statusHashing->setText(mLastText); // fallthrough +#ifdef DEBUG_HASHING_STATUS + std::cerr << "HashStatusEventHandler: received event " << (void*)fe->mEventCode << ": " ; + std::cerr << "HASHING RESUMED" << std::endl; +#endif + + case RsSharedDirectoriesEventCode::HASHING_PROCESS_STARTED: + { +#ifdef DEBUG_HASHING_STATUS + std::cerr << "HashStatusEventHandler: received event " << (void*)fe->mEventCode << ": " ; + std::cerr << "HASHING STARTED" << std::endl; +#endif + hashloader->show() ; + hashloader->setMovie(movie) ; + movie->start() ; + + statusHashing->setVisible(!_compactMode) ; + } + break; + + case RsSharedDirectoriesEventCode::HASHING_PROCESS_PAUSED: + { +#ifdef DEBUG_HASHING_STATUS + std::cerr << "HashStatusEventHandler: received event " << (void*)fe->mEventCode << ": " ; + std::cerr << "HASHING PAUSED" << std::endl; +#endif + movie->stop() ; + hashloader->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/resume.png")) ; + + mLastText = statusHashing->text(); + statusHashing->setText(QObject::tr("[Hashing is paused]")); + setToolTip(QObject::tr("Click to resume the hashing process")); + } + break; + + case RsSharedDirectoriesEventCode::HASHING_PROCESS_FINISHED: + { +#ifdef DEBUG_HASHING_STATUS + std::cerr << "HashStatusEventHandler: received event " << (void*)fe->mEventCode << ": " ; + std::cerr << "HASHING FINISHED" << std::endl; +#endif + movie->stop() ; + statusHashing->setText(QString()); + statusHashing->hide() ; + setToolTip(QString()); + hashloader->hide() ; + } + break; + + case RsSharedDirectoriesEventCode::HASHING_FILE: + { + QString msg = QString::number((unsigned long int)fe->mHashCounter+1) + "/" + QString::number((unsigned long int)fe->mTotalFilesToHash); + + msg += " (" + misc::friendlyUnit(fe->mTotalHashedSize) + " - " + + QString::number(int(fe->mTotalHashedSize/double(fe->mTotalSizeToHash)*100.0)) + "%" + + ((fe->mHashingSpeed>0)?("," + QString::number((double)fe->mHashingSpeed,'f',2) + " MB/s)"):(QString())) + + " : " + QString::fromUtf8(fe->mFilePath.c_str()) ; + + statusHashing->setText(tr("Hashing file") + " " + msg); + setToolTip(msg + "\n"+QObject::tr("Click to pause the hashing process")); +#ifdef DEBUG_HASHING_STATUS + std::cerr << "HashStatusEventHandler: received event " << (void*)fe->mEventCode << ": " ; + std::cerr << "HASHING FILE " << msg.toStdString() << std::endl; +#endif + } + break; + case RsSharedDirectoriesEventCode::SAVING_FILE_INDEX: - info = tr("Saving file index..."); - break; - } + { +#ifdef DEBUG_HASHING_STATUS + std::cerr << "HashStatusEventHandler: received event " << (void*)fe->mEventCode << ": " ; + std::cerr << "SAVING FILE INDEX" << std::endl; +#endif + statusHashing->setText(tr("Saving file index...")); + } + break; - // GUI calls should only happen in the GUI thread, which is achieved by postToObject(). - - updateHashingInfo(info); + }; } HashingStatus::~HashingStatus() @@ -98,47 +162,8 @@ HashingStatus::~HashingStatus() delete(movie); } -void HashingStatus::updateHashingInfo(const QString& s) -{ - if (s.isEmpty()) - { - statusHashing->hide() ; - hashloader->hide() ; - setToolTip(QString()); - - movie->stop() ; - } else { - setToolTip(s + "\n"+QObject::tr("Click to pause the hashing process")); - - if (_compactMode) { - statusHashing->hide() ; - } else { - statusHashing->setText(s) ; - statusHashing->show() ; - } - hashloader->show() ; - - movie->start() ; - } -} - void HashingStatus::mousePressEvent(QMouseEvent *) { rsFiles->togglePauseHashingProcess() ; - - if(rsFiles->hashingProcessPaused()) - { - movie->stop() ; - hashloader->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/resume.png")) ; - - mLastText = statusHashing->text(); - statusHashing->setText(QObject::tr("[Hashing is paused]")); - setToolTip(QObject::tr("Click to resume the hashing process")); - } - else - { - hashloader->setMovie(movie) ; - statusHashing->setText(mLastText); - movie->start() ; - } } + diff --git a/retroshare-gui/src/gui/statusbar/hashingstatus.h b/retroshare-gui/src/gui/statusbar/hashingstatus.h index 8f09120a1..180206088 100644 --- a/retroshare-gui/src/gui/statusbar/hashingstatus.h +++ b/retroshare-gui/src/gui/statusbar/hashingstatus.h @@ -39,7 +39,6 @@ public: void mousePressEvent(QMouseEvent *); private: - void updateHashingInfo(const QString& s); void handleEvent_main_thread(std::shared_ptr event); ElidedLabel *statusHashing; diff --git a/retroshare-gui/src/gui/statusbar/natstatus.cpp b/retroshare-gui/src/gui/statusbar/natstatus.cpp index 15e2a7067..28ae53c35 100644 --- a/retroshare-gui/src/gui/statusbar/natstatus.cpp +++ b/retroshare-gui/src/gui/statusbar/natstatus.cpp @@ -31,7 +31,7 @@ NATStatus::NATStatus(QWidget *parent) : QWidget(parent) { QHBoxLayout *hbox = new QHBoxLayout(this); - hbox->setMargin(0); + hbox->setContentsMargins(0, 0, 0, 0); hbox->setSpacing(6); statusNAT = new QLabel( tr("NAT:"), this ); diff --git a/retroshare-gui/src/gui/statusbar/peerstatus.cpp b/retroshare-gui/src/gui/statusbar/peerstatus.cpp index 4f1c9811f..5cfce309f 100644 --- a/retroshare-gui/src/gui/statusbar/peerstatus.cpp +++ b/retroshare-gui/src/gui/statusbar/peerstatus.cpp @@ -28,7 +28,7 @@ PeerStatus::PeerStatus(QWidget *parent) : QWidget(parent) { QHBoxLayout *hbox = new QHBoxLayout(this); - hbox->setMargin(0); + hbox->setContentsMargins(0, 0, 0, 0); hbox->setSpacing(6); diff --git a/retroshare-gui/src/gui/statusbar/ratesstatus.cpp b/retroshare-gui/src/gui/statusbar/ratesstatus.cpp index 8e4f606f7..b953020fa 100644 --- a/retroshare-gui/src/gui/statusbar/ratesstatus.cpp +++ b/retroshare-gui/src/gui/statusbar/ratesstatus.cpp @@ -32,7 +32,7 @@ RatesStatus::RatesStatus(QWidget *parent) : QWidget(parent) { QHBoxLayout *hbox = new QHBoxLayout(this); - hbox->setMargin(0); + hbox->setContentsMargins(0, 0, 0, 0); hbox->setSpacing(6); iconLabel = new QLabel( this ); diff --git a/retroshare-gui/src/gui/statusbar/torstatus.cpp b/retroshare-gui/src/gui/statusbar/torstatus.cpp index d43de1df3..12bcddf54 100644 --- a/retroshare-gui/src/gui/statusbar/torstatus.cpp +++ b/retroshare-gui/src/gui/statusbar/torstatus.cpp @@ -40,7 +40,7 @@ TorStatus::TorStatus(QWidget *parent) : QWidget(parent) { QHBoxLayout *hbox = new QHBoxLayout(); - hbox->setMargin(0); + hbox->setContentsMargins(0, 0, 0, 0); hbox->setSpacing(6); statusTor = new QLabel("" + tr("Tor") + ":", this ); diff --git a/retroshare-gui/src/gui/toaster/DownloadToaster.cpp b/retroshare-gui/src/gui/toaster/DownloadToaster.cpp index 2818ba265..41b77c842 100644 --- a/retroshare-gui/src/gui/toaster/DownloadToaster.cpp +++ b/retroshare-gui/src/gui/toaster/DownloadToaster.cpp @@ -28,7 +28,7 @@ #include -DownloadToaster::DownloadToaster(const RsFileHash &hash, const QString &name) : QWidget(NULL) +DownloadToaster::DownloadToaster(const RsFileHash &hash) : QWidget(NULL) { ui.setupUi(this); @@ -38,8 +38,11 @@ DownloadToaster::DownloadToaster(const RsFileHash &hash, const QString &name) : connect(ui.closeButton, SIGNAL(clicked()), this, SLOT(hide())); connect(ui.toasterButton, SIGNAL(clicked()), this, SLOT(play())); + FileInfo info; + rsFiles->FileDetails(hash, RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_DOWNLOAD, info ) ; + /* set informations */ - ui.textLabel->setText(name); + ui.textLabel->setText(QString::fromStdString(info.fname)); } void DownloadToaster::play() diff --git a/retroshare-gui/src/gui/toaster/DownloadToaster.h b/retroshare-gui/src/gui/toaster/DownloadToaster.h index 3d67e1af1..f63a6aadc 100644 --- a/retroshare-gui/src/gui/toaster/DownloadToaster.h +++ b/retroshare-gui/src/gui/toaster/DownloadToaster.h @@ -30,7 +30,7 @@ class DownloadToaster : public QWidget Q_OBJECT public: - DownloadToaster(const RsFileHash &hash, const QString &name); + DownloadToaster(const RsFileHash &hash); private slots: void play(); diff --git a/retroshare-gui/src/gui/toaster/FriendRequestToaster.cpp b/retroshare-gui/src/gui/toaster/FriendRequestToaster.cpp index 90bde9d10..f4968d55f 100644 --- a/retroshare-gui/src/gui/toaster/FriendRequestToaster.cpp +++ b/retroshare-gui/src/gui/toaster/FriendRequestToaster.cpp @@ -24,8 +24,8 @@ #include -FriendRequestToaster::FriendRequestToaster(const RsPgpId &gpgId, const QString &sslName, const RsPeerId &peerId) - : QWidget(NULL), mGpgId(gpgId), mSslId(peerId), mSslName(sslName) +FriendRequestToaster::FriendRequestToaster(const RsPgpId &gpgId, const RsPeerId &peerId) + : QWidget(NULL), mGpgId(gpgId), mSslId(peerId) { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); @@ -33,7 +33,8 @@ FriendRequestToaster::FriendRequestToaster(const RsPgpId &gpgId, const QString & bool knownPeer = false; RsPeerDetails details; if (rsPeers->getGPGDetails(mGpgId, details)) { - knownPeer = true; + knownPeer = true; + mSslName = QString::fromUtf8(details.name.c_str()); } if (knownPeer) { @@ -51,7 +52,7 @@ FriendRequestToaster::FriendRequestToaster(const RsPgpId &gpgId, const QString & ui.textLabel->setText( peerName + " " + tr("wants to be friend with you on RetroShare")); ui.avatarWidget->setDefaultAvatar(":/images/avatar_request.png"); } else { - ui.textLabel->setText( sslName + " " + tr("Unknown (Incoming) Connect Attempt")); + ui.textLabel->setText( mSslName + " " + tr("Unknown (Incoming) Connect Attempt")); ui.avatarWidget->setDefaultAvatar(":/images/avatar_request_unknown.png"); } } diff --git a/retroshare-gui/src/gui/toaster/FriendRequestToaster.h b/retroshare-gui/src/gui/toaster/FriendRequestToaster.h index 07e7c11f8..eebc85301 100644 --- a/retroshare-gui/src/gui/toaster/FriendRequestToaster.h +++ b/retroshare-gui/src/gui/toaster/FriendRequestToaster.h @@ -33,7 +33,7 @@ class FriendRequestToaster : public QWidget Q_OBJECT public: - FriendRequestToaster(const RsPgpId &gpgId, const QString &sslName, const RsPeerId &peerId); + FriendRequestToaster(const RsPgpId &gpgId, const RsPeerId &peerId); private slots: void friendrequestButtonSlot(); diff --git a/retroshare-gui/src/gui/unfinished/ApplicationWindow.h b/retroshare-gui/src/gui/unfinished/ApplicationWindow.h index 89631f1b3..58f03907b 100644 --- a/retroshare-gui/src/gui/unfinished/ApplicationWindow.h +++ b/retroshare-gui/src/gui/unfinished/ApplicationWindow.h @@ -32,7 +32,7 @@ class ApplicationWindow : public QMainWindow public: /** Default Constructor */ - ApplicationWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0); + ApplicationWindow(QWidget *parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); /** Destructor. */ ~ApplicationWindow(); diff --git a/retroshare-gui/src/gui/unfinished/ExampleDialog.cpp b/retroshare-gui/src/gui/unfinished/ExampleDialog.cpp index e263f75e9..e1d5c7809 100644 --- a/retroshare-gui/src/gui/unfinished/ExampleDialog.cpp +++ b/retroshare-gui/src/gui/unfinished/ExampleDialog.cpp @@ -37,7 +37,7 @@ #include #include -#include "util/QtVersion.h" +#include "util/RsQtVersion.h" /* Images for context menu icons */ #define IMAGE_REMOVEFRIEND ":/images/removefriend16.png" diff --git a/retroshare-gui/src/idle/idle_platform.cpp b/retroshare-gui/src/idle/idle_platform.cpp index ddae72f17..c3d582acc 100644 --- a/retroshare-gui/src/idle/idle_platform.cpp +++ b/retroshare-gui/src/idle/idle_platform.cpp @@ -24,8 +24,15 @@ #ifdef HAVE_XSS #include -#include +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) +#include +#else #include +#endif + +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) +#include +#endif #include #include @@ -73,7 +80,10 @@ bool IdlePlatform::init() old_handler = XSetErrorHandler(xerrhandler); int event_base, error_base; -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) + QNativeInterface::QX11Application *nativeInterface = qGuiApp->nativeInterface(); + if (nativeInterface && XScreenSaverQueryExtension(nativeInterface->display(), &event_base, &error_base)) { +#elif QT_VERSION >= QT_VERSION_CHECK(5,0,0) if(QX11Info::isPlatformX11() && XScreenSaverQueryExtension(QX11Info::display(), &event_base, &error_base)) { #else if(XScreenSaverQueryExtension(QApplication::desktop()->screen()->x11Info().display(), &event_base, &error_base)) { @@ -88,7 +98,10 @@ int IdlePlatform::secondsIdle() { if(!d->ss_info) return 0; -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) + QNativeInterface::QX11Application *nativeInterface = qGuiApp->nativeInterface(); + if(!nativeInterface || !XScreenSaverQueryInfo(nativeInterface->display(), DefaultRootWindow(nativeInterface->display()), d->ss_info)) +#elif QT_VERSION >= QT_VERSION_CHECK(5,0,0) if(!QX11Info::isPlatformX11() || !XScreenSaverQueryInfo(QX11Info::display(), QX11Info::appRootWindow(), d->ss_info)) #else if(!XScreenSaverQueryInfo(QApplication::desktop()->screen()->x11Info().display(), QX11Info::appRootWindow(), d->ss_info)) diff --git a/retroshare-gui/src/lang/languagesupport.cpp b/retroshare-gui/src/lang/languagesupport.cpp index 46e749465..3be4a1ec2 100644 --- a/retroshare-gui/src/lang/languagesupport.cpp +++ b/retroshare-gui/src/lang/languagesupport.cpp @@ -261,6 +261,6 @@ bool LanguageSupport::localize(const QString &languageCode) { if (!isValidLanguageCode(languageCode)) return false; - QLocale::setDefault(locales().key(languageCode)); + QLocale::setDefault(locales()[languageCode]); return true; } diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index 228f24067..dd343bf03 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -59,6 +59,7 @@ CrashStackTrace gCrashStackTrace; #include "util/rsdir.h" #include "util/rstime.h" #include "retroshare/rsinit.h" +#include "util/RsQtVersion.h" #ifdef MESSENGER_WINDOW #include "gui/MessengerWindow.h" @@ -107,7 +108,7 @@ __declspec(dllexport) __cdecl BOOL _OPENSSL_isservice(void) #include #include #include -#include "gui/notifyqt.h" +#include "gui/RsGUIEventManager.h" #include static void showHelp(const argstream& as) @@ -136,7 +137,7 @@ static void showHelp(const argstream& as) box.setWindowTitle(QObject::tr("Retroshare commandline arguments")); // now compute the size of text and set the size of the box. For the record, this doesn't work... - box.setBaseSize( QSize(QFontMetricsF(font).width(text),QFontMetricsF(font).height()*text.count('\n')) ); + box.setBaseSize( QSize(QFontMetrics_horizontalAdvance(QFontMetricsF(font), text),QFontMetricsF(font).height()*text.count('\n')) ); box.exec(); } @@ -345,8 +346,8 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); // RsControl::earlyInitNotificationSystem() ; - NotifyQt *notify = NotifyQt::Create(); - rsNotify->registerNotifyClient(notify); + RsGUIEventManager::Create(); + //rsNotify->registerNotifyClient(notify); /* RetroShare Core Objects */ RsInit::InitRsConfig(); @@ -725,20 +726,20 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); #ifdef DEBUG std::cerr << "connecting signals and slots" << std::endl ; #endif - QObject::connect(notify,SIGNAL(deferredSignatureHandlingRequested()),notify,SLOT(handleSignatureEvent()),Qt::QueuedConnection) ; - QObject::connect(notify,SIGNAL(chatLobbyTimeShift(int)),notify,SLOT(handleChatLobbyTimeShift(int)),Qt::QueuedConnection) ; - QObject::connect(notify,SIGNAL(diskFull(int,int)) ,w ,SLOT(displayDiskSpaceWarning(int,int))) ; - QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w ,SLOT(postModDirectories(bool)) ,Qt::QueuedConnection ) ; - QObject::connect(notify,SIGNAL(transfersChanged()) ,w->transfersDialog ,SLOT(insertTransfers() )) ; - QObject::connect(notify,SIGNAL(publicChatChanged(int)) ,w->friendsDialog ,SLOT(publicChatChanged(int) )); - QObject::connect(notify,SIGNAL(neighboursChanged()) ,w->friendsDialog->networkDialog ,SLOT(securedUpdateDisplay())) ; +// QObject::connect(notify,SIGNAL(deferredSignatureHandlingRequested()),notify,SLOT(handleSignatureEvent()),Qt::QueuedConnection) ; +// QObject::connect(notify,SIGNAL(chatLobbyTimeShift(int)),notify,SLOT(handleChatLobbyTimeShift(int)),Qt::QueuedConnection) ; +// QObject::connect(notify,SIGNAL(diskFull(int,int)) ,w ,SLOT(displayDiskSpaceWarning(int,int))) ; +// QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w ,SLOT(postModDirectories(bool)) ,Qt::QueuedConnection ) ; +// QObject::connect(notify,SIGNAL(transfersChanged()) ,w->transfersDialog ,SLOT(insertTransfers() )) ; +// QObject::connect(notify,SIGNAL(publicChatChanged(int)) ,w->friendsDialog ,SLOT(publicChatChanged(int) )); +// QObject::connect(notify,SIGNAL(neighboursChanged()) ,w->friendsDialog->networkDialog ,SLOT(securedUpdateDisplay())) ; - QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&,bool)),w->friendsDialog,SLOT(updatePeerStatusString(const QString&,const QString&,bool))); - QObject::connect(notify,SIGNAL(ownStatusMessageChanged()),w->friendsDialog,SLOT(loadmypersonalstatus())); +// QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&,bool)),w->friendsDialog,SLOT(updatePeerStatusString(const QString&,const QString&,bool))); +// QObject::connect(notify,SIGNAL(ownStatusMessageChanged()),w->friendsDialog,SLOT(loadmypersonalstatus())); // QObject::connect(notify,SIGNAL(logInfoChanged(const QString&)) ,w->friendsDialog->networkDialog,SLOT(setLogInfo(QString))) ; - QObject::connect(notify,SIGNAL(discInfoChanged()) ,w->friendsDialog->networkView,SLOT(update()),Qt::QueuedConnection) ; - QObject::connect(notify,SIGNAL(errorOccurred(int,int,const QString&)),w,SLOT(displayErrorMessage(int,int,const QString&))) ; +// QObject::connect(notify,SIGNAL(discInfoChanged()) ,w->friendsDialog->networkView,SLOT(update()),Qt::QueuedConnection) ; +// QObject::connect(notify,SIGNAL(errorOccurred(int,int,const QString&)),w,SLOT(displayErrorMessage(int,int,const QString&))) ; w->installGroupChatNotifier(); @@ -751,11 +752,10 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); } /* Startup a Timer to keep the gui's updated */ - QTimer *timer = new QTimer(w); - timer -> connect(timer, SIGNAL(timeout()), notify, SLOT(UpdateGUI())); - timer->start(1000); - - notify->enable() ; // enable notification system after GUI creation, to avoid data races in Qt. + //QTimer *timer = new QTimer(w); + //timer -> connect(timer, SIGNAL(timeout()), notify, SLOT(UpdateGUI())); + //timer->start(1000); + //notify->enable() ; // enable notification system after GUI creation, to avoid data races in Qt. // Read webui params in settings. We cannot save them to some webui.cfg because cfg needs the node id and // jsonapi is started before node ID selection in retroshare-service. diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index 6f217db9c..e8362a885 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -25,6 +25,8 @@ CONFIG += console TARGET = retroshare DEFINES += TARGET=\\\"$${TARGET}\\\" +greaterThan(QT_MAJOR_VERSION,5): QT += core5compat + DEPENDPATH *= $${PWD} $${RS_INCLUDE_DIR} INCLUDEPATH *= $${PWD} @@ -96,12 +98,11 @@ HEADERS += TorControl/TorControlWindow.h greaterThan(QT_MAJOR_VERSION, 4) { # Qt 5 QT += widgets multimedia printsupport - linux-* { - QT += x11extras - } -} else { - # Qt 4 - CONFIG += uitools + lessThan(QT_MAJOR_VERSION, 6) { + linux-*{ + QT += x11extras + } + } } CONFIG += identities @@ -357,7 +358,10 @@ openbsd-* { wikipoos { PRE_TARGETDEPS *= $$OUT_PWD/../../supportlibs/pegmarkdown/lib/libpegmarkdown.a LIBS *= $$OUT_PWD/../../supportlibs/pegmarkdown/lib/libpegmarkdown.a - LIBS *= -lglib-2.0 + + !win32 { + LIBS *= -lglib-2.0 + } } ################################### HEADERS & SOURCES ############################# @@ -367,7 +371,7 @@ HEADERS += rshare.h \ retroshare-gui/configpage.h \ retroshare-gui/RsAutoUpdatePage.h \ retroshare-gui/mainpage.h \ - gui/notifyqt.h \ + gui/RsGUIEventManager.h \ control/bandwidthevent.h \ control/eventtype.h \ gui/QuickStartWizard.h \ @@ -446,7 +450,7 @@ HEADERS += rshare.h \ util/misc.h \ util/HandleRichText.h \ util/ObjectPainter.h \ - util/QtVersion.h \ + util/RsQtVersion.h \ util/RsFile.h \ util/qtthreadsutils.h \ util/ClickableLabel.h \ @@ -592,10 +596,13 @@ HEADERS += rshare.h \ gui/elastic/elnode.h \ gui/NewsFeed.h \ gui/feeds/BoardsCommentsItem.h \ + gui/feeds/BoardsPostItem.h \ gui/feeds/FeedItem.h \ gui/feeds/FeedHolder.h \ + gui/feeds/GxsGroupFeedItem.h \ gui/feeds/GxsCircleItem.h \ gui/feeds/ChannelsCommentsItem.h \ + gui/feeds/GxsFeedItem.h \ gui/feeds/PeerItem.h \ gui/feeds/MsgItem.h \ gui/feeds/ChatMsgItem.h \ @@ -616,22 +623,6 @@ HEADERS += rshare.h \ gui/NetworkDialog/pgpid_item_proxy.h \ gui/common/RsCollection.h \ util/retroshareWin32.h -# gui/ForumsDialog.h \ -# gui/forums/ForumDetails.h \ -# gui/forums/EditForumDetails.h \ -# gui/forums/CreateForum.h \ -# gui/forums/CreateForumMsg.h \ -# gui/forums/ForumUserNotify.h \ -# gui/feeds/ForumNewItem.h \ -# gui/feeds/ForumMsgItem.h \ -# gui/ChannelFeed.h \ -# gui/feeds/ChanNewItem.h \ -# gui/feeds/ChanMsgItem.h \ -# gui/channels/CreateChannel.h \ -# gui/channels/ChannelDetails.h \ -# gui/channels/CreateChannelMsg.h \ -# gui/channels/EditChanDetails.h \ -# gui/channels/ChannelUserNotify.h \ FORMS += gui/StartDialog.ui \ gui/HomePage.ui\ @@ -650,7 +641,6 @@ FORMS += gui/StartDialog.ui \ gui/NetworkView.ui \ gui/FriendsDialog.ui \ gui/ShareManager.ui \ -# gui/ShareDialog.ui \ gui/help/browser/helpbrowser.ui \ gui/HelpDialog.ui \ gui/ServicePermissionDialog.ui \ @@ -704,6 +694,7 @@ FORMS += gui/StartDialog.ui \ gui/advsearch/expressionwidget.ui \ gui/NewsFeed.ui \ gui/feeds/BoardsCommentsItem.ui \ + gui/feeds/BoardsPostItem.ui \ gui/feeds/GxsCircleItem.ui \ gui/feeds/ChannelsCommentsItem.ui \ gui/feeds/PeerItem.ui \ @@ -757,7 +748,7 @@ FORMS += gui/StartDialog.ui \ SOURCES += main.cpp \ rshare.cpp \ - gui/notifyqt.cpp \ + gui/RsGUIEventManager.cpp \ gui/AboutDialog.cpp \ gui/AboutWidget.cpp \ gui/QuickStartWizard.cpp \ @@ -814,6 +805,7 @@ SOURCES += main.cpp \ util/misc.cpp \ util/HandleRichText.cpp \ util/ObjectPainter.cpp \ + util/RsQtVersion.cpp \ util/RsFile.cpp \ util/RichTextEdit.cpp \ util/ClickableLabel.cpp \ @@ -954,10 +946,13 @@ SOURCES += main.cpp \ gui/elastic/elnode.cpp \ gui/NewsFeed.cpp \ gui/feeds/BoardsCommentsItem.cpp \ + gui/feeds/BoardsPostItem.cpp \ gui/feeds/FeedItem.cpp \ + gui/feeds/GxsGroupFeedItem.cpp \ gui/feeds/FeedHolder.cpp \ gui/feeds/GxsCircleItem.cpp \ gui/feeds/ChannelsCommentsItem.cpp \ + gui/feeds/GxsFeedItem.cpp \ gui/feeds/PeerItem.cpp \ gui/feeds/MsgItem.cpp \ gui/feeds/ChatMsgItem.cpp \ @@ -1045,12 +1040,9 @@ unfinishedtranslations { } messenger { - SOURCES += gui/MessengerWindow.cpp \ - gui/common/FriendList.cpp - HEADERS += gui/MessengerWindow.h \ - gui/common/FriendList.h - FORMS += gui/MessengerWindow.ui \ - gui/common/FriendList.ui + SOURCES += gui/MessengerWindow.cpp + HEADERS += gui/MessengerWindow.h + FORMS += gui/MessengerWindow.ui DEFiNES += MESSENGER_WINDOW } @@ -1439,11 +1431,9 @@ gxsgui { gui/gxs/GxsGroupFrameDialog.h \ gui/gxs/GxsMessageFrameWidget.h \ gui/gxs/GxsMessageFramePostWidget.h \ - gui/gxs/GxsGroupFeedItem.h \ - gui/gxs/GxsFeedItem.h \ gui/gxs/GxsGroupShareKey.h \ gui/gxs/GxsUserNotify.h \ - gui/gxs/GxsFeedWidget.h \ +# gui/gxs/GxsFeedWidget.h \ util/TokenQueue.h \ util/RsGxsUpdateBroadcast.h \ @@ -1473,10 +1463,8 @@ gxsgui { gui/gxs/GxsGroupFrameDialog.cpp \ gui/gxs/GxsMessageFrameWidget.cpp \ gui/gxs/GxsMessageFramePostWidget.cpp \ - gui/gxs/GxsGroupFeedItem.cpp \ - gui/gxs/GxsFeedItem.cpp \ gui/gxs/GxsUserNotify.cpp \ - gui/gxs/GxsFeedWidget.cpp \ +# gui/gxs/GxsFeedWidget.cpp \ util/TokenQueue.cpp \ util/RsGxsUpdateBroadcast.cpp \ diff --git a/retroshare-gui/src/retroshare-gui/RsAutoUpdatePage.h b/retroshare-gui/src/retroshare-gui/RsAutoUpdatePage.h index a21e6c595..31e975696 100644 --- a/retroshare-gui/src/retroshare-gui/RsAutoUpdatePage.h +++ b/retroshare-gui/src/retroshare-gui/RsAutoUpdatePage.h @@ -37,7 +37,7 @@ class RsAutoUpdatePage: public MainPage Q_OBJECT public: - RsAutoUpdatePage(int ms_update_period = 1000, QWidget *parent = NULL, Qt::WindowFlags flags = 0) ; + RsAutoUpdatePage(int ms_update_period = 1000, QWidget *parent = NULL, Qt::WindowFlags flags = Qt::WindowFlags()) ; virtual ~RsAutoUpdatePage() ; static void lockAllEvents() ; diff --git a/retroshare-gui/src/retroshare-gui/configpage.h b/retroshare-gui/src/retroshare-gui/configpage.h index 6aa081055..d0d0625dc 100644 --- a/retroshare-gui/src/retroshare-gui/configpage.h +++ b/retroshare-gui/src/retroshare-gui/configpage.h @@ -29,7 +29,7 @@ class ConfigPage : public QWidget { public: /** Default Constructor */ - ConfigPage(QWidget *parent = 0, Qt::WindowFlags flags = 0) : QWidget(parent, flags), loaded(false) {} + ConfigPage(QWidget *parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()) : QWidget(parent, flags), loaded(false) {} /** Pure virtual method. Subclassed pages load their config settings here. */ virtual void load() = 0; diff --git a/retroshare-gui/src/rshare.cpp b/retroshare-gui/src/rshare.cpp index d867f1545..5dc08cc2e 100644 --- a/retroshare-gui/src/rshare.cpp +++ b/retroshare-gui/src/rshare.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include @@ -35,6 +35,7 @@ #include #include #include +#include #ifdef __APPLE__ #include #endif @@ -310,8 +311,8 @@ void RsApplication::customizeDateFormat() QLocale locale = QLocale(); // set to default locale /* get long date format without weekday */ options.dateformat = locale.dateFormat(QLocale::LongFormat); - options.dateformat.replace(QRegExp("^dddd,*[^ ]* *('[^']+' )*"), ""); - options.dateformat.replace(QRegExp(",* *dddd"), ""); + options.dateformat.replace(QRegularExpression("^dddd,*[^ ]* *('[^']+' )*"), ""); + options.dateformat.replace(QRegularExpression(",* *dddd"), ""); options.dateformat = options.dateformat.trimmed(); } @@ -676,3 +677,25 @@ bool RsApplication::updateLocalServer() } return false; } + +/** Get available geometry of primary screen */ +QRect RsApplication::availablePrimaryScreenGeometry() +{ + QScreen *primaryScreen = QGuiApplication::primaryScreen(); + if (!primaryScreen) { + return QRect(0, 0, 0, 0); + } + + return primaryScreen->availableGeometry(); +} + +/** Get geometry of primary screen */ +QRect RsApplication::primaryScreenGeometry() +{ + QScreen *primaryScreen = QGuiApplication::primaryScreen(); + if (!primaryScreen) { + return QRect(0, 0, 0, 0); + } + + return primaryScreen->geometry(); +} diff --git a/retroshare-gui/src/rshare.h b/retroshare-gui/src/rshare.h index be6af336c..ff079b1e8 100644 --- a/retroshare-gui/src/rshare.h +++ b/retroshare-gui/src/rshare.h @@ -154,6 +154,11 @@ public: static void createShortcut(const QKeySequence &key, QWidget *sender, QWidget *receiver, const char *slot); + /** Get available geometry of primary screen */ + static QRect availablePrimaryScreenGeometry(); + /** Get geometry of primary screen */ + static QRect primaryScreenGeometry(); + #ifdef __APPLE__ /**To process event from Mac system */ bool event(QEvent *); diff --git a/retroshare-gui/src/util/ClickableLabel.cpp b/retroshare-gui/src/util/ClickableLabel.cpp index 6bbd5ca4a..ee16abdc8 100644 --- a/retroshare-gui/src/util/ClickableLabel.cpp +++ b/retroshare-gui/src/util/ClickableLabel.cpp @@ -33,3 +33,21 @@ ClickableLabel::~ClickableLabel() { void ClickableLabel::mousePressEvent(QMouseEvent* /*event*/) { emit clicked(); } + +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) +void ClickableLabel::enterEvent(QEnterEvent* /*event*/) +#else +void ClickableLabel::enterEvent(QEvent* /*event*/) +#endif +{ + if (mUseStyleSheet) { + setStyleSheet("QLabel { border: 2px solid #039bd5; }"); + } +} + +void ClickableLabel::leaveEvent(QEvent* /*event*/) +{ + if (mUseStyleSheet) { + setStyleSheet(""); + } +} diff --git a/retroshare-gui/src/util/ClickableLabel.h b/retroshare-gui/src/util/ClickableLabel.h index 54b3499d8..610a1eabd 100644 --- a/retroshare-gui/src/util/ClickableLabel.h +++ b/retroshare-gui/src/util/ClickableLabel.h @@ -39,8 +39,12 @@ signals: protected: void mousePressEvent(QMouseEvent* event) override; - void enterEvent(QEvent * /* ev */ ) override { if(mUseStyleSheet) setStyleSheet("QLabel { border: 2px solid #039bd5; }");} - void leaveEvent(QEvent * /* ev */ ) override { if(mUseStyleSheet) setStyleSheet("");} +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) + void enterEvent(QEnterEvent* event) override; +#else + void enterEvent(QEvent* event) override; +#endif + void leaveEvent(QEvent* event) override; bool mUseStyleSheet; }; diff --git a/retroshare-gui/src/util/DateTime.cpp b/retroshare-gui/src/util/DateTime.cpp index 658772c5a..ea81e69fd 100644 --- a/retroshare-gui/src/util/DateTime.cpp +++ b/retroshare-gui/src/util/DateTime.cpp @@ -19,13 +19,14 @@ *******************************************************************************/ #include +#include #include "DateTime.h" #include "rshare.h" QString DateTime::formatLongDate(time_t dateValue) { - return formatLongDate(QDateTime::fromTime_t(dateValue).date()); + return formatLongDate(DateTimeFromTime_t(dateValue).date()); } QString DateTime::formatLongDate(const QDate &dateValue) @@ -41,7 +42,7 @@ QString DateTime::formatLongDate(const QDate &dateValue) QString DateTime::formatLongDateTime(time_t datetimeValue) { - return formatLongDateTime(QDateTime::fromTime_t(datetimeValue)); + return formatLongDateTime(DateTimeFromTime_t(datetimeValue)); } QString DateTime::formatLongDateTime(const QDateTime &datetimeValue) @@ -51,7 +52,7 @@ QString DateTime::formatLongDateTime(const QDateTime &datetimeValue) QString DateTime::formatDateTime(time_t datetimeValue) { - return formatDateTime(QDateTime::fromTime_t(datetimeValue)); + return formatDateTime(DateTimeFromTime_t(datetimeValue)); } QString DateTime::formatDateTime(const QDateTime &datetimeValue) @@ -61,20 +62,38 @@ QString DateTime::formatDateTime(const QDateTime &datetimeValue) QString DateTime::formatDate(time_t dateValue) { - return formatDate(QDateTime::fromTime_t(dateValue).date()); + return formatDate(DateTimeFromTime_t(dateValue).date()); } QString DateTime::formatDate(const QDate &dateValue) { - return dateValue.toString(Qt::SystemLocaleShortDate); + return QLocale::system().toString(dateValue, QLocale::ShortFormat); } QString DateTime::formatTime(time_t timeValue) { - return formatTime(QDateTime::fromTime_t(timeValue).time()); + return formatTime(DateTimeFromTime_t(timeValue).time()); } QString DateTime::formatTime(const QTime &timeValue) { - return timeValue.toString(Qt::SystemLocaleShortDate); + return QLocale::system().toString(timeValue, QLocale::ShortFormat); +} + +QDateTime DateTime::DateTimeFromTime_t(time_t timeValue) +{ +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) + return QDateTime::fromSecsSinceEpoch(timeValue); +#else + return QDateTime::fromTime_t(timeValue); +#endif +} + +time_t DateTime::DateTimeToTime_t(const QDateTime& dateTime) +{ +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) + return dateTime.toSecsSinceEpoch(); +#else + return dateTime.toTime_t(); +#endif } diff --git a/retroshare-gui/src/util/DateTime.h b/retroshare-gui/src/util/DateTime.h index c614ab3bd..4d38c48c1 100644 --- a/retroshare-gui/src/util/DateTime.h +++ b/retroshare-gui/src/util/DateTime.h @@ -49,6 +49,12 @@ public: /* format date and time (see formatDate & formatTime) */ static QString formatDateTime(time_t datetimeValue); static QString formatDateTime(const QDateTime &datetimeValue); + + /* Convert time_t to QDateTime */ + static QDateTime DateTimeFromTime_t(time_t timeValue); + + /* Convert QDateTime to time_t */ + static time_t DateTimeToTime_t(const QDateTime& dateTime); }; #endif diff --git a/retroshare-gui/src/util/FontSizeHandler.cpp b/retroshare-gui/src/util/FontSizeHandler.cpp index c184da0de..51da29032 100644 --- a/retroshare-gui/src/util/FontSizeHandler.cpp +++ b/retroshare-gui/src/util/FontSizeHandler.cpp @@ -25,7 +25,7 @@ #include "rshare.h" #include "FontSizeHandler.h" #include "gui/settings/rsharesettings.h" -#include "gui/notifyqt.h" +#include "gui/RsGUIEventManager.h" // Data for QAbstractItemView struct FontSizeHandlerWidgetData @@ -71,7 +71,7 @@ public: data.callback = callback; mWidget.insert(widget, data); - QObject::connect(NotifyQt::getInstance(), &NotifyQt::settingsChanged, widget, [this, widget, callback]() { + QObject::connect(RsGUIEventManager::getInstance(), &RsGUIEventManager::settingsChanged, widget, [this, widget, callback]() { mFontSizeHandlerBase->updateFontSize(widget, callback); }); @@ -93,7 +93,7 @@ public: data.callback = callback; mView.insert(view, data); - QObject::connect(NotifyQt::getInstance(), &NotifyQt::settingsChanged, view, [this, view, iconHeightFactor, callback]() { + QObject::connect(RsGUIEventManager::getInstance(), &RsGUIEventManager::settingsChanged, view, [this, view, iconHeightFactor, callback]() { mFontSizeHandlerBase->updateFontSize(view, iconHeightFactor, callback); }); diff --git a/retroshare-gui/src/util/HandleRichText.cpp b/retroshare-gui/src/util/HandleRichText.cpp index 6f6eec750..5a4a166a4 100644 --- a/retroshare-gui/src/util/HandleRichText.cpp +++ b/retroshare-gui/src/util/HandleRichText.cpp @@ -26,11 +26,14 @@ #include #include #include +#include +#include #include "HandleRichText.h" #include "gui/RetroShareLink.h" #include "util/ObjectPainter.h" #include "util/imageutil.h" +#include "util/RsQtVersion.h" #include "util/rsdebug.h" #include "util/rstime.h" @@ -357,7 +360,7 @@ void RsHtml::filterEmbeddedImages(QDomDocument &doc, QDomElement ¤tElement } } -int RsHtml::indexInWithValidation(QRegExp &rx, const QString &text, EmbedInHtml &embedInfos, int pos) +int RsHtml::indexInWithValidation(const QRegExp &rx, const QString &text, EmbedInHtml &embedInfos, int pos) { int index = rx.indexIn(text, pos); if(index == -1 || embedInfos.myType != Img) return index; @@ -1170,7 +1173,7 @@ void RsHtml::optimizeHtml(QString &text, unsigned int flag /*= 0*/ { // remove doctype - text.remove(QRegExp("]*>")); + text.remove(QRegularExpression("]*>")); //remove all prepend char that make doc.setContent() fail text.remove(0,text.indexOf("<")); // Save Space and Tab because doc loose it. @@ -1252,7 +1255,7 @@ QString RsHtml::makeQuotedText(RSTextBrowser *browser) { text = browser->toPlainText(); } - QStringList sl = text.split(QRegExp("[\r\n]"),QString::SkipEmptyParts); + QStringList sl = text.split(QRegularExpression("[\r\n]"),QtSkipEmptyParts); text = sl.join("\n> "); text.replace("\n> >","\n>>"); // Don't add space for already quotted lines. text.replace(QChar(-4)," ");//Char used when image on text. diff --git a/retroshare-gui/src/util/HandleRichText.h b/retroshare-gui/src/util/HandleRichText.h index 3e98ea21c..cefb40c70 100644 --- a/retroshare-gui/src/util/HandleRichText.h +++ b/retroshare-gui/src/util/HandleRichText.h @@ -54,6 +54,7 @@ class QDomElement; class EmbedInHtml; class RetroShareLink; class QTextCursor; +class QRegExp; class RsHtml { @@ -89,7 +90,7 @@ protected: virtual void anchorStylesheetForImg(QDomDocument &doc, QDomElement &element, const RetroShareLink &link, QString &styleSheet); private: - int indexInWithValidation(QRegExp &rx, const QString &text, EmbedInHtml &embedInfos, int pos = 0); + int indexInWithValidation(const QRegExp &rx, const QString &text, EmbedInHtml &embedInfos, int pos = 0); }; #endif // HANDLE_RICH_TEXT_H_ diff --git a/retroshare-gui/src/util/RetroStyleLabel.cpp b/retroshare-gui/src/util/RetroStyleLabel.cpp index 293ae50c7..3023120ae 100644 --- a/retroshare-gui/src/util/RetroStyleLabel.cpp +++ b/retroshare-gui/src/util/RetroStyleLabel.cpp @@ -24,6 +24,8 @@ #include #include +#include "util/RsQtVersion.h" + RetroStyleLabel::RetroStyleLabel(QWidget * parent, Mode mode, Qt::AlignmentFlag hAlign) : QLabel(parent), _mode(mode) { @@ -206,7 +208,7 @@ void RetroStyleLabel::mouseReleaseEvent(QMouseEvent * event) { void RetroStyleLabel::setText(const QString & text) { QLabel::setText(text); QFontMetrics fm(font()); - int textWidth = fm.width(text); + int textWidth = QFontMetrics_horizontalAdvance(fm, text); textWidth += 40; QSize s = size(); if (textWidth > s.width()) { diff --git a/retroshare-gui/src/util/RichTextEdit.cpp b/retroshare-gui/src/util/RichTextEdit.cpp index 020b13db9..1f53af489 100644 --- a/retroshare-gui/src/util/RichTextEdit.cpp +++ b/retroshare-gui/src/util/RichTextEdit.cpp @@ -45,7 +45,11 @@ static const uint32_t MAX_ALLOWED_GXS_MESSAGE_SIZE = 199000; RichTextEdit::RichTextEdit(QWidget *parent) : QWidget(parent) { setupUi(this); m_lastBlockList = 0; +#if QT_VERSION >= QT_VERSION_CHECK (5, 10, 0) + f_textedit->setTabStopDistance(40); +#else f_textedit->setTabStopWidth(40); +#endif connect(f_textedit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(slotCurrentCharFormatChanged(QTextCharFormat))); @@ -177,14 +181,14 @@ RichTextEdit::RichTextEdit(QWidget *parent) : QWidget(parent) { // text foreground color QPixmap pix(16, 16); - pix.fill(QApplication::palette().foreground().color()); + pix.fill(QApplication::palette().windowText().color()); f_fgcolor->setIcon(pix); connect(f_fgcolor, SIGNAL(clicked()), this, SLOT(textFgColor())); // text background color - pix.fill(QApplication::palette().background().color()); + pix.fill(QApplication::palette().window().color()); f_bgcolor->setIcon(pix); connect(f_bgcolor, SIGNAL(clicked()), this, SLOT(textBgColor())); @@ -515,7 +519,7 @@ void RichTextEdit::fgColorChanged(const QColor &c) { if (c.isValid()) { pix.fill(c); } else { - pix.fill(QApplication::palette().foreground().color()); + pix.fill(QApplication::palette().windowText().color()); } f_fgcolor->setIcon(pix); } @@ -525,7 +529,7 @@ void RichTextEdit::bgColorChanged(const QColor &c) { if (c.isValid()) { pix.fill(c); } else { - pix.fill(QApplication::palette().background().color()); + pix.fill(QApplication::palette().window().color()); } f_bgcolor->setIcon(pix); } @@ -547,9 +551,9 @@ void RichTextEdit::slotClipboardDataChanged() { QString RichTextEdit::toHtml() const { QString s = f_textedit->toHtml(); // convert emails to links - s = s.replace(QRegExp("(<[^a][^>]+>(?:]+>)?|\\s)([a-zA-Z\\d]+@[a-zA-Z\\d]+\\.[a-zA-Z]+)"), "\\1\\2"); + s = s.replace(QRegularExpression("(<[^a][^>]+>(?:]+>)?|\\s)([a-zA-Z\\d]+@[a-zA-Z\\d]+\\.[a-zA-Z]+)"), "\\1\\2"); // convert links - s = s.replace(QRegExp("(<[^a][^>]+>(?:]+>)?|\\s)((?:https?|ftp|file)://[^\\s'\"<>]+)"), "\\1\\2"); + s = s.replace(QRegularExpression("(<[^a][^>]+>(?:]+>)?|\\s)((?:https?|ftp|file)://[^\\s'\"<>]+)"), "\\1\\2"); // see also: Utils::linkify() return s; } diff --git a/retroshare-gui/src/util/RsAction.cpp b/retroshare-gui/src/util/RsAction.cpp index f80fd0293..a0c38d492 100644 --- a/retroshare-gui/src/util/RsAction.cpp +++ b/retroshare-gui/src/util/RsAction.cpp @@ -20,7 +20,7 @@ #include "util/RsAction.h" -RsAction::RsAction(QWidget * parent, std::string rsid) +RsAction::RsAction(QObject * parent, std::string rsid) : QAction(parent), RsId(rsid) { connect(this, SIGNAL( triggered( bool ) ), this, SLOT( triggerEvent( bool ) ) ); diff --git a/retroshare-gui/src/util/RsAction.h b/retroshare-gui/src/util/RsAction.h index d61efc08b..b2110428a 100644 --- a/retroshare-gui/src/util/RsAction.h +++ b/retroshare-gui/src/util/RsAction.h @@ -28,7 +28,7 @@ class RsAction : public QAction { Q_OBJECT public: - RsAction(QWidget * parent, std::string rsid); + RsAction(QObject *parent, std::string rsid); RsAction(const QString & text, QObject * parent, std::string rsid); RsAction(const QIcon & icon, const QString & text, QObject * parent , std::string rsid); diff --git a/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp b/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp index c228923e8..906388cc2 100644 --- a/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp +++ b/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp @@ -21,7 +21,6 @@ #include #include "RsGxsUpdateBroadcast.h" -#include "gui/notifyqt.h" #include "util/qtthreadsutils.h" #include diff --git a/retroshare-gui/src/util/RsQtVersion.cpp b/retroshare-gui/src/util/RsQtVersion.cpp new file mode 100644 index 000000000..0762e5510 --- /dev/null +++ b/retroshare-gui/src/util/RsQtVersion.cpp @@ -0,0 +1,36 @@ +/******************************************************************************* + * util/RsQtVersion.cpp * + * * + * Copyright (C) 2025 Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#include + +// Functions to compile with Qt 4, Qt 5 and Qt 6 + +#if QT_VERSION < QT_VERSION_CHECK (5, 15, 0) +#include +QPixmap QLabel_pixmap(QLabel* label) +{ + const QPixmap *pixmap = label->pixmap(); + if (pixmap) { + return *pixmap; + } + + return QPixmap(); +} +#endif diff --git a/retroshare-gui/src/util/QtVersion.h b/retroshare-gui/src/util/RsQtVersion.h similarity index 64% rename from retroshare-gui/src/util/QtVersion.h rename to retroshare-gui/src/util/RsQtVersion.h index d04d226ae..e313f6054 100644 --- a/retroshare-gui/src/util/QtVersion.h +++ b/retroshare-gui/src/util/RsQtVersion.h @@ -1,5 +1,5 @@ /******************************************************************************* - * util/qthreadutils.h * + * util/RsQtVersion.h * * * * Copyright (C) 2013 Retroshare Team * * * @@ -18,10 +18,10 @@ * * *******************************************************************************/ -#ifndef QTVERSION_H -#define QTVERSION_H +#ifndef RS_QTVERSION_H +#define RS_QTVERSION_H -// Macros to compile with Qt 4 and Qt 5 +// Macros to compile with Qt 4, Qt 5 and Qt 6 // Renamed QHeaderView::setResizeMode to QHeaderView::setSectionResizeMode #if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0) @@ -43,4 +43,35 @@ #define QHeaderView_setSectionsMovable(header, movable) header->setMovable(movable); #endif +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) +#define QtSkipEmptyParts Qt::SkipEmptyParts +#else +#define QtSkipEmptyParts QString::SkipEmptyParts +#endif + +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) +#define QSortFilterProxyModel_setFilterRegularExpression(proxyModel, pattern) proxyModel->setFilterRegularExpression(pattern); +#else +#define QSortFilterProxyModel_setFilterRegularExpression(proxyModel, pattern) proxyModel->setFilterRegExp(pattern); +#endif + +#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0) +#define QFontMetrics_horizontalAdvance(fontMetrics, text) fontMetrics.horizontalAdvance(text) +#else +#define QFontMetrics_horizontalAdvance(fontMetrics, text) fontMetrics.width(text) +#endif + +#if QT_VERSION >= QT_VERSION_CHECK (6, 6, 0) +#define QLabel_pixmap(label) label->pixmap() +#elif QT_VERSION >= QT_VERSION_CHECK (5, 15, 0) +#define QLabel_pixmap(label) label->pixmap(Qt::ReturnByValue) +#else +class QLabel; +extern QPixmap QLabel_pixmap(QLabel* label); +#endif + +#if QT_VERSION < QT_VERSION_CHECK (5, 8, 0) +#define Q_FALLTHROUGH() (void)0 +#endif + #endif diff --git a/retroshare-gui/src/util/RsSyntaxHighlighter.cpp b/retroshare-gui/src/util/RsSyntaxHighlighter.cpp index ed05b702c..6a191ca2f 100644 --- a/retroshare-gui/src/util/RsSyntaxHighlighter.cpp +++ b/retroshare-gui/src/util/RsSyntaxHighlighter.cpp @@ -18,6 +18,8 @@ * * *******************************************************************************/ +#include + #include "RsSyntaxHighlighter.h" RsSyntaxHighlighter::RsSyntaxHighlighter(QTextEdit *parent) @@ -65,7 +67,7 @@ void RsSyntaxHighlighter::highlightBlock(const QString &text) { if (text == "") return; - QRegExp endl("[\\r\\n\\x2028]"); //Usually 0x2028 character is used for newline, no idea why + QRegularExpression endl("[\\r\\n\\N{U+2028}]"); //Usually 0x2028 character is used for newline, no idea why int index = 0; QStringList lines = text.split(endl); foreach (const QString &cLine, lines) { diff --git a/retroshare-gui/src/util/Widget.cpp b/retroshare-gui/src/util/Widget.cpp index 0fdf10880..cb9f6ad91 100644 --- a/retroshare-gui/src/util/Widget.cpp +++ b/retroshare-gui/src/util/Widget.cpp @@ -27,7 +27,7 @@ QGridLayout * Widget::createLayout(QWidget * parent) { QGridLayout * layout = new QGridLayout(parent); layout->setSpacing(0); - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); return layout; } diff --git a/retroshare-gui/src/util/imageutil.cpp b/retroshare-gui/src/util/imageutil.cpp index 690872bdb..472ea2369 100644 --- a/retroshare-gui/src/util/imageutil.cpp +++ b/retroshare-gui/src/util/imageutil.cpp @@ -340,7 +340,11 @@ void ImageUtil::quantization(const QImage &img, QVector &palette) colors.insert(pixel); } +#if QT_VERSION >= QT_VERSION_CHECK (5, 14, 0) + QList colorlist(colors.begin(), colors.end()); +#else QList colorlist = colors.toList(); +#endif //don't do the algoritmh if we have less than 16 different colors if(colorlist.size() <= (1 << bits)) { for(int i = 0; i < colors.count(); ++i) @@ -387,14 +391,14 @@ void ImageUtil::quantization(QList::iterator begin, QList::iterator //order by the widest channel if(red > green) if(red > blue) - qSort(begin, end, redLessThan); + std::sort(begin, end, redLessThan); else - qSort(begin, end, blueLessThan); + std::sort(begin, end, blueLessThan); else if(green > blue) - qSort(begin, end, greenLessThan); + std::sort(begin, end, greenLessThan); else - qSort(begin, end, blueLessThan); + std::sort(begin, end, blueLessThan); //split into two buckets QList::iterator split = begin + count / 2; diff --git a/retroshare-gui/src/util/log.cpp b/retroshare-gui/src/util/log.cpp index f1d31d706..23efb329c 100644 --- a/retroshare-gui/src/util/log.cpp +++ b/retroshare-gui/src/util/log.cpp @@ -171,7 +171,12 @@ Log::LogMessage::~LogMessage() if (!--stream->ref) { if (stream->out && !stream->buf.isEmpty()) { QTextStream log(stream->out); - log << toString() << endl; + log << toString() << +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + Qt::endl; +#else + endl; +#endif log.flush(); } delete stream; diff --git a/retroshare-gui/src/util/misc.cpp b/retroshare-gui/src/util/misc.cpp index 84c408de3..6ab427d10 100644 --- a/retroshare-gui/src/util/misc.cpp +++ b/retroshare-gui/src/util/misc.cpp @@ -335,8 +335,7 @@ bool misc::getOpenFileName(QWidget *parent, RshareSettings::enumLastDir type #ifdef WINDOWS_SYS // fix bug in Qt for Windows Vista and higher, convert path from native separators - if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)) - file = QDir::fromNativeSeparators(file); + file = QDir::fromNativeSeparators(file); #endif return true; @@ -361,11 +360,9 @@ bool misc::getOpenFileNames(QWidget *parent, RshareSettings::enumLastDir type Settings->setLastDir(type, lastDir); #ifdef WINDOWS_SYS - // fix bug in Qt for Windows Vista and higher, convert path from native separators - if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)) - for (QStringList::iterator file = files.begin(); file != files.end(); ++file) { - (*file) = QDir::fromNativeSeparators(*file); - } + for (QStringList::iterator file = files.begin(); file != files.end(); ++file) { + (*file) = QDir::fromNativeSeparators(*file); + } #endif return true; diff --git a/retroshare-gui/src/util/printpreview.cpp b/retroshare-gui/src/util/printpreview.cpp index cae4214d2..4bf4ad7c4 100644 --- a/retroshare-gui/src/util/printpreview.cpp +++ b/retroshare-gui/src/util/printpreview.cpp @@ -108,11 +108,11 @@ void PreviewView::paintPage(QPainter *painter, int page) painter->drawRect(QRectF(QPointF(0, 0), printPreview->paperSize)); painter->setBrush(Qt::NoBrush); - col = col.light(); + col = col.lighter(); painter->drawLine(QLineF(printPreview->paperSize.width(), 1, printPreview->paperSize.width(), printPreview->paperSize.height() - 1)); - col = col.light(); + col = col.lighter(); painter->drawLine(QLineF(printPreview->paperSize.width(), 2, printPreview->paperSize.width(), printPreview->paperSize.height() - 2)); @@ -239,12 +239,12 @@ PrintPreview::PrintPreview(const QTextDocument *document, QWidget *parent) void PrintPreview::setup() { - QSizeF page = printer.pageRect().size(); - paperSize = printer.paperRect().size(); + QRect page = printer.pageLayout().paintRectPixels(printer.resolution()); + paperSize = printer.pageLayout().fullRectPixels(printer.resolution()).size(); paperSize.rwidth() *= qreal(view->logicalDpiX()) / printer.logicalDpiX(); paperSize.rheight() *= qreal(view->logicalDpiY()) / printer.logicalDpiY(); - pageTopLeft = printer.pageRect().topLeft(); + pageTopLeft = page.topLeft(); pageTopLeft.rx() *= qreal(view->logicalDpiX()) / printer.logicalDpiX(); pageTopLeft.ry() *= qreal(view->logicalDpiY()) / printer.logicalDpiY(); @@ -257,7 +257,7 @@ void PrintPreview::setup() fmt.setMargin(margin); doc->rootFrame()->setFrameFormat(fmt); - doc->setPageSize(page); + doc->setPageSize(page.size()); } PrintPreview::~PrintPreview() diff --git a/retroshare-service/CMakeLists.txt b/retroshare-service/CMakeLists.txt index 97562c91e..2c8bb2e80 100644 --- a/retroshare-service/CMakeLists.txt +++ b/retroshare-service/CMakeLists.txt @@ -27,6 +27,11 @@ option( just for development purposes, not suitable for library usage" OFF ) +option( + RS_RNPLIB + "Enable use RNP lib for PGP" + OFF ) + option( RS_JSON_API "Use restbed to expose libretroshare as JSON API via HTTP" @@ -61,6 +66,21 @@ cmake_dependent_option( set(FETCHCONTENT_QUIET OFF) include(FetchContent) +# Find required dependencies +# find_package for Botan and json-c failed to populate variables, remove them. +# find_package(Botan 3 REQUIRED) +# message(STATUS "Botan_FOUND=${Botan_FOUND}") +# message(STATUS "BOTAN_LIBRARIES=${BOTAN_LIBRARIES}") +# message(STATUS "BOTAN_INCLUDE_DIRS=${BOTAN_INCLUDE_DIRS}") +# +# find_package(json-c REQUIRED) +# message(STATUS "json-c_FOUND=${json-c_FOUND}") +# message(STATUS "JSON-C_LIBRARIES=${JSON-C_LIBRARIES}") +# message(STATUS "JSON-C_INCLUDE_DIRS=${JSON-C_INCLUDE_DIRS}") + +find_package(ZLIB REQUIRED) +find_package(BZip2 REQUIRED) + find_package(Git REQUIRED) ################################################################################ @@ -113,6 +133,38 @@ target_link_libraries(${PROJECT_NAME} PRIVATE retroshare) ################################################################################ +if(RS_RNPLIB) + # Add RNP build directories to linker search path + target_link_directories(${PROJECT_NAME} PRIVATE + ${PROJECT_SOURCE_DIR}/../../supportlibs/librnp/Build/src/lib + ${PROJECT_SOURCE_DIR}/../../supportlibs/librnp/Build/src/libsexpp + ) + + # Link libraries by name, including RNP libs and dependencies first + target_link_libraries(${PROJECT_NAME} PRIVATE + rnp # Link by name + sexpp + botan-3 + json-c + bz2 + z + retroshare + ) +endif(RS_RNPLIB) + +################################################################################ + +# Add include directories from found packages +# target_include_directories(${PROJECT_NAME} PRIVATE +# ${Botan_INCLUDE_DIRS} +# ${JSONC_INCLUDE_DIRS} +# ) + +# Link only libretroshare, it should handle its own dependencies now +target_link_libraries(${PROJECT_NAME} PRIVATE retroshare) + +################################################################################ + if(RS_SERVICE_DESKTOP) if(UNIX AND NOT APPLE) install( diff --git a/retroshare-service/src/retroshare-service.cc b/retroshare-service/src/retroshare-service.cc index ac82593da..4ca2c8a7a 100644 --- a/retroshare-service/src/retroshare-service.cc +++ b/retroshare-service/src/retroshare-service.cc @@ -71,7 +71,29 @@ std::string colored(int color,const std::string& s) } } +static void eventHandler(std::shared_ptr e) +{ + auto fe = dynamic_cast(e.get()); + + if(!fe) + return; + #ifdef RS_SERVICE_TERMINAL_LOGIN + if(fe->mEventCode == RsSystemEventCode::PASSWORD_REQUESTED) + { + std::string question1 = fe->passwd_request_title + colored(COLOR_GREEN,"Please enter your PGP password for key:\n ") + fe->passwd_request_key_details + " :"; + std::string password = RsUtil::rs_getpass(question1.c_str()) ; + + if(!password.empty()) + RsLoginHelper::cachePgpPassphrase(password); + } +#endif + + // We should also handle plugin loading +} + + +#ifdef TO_REMOVE class RsServiceNotify: public NotifyClient { public: @@ -86,7 +108,7 @@ public: password = RsUtil::rs_getpass(question1.c_str()) ; cancel = false ; - return !password.empty(); + return !password.empty(); } }; #endif // def RS_SERVICE_TERMINAL_LOGIN @@ -149,6 +171,9 @@ int main(int argc, char* argv[]) RsInit::InitRsConfig(); RsControl::earlyInitNotificationSystem(); + RsEventsHandlerId_t EventHandlerId = 0; + rsEvents->registerEventsHandler(eventHandler,EventHandlerId, RsEventType::SYSTEM); + #ifdef __APPLE__ // TODO: is this still needed with argstream? /* HACK to avoid stupid OSX Finder behaviour @@ -330,8 +355,8 @@ int main(int argc, char* argv[]) return -EINVAL; } - RsServiceNotify* notify = new RsServiceNotify(); - rsNotify->registerNotifyClient(notify); + //RsServiceNotify* notify = new RsServiceNotify(); + //rsNotify->registerNotifyClient(notify); // supply empty passwd so that it is properly asked 3 times on console RsInit::LoadCertificateStatus result = rsLoginHelper->attemptLogin(ssl_id, ""); diff --git a/retroshare-service/src/retroshare-service.pro b/retroshare-service/src/retroshare-service.pro index 275f868cc..c514ef607 100644 --- a/retroshare-service/src/retroshare-service.pro +++ b/retroshare-service/src/retroshare-service.pro @@ -67,6 +67,7 @@ unix { macx { # ENABLE THIS OPTION FOR Univeral Binary BUILD. #CONFIG += ppc x86 + QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.13 #QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4 LIBS += -lz #LIBS += -lssl -lcrypto -lz -lgpgme -lgpg-error -lassuan @@ -81,6 +82,12 @@ macx { LIBS += -framework Security LIBS += -framework Carbon + # Explicitly add RNP libs here for the service target + LIBRNP_BUILD_PATH = $$clean_path($${OUT_PWD}/../../supportlibs/librnp/Build) + LIBS += -L$$clean_path($${LIBRNP_BUILD_PATH}/src/lib) -lrnp + LIBS += -L$$clean_path($${LIBRNP_BUILD_PATH}/src/libsexpp) -lsexpp + LIBS += -lbz2 -lz -ljson-c -lbotan-2 + for(lib, LIB_DIR):LIBS += -L"$$lib" for(bin, BIN_DIR):LIBS += -L"$$bin" diff --git a/retroshare.pri b/retroshare.pri index 18207838d..7eeeec39c 100644 --- a/retroshare.pri +++ b/retroshare.pri @@ -131,16 +131,15 @@ CONFIG *= no_use_dht_stunner_ext_ip use_dht_stunner_ext_ip:CONFIG -= no_use_dht_stunner_ext_ip # To select your MacOsX version append the following assignation to qmake -# command line "CONFIG+=rs_macos10.11" where 10.11 depends your version -macx:CONFIG *= rs_macos11.1 -rs_macos10.8:CONFIG -= rs_macos10.11 -rs_macos10.9:CONFIG -= rs_macos10.11 -rs_macos10.10:CONFIG -= rs_macos10.11 -rs_macos10.12:CONFIG -= rs_macos10.11 -rs_macos10.13:CONFIG -= rs_macos10.11 -rs_macos10.14:CONFIG -= rs_macos10.11 -rs_macos10.15:CONFIG -= rs_macos10.11 -rs_macos11.1:CONFIG -= rs_macos10.11 +# command line "CONFIG+=rs_macos10.13" where 10.13 depends your version +macx:CONFIG *= rs_macos10.13 +rs_macos10.14:CONFIG -= rs_macos10.13 +rs_macos10.15:CONFIG -= rs_macos10.13 +rs_macos11.1:CONFIG -= rs_macos10.13 +rs_macos14.0:CONFIG -= rs_macos10.13 +rs_macos14.5:CONFIG -= rs_macos10.13 +rs_macos15.2:CONFIG -= rs_macos10.13 +rs_macos15.5:CONFIG -= rs_macos10.13 # To enable JSON API append the following assignation to qmake command line # "CONFIG+=rs_jsonapi" @@ -734,7 +733,10 @@ android-* { # To export all symbols for the plugins on Windows build we need to build # libretroshare as shared library. Fix linking error (ld.exe: Error: export # ordinal too large) due to too many exported symbols. -retroshare_plugins:win32:CONFIG *= libretroshare_shared +#retroshare_plugins:win32:CONFIG *= libretroshare_shared + +# Always build libretroshare on Windows as shared library to be compatible when building with and without plugins +win32:CONFIG *= libretroshare_shared win32-g++|win32-clang-g++ { !isEmpty(EXTERNAL_LIB_DIR) { @@ -793,37 +795,6 @@ win32-clang-g++ { } macx-* { - rs_macos10.8 { - message(***retroshare.pri: Set Target and SDK to MacOS 10.8 ) - QMAKE_MACOSX_DEPLOYMENT_TARGET=10.8 - QMAKE_MAC_SDK = macosx10.8 - } - - rs_macos10.9 { - message(***retroshare.pri: Set Target and SDK to MacOS 10.9 ) - QMAKE_MACOSX_DEPLOYMENT_TARGET=10.9 - QMAKE_MAC_SDK = macosx10.9 - } - - rs_macos10.10 { - message(***retroshare.pri: Set Target and SDK to MacOS 10.10 ) - QMAKE_MACOSX_DEPLOYMENT_TARGET=10.10 - QMAKE_MAC_SDK = macosx10.10 - } - - rs_macos10.11 { - message(***retroshare.pri: Set Target and SDK to MacOS 10.11 ) - QMAKE_MACOSX_DEPLOYMENT_TARGET=10.11 - QMAKE_MAC_SDK = macosx10.11 - } - - rs_macos10.12 { - message(***retroshare.pri: Set Target and SDK to MacOS 10.12 ) - QMAKE_MACOSX_DEPLOYMENT_TARGET=10.12 - QMAKE_MAC_SDK = macosx10.12 - QMAKE_CXXFLAGS += -Wno-nullability-completeness - QMAKE_CFLAGS += -Wno-nullability-completeness - } rs_macos10.13 { message(***retroshare.pri: Set Target and SDK to MacOS 10.13 ) QMAKE_MACOSX_DEPLOYMENT_TARGET=10.13 @@ -833,25 +804,53 @@ macx-* { } rs_macos10.14 { message(***retroshare.pri: Set Target and SDK to MacOS 10.14 ) - QMAKE_MACOSX_DEPLOYMENT_TARGET=10.14 + QMAKE_MACOSX_DEPLOYMENT_TARGET=10.13 QMAKE_MAC_SDK = macosx10.14 QMAKE_CXXFLAGS += -Wno-nullability-completeness QMAKE_CFLAGS += -Wno-nullability-completeness } rs_macos10.15 { message(***retroshare.pri: Set Target and SDK to MacOS 10.15 ) - QMAKE_MACOSX_DEPLOYMENT_TARGET=10.15 + QMAKE_MACOSX_DEPLOYMENT_TARGET=10.13 QMAKE_MAC_SDK = macosx10.15 QMAKE_CXXFLAGS += -Wno-nullability-completeness QMAKE_CFLAGS += -Wno-nullability-completeness } rs_macos11.1 { message(***retroshare.pri: Set Target and SDK to MacOS 11.1 ) - QMAKE_MACOSX_DEPLOYMENT_TARGET=11.1 + QMAKE_MACOSX_DEPLOYMENT_TARGET=10.13 QMAKE_MAC_SDK = macosx11.1 QMAKE_CXXFLAGS += -Wno-nullability-completeness QMAKE_CFLAGS += -Wno-nullability-completeness } + rs_macos14.0 { + message(***retroshare.pri: Set Target and SDK to MacOS 14.0 ) + QMAKE_MACOSX_DEPLOYMENT_TARGET=14.0 + QMAKE_MAC_SDK = macosx14.0 + QMAKE_CXXFLAGS += -Wno-nullability-completeness + QMAKE_CFLAGS += -Wno-nullability-completeness + } + rs_macos14.5 { + message(***retroshare.pri: Set Target and SDK to MacOS 14.5 ) + QMAKE_MACOSX_DEPLOYMENT_TARGET=10.13 + QMAKE_MAC_SDK = macosx14.5 + QMAKE_CXXFLAGS += -Wno-nullability-completeness + QMAKE_CFLAGS += -Wno-nullability-completeness + } + rs_macos15.2 { + message(***retroshare.pri: Set Target and SDK to MacOS 15.2 ) + QMAKE_MACOSX_DEPLOYMENT_TARGET=10.13 + QMAKE_MAC_SDK = macosx15.2 + QMAKE_CXXFLAGS += -Wno-nullability-completeness + QMAKE_CFLAGS += -Wno-nullability-completeness + } + rs_macos15.5 { + message(***retroshare.pri: Set Target and SDK to MacOS 15.5 ) + QMAKE_MACOSX_DEPLOYMENT_TARGET=10.13 + QMAKE_MAC_SDK = macosx15.5 + QMAKE_CXXFLAGS += -Wno-nullability-completeness + QMAKE_CFLAGS += -Wno-nullability-completeness + } @@ -859,7 +858,7 @@ macx-* { BIN_DIR += "/Applications/Xcode.app/Contents/Developer/usr/bin" INCLUDEPATH += "/usr/local/include" RS_UPNP_LIB = miniupnpc - QT += macextras + lessThan(QT_MAJOR_VERSION, 6): QT += macextras INCLUDEPATH += "/usr/local/opt/openssl/include" QMAKE_LIBDIR += "/usr/local/opt/openssl/lib" QMAKE_LIBDIR += "/usr/local/opt/sqlcipher/lib" diff --git a/supportlibs/cmark b/supportlibs/cmark index 3460cd809..b9c7a496b 160000 --- a/supportlibs/cmark +++ b/supportlibs/cmark @@ -1 +1 @@ -Subproject commit 3460cd809b6dd311b58e92733ece2fc956224fd2 +Subproject commit b9c7a496ba7dd9c3495bae2ff2855899e47b245d diff --git a/supportlibs/libsam3 b/supportlibs/libsam3 index f90555ba4..8623304b6 160000 --- a/supportlibs/libsam3 +++ b/supportlibs/libsam3 @@ -1 +1 @@ -Subproject commit f90555ba4d6f9fadb6f0fbb1e2253e13557aad34 +Subproject commit 8623304b62294dafbe477573f321a464fef721dd diff --git a/supportlibs/rapidjson b/supportlibs/rapidjson index 24b5e7a8b..f54b0e47a 160000 --- a/supportlibs/rapidjson +++ b/supportlibs/rapidjson @@ -1 +1 @@ -Subproject commit 24b5e7a8b27f42fa16b96fc70aade9106cf7102f +Subproject commit f54b0e47a08782a6131cc3d60f94d038fa6e0a51