From b34750f8cdac155998b9a8bc7f8369ee3092b8c6 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 19 Mar 2017 22:44:46 +0100 Subject: [PATCH] WIP: salt package manager New features like properties editor, proper icon sizing, some styling etc. --- src/lay/SaltGrainPropertiesDialog.ui | 675 +++++++++++++++++++++++ src/lay/lay.pro | 9 +- src/lay/laySaltGrainDetailsTextWidget.cc | 33 +- src/lay/laySaltGrainPropertiesDialog.cc | 268 +++++++++ src/lay/laySaltGrainPropertiesDialog.h | 84 +++ src/lay/laySaltManagerDialog.cc | 52 +- src/lay/laySaltManagerDialog.h | 13 +- 7 files changed, 1109 insertions(+), 25 deletions(-) create mode 100644 src/lay/SaltGrainPropertiesDialog.ui create mode 100644 src/lay/laySaltGrainPropertiesDialog.cc create mode 100644 src/lay/laySaltGrainPropertiesDialog.h diff --git a/src/lay/SaltGrainPropertiesDialog.ui b/src/lay/SaltGrainPropertiesDialog.ui new file mode 100644 index 000000000..f9edcf633 --- /dev/null +++ b/src/lay/SaltGrainPropertiesDialog.ui @@ -0,0 +1,675 @@ + + + SaltGrainPropertiesDialog + + + + 0 + 0 + 754 + 571 + + + + Package Properties + + + + + + + 0 + 1 + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 75 + true + + + + License + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 5 + + + + + + + + + 0 + 0 + + + + <a href="%1">Open link</a> + + + true + + + + + + + + 1 + 0 + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + 2 + + + 6 + + + + + Qt::Vertical + + + + 20 + 0 + + + + + + + + Select a Screenshot Image + + + ... + + + + :/add.png:/add.png + + + + 64 + 64 + + + + + + + + Reset Icon + + + ... + + + + :/clear_edit.png:/clear_edit.png + + + true + + + + + + + Showcase image +(max 1024x1024) + + + + + + + Select an Icon Image + + + ... + + + + :/salt_icon.png:/salt_icon.png + + + + 64 + 64 + + + + + + + + Reset Screenshot + + + ... + + + + :/clear_edit.png:/clear_edit.png + + + true + + + + + + + Icon +(64x64) + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + 75 + true + + + + Title + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + 0 + 0 + + + + + + + + + true + + + + (use numeric versions like "1.5" or "2.1.3") + + + + + + + + 16777215 + 80 + + + + + + + + + 75 + true + + + + Documentation + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 75 + true + + + + +Images + + + Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing + + + + + + + + + + + 75 + true + + + + +Description + + + Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing + + + + + + + + 75 + true + + + + Author + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 75 + true + + + + Author contact + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + + + + Qt::Vertical + + + + 736 + 32 + + + + + + + + + 0 + 0 + + + + + true + + + + (enter an URL to provide a documentation link) + + + + + + + + 0 + 0 + + + + + + + + + true + + + + (license information like "GPLv3" or "MIT") + + + + + + + + 75 + true + + + + Version + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 5 + + + + + + + + + 75 + true + + + + +Depends on + + + Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing + + + + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Add new dependency + + + ... + + + + :/add.png:/add.png + + + true + + + + + + + Delete dependency + + + ... + + + + :/clear.png:/clear.png + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + true + + + false + + + true + + + + Name + + + + + Version + + + + + URL + + + + + + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + version + title + author + author_contact + license + doc + doc_url + icon_config_button + icon_delete_button + screenshot_config_button + screenshot_delete_button + dependencies + add_dependency + remove_dependency + + + + + + + buttonBox + accepted() + SaltGrainPropertiesDialog + accept() + + + 546 + 425 + + + 561 + 435 + + + + + buttonBox + rejected() + SaltGrainPropertiesDialog + reject() + + + 638 + 418 + + + 649 + 433 + + + + + diff --git a/src/lay/lay.pro b/src/lay/lay.pro index 572c78a0d..da3d53cb0 100644 --- a/src/lay/lay.pro +++ b/src/lay/lay.pro @@ -50,7 +50,8 @@ HEADERS = \ laySaltGrain.h \ laySaltGrains.h \ laySaltManagerDialog.h \ - laySaltGrainDetailsTextWidget.h + laySaltGrainDetailsTextWidget.h \ + laySaltGrainPropertiesDialog.h FORMS = \ ClipDialog.ui \ @@ -96,7 +97,8 @@ FORMS = \ TechLoadOptionsEditorPage.ui \ TechSaveOptionsEditorPage.ui \ MainConfigPage7.ui \ - SaltManagerDialog.ui + SaltManagerDialog.ui \ + SaltGrainPropertiesDialog.ui SOURCES = \ gsiDeclLayApplication.cc \ @@ -144,7 +146,8 @@ SOURCES = \ laySaltGrain.cc \ laySaltGrains.cc \ laySaltManagerDialog.cc \ - laySaltGrainDetailsTextWidget.cc + laySaltGrainDetailsTextWidget.cc \ + laySaltGrainPropertiesDialog.cc RESOURCES = layBuildInMacros.qrc \ layHelpResources.qrc \ diff --git a/src/lay/laySaltGrainDetailsTextWidget.cc b/src/lay/laySaltGrainDetailsTextWidget.cc index 730a6daeb..f71bdda14 100644 --- a/src/lay/laySaltGrainDetailsTextWidget.cc +++ b/src/lay/laySaltGrainDetailsTextWidget.cc @@ -40,10 +40,8 @@ SaltGrainDetailsTextWidget::SaltGrainDetailsTextWidget (QWidget *w) void SaltGrainDetailsTextWidget::set_grain (SaltGrain *g) { - if (mp_grain != g) { - mp_grain = g; - setHtml (details_text ()); - } + mp_grain = g; + setHtml (details_text ()); } QVariant @@ -51,15 +49,30 @@ SaltGrainDetailsTextWidget::loadResource (int type, const QUrl &url) { if (url.path () == QString::fromUtf8 ("/icon")) { + int icon_dim = 64; + if (!mp_grain || mp_grain->icon ().isNull ()) { + return QImage (":/salt_icon.png"); + } else { + QImage img = mp_grain->icon (); - if (img.width () != 64) { - return img.scaled (QSize (64, 64), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); + if (img.width () != icon_dim || img.height () != icon_dim) { + + img = img.scaled (QSize (icon_dim, icon_dim), Qt::KeepAspectRatio, Qt::SmoothTransformation); + + QImage final_img (icon_dim, icon_dim, QImage::Format_ARGB32); + final_img.fill (QColor (0, 0, 0, 0)); + QPainter painter (&final_img); + painter.drawImage ((icon_dim - img.width ()) / 2, (icon_dim - img.height ()) / 2, img); + + return final_img; + } else { return img; } + } } else if (url.path () == QString::fromUtf8 ("/screenshot")) { @@ -69,7 +82,7 @@ SaltGrainDetailsTextWidget::loadResource (int type, const QUrl &url) QImage smask (s.size (), QImage::Format_ARGB32_Premultiplied); smask.fill (QColor (0, 0, 0, 0)); { - int border = 4; + int border = 0; int radius = 6; QPainter painter (&smask); @@ -210,9 +223,11 @@ SaltGrainDetailsTextWidget::details_text () stream << "

" << QObject::tr ("Installed: ") << "" << g->installed_time ().toString () << "

"; } if (! g->dependencies ().empty ()) { - stream << "

" << QObject::tr ("Depends on: ") << "

"; + stream << "

" << QObject::tr ("Depends on: ") << "
"; for (std::vector::const_iterator d = g->dependencies ().begin (); d != g->dependencies ().end (); ++d) { - stream << "    " << tl::to_qstring (tl::escaped_to_html (d->name)) << " " << tl::to_qstring (tl::escaped_to_html (d->url)) << "
"; + stream << "    " << tl::to_qstring (tl::escaped_to_html (d->name)) << " "; + stream << tl::to_qstring (tl::escaped_to_html (d->version)) << " - "; + stream << "[" << tl::to_qstring (tl::escaped_to_html (d->url)) << "]
"; } stream << "

"; } diff --git a/src/lay/laySaltGrainPropertiesDialog.cc b/src/lay/laySaltGrainPropertiesDialog.cc new file mode 100644 index 000000000..1c60abd4d --- /dev/null +++ b/src/lay/laySaltGrainPropertiesDialog.cc @@ -0,0 +1,268 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2017 Matthias Koefferlein + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +#include "laySaltGrainPropertiesDialog.h" +#include "laySalt.h" +#include "tlString.h" +#include "tlExceptions.h" + +#include +#include +#include + +namespace lay +{ + +SaltGrainPropertiesDialog::SaltGrainPropertiesDialog (QWidget *parent) + : QDialog (parent), mp_salt (0) +{ + Ui::SaltGrainPropertiesDialog::setupUi (this); + + m_title = windowTitle (); + m_open_label = open_label->text (); + + connect (icon_delete_button, SIGNAL (clicked ()), this, SLOT (reset_icon ())); + connect (icon_config_button, SIGNAL (clicked ()), this, SLOT (set_icon ())); + connect (screenshot_delete_button, SIGNAL (clicked ()), this, SLOT (reset_screenshot ())); + connect (screenshot_config_button, SIGNAL (clicked ()), this, SLOT (set_screenshot ())); + connect (doc_url, SIGNAL (textChanged (const QString &)), this, SLOT (url_changed (const QString &))); + connect (add_dependency, SIGNAL (clicked ()), this, SLOT (add_dependency_clicked ())); + connect (remove_dependency, SIGNAL (clicked ()), this, SLOT (remove_dependency_clicked ())); + connect (dependencies, SIGNAL (itemChanged (QTreeWidgetItem *, int)), this, SLOT (dependency_changed (QTreeWidgetItem *, int))); +} + +void +SaltGrainPropertiesDialog::update_controls () +{ + setWindowTitle (m_title + tl::to_qstring (" - " + m_grain.name ())); + + version->setText (tl::to_qstring (m_grain.version ())); + title->setText (tl::to_qstring (m_grain.title ())); + author->setText (tl::to_qstring (m_grain.author ())); + author_contact->setText (tl::to_qstring (m_grain.author_contact ())); + doc->setText (tl::to_qstring (m_grain.doc ())); + doc_url->setText (tl::to_qstring (m_grain.doc_url ())); + license->setText (tl::to_qstring (m_grain.license ())); + + dependencies->clear (); + for (std::vector::const_iterator d = m_grain.dependencies ().begin (); d != m_grain.dependencies ().end (); ++d) { + QTreeWidgetItem *item = new QTreeWidgetItem (dependencies); + item->setFlags (item->flags () | Qt::ItemIsEditable); + item->setText (0, tl::to_qstring (d->name)); + item->setText (1, tl::to_qstring (d->version)); + item->setText (2, tl::to_qstring (d->url)); + dependencies->addTopLevelItem (item); + } + + update_icon (); + update_screenshot (); +} + +void +SaltGrainPropertiesDialog::update_icon () +{ + if (m_grain.icon ().isNull ()) { + icon_config_button->setIcon (QIcon (":/salt_icon.png")); + } else { + QImage img = m_grain.icon (); + if (img.width () == icon_config_button->iconSize ().width ()) { + icon_config_button->setIcon (QIcon (QPixmap::fromImage (img))); + } else { + icon_config_button->setIcon (QIcon (QPixmap::fromImage (img.scaled (icon_config_button->iconSize (), Qt::KeepAspectRatio, Qt::SmoothTransformation)))); + } + } +} + +void +SaltGrainPropertiesDialog::update_screenshot () +{ + if (m_grain.screenshot ().isNull ()) { + screenshot_config_button->setIcon (QIcon (":/add.png")); + } else { + QImage img = m_grain.screenshot (); + if (img.width () == screenshot_config_button->iconSize ().width ()) { + screenshot_config_button->setIcon (QIcon (QPixmap::fromImage (img))); + } else { + screenshot_config_button->setIcon (QIcon (QPixmap::fromImage (img.scaled (screenshot_config_button->iconSize (), Qt::KeepAspectRatio, Qt::SmoothTransformation)))); + } + } +} + +void +SaltGrainPropertiesDialog::update_data () +{ + m_grain.set_version (tl::to_string (version->text ())); + m_grain.set_title (tl::to_string (title->text ())); + m_grain.set_author (tl::to_string (author->text ())); + m_grain.set_author_contact (tl::to_string (author_contact->text ())); + m_grain.set_doc (tl::to_string (doc->toPlainText ())); + m_grain.set_doc_url (tl::to_string (doc_url->text ())); + m_grain.set_license (tl::to_string (license->text ())); + + m_grain.dependencies ().clear (); + for (int i = 0; i < dependencies->topLevelItemCount (); ++i) { + QTreeWidgetItem *item = dependencies->topLevelItem (i); + QString name = item->text (0).simplified (); + QString version = item->text (1).simplified (); + QString url = item->text (2).simplified (); + if (! name.isEmpty ()) { + lay::SaltGrain::Dependency dep = lay::SaltGrain::Dependency (); + dep.name = tl::to_string (name); + dep.version = tl::to_string (version); + dep.url = tl::to_string (url); + m_grain.dependencies ().push_back (dep); + } + } +} + +void +SaltGrainPropertiesDialog::dependency_changed (QTreeWidgetItem *item, int column) +{ + if (column == 0 && mp_salt) { + + // set URL and version for known grains + std::string name = tl::to_string (item->text (0).simplified ()); + if (name == m_grain.name ()) { + + item->setText (1, QString ()); + item->setText (2, tr ("(must not depend on itself)")); + + } else { + + SaltGrain *g = 0; + for (lay::Salt::flat_iterator i = mp_salt->begin_flat (); i != mp_salt->end_flat (); ++i) { + if ((*i)->name () == name) { + g = *i; + } + } + if (g) { + item->setText (1, tl::to_qstring (g->version ())); + item->setText (2, tl::to_qstring (g->url ())); + } else { + item->setText (1, QString ()); + item->setText (2, tr ("(unknown packet)")); + } + + } + + } +} + +void +SaltGrainPropertiesDialog::url_changed (const QString &url) +{ + // inserts the URL into the label + open_label->setText (m_open_label.arg (url)); +} + +void +SaltGrainPropertiesDialog::set_icon () +{ +BEGIN_PROTECTED + + const int max_dim = 256; + + QString fileName = QFileDialog::getOpenFileName (this, tr ("Pick Icon Image File"), m_image_dir, tr ("Images (*.png *.jpg)")); + if (! fileName.isNull ()) { + QImage img = QImage (fileName); + if (img.width () > max_dim || img.height () > max_dim) { + throw tl::Exception (tl::to_string (tr ("Icon image too big -\nmust be %1x%2 pixels max, but is %3x%4").arg (max_dim).arg (max_dim).arg (img.width ()).arg (img.height ()))); + } + m_grain.set_icon (img); + m_image_dir = QFileInfo (fileName).path (); + update_icon (); + } + +END_PROTECTED +} + +void +SaltGrainPropertiesDialog::reset_icon () +{ + m_grain.set_icon (QImage ()); + update_icon (); +} + +void +SaltGrainPropertiesDialog::set_screenshot () +{ +BEGIN_PROTECTED + + const int max_dim = 1024; + + QString fileName = QFileDialog::getOpenFileName (this, tr ("Pick Showcase Image File"), m_image_dir, tr ("Images (*.png *.jpg)")); + if (! fileName.isNull ()) { + QImage img = QImage (fileName); + if (img.width () > max_dim || img.height () > max_dim) { + throw tl::Exception (tl::to_string (tr ("Showcase image too big -\nmust be %1x%2 pixels max, but is %3x%4").arg (max_dim).arg (max_dim).arg (img.width ()).arg (img.height ()))); + } + m_grain.set_screenshot (img); + m_image_dir = QFileInfo (fileName).path (); + update_screenshot (); + } + +END_PROTECTED +} + +void +SaltGrainPropertiesDialog::reset_screenshot () +{ + m_grain.set_screenshot (QImage ()); + update_screenshot (); +} + +void +SaltGrainPropertiesDialog::add_dependency_clicked () +{ + QTreeWidgetItem *item = new QTreeWidgetItem (dependencies); + item->setFlags (item->flags () | Qt::ItemIsEditable); + dependencies->addTopLevelItem (item); + dependencies->setCurrentItem (dependencies->topLevelItem (dependencies->topLevelItemCount () - 1)); +} + +void +SaltGrainPropertiesDialog::remove_dependency_clicked () +{ + int index = dependencies->indexOfTopLevelItem (dependencies->currentItem ()); + if (index >= 0 && index < dependencies->topLevelItemCount ()) { + delete dependencies->topLevelItem (index); + } +} + +bool +SaltGrainPropertiesDialog::exec_dialog (lay::SaltGrain *grain, lay::Salt *salt) +{ + m_grain = *grain; + mp_salt = salt; + update_controls (); + + bool res = exec (); + if (res) { + update_data (); + *grain = m_grain; + } + + mp_salt = 0; + return res; +} + +} diff --git a/src/lay/laySaltGrainPropertiesDialog.h b/src/lay/laySaltGrainPropertiesDialog.h new file mode 100644 index 000000000..e9eeae2d7 --- /dev/null +++ b/src/lay/laySaltGrainPropertiesDialog.h @@ -0,0 +1,84 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2017 Matthias Koefferlein + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +#ifndef HDR_laySaltGrainPropertiesDialog +#define HDR_laySaltGrainPropertiesDialog + +#include "laySaltGrain.h" + +#include + +#include "ui_SaltGrainPropertiesDialog.h" + +namespace lay +{ + +class Salt; + +/** + * @brief The dialog for managing the Salt ("Packages") + */ +class SaltGrainPropertiesDialog + : public QDialog, private Ui::SaltGrainPropertiesDialog +{ +Q_OBJECT + +public: + /** + * @brief Constructor + */ + SaltGrainPropertiesDialog (QWidget *parent); + + /** + * @brief Executes the dialog for the given grain + * If the dialog is committed with "Ok", the new data is written into + * the grain provided and "true" is returned. Otherwise, "false" is + * returned and the object remains unchanged. + */ + bool exec_dialog (lay::SaltGrain *grain, lay::Salt *salt); + +private slots: + void reset_icon (); + void set_icon (); + void reset_screenshot (); + void set_screenshot (); + void url_changed (const QString &url); + void add_dependency_clicked (); + void remove_dependency_clicked (); + void dependency_changed (QTreeWidgetItem *item, int column); + +private: + lay::SaltGrain m_grain; + lay::Salt *mp_salt; + QString m_title; + QString m_open_label; + QString m_image_dir; + + void update_controls (); + void update_data (); + void update_icon (); + void update_screenshot (); +}; + +} + +#endif diff --git a/src/lay/laySaltManagerDialog.cc b/src/lay/laySaltManagerDialog.cc index 8da3b9934..8c83aa9f8 100644 --- a/src/lay/laySaltManagerDialog.cc +++ b/src/lay/laySaltManagerDialog.cc @@ -21,6 +21,7 @@ */ #include "laySaltManagerDialog.h" +#include "laySaltGrainPropertiesDialog.h" #include "laySalt.h" #include "tlString.h" @@ -80,16 +81,29 @@ public: } else if (role == Qt::DecorationRole) { + int icon_dim = 64; + const lay::SaltGrain *g = mp_salt->begin_flat ()[index.row ()]; if (g->icon ().isNull ()) { return QIcon (":/salt_icon.png"); } else { - QPixmap px = QPixmap::fromImage (g->icon ()); - if (px.width () == 64) { - return px; + + QImage img = g->icon (); + if (img.width () == icon_dim && img.height () == icon_dim) { + return QPixmap::fromImage (img); } else { - return px.scaled (QSize (64, 64), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); + + img = img.scaled (QSize (icon_dim, icon_dim), Qt::KeepAspectRatio, Qt::SmoothTransformation); + + QImage final_img (icon_dim, icon_dim, QImage::Format_ARGB32); + final_img.fill (QColor (0, 0, 0, 0)); + QPainter painter (&final_img); + painter.drawImage ((icon_dim - img.width ()) / 2, (icon_dim - img.height ()) / 2, img); + + return QPixmap::fromImage (final_img); + } + } } else { @@ -225,6 +239,9 @@ SaltManagerDialog::SaltManagerDialog (QWidget *parent) m_current_changed_enabled (true) { Ui::SaltManagerDialog::setupUi (this); + mp_properties_dialog = new lay::SaltGrainPropertiesDialog (this); + + connect (edit_button, SIGNAL (clicked ()), this, SLOT (edit_properties ())); // @@@ salt = lay::Salt (); salt_initialized = false; @@ -247,8 +264,19 @@ SaltManagerDialog::SaltManagerDialog (QWidget *parent) connect (salt_view->selectionModel (), SIGNAL (currentChanged (const QModelIndex &, const QModelIndex &)), this, SLOT (current_changed ())); + // @@@ +} - // ... +void +SaltManagerDialog::edit_properties () +{ + SaltGrain *g = current_grain (); + if (g) { + if (mp_properties_dialog->exec_dialog (g, mp_salt)) { + current_changed (); + // @@@ + } + } } void @@ -277,12 +305,7 @@ SaltManagerDialog::salt_changed () void SaltManagerDialog::current_changed () { - SaltModel *model = dynamic_cast (salt_view->model ()); - if (! model) { - return; - } - - SaltGrain *g = model->grain_from_index (salt_view->currentIndex ()); + SaltGrain *g = current_grain (); details_text->set_grain (g); if (!g) { details_frame->setEnabled (false); @@ -293,4 +316,11 @@ SaltManagerDialog::current_changed () } } +lay::SaltGrain * +SaltManagerDialog::current_grain () +{ + SaltModel *model = dynamic_cast (salt_view->model ()); + return model ? model->grain_from_index (salt_view->currentIndex ()) : 0; +} + } diff --git a/src/lay/laySaltManagerDialog.h b/src/lay/laySaltManagerDialog.h index 24b55a62e..170e02b7d 100644 --- a/src/lay/laySaltManagerDialog.h +++ b/src/lay/laySaltManagerDialog.h @@ -20,8 +20,8 @@ */ -#ifndef HDR_laySaltManager -#define HDR_laySaltManager +#ifndef HDR_laySaltManagerDialog +#define HDR_laySaltManagerDialog #include @@ -32,6 +32,7 @@ namespace lay class Salt; class SaltGrain; +class SaltGrainPropertiesDialog; /** * @brief The dialog for managing the Salt ("Packages") @@ -58,9 +59,17 @@ private slots: */ void current_changed (); + /** + * @brief Called when the "edit" button is pressed + */ + void edit_properties (); + private: lay::Salt *mp_salt; bool m_current_changed_enabled; + lay::SaltGrainPropertiesDialog *mp_properties_dialog; + + lay::SaltGrain *current_grain (); }; }