parent
d00e769749
commit
efff69b7b2
51 changed files with 41 additions and 1586 deletions
@ -1,104 +0,0 @@ |
||||
sudo: required |
||||
dist: trusty |
||||
language: cpp |
||||
cache: ccache |
||||
|
||||
matrix: |
||||
include: |
||||
- os: osx |
||||
osx_image: xcode8.3 |
||||
|
||||
env: |
||||
- QT=qt58 |
||||
- QT=qt59 |
||||
|
||||
before_install: |
||||
- export QZ_VER=2.1.99 |
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then |
||||
export DISPLAY=:99.0; |
||||
sh -e /etc/init.d/xvfb start; |
||||
fi |
||||
|
||||
install: |
||||
- export QZ_DIR=$PWD |
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then |
||||
sudo apt-get -qq update; |
||||
sudo apt-get -qq install libssl-dev pkg-config libxcb-util0-dev; |
||||
if [[ "$QT" == "qt58" ]]; then |
||||
sudo apt-add-repository -y ppa:beineri/opt-qt58-trusty; |
||||
sudo apt-get update -qq; |
||||
sudo apt-get install -qq qt58tools qt58script qt58webengine qt58webchannel qt58declarative qt58x11extras; |
||||
elif [[ "$QT" == "qt59" ]]; then |
||||
sudo apt-add-repository -y ppa:beineri/opt-qt59-trusty; |
||||
sudo apt-get update -qq; |
||||
sudo apt-get install -qq qt59tools qt59script qt59webengine qt59webchannel qt59declarative qt59x11extras; |
||||
fi |
||||
fi |
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then |
||||
echo "Calling brew update..."; |
||||
brew update; |
||||
brew outdated openssl || brew upgrade openssl; |
||||
brew install ccache; |
||||
PATH="/usr/local/opt/ccache/libexec:$PATH"; |
||||
|
||||
if [[ "$QT" == "qt58" ]]; then |
||||
QT_VER=5.8; |
||||
if [ -z "$TRAVIS_TAG" ]; then |
||||
echo "Using Homebrew Qt..."; |
||||
brew install qt5; |
||||
export QTDIR=/usr/local/opt/qt5; |
||||
else |
||||
echo "Using official Qt installer..."; |
||||
QT_INSTALLER_FILE_NAME=qt-opensource-mac-x64-clang-$QT_VER.0; |
||||
wget "http://download.qt.io/official_releases/qt/$QT_VER/$QT_VER.0/$QT_INSTALLER_FILE_NAME.dmg"; |
||||
hdiutil attach -noverify $QT_INSTALLER_FILE_NAME.dmg; |
||||
QT_INSTALLER=/Volumes/$QT_INSTALLER_FILE_NAME/$QT_INSTALLER_FILE_NAME.app/Contents/MacOS/$QT_INSTALLER_FILE_NAME; |
||||
echo "Silently installing Qt..."; |
||||
travis_wait $QT_INSTALLER --script $QZ_DIR/mac/qt-mac-silent-install.qs; |
||||
export QTDIR="$HOME/Qt/$QT_VER/clang_64"; |
||||
fi |
||||
fi |
||||
fi |
||||
|
||||
script: |
||||
- QMAKE="qmake" |
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then |
||||
CXXFLAGS="-Wextra -Werror"; |
||||
if [[ "$QT" == "qt58" ]]; then |
||||
QMAKE="/opt/qt58/bin/qmake"; |
||||
elif [[ "$QT" == "qt59" ]]; then |
||||
QMAKE="/opt/qt59/bin/qmake"; |
||||
fi |
||||
fi |
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then |
||||
MACDEPLOYQT="macdeployqt"; |
||||
CXXFLAGS="-Wextra -Werror -Wno-inconsistent-missing-override -Wno-deprecated-declarations"; |
||||
if [[ "$QT" == "qt58" ]]; then |
||||
MACDEPLOYQT=$QTDIR/bin/macdeployqt; |
||||
QMAKE=$QTDIR/bin/qmake; |
||||
fi |
||||
fi |
||||
- $QMAKE QMAKE_CXXFLAGS+="$CXXFLAGS" |
||||
- make -j2 CC=$CC CXX=$CXX || exit 1 |
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then |
||||
cp -v bin/libQupZilla*.dylib tests/autotests; |
||||
fi |
||||
- cd scripts && ./run_tests.sh $QMAKE |
||||
- ccache --show-stats |
||||
|
||||
before_deploy: |
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then |
||||
cd $QZ_DIR; |
||||
make bundle; |
||||
mv bin/QupZilla.dmg bin/QupZilla-${QZ_VER}.dmg; |
||||
fi |
||||
|
||||
deploy: |
||||
provider: releases |
||||
api_key: |
||||
secure: "bGGHyeMXF3nrFIaJCzA5zicH3TfdcMNY6+DT+84veBoCAsBMIjp+1t//mkEBnyAYZHKV/6XDhgztwinX1yEylvOeXxQXG5J0fYj96UzZmjBY+QmgDc31XgVeKKIbEi0Ab2bkgW3qHyQJ5ao/lZwSPCt1stOnjz0WuGgrjGWoAgEoHBXzRlsGzU2LrF/bXnmjyPL/qe7AaV0neE9mD+FmeQwiBPoP+/cQCyz5veOdjuzCy4I57HLCvNH4y28z1p6qotS+V1jGRj8PgMWWQP/VXVp9glTV0+gGkOLKL91SPKvLkS76f5bgn6K3+vdDASf+ZCNajIsh1YpwiabX4tQKwnCd80Ps9PR5dXcQVPMBRy1lFr6u2ps0ZTTfiBpI6vqyvLtyv2QbrfGZfT5bWtwdqpSRPJhp6b/ieHHduuRkZ0aU3JuTpLeoob+rLlkvYQmpvmDgyTx44/q+UOOetkoSCD276sMxYxsd3DJKyeG320UcQvwU+dR8uv9NDdv9wpUi13mfGqaRdcSXXgUQWpZlzCGvQYwLozcNnFfbtyrY9BlJsH7Sf97b3313qHO1lrz92z4IhagY1eQqyTwUrtdH8VeeWNx3INdnd7/u1bSdTSLerzMOG/xds96XW/kVbB1SO8bG9IEel7kC5oTiEQfWXAvFw54P6F3eRjDCZvXGaZA=" |
||||
file: $QZ_DIR/bin/QupZilla-$QZ_VER.dmg |
||||
skip_cleanup: true |
||||
on: |
||||
tags: true |
||||
condition: "$TRAVIS_OS_NAME = osx" |
||||
@ -1,67 +0,0 @@ |
||||
[main] |
||||
host = https://www.transifex.com |
||||
|
||||
[qupzilla.app] |
||||
file_filter = translations/<lang>.ts |
||||
source_lang = en |
||||
minimum_perc = 60 |
||||
|
||||
[qupzilla.accesskeysnavigation-plugin] |
||||
file_filter = src/plugins/AccessKeysNavigation/translations/<lang>.ts |
||||
source_lang = en |
||||
minimum_perc = 60 |
||||
|
||||
[qupzilla.autoscroll-plugin] |
||||
file_filter = src/plugins/AutoScroll/translations/<lang>.ts |
||||
source_lang = en |
||||
minimum_perc = 60 |
||||
|
||||
[qupzilla.gnomekeyringpasswords-plugin] |
||||
file_filter = src/plugins/GnomeKeyringPasswords/translations/<lang>.ts |
||||
source_lang = en |
||||
minimum_perc = 60 |
||||
|
||||
[qupzilla.greasemonkey-plugin] |
||||
file_filter = src/plugins/GreaseMonkey/translations/<lang>.ts |
||||
source_lang = en |
||||
minimum_perc = 60 |
||||
|
||||
[qupzilla.kwalletpasswords-plugin] |
||||
file_filter = src/plugins/KWalletPasswords/translations/<lang>.ts |
||||
source_lang = en |
||||
minimum_perc = 60 |
||||
|
||||
[qupzilla.mousegestures-plugin] |
||||
file_filter = src/plugins/MouseGestures/translations/<lang>.ts |
||||
source_lang = en |
||||
minimum_perc = 60 |
||||
|
||||
[qupzilla.pim-plugin] |
||||
file_filter = src/plugins/PIM/translations/<lang>.ts |
||||
source_lang = en |
||||
minimum_perc = 60 |
||||
|
||||
[qupzilla.statusbaricons-plugin] |
||||
file_filter = src/plugins/StatusBarIcons/translations/<lang>.ts |
||||
source_lang = en |
||||
minimum_perc = 60 |
||||
|
||||
[qupzilla.test-plugin] |
||||
file_filter = src/plugins/TestPlugin/translations/<lang>.ts |
||||
source_lang = en |
||||
minimum_perc = 60 |
||||
|
||||
[qupzilla.flashcookiemanager-plugin] |
||||
file_filter = src/plugins/FlashCookieManager/translations/<lang>.ts |
||||
source_lang = en |
||||
minimum_perc = 60 |
||||
|
||||
[qupzilla.tabmanager-plugin] |
||||
file_filter = src/plugins/TabManager/translations/<lang>.ts |
||||
source_lang = en |
||||
minimum_perc = 60 |
||||
|
||||
[qupzilla.imagefinder-plugin] |
||||
file_filter = src/plugins/ImageFinder/translations/<lang>.ts |
||||
source_lang = en |
||||
minimum_perc = 60 |
||||
@ -1,157 +0,0 @@ |
||||
version: 2.1.99.{build}-{branch} |
||||
shallow_clone: true |
||||
|
||||
cache: |
||||
- windows/dependencies |
||||
|
||||
build: |
||||
parallel: true |
||||
verbosity: detailed |
||||
|
||||
configuration: |
||||
- release |
||||
# - debug |
||||
|
||||
branches: |
||||
except: |
||||
- v1.4 |
||||
- v1.6 |
||||
- v1.8 |
||||
|
||||
environment: |
||||
global: |
||||
QZ_VER: 2.1.99 |
||||
VSVER: 14 |
||||
ARCH: x86 |
||||
QMAKESPEC: win32-msvc |
||||
MAKETOOL: jom |
||||
TOOLSDIR: C:\Qt\Tools\QtCreator |
||||
|
||||
matrix: |
||||
- QTDIR: C:\Qt\5.9\msvc2015 |
||||
- QTDIR: C:\Qt\5.8\msvc2015 |
||||
QMAKESPEC: win32-msvc2015 |
||||
- ARCH: x64 |
||||
QTDIR: C:\Qt\5.9\msvc2015_64 |
||||
- PORTABLE_BUILD: "true" |
||||
QTDIR: C:\Qt\5.9\msvc2015 |
||||
|
||||
install: |
||||
- set QZ_DIR=%CD% |
||||
- set CPU=32 |
||||
- IF /I "%ARCH%" == "x64" (set CPU=64) |
||||
- set OPENSSL_DIR="C:\OpenSSL-Win%CPU%" |
||||
- set ICU_DIR_NAME=icu4c-54_1-Win%CPU%-msvc10 |
||||
- set ICU_DOWNLOAD_URL="http://download.icu-project.org/files/icu4c/54.1/%ICU_DIR_NAME%.zip" |
||||
- call "C:\Program Files (x86)\Microsoft Visual Studio "%VSVER%".0\VC\vcvarsall.bat" %ARCH% |
||||
- set PATH=%QTDIR%\bin;%TOOLSDIR%\bin;%OPENSSL_DIR%\bin;%CD%\bin;%PATH% |
||||
|
||||
build_script: |
||||
- echo "QupZilla BUILD %APPVEYOR_BUILD_VERSION%_%QMAKESPEC%_%CONFIGURATION%_%ARCH%" |
||||
- qmake -v |
||||
- qmake CONFIG+=%CONFIGURATION% INCLUDEPATH+="%OPENSSL_DIR%\include" LIBS+=-L%OPENSSL_DIR%\lib QupZilla.pro |
||||
- call %MAKETOOL% |
||||
|
||||
test_script: |
||||
- cd %QZ_DIR%\tests\autotests |
||||
- qmake CONFIG+=%CONFIGURATION% INCLUDEPATH+="%OPENSSL_DIR%\include" LIBS+=-L%OPENSSL_DIR%\lib |
||||
- call %MAKETOOL% |
||||
- call %CONFIGURATION%\autotests.exe |
||||
|
||||
after_build: |
||||
# prepare dependencies |
||||
- echo [Paths] > %QZ_DIR%\bin\qt.conf && echo Plugins="." >> %QZ_DIR%\bin\qt.conf |
||||
- copy %QZ_DIR%\COPYRIGHT %QZ_DIR%\bin\COPYRIGHT.txt |
||||
- cd %QZ_DIR%\windows |
||||
- IF NOT EXIST "dependencies" ( mkdir dependencies ) |
||||
- cd dependencies |
||||
- IF NOT EXIST "%ICU_DIR_NAME%.zip" ( appveyor DownloadFile %ICU_DOWNLOAD_URL% ) else ( echo "Use cached %ICU_DIR_NAME%.zip") |
||||
# see: https://github.com/appveyor/ci/issues/1347 |
||||
- ps: If (![System.IO.File]::Exists("$env:APPVEYOR_BUILD_FOLDER\windows\dependencies\KillProcDll&FindProcDll.zip")) { (New-Object Net.WebClient).DownloadFile("http://nsis.sourceforge.net/mediawiki/images/5/53/KillProcDll%26FindProcDll.zip", "$env:APPVEYOR_BUILD_FOLDER\windows\dependencies\KillProcDll&FindProcDll.zip") } ELse { echo "Use cached KillProcDll&FindProcDll.zip" } |
||||
- IF NOT EXIST "Registry.zip" ( |
||||
appveyor DownloadFile "http://nsis.sourceforge.net/mediawiki/images/4/47/Registry.zip" ) else (echo "Use cached Registry.zip") |
||||
- IF NOT EXIST "AppAssocReg-0.4.zip" ( |
||||
appveyor DownloadFile "http://nsis.sourceforge.net/mediawiki/images/d/d4/AppAssocReg-0.4.zip" ) else (echo "Use cached AppAssocReg-0.4.zip") |
||||
- IF NOT EXIST "StdUtils.2016-05-14.r2.zip" ( |
||||
appveyor DownloadFile "http://github.com/lordmulder/stdutils/releases/download/1.10/StdUtils.2016-05-14.r2.zip" ) else (echo "Use cached StdUtils.2016-05-14.r2.zip") |
||||
- IF NOT EXIST "master.tar.gz" ( |
||||
appveyor DownloadFile "http://chromium.googlesource.com/chromium/deps/hunspell_dictionaries/+archive/master.tar.gz" ) else (echo "Use cached master.tar.gz") |
||||
- mkdir ..\wininstall |
||||
- cd ..\wininstall |
||||
- copy ..\*.nsh .\ |
||||
- copy ..\*.ico .\ |
||||
- copy ..\*.bmp .\ |
||||
# prepare nsis plugins |
||||
- 7z x "..\dependencies\KillProcDll&FindProcDll.zip" |
||||
- 7z x ..\dependencies\Registry.zip |
||||
- 7z x ..\dependencies\AppAssocReg-0.4.zip |
||||
- 7z x ..\dependencies\StdUtils.2016-05-14.r2.zip |
||||
- copy Desktop\Plugin\*.dll .\ |
||||
- copy Plugins\Unicode\*.dll .\ |
||||
- copy Include\*.nsh %QZ_DIR%\windows |
||||
# prepare icu |
||||
- 7z x "..\dependencies\%ICU_DIR_NAME%.zip" |
||||
# prepare qtwebengine_dictionaries |
||||
- mkdir qtwebengine_dictionaries |
||||
- cd qtwebengine_dictionaries |
||||
- IF /I "%APPVEYOR_REPO_TAG%" == "true" ( |
||||
7z x "%QZ_DIR%\windows\dependencies\master.tar.gz" && |
||||
7z x "master.tar" && |
||||
mkdir "doc" && |
||||
move README* "doc\" && |
||||
move COPYING* "doc\" |
||||
) |
||||
- cd %QZ_DIR%\windows |
||||
# set paths |
||||
- set OPENSSL_BIN_DIR="%OPENSSL_DIR%\bin" |
||||
- set MSVC_REDIST_DIR="C:\Program Files (x86)\Microsoft Visual Studio "%VSVER%".0\VC\redist\%ARCH%\Microsoft.VC%VSVER%0.CRT" |
||||
- set ICU_BIN_DIR="%QZ_DIR%\windows\wininstall\icu\bin" |
||||
- IF /I "%ARCH%" == "x64" (set INSTALLER_VERSION="%QZ_VER% x64" && set ICU_BIN_DIR="%QZ_DIR%\windows\wininstall\icu\bin64") else (set INSTALLER_VERSION="%QZ_VER%") |
||||
- set QTWEBENGINE_DICTIONARIES_DIR="%QZ_DIR%\windows\wininstall\qtwebengine_dictionaries" |
||||
# make installer |
||||
- IF /I "%APPVEYOR_REPO_TAG%" == "true" ( |
||||
IF /I "%PORTABLE_BUILD%" == "true" ( |
||||
call "C:\Program Files (x86)\NSIS\makensis.exe" /X"Unicode true" /DCUSTOM=1 /DPORTABLE=1 /DVERSION="%QZ_VER% Portable" /DARCH=%ARCH% /DMSVC_VER=%VSVER%0 /DOPENSSL_BIN_DIR=%OPENSSL_BIN_DIR% /DMSVC_REDIST_DIR=%MSVC_REDIST_DIR% /DQZ_BIN_DIR=%QZ_DIR%\bin /DICU_BIN_DIR=%ICU_BIN_DIR% /DQT_DIR=%QTDIR% /DQT_BIN_DIR=%QTDIR%\bin /DQT_PLUGINS_DIR=%QTDIR%\plugins /DQTWEBENGINE_DICTIONARIES_DIR=%QTWEBENGINE_DICTIONARIES_DIR% installer.nsi |
||||
) else ( |
||||
call "C:\Program Files (x86)\NSIS\makensis.exe" /X"Unicode true" /DCUSTOM=1 /DVERSION=%INSTALLER_VERSION% /DARCH=%ARCH% /DMSVC_VER=%VSVER%0 /DOPENSSL_BIN_DIR=%OPENSSL_BIN_DIR% /DMSVC_REDIST_DIR=%MSVC_REDIST_DIR% /DQZ_BIN_DIR=%QZ_DIR%\bin /DICU_BIN_DIR=%ICU_BIN_DIR% /DQT_DIR=%QTDIR% /DQT_BIN_DIR=%QTDIR%\bin /DQT_PLUGINS_DIR=%QTDIR%\plugins /DQTWEBENGINE_DICTIONARIES_DIR=%QTWEBENGINE_DICTIONARIES_DIR% installer.nsi |
||||
) |
||||
) |
||||
|
||||
artifacts: |
||||
- path: windows\QupZilla*Installer*.exe |
||||
name: QupZilla Installer (%ARCH%) |
||||
- path: bin\*.exe |
||||
name: QupZilla Executable (%ARCH%) |
||||
- path: bin\*.dll |
||||
name: QupZilla DLL (%ARCH%) |
||||
|
||||
|
||||
deploy: |
||||
release: 'Version $(qz_ver)' |
||||
tag: $(appveyor_repo_tag_name) # don't remove or modify tag field |
||||
description: 'QupZilla $(qz_ver) Windows Installer Released' |
||||
provider: GitHub |
||||
auth_token: |
||||
secure: BumEo5ic9KIrhc8RxwsKFd/L6WwC0s5LpSef9uH+PtUKICZBZAcyqnPewKUqzEFi # your encrypted token from GitHub |
||||
artifact: /QupZilla.*Installer.*\.exe/ # QupZilla Installer |
||||
draft: false |
||||
prerelease: false |
||||
on: |
||||
appveyor_repo_tag: true # deploy on tag push only |
||||
|
||||
# notifications: |
||||
# - provider: Email |
||||
# to: |
||||
# - nowrep@gmail.com |
||||
# - s.r.alavizadeh@gmail.com |
||||
# on_build_success: false |
||||
# on_build_failure: false |
||||
# on_build_status_changed: true |
||||
|
||||
# # remote desktop connection on init |
||||
# init: |
||||
# - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) |
||||
|
||||
# # remote desktop connection on finish and block build to not destroy VM |
||||
# on_finish: |
||||
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) |
||||
@ -1,172 +0,0 @@ |
||||
resource app_signature "application/x-vnd.QupZilla"; |
||||
resource app_flags B_SINGLE_LAUNCH; |
||||
resource app_version { |
||||
major = 2, |
||||
middle = 1, |
||||
minor = 2, |
||||
|
||||
/* Application "variety" can be set to one of the following: |
||||
* B_APPV_DEVELOPMENT, |
||||
* B_APPV_ALPHA, |
||||
* B_APPV_BETA, |
||||
* B_APPV_GAMMA, |
||||
* B_APPV_GOLDEN_MASTER, |
||||
* B_APPV_FINAL |
||||
*/ |
||||
variety = B_APPV_DEVELOPMENT, |
||||
internal = 0, |
||||
|
||||
short_info = "QupZilla", |
||||
long_info = "QupZilla © 2010-2014 David Rosca" |
||||
}; |
||||
|
||||
resource file_types message { |
||||
"types" = "text/html", |
||||
"types" = "multipart/related", |
||||
"types" = "image/gif", |
||||
"types" = "image/jpeg", |
||||
"types" = "image/png", |
||||
"types" = "image/svg+xml", |
||||
"types" = "application/xhtml+xml", |
||||
"types" = "application/x-vnd.Be.URL.file", |
||||
"types" = "application/x-vnd.Be.URL.http", |
||||
"types" = "application/x-vnd.Be.URL.https" |
||||
}; |
||||
|
||||
resource vector_icon array { |
||||
$"6E6369660904008D040057020106033D8AFE000000000000BD8AFE48F10748A0" |
||||
$"7831B4E8F7C800EAFFFFFFFFFF020106033D0AFE000000000000BD0AFE48F107" |
||||
$"48A078509FA0A4DB677280FF6B6B6B020116043D950B0000000000003D950B49" |
||||
$"4FBC479BEC00FF4CF591D2FF9E0200020538B239BCCACB3F86163B6714C24359" |
||||
$"4A75A8000000FFFF3F0000FF2F750000FF72A00303946EF2030394FF05FF05FF" |
||||
$"020112023E9FFF0000000000003CC0004A70004B00009CFF0000FFFF1302043C" |
||||
$"26C2FF26B95026263C26B95026C2FF3C52B95052C2FF52523C52C2FF52B95002" |
||||
$"6EC5DCB8B6C713BAA0C4CAB706C110B579C307B5D5C0A2B565BFC2B55BC032B5" |
||||
$"5BBDBCB55BBA69B7BABBC5B63AB8F9B94FB89DBD9CB84FBB7EB8C7BE9AB924BF" |
||||
$"77B8E0BEE7B9DEC11FBCE0C332BB38C279BEC5C405C2D8C31AC0FBC3FCC2C6C2" |
||||
$"C1C22FC2B7C27AC2BEC22FC2B7C227C2B7C227C2B7C227C2B7C241C2BDC241C2" |
||||
$"BDC206C2B0C199C2DBC1D0C2CBC159C2EEC0D4C2DDC115C2E5C051C2CEBF43C3" |
||||
$"13BFB0C2B4BF3DC313BF36C313BF36C313BF36C313BF20C313BF20C313BF20C3" |
||||
$"13BDEDC313BE23C313BDB9C2EDBD57C2DFBD87C2E3BD54C2DCBD3EC2C3BD3EC2" |
||||
$"C3BD31C2B4BD13C2A5BD26C2ABBD13C2A5BCA4C27EBCA4C27EBCA4C27EBC31C2" |
||||
$"54BC31C254BC27C251BC12C24FBC1DC250BC10C24BBC0FC242BC11C246BC0FC2" |
||||
$"42BBF5C219BBF5C219BBD3C1DEBB68C195BBAEC1A4BB71C16EBB58C129BB63C1" |
||||
$"4EBB4BC101BB4BC0ADBB48C0D7BB4BC0ADBB4EC087BB4EC087BB52C054BB4DBF" |
||||
$"EEBB55C021BB9EBF93BBA9BEBFBBB0BF36BBA9BEBFBBA7BE93BBA7BE93BBA7BE" |
||||
$"53BBBCBE2FBBA8BE4BBBBCBE2FBBC7BE21BBC7BE21BC00BDD5BBE3BCFCBC5BBD" |
||||
$"3DBBE3BCFCBAB7BC58BAB7BC58BAB7BC58BA8BBC44BA90BC46BA8BBC44BA8BBC" |
||||
$"42BA8BBC42BA89BBEABA23BB79BA6ABBADBA23BB79BA12BB6BBA12BB6BBA12BB" |
||||
$"6BB9F8BB49B9F8BB49B9F8BB49B9AEBAF0B9AEBAF0B97EBAC3B928BAB1B950BA" |
||||
$"B5B924BAA9B91BBA9AB920BAA1B984BA6EB9DEB997B9B5B9F9B9F6B95DBA36B8" |
||||
$"F0BA0BB91FBA5EB8C4BA78B85EBA83B89EBACCB83DBB61B7E7BB18B813BB61B7" |
||||
$"E7BB6BB7E1BB6BB7E1BB6BB7E1BBFEB787BBFEB787BC65B74ABCB6B684BC94B6" |
||||
$"F6BCF5B68ABD58B665BD2DB67BBDA8B695BE6DB651BE29B697BE6FB650BE88B6" |
||||
$"4FBE7CB64FBE62B6A0BEE1B72FBE88B70EBEE4B733BEE9B73EBEE5B73ABED8B7" |
||||
$"44BEC6B74ABEC6B74ABEC6B74ABE75B7A5BE75B7A5BE63B7DDBE90B849BE74B8" |
||||
$"17BE91B84CBE92B852BE92B852BE94B85CBE9DB87ABE97B86BBE94B884BE8CB8" |
||||
$"8DBE8CB88DBE3AB8F0BD92B98FBDB7B906BD92B98FBD8DB9A1BD8DB9A1BD64B9" |
||||
$"D8BD7EBA55BD59BA19BD7BBA5CBD77BA63BD77BA63BD56BAA0BD4DBB2CBD39BA" |
||||
$"E6BD60BB70BDCCBBCEBD98BBA2BDFFBBFABE73BC3FBE33BC27BEBEBC5CBF5EBC" |
||||
$"42BF12BC56BF5EBC42BFAC37BFAC37BFD0BC1EC01CBC0FBFF5BC0BC046BC14C0" |
||||
$"83BC4EC066BC35C04DBCD9C0F4BDDAC0B6BD63C0F4BDDAC107BDF9C102BDF2C0" |
||||
$"BABE84C127BF91C0B2BF1DC127BF91C133BF9DC133BF9DC131C00FC1C5C0F9C1" |
||||
$"35C0D6C259C11CC348C059C2EEC0C9C348C059C36BC02FC36BC02FC36BC02FC3" |
||||
$"88C019C388C019C3A8C003C3DBBFC5C3C9BFE8C3EEBFA0C409BF52C3F0BF73C4" |
||||
$"09BF52C409BF53C409BF53C40DBF9AC495BFC1C450BFCEC4EBBFB3C542BF10C5" |
||||
$"1FBF56C542BF10C551BEF2C551BEF2C551BEF2C555BEEBC555BEEBC57FBEA3C5" |
||||
$"68BDFCC59EBE47C53ABDBBC4A3BDDFC4E1BDAAC4A3BDCAC4A3BDB5C4A3BDB5C4" |
||||
$"A3BDB5C4A5BD31C4A5BD31C4A8BD1EC4E8BCDFC4D2BCF5C4E8BCDFC4FEBCC9C4" |
||||
$"FEBCC9C4FEBCC9C516BCB3C516BCB3C545BC8BC582BC20C571BC5EC58CBC05C5" |
||||
$"88BBBCC586BBD9C588BBBCC587BBA8C587BBA8C587BBA8C588BB9DC588BB9DC5" |
||||
$"8DBB614EBAFAC584BB24C58ABADAC5C2BA5DC5B0BAA2C5C4BA62C5CBBA70C5CB" |
||||
$"BA70C5D9BA8EC60FBAD4C5EDBAB3C60ABB1FC648BBAAC627BB67C669BBEBC66F" |
||||
$"BC7BC670BC33C66FBC7BC672BCC4C672BCC4C674BCEAC66EBD37C678BD11C664" |
||||
$"BD5AC649BD9CC652BD79C633BDECC62CBE92C62DBE3FC621BED5C67FBF2CC648" |
||||
$"BF16C750BD0F0006BC12B6E4BC12B6E4BC32B6B0BC55B638BC47B674BB81B6AB" |
||||
$"BA2BB802BAC4B747BA88B7E3BB30B77EBADDB7B0BB59B765BBAAB733BB82B74D" |
||||
$"BBCBB71DBC12B6E4BBFCB707BC12B6E4001DBACDBFD1BACDBFD1BAEBBFAABB29" |
||||
$"BF5CBB13BF89BB43BF24BB34BE93BB34BED0BB34BE4DBB60BDEABB34BE25BB80" |
||||
$"BDBEBBABBD60BBA1BD98BB48BD2ABA81BCBEBAE5BCF3BA67BCB1BA20BC83BA2D" |
||||
$"BCA0BA0FBC5BBA0DBC02BA1FBC28B9FEBBE5B9BABBB6B9D0BBD0B99BBB91B95F" |
||||
$"BB44B983BB66B93DBB24B8F0BB2DB91CBB16B8C0BB48B8BEBADFB8C3BAFFB8B1" |
||||
$"BB14B89FBB7EB8A7BB49B8C9BB7EB8C5BBB2B8C3BB8AB8C6BBDBB8C9BC2EB8C7" |
||||
$"BC05B8D0BC40B8BABC49B8CBBC49B8B4BC4BB8AABC4EB8AFBC4DB8A0BC57B893" |
||||
$"BC4BB898BC56B882BC4AB88FBD10B88EBD00B893BD49B8E1BDE7B88DBE03B90D" |
||||
$"BE04B923BE75B906BE4BB946BEA8B985BF00B973BEC1B997BF3EB9A3BFC1B998" |
||||
$"BF81B9B0C011BA17C05FB9DBC02EBA25C0B3BA75C127BA3DC0E7BA8FC144BAC0" |
||||
$"C17FBAA9C160BAD8C19FBAFCC17CBAE4C19DBADDC13ABAD7C0A6BAD3C0EFBADB" |
||||
$"C061BACDBFD1BAEAC013BACDBFD10009BD5EB5D7BD5EB5D7BD81B5EEBDB1B60E" |
||||
$"BD84B605BDD0B613BE19B601BE01B61ABE55B5C3BEF6B5C4BEB0B5EFBF2DB5A2" |
||||
$"BFA3B55EBF5BB55EBFCEB55DC00CB58CBFE9B578C03CB5A7C090B566C064B575" |
||||
$"BF3AB541BCA7B60EBDDDB57ABCECB623BD5EB5D7BD29B601BD5EB5D70005BF35" |
||||
$"B6EABF35B6EABF55B6ECBF9AB6F5BF7BB702BFCEB6E0BF87B67DBF9CB693BF78" |
||||
$"B66DBF3CB664BF2FB623BF45B690BF35B6EABF6BB6CCBF35B6EA0004BA07B87F" |
||||
$"BA07B87FBA0CB868B9EFB850B9FEB85FB982B8E4B8F0BA35B92CB988B97E31BA" |
||||
$"07B87FB974B8F0BA07B87F0066C6F7BC24C6F7BC24C6DCBB0AC6002FC68BB9F2" |
||||
$"C5B9B87CC4FFB79CC563B805C4CEB768C463B709C49AB737C452B6FBC428B6EF" |
||||
$"C440B6E2C412B6FAC407B6C1C401B6D1C316B60FC0D0B56FC1F9B59AC0FBB58B" |
||||
$"C15FB59CC131B589C170B5A2C179B5C9C19FB5BDC12DB5E2C08AB5C9C0D7B5C4" |
||||
$"C05AB5CDC03FB60EC043B5DDC03DB629C040B676C036B65DC04BB694C0B6B65F" |
||||
$"C0A8B66FC0CDB643C0F1B61AC0B1B608C108B64BC0D0B6B1C13AB6D6C0B5B6A7" |
||||
$"C066B689C083B67CC064B68AC05DB6AFC05FB6ABC053B6C0C031B6D0C044B6CB" |
||||
$"BFE6B6E5BF94B741BFB0B6EFBF87B769BF5DB791BF88B781BF3BB79DBEF7B7B2" |
||||
$"BF17B7A4BECCB7C7BEFAB81CBEEAB7FFBF06B830BF19B86CBF03B860BF59B891" |
||||
$"BFBEB7E0BFA3B802BFE1B7B3C038B7ADC008B7BDC04FB7A6C084B777C06CB76E" |
||||
$"C0D3B795C0F8B83EC0EBB7F4C110B83FC135B810C100B802C10DB7E5C0ECB770" |
||||
$"43B7ABC125B795C15FB7FDC14DB7BDC170B83DC1C2B820C18EB860C1CFB813C1" |
||||
$"FDB7D5C1E2B7BDC214B7EAC1F1B838C215B82FC206B84BC23AB83DC222B843C2" |
||||
$"5AB834C28BB842C26CB836C2AFB850C2FAB857C2D5B854C320B859C347B898C3" |
||||
$"35B87BC377B8E7C24AB8C5C259B8C6C228B8C3C1E2B8D0C202B8C2C1C9B8DAC1" |
||||
$"99B8F0C1B62FC179B8E5C13FB8B6C15BB8C8C118B89CC0C5B872C0EFB885C07F" |
||||
$"B853BFE3B84FC02FB83FBFBFB856BF7FB87CBF9CB866BF5CB897BF11B8A4BF35" |
||||
$"B87FBEDCB8DCBE6EB942BEB6B91FBE51B950BE19B976BE2EB95CBE04B990BDF6" |
||||
$"B9D1BE04B9B4BDE9B9EEBDE2BA1DBDCAB9FCBDF8BA3CBDEFBA76BDFEBA53BDD9" |
||||
$"BAA9BDC9BB27BD9FBAEFBDF235BE71BBBCBE3ABB94BEAFBBE9BF41BBD2BEFBBB" |
||||
$"E5BF83BBC1C009BB9CBFC5BBA1C05FBB96C0DDBC03C0A1BBCDC104BC26C0F5BC" |
||||
$"67C114BC34C0D3BC9FC103BD00C0E8BCC8C11FBD37C159BDA3C13CBD6DC166BD" |
||||
$"BAC182BDE8C177BDD0C18EBE04C16DBE2DC17BBE15C152BE5EC13FBECFC13FBE" |
||||
$"97C13FBF0EC185BF4CC15DBF24C1AABF71C1A4BFE3C1A8BFB3C1A0C025C1DBC0" |
||||
$"87C1B3C053C216C08AC289C06CC253C086C2CBC04DC319BFDEC2E8C00FC347BF" |
||||
$"B0C386BF66C378BFABC396BF13C3FEBEBFC3C2BEF2C435BE90C430BE0CC42EBE" |
||||
$"4DC432BDC0C433BD22C429BD6DC43CBCDEC4ABBC78C47EBCA7C4CDBC56C512BC" |
||||
$"03C505BC34C519BBE7C513BBA8C51336C513BB93C51135C51ABB71C4F8BB29C4" |
||||
$"7EBB2CC48ABB5DC476BB0EC48BBB01C477BB14C4A1BAEDC478BACDC48BBAD8C4" |
||||
$"42BAADC3F1BA66C418BA9AC3CCBA36C391B9CBC3AEBA00C389B9BEC36CB93BC3" |
||||
$"42B92EC39AB94AC3E2B9A3C3C4B981C419B9DFC46DBA6AC44ABA20C46EBA73C4" |
||||
$"96BA8AC48FBA85C4AFBA9CC4EABAA8C4CABAABC533BAA2C55ABA20C555BA61C5" |
||||
$"62B9C7C4E8B9AFC51DB9DAC4CAB997C49EB958C4B6B975C48FB946C474B90EC4" |
||||
$"66B92AC493B8F9C4BDB91DC49FB90BC4E0B932C52CB951C505B944C555B95EC5" |
||||
$"B4B96CC592B952C5C9B97CC5E7B9B8C5D9B9A2C5FEB9DCC627BA26C614BA00C6" |
||||
$"45BA61C694BA9FC64DBA89C667BAE8C6B6BB83C693BB3FC6DFBBD4C6E3BC7CC6" |
||||
$"E4BC23C6E2BCCEC6D0BD79C6F5BD2CC6A7BDCCC69FBE9AC69FBE3EC6A1BE95C6" |
||||
$"A5BE88C6A3BE8DC6A2BE8FC6A1BEC0C696BEBEC6B2BEC4C6D6BE02C6D2BE15C6" |
||||
$"F6BD65C6F7BC24C700BCC4C6F7BC240008C301B7D8C301B7D8C2E6B7DCC2D4B7" |
||||
$"A4C2E8B7AEC2B1B792C269B7B8C288B7A7C204B7EFC236B743C221B77BC239B7" |
||||
$"3AC285B744C27AB746C2A7B740C2F3B74FC2D8B731C30CB76BC33CB7A1C31FB7" |
||||
$"87C360B7C2C301B7D8C31CB7D4C301B7D80004BB53C203BB53C203BB45C20DBB" |
||||
$"26C221BB38C21DBB55C249BBBAC291BB87C26EBB92C265BB53C203BB84C227BB" |
||||
$"53C2030005C4F4BE2EC4F4BE2EC4D3BE57C48CBEA4C4A6BE76C46EBEDAC47DBF" |
||||
$"53C47DBF18C4B6BF38C4EDBEB9C4D0BEECC502BE93C4F4BE2EC531BE48C4F4BE" |
||||
$"2E0009C213C327C213C327C17FC390BFF7C345C09DC332BFD0C349BF8EC36ABF" |
||||
$"ACC350BF67C38CBF20C386BF56C386BEAFC386BDCDC386BE3EC386BEC1C3CBC0" |
||||
$"C0C3BABFC4C3DDC137C3AAC221C367C1AFC38EC22AC364C262C32BC280C337C2" |
||||
$"49C322C213C327C22AC331C213C32702044844C83744BDA844304F30C34E30C8" |
||||
$"25485ABDA85AC8375A604F60C82560C34E02044844C83744BDA844304F30C34E" |
||||
$"30C825485ABDA85AC8375A604F60C82560C34E00033129B6FBB62F382A432D38" |
||||
$"29C350B90A51374F34C7F0BE4900032F2BB61DB6E7352C4331BD1AB8554B3452" |
||||
$"3AC5A5BC67563D00032F2AB6132A362A452EBDF8B6F64C3153395236C82ABF7F" |
||||
$"00032F2AB61AB692362B4431BD92B8284B3453395137C935BED9000333293025" |
||||
$"BB8EB7E64032BBC9B87947355137C4F2BBF058380F0A01010C2020230A000100" |
||||
$"12403FFF000000000000403FFFC37FFDBDFFEA01178400040A020100024045D1" |
||||
$"0000000000004045D1C3D174BF45D10A05010C023F800000000000000040D174" |
||||
$"C57FFFCAABA20A07010E12405F24B29AD639906A408BA7C636B6419D45011781" |
||||
$"00040A07010F124015ED323FDBB24E2E402334C5F50747993901178100040A07" |
||||
$"0112124066B7000000000000401824C818EA49567301178100040A0701101239" |
||||
$"2225C032573F46E538E8064444BD4BFBDC01178100040A07011112B96A6E4008" |
||||
$"5EBF3FF2B8E00B4AF9633A4E3F01178100040A08010D023BAAAA000000000000" |
||||
$"3DA2E84655554551740A08010D023BAAAA0000000000003E0000480AAA48C000" |
||||
$"0A08010D023A55550000000000003C2E8B485555422E8B0A08010D023A555500" |
||||
$"00000000003C2E8B462AAA49A5D10A030101024089423E3FC6BE4B32407CA03E" |
||||
$"BCEEC81B9D0A040A0304050607080A0B02090240889B3E4A79BE57CC407A333F" |
||||
$"DD1AC822A9" |
||||
}; |
||||
@ -1,252 +0,0 @@ |
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser |
||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com> |
||||
* |
||||
* 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, 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 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 "fileschemehandler.h" |
||||
#include "qztools.h" |
||||
#include "iconprovider.h" |
||||
#include "downloadoptionsdialog.h" |
||||
#include "mainapplication.h" |
||||
#include "browserwindow.h" |
||||
|
||||
#include <QFileIconProvider> |
||||
#include <QFileDialog> |
||||
#include <QFileInfo> |
||||
#include <QDesktopServices> |
||||
#include <QTextStream> |
||||
#include <QDateTime> |
||||
#include <QTimer> |
||||
#include <QDir> |
||||
|
||||
FileSchemeHandler::FileSchemeHandler() |
||||
{ |
||||
} |
||||
|
||||
QNetworkReply* FileSchemeHandler::createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice* outgoingData) |
||||
{ |
||||
Q_UNUSED(outgoingData) |
||||
|
||||
if (op != QNetworkAccessManager::GetOperation) { |
||||
return 0; |
||||
} |
||||
|
||||
// Only list directories
|
||||
QString filePath = request.url().toLocalFile(); |
||||
QFileInfo fileInfo(filePath); |
||||
if (!fileInfo.isDir() || !fileInfo.isReadable() || !fileInfo.exists()) { |
||||
return 0; |
||||
} |
||||
#ifdef Q_OS_WIN |
||||
QNetworkRequest req = request; |
||||
|
||||
if (filePath.endsWith(QLatin1Char(':'))) { |
||||
filePath.append(QLatin1Char('/')); |
||||
req.setUrl(QUrl::fromLocalFile(filePath)); |
||||
} |
||||
else if (filePath.endsWith(QLatin1String(".lnk"))) { |
||||
req.setUrl(QUrl::fromLocalFile(fileInfo.canonicalFilePath())); |
||||
} |
||||
FileSchemeReply* reply = new FileSchemeReply(req); |
||||
#else |
||||
FileSchemeReply* reply = new FileSchemeReply(request); |
||||
#endif |
||||
return reply; |
||||
} |
||||
|
||||
void FileSchemeHandler::handleUrl(const QUrl &url) |
||||
{ |
||||
QFileIconProvider iconProvider; |
||||
QFile file(url.toLocalFile()); |
||||
QFileInfo info(file); |
||||
|
||||
if (!info.exists() || info.isDir() || !info.isReadable()) { |
||||
return; |
||||
} |
||||
|
||||
const QString fileName = info.fileName(); |
||||
const QPixmap pixmap = iconProvider.icon(info).pixmap(30); |
||||
const QString type = iconProvider.type(info); |
||||
|
||||
DownloadOptionsDialog dialog(fileName, pixmap, type, url, mApp->getWindow()); |
||||
dialog.showExternalManagerOption(false); |
||||
dialog.showFromLine(false); |
||||
|
||||
int status = dialog.exec(); |
||||
|
||||
if (status == 1) { |
||||
// Open
|
||||
QDesktopServices::openUrl(url); |
||||
} |
||||
else if (status == 2) { |
||||
// Save
|
||||
const QString savePath = QzTools::getSaveFileName("FileSchemeHandler-Save", mApp->getWindow(), |
||||
QObject::tr("Save file as..."), |
||||
QDir::homePath() + QDir::separator() + QzTools::getFileNameFromUrl(url)); |
||||
|
||||
if (!savePath.isEmpty()) { |
||||
file.copy(savePath); |
||||
} |
||||
} |
||||
} |
||||
|
||||
FileSchemeReply::FileSchemeReply(const QNetworkRequest &req, QObject* parent) |
||||
: QNetworkReply(parent) |
||||
{ |
||||
setOperation(QNetworkAccessManager::GetOperation); |
||||
setRequest(req); |
||||
setUrl(req.url()); |
||||
|
||||
m_buffer.open(QIODevice::ReadWrite); |
||||
setError(QNetworkReply::NoError, tr("No Error")); |
||||
open(QIODevice::ReadOnly); |
||||
|
||||
QTimer::singleShot(0, this, SLOT(loadPage())); |
||||
} |
||||
|
||||
qint64 FileSchemeReply::bytesAvailable() const |
||||
{ |
||||
return m_buffer.bytesAvailable() + QNetworkReply::bytesAvailable(); |
||||
} |
||||
|
||||
qint64 FileSchemeReply::readData(char* data, qint64 maxSize) |
||||
{ |
||||
return m_buffer.read(data, maxSize); |
||||
} |
||||
|
||||
void FileSchemeReply::loadPage() |
||||
{ |
||||
QTextStream stream(&m_buffer); |
||||
stream.setCodec("UTF-8"); |
||||
|
||||
stream << loadDirectory(); |
||||
|
||||
stream.flush(); |
||||
m_buffer.reset(); |
||||
|
||||
setHeader(QNetworkRequest::ContentTypeHeader, QByteArray("text/html")); |
||||
setHeader(QNetworkRequest::ContentLengthHeader, m_buffer.bytesAvailable()); |
||||
setAttribute(QNetworkRequest::HttpStatusCodeAttribute, 200); |
||||
setAttribute(QNetworkRequest::HttpReasonPhraseAttribute, QByteArray("Ok")); |
||||
emit metaDataChanged(); |
||||
emit downloadProgress(m_buffer.size(), m_buffer.size()); |
||||
|
||||
emit readyRead(); |
||||
emit finished(); |
||||
} |
||||
|
||||
QString FileSchemeReply::loadDirectory() |
||||
{ |
||||
const QDir dir = QDir(request().url().toLocalFile()); |
||||
const QFileInfoList list = dir.entryInfoList(QDir::AllEntries | QDir::Hidden, |
||||
QDir::Name | QDir::DirsFirst | QDir::IgnoreCase); |
||||
|
||||
static QString sPage; |
||||
|
||||
if (sPage.isEmpty()) { |
||||
sPage = QzTools::readAllFileContents(":/html/dirlist.html"); |
||||
sPage.replace(QLatin1String("%BOX-BORDER%"), QLatin1String("qrc:html/box-border.png")); |
||||
sPage.replace(QLatin1String("%UP-IMG%"), QzTools::pixmapToByteArray(IconProvider::standardIcon(QStyle::SP_FileDialogToParent).pixmap(22))); |
||||
sPage.replace(QLatin1String("%UP-DIR-TEXT%"), tr("Up to higher level directory")); |
||||
sPage.replace(QLatin1String("%SHOW-HIDDEN-TEXT%"), tr("Show hidden files")); |
||||
sPage.replace(QLatin1String("%NAME%"), tr("Name")); |
||||
sPage.replace(QLatin1String("%SIZE%"), tr("Size")); |
||||
sPage.replace(QLatin1String("%MODIFIED%"), tr("Last modified")); |
||||
sPage = QzTools::applyDirectionToPage(sPage); |
||||
} |
||||
|
||||
QString page = sPage; |
||||
QString title = request().url().toLocalFile(); |
||||
title.replace(QLatin1Char('/'), QDir::separator()); |
||||
page.replace(QLatin1String("%TITLE%"), tr("Index for %1").arg(title.toHtmlEscaped())); |
||||
page.replace(QLatin1String("%CLICKABLE-TITLE%"), tr("Index for %1").arg(clickableSections(title))); |
||||
|
||||
QString upDirDisplay = QLatin1String("none"); |
||||
QString showHiddenDisplay = QLatin1String("none"); |
||||
QString tBody; |
||||
|
||||
if (!dir.isRoot()) { |
||||
QDir upDir = dir; |
||||
upDir.cdUp(); |
||||
|
||||
upDirDisplay = QLatin1String("inline"); |
||||
page.replace(QLatin1String("%UP-DIR-LINK%"), QUrl::fromLocalFile(upDir.absolutePath()).toEncoded()); |
||||
} |
||||
|
||||
foreach (const QFileInfo &info, list) { |
||||
if (info.fileName() == QLatin1String(".") || info.fileName() == QLatin1String("..")) { |
||||
continue; |
||||
} |
||||
|
||||
QString line = QLatin1String("<tr"); |
||||
|
||||
if (info.isHidden()) { |
||||
showHiddenDisplay = "inline"; |
||||
line += " class=\"tr-hidden\""; |
||||
} |
||||
|
||||
line += QLatin1String("><td class=\"td-name\" style=\"background-image:url(data:image/png;base64,"); |
||||
line += QzTools::pixmapToByteArray(QFileIconProvider().icon(info).pixmap(16)); |
||||
line += QLatin1String(");\">"); |
||||
line += QLatin1String("<a href=\""); |
||||
line += QUrl::fromLocalFile(info.absoluteFilePath()).toEncoded(); |
||||
line += QLatin1String("\">"); |
||||
line += info.fileName().toHtmlEscaped(); |
||||
line += QLatin1String("</a></td><td class=\"td-size\">"); |
||||
line += info.isDir() ? QString() : QzTools::fileSizeToString(info.size()); |
||||
line += QLatin1String("</td><td>"); |
||||
line += info.lastModified().toString("dd.MM.yyyy"); |
||||
line += QLatin1String("</td><td>"); |
||||
line += info.lastModified().toString("hh:mm:ss"); |
||||
line += QLatin1String("</td></tr>\n"); |
||||
|
||||
tBody.append(line); |
||||
} |
||||
|
||||
if (tBody.isEmpty()) { |
||||
tBody = QString("<tr><td colspan='4'>%1</td></tr>").arg(tr("Folder is empty.")); |
||||
} |
||||
|
||||
page.replace(QLatin1String("%T-BODY%"), tBody); |
||||
page.replace(QLatin1String("%UP-DIR-DISPLAY%"), upDirDisplay); |
||||
page.replace(QLatin1String("%SHOW-HIDDEN-DISPLAY%"), showHiddenDisplay); |
||||
|
||||
return page; |
||||
} |
||||
|
||||
QString FileSchemeReply::clickableSections(const QString &path) |
||||
{ |
||||
QString title = path; |
||||
const QString dirSeparator = QDir::separator(); |
||||
QStringList sections = title.split(dirSeparator, QString::SkipEmptyParts); |
||||
if (sections.isEmpty()) { |
||||
return QString("<a href=\"%1\">%1</a>").arg(path); |
||||
} |
||||
|
||||
title.clear(); |
||||
#ifndef Q_OS_WIN |
||||
title = QString("<a href=\"%1\">%1</a>").arg(dirSeparator); |
||||
#endif |
||||
for (int i = 0; i < sections.size(); ++i) { |
||||
QStringList currentParentSections = sections.mid(0, i + 1); |
||||
QString localFile = currentParentSections.join(QLatin1String("/")); |
||||
#ifndef Q_OS_WIN |
||||
localFile.prepend(dirSeparator); |
||||
#endif |
||||
title += QString("<a href=\"%1\">%2</a>%3").arg(QUrl::fromLocalFile(localFile).toEncoded(), sections.at(i).toHtmlEscaped(), dirSeparator); |
||||
} |
||||
|
||||
return title; |
||||
} |
||||
@ -1,61 +0,0 @@ |
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser |
||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com> |
||||
* |
||||
* 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, 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 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/>.
|
||||
* ============================================================ */ |
||||
#ifndef FILESCHEMEHANDLER_H |
||||
#define FILESCHEMEHANDLER_H |
||||
|
||||
#include <QNetworkReply> |
||||
#include <QBuffer> |
||||
|
||||
#include "schemehandler.h" |
||||
#include "qzcommon.h" |
||||
|
||||
class QUPZILLA_EXPORT FileSchemeHandler : public SchemeHandler |
||||
{ |
||||
public: |
||||
explicit FileSchemeHandler(); |
||||
|
||||
QNetworkReply* createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice* outgoingData); |
||||
|
||||
static void handleUrl(const QUrl &url); |
||||
}; |
||||
|
||||
class QUPZILLA_EXPORT FileSchemeReply : public QNetworkReply |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
explicit FileSchemeReply(const QNetworkRequest &req, QObject* parent = 0); |
||||
|
||||
qint64 bytesAvailable() const; |
||||
|
||||
protected: |
||||
qint64 readData(char* data, qint64 maxSize); |
||||
void abort() { } |
||||
|
||||
private slots: |
||||
void loadPage(); |
||||
|
||||
private: |
||||
QString loadDirectory(); |
||||
QString clickableSections(const QString &path); |
||||
|
||||
QBuffer m_buffer; |
||||
QString m_pageName; |
||||
}; |
||||
|
||||
|
||||
#endif // FILESCHEMEHANDLER_H
|
||||
@ -1,277 +0,0 @@ |
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser |
||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com> |
||||
* |
||||
* 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, 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 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 "pagescreen.h" |
||||
#include "ui_pagescreen.h" |
||||
#include "tabbedwebview.h" |
||||
#include "webpage.h" |
||||
#include "qztools.h" |
||||
#include "browserwindow.h" |
||||
#include "settings.h" |
||||
|
||||
#if QTWEBENGINE_DISABLED |
||||
|
||||
#include <QFileDialog> |
||||
#include <QMessageBox> |
||||
#include <QWebEngineFrame> |
||||
#include <QLabel> |
||||
#include <QTimer> |
||||
#include <QMovie> |
||||
#include <QPushButton> |
||||
#include <QCloseEvent> |
||||
#include <QPrinter> |
||||
|
||||
#include <QtConcurrent/QtConcurrentRun> |
||||
|
||||
PageScreen::PageScreen(WebView* view, QWidget* parent) |
||||
: QDialog(parent) |
||||
, ui(new Ui::PageScreen) |
||||
, m_view(view) |
||||
, m_imageScaling(0) |
||||
{ |
||||
setAttribute(Qt::WA_DeleteOnClose); |
||||
|
||||
ui->setupUi(this); |
||||
|
||||
m_formats.append(QSL("PNG")); |
||||
m_formats.append(QSL("BMP")); |
||||
m_formats.append(QSL("JPG")); |
||||
m_formats.append(QSL("PPM")); |
||||
m_formats.append(QSL("TIFF")); |
||||
m_formats.append(QSL("PDF")); |
||||
|
||||
foreach (const QString &format, m_formats) { |
||||
ui->formats->addItem(tr("Save as %1").arg(format)); |
||||
} |
||||
|
||||
m_pageTitle = m_view->title(); |
||||
|
||||
Settings settings; |
||||
const QString name = QzTools::filterCharsFromFilename(m_pageTitle).replace(QLatin1Char(' '), QLatin1Char('_')); |
||||
const QString path = settings.value("FileDialogPaths/PageScreen-Location", QDir::homePath()).toString(); |
||||
ui->location->setText(QString("%1/%2.png").arg(path, name)); |
||||
|
||||
QMovie* mov = new QMovie(":html/loading.gif"); |
||||
ui->label->setMovie(mov); |
||||
mov->start(); |
||||
|
||||
connect(ui->changeLocation, SIGNAL(clicked()), this, SLOT(changeLocation())); |
||||
connect(ui->formats, SIGNAL(currentIndexChanged(int)), this, SLOT(formatChanged())); |
||||
connect(ui->buttonBox->button(QDialogButtonBox::Save), SIGNAL(clicked()), this, SLOT(dialogAccepted())); |
||||
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(close())); |
||||
|
||||
QTimer::singleShot(200, this, SLOT(createThumbnail())); |
||||
} |
||||
|
||||
void PageScreen::formatChanged() |
||||
{ |
||||
QString text = ui->location->text(); |
||||
int pos = text.lastIndexOf(QLatin1Char('.')); |
||||
|
||||
if (pos > -1) { |
||||
text = text.left(pos + 1) + m_formats.at(ui->formats->currentIndex()).toLower(); |
||||
} |
||||
else { |
||||
text.append(QLatin1Char('.') + m_formats.at(ui->formats->currentIndex()).toLower()); |
||||
} |
||||
|
||||
ui->location->setText(text); |
||||
} |
||||
|
||||
void PageScreen::changeLocation() |
||||
{ |
||||
const QString name = QzTools::filterCharsFromFilename(m_pageTitle).replace(QLatin1Char(' '), QLatin1Char('_')); |
||||
const QString suggestedPath = QString("%1/%2.%3").arg(QDir::homePath(), name, m_formats.at(ui->formats->currentIndex()).toLower()); |
||||
|
||||
const QString path = QzTools::getSaveFileName("PageScreen-Location", this, tr("Choose location..."), suggestedPath); |
||||
|
||||
if (!path.isEmpty()) { |
||||
ui->location->setText(path); |
||||
} |
||||
} |
||||
|
||||
void PageScreen::dialogAccepted() |
||||
{ |
||||
if (!ui->location->text().isEmpty()) { |
||||
if (QFile::exists(ui->location->text())) { |
||||
const QString text = tr("File '%1' already exists. Do you want to overwrite it?").arg(ui->location->text()); |
||||
QMessageBox::StandardButton button = QMessageBox::warning(this, tr("File already exists"), text, |
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::No); |
||||
|
||||
if (button != QMessageBox::Yes) { |
||||
return; |
||||
} |
||||
} |
||||
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor); |
||||
|
||||
const QString format = m_formats.at(ui->formats->currentIndex()); |
||||
if (format == QLatin1String("PDF")) { |
||||
saveAsDocument(format); |
||||
} |
||||
else { |
||||
saveAsImage(format); |
||||
} |
||||
|
||||
QApplication::restoreOverrideCursor(); |
||||
|
||||
close(); |
||||
} |
||||
} |
||||
|
||||
void PageScreen::saveAsImage(const QString &format) |
||||
{ |
||||
const QString suffix = QLatin1Char('.') + format.toLower(); |
||||
|
||||
QString pathWithoutSuffix = ui->location->text(); |
||||
if (pathWithoutSuffix.endsWith(suffix, Qt::CaseInsensitive)) { |
||||
pathWithoutSuffix = pathWithoutSuffix.mid(0, pathWithoutSuffix.length() - suffix.length()); |
||||
} |
||||
|
||||
if (m_pageImages.count() == 1) { |
||||
m_pageImages.first().save(pathWithoutSuffix + suffix, format.toUtf8()); |
||||
} |
||||
else { |
||||
int part = 1; |
||||
foreach (const QImage &image, m_pageImages) { |
||||
const QString fileName = pathWithoutSuffix + ".part" + QString::number(part); |
||||
image.save(fileName + suffix, format.toUtf8()); |
||||
part++; |
||||
} |
||||
} |
||||
} |
||||
|
||||
void PageScreen::saveAsDocument(const QString &format) |
||||
{ |
||||
const QString suffix = QLatin1Char('.') + format.toLower(); |
||||
|
||||
QString pathWithoutSuffix = ui->location->text(); |
||||
if (pathWithoutSuffix.endsWith(suffix, Qt::CaseInsensitive)) { |
||||
pathWithoutSuffix = pathWithoutSuffix.mid(0, pathWithoutSuffix.length() - suffix.length()); |
||||
} |
||||
|
||||
QPrinter printer; |
||||
printer.setCreator(BrowserWindow::tr("Falkon %1 (%2)").arg(Qz::VERSION, Qz::WWWADDRESS)); |
||||
printer.setOutputFileName(pathWithoutSuffix + suffix); |
||||
printer.setOutputFormat(QPrinter::PdfFormat); |
||||
printer.setPaperSize(m_pageImages.first().size(), QPrinter::DevicePixel); |
||||
printer.setPageMargins(0, 0, 0, 0, QPrinter::DevicePixel); |
||||
printer.setFullPage(true); |
||||
|
||||
QPainter painter; |
||||
painter.begin(&printer); |
||||
|
||||
for (int i = 0; i < m_pageImages.size(); ++i) { |
||||
const QImage image = m_pageImages.at(i); |
||||
painter.drawImage(0, 0, image); |
||||
|
||||
if (i != m_pageImages.size() - 1) { |
||||
printer.newPage(); |
||||
} |
||||
} |
||||
|
||||
painter.end(); |
||||
} |
||||
|
||||
void PageScreen::createThumbnail() |
||||
{ |
||||
QWebEnginePage* page = m_view->page(); |
||||
|
||||
const int heightLimit = 20000; |
||||
const QPoint originalScrollPosition = page->mainFrame()->scrollPosition(); |
||||
const QSize originalSize = page->viewportSize(); |
||||
const QSize frameSize = page->mainFrame()->contentsSize(); |
||||
const int verticalScrollbarSize = page->mainFrame()->scrollBarGeometry(Qt::Vertical).width(); |
||||
const int horizontalScrollbarSize = page->mainFrame()->scrollBarGeometry(Qt::Horizontal).height(); |
||||
|
||||
int yPosition = 0; |
||||
bool canScroll = frameSize.height() > heightLimit; |
||||
|
||||
// We will split rendering page into smaller parts to avoid infinite loops
|
||||
// or crashes.
|
||||
|
||||
do { |
||||
int remainingHeight = frameSize.height() - yPosition; |
||||
if (remainingHeight <= 0) { |
||||
break; |
||||
} |
||||
|
||||
QSize size(frameSize.width(), |
||||
remainingHeight > heightLimit ? heightLimit : remainingHeight); |
||||
page->setViewportSize(size); |
||||
page->mainFrame()->scroll(0, qMax(0, yPosition - horizontalScrollbarSize)); |
||||
|
||||
QImage image(page->viewportSize().width() - verticalScrollbarSize, |
||||
page->viewportSize().height() - horizontalScrollbarSize, |
||||
QImage::Format_ARGB32_Premultiplied); |
||||
QPainter painter(&image); |
||||
page->mainFrame()->render(&painter); |
||||
painter.end(); |
||||
|
||||
m_pageImages.append(image); |
||||
|
||||
canScroll = remainingHeight > heightLimit; |
||||
yPosition += size.height(); |
||||
} |
||||
while (canScroll); |
||||
|
||||
page->setViewportSize(originalSize); |
||||
page->mainFrame()->setScrollBarValue(Qt::Vertical, originalScrollPosition.y()); |
||||
page->mainFrame()->setScrollBarValue(Qt::Horizontal, originalScrollPosition.x()); |
||||
|
||||
m_imageScaling = new QFutureWatcher<QImage>(this); |
||||
m_imageScaling->setFuture(QtConcurrent::run(this, &PageScreen::scaleImage)); |
||||
connect(m_imageScaling, SIGNAL(finished()), SLOT(showImage())); |
||||
} |
||||
|
||||
QImage PageScreen::scaleImage() |
||||
{ |
||||
QVector<QImage> scaledImages; |
||||
int sumHeight = 0; |
||||
|
||||
foreach (const QImage &image, m_pageImages) { |
||||
QImage scaled = image.scaledToWidth(450, Qt::SmoothTransformation); |
||||
|
||||
scaledImages.append(scaled); |
||||
sumHeight += scaled.height(); |
||||
} |
||||
|
||||
QImage finalImage(QSize(450, sumHeight), QImage::Format_ARGB32_Premultiplied); |
||||
QPainter painter(&finalImage); |
||||
|
||||
int offset = 0; |
||||
foreach (const QImage &image, scaledImages) { |
||||
painter.drawImage(0, offset, image); |
||||
offset += image.height(); |
||||
} |
||||
|
||||
return finalImage; |
||||
} |
||||
|
||||
void PageScreen::showImage() |
||||
{ |
||||
delete ui->label->movie(); |
||||
|
||||
ui->label->setPixmap(QPixmap::fromImage(m_imageScaling->result())); |
||||
} |
||||
|
||||
PageScreen::~PageScreen() |
||||
{ |
||||
delete ui; |
||||
} |
||||
|
||||
#endif |
||||
@ -1,70 +0,0 @@ |
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser |
||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com> |
||||
* |
||||
* 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, 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 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/>.
|
||||
* ============================================================ */ |
||||
#ifndef PAGESCREEN_H |
||||
#define PAGESCREEN_H |
||||
|
||||
#include <QDialog> |
||||
#include <QFutureWatcher> |
||||
|
||||
#include "qzcommon.h" |
||||
|
||||
#if QTWEBENGINE_DISABLED |
||||
|
||||
namespace Ui |
||||
{ |
||||
class PageScreen; |
||||
} |
||||
|
||||
class WebView; |
||||
|
||||
class FALKON_EXPORT PageScreen : public QDialog |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit PageScreen(WebView* view, QWidget* parent); |
||||
~PageScreen(); |
||||
|
||||
QImage scaleImage(); |
||||
|
||||
private slots: |
||||
void createThumbnail(); |
||||
void showImage(); |
||||
|
||||
void formatChanged(); |
||||
void changeLocation(); |
||||
void dialogAccepted(); |
||||
|
||||
private: |
||||
void saveAsImage(const QString &format); |
||||
void saveAsDocument(const QString &format); |
||||
|
||||
void createPixmap(); |
||||
|
||||
Ui::PageScreen* ui; |
||||
WebView* m_view; |
||||
QString m_pageTitle; |
||||
|
||||
QFutureWatcher<QImage>* m_imageScaling; |
||||
QVector<QImage> m_pageImages; |
||||
QStringList m_formats; |
||||
}; |
||||
|
||||
#endif |
||||
|
||||
#endif // PAGESCREEN_H
|
||||
@ -1,289 +0,0 @@ |
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser |
||||
* Copyright (C) 2010-2014 Alexander Samilovskih <alexsamilovskih@gmail.com> |
||||
* David Rosca <nowrep@gmail.com> |
||||
* |
||||
* 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, 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 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 "browserwindow.h" |
||||
#include "tabpreview.h" |
||||
#include "qztools.h" |
||||
#include "webtab.h" |
||||
#include "mainapplication.h" |
||||
#include "proxystyle.h" |
||||
#include "tabbedwebview.h" |
||||
|
||||
#include <QLabel> |
||||
#include <QPaintEvent> |
||||
#include <QPalette> |
||||
#include <QStylePainter> |
||||
#include <QVBoxLayout> |
||||
#include <QStyleOptionFrame> |
||||
|
||||
TabPreview::TabPreview(BrowserWindow* window, QWidget* parent) |
||||
: QFrame(parent) |
||||
, m_window(window) |
||||
, m_previewIndex(-1) |
||||
, m_animationsEnabled(true) |
||||
, m_stepX(0) |
||||
, m_stepY(0) |
||||
, m_stepWidth(0) |
||||
, m_stepHeight(0) |
||||
{ |
||||
m_pixmapLabel = new QLabel(this); |
||||
m_pixmapLabel->setAlignment(Qt::AlignHCenter); |
||||
|
||||
m_title = new QLabel(this); |
||||
m_title->setAlignment(Qt::AlignHCenter); |
||||
m_title->setWordWrap(true); |
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout(this); |
||||
layout->addWidget(m_pixmapLabel); |
||||
layout->addWidget(m_title); |
||||
layout->setMargin(0); |
||||
layout->setAlignment(Qt::AlignCenter); |
||||
setLayout(layout); |
||||
|
||||
setBackgroundRole(QPalette::ToolTipBase); |
||||
setForegroundRole(QPalette::ToolTipText); |
||||
|
||||
setContentsMargins(5, 5, 5, 5); |
||||
setMaximumWidth(250); |
||||
setMaximumHeight(170); |
||||
|
||||
#ifdef ENABLE_OPACITY_EFFECT |
||||
setGraphicsEffect(&m_opacityEffect); |
||||
m_opacityEffect.setOpacity(0.0); |
||||
connect(&m_opacityTimeLine, SIGNAL(frameChanged(int)), this, SLOT(setOpacity(int))); |
||||
#endif |
||||
|
||||
m_animation.setDuration(400); |
||||
m_animation.setFrameRange(0, 100); |
||||
m_animation.setUpdateInterval(20); // 50 fps
|
||||
connect(&m_animation, SIGNAL(frameChanged(int)), this, SLOT(setAnimationFrame(int))); |
||||
} |
||||
|
||||
int TabPreview::previewIndex() |
||||
{ |
||||
return m_previewIndex; |
||||
} |
||||
|
||||
void TabPreview::setPreviewIndex(int index) |
||||
{ |
||||
m_previewIndex = index; |
||||
} |
||||
|
||||
void TabPreview::setWebTab(WebTab* webTab, bool noPixmap) |
||||
{ |
||||
if (webTab->isRestored() && !webTab->isLoading() && !noPixmap) { |
||||
m_title->setText(webTab->title()); |
||||
m_pixmapLabel->setPixmap(webTab->renderTabPreview()); |
||||
m_pixmapLabel->show(); |
||||
} |
||||
else { |
||||
m_title->setText(webTab->title()); |
||||
m_pixmapLabel->hide(); |
||||
} |
||||
} |
||||
|
||||
void TabPreview::setAnimationsEnabled(bool enabled) |
||||
{ |
||||
m_animationsEnabled = enabled; |
||||
} |
||||
|
||||
void TabPreview::hideAnimated() |
||||
{ |
||||
#ifdef ENABLE_OPACITY_EFFECT |
||||
if (m_opacityTimeLine.state() == QTimeLine::Running) { |
||||
m_opacityTimeLine.stop(); |
||||
} |
||||
|
||||
if (m_animationsEnabled) { |
||||
m_opacityTimeLine.setDuration(400); |
||||
m_opacityTimeLine.setStartFrame(m_opacityEffect.opacity() * 100); |
||||
m_opacityTimeLine.setEndFrame(0); |
||||
m_opacityTimeLine.start(); |
||||
|
||||
connect(&m_opacityTimeLine, SIGNAL(finished()), this, SLOT(hide())); |
||||
} |
||||
else |
||||
#endif |
||||
{ |
||||
QFrame::hide(); |
||||
} |
||||
} |
||||
|
||||
void TabPreview::hide() |
||||
{ |
||||
m_previewIndex = -1; |
||||
#ifdef ENABLE_OPACITY_EFFECT |
||||
disconnect(&m_opacityTimeLine, SIGNAL(finished()), this, SLOT(hide())); |
||||
#endif |
||||
|
||||
QFrame::hide(); |
||||
} |
||||
|
||||
void TabPreview::show() |
||||
{ |
||||
if (!isVisible() && m_animationsEnabled) { |
||||
showAnimated(); |
||||
} |
||||
|
||||
QFrame::show(); |
||||
} |
||||
|
||||
void TabPreview::showOnRect(const QRect &r) |
||||
{ |
||||
if (m_animation.state() == QTimeLine::Running) { |
||||
m_animation.stop(); |
||||
} |
||||
|
||||
m_startGeometry = geometry(); |
||||
bool wasVisible = isVisible(); |
||||
QRect finishingGeometry; |
||||
|
||||
resize(QSize(250, 170)); |
||||
QFrame::show(); |
||||
|
||||
if (m_pixmapLabel->isVisible()) { |
||||
m_title->setWordWrap(false); |
||||
m_title->setText(m_title->fontMetrics().elidedText(m_title->text(), Qt::ElideRight, 240)); |
||||
|
||||
QSize previewSize(250, 170); |
||||
finishingGeometry = QRect(calculatePosition(r, previewSize), previewSize); |
||||
} |
||||
else { |
||||
m_title->setWordWrap(true); |
||||
|
||||
QSize previewSize = sizeHint(); |
||||
previewSize.setWidth(qMin(previewSize.width() + 2 * 5, 240)); |
||||
previewSize.setHeight(qMin(previewSize.height() + 2 * 5, 130)); |
||||
|
||||
finishingGeometry = QRect(calculatePosition(r, previewSize), previewSize); |
||||
} |
||||
|
||||
#ifdef ENABLE_OPACITY_EFFECT |
||||
if (!m_animationsEnabled) { |
||||
m_opacityEffect.setOpacity(1.0); |
||||
#else |
||||
if (!m_animationsEnabled || !wasVisible) { |
||||
#endif |
||||
QFrame::setGeometry(finishingGeometry); |
||||
return; |
||||
} |
||||
else { |
||||
showAnimated(); |
||||
} |
||||
|
||||
if (!wasVisible) { |
||||
m_startGeometry = finishingGeometry; |
||||
} |
||||
|
||||
QFrame::setGeometry(m_startGeometry); |
||||
|
||||
calculateSteps(m_startGeometry, finishingGeometry); |
||||
m_animation.start(); |
||||
} |
||||
|
||||
#ifdef ENABLE_OPACITY_EFFECT |
||||
void TabPreview::setOpacity(int opacity) |
||||
{ |
||||
m_opacityEffect.setOpacity(opacity / 100.0); |
||||
} |
||||
#endif |
||||
|
||||
void TabPreview::setAnimationFrame(int frame) |
||||
{ |
||||
QRect g; |
||||
g.setX(m_startGeometry.x() + frame * m_stepX); |
||||
g.setY(m_startGeometry.y() + frame * m_stepY); |
||||
g.setWidth(m_startGeometry.width() + frame * m_stepWidth); |
||||
g.setHeight(m_startGeometry.height() + frame * m_stepHeight); |
||||
|
||||
setGeometry(g); |
||||
} |
||||
|
||||
void TabPreview::showAnimated() |
||||
{ |
||||
#ifdef ENABLE_OPACITY_EFFECT |
||||
disconnect(&m_opacityTimeLine, SIGNAL(finished()), this, SLOT(hide())); |
||||
|
||||
if (m_opacityTimeLine.state() == QTimeLine::Running) { |
||||
m_opacityTimeLine.stop(); |
||||
} |
||||
|
||||
m_opacityTimeLine.setDuration(400); |
||||
m_opacityTimeLine.setStartFrame(m_opacityEffect.opacity() * 100); |
||||
m_opacityTimeLine.setEndFrame(100); |
||||
m_opacityTimeLine.start(); |
||||
#endif |
||||
} |
||||
|
||||
void TabPreview::resizeEvent(QResizeEvent* ev) |
||||
{ |
||||
QFrame::resizeEvent(ev); |
||||
|
||||
// Oxygen is setting rounded corners only for top-level tooltips
|
||||
if (mApp->styleName() == QLatin1String("oxygen")) { |
||||
setMask(QzTools::roundedRect(rect(), 4)); |
||||
} |
||||
} |
||||
|
||||
void TabPreview::paintEvent(QPaintEvent* pe) |
||||
{ |
||||
QStylePainter painter(this); |
||||
QStyleOptionFrame opt; |
||||
opt.init(this); |
||||
|
||||
painter.setClipRegion(pe->region()); |
||||
painter.drawPrimitive(QStyle::PE_PanelTipLabel, opt); |
||||
painter.end(); |
||||
|
||||
QFrame::paintEvent(pe); |
||||
} |
||||
|
||||
void TabPreview::calculateSteps(const QRect &oldGeometry, const QRect &newGeometry) |
||||
{ |
||||
m_stepX = (newGeometry.x() - oldGeometry.x()) / 100.0; |
||||
m_stepY = (newGeometry.y() - oldGeometry.y()) / 100.0; |
||||
m_stepWidth = (newGeometry.width() - oldGeometry.width()) / 100.0; |
||||
m_stepHeight = (newGeometry.height() - oldGeometry.height()) / 100.0; |
||||
} |
||||
|
||||
QPoint TabPreview::calculatePosition(const QRect &tabRect, const QSize &previewSize) |
||||
{ |
||||
QPoint p; |
||||
p.setY(tabRect.y() + tabRect.height() + 1); |
||||
|
||||
// Map to center of tab
|
||||
if (tabRect.width() > previewSize.width()) { |
||||
int extraWidth = tabRect.width() - previewSize.width(); |
||||
p.setX(tabRect.x() + extraWidth / 2); |
||||
} |
||||
else { |
||||
int extraWidth = previewSize.width() - tabRect.width(); |
||||
p.setX(tabRect.x() - extraWidth / 2); |
||||
} |
||||
|
||||
// Ensure the whole preview is always shown
|
||||
if (p.x() < 0) { |
||||
p.setX(0); |
||||
} |
||||
if (p.x() + previewSize.width() > m_window->width()) { |
||||
int extraWidth = p.x() + previewSize.width() - m_window->width(); |
||||
p.setX(p.x() - extraWidth); |
||||
} |
||||
|
||||
return p; |
||||
} |
||||
@ -1,88 +0,0 @@ |
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser |
||||
* Copyright (C) 2010-2014 Alexander Samilovskih <alexsamilovskih@gmail.com> |
||||
* David Rosca <nowrep@gmail.com> |
||||
* |
||||
* 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, 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 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/>.
|
||||
* ============================================================ */ |
||||
#ifndef TABPREVIEW_H |
||||
#define TABPREVIEW_H |
||||
|
||||
#include <QFrame> |
||||
#include <QTimeLine> |
||||
|
||||
#ifdef ENABLE_OPACITY_EFFECT |
||||
#include <QGraphicsOpacityEffect> |
||||
#endif |
||||
|
||||
class BrowserWindow; |
||||
class WebTab; |
||||
class QLabel; |
||||
|
||||
class TabPreview : public QFrame |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
explicit TabPreview(BrowserWindow* window, QWidget* parent); |
||||
|
||||
void setWebTab(WebTab* webTab, bool noPixmap); |
||||
void showOnRect(const QRect &rect); |
||||
|
||||
int previewIndex(); |
||||
void setPreviewIndex(int index); |
||||
|
||||
void setAnimationsEnabled(bool enabled); |
||||
|
||||
public slots: |
||||
void hideAnimated(); |
||||
void hide(); |
||||
|
||||
void show(); |
||||
|
||||
private slots: |
||||
void setAnimationFrame(int frame); |
||||
#ifdef ENABLE_OPACITY_EFFECT |
||||
void setOpacity(int opacity); |
||||
#endif |
||||
|
||||
protected: |
||||
void resizeEvent(QResizeEvent* ev); |
||||
void paintEvent(QPaintEvent* pe); |
||||
|
||||
private: |
||||
void showAnimated(); |
||||
void calculateSteps(const QRect &oldGeometry, const QRect &newGeometry); |
||||
QPoint calculatePosition(const QRect &tabRect, const QSize &previewSize); |
||||
|
||||
BrowserWindow* m_window; |
||||
QLabel* m_pixmapLabel; |
||||
QLabel* m_title; |
||||
|
||||
int m_previewIndex; |
||||
bool m_animationsEnabled; |
||||
|
||||
#ifdef ENABLE_OPACITY_EFFECT |
||||
QTimeLine m_opacityTimeLine; |
||||
QGraphicsOpacityEffect m_opacityEffect; |
||||
#endif |
||||
|
||||
QTimeLine m_animation; |
||||
QRect m_startGeometry; |
||||
qreal m_stepX; |
||||
qreal m_stepY; |
||||
qreal m_stepWidth; |
||||
qreal m_stepHeight; |
||||
}; |
||||
|
||||
#endif // TABPREVIEW_H
|
||||
Loading…
Reference in new issue