From fee806704d74e882b10e79cab4ef75ba2aecf4f4 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 25 Mar 2017 10:15:24 +0100 Subject: [PATCH] WIP: combined installation and browser dialog --- src/lay/SaltGrainInstallationDialog.ui | 313 ------- src/lay/SaltManagerDialog.ui | 968 ++++++++++++++-------- src/lay/lay.pro | 9 +- src/lay/laySaltGrainInstallationDialog.cc | 101 --- src/lay/laySaltGrainInstallationDialog.h | 76 -- src/lay/laySaltManagerDialog.cc | 103 ++- src/lay/laySaltManagerDialog.h | 18 +- 7 files changed, 737 insertions(+), 851 deletions(-) delete mode 100644 src/lay/SaltGrainInstallationDialog.ui delete mode 100644 src/lay/laySaltGrainInstallationDialog.cc delete mode 100644 src/lay/laySaltGrainInstallationDialog.h diff --git a/src/lay/SaltGrainInstallationDialog.ui b/src/lay/SaltGrainInstallationDialog.ui deleted file mode 100644 index ab54731cb..000000000 --- a/src/lay/SaltGrainInstallationDialog.ui +++ /dev/null @@ -1,313 +0,0 @@ - - - SaltGrainInstallationDialog - - - - 0 - 0 - 692 - 440 - - - - Salt Mine Repository Browser - - - - - - Qt::Horizontal - - - - - 4 - - - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 2 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 75 - true - - - - Repository - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Install - - - - - - - Qt::Horizontal - - - - 126 - 20 - - - - - - - - - 0 - 0 - - - - - - - - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - true - - - - 64 - 64 - - - - false - - - - - - - - - - - - 1 - 0 - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 4 - - - 0 - - - 0 - - - 0 - - - - - - 75 - true - - - - Details - - - - - - - true - - - - - - - - - - - QDialogButtonBox::Apply|QDialogButtonBox::Close - - - - - - - - :/add.png:/add.png - - - New - - - New package - - - - - - :/clear.png:/clear.png - - - Delete - - - Delete package - - - - - - :/import.png:/import.png - - - Import - - - Import package - - - - - - lay::DecoratedLineEdit - QLineEdit -
layWidgets.h
-
- - lay::SaltGrainDetailsTextWidget - QTextBrowser -
laySaltGrainDetailsTextWidget.h
-
-
- - details_text - - - - - - - button_box - rejected() - SaltGrainInstallationDialog - reject() - - - 559 - 425 - - - 576 - 437 - - - - -
diff --git a/src/lay/SaltManagerDialog.ui b/src/lay/SaltManagerDialog.ui index d16b5af31..0a4bcf96c 100644 --- a/src/lay/SaltManagerDialog.ui +++ b/src/lay/SaltManagerDialog.ui @@ -15,187 +15,43 @@ - - - Qt::Horizontal + + + 0 - - - - 4 - + + + Installed Packages + + - - - - 0 - 0 - + + + Qt::Horizontal - - QFrame::NoFrame - - - QFrame::Raised - - - - 2 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::NoFocus - - - Install Package - - - ... - - - - :/import.png:/import.png - - - true - - - - - - - Qt::Horizontal - - - - 50 - 0 - - - - - - - - Qt::NoFocus - - - Create New Package - - - ... - - - - :/add.png:/add.png - - - true - - - - - - - Qt::NoFocus - - - Uninstall Package - - - ... - - - - :/clear.png:/clear.png - - - true - - - - - - - - - - - 0 - 0 - - - - 0 - - - - - 0 - - - 0 - + + - 0 - - - 0 + 4 - - - true + + + + 0 + 0 + - - - 64 - 64 - - - - false - - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - QFrame::StyledPanel + QFrame::NoFrame QFrame::Raised - + + + 2 + 0 @@ -209,187 +65,621 @@ 0 - - - QFrame::NoFrame + + + Qt::NoFocus - + + Create New Package + + + ... + + + + :/add.png:/add.png + + true - - - - 0 - 0 - 320 - 204 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - :/salt.png - - - - - - - - 0 - 0 - - - - - 9 - 50 - false - - - - <h1>Salt Package Manager</h1> - - - - - - - - 1 - 0 - - - - - 0 - 0 - - - - <html><body><h4>No packages are installed currently.</h4><p>Use<br/> -<table> - <tr><td width="30"><a href=":import"><img src=":/import.png"></a></td><td>to import a package from an<br/>external repository</td></tr> - <tr></tr> - <tr><td><a href=":add"><img src=":/add.png"></a></td><td>to create a new package</td></tr> -</table> -</body></html> - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - + + + + + + Qt::NoFocus + + + Uninstall Package + + + ... + + + + :/clear.png:/clear.png + + + true + + + + + + + Qt::Horizontal + + + + 50 + 0 + + + + + + + + + + + :/find.png + + + + + + + + 0 + 0 + + + + + + + 0 + 0 + + + + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + true + + + + 64 + 64 + + + + false + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::NoFrame + + + true + + + + + 0 + 0 + 343 + 207 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + :/salt.png + + + + + + + + 0 + 0 + + + + + 9 + 50 + false + + + + <h1>Salt Package Manager</h1> + + + + + + + + 1 + 0 + + + + + 0 + 0 + + + + <html><body><h4>No packages are installed currently.</h4><p>Use<br/> +<table> + <tr><td>The "Install New Packages" tab to install a package<br/>from an external repository</td></tr> + <tr></tr> + <tr><td>The <a href=":add"><img src=":/add.png"></a> button to create a new package</td></tr> +</table> +</body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + false + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + + + + + + + + + + + + + 1 + 0 + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 4 + + + 0 + + + 0 + + + 0 + + + + + + 75 + true + + + + Details + + + + + + + Edit Package Details + + + Edit + + + + :/edit.png:/edit.png + + + true + + + + + + + true + + + - - - - 1 - 0 - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 4 - - - 0 - - - 0 - - - 0 - - - - - - 75 - true - + + + Install New Packages + + + + + + + 0 + 1 + - - Details + + Qt::Horizontal + + + + 4 + + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 2 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Mark for installation + + + Mark + + + + + + + Qt::Horizontal + + + + 126 + 20 + + + + + + + + + + + :/find.png + + + + + + + + 0 + 0 + + + + + + + + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + true + + + + 64 + 64 + + + + false + + + + + + + + + + + + 1 + 0 + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 4 + + + 0 + + + 0 + + + 0 + + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 75 + true + + + + Details + + + + + + + false + + + ... + + + + :/empty_16.png:/empty_16.png + + + true + + + + + + + + + + true + + + + + - - - - Edit Package Details + + + + QFrame::NoFrame - - Edit - - - - :/edit.png:/edit.png - - - true - - - - - - - true + + QFrame::Raised + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Apply + + + false + + + false + + + + + + + Qt::Horizontal + + + + 563 + 20 + + + + + @@ -442,6 +732,11 @@ + + lay::DecoratedLineEdit + QLineEdit +
layWidgets.h
+
lay::SaltGrainDetailsTextWidget QTextBrowser @@ -449,11 +744,18 @@
+ mode_tab + search_installed_edit salt_view - install_button - create_button - delete_button details_text + edit_button + search_new_edit + mark_button + salt_mine_view + details_new_text + toolButton + apply_button + scrollArea diff --git a/src/lay/lay.pro b/src/lay/lay.pro index 0d1251609..7d1bff20d 100644 --- a/src/lay/lay.pro +++ b/src/lay/lay.pro @@ -53,8 +53,7 @@ HEADERS = \ laySaltGrainDetailsTextWidget.h \ laySaltGrainPropertiesDialog.h \ laySaltDownloadManager.h \ - laySaltModel.h \ - laySaltGrainInstallationDialog.h + laySaltModel.h FORMS = \ ClipDialog.ui \ @@ -102,8 +101,7 @@ FORMS = \ MainConfigPage7.ui \ SaltManagerDialog.ui \ SaltGrainPropertiesDialog.ui \ - SaltGrainTemplateSelectionDialog.ui \ - SaltGrainInstallationDialog.ui + SaltGrainTemplateSelectionDialog.ui SOURCES = \ gsiDeclLayApplication.cc \ @@ -154,8 +152,7 @@ SOURCES = \ laySaltGrainDetailsTextWidget.cc \ laySaltGrainPropertiesDialog.cc \ laySaltDownloadManager.cc \ - laySaltModel.cc \ - laySaltGrainInstallationDialog.cc + laySaltModel.cc RESOURCES = layBuildInMacros.qrc \ layHelpResources.qrc \ diff --git a/src/lay/laySaltGrainInstallationDialog.cc b/src/lay/laySaltGrainInstallationDialog.cc deleted file mode 100644 index f12d7f576..000000000 --- a/src/lay/laySaltGrainInstallationDialog.cc +++ /dev/null @@ -1,101 +0,0 @@ - -/* - - 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 "laySaltGrainInstallationDialog.h" -#include "laySaltModel.h" -#include "laySaltGrainPropertiesDialog.h" -#include "laySalt.h" -#include "ui_SaltGrainTemplateSelectionDialog.h" -#include "tlString.h" -#include "tlExceptions.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace lay -{ - -// -------------------------------------------------------------------------------------- -// SaltGrainInstallation implementation - -SaltGrainInstallationDialog::SaltGrainInstallationDialog (QWidget *parent, lay::Salt *salt) - : QDialog (parent), mp_salt (salt) -{ - Ui::SaltGrainInstallationDialog::setupUi (this); - - // TODO: cache package list - // @@@ - m_salt_mine.load ("/home/matthias/salt.mine"); - // @@@ - - SaltModel *model = new SaltModel (this, &m_salt_mine); - salt_view->setModel (model); - salt_view->setItemDelegate (new SaltItemDelegate (this)); - salt_view->setCurrentIndex (model->index (0, 0, QModelIndex ())); - - connect (salt_view->selectionModel (), SIGNAL (currentChanged (const QModelIndex &, const QModelIndex &)), this, SLOT (current_changed ())); - connect (mark_button, SIGNAL (clicked ()), this, SLOT (mark ())); - connect (button_box->button (QDialogButtonBox::Apply), SIGNAL (clicked ()), this, SLOT (apply ())); - - current_changed (); -} - -void -SaltGrainInstallationDialog::current_changed () -{ - SaltGrain *g = current_grain (); - details_text->set_grain (g); - details_frame->setEnabled (g != 0); -} - -lay::SaltGrain * -SaltGrainInstallationDialog::current_grain () -{ - SaltModel *model = dynamic_cast (salt_view->model ()); - return model ? model->grain_from_index (salt_view->currentIndex ()) : 0; -} - -void -SaltGrainInstallationDialog::apply () -{ - - // @@@ - -} - -void -SaltGrainInstallationDialog::mark () -{ - - // @@@ - -} - -} diff --git a/src/lay/laySaltGrainInstallationDialog.h b/src/lay/laySaltGrainInstallationDialog.h deleted file mode 100644 index 9c7986fb2..000000000 --- a/src/lay/laySaltGrainInstallationDialog.h +++ /dev/null @@ -1,76 +0,0 @@ - -/* - - 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_laySaltGrainInstallationDialog -#define HDR_laySaltGrainInstallationDialog - -#include "laySalt.h" - -#include - -#include "ui_SaltGrainInstallationDialog.h" - -namespace lay -{ - -class Salt; - -/** - * @brief The dialog for managing the Salt ("Packages") - */ -class SaltGrainInstallationDialog - : public QDialog, private Ui::SaltGrainInstallationDialog -{ -Q_OBJECT - -public: - /** - * @brief Constructor - */ - SaltGrainInstallationDialog (QWidget *parent, lay::Salt *salt); - -private slots: - /** - * @brief Called when the currently selected package (grain) has changed - */ - void current_changed (); - - /** - * @brief Called when the Apply button is clicked - */ - void apply (); - - /** - * @brief Called when the Mark button is pressed - */ - void mark (); - -private: - lay::Salt *mp_salt; - lay::Salt m_salt_mine; - - lay::SaltGrain *current_grain (); -}; - -} - -#endif diff --git a/src/lay/laySaltManagerDialog.cc b/src/lay/laySaltManagerDialog.cc index c0d0934be..09d4a66ed 100644 --- a/src/lay/laySaltManagerDialog.cc +++ b/src/lay/laySaltManagerDialog.cc @@ -23,7 +23,6 @@ #include "laySaltManagerDialog.h" #include "laySaltModel.h" #include "laySaltGrainPropertiesDialog.h" -#include "laySaltGrainInstallationDialog.h" #include "laySalt.h" #include "ui_SaltGrainTemplateSelectionDialog.h" #include "tlString.h" @@ -119,6 +118,25 @@ void make_salt () salt.add_location (tl::to_string (QDir::homePath () + QString::fromUtf8("/.klayout/salt"))); } } +lay::Salt *get_salt () +{ + salt = lay::Salt (); salt_initialized = false; + make_salt (); + return &salt; +} +// @@@ + +// @@@ +lay::Salt salt_mine; +void make_salt_mine () +{ + salt_mine.load ("/home/matthias/salt.mine"); +} +lay::Salt *get_salt_mine () +{ + make_salt_mine(); + return &salt_mine; +} // @@@ SaltManagerDialog::SaltManagerDialog (QWidget *parent) @@ -131,27 +149,46 @@ SaltManagerDialog::SaltManagerDialog (QWidget *parent) 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 ())); - connect (install_button, SIGNAL (clicked ()), this, SLOT (install_grain ())); -// @@@ - salt = lay::Salt (); salt_initialized = false; - make_salt (); - mp_salt = &salt; -// @@@ + mp_salt = get_salt (); + mp_salt_mine = get_salt_mine (); - SaltModel *model = new SaltModel (this, mp_salt); + SaltModel *model; + + model = new SaltModel (this, mp_salt); salt_view->setModel (model); salt_view->setItemDelegate (new SaltItemDelegate (this)); + model = new SaltModel (this, mp_salt_mine); + salt_mine_view->setModel (model); + salt_mine_view->setItemDelegate (new SaltItemDelegate (this)); + + mode_tab->setCurrentIndex (mp_salt->is_empty () ? 1 : 0); + + connect (mode_tab, SIGNAL (currentChanged (int)), this, SLOT (mode_changed ())); connect (mp_salt, SIGNAL (collections_changed ()), this, SLOT (salt_changed ())); + connect (mp_salt_mine, SIGNAL (collections_changed ()), this, SLOT (salt_mine_changed ())); salt_changed (); + salt_mine_changed (); connect (salt_view->selectionModel (), SIGNAL (currentChanged (const QModelIndex &, const QModelIndex &)), this, SLOT (current_changed ())); + connect (salt_mine_view->selectionModel (), SIGNAL (currentChanged (const QModelIndex &, const QModelIndex &)), this, SLOT (mine_current_changed ())); // @@@ } +void +SaltManagerDialog::mode_changed () +{ + // keeps the splitters in sync + if (mode_tab->currentIndex () == 1) { + splitter_new->setSizes (splitter->sizes ()); + } else if (mode_tab->currentIndex () == 0) { + splitter->setSizes (splitter_new->sizes ()); + } +} + void SaltManagerDialog::edit_properties () { @@ -159,7 +196,6 @@ SaltManagerDialog::edit_properties () if (g) { if (mp_properties_dialog->exec_dialog (g, mp_salt)) { current_changed (); - // @@@ } } } @@ -218,18 +254,6 @@ BEGIN_PROTECTED END_PROTECTED } -void -SaltManagerDialog::install_grain () -{ -BEGIN_PROTECTED - - // @@@ TODO: cache this somewhere - don't recreate this dialog always - SaltGrainInstallationDialog inst_dialog (this, mp_salt); - inst_dialog.exec (); - -END_PROTECTED -} - void SaltManagerDialog::salt_changed () { @@ -286,4 +310,41 @@ SaltManagerDialog::current_grain () return model ? model->grain_from_index (salt_view->currentIndex ()) : 0; } +void +SaltManagerDialog::salt_mine_changed () +{ + SaltModel *model = dynamic_cast (salt_mine_view->model ()); + if (! model) { + return; + } + + // NOTE: the disabling of the event handler prevents us from + // letting the model connect to the salt's signal directly. + m_current_changed_enabled = false; + model->update (); + m_current_changed_enabled = true; + + // select the first grain + if (model->rowCount (QModelIndex ()) > 0) { + salt_mine_view->setCurrentIndex (model->index (0, 0, QModelIndex ())); + } + + mine_current_changed (); +} + +void +SaltManagerDialog::mine_current_changed () +{ + SaltGrain *g = mine_current_grain (); + details_new_text->set_grain (g); + details_new_frame->setEnabled (g != 0); +} + +lay::SaltGrain * +SaltManagerDialog::mine_current_grain () +{ + SaltModel *model = dynamic_cast (salt_mine_view->model ()); + return model ? model->grain_from_index (salt_mine_view->currentIndex ()) : 0; +} + } diff --git a/src/lay/laySaltManagerDialog.h b/src/lay/laySaltManagerDialog.h index 232d40403..305969f73 100644 --- a/src/lay/laySaltManagerDialog.h +++ b/src/lay/laySaltManagerDialog.h @@ -54,11 +54,21 @@ private slots: */ void salt_changed (); + /** + * @brief Called when the repository (salt mine) has changed + */ + void salt_mine_changed (); + /** * @brief Called when the currently selected package (grain) has changed */ void current_changed (); + /** + * @brief Called when the currently selected package from the salt mine has changed + */ + void mine_current_changed (); + /** * @brief Called when the "edit" button is pressed */ @@ -79,12 +89,18 @@ private slots: */ void install_grain (); + /** + * @brief Called when the mode tab changed + */ + void mode_changed (); + private: - lay::Salt *mp_salt; + lay::Salt *mp_salt, *mp_salt_mine; bool m_current_changed_enabled; lay::SaltGrainPropertiesDialog *mp_properties_dialog; lay::SaltGrain *current_grain (); + lay::SaltGrain *mine_current_grain (); }; }