From 439201f5550faabcc897e503d859e26a7dff2372 Mon Sep 17 00:00:00 2001 From: w1z7ard Date: Mon, 3 Aug 2009 00:39:27 +0000 Subject: [PATCH] fixed qt file dialog bug. git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/trunk@1253 6778bc44-b910-0410-a7a0-be141de4315d --- src/projectM-qt/qplaylistfiledialog.hpp | 7 +- src/projectM-qt/qprojectm.hpp | 5 +- src/projectM-qt/qprojectm_mainwindow.cpp | 2 +- src/projectM-qt/qprojectmwidget.hpp | 238 ++++++++++++----------- 4 files changed, 135 insertions(+), 117 deletions(-) diff --git a/src/projectM-qt/qplaylistfiledialog.hpp b/src/projectM-qt/qplaylistfiledialog.hpp index 1e4c4b58c..90a4cf500 100644 --- a/src/projectM-qt/qplaylistfiledialog.hpp +++ b/src/projectM-qt/qplaylistfiledialog.hpp @@ -124,7 +124,7 @@ private slots: - void updateFileMode(const QString & fileName) { + void updateFileMode(const QString fileName) { QString filter = getFilter(); @@ -159,8 +159,9 @@ void updateFileMode(const QStringList & selectedFiles) { if (selectedFiles.empty()) - updateFileMode(QString()); - updateFileMode(selectedFiles[0]); + updateFileMode(QString()); + else + updateFileMode(selectedFiles[0]); } }; diff --git a/src/projectM-qt/qprojectm.hpp b/src/projectM-qt/qprojectm.hpp index 06f5c4788..396cc7357 100644 --- a/src/projectM-qt/qprojectm.hpp +++ b/src/projectM-qt/qprojectm.hpp @@ -20,7 +20,7 @@ class QProjectM : public QObject, public projectM { Q_OBJECT public: - QProjectM(const std::string & config_file):projectM(config_file, projectM::FLAG_DISABLE_PLAYLIST_LOAD) {} + QProjectM(const std::string & config_file):projectM(config_file, projectM::FLAG_DISABLE_PLAYLIST_LOAD) {} void presetSwitchedEvent(bool hardCut, unsigned int index) const { presetSwitchedSignal(hardCut, index); @@ -28,6 +28,7 @@ class QProjectM : public QObject, public projectM { signals: void presetSwitchedSignal(bool hardCut, unsigned int index) const; public slots: - + + }; #endif diff --git a/src/projectM-qt/qprojectm_mainwindow.cpp b/src/projectM-qt/qprojectm_mainwindow.cpp index 364bdbfb1..4dfa481d2 100644 --- a/src/projectM-qt/qprojectm_mainwindow.cpp +++ b/src/projectM-qt/qprojectm_mainwindow.cpp @@ -550,7 +550,7 @@ void QProjectM_MainWindow::keyReleaseEvent ( QKeyEvent * e ) return; if (ui->tableView->hasFocus()) - return; + return; } setMenuAndStatusBarsVisible(!_menuAndStatusBarsVisible); diff --git a/src/projectM-qt/qprojectmwidget.hpp b/src/projectM-qt/qprojectmwidget.hpp index 6be5045e4..7807afa3b 100644 --- a/src/projectM-qt/qprojectmwidget.hpp +++ b/src/projectM-qt/qprojectmwidget.hpp @@ -9,133 +9,147 @@ #include #include -class QProjectMWidget : public QGLWidget { - - Q_OBJECT // must include this if you use Qt signals/slots +class QProjectMWidget : public QGLWidget +{ + + Q_OBJECT // must include this if you use Qt signals/slots public: static const int MOUSE_VISIBLE_TIMEOUT_MS = 5000; - QProjectMWidget(const std::string & config_file, QWidget * parent, QMutex * audioMutex = 0) - : QGLWidget(parent), m_config_file(config_file), m_projectM(0), m_audioMutex(audioMutex), m_mouseTimer(0) { - - m_mouseTimer = new QTimer(this); - - - m_mouseTimer->start(MOUSE_VISIBLE_TIMEOUT_MS); - - connect(m_mouseTimer, SIGNAL(timeout()), this, SLOT(hideMouse())); - this->setMouseTracking(true); - - } + QProjectMWidget ( const std::string & config_file, QWidget * parent, QMutex * audioMutex = 0 ) + : QGLWidget ( parent ), m_config_file ( config_file ), m_projectM ( 0 ), m_audioMutex ( audioMutex ), m_mouseTimer ( 0 ) + { + + m_mouseTimer = new QTimer ( this ); + m_mouseTimer->start ( MOUSE_VISIBLE_TIMEOUT_MS ); + + connect ( m_mouseTimer, SIGNAL ( timeout() ), this, SLOT ( hideMouse() ) ); + this->setMouseTracking ( true ); + + } ~QProjectMWidget() { destroyProjectM(); } - void resizeGL(int w, int h) + void resizeGL ( int w, int h ) { - // Setup viewport, projection etc - setup_opengl(w,h); - m_projectM->projectM_resetGL( w, h ); + // Setup viewport, projection etc + setup_opengl ( w,h ); + m_projectM->projectM_resetGL ( w, h ); } - inline const std::string & configFile() { + inline const std::string & configFile() + { return m_config_file; } - - inline void seizePresetLock() { + + inline void seizePresetLock() + { m_presetSeizeMutex.lock(); m_presetWasLocked = qprojectM()->isPresetLocked(); - qprojectM()->setPresetLock(true); + qprojectM()->setPresetLock ( true ); } - - inline void releasePresetLock() { - qprojectM()->setPresetLock(m_presetWasLocked); + + inline void releasePresetLock() + { + qprojectM()->setPresetLock ( m_presetWasLocked ); m_presetSeizeMutex.unlock(); } - + inline QProjectM * qprojectM() { return m_projectM; } protected slots: - inline void mouseMoveEvent ( QMouseEvent * event ) { - + inline void mouseMoveEvent ( QMouseEvent * event ) + { + m_mouseTimer->stop(); QApplication::restoreOverrideCursor(); - m_mouseTimer->start(MOUSE_VISIBLE_TIMEOUT_MS); - + m_mouseTimer->start ( MOUSE_VISIBLE_TIMEOUT_MS ); + } - - inline void leaveEvent ( QEvent * event ) { + + inline void leaveEvent ( QEvent * event ) + { /// @bug testing if this resolves a bug for ubuntu users - QApplication::restoreOverrideCursor(); + QApplication::restoreOverrideCursor(); } - + public slots: - void resetProjectM() { - + void resetProjectM() + { + qDebug() << "reset start"; - - emit(projectM_BeforeDestroy()); - - if (m_audioMutex) + + emit ( projectM_BeforeDestroy() ); + + if ( m_audioMutex ) m_audioMutex->lock(); - + destroyProjectM(); - - // Make a new projectM instance and reset the opengl state + + // Make a new projectM instance and reset the opengl state initializeGL(); - - // Allow audio thread to continue its business - if (m_audioMutex) { + + // Allow audio thread to continue its business + if ( m_audioMutex ) + { m_audioMutex->unlock(); } qDebug() << "reinit'ed"; } - void setAudioMutex(QMutex * mutex) { - m_audioMutex = mutex; + void setAudioMutex ( QMutex * mutex ) + { + m_audioMutex = mutex; } - void setPresetLock(int state) { - m_projectM->setPresetLock((bool)state); - emit(presetLockChanged((bool)state)); + void setPresetLock ( int state ) + { + m_projectM->setPresetLock ( ( bool ) state ); + emit ( presetLockChanged ( ( bool ) state ) ); } - void setShuffleEnabled(int state) { - m_projectM->setShuffleEnabled((bool)state); - emit(shuffleEnabledChanged((bool)state)); + void setShuffleEnabled ( int state ) + { + m_projectM->setShuffleEnabled ( ( bool ) state ); + emit ( shuffleEnabledChanged ( ( bool ) state ) ); } - void mousePressEvent ( QMouseEvent * event ) { + void mousePressEvent ( QMouseEvent * event ) + { this->setFocus(); } signals: - void projectM_Initialized(QProjectM *); + void projectM_Initialized ( QProjectM * ); void projectM_BeforeDestroy(); - void presetLockChanged(bool isLocked); - void shuffleEnabledChanged(bool isShuffleEnabled); - + void presetLockChanged ( bool isLocked ); + void shuffleEnabledChanged ( bool isShuffleEnabled ); + private slots: - void hideMouse() { - if (this->underMouse() && this->hasFocus()) - QApplication::setOverrideCursor(Qt::BlankCursor); + void hideMouse() + { + if ( this->underMouse() && this->hasFocus() ) + QApplication::setOverrideCursor ( Qt::BlankCursor ); } private: std::string m_config_file; - QProjectM * m_projectM; - void destroyProjectM() { - - if (m_projectM) { - delete(m_projectM); + QProjectM * m_projectM; + void destroyProjectM() + { + + if ( m_projectM ) + { + delete ( m_projectM ); m_projectM = 0; } } - + QTimer * m_mouseTimer; QMutex * m_audioMutex; QMutex m_presetSeizeMutex; @@ -143,11 +157,13 @@ class QProjectMWidget : public QGLWidget { protected: - void keyReleaseEvent ( QKeyEvent * e ) { - + void keyReleaseEvent ( QKeyEvent * e ) + { + projectMKeycode pkey; bool ignore = false; - switch (e->key()) { + switch ( e->key() ) + { case Qt::Key_F4: pkey = PROJECTM_K_F4; break; @@ -166,13 +182,13 @@ class QProjectMWidget : public QGLWidget { case Qt::Key_L: pkey = PROJECTM_K_l; ignore = true; - break; + break; case Qt::Key_N: pkey = PROJECTM_K_n; break; - case Qt::Key_P: + case Qt::Key_P: pkey = PROJECTM_K_p; - break; + break; case Qt::Key_F5: pkey = PROJECTM_K_F5; break; @@ -182,18 +198,18 @@ class QProjectMWidget : public QGLWidget { } projectMModifier modifier; - m_projectM->key_handler(PROJECTM_KEYDOWN, pkey, modifier); - if (ignore) + m_projectM->key_handler ( PROJECTM_KEYDOWN, pkey, modifier ); + if ( ignore ) e->ignore(); - + } void initializeGL() - { + { - this->m_projectM = new QProjectM(m_config_file); - projectM_Initialized(m_projectM); + this->m_projectM = new QProjectM ( m_config_file ); + projectM_Initialized ( m_projectM ); } inline void paintGL() @@ -203,48 +219,48 @@ class QProjectMWidget : public QGLWidget { private: - void setup_opengl( int w, int h ) + void setup_opengl ( int w, int h ) { /* Our shading model--Gouraud (smooth). */ - glShadeModel( GL_SMOOTH); + glShadeModel ( GL_SMOOTH ); /* Culling. */ - // glCullFace( GL_BACK ); - // glFrontFace( GL_CCW ); - // glEnable( GL_CULL_FACE ); + // glCullFace( GL_BACK ); + // glFrontFace( GL_CCW ); + // glEnable( GL_CULL_FACE ); /* Set the clear color. */ - glClearColor( 0, 0, 0, 0 ); + glClearColor ( 0, 0, 0, 0 ); /* Setup our viewport. */ - glViewport( 0, 0, w, h ); - /* - * Change to the projection matrix and set - * our viewing volume. - */ - glMatrixMode(GL_TEXTURE); + glViewport ( 0, 0, w, h ); + /* + * Change to the projection matrix and set + * our viewing volume. + */ + glMatrixMode ( GL_TEXTURE ); glLoadIdentity(); - // gluOrtho2D(0.0, (GLfloat) width, 0.0, (GLfloat) height); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - // glFrustum(0.0, height, 0.0,width,10,40); - glMatrixMode(GL_MODELVIEW); + // gluOrtho2D(0.0, (GLfloat) width, 0.0, (GLfloat) height); + glMatrixMode ( GL_PROJECTION ); glLoadIdentity(); - glDrawBuffer(GL_BACK); - glReadBuffer(GL_BACK); - glEnable(GL_BLEND); + // glFrustum(0.0, height, 0.0,width,10,40); + glMatrixMode ( GL_MODELVIEW ); + glLoadIdentity(); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - // glBlendFunc(GL_SRC_ALPHA, GL_ONE); - glEnable(GL_LINE_SMOOTH); - glEnable(GL_POINT_SMOOTH); - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + glDrawBuffer ( GL_BACK ); + glReadBuffer ( GL_BACK ); + glEnable ( GL_BLEND ); + + glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); + // glBlendFunc(GL_SRC_ALPHA, GL_ONE); + glEnable ( GL_LINE_SMOOTH ); + glEnable ( GL_POINT_SMOOTH ); + glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f ); // glClear(GL_COLOR_BUFFER_BIT); - - // glCopyTexImage2D(GL_TEXTURE_2D,0,GL_RGB,0,0,texsize,texsize,0); - //glCopyTexSubImage2D(GL_TEXTURE_2D,0,0,0,0,0,texsize,texsize); - glLineStipple(2, 0xAAAA); + + // glCopyTexImage2D(GL_TEXTURE_2D,0,GL_RGB,0,0,texsize,texsize,0); + //glCopyTexSubImage2D(GL_TEXTURE_2D,0,0,0,0,0,texsize,texsize); + glLineStipple ( 2, 0xAAAA ); }