fixes #0002887: add FC logo (watermark) in Save Picture Tool
This commit is contained in:
parent
9b58d8bd6f
commit
709d2f325d
|
@ -29,7 +29,11 @@
|
|||
# include <Inventor/nodes/SoOrthographicCamera.h>
|
||||
# include <Inventor/nodes/SoPerspectiveCamera.h>
|
||||
# include <QFile>
|
||||
# include <QFileInfo>
|
||||
# include <QFont>
|
||||
# include <QFontMetrics>
|
||||
# include <QMessageBox>
|
||||
# include <QPainter>
|
||||
# include <QTextStream>
|
||||
# include <boost/bind.hpp>
|
||||
#endif
|
||||
|
@ -1680,6 +1684,42 @@ void StdViewScreenShot::activated(int iMsg)
|
|||
doCommand(Gui,"Gui.activeDocument().activeView().saveImage('%s',%d,%d,'%s')",
|
||||
fn.toUtf8().constData(),w,h,background);
|
||||
}
|
||||
|
||||
// When adding a watermark check if the image could be created
|
||||
if (opt->addWatermark()) {
|
||||
QFileInfo fi(fn);
|
||||
QPixmap pixmap;
|
||||
if (fi.exists() && pixmap.load(fn)) {
|
||||
QString name = qApp->applicationName();
|
||||
std::map<std::string, std::string>& config = App::Application::Config();
|
||||
QString url = QString::fromLatin1(config["MaintainerUrl"].c_str());
|
||||
url = QUrl(url).host();
|
||||
|
||||
QPixmap appicon = Gui::BitmapFactory().pixmap(config["AppIcon"].c_str());
|
||||
|
||||
QPainter painter;
|
||||
painter.begin(&pixmap);
|
||||
|
||||
painter.drawPixmap(8, h-15-appicon.height(), appicon);
|
||||
|
||||
QFont font = painter.font();
|
||||
font.setPointSize(20);
|
||||
|
||||
int n = QFontMetrics(font).width(name);
|
||||
int h = pixmap.height();
|
||||
|
||||
painter.setFont(font);
|
||||
painter.drawText(8+appicon.width(), h-24, name);
|
||||
|
||||
font.setPointSize(12);
|
||||
int u = QFontMetrics(font).width(url);
|
||||
painter.setFont(font);
|
||||
painter.drawText(8+appicon.width()+n-u, h-9, url);
|
||||
|
||||
painter.end();
|
||||
pixmap.save(fn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -411,6 +411,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" >
|
||||
<widget class="QCheckBox" name="checkWatermark" >
|
||||
<property name="text" >
|
||||
<string>Add watermark</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -139,6 +139,11 @@ int DlgSettingsImageImp::backgroundType() const
|
|||
return comboBackground->currentIndex();
|
||||
}
|
||||
|
||||
bool DlgSettingsImageImp::addWatermark() const
|
||||
{
|
||||
return checkWatermark->isChecked();
|
||||
}
|
||||
|
||||
void DlgSettingsImageImp::onSelectedFilter(const QString& filter)
|
||||
{
|
||||
bool ok = (filter.startsWith(QLatin1String("JPG")) ||
|
||||
|
|
|
@ -57,6 +57,7 @@ public:
|
|||
//@{
|
||||
QString comment() const;
|
||||
int backgroundType() const;
|
||||
bool addWatermark() const;
|
||||
//@}
|
||||
|
||||
public Q_SLOTS:
|
||||
|
|
Loading…
Reference in New Issue
Block a user