Skip to content

Commit 25d15b4

Browse files
committed
Merge branch 'develop' of https://github.com/febiosoftware/FEBioStudio into develop
2 parents f7bfcc0 + 3390cf1 commit 25d15b4

12 files changed

Lines changed: 124 additions & 159 deletions

FEBioStudio/DlgAddPhysicsItem.cpp

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ SOFTWARE.*/
3030
#include <QTreeWidgetItem>
3131
#include <QFormLayout>
3232
#include <QBoxLayout>
33+
#include <QMessageBox>
3334
#include <QLabel>
3435
#include <QToolButton>
3536
#include <QHeaderView>
@@ -43,6 +44,7 @@ SOFTWARE.*/
4344
#include <FEBioLink/FEBioClass.h>
4445
#include <FEBioLink/FEBioModule.h>
4546
#include <FSCore/FSCore.h>
47+
#include "HelpFeature.h"
4648

4749
using namespace std;
4850

@@ -106,8 +108,15 @@ class UIDlgAddPhysicsItem
106108
layout->addLayout(h);
107109
layout->addWidget(type);
108110

109-
dlg->SetLeftSideLayout(layout);
111+
QDialogButtonBox* bb = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help);
110112

113+
layout->addWidget(bb);
114+
115+
dlg->setLayout(layout);
116+
117+
QObject::connect(bb, SIGNAL(accepted()), dlg, SLOT(accept()));
118+
QObject::connect(bb, SIGNAL(rejected()), dlg, SLOT(reject()));
119+
QObject::connect(bb, SIGNAL(helpRequested()), dlg, SLOT(on_help_clicked()));
111120
QObject::connect(type, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), dlg, SLOT(accept()));
112121
QObject::connect(flt, SIGNAL(textChanged(const QString&)), dlg, SLOT(Update()));
113122
QObject::connect(tb, SIGNAL(clicked()), dlg, SLOT(Update()));
@@ -118,7 +127,7 @@ class UIDlgAddPhysicsItem
118127
};
119128

120129
CDlgAddPhysicsItem::CDlgAddPhysicsItem(QString windowName, int superID, int baseClassID, FSModel* fem, bool includeModuleDependencies, bool showStepList, QWidget* parent)
121-
: CHelpDialog(parent), ui(new UIDlgAddPhysicsItem)
130+
: QDialog(parent), ui(new UIDlgAddPhysicsItem)
122131
{
123132
setWindowTitle(windowName);
124133
setMinimumSize(800, 600);
@@ -138,13 +147,11 @@ CDlgAddPhysicsItem::CDlgAddPhysicsItem(QString windowName, int superID, int base
138147
}
139148
}
140149

141-
m_module = FEBio::GetActiveModule();
142-
143150
unsigned int searchFlags = 0;
144151
if (ui->m_modDepends) searchFlags |= FEBio::ClassSearchFlags::IncludeModuleDependencies;
145152

146153
// set the types
147-
vector<FEBio::FEBioClassInfo> l = FEBio::FindAllClasses(m_module, ui->m_superID, ui->m_baseClassID, searchFlags);
154+
vector<FEBio::FEBioClassInfo> l = FEBio::FindAllClasses(FEBio::GetActiveModule(), ui->m_superID, ui->m_baseClassID, searchFlags);
148155
for (int i = 0; i < (int)l.size(); ++i)
149156
{
150157
FEBio::FEBioClassInfo& fac = l[i];
@@ -210,6 +217,20 @@ void CDlgAddPhysicsItem::Update()
210217
ui->type->model()->sort(0);
211218
}
212219

220+
void CDlgAddPhysicsItem::on_help_clicked()
221+
{
222+
if(ui->type->selectedItems().size() > 0)
223+
{
224+
int classID = ui->type->currentItem()->data(0, Qt::UserRole).toInt();
225+
226+
ShowHelp(ClassIDToURL(classID));
227+
}
228+
else
229+
{
230+
QMessageBox::information(this, "Help", "Please select an item before clicking Help.");
231+
}
232+
}
233+
213234
std::string CDlgAddPhysicsItem::GetName()
214235
{
215236
return ui->name->text().toStdString();
@@ -226,20 +247,6 @@ int CDlgAddPhysicsItem::GetClassID()
226247
return (it ? it->data(0, Qt::UserRole).toInt() : -1);
227248
}
228249

229-
void CDlgAddPhysicsItem::UpdateHelpURL()
230-
{
231-
if(ui->type->selectedItems().size() > 0)
232-
{
233-
int classID = ui->type->currentItem()->data(0, Qt::UserRole).toInt();
234-
235-
SetURL(ClassIDToURL(classID));
236-
}
237-
else
238-
{
239-
SetURL(QString());
240-
}
241-
}
242-
243250
class UIDlgCopyPhysicsItem
244251
{
245252
private:

FEBioStudio/DlgAddPhysicsItem.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2525
SOFTWARE.*/
2626

2727
#pragma once
28-
#include "HelpDialog.h"
28+
#include <QDialog>
2929

3030
class UIDlgAddPhysicsItem;
3131
class UIDlgCopyPhysicsItem;
3232
class FSModel;
3333
class FSModelComponent;
3434

35-
class CDlgAddPhysicsItem : public CHelpDialog
35+
class CDlgAddPhysicsItem : public QDialog
3636
{
3737
Q_OBJECT
3838

@@ -45,11 +45,9 @@ class CDlgAddPhysicsItem : public CHelpDialog
4545

4646
void ShowNameAndCategoryFields(bool b);
4747

48-
protected:
49-
void UpdateHelpURL();
50-
5148
public slots:
5249
void Update();
50+
void on_help_clicked();
5351

5452
private:
5553
UIDlgAddPhysicsItem* ui;

FEBioStudio/DlgPluginRepo.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ class Ui::CDlgPluginRepo
308308

309309
QPushButton* loadLocalButton;
310310
QPushButton* submitPluginButton;
311+
QPushButton* writeConfigButton;
311312
QPushButton* closeButton;
312313

313314
void setupUI(::CDlgPluginRepo* dlg, CPluginManager* manager)
@@ -524,6 +525,12 @@ class Ui::CDlgPluginRepo
524525
buttonBar->addWidget(submitPluginButton = new QPushButton("Sumbit a Plugin to the Repository"));
525526
submitPluginButton->setFocusPolicy(Qt::NoFocus);
526527

528+
buttonBar->addWidget(writeConfigButton = new QPushButton("Save FEBio Config File"));
529+
writeConfigButton->setFocusPolicy(Qt::NoFocus);
530+
writeConfigButton->setToolTip("Writes the current plugin configuration to an FEBio config file. "
531+
"This allows you to easily load these plugins into FEBio when launched from the command line by "
532+
"referencing the config file.");
533+
527534
QWidget* spacer = new QWidget();
528535
spacer->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
529536
buttonBar->addWidget(spacer);
@@ -549,6 +556,7 @@ class Ui::CDlgPluginRepo
549556

550557
QObject::connect(loadLocalButton, &QPushButton::clicked, dlg, &::CDlgPluginRepo::on_loadLocalButton_clicked);
551558
QObject::connect(submitPluginButton, &QPushButton::clicked, dlg, &::CDlgPluginRepo::on_submitPluginButton_clicked);
559+
QObject::connect(writeConfigButton, &QPushButton::clicked, dlg, &::CDlgPluginRepo::on_writeConfigButton_clicked);
552560
QObject::connect(closeButton, &QPushButton::clicked, dlg, &::CDlgPluginRepo::reject);
553561
}
554562

@@ -885,6 +893,8 @@ void CDlgPluginRepo::on_PluginsReady()
885893

886894
for (auto& [id, plugin] : plugins)
887895
{
896+
if(plugin.status == PLUGIN_UNAVAILABLE) continue;
897+
888898
ui->pluginListWidget->AddPlugin(plugin);
889899
}
890900

@@ -1032,4 +1042,13 @@ void CDlgPluginRepo::on_submitPluginButton_clicked()
10321042
{
10331043
DlgSubmitPlugin dlg(ui->m_manager);
10341044
dlg.exec();
1035-
}
1045+
}
1046+
1047+
void CDlgPluginRepo::on_writeConfigButton_clicked()
1048+
{
1049+
QString fileName = QFileDialog::getSaveFileName(this, "Save FEBio Config File", "febio.xml", "XML Files (*.xml)");
1050+
1051+
if(fileName.isEmpty()) return;
1052+
1053+
ui->m_manager->WriteConfigFile(fileName.toStdString());
1054+
}

FEBioStudio/DlgPluginRepo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ private slots:
113113
// void on_bbButton_clicked(QAbstractButton *button);
114114
void on_loadLocalButton_clicked();
115115
void on_submitPluginButton_clicked();
116+
void on_writeConfigButton_clicked();
116117

117118
private:
118119
friend class Ui::CDlgPluginRepo;
Lines changed: 4 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -24,88 +24,13 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2424
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2525
SOFTWARE.*/
2626

27-
#include <QCoreApplication>
28-
#include <QBoxLayout>
29-
#include <QDialogButtonBox>
30-
#include <QPushButton>
31-
#include <QTextBrowser>
3227
#include <QDesktopServices>
33-
#include <QMessageBox>
34-
#include <FEMLib/FSProject.h>
35-
#include "HelpDialog.h"
36-
#include "FEBioStudio.h"
37-
#include "MainWindow.h"
38-
#include <FEBioLink/FEBioModule.h>
39-
#include <FEBioLib/version.h>
28+
#include <QUrl>
29+
#include "HelpFeature.h"
4030
#include <FEBioLink/FEBioClass.h>
4131

4232
#define MANUAL_PATH "https://febiosoftware.github.io/febio-feature-manual/features/"
4333

44-
class Ui::CHelpDialog
45-
{
46-
public:
47-
QPushButton* helpButton;
48-
QHBoxLayout* helpLayout;
49-
50-
public:
51-
void setupUi(QWidget* parent)
52-
{
53-
QVBoxLayout* mainLayout = new QVBoxLayout;
54-
helpLayout = new QHBoxLayout;
55-
56-
mainLayout->addLayout(helpLayout);
57-
58-
QDialogButtonBox* bb = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
59-
60-
helpButton = new QPushButton("Help");
61-
helpButton->setCheckable(true);
62-
63-
bb->addButton(helpButton, QDialogButtonBox::HelpRole);
64-
65-
mainLayout->addWidget(bb);
66-
67-
QObject::connect(bb, SIGNAL(accepted()), parent, SLOT(accept()));
68-
QObject::connect(bb, SIGNAL(rejected()), parent, SLOT(reject()));
69-
QObject::connect(bb, SIGNAL(helpRequested()), parent, SLOT(on_help_clicked()));
70-
71-
parent->setLayout(mainLayout);
72-
}
73-
};
74-
75-
76-
CHelpDialog::CHelpDialog(QWidget* parent) : QDialog(parent), ui(new Ui::CHelpDialog)
77-
{
78-
ui->setupUi(this);
79-
80-
m_module = FEBio::GetActiveModule();
81-
}
82-
83-
CHelpDialog::~CHelpDialog() { delete ui; }
84-
85-
void ShowHelp(const QString& url)
86-
{
87-
QDesktopServices::openUrl(QUrl(QString(MANUAL_PATH) + url));
88-
}
89-
90-
void CHelpDialog::on_help_clicked()
91-
{
92-
UpdateHelpURL();
93-
94-
if(m_url.isEmpty())
95-
{
96-
QMessageBox::information(this, "Help", "Please select an item before clicking Help.");
97-
}
98-
else
99-
{
100-
ShowHelp(m_url);
101-
}
102-
}
103-
104-
void CHelpDialog::SetLeftSideLayout(QLayout* layout)
105-
{
106-
ui->helpLayout->insertLayout(0, layout);
107-
}
108-
10934
QString ClassIDToURL(int classID)
11035
{
11136
QString url;
@@ -122,7 +47,7 @@ QString ClassIDToURL(int classID)
12247
return url;
12348
}
12449

125-
void CHelpDialog::SetURL(const QString& url)
50+
void ShowHelp(const QString& url)
12651
{
127-
m_url = url;
52+
QDesktopServices::openUrl(QUrl(QString(MANUAL_PATH) + url));
12853
}
Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -25,40 +25,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2525
SOFTWARE.*/
2626

2727
#pragma once
28-
#include <QDialog>
29-
30-
class QLayout;
31-
32-
namespace Ui {
33-
class CHelpDialog;
34-
};
35-
36-
class CHelpDialog : public QDialog
37-
{
38-
Q_OBJECT
39-
40-
public:
41-
CHelpDialog(QWidget* parent);
42-
virtual ~CHelpDialog();
43-
44-
protected slots:
45-
void on_help_clicked();
46-
47-
public:
48-
void SetLeftSideLayout(QLayout* layout);
49-
50-
virtual void UpdateHelpURL() = 0;
51-
52-
protected:
53-
void SetURL(const QString& url);
54-
55-
protected:
56-
int m_module;
57-
QString m_url;
58-
QString m_unselectedHelp;
59-
private:
60-
Ui::CHelpDialog* ui;
61-
};
28+
#include <QString>
6229

6330
QString ClassIDToURL(int classID);
6431
void ShowHelp(const QString& url);

0 commit comments

Comments
 (0)