Skip to content
This repository was archived by the owner on May 15, 2024. It is now read-only.

Commit 0896432

Browse files
committed
Remove unneccessary method FFuLabel::setLabelAlignment().
Simplify FFuLabel::setPixMap() to also set the scaling property. Fix opening of URLs with https (in addition to http).
1 parent ef38538 commit 0896432

File tree

8 files changed

+24
-42
lines changed

8 files changed

+24
-42
lines changed

src/FFuLib/FFuLabel.H

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ public:
2020

2121
// Methods to set what to show :
2222

23-
virtual void setPixMap(const char** pixmap, int width = 0, int height = 0) = 0;
23+
virtual void setPixMap(const char** pixmap, bool stretch = false) = 0;
2424
virtual void setLabel(const char* label) = 0;
25-
virtual void setLabel(const std::string& label) = 0;
26-
virtual void setLabelAlignment(int align) = 0;
25+
26+
void setLabel(const std::string& label) { this->setLabel(label.c_str()); }
2727

2828
// Get the text of the label :
2929

src/FFuLib/FFuQtComponents/FFuQtLabel.C

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,11 @@ FFuQtLabel::FFuQtLabel(QWidget* parent) : QLabel(parent)
2020
}
2121

2222

23-
void FFuQtLabel::setPixMap(const char** pixmap, int width, int height)
23+
void FFuQtLabel::setPixMap(const char** pixmap, bool stretch)
2424
{
2525
if (pixmap) {
26-
QPixmap xpm(pixmap);
27-
if (width > 0 && height > 0)
28-
this->QLabel::setPixmap(xpm.scaled(width,height));
29-
else if (width > 0)
30-
this->QLabel::setPixmap(xpm.scaledToWidth(width));
31-
else if (height > 0)
32-
this->QLabel::setPixmap(xpm.scaledToHeight(height));
33-
else
34-
this->QLabel::setPixmap(xpm);
26+
this->setScaledContents(stretch);
27+
this->QLabel::setPixmap(QPixmap(pixmap));
3528
}
3629
else
3730
this->QLabel::clear();
@@ -43,21 +36,13 @@ void FFuQtLabel::setLabel(const char* label)
4336
this->setText(label);
4437
}
4538

46-
void FFuQtLabel::setLabel(const std::string& label)
47-
{
48-
this->setText(label.c_str());
49-
}
50-
51-
void FFuQtLabel::setLabelAlignment(int alignment)
52-
{
53-
this->setAlignment(static_cast<Qt::Alignment>(alignment));
54-
}
5539

5640
std::string FFuQtLabel::getLabel() const
5741
{
5842
return this->text().toStdString();
5943
}
6044

45+
6146
void FFuQtLabel::fwdLinkActivated(const QString& txt)
6247
{
6348
myLinkActivatedCB.invoke(txt.toStdString());

src/FFuLib/FFuQtComponents/FFuQtLabel.H

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ public:
2323
FFuQtLabel(QWidget* parent = NULL);
2424
virtual ~FFuQtLabel() {}
2525

26-
virtual void setPixMap(const char** pixmap, int width = 0, int height = 0);
26+
virtual void setPixMap(const char** pixmap, bool stretch);
2727
virtual void setLabel(const char* label);
28-
virtual void setLabel(const std::string& label);
29-
virtual void setLabelAlignment(int align);
28+
3029
virtual std::string getLabel() const;
3130

3231
public slots:

src/vpmUI/vpmUITopLevels/FuiAdvAnalysisOptions.C

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,6 @@ void FuiAdvAnalysisOptions::initWidgets()
406406
this->autoCurveExportField->setFileOpenedCB(FFaDynCB2M(FuiAdvAnalysisOptions,this,
407407
onAutoCurveExportFileChanged,const std::string&,int));
408408

409-
this->labels[OUTPUTOPTIONS][AUTO_CURVE_EXPORT]->setLabelAlignment(FFuaTextAlignment::AlignRight);
410-
411409
this->toggleButtons[OUTPUTOPTIONS][AUTO_VTF_EXPORT]->setLabel("Automatic export to GLview VTF file");
412410
this->toggleButtons[OUTPUTOPTIONS][AUTO_VTF_EXPORT]->setToggleCB(FFaDynCB1M(FFuComponentBase,autoVTFField,
413411
setSensitivity,bool));

src/vpmUI/vpmUITopLevels/FuiObjectBrowser.C

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ FuiObjectBrowser::FuiObjectBrowser()
3737

3838
void FuiObjectBrowser::initWidgets()
3939
{
40-
this->headerImage1->setPixMap(objectBrowser1_xpm);
41-
this->headerImage2->setPixMap(objectBrowser2_xpm);
40+
this->headerImage1->setPixMap(objectBrowser1_xpm, false);
41+
this->headerImage2->setPixMap(objectBrowser2_xpm, true);
4242

4343
this->searchLabel->setLabel("Search and browse objects:");
4444

src/vpmUI/vpmUITopLevels/vpmUIQtTopLevels/FuiQtAdvAnalysisOptions.C

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,9 @@ FuiQtAdvAnalysisOptions::FuiQtAdvAnalysisOptions(QWidget* parent,
215215

216216
// Output options
217217
#ifdef FT_HAS_SOLVERS
218-
this->labels[OUTPUTOPTIONS][AUTO_CURVE_EXPORT] = new FFuQtLabel(myOptions[OUTPUTOPTIONS]);
218+
FFuQtLabel* qlab;
219+
this->labels[OUTPUTOPTIONS][AUTO_CURVE_EXPORT] = qlab = new FFuQtLabel(myOptions[OUTPUTOPTIONS]);
220+
qlab->setAlignment(Qt::AlignRight);
219221
this->toggleButtons[OUTPUTOPTIONS][AUTO_CURVE_EXPORT] = new FFuQtToggleButton(myOptions[OUTPUTOPTIONS]);
220222
this->toggleButtons[OUTPUTOPTIONS][AUTO_VTF_EXPORT] = new FFuQtToggleButton(myOptions[OUTPUTOPTIONS]);
221223
this->toggleButtons[OUTPUTOPTIONS][AUTO_ANIM] = new FFuQtToggleButton(myOptions[OUTPUTOPTIONS]);

src/vpmUI/vpmUITopLevels/vpmUIQtTopLevels/FuiQtObjectBrowser.C

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ FuiQtObjectBrowser::FuiQtObjectBrowser(int xpos, int ypos,
4545
this->helpButton = new FFuQtPushButton(this);
4646
this->sepLabel = new FFuQtLabel(this);
4747
this->copyDataButton = new FFuQtPushButton(this);
48-
((FFuQtLabel*)headerImage2)->setScaledContents(true); // stretch the picture
4948

5049
this->initWidgets();
5150
}

src/vpmUI/vpmUITopLevels/vpmUIQtTopLevels/FuiQtProperties.C

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -377,15 +377,14 @@ FuiQtProperties::FuiQtProperties(QWidget* parent,
377377
mySGLogoBorderTop = new FFuQtLabel(this);
378378
mySGLogoBorderRight = new FFuQtLabel(this);
379379
mySGFillWhite = new FFuQtLabel(this);
380-
mySGContentLabel = new FFuQtLabel(this);
381380
mySGHeading = new FFuQtLabel(this);
382381
mySGBorderRight = new FFuQtLabel(this);
383382
mySGBorderBottom = new FFuQtLabel(this);
384383
mySGBorderTop = new FFuQtLabel(this);
385-
((FFuQtLabel*)mySGLogoImage)->setScaledContents(true); // stretch the picture
386-
((FFuQtLabel*)mySGLogoBorderRight)->setScaledContents(true); // stretch the picture
387-
((FFuQtLabel*)mySGBorderTop)->setScaledContents(true); // stretch the picture
388-
((FFuQtLabel*)mySGContentLabel)->setAlignment(Qt::AlignTop|Qt::AlignLeft); // set alignment
384+
385+
FFuQtLabel* qlab;
386+
mySGContentLabel = qlab = new FFuQtLabel(this);
387+
qlab->setAlignment(Qt::AlignTop|Qt::AlignLeft);
389388

390389
// Parent class component initiation
391390

@@ -454,7 +453,7 @@ static void onURLActivated(const std::string& url)
454453
FFaMsg::dialog("Invalid URL:\n" + url, FFaMsg::WARNING);
455454
else if (strUrl.left(7) == "file://")
456455
showPDFfile(strUrl);
457-
else if (strUrl.left(7) == "http://")
456+
else if (strUrl.left(8) == "https://" || strUrl.left(7) == "http://")
458457
if (!QDesktopServices::openUrl(objUrl))
459458
FFaMsg::dialog("Unable to open URL:\n" + url, FFaMsg::WARNING);
460459
}
@@ -506,25 +505,25 @@ bool FuiQtProperties::initStartGuide(FedemEdition edition)
506505
strData.replace(" src='", " src='" + appPath);
507506
// Set fields
508507
if (edition == Windpower) {
509-
mySGLogoImage->setPixMap(startGuideLogoWP_xpm);
508+
mySGLogoImage->setPixMap(startGuideLogoWP_xpm,true);
510509
mySGHeading->setLabel("<font color='#008cff' size='5'><i><b>Welcome to FEDEM Windpower 8.0</b></i></font>");
511510
}
512511
else if (edition == Offshore) {
513-
mySGLogoImage->setPixMap(startGuideLogo_xpm);
512+
mySGLogoImage->setPixMap(startGuideLogo_xpm,true);
514513
mySGHeading->setLabel("<font color='#008cff' size='5'><i><b>Welcome to FEDEM Offshore 8.0</b></i></font>");
515514
}
516515
else {
517-
mySGLogoImage->setPixMap(startGuideLogo_xpm);
516+
mySGLogoImage->setPixMap(startGuideLogo_xpm,true);
518517
mySGHeading->setLabel("<font color='#008cff' size='5'><i><b>Welcome to FEDEM 8.0</b></i></font>");
519518
}
520519
mySGContentLabel->setLabel(strData);
521520
mySGContentLabel->setLinkActivatedCB(FFaDynCB1S(onURLActivated,const std::string&));
522-
mySGLogoBorderRight->setPixMap(startGuideBorderRight_xpm);
521+
mySGLogoBorderRight->setPixMap(startGuideBorderRight_xpm,true);
523522
FFuaPalette pal;
524523
pal.setStdBackground(255,255,255);
525524
mySGFillWhite->setColors(pal);
526525
mySGContentLabel->setColors(pal);
527-
mySGBorderTop->setPixMap(startGuideBorderTop_xpm);
526+
mySGBorderTop->setPixMap(startGuideBorderTop_xpm,true);
528527
pal.setStdBackground(130,135,144);
529528
mySGBorderRight->setColors(pal);
530529
mySGBorderBottom->setColors(pal);

0 commit comments

Comments
 (0)