]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Improve SALOME style handling
authorvsr <vsr@opencascade.com>
Sat, 1 Nov 2008 11:07:41 +0000 (11:07 +0000)
committervsr <vsr@opencascade.com>
Sat, 1 Nov 2008 11:07:41 +0000 (11:07 +0000)
src/Style/Style_PrefDlg.cxx
src/Style/Style_PrefDlg.h

index 32713dd756de9105301a62e41c7a9dff3cc2df1d..3dd264117ad9480b1c63a785def3de026a50a7af 100644 (file)
 #include <QGridLayout>
 #include <QGroupBox>
 #include <QHBoxLayout>
+#include <QKeyEvent>
 #include <QLabel>
 #include <QListWidget>
 #include <QMap>
+#include <QMessageBox>
 #include <QPushButton>
 #include <QRadioButton>
 #include <QSlider>
@@ -483,7 +485,7 @@ void Style_PrefDlg::PaletteEditor::onAuto()
   \param parent parent widget
 */
 Style_PrefDlg::Style_PrefDlg( QWidget* parent )
-  : QtxDialog( parent, true, true, OK | Close | Apply | Help ),
+  : QtxDialog( parent, true, true, OK | Close | Apply ),
     myResMgr( 0 )
 {
   // set title
@@ -712,6 +714,29 @@ void Style_PrefDlg::accept()
   QtxDialog::accept();
 }
 
+/*!
+  \brief Process key press event
+  \param e key event
+*/
+void Style_PrefDlg::keyPressEvent( QKeyEvent* e )
+{
+  if ( e->key() == Qt::Key_Delete ) {
+    QListWidgetItem* item = myStylesList->currentItem();
+    if ( item && item->data( TypeRole ).toInt() == User ) {
+      if ( QMessageBox::question( this,
+                                 tr( "Delete user theme" ),
+                                 tr( "Remove theme %1?" ).arg( item->text() ),
+                                 QMessageBox::Yes | QMessageBox::No,
+                                 QMessageBox::Yes ) == QMessageBox::Yes ) {
+       resourceMgr()->remove( item->data( NameRole ).toString() );
+       resourceMgr()->save();
+       delete item;
+      }
+    }
+  }
+  QtxDialog::keyPressEvent( e );
+}
+
 /*!
   \brief Get SALOME themes resource manager
   \return themes resource manager
index 73972665d6ddf1ae0f535f791a076029a226a9be..4b6f6dbdeb841469bbabe51c5454a52b61537eeb 100644 (file)
@@ -59,6 +59,9 @@ public:
 
   void               accept();
 
+protected:
+  void               keyPressEvent( QKeyEvent* );
+
 private:
   Style_ResourceMgr* resourceMgr();
   void               fromModel( Style_Model* );