Some enhancements/bug fixes for package manager

This commit is contained in:
Matthias Koefferlein 2017-09-27 00:16:43 +02:00
parent 9eddeabef2
commit 7e7a5ce030
4 changed files with 83 additions and 52 deletions

View File

@ -35,6 +35,9 @@
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="childrenCollapsible">
<bool>false</bool>
</property>
<widget class="QWidget" name="layoutWidget_2">
<layout class="QVBoxLayout" name="verticalLayout_7">
<property name="rightMargin">
@ -325,6 +328,9 @@
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="childrenCollapsible">
<bool>false</bool>
</property>
<widget class="QWidget" name="layoutWidget_3">
<layout class="QVBoxLayout" name="verticalLayout_11">
<property name="rightMargin">
@ -601,7 +607,7 @@
</widget>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Current Packages</string>
<string>Installed Packages</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
@ -615,6 +621,9 @@
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="childrenCollapsible">
<bool>false</bool>
</property>
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="rightMargin">
@ -650,26 +659,6 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="delete_button">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Uninstall Package</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="layResources.qrc">
<normaloff>:/clear.png</normaloff>:/clear.png</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
@ -797,8 +786,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>343</width>
<height>207</height>
<width>537</width>
<height>284</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
@ -994,16 +983,19 @@
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="create_button">
<widget class="QPushButton" name="delete_button">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Uninstall Package</string>
</property>
<property name="text">
<string>Create Package</string>
<string>Remove Package</string>
</property>
<property name="icon">
<iconset resource="layResources.qrc">
<normaloff>:/add.png</normaloff>:/add.png</iconset>
</property>
<property name="autoDefault">
<bool>false</bool>
<normaloff>:/clear.png</normaloff>:/clear.png</iconset>
</property>
</widget>
</item>
@ -1020,6 +1012,20 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="create_button">
<property name="text">
<string>Create (Edit) Package</string>
</property>
<property name="icon">
<iconset resource="layResources.qrc">
<normaloff>:/add.png</normaloff>:/add.png</iconset>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -1053,10 +1059,10 @@
<normaloff>:/clear.png</normaloff>:/clear.png</iconset>
</property>
<property name="text">
<string>Delete</string>
<string>Remove Package</string>
</property>
<property name="toolTip">
<string>Delete package</string>
<string>Remove package</string>
</property>
</action>
<action name="actionUnmarkAllNew">
@ -1108,8 +1114,12 @@
</property>
</action>
<action name="actionCreatePackage">
<property name="icon">
<iconset resource="layResources.qrc">
<normaloff>:/add.png</normaloff>:/add.png</iconset>
</property>
<property name="text">
<string>Create package</string>
<string>Create (edit) package</string>
</property>
</action>
<action name="actionMarkAllUpdate">

View File

@ -25,6 +25,7 @@
#include "tlXMLParser.h"
#include "tlHttpStream.h"
#include "tlWebDAV.h"
#include "tlFileUtils.h"
#include <memory>
#include <QDir>
@ -124,24 +125,29 @@ SaltGrain::eff_doc_url () const
return m_doc_url;
}
if (! path ().empty ()) {
QString p = tl::to_qstring (path ());
if (! p.isEmpty ()) {
// if the URL is a relative URL, make it absolute relative to the grain's installation directory
QFileInfo fi (url.toLocalFile ());
if (! fi.isAbsolute ()) {
url = QUrl::fromLocalFile (QDir (tl::to_qstring (path ())).absoluteFilePath (fi.filePath ()));
fi = QFileInfo (QDir (p).absoluteFilePath (fi.filePath ()));
}
url.setScheme (tl::to_qstring ("file"));
return tl::to_string (url.toString ());
} else {
// base the documentation URL on the download URL
QUrl eff_url = QUrl (tl::to_qstring (m_url));
eff_url.setPath (eff_url.path () + QString::fromUtf8 ("/") + url.path ());
return tl::to_string (eff_url.toString ());
// if the resulting path is inside the downloaded package, use this path
QString dp = fi.canonicalFilePath ();
if (!dp.isEmpty () && tl::is_parent_path (p, dp)) {
url = QUrl::fromLocalFile (dp);
url.setScheme (tl::to_qstring ("file"));
return tl::to_string (url.toString ());
}
}
// base the documentation URL on the download URL
QUrl eff_url = QUrl (tl::to_qstring (m_url));
eff_url.setPath (eff_url.path () + QString::fromUtf8 ("/") + url.path ());
return tl::to_string (eff_url.toString ());
}
void

View File

@ -118,10 +118,6 @@ SaltManagerDialog::SaltManagerDialog (QWidget *parent, lay::Salt *salt, const st
Ui::SaltManagerDialog::setupUi (this);
mp_properties_dialog = new lay::SaltGrainPropertiesDialog (this);
// TODO: clarify where the delete button should go ... currently it's too easy to
// mistake add and delete buttons
delete_button->hide ();
connect (edit_button, SIGNAL (clicked ()), this, SLOT (edit_properties ()));
connect (create_button, SIGNAL (clicked ()), this, SLOT (create_grain ()));
connect (delete_button, SIGNAL (clicked ()), this, SLOT (delete_grain ()));
@ -130,6 +126,7 @@ SaltManagerDialog::SaltManagerDialog (QWidget *parent, lay::Salt *salt, const st
mp_salt = salt;
QApplication::setOverrideCursor (Qt::WaitCursor);
try {
if (! m_salt_mine_url.empty ()) {
tl::log << tl::to_string (tr ("Downloading package repository from %1").arg (tl::to_qstring (m_salt_mine_url)));
@ -138,6 +135,7 @@ SaltManagerDialog::SaltManagerDialog (QWidget *parent, lay::Salt *salt, const st
} catch (tl::Exception &ex) {
tl::error << ex.msg ();
}
QApplication::restoreOverrideCursor ();
SaltModel *model = new SaltModel (this, mp_salt);
model->set_empty_explanation (tr ("No packages are present on this system"));
@ -258,7 +256,7 @@ SaltManagerDialog::mode_changed ()
}
// keeps the splitters in sync
if (!sizes.empty ()) {
if (sizes.size () == 2 && sizes[1] > 0 /*visible*/) {
splitter_new->setSizes (sizes);
splitter_update->setSizes (sizes);
splitter->setSizes (sizes);
@ -661,9 +659,20 @@ BEGIN_PROTECTED
tl::log << tl::to_string (tr ("Downloading package repository from %1").arg (tl::to_qstring (m_salt_mine_url)));
lay::Salt new_mine;
new_mine.load (m_salt_mine_url);
m_salt_mine = new_mine;
try {
QApplication::setOverrideCursor (Qt::WaitCursor);
lay::Salt new_mine;
new_mine.load (m_salt_mine_url);
m_salt_mine = new_mine;
QApplication::restoreOverrideCursor ();
} catch (...) {
QApplication::restoreOverrideCursor ();
throw;
}
salt_mine_changed ();
@ -870,6 +879,8 @@ SaltManagerDialog::get_remote_grain_info (lay::SaltGrain *g, SaltGrainDetailsTex
// Download actual grain definition file
try {
QApplication::setOverrideCursor (Qt::WaitCursor);
if (g->url ().empty ()) {
throw tl::Exception (tl::to_string (tr ("No download link available")));
}
@ -901,8 +912,12 @@ SaltManagerDialog::get_remote_grain_info (lay::SaltGrain *g, SaltGrainDetailsTex
details->set_grain (remote_grain.get ());
QApplication::restoreOverrideCursor ();
} catch (tl::Exception &ex) {
QApplication::restoreOverrideCursor ();
remote_grain.reset (0);
QString html = tr (

View File

@ -189,9 +189,9 @@ InputHttpStream::read (char *b, size_t n)
issue_request (QUrl (tl::to_qstring (m_url)));
}
// @@@ TODO: progress, timeout
// TODO: progress, timeout
while (mp_reply == 0) {
QCoreApplication::processEvents (QEventLoop::ExcludeUserInputEvents | QEventLoop::WaitForMoreEvents, 100);
QCoreApplication::processEvents (QEventLoop::ExcludeUserInputEvents);
}
if (mp_reply->error () != QNetworkReply::NoError) {