Compare commits
53 Commits
Author | SHA1 | Date | |
---|---|---|---|
733aad9903 | |||
3a8b8c715a | |||
b19e8b233a | |||
bc6444747d | |||
ea9755bf9a | |||
774c1685af | |||
9067b9dc91 | |||
11b88aaf3d | |||
231f8ee1bb | |||
788d56f98e | |||
bd33509e7a | |||
3711f30f3b | |||
69177d5dda | |||
dc33ae0a54 | |||
032dc9f644 | |||
1bb26d9c33 | |||
3ab52e1b9e | |||
58a79b0681 | |||
fac5bd700a | |||
3ed5d3ce0d | |||
449651e94f | |||
59466c5f9e | |||
229c3f6645 | |||
2acd37bcce | |||
ccf31d072e | |||
daefd245f0 | |||
8a5aa60d66 | |||
1a99bf1ded | |||
fd951ed502 | |||
d9065280ea | |||
0fdaad70ee | |||
0f13bc8d9b | |||
75dc40406c | |||
54919796d7 | |||
165e9039a7 | |||
f29e180092 | |||
64ab212a1f | |||
eab650d6dd | |||
dd83e11338 | |||
89eef7247a | |||
540877fb75 | |||
f0e01cd268 | |||
7407a9a037 | |||
614eb26f32 | |||
7d1d5e52d8 | |||
b50f38decf | |||
a65c1c549e | |||
e680b8e323 | |||
2a8cd9c5b0 | |||
740d0929d2 | |||
5163b4adbb | |||
096c74c4cc | |||
ce9d156ef2 |
401
.drone.yml
401
.drone.yml
|
@ -1,182 +1,223 @@
|
|||
pipeline:
|
||||
gcc6:
|
||||
image: debian:stretch-slim
|
||||
pull: true
|
||||
environment:
|
||||
- LANG=C.utf8
|
||||
- CXX=g++-6
|
||||
- CXXFLAGS=-pipe -O2
|
||||
commands:
|
||||
- rm /etc/apt/apt.conf.d/docker-clean
|
||||
- apt-get update -q
|
||||
- apt-get install -qy g++ cmake pkg-config
|
||||
- apt-get install -qy libvsqlitepp-dev libboost-dev libxdg-basedir-dev qt5-default qttools5-dev-tools qttools5-dev
|
||||
- apt-get install -qy dpkg-dev rpm file wget
|
||||
- gpg --import /var/autosign_gpg.key
|
||||
- rm -rf build && mkdir -p build && cd build
|
||||
- cmake -DCMAKE_INSTALL_PREFIX=/usr ..
|
||||
- make VERBOSE=1
|
||||
- make install DESTDIR=install
|
||||
- make package
|
||||
- cmake -DWITH_DEB=ON ..
|
||||
- make package
|
||||
- cmake -DWITH_DEB=OFF -DWITH_RPM=ON ..
|
||||
- make package
|
||||
- gpg --verbose --detach-sign *.tar.gz
|
||||
- gpg --verbose --detach-sign *.deb
|
||||
- gpg --verbose --detach-sign *.rpm
|
||||
volumes:
|
||||
- /var/cache/debian-package-cache:/var/cache/apt/archives
|
||||
- /home/tastytea/misc/autosign_gpg.key:/var/autosign_gpg.key
|
||||
kind: pipeline
|
||||
name: build x86_64
|
||||
|
||||
gcc7:
|
||||
image: debian:stretch-slim
|
||||
pull: true
|
||||
when:
|
||||
event: [push, pull_request]
|
||||
environment:
|
||||
- LANG=C.utf8
|
||||
- CXX=g++-7
|
||||
- CXXFLAGS=-pipe -O2
|
||||
commands:
|
||||
- rm /etc/apt/apt.conf.d/docker-clean
|
||||
- apt-get update -q
|
||||
- echo "APT::Default-Release \"stretch\";" >> /etc/apt/apt.conf.d/00default_release
|
||||
- echo "deb http://deb.debian.org/debian stretch-backports main" >> /etc/apt/sources.list.d/backports.list
|
||||
- echo "deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main" >> /etc/apt/sources.list.d/ubuntu-toolchain-r.list
|
||||
- apt-get install -qy gnupg
|
||||
- gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 0x60c317803a41ba51845e371a1e9377a2ba9ef27f
|
||||
- gpg --armor --export 0x60c317803a41ba51845e371a1e9377a2ba9ef27f | apt-key add -
|
||||
- apt-get update -q
|
||||
- apt-get install -qy -t xenial g++-7
|
||||
- apt-get install -qy cmake pkg-config
|
||||
- apt-get install -qy libvsqlitepp-dev libboost-dev libxdg-basedir-dev qt5-default qttools5-dev-tools qttools5-dev
|
||||
- rm -rf build && mkdir -p build && cd build
|
||||
- cmake ..
|
||||
- make VERBOSE=1
|
||||
- make install DESTDIR=install
|
||||
volumes:
|
||||
- /var/cache/debian-package-cache:/var/cache/apt/archives
|
||||
volumes:
|
||||
- name: debian-package-cache
|
||||
host:
|
||||
path: /var/cache/debian-package-cache
|
||||
|
||||
gcc8:
|
||||
image: debian:stretch-slim
|
||||
pull: true
|
||||
when:
|
||||
event: [push, pull_request]
|
||||
environment:
|
||||
- LANG=C.utf8
|
||||
- CXX=g++-8
|
||||
- CXXFLAGS=-pipe -O2
|
||||
commands:
|
||||
- rm /etc/apt/apt.conf.d/docker-clean
|
||||
- apt-get update -q
|
||||
- echo "APT::Default-Release \"stretch\";" >> /etc/apt/apt.conf.d/00default_release
|
||||
- echo "deb http://deb.debian.org/debian stretch-backports main" >> /etc/apt/sources.list.d/backports.list
|
||||
- echo "deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main" >> /etc/apt/sources.list.d/ubuntu-toolchain-r.list
|
||||
- apt-get install -qy gnupg
|
||||
- gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 0x60c317803a41ba51845e371a1e9377a2ba9ef27f
|
||||
- gpg --armor --export 0x60c317803a41ba51845e371a1e9377a2ba9ef27f | apt-key add -
|
||||
- apt-get update -q
|
||||
- apt-get install -qy -t xenial g++-8
|
||||
- apt-get install -qy cmake pkg-config
|
||||
- apt-get install -qy libvsqlitepp-dev libboost-dev libxdg-basedir-dev qt5-default qttools5-dev-tools qttools5-dev
|
||||
- rm -rf build && mkdir -p build && cd build
|
||||
- cmake ..
|
||||
- make VERBOSE=1
|
||||
- make install DESTDIR=install
|
||||
volumes:
|
||||
- /var/cache/debian-package-cache:/var/cache/apt/archives
|
||||
trigger:
|
||||
event:
|
||||
exclude:
|
||||
- tag
|
||||
|
||||
clang3:
|
||||
image: debian:stretch-slim
|
||||
pull: true
|
||||
when:
|
||||
event: [push, pull_request]
|
||||
environment:
|
||||
- LANG=C.utf8
|
||||
- CXX=clang++
|
||||
- CXXFLAGS=-pipe -O2
|
||||
commands:
|
||||
- rm /etc/apt/apt.conf.d/docker-clean
|
||||
- echo "APT::Default-Release \"stretch\";" >> /etc/apt/apt.conf.d/00default_release
|
||||
- echo "deb http://deb.debian.org/debian stretch-backports main" >> /etc/apt/sources.list.d/backports.list
|
||||
- apt-get update -q
|
||||
- apt-get install -qy clang cmake pkg-config
|
||||
- apt-get install -qy libvsqlitepp-dev libboost-dev libxdg-basedir-dev qt5-default qttools5-dev-tools qttools5-dev
|
||||
- rm -rf build && mkdir -p build && cd build
|
||||
- cmake ..
|
||||
- make VERBOSE=1
|
||||
- make install DESTDIR=install
|
||||
volumes:
|
||||
- /var/cache/debian-package-cache:/var/cache/apt/archives
|
||||
steps:
|
||||
- name: submodules
|
||||
image: docker:git
|
||||
commands:
|
||||
- git submodule init
|
||||
- git submodule update --recursive
|
||||
|
||||
clang5:
|
||||
image: debian:stretch-slim
|
||||
pull: true
|
||||
when:
|
||||
event: [push, pull_request]
|
||||
environment:
|
||||
- LANG=C.utf8
|
||||
- CXX=clang++-5.0
|
||||
- CXXFLAGS=-pipe -O2
|
||||
commands:
|
||||
- rm /etc/apt/apt.conf.d/docker-clean
|
||||
- echo "APT::Default-Release \"stretch\";" >> /etc/apt/apt.conf.d/00default_release
|
||||
- echo "deb http://deb.debian.org/debian stretch-backports main" >> /etc/apt/sources.list.d/stretch.list
|
||||
- apt-get update -q
|
||||
- apt-get install -qy -t stretch-backports clang-5.0
|
||||
- apt-get install -qy cmake pkg-config
|
||||
- apt-get install -qy libvsqlitepp-dev libboost-dev libxdg-basedir-dev qt5-default qttools5-dev-tools qttools5-dev
|
||||
- rm -rf build && mkdir -p build && cd build
|
||||
- cmake ..
|
||||
- make VERBOSE=1
|
||||
- make install DESTDIR=install
|
||||
volumes:
|
||||
- /var/cache/debian-package-cache:/var/cache/apt/archives
|
||||
- name: gcc6
|
||||
image: ubuntu:xenial
|
||||
pull: always
|
||||
environment:
|
||||
CXX: g++-6
|
||||
CXXFLAGS: -pipe -O2
|
||||
commands:
|
||||
- rm /etc/apt/apt.conf.d/docker-clean
|
||||
- echo "deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main" >> /etc/apt/sources.list.d/ubuntu-toolchain-r.list
|
||||
- gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 0x60c317803a41ba51845e371a1e9377a2ba9ef27f
|
||||
- gpg --armor --export 0x60c317803a41ba51845e371a1e9377a2ba9ef27f | apt-key add -
|
||||
- rm -f /var/cache/apt/archives/lock
|
||||
- apt-get update -q
|
||||
- rm -f /var/cache/apt/archives/lock
|
||||
- apt-get install -qy g++-6 cmake pkg-config
|
||||
- rm -f /var/cache/apt/archives/lock
|
||||
- apt-get install -qy libvsqlitepp-dev libboost-dev libxdg-basedir-dev qt5-default qttools5-dev-tools qttools5-dev libconfig++-dev asciidoc
|
||||
- rm -rf build && mkdir -p build && cd build
|
||||
- cmake -DCMAKE_INSTALL_PREFIX=/usr ..
|
||||
- make VERBOSE=1
|
||||
- make install DESTDIR=install
|
||||
volumes:
|
||||
- name: debian-package-cache
|
||||
path: /var/cache/apt/archives
|
||||
|
||||
clang6:
|
||||
image: debian:stretch-slim
|
||||
pull: true
|
||||
when:
|
||||
event: [push, pull_request]
|
||||
environment:
|
||||
- LANG=C.utf8
|
||||
- CXX=clang++-6.0
|
||||
- CXXFLAGS=-pipe -O2
|
||||
commands:
|
||||
- rm /etc/apt/apt.conf.d/docker-clean
|
||||
- echo "APT::Default-Release \"stretch\";" >> /etc/apt/apt.conf.d/00default_release
|
||||
- echo "deb http://deb.debian.org/debian stretch-backports main" >> /etc/apt/sources.list.d/stretch.list
|
||||
- apt-get update -q
|
||||
- apt-get install -qy -t stretch-backports clang-6.0
|
||||
- apt-get install -qy cmake pkg-config
|
||||
- apt-get install -qy libvsqlitepp-dev libboost-dev libxdg-basedir-dev qt5-default qttools5-dev-tools qttools5-dev
|
||||
- rm -rf build && mkdir -p build && cd build
|
||||
- cmake ..
|
||||
- make VERBOSE=1
|
||||
- make install DESTDIR=install
|
||||
volumes:
|
||||
- /var/cache/debian-package-cache:/var/cache/apt/archives
|
||||
- name: gcc9
|
||||
image: debian:stretch-slim
|
||||
pull: always
|
||||
environment:
|
||||
CXX: g++-9
|
||||
CXXFLAGS: -pipe -O2
|
||||
commands:
|
||||
- rm /etc/apt/apt.conf.d/docker-clean
|
||||
- rm -f /var/cache/apt/archives/lock
|
||||
- apt-get update -q
|
||||
- echo "APT::Default-Release \"stretch\";" >> /etc/apt/apt.conf.d/00default_release
|
||||
- echo "deb http://deb.debian.org/debian stretch-backports main" >> /etc/apt/sources.list.d/backports.list
|
||||
- echo "deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main" >> /etc/apt/sources.list.d/ubuntu-toolchain-r.list
|
||||
- rm -f /var/cache/apt/archives/lock
|
||||
- apt-get install -qy gnupg
|
||||
- gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 0x60c317803a41ba51845e371a1e9377a2ba9ef27f
|
||||
- gpg --armor --export 0x60c317803a41ba51845e371a1e9377a2ba9ef27f | apt-key add -
|
||||
- rm -f /var/cache/apt/archives/lock
|
||||
- apt-get update -q
|
||||
- rm -f /var/cache/apt/archives/lock
|
||||
- apt-get install -qy -t xenial g++-9
|
||||
- rm -f /var/cache/apt/archives/lock
|
||||
- apt-get install -qy cmake pkg-config
|
||||
- rm -f /var/cache/apt/archives/lock
|
||||
- apt-get install -qy libvsqlitepp-dev libboost-dev libxdg-basedir-dev qt5-default qttools5-dev-tools qttools5-dev libconfig++-dev asciidoc
|
||||
- rm -rf build && mkdir -p build && cd build
|
||||
- cmake ..
|
||||
- make VERBOSE=1
|
||||
- make install DESTDIR=install
|
||||
volumes:
|
||||
- name: debian-package-cache
|
||||
path: /var/cache/apt/archives
|
||||
|
||||
prepare_release:
|
||||
image: debian:jessie-slim
|
||||
pull: true
|
||||
when:
|
||||
event: tag
|
||||
commands:
|
||||
- cp -v build/whyblocked-${DRONE_TAG}_x86_64.tar.gz .
|
||||
- cp -v build/whyblocked-${DRONE_TAG}_x86_64.tar.gz.sig .
|
||||
- cp -v build/whyblocked_${DRONE_TAG}-0_amd64.deb .
|
||||
- cp -v build/whyblocked_${DRONE_TAG}-0_amd64.deb.sig .
|
||||
- cp -v build/whyblocked-${DRONE_TAG}-0.x86_64.rpm .
|
||||
- cp -v build/whyblocked-${DRONE_TAG}-0.x86_64.rpm.sig .
|
||||
gitea_release:
|
||||
image: plugins/gitea-release
|
||||
pull: true
|
||||
when:
|
||||
event: tag
|
||||
- name: clang3
|
||||
image: debian:stretch-slim
|
||||
pull: always
|
||||
environment:
|
||||
CXX: clang++
|
||||
CXXFLAGS: -pipe -O2
|
||||
commands:
|
||||
- rm /etc/apt/apt.conf.d/docker-clean
|
||||
- echo "APT::Default-Release \"stretch\";" >> /etc/apt/apt.conf.d/00default_release
|
||||
- echo "deb http://deb.debian.org/debian stretch-backports main" >> /etc/apt/sources.list.d/backports.list
|
||||
- rm -f /var/cache/apt/archives/lock
|
||||
- apt-get update -q
|
||||
- rm -f /var/cache/apt/archives/lock
|
||||
- apt-get install -qy clang cmake pkg-config
|
||||
- rm -f /var/cache/apt/archives/lock
|
||||
- apt-get install -qy libvsqlitepp-dev libboost-dev libxdg-basedir-dev qt5-default qttools5-dev-tools qttools5-dev libconfig++-dev asciidoc
|
||||
- rm -rf build && mkdir -p build && cd build
|
||||
- cmake ..
|
||||
- make VERBOSE=1
|
||||
- make install DESTDIR=install
|
||||
volumes:
|
||||
- name: debian-package-cache
|
||||
path: /var/cache/apt/archives
|
||||
|
||||
- name: clang6
|
||||
image: debian:stretch-slim
|
||||
pull: always
|
||||
environment:
|
||||
CXX: clang++-6.0
|
||||
CXXFLAGS: -pipe -O2
|
||||
commands:
|
||||
- rm /etc/apt/apt.conf.d/docker-clean
|
||||
- echo "APT::Default-Release \"stretch\";" >> /etc/apt/apt.conf.d/00default_release
|
||||
- echo "deb http://deb.debian.org/debian stretch-backports main" >> /etc/apt/sources.list.d/stretch.list
|
||||
- rm -f /var/cache/apt/archives/lock
|
||||
- apt-get update -q
|
||||
- rm -f /var/cache/apt/archives/lock
|
||||
- apt-get install -qy -t stretch-backports clang-6.0
|
||||
- rm -f /var/cache/apt/archives/lock
|
||||
- apt-get install -qy cmake pkg-config
|
||||
- rm -f /var/cache/apt/archives/lock
|
||||
- apt-get install -qy libvsqlitepp-dev libboost-dev libxdg-basedir-dev qt5-default qttools5-dev-tools qttools5-dev libconfig++-dev asciidoc
|
||||
- rm -rf build && mkdir -p build && cd build
|
||||
- cmake ..
|
||||
- make VERBOSE=1
|
||||
- make install DESTDIR=install
|
||||
volumes:
|
||||
- name: debian-package-cache
|
||||
path: /var/cache/apt/archives
|
||||
|
||||
- name: notify
|
||||
image: drillster/drone-email
|
||||
pull: always
|
||||
settings:
|
||||
host: cryptoparty-celle.de
|
||||
username:
|
||||
from_secret: email_username
|
||||
password:
|
||||
from_secret: email_password
|
||||
from: drone@tzend.de
|
||||
when:
|
||||
status: [ changed, failure ]
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
name: packages x86_64
|
||||
|
||||
volumes:
|
||||
- name: debian-package-cache
|
||||
host:
|
||||
path: /var/cache/debian-package-cache
|
||||
- name: gpg-key
|
||||
host:
|
||||
path: /var/autosign_gpg.key
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- tag
|
||||
|
||||
steps:
|
||||
- name: submodules
|
||||
image: docker:git
|
||||
commands:
|
||||
- git submodule init
|
||||
- git submodule update --recursive
|
||||
|
||||
- name: gcc6
|
||||
image: ubuntu:xenial
|
||||
pull: always
|
||||
environment:
|
||||
CXX: g++-6
|
||||
CXXFLAGS: -pipe -O2
|
||||
commands:
|
||||
- rm /etc/apt/apt.conf.d/docker-clean
|
||||
- echo "deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main" >> /etc/apt/sources.list.d/ubuntu-toolchain-r.list
|
||||
- gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 0x60c317803a41ba51845e371a1e9377a2ba9ef27f
|
||||
- gpg --armor --export 0x60c317803a41ba51845e371a1e9377a2ba9ef27f | apt-key add -
|
||||
- rm -f /var/cache/apt/archives/lock
|
||||
- apt-get update -q
|
||||
- rm -f /var/cache/apt/archives/lock
|
||||
- apt-get install -qy g++-6 cmake pkg-config
|
||||
- rm -f /var/cache/apt/archives/lock
|
||||
- apt-get install -qy libvsqlitepp-dev libboost-dev libxdg-basedir-dev qt5-default qttools5-dev-tools qttools5-dev libconfig++-dev asciidoc
|
||||
- rm -f /var/cache/apt/archives/lock
|
||||
- apt-get install -qy dpkg-dev rpm file wget
|
||||
- gpg --import /var/autosign_gpg.key
|
||||
- rm -rf build && mkdir -p build && cd build
|
||||
- cmake -DCMAKE_INSTALL_PREFIX=/usr ..
|
||||
- make VERBOSE=1
|
||||
- make install DESTDIR=install
|
||||
- make package
|
||||
- cmake -DWITH_DEB=ON ..
|
||||
- make package
|
||||
- cmake -DWITH_DEB=OFF -DWITH_RPM=ON ..
|
||||
- make package
|
||||
- gpg --verbose --detach-sign *.tar.gz
|
||||
- gpg --verbose --detach-sign *.deb
|
||||
- gpg --verbose --detach-sign *.rpm
|
||||
volumes:
|
||||
- name: debian-package-cache
|
||||
path: /var/cache/apt/archives
|
||||
- name: gpg-key
|
||||
path: /var/autosign_gpg.key
|
||||
|
||||
- name: prepare_release
|
||||
image: ubuntu:xenial
|
||||
pull: always
|
||||
commands:
|
||||
- cp -v build/whyblocked-${DRONE_TAG}_x86_64.tar.gz .
|
||||
- cp -v build/whyblocked-${DRONE_TAG}_x86_64.tar.gz.sig .
|
||||
- cp -v build/whyblocked_${DRONE_TAG}-0_amd64.deb .
|
||||
- cp -v build/whyblocked_${DRONE_TAG}-0_amd64.deb.sig .
|
||||
- cp -v build/whyblocked-${DRONE_TAG}-0.x86_64.rpm .
|
||||
- cp -v build/whyblocked-${DRONE_TAG}-0.x86_64.rpm.sig .
|
||||
|
||||
- name: release
|
||||
image: plugins/gitea-release
|
||||
pull: always
|
||||
settings:
|
||||
base_url: https://schlomp.space
|
||||
secrets: [ gitea_token ]
|
||||
api_key:
|
||||
from_secret: gitea_token
|
||||
title: ${DRONE_TAG}
|
||||
prerelease: true
|
||||
files:
|
||||
|
@ -190,11 +231,15 @@ pipeline:
|
|||
- sha256
|
||||
- sha512
|
||||
|
||||
notify:
|
||||
image: drillster/drone-email
|
||||
pull: true
|
||||
- name: notify
|
||||
image: drillster/drone-email
|
||||
pull: always
|
||||
settings:
|
||||
host: cryptoparty-celle.de
|
||||
secrets: [ email_username, email_password ]
|
||||
username:
|
||||
from_secret: email_username
|
||||
password:
|
||||
from_secret: email_password
|
||||
from: drone@tzend.de
|
||||
when:
|
||||
status: [ changed, failure ]
|
||||
when:
|
||||
status: [ changed, failure ]
|
||||
|
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
[submodule "xdgcfg"]
|
||||
path = xdgcfg
|
||||
url = https://schlomp.space/tastytea/xdgcfg.git
|
|
@ -1,6 +1,6 @@
|
|||
cmake_minimum_required (VERSION 3.6)
|
||||
cmake_minimum_required (VERSION 3.2)
|
||||
project (whyblocked
|
||||
VERSION 0.11.1
|
||||
VERSION 0.15.0
|
||||
LANGUAGES CXX
|
||||
)
|
||||
|
||||
|
@ -10,18 +10,18 @@ pkg_check_modules(LIBXDG_BASEDIR REQUIRED libxdg-basedir)
|
|||
# sqlite3 is not a direct dependency, but vsqlite++ has no cmake- or pkg-config
|
||||
# module. Since it installs in the same directories as sqlite3, I am adding the
|
||||
# module here to add the include- and link directories below. It is not REQUIRED
|
||||
# because the sqlite3 in Debian jessie doesn't come with an pkg-config module.
|
||||
# because the sqlite3 in Debian jessie doesn't come with a pkg-config module.
|
||||
pkg_check_modules(SQLITE3 sqlite3)
|
||||
find_package(Qt5Core CONFIG REQUIRED)
|
||||
if(NOT WITHOUT_GUI)
|
||||
find_package(Qt5Widgets CONFIG REQUIRED)
|
||||
endif()
|
||||
find_package(Qt5Widgets CONFIG REQUIRED)
|
||||
pkg_check_modules(LIBCONFIG REQUIRED libconfig++)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -g -Og")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG
|
||||
"${CMAKE_CXX_FLAGS_DEBUG} -Wpedantic -Wall -Wextra -g -Og -fno-omit-frame-pointer")
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
|
@ -29,9 +29,11 @@ set(CMAKE_AUTOUIC ON)
|
|||
include_directories(${PROJECT_BINARY_DIR})
|
||||
include_directories(${LIBXDG_BASEDIR_INCLUDE_DIRS})
|
||||
include_directories(${SQLITE3_INCLUDE_DIRS})
|
||||
include_directories(${LIBCONFIG_INCLUDE_DIRS})
|
||||
|
||||
link_directories(${LIBXDG_BASEDIR_LIBRARY_DIRS})
|
||||
link_directories(${SQLITE3_LIBRARY_DIRS})
|
||||
link_directories(${LIBCONFIG_LIBRARY_DIRS})
|
||||
|
||||
# Write version in header
|
||||
configure_file (
|
||||
|
@ -39,27 +41,46 @@ configure_file (
|
|||
"${PROJECT_BINARY_DIR}/version.hpp"
|
||||
)
|
||||
|
||||
set(COMMON_LIBRARIES
|
||||
${LIBXDG_BASEDIR_LIBRARIES} vsqlitepp stdc++fs)
|
||||
add_executable(${CMAKE_PROJECT_NAME}
|
||||
src/qt/main.cpp src/qt/mainwindow.cpp src/qt/dialog_add.cpp
|
||||
src/whyblocked.cpp src/xdgcfg.cpp)
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME}
|
||||
${LIBXDG_BASEDIR_LIBRARIES} vsqlitepp Qt5::Widgets
|
||||
${LIBCONFIG_LIBRARIES} stdc++fs)
|
||||
set(WITH_MAN "YES" CACHE STRING "WITH_MAN defaults to \"YES\"")
|
||||
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
|
||||
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_PROJECT_NAME} whyblocked-gui)
|
||||
|
||||
add_executable(whyblocked src/interface_text.cpp src/whyblocked.cpp)
|
||||
target_link_libraries(whyblocked ${COMMON_LIBRARIES} Qt5::Core)
|
||||
install(TARGETS whyblocked DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
if(NOT WITHOUT_GUI)
|
||||
add_executable(whyblocked-gui src/interface_qt.cpp src/whyblocked.cpp)
|
||||
target_link_libraries(whyblocked-gui ${COMMON_LIBRARIES} Qt5::Widgets)
|
||||
|
||||
install(TARGETS whyblocked-gui DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
install(FILES de.tastytea.Whyblocked.desktop DESTINATION
|
||||
${CMAKE_INSTALL_DATAROOTDIR}/applications)
|
||||
install(FILES de.tastytea.Whyblocked.appdata.xml DESTINATION
|
||||
${CMAKE_INSTALL_DATAROOTDIR}/metainfo)
|
||||
install(FILES de.tastytea.Whyblocked.svg DESTINATION
|
||||
${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps)
|
||||
if(WITH_MAN)
|
||||
add_custom_command(
|
||||
OUTPUT "${PROJECT_BINARY_DIR}/whyblocked.1"
|
||||
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
|
||||
DEPENDS "${CMAKE_SOURCE_DIR}/whyblocked.1.adoc"
|
||||
COMMAND ${CMAKE_SOURCE_DIR}/build_manpage.sh
|
||||
ARGS ${PROJECT_VERSION})
|
||||
add_custom_target(run ALL
|
||||
DEPENDS "${PROJECT_BINARY_DIR}/whyblocked.1"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT WITHOUT_TRANSLATIONS)
|
||||
install(TARGETS ${CMAKE_PROJECT_NAME}
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
install(FILES "${PROJECT_BINARY_DIR}/whyblocked-gui"
|
||||
DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
install(FILES de.tastytea.Whyblocked.desktop
|
||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications)
|
||||
install(FILES de.tastytea.Whyblocked.appdata.xml
|
||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/metainfo)
|
||||
install(FILES de.tastytea.Whyblocked.svg
|
||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps)
|
||||
if(WITH_MAN)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/whyblocked.1
|
||||
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
|
||||
endif()
|
||||
|
||||
set(WITH_TRANSLATIONS "YES" CACHE STRING "WITH_TRANSLATIONS defaults to \"YES\"")
|
||||
if(WITH_TRANSLATIONS)
|
||||
add_subdirectory(translations)
|
||||
endif()
|
||||
|
||||
|
|
50
README.md
50
README.md
|
@ -1,14 +1,13 @@
|
|||
**Whyblocked** allows you to store the reason why you blocked someone, along with
|
||||
"receipts", URLs to the posts that led you to block them.
|
||||
**Whyblocked** allows you to store the reason why you blocked someone, along
|
||||
with “receipts”, URLs to the posts that led you to block them.
|
||||
|
||||
It has a text- and a Qt-interface and uses an SQLite-database.
|
||||
It has a Qt-interface and uses an SQLite-database.
|
||||
|
||||
![Screenshot Qt interface](https://doc.schlomp.space/whyblocked/whyblocked_screenshot.png)
|
||||
![Screenshot](https://doc.schlomp.space/whyblocked/whyblocked_screenshot.png)
|
||||
|
||||
## Usage
|
||||
|
||||
For the text interface start `whyblocked`, for the Qt interface
|
||||
`whyblocked-gui`. You can also start it from the menu of your desktop
|
||||
Run `whyblocked`. You can also start it from the menu of your desktop
|
||||
environment.
|
||||
|
||||
## Install
|
||||
|
@ -16,11 +15,14 @@ environment.
|
|||
### Packages
|
||||
|
||||
Every [release](https://schlomp.space/tastytea/whyblocked/releases) includes
|
||||
a .deb-package, an .rpm-package, a .tar.gz-package and an AppImage with
|
||||
precompiled binaries for x86_64(amd64). These are automatically built and not
|
||||
tested. You can install them with `dpkg -i` or `rpm -i`, respectively. The packages are signed with the PGP key
|
||||
[242E5AC4DA587BF9](https://tastytea.de/tastytea_autosign.asc) (Fingerprint:
|
||||
`F730 1ADF C9ED 2624 48C4 2B64 242E 5AC4 DA58 7BF9`).
|
||||
a .deb-package, an .rpm-package and a .tar.gz-package with precompiled binaries
|
||||
for x86_64(amd64)
|
||||
([more info](https://schlomp.space/tastytea/whyblocked/wiki/Binary-Packages)).
|
||||
These are automatically built and not tested. You can install them with
|
||||
`apt install ./whyblocked*.deb` or `yum install ./whyblocked*.rpm`,
|
||||
respectively. The packages are signed with the PGP key
|
||||
[242E5AC4DA587BF9](https://tastytea.de/tastytea_autosign.asc)
|
||||
(Fingerprint: `F730 1ADF C9ED 2624 48C4 2B64 242E 5AC4 DA58 7BF9`).
|
||||
|
||||
Gentoo ebuilds are available via my
|
||||
[repository](https://schlomp.space/tastytea/overlay).
|
||||
|
@ -29,15 +31,17 @@ Gentoo ebuilds are available via my
|
|||
|
||||
#### Dependencies
|
||||
|
||||
* C++ compiler (tested: [gcc](https://gcc.gnu.org/) 6/7/8,
|
||||
[clang](https://llvm.org/) 3/5/6)
|
||||
* [cmake](https://cmake.org/) (at least 3.6)
|
||||
* [vsqlite++](http://vsqlite.virtuosic-bytes.com/) (tested: 0.3.13)
|
||||
* C++ compiler (tested: [gcc](https://gcc.gnu.org/) 6/8/9,
|
||||
[clang](https://llvm.org/) 3/6)
|
||||
* [cmake](https://cmake.org/) (at least 3.2)
|
||||
* [vsqlite++](http://vsqlite.virtuosic-bytes.com/) (tested: 0.3)
|
||||
* [libxdg-basedir](http://repo.or.cz/w/libxdg-basedir.git) (tested: 1.2)
|
||||
* [qtcore](https://www.qt.io/) (tested: 5.11/5.7)
|
||||
* [qtcore](https://www.qt.io/) (tested: 5.12/5.5)
|
||||
* [qtwidgets](https://www.qt.io/) (tested: 5.12/5.5)
|
||||
* [libconfig++](https://github.com/hyperrealm/libconfig) (tested: 1.5)
|
||||
* Optional
|
||||
* [qtwidgets](https://www.qt.io/) (tested: 5.11/5.7)
|
||||
* [lupdate & lrelease](http://doc.qt.io/qt-5/linguist-manager.html) (tested: 5.11/5.7)
|
||||
* Translations: [lupdate & lrelease](http://doc.qt.io/qt-5/linguist-manager.html) (tested: 5.12/5.5)
|
||||
* Manpage: [asciidoc](http://asciidoc.org/) (tested: 8.6)
|
||||
|
||||
#### Get sourcecode
|
||||
|
||||
|
@ -46,7 +50,7 @@ Download the current
|
|||
|
||||
#### Compile
|
||||
|
||||
```SH
|
||||
``` zsh
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
|
@ -56,8 +60,8 @@ make install
|
|||
|
||||
cmake options:
|
||||
* `-DCMAKE_BUILD_TYPE=Debug` for a debug build
|
||||
* `-DWITHOUT_GUI=YES` to not build GUI
|
||||
* `-DWITHOUT_TRANSLATIONS=YES` to not compile translations
|
||||
* `-DWITH_TRANSLATIONS=NO` to not compile translations
|
||||
* `-DWITH_MAN=NO` to not compile the manpage
|
||||
* One of:
|
||||
* `-DWITH_DEB=YES` if you want to be able to generate a deb-package
|
||||
* `-DWITH_RPM=YES` if you want to be able to generate an rpm-package
|
||||
|
@ -85,14 +89,14 @@ Please report them on the
|
|||
|
||||
## Licence & Copyright
|
||||
|
||||
```PLAIN
|
||||
``` plain
|
||||
Copyright © 2018 tastytea <tastytea@tastytea.de>.
|
||||
License GPLv3: GNU GPL version 3 <https://www.gnu.org/licenses/gpl-3.0.html>.
|
||||
This program comes with ABSOLUTELY NO WARRANTY. This is free software,
|
||||
and you are welcome to redistribute it under certain conditions.
|
||||
```
|
||||
|
||||
The icon is derived from the icons `messagebox critical` and `help` of the
|
||||
The icon is derived from the icons *“messagebox critical”* and *“help”* of the
|
||||
[Gartoon icon theme](https://commons.wikimedia.org/wiki/Gartoon_icons). The
|
||||
original authors were Zeus, Patrick Yavitz and La Mula Francis, who released
|
||||
them under the terms of the
|
||||
|
|
10
build_manpage.sh
Executable file
10
build_manpage.sh
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ -n "${1}" ]; then
|
||||
dir="$(dirname ${0})"
|
||||
cp -vf ${dir}/whyblocked.1.adoc .
|
||||
sed -Ei "s/(Revision: +)[0-9]+\.[0-9]\.[0-9]/\1${1}/" whyblocked.1.adoc
|
||||
a2x --doctype manpage --format manpage --no-xmllint whyblocked.1.adoc
|
||||
else
|
||||
echo "usage: ${0} VERSION" >&2
|
||||
fi
|
|
@ -5,7 +5,7 @@ Name=Whyblocked
|
|||
Comment=Reminds you why you blocked someone
|
||||
Comment[de]=Erinnert dich, warum du jemanden blockiertest
|
||||
Icon=de.tastytea.Whyblocked
|
||||
Exec=whyblocked-gui
|
||||
Exec=whyblocked
|
||||
Terminal=false
|
||||
Categories=Utility;
|
||||
Keywords=blocklist;social-network;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# Packages
|
||||
set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR ${mastodon-cpp_VERSION_MAJOR})
|
||||
set(CPACK_PACKAGE_VERSION_MINOR ${mastodon-cpp_VERSION_MINOR})
|
||||
set(CPACK_PACKAGE_VERSION_PATCH ${mastodon-cpp_VERSION_PATCH})
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR ${${CMAKE_PROJECT_NAME}_VERSION_MAJOR})
|
||||
set(CPACK_PACKAGE_VERSION_MINOR ${${CMAKE_PROJECT_NAME}_VERSION_MINOR})
|
||||
set(CPACK_PACKAGE_VERSION_PATCH ${${CMAKE_PROJECT_NAME}_VERSION_PATCH})
|
||||
set(CPACK_PACKAGE_VERSION ${whyblocked_VERSION})
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Whyblocked reminds you why you blocked someone.")
|
||||
set(CPACK_PACKAGE_CONTACT "tastytea <tastytea@tastytea.de>")
|
||||
|
|
|
@ -1,337 +0,0 @@
|
|||
/* This file is part of whyblocked.
|
||||
* Copyright © 2018 tastytea <tastytea@tastytea.de>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <regex>
|
||||
#include <array>
|
||||
#include <QMessageBox>
|
||||
#include <QDebug>
|
||||
#include <QTranslator>
|
||||
#include <QLibraryInfo>
|
||||
#include <QtCore/qmimedata.h>
|
||||
#include "version.hpp"
|
||||
#include "whyblocked.hpp"
|
||||
#include "interface_qt.hpp"
|
||||
|
||||
MainWindow::MainWindow(QMainWindow *parent) : QMainWindow(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
_model = new QStandardItemModel;
|
||||
tableview->setModel(_model);
|
||||
populate_tableview();
|
||||
}
|
||||
|
||||
void MainWindow::populate_tableview()
|
||||
{
|
||||
_model->clear();
|
||||
_model->setHorizontalHeaderLabels(
|
||||
{
|
||||
tr("User/Instance"),
|
||||
tr("Blocked/Silenced"),
|
||||
tr("Reason")
|
||||
});
|
||||
tableview->horizontalHeader()->resizeSection(0, 250);
|
||||
|
||||
result_view result;
|
||||
if (database::view(result))
|
||||
{
|
||||
for (const std::tuple<string, int, string> &line : result)
|
||||
{
|
||||
add_row(QString::fromStdString(std::get<0>(line)),
|
||||
std::get<1>(line),
|
||||
QString::fromStdString(std::get<2>(line)));
|
||||
}
|
||||
}
|
||||
|
||||
statusBar()->showMessage(tr("Database loaded."));
|
||||
}
|
||||
|
||||
void MainWindow::add_row(const QString &user, const int &blocked,
|
||||
const QString &reason)
|
||||
{
|
||||
QList<QStandardItem*> items;
|
||||
items.append(new QStandardItem(user));
|
||||
if (blocked == 1)
|
||||
{
|
||||
items.append(new QStandardItem(QString(tr("blocked"))));
|
||||
}
|
||||
else
|
||||
{
|
||||
items.append(new QStandardItem(QString(tr("silenced"))));
|
||||
}
|
||||
items.append(new QStandardItem(reason));
|
||||
_model->appendRow(items);
|
||||
}
|
||||
|
||||
void MainWindow::add()
|
||||
{
|
||||
DialogAdd *dialog = new DialogAdd(this);
|
||||
dialog->show();
|
||||
}
|
||||
|
||||
void MainWindow::edit()
|
||||
{
|
||||
if (tableview->selectionModel()->selectedRows().count() != 1)
|
||||
{
|
||||
QMessageBox::warning(this, tr("Invalid selection"),
|
||||
tr("Please select only 1 entry to edit."));
|
||||
return;
|
||||
}
|
||||
|
||||
DialogAdd *dialog = new DialogAdd(this);
|
||||
dialog->setWindowTitle(tr("Edit entry"));
|
||||
|
||||
Dialogdata data;
|
||||
QModelIndex index = tableview->selectionModel()->selectedRows().first();
|
||||
data.user = index.sibling(index.row(), 0).data().toString().toStdString();
|
||||
result_details details;
|
||||
database::details(data.user, details);
|
||||
if (std::get<0>(details) == true)
|
||||
{
|
||||
data.blocked = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
data.blocked = 0;
|
||||
}
|
||||
data.reason = std::get<1>(details);
|
||||
data.receipts = std::get<2>(details);
|
||||
|
||||
dialog->set_data(data);
|
||||
dialog->setProperty("edit", true);
|
||||
dialog->show();
|
||||
}
|
||||
|
||||
void MainWindow::remove()
|
||||
{
|
||||
QItemSelectionModel *selection = tableview->selectionModel();
|
||||
if (selection->hasSelection())
|
||||
{
|
||||
for (auto &row : selection->selectedRows())
|
||||
{
|
||||
const string user = row.data().toString().toStdString();
|
||||
database::remove(user);
|
||||
statusBar()->showMessage(tr("Removed %1 from database.")
|
||||
.arg(QString::fromStdString(user)));
|
||||
_model->removeRow(row.row());
|
||||
}
|
||||
label_receipts->clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
statusBar()->showMessage(tr("Select data to remove."));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::about()
|
||||
{
|
||||
QMessageBox::about(this, tr("About Whyblocked"),
|
||||
tr("<p><b>Whyblocked</b> %1</p>"
|
||||
"<p>Reminds you why you blocked someone.</p>"
|
||||
"<p>Sourcecode: <a href=\"https://schlomp.space/tastytea/whyblocked\">"
|
||||
"https://schlomp.space/tastytea/whyblocked</a></p>"
|
||||
"<p><small>Copyright © 2018 <a href=\"mailto:tastytea@tastytea.de\">tastytea</a>.<br>"
|
||||
"Licence GPLv3: <a href=\"https://www.gnu.org/licenses/gpl-3.0.html\">"
|
||||
"GNU GPL version 3</a>.<br>"
|
||||
"This program comes with ABSOLUTELY NO WARRANTY. This is free software, "
|
||||
"and you are welcome to redistribute it under certain conditions.</small></p>")
|
||||
.arg(global::version));
|
||||
}
|
||||
|
||||
void MainWindow::show_details(QModelIndex index)
|
||||
{
|
||||
const string user = index.sibling(index.row(), 0).data()
|
||||
.toString().toStdString();
|
||||
result_details result;
|
||||
string text = "";
|
||||
|
||||
if (database::details(user, result))
|
||||
{
|
||||
if (!std::get<2>(result).empty())
|
||||
{
|
||||
text += string("<b>") + tr("Receipts:").toStdString() + "</b>";
|
||||
for (const string &url : std::get<2>(result))
|
||||
{
|
||||
text += "<br>" + url;
|
||||
}
|
||||
text = urls_to_hyperlinks(text);
|
||||
}
|
||||
label_receipts->setText(QString::fromStdString((text)));
|
||||
}
|
||||
}
|
||||
|
||||
const string MainWindow::urls_to_hyperlinks(const string &text)
|
||||
{
|
||||
std::regex re_url("((https?|gopher|ftps?)\\://[^ <]*)");
|
||||
return std::regex_replace(text, re_url, "<a href=\"$1\">$1</a>");
|
||||
}
|
||||
|
||||
void MainWindow::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
if (event->mimeData()->hasFormat("text/plain"))
|
||||
{
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::dropEvent(QDropEvent *event)
|
||||
{
|
||||
string text = event->mimeData()->text().toStdString();
|
||||
const std::array<const std::regex, 4> fediverse =
|
||||
{
|
||||
std::regex("https://([^/]+)/@([^/]+)"), // Mastodon
|
||||
std::regex("https://([^/]+)/profile/([^/]+)"), // Friendica
|
||||
std::regex("https://([^/]+)/users/([^/]+)"), // Pleroma
|
||||
std::regex("https://([^/]+)/([^/]+)") // Gnusocial
|
||||
};
|
||||
std::smatch match;
|
||||
|
||||
for (const std::regex &re : fediverse)
|
||||
{
|
||||
std::regex_match(text, match, re);
|
||||
const string instance = match[1];
|
||||
const string user = match[2];
|
||||
if (!instance.empty() && !user.empty())
|
||||
{
|
||||
text = '@' + user + '@' + instance;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
DialogAdd *dialog = new DialogAdd(this);
|
||||
Dialogdata data;
|
||||
data.user = text;
|
||||
dialog->set_data(data);
|
||||
dialog->show();
|
||||
}
|
||||
|
||||
DialogAdd::DialogAdd(QMainWindow *parent)
|
||||
: QDialog(parent)
|
||||
, _parent(static_cast<MainWindow*>(parent))
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
const Dialogdata DialogAdd::get_data() const
|
||||
{
|
||||
std::vector<string> receipts;
|
||||
for (int row = 0; row <= list_receipts->count() - 1; ++row)
|
||||
{
|
||||
receipts.push_back(list_receipts->item(row)->text().toStdString());
|
||||
}
|
||||
|
||||
Dialogdata data;
|
||||
data.user = text_user->text().toStdString();
|
||||
data.blocked = radio_blocked->isChecked();
|
||||
data.reason = text_reason->text().toStdString();
|
||||
data.receipts = receipts;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
const void DialogAdd::set_data(const Dialogdata &data)
|
||||
{
|
||||
text_user->setText(QString::fromStdString(data.user));
|
||||
radio_blocked->setChecked(data.blocked);
|
||||
radio_silcenced->setChecked(!data.blocked);
|
||||
text_reason->setText(QString::fromStdString(data.reason));
|
||||
for (const string &receipt : data.receipts)
|
||||
{
|
||||
QListWidgetItem *item =
|
||||
new QListWidgetItem(QString::fromStdString(receipt));
|
||||
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
||||
list_receipts->insertItem(list_receipts->count(), item);
|
||||
}
|
||||
}
|
||||
|
||||
void DialogAdd::add_receipt()
|
||||
{
|
||||
QListWidgetItem *item = new QListWidgetItem(tr("Insert receipt here."));
|
||||
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
||||
list_receipts->insertItem(list_receipts->count(), item);
|
||||
list_receipts->editItem(item);
|
||||
}
|
||||
|
||||
void DialogAdd::remove_receipt()
|
||||
{
|
||||
for (auto item :list_receipts->selectedItems())
|
||||
{
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
|
||||
void DialogAdd::accept()
|
||||
{
|
||||
if (property("edit").toBool())
|
||||
{
|
||||
_parent->remove();
|
||||
}
|
||||
Dialogdata data = get_data();
|
||||
|
||||
if (data.user.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
database::add_block(data.user, data.blocked, data.reason);
|
||||
_parent->add_row(QString::fromStdString(data.user),
|
||||
data.blocked,
|
||||
QString::fromStdString(data.reason));
|
||||
for (const string &receipt : data.receipts)
|
||||
{
|
||||
database::add_receipt(data.user, receipt);
|
||||
}
|
||||
|
||||
_parent->statusBar()->showMessage(tr("Added %1 to database.")
|
||||
.arg(QString::fromStdString(data.user)));
|
||||
|
||||
delete this;
|
||||
}
|
||||
|
||||
void DialogAdd::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
if (event->mimeData()->hasFormat("text/plain"))
|
||||
{
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
}
|
||||
|
||||
void DialogAdd::dropEvent(QDropEvent *event)
|
||||
{
|
||||
const QString text = event->mimeData()->text();
|
||||
QListWidgetItem *item = new QListWidgetItem(text);
|
||||
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
||||
list_receipts->insertItem(list_receipts->count(), item);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
QCoreApplication::setApplicationName("Whyblocked");
|
||||
|
||||
QTranslator qtTranslator;
|
||||
qtTranslator.load("qt_" + QLocale::system().name(),
|
||||
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||
app.installTranslator(&qtTranslator);
|
||||
QTranslator appTranslator;
|
||||
appTranslator.load("whyblocked_" + QLocale::system().name(),
|
||||
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||
app.installTranslator(&appTranslator);
|
||||
|
||||
MainWindow win;
|
||||
win.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
|
@ -1,322 +0,0 @@
|
|||
/* This file is part of whyblocked.
|
||||
* Copyright © 2018 tastytea <tastytea@tastytea.de>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <QCoreApplication>
|
||||
#include <QTranslator>
|
||||
#include <QLocale>
|
||||
#include <QLibraryInfo>
|
||||
#include "version.hpp"
|
||||
#include "whyblocked.hpp"
|
||||
#include "interface_text.hpp"
|
||||
|
||||
using std::cout;
|
||||
using std::cerr;
|
||||
using std::cin;
|
||||
|
||||
// Allow cout to output QStrings
|
||||
std::ostream &operator <<(std::ostream &stream, const QString &str)
|
||||
{
|
||||
stream << str.toStdString();
|
||||
return stream;
|
||||
}
|
||||
|
||||
const string Text::get_answer(const QString &question)
|
||||
{
|
||||
string answer;
|
||||
|
||||
cout << question << ": ";
|
||||
std::getline(cin, answer, '\n');
|
||||
|
||||
return answer;
|
||||
}
|
||||
|
||||
const bool Text::askblocked()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
const string blocked = get_answer(tr("Blocked or silenced?") +
|
||||
" [b/s]");
|
||||