Gui: set image creation method in settings dialog

This commit is contained in:
wmayer
2020-01-08 12:49:56 +01:00
parent 31e2bbe3a9
commit 8e5151002b
4 changed files with 279 additions and 166 deletions

View File

@@ -1730,6 +1730,10 @@ void StdViewScreenShot::activated(int iMsg)
QString ext = QString::fromLatin1(hExt->GetASCII("OffscreenImageFormat").c_str());
int backtype = hExt->GetInt("OffscreenImageBackground",0);
Base::Reference<ParameterGrp> methodGrp = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/View");
QByteArray method = methodGrp->GetASCII("SavePicture").c_str();
QStringList filter;
QString selFilter;
for (QStringList::Iterator it = formats.begin(); it != formats.end(); ++it) {
@@ -1752,6 +1756,7 @@ void StdViewScreenShot::activated(int iMsg)
SbVec2s sz = vp.getWindowSize();
opt->setImageSize((int)sz[0], (int)sz[1]);
opt->setBackgroundType(backtype);
opt->setMethod(method);
fd.setOptionsWidget(FileOptionsDialog::ExtensionRight, opt);
fd.setConfirmOverwrite(true);
@@ -1783,6 +1788,9 @@ void StdViewScreenShot::activated(int iMsg)
hExt->SetASCII("OffscreenImageFormat", (const char*)format.toLatin1());
method = opt->method();
methodGrp->SetASCII("SavePicture", method.constData());
// which background chosen
const char* background;
switch(opt->backgroundType()){

View File

@@ -1,68 +1,142 @@
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Gui::Dialog::DlgSettingsImage</class>
<widget class="QWidget" name="Gui::Dialog::DlgSettingsImage" >
<property name="geometry" >
<widget class="QWidget" name="Gui::Dialog::DlgSettingsImage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>440</width>
<height>519</height>
<width>459</width>
<height>552</height>
</rect>
</property>
<property name="windowTitle" >
<property name="windowTitle">
<string>Image settings</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<layout class="QGridLayout">
<property name="leftMargin">
<number>9</number>
</property>
<property name="spacing" >
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item row="1" column="0" >
<widget class="QGroupBox" name="groupBoxProp" >
<property name="title" >
<string>Image properties</string>
<item row="3" column="0">
<widget class="QGroupBox" name="buttonGroupComment">
<property name="enabled">
<bool>false</bool>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<property name="title">
<string>Image comment</string>
</property>
<layout class="QGridLayout">
<property name="leftMargin">
<number>9</number>
</property>
<property name="spacing" >
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="0" >
<widget class="QLabel" name="textLabelColor" >
<property name="text" >
<item row="0" column="0">
<widget class="QRadioButton" name="radioButtonMiba">
<property name="text">
<string>Insert MIBA</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QTextEdit" name="textEditComment">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="radioButtonComment">
<property name="text">
<string>Insert comment</string>
</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>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBoxProp">
<property name="title">
<string>Image properties</string>
</property>
<layout class="QGridLayout">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="textLabelColor">
<property name="text">
<string>Back&amp;ground:</string>
</property>
<property name="buddy" >
<property name="buddy">
<cstring>comboBackground</cstring>
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="QComboBox" name="comboBackground" >
<item row="0" column="2">
<widget class="QComboBox" name="comboBackground">
<item>
<property name="text" >
<property name="text">
<string>Current</string>
</property>
</item>
<item>
<property name="text" >
<property name="text">
<string>White</string>
</property>
</item>
<item>
<property name="text" >
<property name="text">
<string>Black</string>
</property>
</item>
<item>
<property name="text" >
<property name="text">
<string>Transparent</string>
</property>
</item>
@@ -71,32 +145,50 @@
</layout>
</widget>
</item>
<item row="0" column="0" >
<widget class="QGroupBox" name="groupBoxDim" >
<property name="title" >
<item row="0" column="0">
<widget class="QGroupBox" name="groupBoxDim">
<property name="title">
<string>Image dimensions</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<layout class="QGridLayout">
<property name="leftMargin">
<number>9</number>
</property>
<property name="spacing" >
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="0" >
<layout class="QGridLayout" >
<property name="margin" >
<item row="0" column="0">
<layout class="QGridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="spacing" >
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item row="1" column="1" >
<item row="1" column="1">
<spacer>
<property name="orientation" >
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
@@ -104,175 +196,175 @@
</property>
</spacer>
</item>
<item row="2" column="2" >
<widget class="QSpinBox" name="spinHeight" >
<property name="maximum" >
<number>32767</number>
</property>
<property name="minimum" >
<item row="2" column="2">
<widget class="QSpinBox" name="spinHeight">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>32767</number>
</property>
</widget>
</item>
<item row="1" column="2" >
<widget class="QSpinBox" name="spinWidth" >
<property name="maximum" >
<number>32767</number>
</property>
<property name="minimum" >
<item row="1" column="2">
<widget class="QSpinBox" name="spinWidth">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>32767</number>
</property>
</widget>
</item>
<item row="1" column="3" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<item row="1" column="3">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Pixel</string>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="textLabelWidth" >
<property name="text" >
<item row="1" column="0">
<widget class="QLabel" name="textLabelWidth">
<property name="text">
<string>&amp;Width:</string>
</property>
<property name="buddy" >
<property name="buddy">
<cstring>spinWidth</cstring>
</property>
</widget>
</item>
<item row="0" column="2" colspan="2" >
<widget class="QComboBox" name="standardSizeBox" >
<item row="0" column="2" colspan="2">
<widget class="QComboBox" name="standardSizeBox">
<item>
<property name="text" >
<property name="text">
<string>Current screen</string>
</property>
</item>
<item>
<property name="text" >
<property name="text">
<string>Icon 32 x 32</string>
</property>
</item>
<item>
<property name="text" >
<property name="text">
<string>Icon 64 x 64</string>
</property>
</item>
<item>
<property name="text" >
<property name="text">
<string>Icon 128 x 128</string>
</property>
</item>
<item>
<property name="text" >
<property name="text">
<string>CGA 320 x 200</string>
</property>
</item>
<item>
<property name="text" >
<property name="text">
<string>QVGA 320 x 240</string>
</property>
</item>
<item>
<property name="text" >
<property name="text">
<string>VGA 640 x 480</string>
</property>
</item>
<item>
<property name="text" >
<property name="text">
<string>NTSC 720 x 480</string>
</property>
</item>
<item>
<property name="text" >
<property name="text">
<string>PAL 768 x 578</string>
</property>
</item>
<item>
<property name="text" >
<property name="text">
<string>SVGA 800 x 600</string>
</property>
</item>
<item>
<property name="text" >
<property name="text">
<string>XGA 1024 x 768</string>
</property>
</item>
<item>
<property name="text" >
<property name="text">
<string>HD720 1280 x 720</string>
</property>
</item>
<item>
<property name="text" >
<property name="text">
<string>SXGA 1280 x 1024</string>
</property>
</item>
<item>
<property name="text" >
<property name="text">
<string>SXGA+ 1400 x 1050</string>
</property>
</item>
<item>
<property name="text" >
<property name="text">
<string>UXGA 1600 x 1200</string>
</property>
</item>
<item>
<property name="text" >
<property name="text">
<string>HD1080 1920 x 1080</string>
</property>
</item>
<item>
<property name="text" >
<property name="text">
<string>WUXGA 1920 x 1200</string>
</property>
</item>
<item>
<property name="text" >
<property name="text">
<string>QXGA 2048 x 1538</string>
</property>
</item>
<item>
<property name="text" >
<property name="text">
<string>WQXGA 2560 x 1600</string>
</property>
</item>
<item>
<property name="text" >
<property name="text">
<string>QSXGA 2560 x 2048</string>
</property>
</item>
<item>
<property name="text" >
<property name="text">
<string>QUXGA 3200 × 2400</string>
</property>
</item>
<item>
<property name="text" >
<property name="text">
<string>HUXGA 6400 × 4800</string>
</property>
</item>
<item>
<property name="text" >
<property name="text">
<string>!!! 10000 x 10000</string>
</property>
</item>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Standard sizes:</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<item row="0" column="1">
<spacer>
<property name="orientation" >
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
@@ -280,19 +372,19 @@
</property>
</spacer>
</item>
<item row="2" column="3" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<item row="2" column="3">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Pixel</string>
</property>
</widget>
</item>
<item row="2" column="1" >
<item row="2" column="1">
<spacer>
<property name="orientation" >
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
@@ -300,69 +392,78 @@
</property>
</spacer>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="textLabelHeight" >
<property name="text" >
<item row="2" column="0">
<widget class="QLabel" name="textLabelHeight">
<property name="text">
<string>&amp;Height:</string>
</property>
<property name="buddy" >
<property name="buddy">
<cstring>spinHeight</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<item row="1" column="0">
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="textLabel1" >
<property name="text" >
<widget class="QLabel" name="textLabel1">
<property name="text">
<string>Aspect ratio:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonRatioScreen" >
<property name="text" >
<widget class="QPushButton" name="buttonRatioScreen">
<property name="text">
<string>&amp;Screen</string>
</property>
<property name="shortcut" >
<property name="shortcut">
<string>Alt+S</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonRatio4x3" >
<property name="text" >
<widget class="QPushButton" name="buttonRatio4x3">
<property name="text">
<string>&amp;4:3</string>
</property>
<property name="shortcut" >
<property name="shortcut">
<string>Alt+4</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonRatio16x9" >
<property name="text" >
<widget class="QPushButton" name="buttonRatio16x9">
<property name="text">
<string>1&amp;6:9</string>
</property>
<property name="shortcut" >
<property name="shortcut">
<string>Alt+6</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonRatio1x1" >
<property name="text" >
<widget class="QPushButton" name="buttonRatio1x1">
<property name="text">
<string>&amp;1:1</string>
</property>
<property name="shortcut" >
<property name="shortcut">
<string>Alt+1</string>
</property>
</widget>
@@ -372,58 +473,28 @@
</layout>
</widget>
</item>
<item row="2" column="0" >
<widget class="QGroupBox" name="buttonGroupComment" >
<property name="enabled" >
<bool>false</bool>
<item row="2" column="0">
<widget class="QGroupBox" name="groupBoxMethod">
<property name="title">
<string>Method</string>
</property>
<property name="title" >
<string>Image comment</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="0" >
<widget class="QRadioButton" name="radioButtonMiba" >
<property name="text" >
<string>Insert MIBA</string>
</property>
<property name="checked" >
<bool>true</bool>
<layout class="QGridLayout" name="gridLayoutMethod">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Creation method:</string>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QTextEdit" name="textEditComment" >
<property name="enabled" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QRadioButton" name="radioButtonComment" >
<property name="text" >
<string>Insert comment</string>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QCheckBox" name="checkWatermark" >
<property name="text" >
<string>Add watermark</string>
</property>
</widget>
<item row="0" column="1">
<widget class="QComboBox" name="comboMethod"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
<layoutdefault spacing="6" margin="11"/>
<tabstops>
<tabstop>standardSizeBox</tabstop>
<tabstop>spinWidth</tabstop>
@@ -445,11 +516,11 @@
<receiver>textEditComment</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<hint type="sourcelabel">
<x>35</x>
<y>262</y>
</hint>
<hint type="destinationlabel" >
<hint type="destinationlabel">
<x>39</x>
<y>316</y>
</hint>

View File

@@ -46,6 +46,14 @@ DlgSettingsImageImp::DlgSettingsImageImp( QWidget* parent )
_width = width();
_height = height();
_fRatio = (float)_width/(float)_height;
comboMethod->addItem(tr("Offscreen (New)"), QByteArray("QtOffscreenRenderer"));
comboMethod->addItem(tr("Offscreen (Old)"), QByteArray("CoinOffscreenRenderer"));
comboMethod->addItem(tr("Framebuffer (custom)"), QByteArray("FramebufferObject"));
comboMethod->addItem(tr("Framebuffer (as is)"), QByteArray("GrabFramebuffer"));
#if QT_VERSION < 0x050000
comboMethod->addItem(tr("Pixel buffer"), QByteArray("PixelBuffer"));
#endif
}
/**
@@ -221,4 +229,27 @@ void DlgSettingsImageImp::on_standardSizeBox_activated(int index)
}
}
void DlgSettingsImageImp::setMethod(const QByteArray& m)
{
int index = comboMethod->findData(m);
if (index >= 0)
comboMethod->setCurrentIndex(index);
}
QByteArray DlgSettingsImageImp::method() const
{
return comboMethod->currentData().toByteArray();
}
void DlgSettingsImageImp::on_comboMethod_activated(int index)
{
QByteArray data = comboMethod->itemData(index).toByteArray();
if (data == QByteArray("GrabFramebuffer")) {
groupBoxProp->setEnabled(false);
}
else {
groupBoxProp->setEnabled(true);
}
}
#include "moc_DlgSettingsImageImp.cpp"

View File

@@ -55,6 +55,8 @@ public:
/** @name Image meta information */
//@{
void setMethod(const QByteArray&);
QByteArray method() const;
QString comment() const;
int backgroundType() const;
void setBackgroundType( int );
@@ -70,6 +72,7 @@ protected Q_SLOTS:
void on_buttonRatio16x9_clicked();
void on_buttonRatio1x1_clicked();
void on_standardSizeBox_activated(int);
void on_comboMethod_activated(int);
protected:
// helper to force an aspect ratio