forked from qt-creator/qt-creator
QtSupport: Remove screenshot cropper
Reduce maintenance by removing a feature that broke in 7.0, caused assertions. The absence of the cropper won't most likely be noticed, because the examples thumbnail size was increased quite a bit in the last Welcome Screen redesign. Instead of cropping, we now always scale the thumbnail to ListModel::defaultImageSize. As a benefit of this simplification, the thumbnail is now also High-DPI enabled. Fixes: QTCREATORBUG-27141 Change-Id: I57cafb000c3095dd387cd96814b6e946980b2aed Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -29,7 +29,6 @@ add_qtc_plugin(QtSupport
|
||||
qtversioninfo.ui
|
||||
qtversionmanager.cpp qtversionmanager.h qtversionmanager.ui
|
||||
qtversions.cpp qtversions.h
|
||||
screenshotcropper.cpp screenshotcropper.h
|
||||
showbuildlog.ui
|
||||
translationwizardpage.cpp translationwizardpage.h
|
||||
uicgenerator.cpp uicgenerator.h
|
||||
|
@@ -24,9 +24,9 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "exampleslistmodel.h"
|
||||
#include "screenshotcropper.h"
|
||||
|
||||
#include <QBuffer>
|
||||
#include <QApplication>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QImageReader>
|
||||
@@ -527,8 +527,13 @@ QPixmap ExamplesListModel::fetchPixmapAndUpdatePixmapCache(const QString &url) c
|
||||
imgBuffer.open(QIODevice::ReadOnly);
|
||||
QImageReader reader(&imgBuffer, QFileInfo(url).suffix().toLatin1());
|
||||
QImage img = reader.read();
|
||||
img = ScreenshotCropper::croppedImage(img, url, ListModel::defaultImageSize);
|
||||
pixmap = QPixmap::fromImage(img);
|
||||
img.convertTo(QImage::Format_RGB32);
|
||||
const int dpr = qApp->devicePixelRatio();
|
||||
// boundedTo -> don't scale thumbnails up
|
||||
const QSize scaledSize = ListModel::defaultImageSize.boundedTo(img.size()) * dpr;
|
||||
pixmap = QPixmap::fromImage(
|
||||
img.scaled(scaledSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||
pixmap.setDevicePixelRatio(dpr);
|
||||
}
|
||||
}
|
||||
QPixmapCache::insert(url, pixmap);
|
||||
|
@@ -26,7 +26,6 @@
|
||||
#include "gettingstartedwelcomepage.h"
|
||||
|
||||
#include "exampleslistmodel.h"
|
||||
#include "screenshotcropper.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
@@ -1,380 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<areas>
|
||||
<area image="2dpainting-example.png" x="270" y="90" width="118" height="92"/>
|
||||
<area image="activeqt-webbrowser-example.png" x="192" y="26" width="146" height="88"/>
|
||||
<area image="addressbook-example.png" x="4" y="50" width="138" height="111"/>
|
||||
<area image="addressbook-tutorial-part1-screenshot.png" x="9" y="25" width="112" height="93"/>
|
||||
<area image="affine-demo.png" x="412" y="34" width="156" height="115"/>
|
||||
<area image="analogclock-example.png" x="82" y="98" width="125" height="89"/>
|
||||
<area image="analogclock-window-example.png" x="0" y="0" width="100" height="100"/>
|
||||
<area image="animatedtiles-example.png" x="191" y="197" width="128" height="121"/>
|
||||
<area image="anomaly-demo.png" x="217" y="530" width="143" height="110"/>
|
||||
<area image="appchooser-example.png" x="189" y="214" width="119" height="117"/>
|
||||
<area image="application.png" x="4" y="9" width="145" height="117"/>
|
||||
<area image="arthurplugin-demo.png" x="136" y="168" width="132" height="110"/>
|
||||
<area image="audiodevices-example.png" x="36" y="119" width="173" height="101"/>
|
||||
<area image="audioinput-example.png" x="0" y="0" width="120" height="120"/>
|
||||
<area image="audiooutput-example.png" x="16" y="39" width="152" height="56"/>
|
||||
<area image="basicdrawing-example.png" x="155" y="190" width="160" height="133"/>
|
||||
<area image="basicgraphicslayouts-example.png" x="17" y="35" width="135" height="143"/>
|
||||
<area image="basiclayouts-example.png" x="8" y="44" width="173" height="97"/>
|
||||
<area image="basicsortfiltermodel-example.png" x="9" y="25" width="125" height="93"/>
|
||||
<area image="bearercloud-example.png" x="215" y="214" width="90" height="69"/>
|
||||
<area image="bearermonitor-example.png" x="273" y="105" width="122" height="85"/>
|
||||
<area image="behavior-example.png" x="0" y="0" width="64" height="64"/>
|
||||
<area image="blockingfortuneclient-example.png" x="0" y="0" width="100" height="100"/>
|
||||
<area image="blockingmaster-example.png" x="0" y="0" width="100" height="100"/>
|
||||
<area image="blockingslave-example.png" x="0" y="0" width="100" height="100"/>
|
||||
<area image="blur_example.png" x="103" y="45" width="55" height="65"/>
|
||||
<area image="blurpickereffect-example.png" x="49" y="220" width="67" height="61"/>
|
||||
<area image="books-demo.png" x="10" y="32" width="163" height="97"/>
|
||||
<area image="borderlayout-example.png" x="1" y="26" width="151" height="128"/>
|
||||
<area image="boxes-demo.png" x="248" y="109" width="93" height="105"/>
|
||||
<area image="broadcastreceiver-example.png" x="73" y="36" width="145" height="57"/>
|
||||
<area image="broadcastsender-example.png" x="99" y="34" width="130" height="64"/>
|
||||
<area image="browser-demo.png" x="84" y="31" width="138" height="108"/>
|
||||
<area image="btchat-example.png" x="283" y="194" width="123" height="100"/>
|
||||
<area image="btfiletransfer-example.png" x="0" y="0" width="100" height="100"/>
|
||||
<area image="btscanner-example.png" x="415" y="37" width="125" height="71"/>
|
||||
<area image="bttennis-example.png" x="306" y="54" width="124" height="94"/>
|
||||
<area image="cachedtable-example.png" x="12" y="33" width="140" height="107"/>
|
||||
<area image="calculator-example.png" x="205" y="27" width="126" height="122"/>
|
||||
<area image="calculatorbuilder-example.png" x="20" y="41" width="131" height="82"/>
|
||||
<area image="calculatorform-example.png" x="14" y="33" width="155" height="72"/>
|
||||
<area image="calendar-example.png" x="12" y="34" width="162" height="124"/>
|
||||
<area image="calendarwidgetexample.png" x="105" y="66" width="142" height="110"/>
|
||||
<area image="camera-example.png" x="473" y="48" width="121" height="118"/>
|
||||
<area image="capabilitiesexample.png" x="18" y="283" width="172" height="100"/>
|
||||
<area image="cenumerator-example.png" x="1" y="19" width="109" height="79"/>
|
||||
<area image="charactermap-example.png" x="13" y="56" width="171" height="108"/>
|
||||
<area image="chart-example.png" x="419" y="59" width="150" height="117"/>
|
||||
<area image="classwizard.png" x="24" y="111" width="152" height="126"/>
|
||||
<area image="checkboxexample.png" x="0" y="0" width="98" height="34"/>
|
||||
<area image="chip-demo.png" x="169" y="14" width="127" height="89"/>
|
||||
<area image="codecs-example.png" x="163" y="98" width="134" height="94"/>
|
||||
<area image="codeeditor-example.png" x="14" y="48" width="143" height="107"/>
|
||||
<area image="collidingmice-example.png" x="45" y="86" width="171" height="133"/>
|
||||
<area image="coloreditorfactoryimage.png" x="50" y="35" width="155" height="109"/>
|
||||
<area image="combowidgetmapper-example.png" x="38" y="168" width="131" height="89"/>
|
||||
<area image="completer-example.png" x="11" y="141" width="159" height="107"/>
|
||||
<area image="composition-demo.png" x="159" y="50" width="103" height="95"/>
|
||||
<area image="concentriccircles-example.png" x="306" y="321" width="50" height="43"/>
|
||||
<area image="configdialog-example.png" x="94" y="27" width="122" height="122"/>
|
||||
<area image="containerextension-example.png" x="30" y="21" width="110" height="97"/>
|
||||
<area image="context2d-example.png" x="0" y="0" width="100" height="100"/>
|
||||
<area image="creaderasync-example.png" x="658" y="2" width="155" height="69"/>
|
||||
<area image="creadersync-example.png" x="0" y="0" width="100" height="54"/>
|
||||
<area image="custom-geometry-example.png" x="99" y="99" width="147" height="89"/>
|
||||
<area image="customcompleter-example.png" x="3" y="69" width="151" height="112"/>
|
||||
<area image="customsortfiltermodel-example.png" x="10" y="27" width="152" height="117"/>
|
||||
<area image="customtypesending-example.png" x="99" y="99" width="152" height="112"/>
|
||||
<area image="customwidgetplugin-example.png" x="16" y="18" width="129" height="124"/>
|
||||
<area image="cwriterasync-example.png" x="0" y="0" width="100" height="58"/>
|
||||
<area image="cwritersync-example.png" x="0" y="0" width="100" height="47"/>
|
||||
<area image="dbus-chat-example.png" x="131" y="138" width="138" height="130"/>
|
||||
<area image="declarative-anchors_example.png" x="0" y="0" width="100" height="100"/>
|
||||
<area image="declarative-radio-example.png" x="8" y="215" width="156" height="85"/>
|
||||
<area image="declarative-textballoons_example.png" x="31" y="20" width="145" height="96"/>
|
||||
<area image="defaultprototypes-example.png" x="2" y="15" width="104" height="111"/>
|
||||
<area image="diagramscene.png" x="1" y="47" width="164" height="138"/>
|
||||
<area image="deform-demo.png" x="228" y="252" width="147" height="116"/>
|
||||
<area image="delayedecoding-example.png" x="0" y="0" width="100" height="100"/>
|
||||
<area image="dialogbuttonboxexample.png" x="432" y="48" width="153" height="112"/>
|
||||
<area image="digitalclock-example.png" x="57" y="37" width="129" height="96"/>
|
||||
<area image="dirview-example.png" x="21" y="96" width="122" height="90"/>
|
||||
<area image="dockwidgets-example.png" x="498" y="262" width="180" height="109"/>
|
||||
<area image="dombookmarks-example.png" x="2" y="53" width="131" height="129"/>
|
||||
<area image="draganddroppuzzle-example.png" x="183" y="230" width="145" height="127"/>
|
||||
<area image="dragdroprobot-example.png" x="119" y="101" width="115" height="129"/>
|
||||
<area image="draggableicons-example.png" x="181" y="67" width="111" height="124"/>
|
||||
<area image="draggabletext-example.png" x="48" y="78" width="96" height="90"/>
|
||||
<area image="drilldown-example.png" x="119" y="34" width="162" height="132"/>
|
||||
<area image="dropsite-example.png" x="32" y="319" width="181" height="91"/>
|
||||
<area image="dynamiclayouts-example.png" x="223" y="2" width="178" height="106"/>
|
||||
<area image="easing-example.png" x="230" y="27" width="116" height="110"/>
|
||||
<area image="echopluginexample.png" x="65" y="27" width="125" height="96"/>
|
||||
<area image="elasticnodes-example.png" x="72" y="71" width="120" height="107"/>
|
||||
<area image="elidedlabel-example.png" x="47" y="8" width="174" height="110"/>
|
||||
<area image="embedded-simpledecoration-example.png" x="0" y="0" width="143" height="91"/>
|
||||
<area image="embeddeddesktopservices-demo.png" x="0" y="0" width="100" height="100"/>
|
||||
<area image="embeddeddialogs-demo.png" x="250" y="0" width="161" height="104"/>
|
||||
<area image="embeddedsvgviewer-demo.png" x="99" y="25" width="112" height="121"/>
|
||||
<area image="enumerator-example.png" x="15" y="4" width="119" height="106"/>
|
||||
<area image="extension-example.png" x="15" y="31" width="198" height="84"/>
|
||||
<area image="factorial-example.png" x="51" y="38" width="145" height="78"/>
|
||||
<area image="fademessageeffect-example.png" x="68" y="153" width="129" height="114"/>
|
||||
<area image="fancybrowser-example.png" x="385" y="201" width="170" height="94"/>
|
||||
<area image="fetchmore-example.png" x="11" y="35" width="129" height="99"/>
|
||||
<area image="filetree_1-example.png" x="11" y="33" width="164" height="112"/>
|
||||
<area image="filetree_2-example.png" x="15" y="67" width="150" height="105"/>
|
||||
<area image="findfiles-example.png" x="61" y="5" width="158" height="138"/>
|
||||
<area image="flickable-demo.png" x="2" y="71" width="176" height="102"/>
|
||||
<area image="flickrview-example.png" x="144" y="297" width="140" height="98"/>
|
||||
<area image="flightinfo-demo.png" x="153" y="107" width="121" height="98"/>
|
||||
<area image="flowlayout-example.png" x="14" y="34" width="165" height="92"/>
|
||||
<area image="fluidlauncher-demo.png" x="75" y="166" width="135" height="113"/>
|
||||
<area image="fontsampler-example.png" x="4" y="42" width="148" height="104"/>
|
||||
<area image="formextractor-example.png" x="56" y="137" width="144" height="108"/>
|
||||
<area image="fortuneclient-example.png" x="7" y="31" width="172" height="102"/>
|
||||
<area image="fortuneserver-example.png" x="72" y="29" width="121" height="86"/>
|
||||
<area image="framebufferobject-example.png" x="147" y="114" width="178" height="131"/>
|
||||
<area image="framebufferobject2-example.png" x="320" y="114" width="136" height="105"/>
|
||||
<area image="framecapture-example.png" x="0" y="0" width="100" height="100"/>
|
||||
<area image="fridgemagnets-example.png" x="211" y="51" width="114" height="111"/>
|
||||
<area image="frozencolumn-example.png" x="6" y="22" width="127" height="97"/>
|
||||
<area image="googlechat-example.png" x="384" y="416" width="177" height="120"/>
|
||||
<area image="googlesuggest-example.png" x="18" y="18" width="129" height="109"/>
|
||||
<area image="grabber-example.png" x="180" y="105" width="158" height="142"/>
|
||||
<area image="gradients-demo.png" x="80" y="141" width="119" height="120"/>
|
||||
<area image="graphicsanchorlayout-example.png" x="156" y="182" width="185" height="124"/>
|
||||
<area image="graphicsflowlayout-example.png" x="113" y="115" width="170" height="76"/>
|
||||
<area image="graphicssimpleanchorlayout-example.png" x="90" y="104" width="189" height="116"/>
|
||||
<area image="gridLayout_example.png" x="0" y="0" width="100" height="100"/>
|
||||
<area image="gridviewexample.png" x="0" y="0" width="64" height="64"/>
|
||||
<area image="groupbox-example.png" x="11" y="30" width="163" height="101"/>
|
||||
<area image="hellogl-es-example.png" x="56" y="166" width="164" height="132"/>
|
||||
<area image="hellogl-example.png" x="105" y="147" width="127" height="106"/>
|
||||
<area image="horizontalpositioner_example.png" x="0" y="0" width="100" height="74"/>
|
||||
<area image="http-example.png" x="17" y="33" width="179" height="87"/>
|
||||
<area image="i18n-example.png" x="15" y="103" width="130" height="108"/>
|
||||
<area image="icons-example.png" x="243" y="87" width="160" height="114"/>
|
||||
<area image="imagecomposition-example.png" x="618" y="72" width="137" height="127"/>
|
||||
<area image="imagescaling_example.png" x="164" y="42" width="141" height="128"/>
|
||||
<area image="imageviewer-example.png" x="10" y="24" width="154" height="145"/>
|
||||
<area image="inputpanel-example.png" x="59" y="131" width="163" height="140"/>
|
||||
<area image="interview-demo.png" x="268" y="29" width="122" height="81"/>
|
||||
<area image="itemviewspuzzle-example.png" x="410" y="141" width="129" height="99"/>
|
||||
<area image="licensewizard-example.png" x="147" y="40" width="176" height="117"/>
|
||||
<area image="lightingeffect-example.png" x="95" y="180" width="104" height="65"/>
|
||||
<area image="lightmaps-demo.png" x="126" y="109" width="142" height="106"/>
|
||||
<area image="lineedits-example.png" x="236" y="26" width="125" height="118"/>
|
||||
<area image="linguist-arrowpad_en.png" x="12" y="52" width="149" height="98"/>
|
||||
<area image="linguist-hellotr_en.png" x="28" y="2" width="118" height="61"/>
|
||||
<area image="linguist-trollprint_10_en.png" x="0" y="0" width="120" height="120"/>
|
||||
<area image="localfortuneclient-example.png" x="8" y="27" width="161" height="86"/>
|
||||
<area image="localfortuneserver-example.png" x="13" y="29" width="159" height="88"/>
|
||||
<area image="loopback-example.png" x="11" y="35" width="122" height="116"/>
|
||||
<area image="maemovibration-example.png" x="85" y="200" width="183" height="106"/>
|
||||
<area image="mainwindow-demo.png" x="246" y="33" width="159" height="97"/>
|
||||
<area image="mainwindow-docks-example.png" x="109" y="13" width="141" height="123"/>
|
||||
<area image="mandelbrot-example.png" x="67" y="77" width="161" height="123"/>
|
||||
<area image="masterdetail-example.png" x="6" y="38" width="102" height="79"/>
|
||||
<area image="mdi-example.png" x="134" y="46" width="147" height="127"/>
|
||||
<area image="menus-example.png" x="27" y="24" width="162" height="112"/>
|
||||
<area image="mouseareaexample.png" x="0" y="0" width="64" height="64"/>
|
||||
<area image="moveblocks-example.png" x="35" y="59" width="86" height="89"/>
|
||||
<area image="movie-example.png" x="14" y="306" width="168" height="126"/>
|
||||
<area image="multicastreceiver-example.png" x="14" y="33" width="173" height="74"/>
|
||||
<area image="multicastsender-example.png" x="20" y="39" width="126" height="51"/>
|
||||
<area image="multipleinheritance-example.png" x="7" y="38" width="177" height="66"/>
|
||||
<area image="network-chat-example.png" x="58" y="68" width="166" height="115"/>
|
||||
<area image="openglwindow-example.png" x="261" y="102" width="116" height="122"/>
|
||||
<area image="orderform-example.png" x="247" y="212" width="157" height="106"/>
|
||||
<area image="overpainting-example.png" x="119" y="69" width="172" height="139"/>
|
||||
<area image="padnavigator-example.png" x="8" y="22" width="214" height="197"/>
|
||||
<area image="painterpaths-example.png" x="9" y="286" width="172" height="113"/>
|
||||
<area image="pathexample.png" x="0" y="0" width="100" height="100"/>
|
||||
<area image="pathstroke-demo.png" x="382" y="207" width="111" height="87"/>
|
||||
<area image="pbuffers-example.png" x="100" y="262" width="145" height="141"/>
|
||||
<area image="pbuffers2-example.png" x="196" y="95" width="156" height="131"/>
|
||||
<area image="pingpong-example.png" x="143" y="119" width="192" height="86"/>
|
||||
<area image="pixelator-example.png" x="242" y="127" width="119" height="110"/>
|
||||
<area image="plugandpaint.png" x="42" y="83" width="183" height="97"/>
|
||||
<area image="portedasteroids-example.png" x="487" y="8" width="161" height="109"/>
|
||||
<area image="portedcanvas-example.png" x="393" y="178" width="151" height="133"/>
|
||||
<area image="pixmapfilter-example.png" x="354" y="63" width="101" height="101"/>
|
||||
<area image="positioner-example.png" x="0" y="0" width="100" height="100"/>
|
||||
<area image="previewer-example.png" x="108" y="62" width="186" height="119"/>
|
||||
<area image="qcameraexample.png" x="314" y="91" width="178" height="97"/>
|
||||
<area image="qmediaplayer-demo.png" x="11" y="26" width="203" height="126"/>
|
||||
<area image="qml-abstractitemmodel-example.png" x="0" y="0" width="100" height="100"/>
|
||||
<area image="qml-affectors-example.png" x="78" y="225" width="152" height="109"/>
|
||||
<area image="qml-animations-example.png" x="86" y="170" width="133" height="85"/>
|
||||
<area image="qml-behaviors-example.png" x="166" y="86" width="164" height="128"/>
|
||||
<area image="qml-borderimage-example.png" x="6" y="7" width="171" height="128"/>
|
||||
<area image="qml-borderimage-shadows-example.png" x="213" y="12" width="114" height="108"/>
|
||||
<area image="qml-calculator-example.png" x="218" y="5" width="142" height="125"/>
|
||||
<area image="qml-canvas-example.png" x="0" y="282" width="141" height="122"/>
|
||||
<area image="qml-clocks-example.png" x="244" y="90" width="157" height="133"/>
|
||||
<area image="qml-coloranim-example.png" x="99" y="21" width="141" height="102"/>
|
||||
<area image="qml-corkboards-example.png" x="37" y="22" width="133" height="124"/>
|
||||
<area image="qml-customparticle-example.png" x="69" y="119" width="131" height="124"/>
|
||||
<area image="qml-dialcontrol-example.png" x="84" y="70" width="123" height="104"/>
|
||||
<area image="qml-dnd2-example.png" x="63" y="59" width="145" height="81"/>
|
||||
<area image="qml-draganddrop-example.png" x="5" y="29" width="160" height="136"/>
|
||||
<area image="qml-dynamicscene-example.png" x="31" y="191" width="117" height="122"/>
|
||||
<area image="qml-easing-example.png" x="156" y="79" width="175" height="126"/>
|
||||
<area image="qml-emitters-example.png" x="92" y="150" width="141" height="140"/>
|
||||
<area image="qml-flickr-demo.png" x="1" y="1" width="167" height="125"/>
|
||||
<area image="qml-flipable-example.png" x="253" y="121" width="146" height="85"/>
|
||||
<area image="qml-focus-example.png" x="195" y="109" width="205" height="108"/>
|
||||
<area image="qml-fonts-availableFonts-example.png" x="99" y="49" width="147" height="87"/>
|
||||
<area image="qml-fonts-banner-example.png" x="105" y="34" width="164" height="102"/>
|
||||
<area image="qml-fonts-fonts-example.png" x="1" y="39" width="148" height="104"/>
|
||||
<area image="qml-fonts-hello-example.png" x="61" y="95" width="160" height="47"/>
|
||||
<area image="qml-gridview-example.png" x="0" y="0" width="100" height="100"/>
|
||||
<area image="qml-guitartuner-example.png" x="180" y="120" width="169" height="144"/>
|
||||
<area image="qml-i18n-example.png" x="0" y="0" width="100" height="38"/>
|
||||
<area image="qml-image-example.png" x="16" y="149" width="153" height="114"/>
|
||||
<area image="qml-imageelements-example.png" x="86" y="148" width="217" height="145"/>
|
||||
<area image="qml-imageparticle-example.png" x="113" y="147" width="147" height="115"/>
|
||||
<area image="qml-imageprovider-example.png" x="0" y="0" width="100" height="100"/>
|
||||
<area image="qml-keyinteraction-example.png" x="79" y="27" width="188" height="96"/>
|
||||
<area image="qml-layoutitem-example.png" x="77" y="3" width="103" height="118"/>
|
||||
<area image="qml-listview-dynamiclist-example.png" x="11" y="56" width="99" height="84"/>
|
||||
<area image="qml-listview-expandingdelegates-example.png" x="1" y="31" width="159" height="151"/>
|
||||
<area image="qml-listview-highlight-example.png" x="4" y="121" width="144" height="88"/>
|
||||
<area image="qml-listview-highlightranges-example.png" x="99" y="99" width="126" height="126"/>
|
||||
<area image="qml-listview-sections-example.png" x="0" y="0" width="100" height="100"/>
|
||||
<area image="qml-localstorage-example.png" x="0" y="0" width="100" height="100"/>
|
||||
<area image="qml-minehunt-demo.png" x="155" y="112" width="168" height="124"/>
|
||||
<area image="qml-modelviews-example.png" x="297" y="182" width="178" height="110"/>
|
||||
<area image="qml-mousearea-example.png" x="25" y="65" width="126" height="56"/>
|
||||
<area image="qml-objectlistmodel-example.png" x="0" y="0" width="100" height="100"/>
|
||||
<area image="qml-package-example.png" x="171" y="23" width="146" height="101"/>
|
||||
<area image="qml-parallax-example.png" x="59" y="220" width="148" height="139"/>
|
||||
<area image="qml-pathview-example.png" x="121" y="76" width="182" height="127"/>
|
||||
<area image="qml-photoviewer-demo.png" x="103" y="17" width="202" height="153"/>
|
||||
<area image="qml-plugins-example.png" x="45" y="13" width="150" height="113"/>
|
||||
<area image="qml-positioners-example.png" x="92" y="99" width="125" height="146"/>
|
||||
<area image="qml-positioners-layoutdirection-example.png" x="99" y="45" width="138" height="125"/>
|
||||
<area image="qml-poster-example.png" x="471" y="147" width="117" height="58"/>
|
||||
<area image="qml-progressbar-example.png" x="408" y="238" width="188" height="127"/>
|
||||
<area image="qml-propertyanim-example.png" x="72" y="147" width="99" height="117"/>
|
||||
<area image="qml-qgraphicsgridlayout-example.png" x="106" y="1" width="87" height="152"/>
|
||||
<area image="qml-qgraphicslinearlayout-example.png" x="70" y="0" width="72" height="76"/>
|
||||
<area image="qml-qtbubblelevel-demo.png" x="158" y="1" width="177" height="48"/>
|
||||
<area image="qml-qwidgets-example.png" x="23" y="22" width="161" height="111"/>
|
||||
<area image="qml-righttoleft-example.png" x="131" y="247" width="184" height="104"/>
|
||||
<area image="qml-righttoleft-layoutdirection-example.png" x="82" y="18" width="115" height="124"/>
|
||||
<area image="qml-righttoleft-layoutmirroring-example.png" x="2" y="182" width="172" height="123"/>
|
||||
<area image="qml-rssnews-demo.png" x="5" y="57" width="168" height="105"/>
|
||||
<area image="qml-samegame-demo.png" x="211" y="294" width="157" height="106"/>
|
||||
<area image="qml-scrollbar-example.png" x="300" y="247" width="191" height="103"/>
|
||||
<area image="qml-searchbox-example.png" x="119" y="61" width="153" height="123"/>
|
||||
<area image="qml-shadereffects-example.png" x="217" y="30" width="198" height="138"/>
|
||||
<area image="qml-slideswitch-example.png" x="119" y="86" width="161" height="71"/>
|
||||
<area image="qml-snake-demo.png" x="271" y="150" width="189" height="79"/>
|
||||
<area image="qml-spinner-example.png" x="59" y="95" width="121" height="109"/>
|
||||
<area image="qml-states-example.png" x="186" y="73" width="121" height="93"/>
|
||||
<area image="qml-stringlistmodel-example.png" x="0" y="0" width="100" height="100"/>
|
||||
<area image="qml-system-example.png" x="99" y="99" width="162" height="83"/>
|
||||
<area image="qml-tabwidget-example.png" x="65" y="5" width="169" height="61"/>
|
||||
<area image="qml-text-example.png" x="185" y="312" width="228" height="135"/>
|
||||
<area image="qml-textselection-example.png" x="10" y="12" width="205" height="108"/>
|
||||
<area image="qml-threading-example.png" x="82" y="44" width="160" height="79"/>
|
||||
<area image="qml-tic-tac-toe-example.png" x="47" y="72" width="211" height="166"/>
|
||||
<area image="qml-touchinteraction-example.png" x="162" y="121" width="157" height="137"/>
|
||||
<area image="qml-transitions-example.png" x="156" y="66" width="159" height="118"/>
|
||||
<area image="qml-tvtennis-example.png" x="225" y="249" width="134" height="111"/>
|
||||
<area image="qml-twitter-demo.png" x="5" y="10" width="162" height="112"/>
|
||||
<area image="qml-visualitemmodel-example.png" x="71" y="262" width="100" height="58"/>
|
||||
<area image="qml-webbrowser-demo.png" x="0" y="0" width="100" height="100"/>
|
||||
<area image="qml-webview-alert-example.png" x="0" y="0" width="100" height="100"/>
|
||||
<area image="qml-webview-autosize-example.png" x="0" y="0" width="100" height="100"/>
|
||||
<area image="qml-webview-googlemaps-example.png" x="0" y="0" width="100" height="100"/>
|
||||
<area image="qml-webview-inlinehtml-example.png" x="0" y="0" width="100" height="100"/>
|
||||
<area image="qml-webview-newwindows-example.png" x="0" y="0" width="100" height="100"/>
|
||||
<area image="qml-window-example.png" x="0" y="0" width="100" height="100"/>
|
||||
<area image="qml-xmlhttprequest-example.png" x="8" y="29" width="120" height="82"/>
|
||||
<area image="qml-xmllistmodel-example.png" x="0" y="0" width="100" height="76"/>
|
||||
<area image="qobjectxmlmodel-example.png" x="9" y="41" width="139" height="119"/>
|
||||
<area image="qpainter-compositiondemo.png" x="64" y="24" width="69" height="62"/>
|
||||
<area image="qpainterpath-demo.png" x="71" y="99" width="66" height="96"/>
|
||||
<area image="qpainterpath-example.png" x="99" y="99" width="104" height="93"/>
|
||||
<area image="qpen-demo.png" x="34" y="31" width="183" height="125"/>
|
||||
<area image="qtdemo-example.png" x="30" y="34" width="179" height="114"/>
|
||||
<area image="qtdemo.png" x="494" y="151" width="173" height="129"/>
|
||||
<area image="qtscript-calculator-example.png" x="195" y="22" width="127" height="111"/>
|
||||
<area image="querymodel-example.png" x="462" y="48" width="129" height="113"/>
|
||||
<area image="queuedcustomtype-example.png" x="270" y="28" width="140" height="120"/>
|
||||
<area image="radio-example.png" x="3" y="59" width="138" height="107"/>
|
||||
<area image="raycasting-demo.png" x="157" y="130" width="143" height="122"/>
|
||||
<area image="recentfiles-example.png" x="0" y="0" width="173" height="138"/>
|
||||
<area image="recipes-example.png" x="3" y="139" width="154" height="103"/>
|
||||
<area image="reflection_example.png" x="5" y="66" width="132" height="93"/>
|
||||
<area image="regexp-example.png" x="12" y="34" width="166" height="114"/>
|
||||
<area image="relationaltablemodel-example.png" x="3" y="28" width="172" height="85"/>
|
||||
<area image="remotecontrolledcar-car-example.png" x="139" y="77" width="117" height="136"/>
|
||||
<area image="remotecontrolledcar-controller-example.png" x="80" y="21" width="121" height="96"/>
|
||||
<area image="rogue-example.png" x="7" y="30" width="115" height="100"/>
|
||||
<area image="rsslistingexample.png" x="13" y="30" width="157" height="110"/>
|
||||
<area image="samplebuffers-example.png" x="88" y="279" width="174" height="116"/>
|
||||
<area image="saxbookmarks-example.png" x="4" y="53" width="143" height="114"/>
|
||||
<area image="schema-example.png" x="55" y="104" width="169" height="98"/>
|
||||
<area image="screenshot-example.png" x="7" y="169" width="176" height="135"/>
|
||||
<area image="scribble-example.png" x="152" y="126" width="206" height="161"/>
|
||||
<area image="sdi-example.png" x="3" y="9" width="150" height="132"/>
|
||||
<area image="securesocketclient.png" x="10" y="25" width="148" height="101"/>
|
||||
<area image="settingseditor-example.png" x="13" y="152" width="165" height="121"/>
|
||||
<area image="shaderexample.png" x="54" y="117" width="145" height="67"/>
|
||||
<area image="shadow_example.png" x="2" y="104" width="112" height="124"/>
|
||||
<area image="shapedclock-example.png" x="107" y="36" width="131" height="115"/>
|
||||
<area image="sharedmemory-example_1.png" x="149" y="18" width="164" height="79"/>
|
||||
<area image="simpleanchorlayout-example.png" x="87" y="28" width="167" height="122"/>
|
||||
<area image="simpledommodel-example.png" x="7" y="84" width="134" height="111"/>
|
||||
<area image="simpletextviewer-example.png" x="112" y="23" width="141" height="110"/>
|
||||
<area image="simpletreemodel-example.png" x="3" y="33" width="172" height="118"/>
|
||||
<area image="simplewidgetmapper-example.png" x="11" y="36" width="160" height="91"/>
|
||||
<area image="sliders-example.png" x="461" y="42" width="182" height="127"/>
|
||||
<area image="sortingmodel-example.png" x="342" y="136" width="145" height="118"/>
|
||||
<area image="spectrum-demo.png" x="77" y="79" width="211" height="123"/>
|
||||
<area image="spinboxdelegate-example.png" x="82" y="86" width="152" height="96"/>
|
||||
<area image="spinboxes-example.png" x="263" y="65" width="169" height="113"/>
|
||||
<area image="spreadsheet-demo.png" x="7" y="50" width="162" height="115"/>
|
||||
<area image="sqlbrowser-demo.png" x="19" y="72" width="143" height="93"/>
|
||||
<area image="standarddialogs-example.png" x="187" y="33" width="178" height="149"/>
|
||||
<area image="stardelegate.png" x="220" y="21" width="180" height="95"/>
|
||||
<area image="states-example.png" x="236" y="258" width="176" height="77"/>
|
||||
<area image="stickman-example.png" x="1" y="1" width="467" height="510"/>
|
||||
<area image="styles-enabledwood.png" x="12" y="24" width="185" height="95"/>
|
||||
<area image="stylesheet-coffee-plastique.png" x="40" y="64" width="180" height="115"/>
|
||||
<area image="styledemo-demo.png" x="220" y="148" width="163" height="111"/>
|
||||
<area image="styledemo.png" x="104" y="140" width="112" height="94"/>
|
||||
<area image="stylepluginexample.png" x="16" y="26" width="140" height="82"/>
|
||||
<area image="sub-attaq-demo.png" x="171" y="279" width="157" height="82"/>
|
||||
<area image="svggenerator-example.png" x="162" y="64" width="90" height="72"/>
|
||||
<area image="svgviewer-example.png" x="193" y="245" width="102" height="91"/>
|
||||
<area image="syntaxhighlighter-example.png" x="4" y="67" width="153" height="101"/>
|
||||
<area image="systemtray-example.png" x="163" y="36" width="181" height="113"/>
|
||||
<area image="t1.png" x="0" y="0" width="108" height="56"/>
|
||||
<area image="tabdialog-example.png" x="7" y="30" width="168" height="105"/>
|
||||
<area image="tablemodel-example.png" x="342" y="44" width="157" height="116"/>
|
||||
<area image="tabletexample.png" x="26" y="70" width="167" height="112"/>
|
||||
<area image="tankgame-example.png" x="9" y="25" width="145" height="102"/>
|
||||
<area image="taskmenuextension-example.png" x="84" y="63" width="170" height="126"/>
|
||||
<area image="terminal-example.png" x="0" y="0" width="100" height="100"/>
|
||||
<area image="tetrix-example.png" x="46" y="72" width="112" height="112"/>
|
||||
<area image="textedit-demo.png" x="4" y="33" width="134" height="145"/>
|
||||
<area image="textfinder-example.png" x="347" y="27" width="137" height="85"/>
|
||||
<area image="textobject-example.png" x="86" y="73" width="99" height="80"/>
|
||||
<area image="textures-example.png" x="245" y="70" width="154" height="137"/>
|
||||
<area image="threadedfortuneserver-example.png" x="100" y="30" width="122" height="85"/>
|
||||
<area image="threadvisual-example.png" x="34" y="99" width="116" height="94"/>
|
||||
<area image="tooltips-example.png" x="96" y="63" width="128" height="129"/>
|
||||
<area image="torrent-example.png" x="5" y="29" width="175" height="126"/>
|
||||
<area image="touch-dials-example.png" x="64" y="162" width="138" height="110"/>
|
||||
<area image="touch-fingerpaint-example.png" x="99" y="78" width="166" height="135"/>
|
||||
<area image="touch-knobs-example.png" x="66" y="9" width="81" height="85"/>
|
||||
<area image="touch-pinchzoom-example.png" x="99" y="67" width="113" height="103"/>
|
||||
<area image="trafficinfo-example.png" x="45" y="1" width="207" height="62"/>
|
||||
<area image="trafficlight-example.png" x="8" y="219" width="112" height="104"/>
|
||||
<area image="transformations-example.png" x="484" y="92" width="128" height="125"/>
|
||||
<area image="treemodelcompleter-example.png" x="11" y="319" width="181" height="109"/>
|
||||
<area image="trivialwizard-example-introduction.png" x="248" y="333" width="170" height="61"/>
|
||||
<area image="undodemo.png" x="230" y="190" width="173" height="126"/>
|
||||
<area image="undoframeworkexample.png" x="176" y="1" width="136" height="121"/>
|
||||
<area image="verticalpositioner_example.png" x="0" y="0" width="50" height="100"/>
|
||||
<area image="visual-coordinates-example.png" x="54" y="44" width="117" height="122"/>
|
||||
<area image="visual-parent-example.png" x="166" y="49" width="119" height="147"/>
|
||||
<area image="weatheranchorlayout-example.png" x="111" y="53" width="161" height="131"/>
|
||||
<area image="weatherinfo-demo.png" x="284" y="33" width="191" height="130"/>
|
||||
<area image="wheel-example.png" x="60" y="74" width="103" height="102"/>
|
||||
<area image="wiggly-example.png" x="10" y="58" width="155" height="113"/>
|
||||
<area image="windowflags-example.png" x="9" y="82" width="140" height="119"/>
|
||||
<area image="worldtimeclockbuilder-example.png" x="99" y="57" width="154" height="93"/>
|
||||
<area image="worldtimeclockplugin-example.png" x="109" y="34" width="141" height="116"/>
|
||||
<area image="xmlstreamexample-screenshot.png" x="2" y="54" width="139" height="98"/>
|
||||
<area image="xmlhttprequestexample.png" x="0" y="0" width="64" height="64"/>
|
||||
<area image="youtubeview-example.png" x="99" y="13" width="184" height="141"/>
|
||||
</areas>
|
@@ -99,8 +99,6 @@ Project {
|
||||
"qtversionmanager.cpp",
|
||||
"qtversionmanager.h",
|
||||
"qtversionmanager.ui",
|
||||
"screenshotcropper.cpp",
|
||||
"screenshotcropper.h",
|
||||
"showbuildlog.ui",
|
||||
"translationwizardpage.cpp",
|
||||
"translationwizardpage.h",
|
||||
|
@@ -4,7 +4,6 @@
|
||||
<file>images/dark_qml.png</file>
|
||||
<file>images/dark_qt_project.png</file>
|
||||
<file>images/dark_qt_qrc.png</file>
|
||||
<file>images_areaofinterest.xml</file>
|
||||
<file>qtcreator_tutorials.xml</file>
|
||||
<file>images/icons/playoverlay.png</file>
|
||||
<file>images/icons/playoverlay@2x.png</file>
|
||||
|
@@ -1,181 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "screenshotcropper.h"
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamWriter>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
|
||||
namespace QtSupport {
|
||||
namespace Internal {
|
||||
|
||||
class AreasOfInterest {
|
||||
public:
|
||||
AreasOfInterest();
|
||||
QMap<QString, QRect> areas;
|
||||
};
|
||||
|
||||
AreasOfInterest::AreasOfInterest()
|
||||
{
|
||||
#ifdef QT_CREATOR
|
||||
areas = ScreenshotCropper::loadAreasOfInterest(":/qtsupport/images_areaofinterest.xml");
|
||||
#endif // QT_CREATOR
|
||||
}
|
||||
|
||||
Q_GLOBAL_STATIC(AreasOfInterest, welcomeScreenAreas)
|
||||
|
||||
static inline QString fileNameForPath(const QString &path)
|
||||
{
|
||||
return Utils::FilePath::fromString(path).fileName();
|
||||
}
|
||||
|
||||
static QRect cropRectForAreaOfInterest(const QSize &imageSize, const QSize &cropSize, const QRect &areaOfInterest)
|
||||
{
|
||||
QRect result;
|
||||
if (areaOfInterest.width() <= cropSize.width()
|
||||
&& areaOfInterest.height() <= cropSize.height()) {
|
||||
const QPoint areaOfInterestCenter = areaOfInterest.center();
|
||||
const int cropX = qBound(0,
|
||||
areaOfInterestCenter.x() - cropSize.width() / 2,
|
||||
imageSize.width() - cropSize.width());
|
||||
const int cropY = qBound(0,
|
||||
areaOfInterestCenter.y() - cropSize.height() / 2,
|
||||
imageSize.height() - cropSize.height());
|
||||
const int cropWidth = qMin(imageSize.width(), cropSize.width());
|
||||
const int cropHeight = qMin(imageSize.height(), cropSize.height());
|
||||
result = QRect(cropX, cropY, cropWidth, cropHeight);
|
||||
} else {
|
||||
QSize resultSize = cropSize.scaled(areaOfInterest.width(), areaOfInterest.height(),
|
||||
Qt::KeepAspectRatioByExpanding);
|
||||
result = QRect(QPoint(), resultSize);
|
||||
result.moveCenter(areaOfInterest.center());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
namespace ScreenshotCropper {
|
||||
|
||||
QImage croppedImage(const QImage &sourceImage, const QString &filePath, const QSize &cropSize,
|
||||
const QRect &areaOfInterest)
|
||||
{
|
||||
const QRect area = areaOfInterest.isValid() ? areaOfInterest :
|
||||
Internal::welcomeScreenAreas()->areas.value(Internal::fileNameForPath(filePath));
|
||||
|
||||
QImage result;
|
||||
if (area.isValid()) {
|
||||
const QRect cropRect = Internal::cropRectForAreaOfInterest(sourceImage.size(),
|
||||
cropSize, areaOfInterest);
|
||||
const QSize cropRectSize = cropRect.size();
|
||||
result = sourceImage.copy(cropRect);
|
||||
if (cropRectSize.width() <= cropSize.width() && cropRectSize.height() <= cropSize.height())
|
||||
return result;
|
||||
} else {
|
||||
result = sourceImage;
|
||||
}
|
||||
|
||||
if (result.format() != QImage::Format_ARGB32)
|
||||
result = result.convertToFormat(QImage::Format_ARGB32);
|
||||
return result.scaled(cropSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
}
|
||||
|
||||
static int areaAttribute(const QXmlStreamAttributes &attributes, const QString &name)
|
||||
{
|
||||
bool ok;
|
||||
const int result = attributes.value(name).toString().toInt(&ok);
|
||||
if (!ok)
|
||||
qWarning() << Q_FUNC_INFO << "Could not parse" << name << "for" << attributes.value(QLatin1String("image")).toString();
|
||||
return result;
|
||||
}
|
||||
|
||||
static const QString xmlTagAreas = QLatin1String("areas");
|
||||
static const QString xmlTagArea = QLatin1String("area");
|
||||
static const QString xmlAttributeImage = QLatin1String("image");
|
||||
static const QString xmlAttributeX = QLatin1String("x");
|
||||
static const QString xmlAttributeY = QLatin1String("y");
|
||||
static const QString xmlAttributeWidth = QLatin1String("width");
|
||||
static const QString xmlAttributeHeight = QLatin1String("height");
|
||||
|
||||
QMap<QString, QRect> loadAreasOfInterest(const QString &areasXmlFile)
|
||||
{
|
||||
QMap<QString, QRect> areasOfInterest;
|
||||
QFile xmlFile(areasXmlFile);
|
||||
if (!xmlFile.open(QIODevice::ReadOnly)) {
|
||||
qWarning() << Q_FUNC_INFO << "Could not open file" << areasXmlFile;
|
||||
return areasOfInterest;
|
||||
}
|
||||
QXmlStreamReader reader(&xmlFile);
|
||||
while (!reader.atEnd()) {
|
||||
switch (reader.readNext()) {
|
||||
case QXmlStreamReader::StartElement:
|
||||
if (reader.name() == xmlTagArea) {
|
||||
const QXmlStreamAttributes attributes = reader.attributes();
|
||||
const QString imageName = attributes.value(xmlAttributeImage).toString();
|
||||
if (imageName.isEmpty())
|
||||
qWarning() << Q_FUNC_INFO << "Could not parse name";
|
||||
|
||||
const QRect area(areaAttribute(attributes, xmlAttributeX), areaAttribute(attributes, xmlAttributeY),
|
||||
areaAttribute(attributes, xmlAttributeWidth), areaAttribute(attributes, xmlAttributeHeight));
|
||||
areasOfInterest.insert(imageName, area);
|
||||
}
|
||||
break;
|
||||
default: // nothing
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return areasOfInterest;
|
||||
}
|
||||
|
||||
bool saveAreasOfInterest(const QString &areasXmlFile, QMap<QString, QRect> &areas)
|
||||
{
|
||||
QFile file(areasXmlFile);
|
||||
if (!file.open(QIODevice::WriteOnly))
|
||||
return false;
|
||||
QXmlStreamWriter writer(&file);
|
||||
writer.setAutoFormatting(true);
|
||||
writer.writeStartDocument();
|
||||
writer.writeStartElement(xmlTagAreas);
|
||||
for (auto i = areas.cbegin(), end = areas.cend(); i != end; ++i) {
|
||||
writer.writeStartElement(xmlTagArea);
|
||||
writer.writeAttribute(xmlAttributeImage, i.key());
|
||||
writer.writeAttribute(xmlAttributeX, QString::number(i.value().x()));
|
||||
writer.writeAttribute(xmlAttributeY, QString::number(i.value().y()));
|
||||
writer.writeAttribute(xmlAttributeWidth, QString::number(i.value().width()));
|
||||
writer.writeAttribute(xmlAttributeHeight, QString::number(i.value().height()));
|
||||
writer.writeEndElement(); // xmlTagArea
|
||||
}
|
||||
writer.writeEndElement(); // xmlTagAreas
|
||||
writer.writeEndDocument();
|
||||
return true;
|
||||
}
|
||||
|
||||
} // ScreenshotCropper
|
||||
} // namespace QtSupport
|
@@ -1,48 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "qtsupport_global.h"
|
||||
|
||||
#include <QMap>
|
||||
#include <QRect>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QImage;
|
||||
class QSize;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace QtSupport {
|
||||
namespace ScreenshotCropper {
|
||||
|
||||
QTSUPPORT_EXPORT QImage croppedImage(const QImage &sourceImage, const QString &filePath,
|
||||
const QSize &cropSize, const QRect &areaOfInterest = {});
|
||||
QTSUPPORT_EXPORT QMap<QString, QRect> loadAreasOfInterest(const QString &areasXmlFile);
|
||||
QTSUPPORT_EXPORT bool saveAreasOfInterest(const QString &areasXmlFile,
|
||||
QMap<QString, QRect> &areas);
|
||||
|
||||
} // ScreenshotCropper
|
||||
} // namespace QtSupport
|
@@ -37,7 +37,6 @@ add_subdirectory(qtc-askpass)
|
||||
add_subdirectory(qtcreatorcrashhandler)
|
||||
# add_subdirectory(qtcreatorwidgets) ## qbs does not build this either
|
||||
add_subdirectory(qtpromaker)
|
||||
add_subdirectory(screenshotcropper)
|
||||
add_subdirectory(sdktool)
|
||||
add_subdirectory(valgrindfake)
|
||||
add_subdirectory(wininterrupt) ## windows only
|
||||
|
@@ -1,9 +0,0 @@
|
||||
add_qtc_executable(screenshotcropper
|
||||
SKIP_INSTALL
|
||||
DEPENDS Qt5::Widgets Utils Core QtSupport
|
||||
SOURCES
|
||||
main.cpp
|
||||
cropimageview.cpp
|
||||
cropimageview.h
|
||||
screenshotcropperwindow.h screenshotcropperwindow.cpp screenshotcropperwindow.ui
|
||||
)
|
@@ -1,89 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "cropimageview.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QMouseEvent>
|
||||
|
||||
CropImageView::CropImageView(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void CropImageView::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
m_initialPoint = event->pos();
|
||||
setEndPoint(m_initialPoint);
|
||||
}
|
||||
|
||||
void CropImageView::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
setEndPoint(event->pos());
|
||||
}
|
||||
|
||||
void CropImageView::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
setEndPoint(event->pos());
|
||||
}
|
||||
|
||||
void CropImageView::setImage(const QImage &image)
|
||||
{
|
||||
m_image = image;
|
||||
setMinimumSize(image.size());
|
||||
update();
|
||||
}
|
||||
|
||||
void CropImageView::setArea(const QRect &area)
|
||||
{
|
||||
m_area = m_image.rect().intersected(area);
|
||||
emit cropAreaChanged(m_area);
|
||||
update();
|
||||
}
|
||||
|
||||
void CropImageView::setEndPoint(const QPoint &point)
|
||||
{
|
||||
setArea(QRect(m_initialPoint, point));
|
||||
}
|
||||
|
||||
void CropImageView::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
QPainter p(this);
|
||||
|
||||
if (!m_image.isNull())
|
||||
p.drawImage(0, 0, m_image);
|
||||
|
||||
if (!m_area.isNull()) {
|
||||
p.setPen(Qt::white);
|
||||
p.drawRect(m_area);
|
||||
QPen redDashes;
|
||||
redDashes.setColor(Qt::red);
|
||||
redDashes.setStyle(Qt::DashLine);
|
||||
p.setPen(redDashes);
|
||||
p.drawRect(m_area);
|
||||
}
|
||||
}
|
||||
|
@@ -1,53 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class CropImageView : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CropImageView(QWidget *parent = 0);
|
||||
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
|
||||
void setImage(const QImage &image);
|
||||
void setArea(const QRect &area);
|
||||
void setEndPoint(const QPoint &point);
|
||||
|
||||
signals:
|
||||
void cropAreaChanged(const QRect &area);
|
||||
|
||||
private:
|
||||
QImage m_image;
|
||||
QRect m_area;
|
||||
QPoint m_initialPoint;
|
||||
};
|
@@ -1,62 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QApplication>
|
||||
#include <QFileDialog>
|
||||
#include <QSettings>
|
||||
|
||||
#include "screenshotcropperwindow.h"
|
||||
|
||||
const QString settingsKeyAreasXmlFile = QLatin1String("areasXmlFile");
|
||||
const QString settingsKeyImagesFolder = QLatin1String("imagesFolder");
|
||||
|
||||
static void promptPaths(QString &areasXmlFile, QString &imagesFolder)
|
||||
{
|
||||
QSettings settings(QLatin1String("QtProject"), QLatin1String("Qt Creator Screenshot Cropper"));
|
||||
|
||||
areasXmlFile = settings.value(settingsKeyAreasXmlFile).toString();
|
||||
areasXmlFile = QFileDialog::getOpenFileName(0, QLatin1String("Select the 'images_areaofinterest.xml' file in Qt Creator's sources"), areasXmlFile);
|
||||
settings.setValue(settingsKeyAreasXmlFile, areasXmlFile);
|
||||
|
||||
imagesFolder = settings.value(settingsKeyImagesFolder).toString();
|
||||
imagesFolder = QFileDialog::getExistingDirectory(0, QLatin1String("Select the 'doc/src/images' folder in Qt's sources"), imagesFolder);
|
||||
settings.setValue(settingsKeyImagesFolder, imagesFolder);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
|
||||
QString areasXmlFile;
|
||||
QString imagesFolder;
|
||||
promptPaths(areasXmlFile, imagesFolder);
|
||||
|
||||
ScreenShotCropperWindow w;
|
||||
w.show();
|
||||
w.loadData(areasXmlFile, imagesFolder);
|
||||
w.selectImage(0);
|
||||
|
||||
return a.exec();
|
||||
}
|
@@ -1,96 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "screenshotcropperwindow.h"
|
||||
#include "ui_screenshotcropperwindow.h"
|
||||
|
||||
#include <coreplugin/welcomepagehelper.h>
|
||||
#include <qtsupport/screenshotcropper.h>
|
||||
|
||||
#include <QListWidget>
|
||||
#include <QDebug>
|
||||
|
||||
ScreenShotCropperWindow::ScreenShotCropperWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::ScreenShotCropperWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->m_filenamesList, &QListWidget::currentRowChanged, this, &ScreenShotCropperWindow::selectImage);
|
||||
connect(ui->m_cropImageView, &CropImageView::cropAreaChanged, this, &ScreenShotCropperWindow::setArea);
|
||||
connect(ui->m_buttonBox, &QDialogButtonBox::accepted, this, &ScreenShotCropperWindow::saveData);
|
||||
connect(ui->m_buttonBox, &QDialogButtonBox::rejected, this, &QWidget::close);
|
||||
}
|
||||
|
||||
ScreenShotCropperWindow::~ScreenShotCropperWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ScreenShotCropperWindow::loadData(const QString &areasXmlFile, const QString &imagesFolder)
|
||||
{
|
||||
typedef QMap<QString, QRect>::ConstIterator StringRectConstIt;
|
||||
|
||||
m_areasOfInterestFile = areasXmlFile;
|
||||
m_areasOfInterest = QtSupport::ScreenshotCropper::loadAreasOfInterest(m_areasOfInterestFile);
|
||||
m_imagesFolder = imagesFolder;
|
||||
const StringRectConstIt cend = m_areasOfInterest.constEnd();
|
||||
for (StringRectConstIt it = m_areasOfInterest.constBegin(); it != cend; ++it)
|
||||
ui->m_filenamesList->addItem(it.key());
|
||||
}
|
||||
|
||||
void ScreenShotCropperWindow::selectImage(int index)
|
||||
{
|
||||
const QString fileName = ui->m_filenamesList->item(index)->text();
|
||||
ui->m_cropImageView->setImage(QImage(m_imagesFolder + QLatin1Char('/') + fileName));
|
||||
ui->m_cropImageView->setArea(m_areasOfInterest.value(fileName));
|
||||
}
|
||||
|
||||
void ScreenShotCropperWindow::setArea(const QRect &area)
|
||||
{
|
||||
const QListWidgetItem *item = ui->m_filenamesList->currentItem();
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
if (!area.isValid()) {
|
||||
ui->m_previewLabel->setPixmap({});
|
||||
return;
|
||||
}
|
||||
|
||||
const QString currentFile = item->text();
|
||||
m_areasOfInterest.insert(currentFile, area);
|
||||
const QImage img(m_imagesFolder + QLatin1Char('/') + currentFile);
|
||||
const QPixmap cropped = QPixmap::fromImage(
|
||||
QtSupport::ScreenshotCropper::croppedImage(img, currentFile,
|
||||
Core::ListModel::defaultImageSize,
|
||||
area));
|
||||
ui->m_previewLabel->setPixmap(cropped);
|
||||
}
|
||||
|
||||
void ScreenShotCropperWindow::saveData()
|
||||
{
|
||||
if (!QtSupport::ScreenshotCropper::saveAreasOfInterest(m_areasOfInterestFile,
|
||||
m_areasOfInterest))
|
||||
qFatal("Cannot write %s", qPrintable(m_areasOfInterestFile));
|
||||
}
|
@@ -1,55 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QMap>
|
||||
#include <QRect>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class ScreenShotCropperWindow; }
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class ScreenShotCropperWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ScreenShotCropperWindow(QWidget *parent = 0);
|
||||
~ScreenShotCropperWindow();
|
||||
|
||||
void loadData(const QString &areasXmlFile, const QString &imagesFolder);
|
||||
|
||||
void selectImage(int index);
|
||||
void setArea(const QRect &area);
|
||||
void saveData();
|
||||
|
||||
private:
|
||||
QMap<QString, QRect> m_areasOfInterest;
|
||||
QString m_areasOfInterestFile;
|
||||
QString m_imagesFolder;
|
||||
Ui::ScreenShotCropperWindow *ui;
|
||||
};
|
@@ -1,103 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ScreenShotCropperWindow</class>
|
||||
<widget class="QMainWindow" name="ScreenShotCropperWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>680</width>
|
||||
<height>488</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>ScreenShotCropperWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QDialogButtonBox" name="m_buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close|QDialogButtonBox::Save</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QListWidget" name="m_filenamesList">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>386</width>
|
||||
<height>438</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin" stdset="0">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="CropImageView" name="m_cropImageView" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="m_previewLabel">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>CropImageView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>cropimageview.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Reference in New Issue
Block a user