diff --git a/src/lay/lay/SaltManagerDialog.ui b/src/lay/lay/SaltManagerDialog.ui index 58f5b5729..cd998ae45 100644 --- a/src/lay/lay/SaltManagerDialog.ui +++ b/src/lay/lay/SaltManagerDialog.ui @@ -35,6 +35,9 @@ Qt::Horizontal + + false + @@ -325,6 +328,9 @@ Qt::Horizontal + + false + @@ -601,7 +607,7 @@ - Current Packages + Installed Packages @@ -615,6 +621,9 @@ Qt::Horizontal + + false + @@ -650,26 +659,6 @@ 0 - - - - Qt::NoFocus - - - Uninstall Package - - - ... - - - - :/clear.png:/clear.png - - - true - - - @@ -797,8 +786,8 @@ 0 0 - 343 - 207 + 537 + 284 @@ -994,16 +983,19 @@ 0 - + + + Qt::NoFocus + + + Uninstall Package + - Create Package + Remove Package - :/add.png:/add.png - - - false + :/clear.png:/clear.png @@ -1020,6 +1012,20 @@ + + + + Create (Edit) Package + + + + :/add.png:/add.png + + + false + + + @@ -1053,10 +1059,10 @@ :/clear.png:/clear.png - Delete + Remove Package - Delete package + Remove package @@ -1108,8 +1114,12 @@ + + + :/add.png:/add.png + - Create package + Create (edit) package diff --git a/src/lay/lay/laySaltGrain.cc b/src/lay/lay/laySaltGrain.cc index ab910e395..9c272a4de 100644 --- a/src/lay/lay/laySaltGrain.cc +++ b/src/lay/lay/laySaltGrain.cc @@ -25,6 +25,7 @@ #include "tlXMLParser.h" #include "tlHttpStream.h" #include "tlWebDAV.h" +#include "tlFileUtils.h" #include #include @@ -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 diff --git a/src/lay/lay/laySaltManagerDialog.cc b/src/lay/lay/laySaltManagerDialog.cc index 7c2cf6fd1..567db67bb 100644 --- a/src/lay/lay/laySaltManagerDialog.cc +++ b/src/lay/lay/laySaltManagerDialog.cc @@ -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 ( diff --git a/src/tl/tl/tlHttpStream.cc b/src/tl/tl/tlHttpStream.cc index c03e4191c..0201ebb01 100644 --- a/src/tl/tl/tlHttpStream.cc +++ b/src/tl/tl/tlHttpStream.cc @@ -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) {