# HG changeset patch # User thomas_-_s # Date 1231766057 0 # Node ID b2bf2c2689302554dcea31eed681443c52cbb095 # Parent 54d6696e86734a25765887018ace67ae891bc7a9 NPP Improved the update/repaint events a bit, so that the GUI reacts better on user inputs. git-svn-id: svn://svn.code.sf.net/p/universalindent/code/trunk@905 59b1889a-e5ac-428c-b0c7-476e01d41282 diff -r 54d6696e8673 -r b2bf2c268930 src/IndentHandler.cpp --- a/src/IndentHandler.cpp Mon Jan 12 12:56:46 2009 +0000 +++ b/src/IndentHandler.cpp Mon Jan 12 13:14:17 2009 +0000 @@ -99,7 +99,7 @@ toolBox->setObjectName(QString::fromUtf8("toolBox")); #ifdef UNIVERSALINDENTGUI_NPP_EXPORTS - connect( toolBox, SIGNAL(currentChanged(int)), this, SLOT(repaint()) ); + connect( toolBox, SIGNAL(currentChanged(int)), this, SLOT(updateDrawing()) ); #endif // UNIVERSALINDENTGUI_NPP_EXPORTS //toolBox->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); @@ -945,6 +945,9 @@ QObject::connect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(handleChangedIndenterSettings())); QObject::connect(chkBox, SIGNAL(clicked()), this, SLOT(handleChangedIndenterSettings())); +#ifdef UNIVERSALINDENTGUI_NPP_EXPORTS + connect( spinBox, SIGNAL(valueChanged(int)), this, SLOT(updateDrawing()) ); +#endif // UNIVERSALINDENTGUI_NPP_EXPORTS } // edit type is boolean so create a checkbox else if ( editType == "boolean" ) { @@ -1023,6 +1026,9 @@ QObject::connect(lineEdit, SIGNAL(editingFinished()), this, SLOT(handleChangedIndenterSettings())); QObject::connect(chkBox, SIGNAL(clicked()), this, SLOT(handleChangedIndenterSettings())); +#ifdef UNIVERSALINDENTGUI_NPP_EXPORTS + connect( lineEdit, SIGNAL(textChanged(const QString)), this, SLOT(updateDrawing()) ); +#endif // UNIVERSALINDENTGUI_NPP_EXPORTS } // edit type is multiple so create a combobox with label else if ( editType == "multiple" ) { @@ -1074,8 +1080,9 @@ QObject::connect(comboBox, SIGNAL(activated(int)), this, SLOT(handleChangedIndenterSettings())); QObject::connect(chkBox, SIGNAL(clicked()), this, SLOT(handleChangedIndenterSettings())); #ifdef UNIVERSALINDENTGUI_NPP_EXPORTS - connect( comboBox, SIGNAL(activated(int)), comboBox, SLOT(repaint()) ); + connect( comboBox, SIGNAL(activated(int)), this, SLOT(updateDrawing()) ); #endif // UNIVERSALINDENTGUI_NPP_EXPORTS + } } } @@ -1126,7 +1133,7 @@ QApplication::setOverrideCursor(Qt::WaitCursor); #ifdef UNIVERSALINDENTGUI_NPP_EXPORTS - disconnect( toolBox, SIGNAL(currentChanged(int)), this, SLOT(repaint()) ); + disconnect( toolBox, SIGNAL(currentChanged(int)), this, SLOT(updateDrawing()) ); #endif // UNIVERSALINDENTGUI_NPP_EXPORTS // Generate the parameter string that will be saved to the indenters config file. @@ -1179,7 +1186,7 @@ QApplication::restoreOverrideCursor(); #ifdef UNIVERSALINDENTGUI_NPP_EXPORTS - connect( toolBox, SIGNAL(currentChanged(int)), this, SLOT(repaint()) ); + connect( toolBox, SIGNAL(currentChanged(int)), this, SLOT(updateDrawing()) ); toolBox->removeItem( toolBox->indexOf(&dummyWidget) ); #endif // UNIVERSALINDENTGUI_NPP_EXPORTS } @@ -1572,3 +1579,22 @@ int IndentHandler::getIndenterId() { return indenterSelectionCombobox->currentIndex(); } + + +void IndentHandler::updateDrawing() { +#ifdef UNIVERSALINDENTGUI_NPP_EXPORTS + if ( isVisible() ) { + QRect savedGeometry = geometry(); + setGeometry( savedGeometry.adjusted(0,0,0,1) ); + repaint(); + setGeometry( savedGeometry ); + } +#endif // UNIVERSALINDENTGUI_NPP_EXPORTS +} + +void IndentHandler::wheelEvent( QWheelEvent *event ) { +#ifdef UNIVERSALINDENTGUI_NPP_EXPORTS + QWidget::wheelEvent( event ); + updateDrawing(); +#endif // UNIVERSALINDENTGUI_NPP_EXPORTS +} diff -r 54d6696e8673 -r b2bf2c268930 src/IndentHandler.h --- a/src/IndentHandler.h Mon Jan 12 12:56:46 2009 +0000 +++ b/src/IndentHandler.h Mon Jan 12 13:14:17 2009 +0000 @@ -86,6 +86,7 @@ protected: bool event( QEvent *event ); void closeEvent(QCloseEvent *event); + void wheelEvent( QWheelEvent *event ); private slots: void setIndenter(int indenterID); @@ -95,6 +96,7 @@ void createIndenterCallShellScript(); void resetIndenterParameter(); void handleChangedIndenterSettings(); + void updateDrawing(); private: QString callExecutableIndenter(QString sourceCode, QString inputFileExtension); diff -r 54d6696e8673 -r b2bf2c268930 src/UniversalIndentGUI_NPP/UniversalIndentGUI_NPP.cpp --- a/src/UniversalIndentGUI_NPP/UniversalIndentGUI_NPP.cpp Mon Jan 12 12:56:46 2009 +0000 +++ b/src/UniversalIndentGUI_NPP/UniversalIndentGUI_NPP.cpp Mon Jan 12 13:14:17 2009 +0000 @@ -30,7 +30,6 @@ HANDLE g_hModule = NULL; NppData nppData; FuncItem funcItem[nbFunc]; -//toolbarIcons g_TBWndMgr; IndentHandler *indentHandler;