changeset 646:b2bf2c268930

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
author thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
date Mon, 12 Jan 2009 13:14:17 +0000
parents 54d6696e8673
children 91587363161e
files src/IndentHandler.cpp src/IndentHandler.h src/UniversalIndentGUI_NPP/UniversalIndentGUI_NPP.cpp
diffstat 3 files changed, 32 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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
+}
--- 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);
--- 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;