8 #include <QtGui/QColor>
9 #include <QtGui/QDoubleValidator>
10 #include <QtGui/QPalette>
19 double currentX,
double currentY,
double currentWidth,
double currentHeight,
unsigned int imageWidth,
unsigned int imageHeight,
20 int lastFrame, QWidget* pParent):
24 mLayoutWidth(layoutWidth),
25 mLayoutHeight(layoutHeight),
28 mCurrentWidth(currentWidth),
29 mCurrentHeight(currentHeight),
33 mWidth(mCurrentWidth),
34 mHeight(mCurrentHeight),
35 mImageWidth(imageWidth),
36 mImageHeight(imageHeight),
37 mDrawSelectionDecorations(false),
38 mLastFrame(lastFrame),
39 mFramesEditHighlighted(false)
42 QPalette palette = this->mpFramesEdit->palette();
43 this->
mDefaultColor = palette.color(this->mpFramesEdit->backgroundRole());
47 this->mpFramesEdit->setEnabled(
false);
50 this->mpFramesWidget->setEnabled(this->
mLastFrame > 0);
51 this->mpFramesWidget->setVisible(this->
mLastFrame > 0);
54 this->mpAdvancedWidget->setVisible(
false);
59 this->mpFramesEdit->setValidator(pFrameVal);
62 QButtonGroup* pFrameButtonGroup =
new QButtonGroup(
this);
63 pFrameButtonGroup->addButton(this->mpCurrentFrameButton);
64 pFrameButtonGroup->addButton(this->mpAllFramesButton);
65 pFrameButtonGroup->addButton(this->mpFramesButton);
66 pFrameButtonGroup->setExclusive(
true);
67 connect(pFrameButtonGroup, SIGNAL(buttonClicked(QAbstractButton*)),
this, SLOT(
slotFrameButtonClicked(QAbstractButton*)));
70 QButtonGroup* pDisplayButtonGroup =
new QButtonGroup(
this);
71 pDisplayButtonGroup->addButton(this->mpCompleteButton);
72 pDisplayButtonGroup->addButton(this->mpVisibleButton);
73 pDisplayButtonGroup->addButton(this->mpCustomButton);
74 pDisplayButtonGroup->setExclusive(
true);
75 connect(pDisplayButtonGroup, SIGNAL(buttonClicked(QAbstractButton*)),
this, SLOT(
slotDisplayButtonClicked(QAbstractButton*)));
79 QDoubleValidator* pVal =
new QDoubleValidator(this->mpXLineEdit);
80 this->mpXLineEdit->setValidator(pVal);
81 this->mpXLineEdit->setText(QString(
"%1").arg(this->
mCurrentX));
82 pVal =
new QDoubleValidator(this->mpYLineEdit);
83 this->mpYLineEdit->setValidator(pVal);
84 this->mpXLineEdit->setText(QString(
"%1").arg(this->
mCurrentY));
85 pVal =
new QDoubleValidator(this->mpWidthLineEdit);
87 this->mpWidthLineEdit->setValidator(pVal);
88 this->mpWidthLineEdit->setText(QString(
"%1").arg(this->
mCurrentWidth));
89 pVal =
new QDoubleValidator(this->mpHeightLineEdit);
91 this->mpHeightLineEdit->setValidator(pVal);
92 this->mpHeightLineEdit->setText(QString(
"%1").arg(this->
mCurrentHeight));
95 std::ostringstream os;
98 this->visible_area_label->setText(QString(os.str().c_str()));
102 this->layout_area_label->setText(QString(os.str().c_str()));
104 this->mpXLineEdit->setText(QString(
"%1").arg(this->
mX));
105 this->mpYLineEdit->setText(QString(
"%1").arg(this->
mY));
106 this->mpWidthLineEdit->setText(QString(
"%1").arg(this->
mWidth));
107 this->mpHeightLineEdit->setText(QString(
"%1").arg(this->
mHeight));
108 this->mpImageWidthSpinbox->setValue(this->
mImageWidth);
109 this->mpImageHeightSpinbox->setValue(this->
mImageHeight);
115 this->mpKeepImageAspectCheckbox->setChecked(
false);
116 this->mpKeepImageAspectCheckbox->setEnabled(
false);
122 if (this->
mCurrentWidth == 0.0 || this->mCurrentHeight == 0.0)
124 this->mpKeepAreaAspectCheckbox->setChecked(
false);
125 this->mpKeepAreaAspectCheckbox->setEnabled(
false);
128 connect(this->mpImageWidthSpinbox, SIGNAL(valueChanged(
int)),
this, SLOT(
slotImageWidthChanged(
int)));
130 connect(this->mpWidthLineEdit, SIGNAL(textChanged(
const QString&)),
this, SLOT(
slotWidthChanged(
const QString&)));
131 connect(this->mpHeightLineEdit, SIGNAL(textChanged(
const QString&)),
this, SLOT(
slotHeightChanged(
const QString&)));
132 connect(this->mpXLineEdit, SIGNAL(textChanged(
const QString&)),
this, SLOT(
slotXChanged(
const QString&)));
133 connect(this->mpYLineEdit, SIGNAL(textChanged(
const QString&)),
this, SLOT(
slotYChanged(
const QString&)));
135 connect(this->mpFramesEdit, SIGNAL(textEdited(
const QString&)),
this, SLOT(
slotFramesTextEdited(
const QString&)));
199 this->QDialog::accept();
205 if (pButton == this->mpCustomButton)
207 this->mpAdvancedWidget->setEnabled(
true);
208 this->mpAdvancedWidget->setVisible(
true);
211 this->
mX = this->mpXLineEdit->text().toDouble();
212 this->
mY = this->mpYLineEdit->text().toDouble();
214 this->
mWidth = this->mpWidthLineEdit->text().toDouble();
215 this->
mHeight = this->mpHeightLineEdit->text().toDouble();
219 this->mpAdvancedWidget->setVisible(
false);
222 if (pButton == this->mpVisibleButton)
266 if (pButton == this->mpCurrentFrameButton)
269 this->mpFramesEdit->setEnabled(
false);
271 else if (pButton == this->mpAllFramesButton)
274 this->mpFramesEdit->setEnabled(
false);
276 else if (pButton == this->mpFramesButton)
279 this->mpFramesEdit->setEnabled(
true);
287 if (this->mpKeepImageAspectCheckbox->isChecked())
290 int h = (int)(round(w * aspect));
291 disconnect(this->mpImageHeightSpinbox, SIGNAL(valueChanged(
int)),
this, SLOT(
slotImageHeightChanged(
int)));
292 this->mpImageHeightSpinbox->setValue(h);
301 if ((this->
mImageWidth == 0 || this->
mImageHeight == 0) && (this->mpKeepImageAspectCheckbox->isEnabled() || this->mpKeepImageAspectCheckbox->isChecked()))
303 this->mpKeepImageAspectCheckbox->setChecked(
false);
304 this->mpKeepImageAspectCheckbox->setEnabled(
false);
306 else if (this->mpKeepImageAspectCheckbox->isEnabled() ==
false)
308 this->mpKeepImageAspectCheckbox->setEnabled(
true);
316 if (this->mpKeepImageAspectCheckbox->isChecked())
319 int w = (int)(round(h * aspect));
320 disconnect(this->mpImageWidthSpinbox, SIGNAL(valueChanged(
int)),
this, SLOT(
slotImageWidthChanged(
int)));
321 this->mpImageWidthSpinbox->setValue(w);
323 connect(this->mpImageWidthSpinbox, SIGNAL(valueChanged(
int)),
this, SLOT(
slotImageWidthChanged(
int)));
330 if ((this->
mImageWidth == 0 || this->
mImageHeight == 0) && (this->mpKeepImageAspectCheckbox->isEnabled() || this->mpKeepImageAspectCheckbox->isChecked()))
332 this->mpKeepImageAspectCheckbox->setChecked(
false);
333 this->mpKeepImageAspectCheckbox->setEnabled(
false);
335 else if (this->mpKeepImageAspectCheckbox->isEnabled() ==
false)
337 this->mpKeepImageAspectCheckbox->setEnabled(
true);
344 double newWidth = wt.toDouble();
347 if (this->mpKeepAreaAspectCheckbox->isChecked())
349 double aspect = (double)this->
mHeight / (
double)this->
mWidth;
350 double h = newWidth * aspect;
351 disconnect(this->mpHeightLineEdit, SIGNAL(textChanged(
const QString&)),
this, SLOT(
slotHeightChanged(
const QString&)));
352 this->mpHeightLineEdit->setText(QString(
"%1").arg(h));
354 connect(this->mpHeightLineEdit, SIGNAL(textChanged(
const QString&)),
this, SLOT(
slotHeightChanged(
const QString&)));
361 if ((this->
mWidth == 0.0 || this->
mHeight == 0.0) && (this->mpKeepAreaAspectCheckbox->isEnabled() || this->mpKeepAreaAspectCheckbox->isChecked()))
363 this->mpKeepAreaAspectCheckbox->setChecked(
false);
364 this->mpKeepAreaAspectCheckbox->setEnabled(
false);
366 else if (this->mpKeepAreaAspectCheckbox->isEnabled() ==
false)
368 this->mpKeepAreaAspectCheckbox->setEnabled(
true);
375 double newHeight = ht.toDouble();
378 if (this->mpKeepAreaAspectCheckbox->isChecked())
380 double aspect = (double)this->
mWidth / (
double)this->
mHeight;
381 double w = newHeight * aspect;
382 disconnect(this->mpWidthLineEdit, SIGNAL(textChanged(
const QString&)),
this, SLOT(
slotWidthChanged(
const QString&)));
383 this->mpWidthLineEdit->setText(QString(
"%1").arg(w));
385 connect(this->mpWidthLineEdit, SIGNAL(textChanged(
const QString&)),
this, SLOT(
slotWidthChanged(
const QString&)));
392 if ((this->
mWidth == 0.0 || this->
mHeight == 0.0) && (this->mpKeepAreaAspectCheckbox->isEnabled() || this->mpKeepAreaAspectCheckbox->isChecked()))
394 this->mpKeepAreaAspectCheckbox->setChecked(
false);
395 this->mpKeepAreaAspectCheckbox->setEnabled(
false);
397 else if (this->mpKeepAreaAspectCheckbox->isEnabled() ==
false)
399 this->mpKeepAreaAspectCheckbox->setEnabled(
true);
406 this->
mX = xt.toDouble();
412 this->
mY = yt.toDouble();
427 mpFramesEdit->setStyleSheet(QString(mpFramesEdit->metaObject()->className()) +
" {background-color:" +
mDefaultColor.name() +
";}");
433 mpFramesEdit->setStyleSheet(QString(mpFramesEdit->metaObject()->className()) +
" {background-color:" +
mHighlightColor.name() +
";}");
441 QString yt = this->mpFramesEdit->text();
446 const QString number(
"^[0-9]+$");
447 QRegExp numberRegExp(number);
448 numberRegExp.setPatternSyntax(QRegExp::RegExp2);
449 const QString closed(
"^([0-9]+)\\s*-\\s*([0-9]+)$");
450 QRegExp closedRegExp(closed);
451 closedRegExp.setPatternSyntax(QRegExp::RegExp2);
452 const QString start(
"^([0-9]+)\\s*-$");
453 QRegExp startRegExp(start);
454 startRegExp.setPatternSyntax(QRegExp::RegExp2);
455 const QString end(
"^-\\s*([0-9]+)$");
456 QRegExp endRegExp(end);
457 endRegExp.setPatternSyntax(QRegExp::RegExp2);
465 QStringList l = yt.split(QString(
","), QString::SkipEmptyParts);
466 int i, iMax = l.size();
471 for (i = 0; i < iMax; ++i)
477 if (numberRegExp.exactMatch(s1))
479 QStringList l2 = numberRegExp.capturedTexts();
480 assert(l2.size() == 1);
484 unsigned int n = l2[0].toUInt();
492 else if (closedRegExp.exactMatch(s1))
494 QStringList l2 = closedRegExp.capturedTexts();
495 assert(l2.size() == 3);
499 unsigned int n1 = l2[1].toUInt();
500 unsigned int n2 = l2[2].toUInt();
505 n2 = (n2 > (
unsigned int)this->mLastFrame) ? (
unsigned int)this->mLastFrame : n2;
515 else if (startRegExp.exactMatch(s1))
517 QStringList l2 = startRegExp.capturedTexts();
518 assert(l2.size() == 2);
522 unsigned int n = l2[1].toUInt();
527 while (n <= (
unsigned int)this->mLastFrame)
535 else if (endRegExp.exactMatch(s1))
537 QStringList l2 = endRegExp.capturedTexts();
538 assert(l2.size() == 2);
542 unsigned int n = l2[1].toUInt();
573 , mValidationRegExp(ValidRegExpString)
574 , mIntermediateRegExp(IntermediateRegExpString)
575 , mClosedRangeGroupRegExp(ClosedRangeGroupRegExpString)
585 QValidator::State state = QValidator::Invalid;
589 state = QValidator::Acceptable;
592 for (
int i = 0; i < l.size() && state != QValidator::Invalid; ++i)
598 assert(l2.size() == 3);
600 if (l2.size() != 3 || (l2.size() == 3 && l2[1].toUInt() > l2[2].toUInt()))
602 state = QValidator::Intermediate;
611 state = QValidator::Intermediate;
void slotDrawSelectionToggled(bool v)
void slotHeightChanged(const QString &ht)
bool isSetDrawSelectionDecoration() const
void slotFrameButtonClicked(QAbstractButton *pButton)
void slotYChanged(const QString &yt)
unsigned int getImageWidth() const
void slotFramesTextEdited(const QString &text)
CQScreenshotOptionsDialog(double layoutX, double layoutY, double layoutWidth, double layoutHeight, double currentX, double currentY, double currentWidth, double currentHeight, unsigned int imageWidth, unsigned int imageHeight, int lastFrame=-1, QWidget *pParent=NULL)
std::set< size_t > mFrames
FRAME_OPTION mFrameOption
void slotImageWidthChanged(int w)
unsigned int getImageHeight() const
bool mFramesEditHighlighted
bool mDrawSelectionDecorations
FRAME_OPTION getFrameOption() const
void slotImageHeightChanged(int h)
void slotWidthChanged(const QString &wt)
void slotFramesTextEditingFinished()
void slotDisplayButtonClicked(QAbstractButton *pButton)
void slotXChanged(const QString &xt)
unsigned int mImageHeight
const std::set< size_t > & getFrameSet() const