Skip to content

Commit caf9638

Browse files
Cleaned up plugin repo dialog UI
1 parent 8985c47 commit caf9638

2 files changed

Lines changed: 47 additions & 43 deletions

File tree

FEBioStudio/DlgPluginRepo.cpp

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,9 @@ class Ui::CDlgPluginRepo
289289
QLabel* downloadNumberLabel;
290290
QLabel* errorLabel;
291291
QLabel* nameLabel;
292-
QLabel* byLabel;
293-
QLabel* ownerLabel;
292+
// QLabel* byLabel;
294293
QLabel* descriptionLabel;
294+
QLabel* ownerLabel;
295295
QLabel* tagLabel;
296296
CFrameButton* downloadButton;
297297
CFrameButton* downloadingButton;
@@ -445,32 +445,12 @@ class Ui::CDlgPluginRepo
445445
errorLabel->setWordWrap(true);
446446
pluginRightLayout->addWidget(errorLabel);
447447

448-
QHBoxLayout* nameLayout = new QHBoxLayout;
449-
nameLayout->setContentsMargins(0, 0, 0, 0);
450-
451-
nameLayout->addWidget(nameLabel = new QLabel);
448+
pluginRightLayout->addWidget(nameLabel = new QLabel);
452449
QFont nameFont = nameLabel->font();
453450
nameFont.setBold(true);
454451
nameFont.setPointSize(18);
455452
nameLabel->setFont(nameFont);
456453

457-
byLabel = new QLabel("by");
458-
QFont byFont = byLabel->font();
459-
byFont.setPointSize(18);
460-
byLabel->setFont(byFont);
461-
462-
nameLayout->addWidget(byLabel);
463-
464-
nameLayout->addWidget(ownerLabel = new QLabel);
465-
QFont font2 = ownerLabel->font();
466-
font2.setItalic(true);
467-
font2.setPointSize(18);
468-
ownerLabel->setFont(font2);
469-
470-
nameLayout->addStretch();
471-
472-
pluginRightLayout->addLayout(nameLayout);
473-
474454
QScrollArea* scrollArea = new QScrollArea;
475455
scrollArea->setWidgetResizable(true);
476456
scrollArea->setFrameShape(QFrame::NoFrame);
@@ -483,6 +463,9 @@ class Ui::CDlgPluginRepo
483463

484464
scrollLayout->addWidget(publicationWidget = new ::CPublicationWidgetView(::CPublicationWidgetView::LIST, false));
485465

466+
scrollLayout->addWidget(ownerLabel = new QLabel);
467+
ownerLabel->setWordWrap(true);
468+
486469
scrollLayout->addWidget(tagLabel = new QLabel);
487470
tagLabel->setWordWrap(true);
488471

@@ -522,15 +505,15 @@ class Ui::CDlgPluginRepo
522505
buttonBar->addWidget(loadLocalButton = new QPushButton("Load Local Plugin"));
523506
loadLocalButton->setFocusPolicy(Qt::NoFocus);
524507

525-
buttonBar->addWidget(submitPluginButton = new QPushButton("Sumbit a Plugin to the Repository"));
526-
submitPluginButton->setFocusPolicy(Qt::NoFocus);
527-
528508
buttonBar->addWidget(writeConfigButton = new QPushButton("Save FEBio Config File"));
529509
writeConfigButton->setFocusPolicy(Qt::NoFocus);
530510
writeConfigButton->setToolTip("Writes the current plugin configuration to an FEBio config file. "
531511
"This allows you to easily load these plugins into FEBio when launched from the command line by "
532512
"referencing the config file.");
533513

514+
buttonBar->addWidget(submitPluginButton = new QPushButton("Sumbit a Plugin to the Repository"));
515+
submitPluginButton->setFocusPolicy(Qt::NoFocus);
516+
534517
QWidget* spacer = new QWidget();
535518
spacer->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
536519
buttonBar->addWidget(spacer);
@@ -602,8 +585,8 @@ class Ui::CDlgPluginRepo
602585
if(id > 0)
603586
{
604587
nameLabel->setText(plugin->name.c_str());
605-
byLabel->show();
606-
ownerLabel->setText(plugin->owner.c_str());
588+
ownerLabel->setText(QString("Author: ") + plugin->owner.c_str());
589+
ownerLabel->show();
607590
downloadLabel->show();
608591
downloadNumberLabel->setText(QString::number(plugin->downloads));
609592
downloadNumberLabel->show();
@@ -626,8 +609,7 @@ class Ui::CDlgPluginRepo
626609
else
627610
{
628611
nameLabel->setText(plugin->name.c_str());
629-
byLabel->hide();
630-
ownerLabel->setText("");
612+
ownerLabel->hide();
631613
downloadLabel->hide();
632614
downloadNumberLabel->hide();
633615
descriptionLabel->setText(QString::fromStdString( plugin->description + "\n\nPath: " + plugin->files[0]));

FEBioStudio/PluginListWidget.cpp

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,38 @@ SOFTWARE.*/
3535
#include <QResizeEvent>
3636
#include <QPixmap>
3737
#include <QPainter>
38+
#include <QScrollBar>
3839
#include "PluginListWidget.h"
3940
#include "PluginManager.h"
4041
#include "DlgPluginRepo.h"
4142

43+
// A custom scroll area that only shows a vertical scrollbar, and resizes the viewport to fit the width of the contents
44+
class VerticalScrollArea : public QScrollArea
45+
{
46+
public:
47+
explicit VerticalScrollArea(QWidget *parent = nullptr)
48+
{
49+
setWidgetResizable(true);
50+
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
51+
setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
52+
}
53+
54+
bool eventFilter(QObject *o, QEvent *e) override
55+
{
56+
// This works because QScrollArea::setWidget installs an eventFilter on the widget
57+
if(o && o == widget() && e->type() == QEvent::Resize)
58+
setMinimumWidth(widget()->minimumSizeHint().width() + verticalScrollBar()->width());
59+
60+
return QScrollArea::eventFilter(o, e);
61+
}
62+
};
63+
4264
class Ui::PluginThumbnail
4365
{
4466
public:
4567
QLabel* imageLabel;
4668
QLabel* nameLabel;
47-
QLabel* ownerLabel;
69+
QLabel* centerLabel;
4870
QLabel* statusLabel;
4971

5072
public:
@@ -75,11 +97,11 @@ class Ui::PluginThumbnail
7597
layout->setAlignment(Qt::AlignHCenter);
7698

7799
nameLabel = new QLabel;
78-
ownerLabel = new QLabel("<b>Connecting...</b>");
100+
centerLabel = new QLabel("<b>Connecting...</b>");
79101
statusLabel = new QLabel;
80102

81103
layout->addWidget(nameLabel, 0, Qt::AlignHCenter);
82-
layout->addWidget(ownerLabel, 0, Qt::AlignHCenter);
104+
layout->addWidget(centerLabel, 0, Qt::AlignHCenter);
83105
layout->addWidget(statusLabel, 0, Qt::AlignHCenter);
84106

85107
m_parent->setLayout(layout);
@@ -101,18 +123,18 @@ class Ui::PluginThumbnail
101123
nameFont.setBold(true);
102124
nameLabel->setFont(nameFont);
103125

104-
ownerLabel = new QLabel(QString::fromStdString("<i>" + plugin->owner + "</i>"));
105-
ownerLabel->setAlignment(Qt::AlignLeft);
106-
QFont ownerFont = ownerLabel->font();
126+
centerLabel = new QLabel;
127+
centerLabel->setAlignment(Qt::AlignLeft);
128+
QFont ownerFont = centerLabel->font();
107129
ownerFont.setItalic(true);
108-
ownerLabel->setFont(ownerFont);
130+
centerLabel->setFont(ownerFont);
109131

110132
statusLabel = new QLabel(QString::fromStdString(plugin->description));
111133
statusLabel->setAlignment(Qt::AlignLeft);
112134
QFont statusFont = statusLabel->font();
113135

114136
infoLayout->addWidget(nameLabel);
115-
infoLayout->addWidget(ownerLabel);
137+
infoLayout->addWidget(centerLabel);
116138
infoLayout->addWidget(statusLabel);
117139

118140
// In order to get the appropriate size for the image label, we need
@@ -214,11 +236,14 @@ void PluginThumbnail::SetProgress(float progress)
214236

215237
void PluginThumbnail::SetErrorText(const QString& text)
216238
{
217-
ui->ownerLabel->setText(text);
239+
ui->centerLabel->setText(text);
240+
ui->centerLabel->show();
218241
}
219242

220243
void PluginThumbnail::SetStatus(int status)
221244
{
245+
ui->centerLabel->hide();
246+
222247
ui->imageLabel->setPixmap(ui->pixmap);
223248

224249
QPixmap pluginImg = ui->imageLabel->pixmap();
@@ -254,7 +279,6 @@ void PluginThumbnail::SetStatus(int status)
254279
case PLUGIN_LOCAL:
255280
setToolTip("This plugin in not part of the repository, but was loaded from a local file.");
256281
ui->statusLabel->setText("Local Plugin");
257-
ui->ownerLabel->hide();
258282
break;
259283
case PLUGIN_DOWNLOADING:
260284
setToolTip("Downloading...");
@@ -339,7 +363,7 @@ class Ui::PluginListWidget
339363
QVBoxLayout* mainLayout = new QVBoxLayout;
340364
mainLayout->setContentsMargins(0, 0, 0, 0);
341365

342-
QScrollArea* scrollArea = new QScrollArea;
366+
VerticalScrollArea* scrollArea = new VerticalScrollArea;
343367
QWidget* scrollWidget = new QWidget;
344368
QVBoxLayout* scrollLayout = new QVBoxLayout;
345369
scrollLayout->setContentsMargins(0,0,0,0);
@@ -380,8 +404,6 @@ class Ui::PluginListWidget
380404
mainLayout->addWidget(scrollArea);
381405

382406
parent->setLayout(mainLayout);
383-
384-
parent->setMinimumWidth(250);
385407
}
386408

387409
void updateUi(int repoStatus = CPluginManager::CONNECTED)

0 commit comments

Comments
 (0)