mirror of https://github.com/KLayout/klayout.git
Better installation feedback for package manager
Now the confirmation dialog stays open and will show a log with the installation progress and results. The "marked" icon has been changed to look a bit less painted.
This commit is contained in:
parent
46fccb99bc
commit
1b0dcb5bf9
|
|
@ -13,7 +13,7 @@
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Ready for Installation</string>
|
<string>Ready for Installation</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|
@ -24,6 +24,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSplitter" name="splitter">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="layoutWidget">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTreeWidget" name="list">
|
<widget class="QTreeWidget" name="list">
|
||||||
<property name="focusPolicy">
|
<property name="focusPolicy">
|
||||||
|
|
@ -57,6 +64,33 @@
|
||||||
</column>
|
</column>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QFrame" name="confirm_panel">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|
@ -81,10 +115,214 @@
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QFrame" name="frame">
|
||||||
<property name="standardButtons">
|
<property name="frameShape">
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
<enum>QFrame::NoFrame</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>300</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="ok_button">
|
||||||
|
<property name="text">
|
||||||
|
<string>Ok</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="cancel_button">
|
||||||
|
<property name="text">
|
||||||
|
<string>Cancel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QFrame" name="log_panel">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QListView" name="log_view">
|
||||||
|
<property name="iconSize">
|
||||||
|
<size>
|
||||||
|
<width>16</width>
|
||||||
|
<height>16</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="isWrapping" stdset="0">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="resizeMode">
|
||||||
|
<enum>QListView::Adjust</enum>
|
||||||
|
</property>
|
||||||
|
<property name="uniformItemSizes">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QFrame" name="frame_2">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QFrame" name="attn_frame">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="pixmap">
|
||||||
|
<pixmap resource="layResources.qrc">:/warn_16.png</pixmap>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>There are errors or warnings</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QFrame" name="frame_3">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="close_button">
|
||||||
|
<property name="text">
|
||||||
|
<string>Close</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
@ -128,38 +366,5 @@
|
||||||
<resources>
|
<resources>
|
||||||
<include location="layResources.qrc"/>
|
<include location="layResources.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections>
|
<connections/>
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>SaltManagerInstallConfirmationDialog</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>273</x>
|
|
||||||
<y>431</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>276</x>
|
|
||||||
<y>448</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>SaltManagerInstallConfirmationDialog</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>351</x>
|
|
||||||
<y>426</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>363</x>
|
|
||||||
<y>445</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 1001 B |
|
|
@ -25,8 +25,7 @@
|
||||||
#include "tlFileUtils.h"
|
#include "tlFileUtils.h"
|
||||||
#include "tlWebDAV.h"
|
#include "tlWebDAV.h"
|
||||||
|
|
||||||
#include "ui_SaltManagerInstallConfirmationDialog.h"
|
#include <memory>
|
||||||
|
|
||||||
#include <QTreeWidgetItem>
|
#include <QTreeWidgetItem>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
|
@ -35,19 +34,28 @@ namespace lay
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
|
|
||||||
class ConfirmationDialog
|
ConfirmationDialog::ConfirmationDialog (QWidget *parent)
|
||||||
: public QDialog, private Ui::SaltManagerInstallConfirmationDialog
|
: QDialog (parent), m_confirmed (false), m_cancelled (false), m_closed (false), m_file (50000, true)
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
ConfirmationDialog (QWidget *parent)
|
|
||||||
: QDialog (parent)
|
|
||||||
{
|
|
||||||
Ui::SaltManagerInstallConfirmationDialog::setupUi (this);
|
Ui::SaltManagerInstallConfirmationDialog::setupUi (this);
|
||||||
}
|
|
||||||
|
|
||||||
void add_info (const std::string &name, bool update, const std::string &version, const std::string &url)
|
connect (ok_button, SIGNAL (clicked ()), this, SLOT (confirm_pressed ()));
|
||||||
{
|
connect (cancel_button, SIGNAL (clicked ()), this, SLOT (cancel_pressed ()));
|
||||||
|
connect (close_button, SIGNAL (clicked ()), this, SLOT (close_pressed ()));
|
||||||
|
|
||||||
|
log_panel->hide ();
|
||||||
|
attn_frame->hide ();
|
||||||
|
log_view->setModel (&m_file);
|
||||||
|
|
||||||
|
connect (&m_file, SIGNAL (layoutChanged ()), log_view, SLOT (scrollToBottom ()));
|
||||||
|
connect (&m_file, SIGNAL (attention_changed (bool)), attn_frame, SLOT (setVisible (bool)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ConfirmationDialog::add_info (const std::string &name, bool update, const std::string &version, const std::string &url)
|
||||||
|
{
|
||||||
QTreeWidgetItem *item = new QTreeWidgetItem (list);
|
QTreeWidgetItem *item = new QTreeWidgetItem (list);
|
||||||
|
m_items_by_name.insert (std::make_pair (name, item));
|
||||||
|
|
||||||
item->setFlags (item->flags () & ~Qt::ItemIsSelectable);
|
item->setFlags (item->flags () & ~Qt::ItemIsSelectable);
|
||||||
|
|
||||||
|
|
@ -59,8 +67,48 @@ public:
|
||||||
for (int column = 0; column < list->colorCount (); ++column) {
|
for (int column = 0; column < list->colorCount (); ++column) {
|
||||||
item->setData (column, Qt::ForegroundRole, update ? Qt::blue : Qt::black);
|
item->setData (column, Qt::ForegroundRole, update ? Qt::blue : Qt::black);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ConfirmationDialog::separator ()
|
||||||
|
{
|
||||||
|
m_file.separator ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ConfirmationDialog::mark_error (const std::string &name)
|
||||||
|
{
|
||||||
|
set_icon_for_name (name, QIcon (QString::fromUtf8 (":/error_16.png")));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ConfirmationDialog::mark_success (const std::string &name)
|
||||||
|
{
|
||||||
|
set_icon_for_name (name, QIcon (QString::fromUtf8 (":/marked_16.png")));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ConfirmationDialog::set_icon_for_name (const std::string &name, const QIcon &icon)
|
||||||
|
{
|
||||||
|
std::map<std::string, QTreeWidgetItem *>::const_iterator i = m_items_by_name.find (name);
|
||||||
|
if (i != m_items_by_name.end ()) {
|
||||||
|
i->second->setData (0, Qt::DecorationRole, icon);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ConfirmationDialog::start ()
|
||||||
|
{
|
||||||
|
confirm_panel->hide ();
|
||||||
|
log_panel->show ();
|
||||||
|
close_button->setEnabled (false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ConfirmationDialog::finish ()
|
||||||
|
{
|
||||||
|
close_button->setEnabled (true);
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -182,23 +230,17 @@ SaltDownloadManager::fetch_missing (const lay::Salt &salt_mine, tl::AbsoluteProg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
lay::ConfirmationDialog *
|
||||||
SaltDownloadManager::show_confirmation_dialog (QWidget *parent, const lay::Salt &salt)
|
SaltDownloadManager::make_confirmation_dialog (QWidget *parent, const lay::Salt &salt)
|
||||||
{
|
{
|
||||||
// Stop with a warning if there is nothing to do
|
lay::ConfirmationDialog *dialog = new lay::ConfirmationDialog (parent);
|
||||||
if (m_registry.empty()) {
|
|
||||||
QMessageBox::warning (parent, tr ("Nothing to do"), tr ("No packages need update or are marked for installation"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
lay::ConfirmationDialog dialog (parent);
|
|
||||||
|
|
||||||
// First the packages to update
|
// First the packages to update
|
||||||
for (std::map<std::string, Descriptor>::const_iterator p = m_registry.begin (); p != m_registry.end (); ++p) {
|
for (std::map<std::string, Descriptor>::const_iterator p = m_registry.begin (); p != m_registry.end (); ++p) {
|
||||||
const lay::SaltGrain *g = salt.grain_by_name (p->first);
|
const lay::SaltGrain *g = salt.grain_by_name (p->first);
|
||||||
if (g) {
|
if (g) {
|
||||||
// \342\206\222 is UTF-8 "right arrow"
|
// \342\206\222 is UTF-8 "right arrow"
|
||||||
dialog.add_info (p->first, true, g->version () + " \342\206\222 " + p->second.version, p->second.url);
|
dialog->add_info (p->first, true, g->version () + " \342\206\222 " + p->second.version, p->second.url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -206,19 +248,37 @@ SaltDownloadManager::show_confirmation_dialog (QWidget *parent, const lay::Salt
|
||||||
for (std::map<std::string, Descriptor>::const_iterator p = m_registry.begin (); p != m_registry.end (); ++p) {
|
for (std::map<std::string, Descriptor>::const_iterator p = m_registry.begin (); p != m_registry.end (); ++p) {
|
||||||
const lay::SaltGrain *g = salt.grain_by_name (p->first);
|
const lay::SaltGrain *g = salt.grain_by_name (p->first);
|
||||||
if (!g) {
|
if (!g) {
|
||||||
dialog.add_info (p->first, false, p->second.version, p->second.url);
|
dialog->add_info (p->first, false, p->second.version, p->second.url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return dialog.exec ();
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SaltDownloadManager::execute (lay::Salt &salt)
|
SaltDownloadManager::execute (QWidget *parent, lay::Salt &salt)
|
||||||
{
|
{
|
||||||
bool result = true;
|
// Stop with a warning if there is nothing to do
|
||||||
|
if (m_registry.empty()) {
|
||||||
|
QMessageBox::warning (parent, tr ("Nothing to do"), tr ("No packages need update or are marked for installation"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
tl::RelativeProgress progress (tl::to_string (QObject::tr ("Downloading packages")), m_registry.size (), 1);
|
std::auto_ptr<lay::ConfirmationDialog> dialog (make_confirmation_dialog (parent, salt));
|
||||||
|
|
||||||
|
dialog->setModal (true);
|
||||||
|
dialog->show ();
|
||||||
|
|
||||||
|
while (! dialog->is_confirmed ()) {
|
||||||
|
QCoreApplication::processEvents (QEventLoop::AllEvents | QEventLoop::WaitForMoreEvents, 100);
|
||||||
|
if (dialog->is_cancelled () || ! dialog->isVisible ()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dialog->start ();
|
||||||
|
|
||||||
|
bool result = true;
|
||||||
|
|
||||||
for (std::map<std::string, Descriptor>::const_iterator p = m_registry.begin (); p != m_registry.end (); ++p) {
|
for (std::map<std::string, Descriptor>::const_iterator p = m_registry.begin (); p != m_registry.end (); ++p) {
|
||||||
|
|
||||||
|
|
@ -230,13 +290,22 @@ SaltDownloadManager::execute (lay::Salt &salt)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! salt.create_grain (p->second.grain, target)) {
|
if (! salt.create_grain (p->second.grain, target)) {
|
||||||
|
dialog->mark_error (p->first);
|
||||||
result = false;
|
result = false;
|
||||||
|
} else {
|
||||||
|
dialog->mark_success (p->first);
|
||||||
}
|
}
|
||||||
|
|
||||||
++progress;
|
dialog->separator ();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dialog->finish ();
|
||||||
|
|
||||||
|
while (! dialog->is_closed () && dialog->isVisible ()) {
|
||||||
|
QCoreApplication::processEvents (QEventLoop::AllEvents | QEventLoop::WaitForMoreEvents, 100);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,11 @@
|
||||||
|
|
||||||
#include "layCommon.h"
|
#include "layCommon.h"
|
||||||
#include "laySaltGrain.h"
|
#include "laySaltGrain.h"
|
||||||
|
#include "layLogViewerDialog.h"
|
||||||
#include "tlProgress.h"
|
#include "tlProgress.h"
|
||||||
|
|
||||||
|
#include "ui_SaltManagerInstallConfirmationDialog.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
@ -36,6 +39,40 @@ namespace lay
|
||||||
|
|
||||||
class Salt;
|
class Salt;
|
||||||
|
|
||||||
|
class ConfirmationDialog
|
||||||
|
: public QDialog, private Ui::SaltManagerInstallConfirmationDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
ConfirmationDialog (QWidget *parent);
|
||||||
|
|
||||||
|
void add_info (const std::string &name, bool update, const std::string &version, const std::string &url);
|
||||||
|
|
||||||
|
bool is_confirmed () const { return m_confirmed; }
|
||||||
|
bool is_cancelled () const { return m_cancelled; }
|
||||||
|
bool is_closed () const { return m_closed; }
|
||||||
|
|
||||||
|
void start ();
|
||||||
|
void separator ();
|
||||||
|
void finish ();
|
||||||
|
|
||||||
|
void mark_error (const std::string &name);
|
||||||
|
void mark_success (const std::string &name);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void confirm_pressed () { m_confirmed = true; }
|
||||||
|
void cancel_pressed () { m_cancelled = true; }
|
||||||
|
void close_pressed () { m_closed = true; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_confirmed, m_cancelled, m_closed;
|
||||||
|
lay::LogFile m_file;
|
||||||
|
std::map<std::string, QTreeWidgetItem *> m_items_by_name;
|
||||||
|
|
||||||
|
void set_icon_for_name (const std::string &name, const QIcon &icon);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The download manager
|
* @brief The download manager
|
||||||
*
|
*
|
||||||
|
|
@ -73,25 +110,16 @@ public:
|
||||||
*/
|
*/
|
||||||
void compute_dependencies (const lay::Salt &salt, const Salt &salt_mine);
|
void compute_dependencies (const lay::Salt &salt, const Salt &salt_mine);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Presents a dialog showing the packages scheduled for download
|
|
||||||
*
|
|
||||||
* This method requires all dependencies to be computed. It will return false
|
|
||||||
* if the dialog is not confirmed.
|
|
||||||
*
|
|
||||||
* "salt" needs to be the currently installed packages so the dialog can
|
|
||||||
* indicate which packages will be updated.
|
|
||||||
*/
|
|
||||||
bool show_confirmation_dialog (QWidget *parent, const lay::Salt &salt);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Actually execute the downloads
|
* @brief Actually execute the downloads
|
||||||
*
|
*
|
||||||
* This method will return false if anything goes wrong.
|
* This method will show a confirmation dialog and start installation
|
||||||
* Failed packages will be removed entirely after they have been listed in
|
* if this dialog is confirmed. It will return false if
|
||||||
* an error dialog.
|
* the dialog was cancelled and an exception if something goes
|
||||||
|
* wrong.
|
||||||
|
* It will return true if the packages were installed successfully.
|
||||||
*/
|
*/
|
||||||
bool execute (lay::Salt &salt);
|
bool execute (QWidget *parent, lay::Salt &salt);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Descriptor
|
struct Descriptor
|
||||||
|
|
@ -110,6 +138,7 @@ private:
|
||||||
|
|
||||||
bool needs_iteration ();
|
bool needs_iteration ();
|
||||||
void fetch_missing (const lay::Salt &salt_mine, tl::AbsoluteProgress &progress);
|
void fetch_missing (const lay::Salt &salt_mine, tl::AbsoluteProgress &progress);
|
||||||
|
lay::ConfirmationDialog *make_confirmation_dialog (QWidget *parent, const lay::Salt &salt);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -529,16 +529,12 @@ BEGIN_PROTECTED
|
||||||
}
|
}
|
||||||
|
|
||||||
manager.compute_dependencies (*mp_salt, m_salt_mine);
|
manager.compute_dependencies (*mp_salt, m_salt_mine);
|
||||||
|
if (manager.execute (this, *mp_salt)) {
|
||||||
if (manager.show_confirmation_dialog (this, *mp_salt)) {
|
|
||||||
if (update) {
|
if (update) {
|
||||||
unmark_all_update ();
|
unmark_all_update ();
|
||||||
} else {
|
} else {
|
||||||
unmark_all_new ();
|
unmark_all_new ();
|
||||||
}
|
}
|
||||||
if (! manager.execute (*mp_salt)) {
|
|
||||||
throw tl::Exception (tl::to_string (tr ("Failed to install some of the selected packages. Please see log for details.")));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
END_PROTECTED
|
END_PROTECTED
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue