Skip to content

Commit

Permalink
Changed Upgrade installed libraries to Update installed libraries (#8724
Browse files Browse the repository at this point in the history
)

Added a dialog to File | Update installed libraries explaining what it does.
  • Loading branch information
adeas31 committed Mar 18, 2022
1 parent 43ea3e4 commit f9ebf66
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 16 deletions.
22 changes: 10 additions & 12 deletions OMEdit/OMEditLIB/MainWindow.cpp
Expand Up @@ -2513,15 +2513,13 @@ bool MainWindow::openInstallLibraryDialog()
}

/*!
* \brief MainWindow::upgradeInstalledLibraries
* Upgrades the installed libraries.
* \brief MainWindow::updateInstalledLibraries
* Opens the update installed libraries dialog.
*/
void MainWindow::upgradeInstalledLibraries()
void MainWindow::updateInstalledLibraries()
{
if (mpOMCProxy->upgradeInstalledPackages(true)) {
mpOMCProxy->updatePackageIndex();
addSystemLibraries();
}
UpdateInstalledLibrariesDialog *pUpdateInstalledLibrariesDialog = new UpdateInstalledLibrariesDialog;
pUpdateInstalledLibrariesDialog->exec();
}

//! Imports the models from OMNotebook.
Expand Down Expand Up @@ -3467,10 +3465,10 @@ void MainWindow::createActions()
mpInstallLibraryAction = new QAction(Helper::installLibrary, this);
mpInstallLibraryAction->setStatusTip(tr("Opens the install library window"));
connect(mpInstallLibraryAction, SIGNAL(triggered()), SLOT(openInstallLibraryDialog()));
// upgrade installed libraries action
mpUpgradeInstalledLibrariesAction = new QAction(tr("Upgrade Installed Libraries"), this);
mpUpgradeInstalledLibrariesAction->setStatusTip(tr("Upgrades the installed libraries"));
connect(mpUpgradeInstalledLibrariesAction, SIGNAL(triggered()), SLOT(upgradeInstalledLibraries()));
// updated installed libraries action
mpUpdateInstalledLibrariesAction = new QAction(Helper::updateInstalledLibraries, this);
mpUpdateInstalledLibrariesAction->setStatusTip(tr("Updates the installed libraries"));
connect(mpUpdateInstalledLibrariesAction, SIGNAL(triggered()), SLOT(updateInstalledLibraries()));
// clear recent files action
mpClearRecentFilesAction = new QAction(Helper::clearRecentFiles, this);
mpClearRecentFilesAction->setStatusTip(tr("Clears the recent files list"));
Expand Down Expand Up @@ -3928,7 +3926,7 @@ void MainWindow::createMenus()
addSystemLibraries();
mpFileMenu->addMenu(mpLibrariesMenu);
mpFileMenu->addAction(mpInstallLibraryAction);
mpFileMenu->addAction(mpUpgradeInstalledLibrariesAction);
mpFileMenu->addAction(mpUpdateInstalledLibrariesAction);
mpFileMenu->addSeparator();
mpRecentFilesMenu = new QMenu(menuBar());
mpRecentFilesMenu->setObjectName("RecentFilesMenu");
Expand Down
4 changes: 2 additions & 2 deletions OMEdit/OMEditLIB/MainWindow.h
Expand Up @@ -336,7 +336,7 @@ class MainWindow : public QMainWindow
QAction *mpExportFigaroAction;
QAction *mpExportToOMNotebookAction;
QAction *mpInstallLibraryAction;
QAction *mpUpgradeInstalledLibrariesAction;
QAction *mpUpdateInstalledLibrariesAction;
QAction *mpClearRecentFilesAction;
QAction *mpPrintModelAction;
QAction *mpQuitAction;
Expand Down Expand Up @@ -529,7 +529,7 @@ public slots:
void runOMSensPlugin();
void exportModelToOMNotebook();
bool openInstallLibraryDialog();
void upgradeInstalledLibraries();
void updateInstalledLibraries();
void importModelfromOMNotebook();
void importNgspiceNetlist();
void exportModelAsImage(bool copyToClipboard = false);
Expand Down
68 changes: 67 additions & 1 deletion OMEdit/OMEditLIB/Modeling/InstallLibraryDialog.cpp
Expand Up @@ -101,7 +101,7 @@ InstallLibraryDialog::InstallLibraryDialog(QDialog *parent)
// exact match checkbox
mpExactMatchCheckBox = new QCheckBox(tr("Exact Match (Install only the specified version of dependencies)"));
mpExactMatchCheckBox->setChecked(true);
// Progress label & bar
// Progress label
mpProgressLabel = new Label(tr("<b>Installing library. Please wait.</b>"));
mpProgressLabel->hide();
// buttons
Expand Down Expand Up @@ -244,3 +244,69 @@ void InstallLibraryDialog::installLibrary()
mpOkButton->setEnabled(true);
}
}

/*!
* \brief UpdateInstalledLibrariesDialog::UpdateInstalledLibrariesDialog
* \param parent
*/
UpdateInstalledLibrariesDialog::UpdateInstalledLibrariesDialog(QDialog *parent)
: QDialog(parent)
{
setAttribute(Qt::WA_DeleteOnClose);
setWindowTitle(QString("%1 - %2").arg(Helper::applicationName, Helper::updateInstalledLibraries));
setMinimumWidth(400);
Label *pHeadingLabel = Utilities::getHeadingLabel(Helper::updateInstalledLibraries);
pHeadingLabel->setElideMode(Qt::ElideMiddle);
// description label
mpDescriptLabel = new Label(tr("Click Update to upgrade the installed libraries that have been registered by the package manager."));
// installNewestVersions checkbox
mpInstallNewestVersionsCheckBox = new QCheckBox(tr("Install Newest Versions"));
mpInstallNewestVersionsCheckBox->setChecked(true);
// Progress label
mpProgressLabel = new Label(tr("<b>Updating installed libraries. Please wait.</b>"));
mpProgressLabel->hide();
// buttons
mpUpdateButton = new QPushButton(tr("Update"));
mpUpdateButton->setAutoDefault(true);
connect(mpUpdateButton, SIGNAL(clicked()), SLOT(updateInstalledLibraries()));
mpCancelButton = new QPushButton(Helper::cancel);
mpCancelButton->setAutoDefault(false);
connect(mpCancelButton, SIGNAL(clicked()), SLOT(reject()));
// add buttons to the button box
mpButtonBox = new QDialogButtonBox(Qt::Horizontal);
mpButtonBox->addButton(mpUpdateButton, QDialogButtonBox::ActionRole);
mpButtonBox->addButton(mpCancelButton, QDialogButtonBox::ActionRole);
// layout
QGridLayout *pMainGridLayout = new QGridLayout;
int row = 0;
pMainGridLayout->setAlignment(Qt::AlignTop);
pMainGridLayout->addWidget(pHeadingLabel, row++, 0, 1, 2);
pMainGridLayout->addWidget(Utilities::getHeadingLine(), row++, 0, 1, 2);
pMainGridLayout->addWidget(mpDescriptLabel, row++, 0, 1, 2);
pMainGridLayout->addWidget(mpInstallNewestVersionsCheckBox, row++, 0, 1, 2);
pMainGridLayout->addWidget(mpProgressLabel, row, 0);
pMainGridLayout->addWidget(mpButtonBox, row++, 1, Qt::AlignRight);
setLayout(pMainGridLayout);
}

/*!
* \brief UpdateInstalledLibrariesDialog::updateInstalledLibraries
* Updates the installed libraries.
*/
void UpdateInstalledLibrariesDialog::updateInstalledLibraries()
{
mpProgressLabel->show();
mpUpdateButton->setEnabled(false);
repaint(); // repaint the dialog so progresslabel is updated.

if (MainWindow::instance()->getOMCProxy()->upgradeInstalledPackages(mpInstallNewestVersionsCheckBox->isChecked())) {
MainWindow::instance()->getOMCProxy()->updatePackageIndex();
MainWindow::instance()->addSystemLibraries();
accept();
} else {
QMessageBox::critical(this, QString("%1 - %2").arg(Helper::applicationName, Helper::error),
tr("Fail to update libraries. See Messages Browser for any possible messages."), Helper::ok);
mpProgressLabel->hide();
mpUpdateButton->setEnabled(true);
}
}
16 changes: 16 additions & 0 deletions OMEdit/OMEditLIB/Modeling/InstallLibraryDialog.h
Expand Up @@ -74,4 +74,20 @@ private slots:
void installLibrary();
};

class UpdateInstalledLibrariesDialog : public QDialog
{
Q_OBJECT
public:
explicit UpdateInstalledLibrariesDialog(QDialog *parent = nullptr);
private:
Label *mpDescriptLabel;
QCheckBox *mpInstallNewestVersionsCheckBox;
Label *mpProgressLabel;
QPushButton *mpUpdateButton;
QPushButton *mpCancelButton;
QDialogButtonBox *mpButtonBox;
private slots:
void updateInstalledLibraries();
};

#endif // INSTALLLIBRARYDIALOG_H
2 changes: 1 addition & 1 deletion OMEdit/OMEditLIB/Modeling/ModelWidgetContainer.h
Expand Up @@ -443,9 +443,9 @@ class WelcomePageWidget : public QWidget
QSplitter *mpSplitter;
QFrame *mpBottomFrame;
QPushButton *mpCreateModelButton;
QPushButton *mpOpenModelButton;
QPushButton *mpSystemLibrariesButton;
QPushButton *mpInstallLibraryButton;
QPushButton *mpOpenModelButton;
public slots:
void addLatestNewsListItems();
private slots:
Expand Down
2 changes: 2 additions & 0 deletions OMEdit/OMEditLIB/Util/Helper.cpp
Expand Up @@ -423,6 +423,7 @@ QString Helper::systemSimulationInformation;
QString Helper::translationFlags;
QString Helper::send;
QString Helper::installLibrary;
QString Helper::updateInstalledLibraries;
QString Helper::dataReconciliation;

void Helper::initHelperVariables()
Expand Down Expand Up @@ -725,6 +726,7 @@ void Helper::initHelperVariables()
Helper::translationFlags = tr("Translation Flags");
Helper::send = tr("Send");
Helper::installLibrary = tr("Install Library");
Helper::updateInstalledLibraries = tr("Update Installed Libraries");
Helper::dataReconciliation = tr("Data Reconciliation");
}

Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditLIB/Util/Helper.h
Expand Up @@ -430,6 +430,7 @@ class Helper : public QObject
static QString translationFlags;
static QString send;
static QString installLibrary;
static QString updateInstalledLibraries;
static QString dataReconciliation;
};

Expand Down

0 comments on commit f9ebf66

Please sign in to comment.