DlgSettingsImageImp.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "PreCompiled.h"
00025
00026 #include "DlgSettingsImageImp.h"
00027 #include "SpinBox.h"
00028
00029 using namespace Gui::Dialog;
00030 using namespace std;
00031
00032
00033
00038 DlgSettingsImageImp::DlgSettingsImageImp( QWidget* parent )
00039 : QWidget( parent )
00040 {
00041 this->setupUi(this);
00042 SbVec2s res = SoOffscreenRenderer::getMaximumResolution();
00043 spinWidth->setMaximum((int)res[0]);
00044 spinHeight->setMaximum((int)res[1]);
00045
00046 _width = width();
00047 _height = height();
00048 _fRatio = (float)_width/(float)_height;
00049 }
00050
00054 DlgSettingsImageImp::~DlgSettingsImageImp()
00055 {
00056
00057 }
00058
00059 void DlgSettingsImageImp::changeEvent(QEvent *e)
00060 {
00061 if (e->type() == QEvent::LanguageChange) {
00062 this->retranslateUi(this);
00063 }
00064 QWidget::changeEvent(e);
00065 }
00066
00070 void DlgSettingsImageImp::setImageSize(int w, int h)
00071 {
00072
00073 standardSizeBox->setItemData(0, QSize(w,h));
00074
00075 spinWidth->setValue(w);
00076 spinHeight->setValue(h);
00077
00078
00079 _width = w;
00080 _height = h;
00081 _fRatio = (float)_width/(float)_height;
00082 }
00083
00087 void DlgSettingsImageImp::setImageSize( const QSize& s )
00088 {
00089
00090 standardSizeBox->setItemData(0, s);
00091
00092 spinWidth->setValue( s.width() );
00093 spinHeight->setValue( s.height() );
00094
00095
00096 _width = s.width();
00097 _height = s.height();
00098 _fRatio = (float)_width/(float)_height;
00099 }
00100
00104 QSize DlgSettingsImageImp::imageSize() const
00105 {
00106 return QSize( spinWidth->value(), spinHeight->value() );
00107 }
00108
00112 int DlgSettingsImageImp::imageWidth() const
00113 {
00114 return spinWidth->value();
00115 }
00116
00120 int DlgSettingsImageImp::imageHeight() const
00121 {
00122 return spinHeight->value();
00123 }
00124
00129 QString DlgSettingsImageImp::comment() const
00130 {
00131 if ( !textEditComment->isEnabled() )
00132 return QString::null;
00133 else
00134 return textEditComment->toPlainText();
00135 }
00136
00137 int DlgSettingsImageImp::backgroundType() const
00138 {
00139 return comboBackground->currentIndex();
00140 }
00141
00142 void DlgSettingsImageImp::onSelectedFilter(const QString& filter)
00143 {
00144 bool ok = (filter.startsWith(QLatin1String("JPG")) ||
00145 filter.startsWith(QLatin1String("JPEG")) ||
00146 filter.startsWith(QLatin1String("PNG")));
00147 buttonGroupComment->setEnabled( ok );
00148 }
00149
00150 void DlgSettingsImageImp::adjustImageSize(float fRatio)
00151 {
00152
00153 if (_height != spinHeight->value())
00154 {
00155 _height = spinHeight->value();
00156 _width = (int)((float)_height*fRatio);
00157 spinWidth->setValue( (int)_width );
00158 }
00159 else
00160 {
00161 _width = spinWidth->value();
00162 _height = (int)((float)_width/fRatio);
00163 spinHeight->setValue( (int)_height );
00164 }
00165 }
00166
00167 void DlgSettingsImageImp::on_buttonRatioScreen_clicked()
00168 {
00169 adjustImageSize(_fRatio);
00170 }
00171
00172 void DlgSettingsImageImp::on_buttonRatio4x3_clicked()
00173 {
00174 adjustImageSize(4.0f/3.0f);
00175 }
00176
00177 void DlgSettingsImageImp::on_buttonRatio16x9_clicked()
00178 {
00179 adjustImageSize(16.0f/9.0f);
00180 }
00181
00182 void DlgSettingsImageImp::on_buttonRatio1x1_clicked()
00183 {
00184 adjustImageSize(1.0f);
00185 }
00186
00187 void DlgSettingsImageImp::on_standardSizeBox_activated(int index)
00188 {
00189 if (index == 0) {
00190
00191 QSize s = standardSizeBox->itemData(0).toSize();
00192 spinWidth->setValue(s.width());
00193 spinHeight->setValue(s.height());
00194 }
00195 else {
00196
00197 QString text = standardSizeBox->itemText(index);
00198 QRegExp rx(QLatin1String("\\b\\d{2,4}\\b"));
00199 int pos = 0;
00200 pos = rx.indexIn(text, pos);
00201 QString w = text.mid(pos, rx.matchedLength());
00202 spinWidth->setValue(w.toInt());
00203 pos += rx.matchedLength();
00204 pos = rx.indexIn(text, pos);
00205 QString h = text.mid(pos, rx.matchedLength());
00206 spinHeight->setValue(h.toInt());
00207 }
00208 }
00209
00210 #include "moc_DlgSettingsImageImp.cpp"