|
From: <sv...@va...> - 2010-03-12 13:33:02
|
Author: cerion
Date: 2010-03-12 13:32:28 +0000 (Fri, 12 Mar 2010)
New Revision: 494
Log:
Eat return/enter keypresses in OptionDialog::eventFilter(),
so we don't end up closing the dialog when an edit fails.
Modified:
branches/valkyrie_qt4port/objects/valgrind_object.cpp
branches/valkyrie_qt4port/options/valkyrie_options_page.cpp
branches/valkyrie_qt4port/options/vk_options_dialog.cpp
branches/valkyrie_qt4port/options/vk_options_dialog.h
branches/valkyrie_qt4port/options/widgets/opt_base_widget.cpp
branches/valkyrie_qt4port/options/widgets/opt_base_widget.h
branches/valkyrie_qt4port/options/widgets/opt_ck_widget.cpp
Modified: branches/valkyrie_qt4port/objects/valgrind_object.cpp
===================================================================
--- branches/valkyrie_qt4port/objects/valgrind_object.cpp 2010-03-12 02:33:11 UTC (rev 493)
+++ branches/valkyrie_qt4port/objects/valgrind_object.cpp 2010-03-12 13:32:28 UTC (rev 494)
@@ -547,9 +547,6 @@
break;
}
- // TODO: do we care if it doesn't end in .supp?
- // - breaks the suppression widgets a little, as only lists those ending in .supp ...
-
// TODO: ? check valid suppression files
}
Modified: branches/valkyrie_qt4port/options/valkyrie_options_page.cpp
===================================================================
--- branches/valkyrie_qt4port/options/valkyrie_options_page.cpp 2010-03-12 02:33:11 UTC (rev 493)
+++ branches/valkyrie_qt4port/options/valkyrie_options_page.cpp 2010-03-12 13:32:28 UTC (rev 494)
@@ -116,6 +116,7 @@
LeWidget* editLedit = (( LeWidget* )m_itemList[VALKYRIE::SRC_EDITOR] );
editLedit->addButton( group1, this, SLOT( getEditor() ) );
connect( editLedit, SIGNAL( returnPressed() ), this, SIGNAL( apply() ) );
+
insertOptionWidget( VALKYRIE::SRC_LINES, group1, true ); // intspin
insertOptionWidget( VALKYRIE::BROWSER, group1, false ); // line edit
Modified: branches/valkyrie_qt4port/options/vk_options_dialog.cpp
===================================================================
--- branches/valkyrie_qt4port/options/vk_options_dialog.cpp 2010-03-12 02:33:11 UTC (rev 493)
+++ branches/valkyrie_qt4port/options/vk_options_dialog.cpp 2010-03-12 13:32:28 UTC (rev 494)
@@ -50,13 +50,6 @@
setupLayout();
// ------------------------------------------------------------
- // setup default state
- QPushButton* applyButton = optionsButtonBox->button( QDialogButtonBox::Apply );
- QPushButton* cancelButton = optionsButtonBox->button( QDialogButtonBox::Cancel );
- applyButton->setEnabled( false );
- cancelButton->setEnabled( false );
-
- // ------------------------------------------------------------
// Add categories, and the default page (other pages loaded on demand)
VkObjectList objList = (( MainWindow* )parent )->getValkyrie()->vkObjList();
@@ -98,12 +91,41 @@
}
+/*!
+ Nothing to cleanup: Qt's object-parenting does it all for us.
+*/
VkOptionsDialog::~VkOptionsDialog()
{
- // optPages.clear();
}
+/*!
+ A return/enter keypress in an option widget isn't eaten up by that
+ widgets' event handler - it's propogated to the QDialog parent.
+ Enter/Return keypresses will then call the QDialog default-button,
+ which is the 'Ok' button.
+
+ We don't know for sure if changes have been applied already, and
+ if the edits failed, we don't want to leave.
+
+ Until this is worked out better, we're just going to ignore these
+ events: shortcuts & mouse are then the only way to accept().
+ TODO: better way of doing this?
+*/
+void VkOptionsDialog::keyPressEvent( QKeyEvent* event )
+{
+ if ( event->key() == Qt::Key_Return ||
+ event->key() == Qt::Key_Enter ) {
+ // eat keypress return/enter event, so dialog doesn't close
+ return;
+ }
+ QDialog::keyPressEvent( event );
+}
+
+
+/*!
+ Setup our basic widget layout, ready for the pages
+*/
void VkOptionsDialog::setupLayout()
{
// ------------------------------------------------------------
@@ -162,21 +184,28 @@
optionsButtonBox->setObjectName( QString::fromUtf8( "optionsButtonBox" ) );
optionsButtonBox->setOrientation( Qt::Horizontal );
optionsButtonBox->setStandardButtons( QDialogButtonBox::Apply |
- QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
+ QDialogButtonBox::Cancel |
+ QDialogButtonBox::Ok );
hLayoutButtons->addWidget( optionsButtonBox );
-
-
// ------------------------------------------------------------
// signals / slots
connect( contentsListWidget, SIGNAL( itemClicked( QListWidgetItem* ) ),
this, SLOT( showPage( QListWidgetItem* ) ) );
- QPushButton* applyButton = optionsButtonBox->button( QDialogButtonBox::Apply );
- connect( applyButton, SIGNAL( released() ), this, SLOT( apply() ) ); // Apply
+ QPushButton* applyButton = optionsButtonBox->button( QDialogButtonBox::Apply );
+ QPushButton* cancelButton = optionsButtonBox->button( QDialogButtonBox::Cancel );
+ QPushButton* okButton = optionsButtonBox->button( QDialogButtonBox::Ok );
+ connect( applyButton, SIGNAL( released() ), this, SLOT( apply() ) ); // Apply
connect( optionsButtonBox, SIGNAL( rejected() ), this, SLOT( reject() ) ); // Cancel
connect( optionsButtonBox, SIGNAL( accepted() ), this, SLOT( accept() ) ); // Ok
connect( saveGlblButton, SIGNAL( released() ), this, SLOT( saveToGlobalConfig() ) );
+
+ // ------------------------------------------------------------
+ // setup default state
+ applyButton->setEnabled( false );
+ cancelButton->setEnabled( false );
+ okButton->setDefault( true );
}
Modified: branches/valkyrie_qt4port/options/vk_options_dialog.h
===================================================================
--- branches/valkyrie_qt4port/options/vk_options_dialog.h 2010-03-12 02:33:11 UTC (rev 493)
+++ branches/valkyrie_qt4port/options/vk_options_dialog.h 2010-03-12 13:32:28 UTC (rev 494)
@@ -39,11 +39,13 @@
private:
void setupLayout();
-
+ void keyPressEvent( QKeyEvent* event ); // overloaded
+
private slots:
bool apply();
- void accept();
- void reject();
+ void accept(); // overloaded
+ void reject(); // overloaded
+
void showPage( QListWidgetItem* );
void pageModified();
void saveToGlobalConfig();
Modified: branches/valkyrie_qt4port/options/widgets/opt_base_widget.cpp
===================================================================
--- branches/valkyrie_qt4port/options/widgets/opt_base_widget.cpp 2010-03-12 02:33:11 UTC (rev 493)
+++ branches/valkyrie_qt4port/options/widgets/opt_base_widget.cpp 2010-03-12 13:32:28 UTC (rev 494)
@@ -23,9 +23,6 @@
#include "utils/vk_config.h"
#include "utils/vk_utils.h"
-#if 0
-#include "vk_messages.h"
-#endif
/* class OptionWidget -------------------------------------------------- */
Modified: branches/valkyrie_qt4port/options/widgets/opt_base_widget.h
===================================================================
--- branches/valkyrie_qt4port/options/widgets/opt_base_widget.h 2010-03-12 02:33:11 UTC (rev 493)
+++ branches/valkyrie_qt4port/options/widgets/opt_base_widget.h 2010-03-12 13:32:28 UTC (rev 494)
@@ -47,7 +47,7 @@
void setEnabled( bool enable );
virtual void reset() = 0;
- virtual void resetDefault() = 0;
+ virtual void resetDefault() = 0; //TODO: not used: wanted?
virtual void saveEdit();
virtual void cancelEdit();
virtual QHBoxLayout* hlayout();
@@ -55,7 +55,7 @@
signals:
void valueChanged( bool, OptionWidget* );
-
+
protected:
QWidget* m_widg;
QLabel* m_wLabel;
Modified: branches/valkyrie_qt4port/options/widgets/opt_ck_widget.cpp
===================================================================
--- branches/valkyrie_qt4port/options/widgets/opt_ck_widget.cpp 2010-03-12 02:33:11 UTC (rev 493)
+++ branches/valkyrie_qt4port/options/widgets/opt_ck_widget.cpp 2010-03-12 13:32:28 UTC (rev 494)
@@ -77,10 +77,7 @@
void CkWidget::resetDefault()
{
- QString val = m_opt->dfltValue.toString();
- bool on = ( val == "1" || val == "on" ||
- val == "yes" || val == "true" );
- setOn( on );
+ setOn( VkConfig::strToBool( m_opt->dfltValue.toString() ) );
}
bool CkWidget::isOn()
|