From 221a612427efd019fd37ca419540bd8170663300 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Tue, 15 Jan 2008 20:07:55 +0000 Subject: [PATCH] second attempt to port to QT4, not working, still a lot to do... --- src/llconclientdlg.cpp | 144 ++++++++++++++++++++++++++++++++--------- src/llconclientdlg.h | 16 ++++- src/llconserverdlg.cpp | 3 +- src/llconserverdlg.h | 2 +- src/server.cpp | 2 +- src/server.h | 2 +- src/util.cpp | 11 ++-- windows/sound.h | 2 +- 8 files changed, 139 insertions(+), 43 deletions(-) diff --git a/src/llconclientdlg.cpp b/src/llconclientdlg.cpp index 0bf57389..a7dfd7ab 100755 --- a/src/llconclientdlg.cpp +++ b/src/llconclientdlg.cpp @@ -30,7 +30,9 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent ) : pClient ( pNCliP ), QDialog ( parent ), ClientSettingsDlg ( pNCliP, 0, Qt::WindowMinMaxButtonsHint ) { - /* add help text to controls */ + setupUi ( this ); + + // add help text to controls QString strInpLevH = tr ( "Input level meter: Shows the level of the " "input audio signal of the sound card. The level is in dB. Overload " "should be avoided." ); @@ -94,17 +96,19 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent ) // we want the cursor to be at IP address line edit at startup LineEditServerAddr->setFocus(); - /* init status label */ + // init status label OnTimerStatus(); - /* init connection button text */ + // init connection button text PushButtonConnect->setText ( CON_BUT_CONNECTTEXT ); - /* init input level meter bars */ - ProgressBarInputLevelL->setTotalSteps ( NUM_STEPS_INP_LEV_METER ); - ProgressBarInputLevelL->setProgress ( 0 ); - ProgressBarInputLevelR->setTotalSteps ( NUM_STEPS_INP_LEV_METER ); - ProgressBarInputLevelR->setProgress ( 0 ); + // init input level meter bars + ProgressBarInputLevelL->setMinimum ( 0 ); + ProgressBarInputLevelL->setMaximum ( NUM_STEPS_INP_LEV_METER ); + ProgressBarInputLevelL->setValue ( 0 ); + ProgressBarInputLevelR->setMinimum ( 0 ); + ProgressBarInputLevelR->setMaximum ( NUM_STEPS_INP_LEV_METER ); + ProgressBarInputLevelR->setValue ( 0 ); // init slider controls --- @@ -133,28 +137,111 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent ) } - /* Settings menu ------------------------------------------------------- */ - pSettingsMenu = new QPopupMenu ( this ); - CHECK_PTR ( pSettingsMenu ); - pSettingsMenu->insertItem ( tr ( "&General Settings..." ), this, + + +// TODO check if code works and then clean up!!!!!!! + + +#if 0 + /* Settings menu ------------------------------------------------------- */ + pSettingsMenu = new QMenu ( this ); + pSettingsMenu->addMenu ( tr ( "&General Settings..." ), this, SLOT ( OnOpenGeneralSettings() ) ); pSettingsMenu->insertSeparator(); - pSettingsMenu->insertItem ( tr ( "E&xit" ), this, + pSettingsMenu->addMenu ( tr ( "E&xit" ), this, SLOT ( close() ), CTRL+Key_Q ); /* Main menu bar -------------------------------------------------------- */ pMenu = new QMenuBar ( this ); - CHECK_PTR ( pMenu ); - - pMenu->insertItem ( tr ( "&Settings" ), pSettingsMenu ); - pMenu->insertItem ( tr ( "&?"), new CLlconHelpMenu ( this ) ); + pMenu->addMenu ( tr ( "&Settings" ), pSettingsMenu ); + pMenu->addMenu ( tr ( "&?"), new CLlconHelpMenu ( this ) ); pMenu->setSeparator ( QMenuBar::InWindowsStyle ); /* Now tell the layout about the menu */ CLlconClientDlgBaseLayout->setMenuBar ( pMenu ); +#endif + + + /* Settings menu ------------------------------------------------------- */ + pSettingsMenu = new QMenu ( "&Settings", this ); + pSettingsMenu->addAction ( tr ( "&General Settings..." ), this, + SLOT ( OnOpenGeneralSettings() ) ); + + pSettingsMenu->addSeparator(); + pSettingsMenu->addAction ( tr ( "E&xit" ), this, + SLOT ( close() ), QKeySequence ( Qt::CTRL + Qt::Key_Q ) ); + + + /* Main menu bar -------------------------------------------------------- */ + pMenu = new QMenuBar ( this ); + //pMenu->addMenu ( tr ( "&Settings" ), pSettingsMenu ); + pMenu->addMenu ( pSettingsMenu ); + //pMenu->addMenu ( tr ( "&?" ), new CLlconHelpMenu ( this ) ); + pMenu->addMenu ( new CLlconHelpMenu ( this ) ); +// pMenu->setSeparator ( QMenuBar::InWindowsStyle ); + + // Now tell the layout about the menu + layout()->setMenuBar ( pMenu ); + + + + + /* Menu actions --------------------------------------------------------- */ +/* + pActGeneralSettings = new QAction ( tr ( "&General Settings..."), this ); + connect( pActGeneralSettings, SIGNAL ( triggered() ), + this, SLOT ( OnOpenGeneralSettings() ) ); + + pActExit = new QAction ( tr ( "&Quit" ), this ); + pActExit->setShortcut ( tr ( "Ctrl+Q" ) ); + connect ( pActExit, SIGNAL ( triggered() ), this, SLOT ( close() ) ); + + + pActAbout = new QAction ( tr ( "&About" ), this ); + connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); + + +pActAbout +pHelpMenu +*/ + + /* Main menu bar -------------------------------------------------------- */ +/* +pMainMenuBar + + pMainMenuBar = new QMenuBar ( this ); + pMainMenuBar->addMenu ( tr ( "&Settings" ), pSettingsMenu ); + + pMenu->addMenu ( tr ( "&?"), new CLlconHelpMenu ( this ) ); + pMenu->setSeparator ( QMenuBar::InWindowsStyle ); + + pSettingsMenu = menuBar()->addMenu ( tr ( "&Settings" ) ); + pSettingsMenu->addAction(pActGeneralSettings); + pSettingsMenu->addSeparator(); + pSettingsMenu->addAction(pActExit); + + + pMenu->addMenu ( tr ( "&?"), new CLlconHelpMenu ( this ) ); + pMenu->setSeparator ( QMenuBar::InWindowsStyle ); + + // Now tell the layout about the menu + CLlconClientDlgBaseLayout->setMenuBar ( pMainMenuBar ); +*/ + + + + + + + + + + + + // connections ------------------------------------------------------------- @@ -199,7 +286,7 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent ) CLlconClientDlg::~CLlconClientDlg() { - /* if connected, terminate connection */ + // if connected, terminate connection if ( pClient->IsRunning() ) { pClient->Stop(); @@ -228,8 +315,8 @@ void CLlconClientDlg::OnConnectDisconBut() // stop timer for level meter bars and reset them TimerSigMet.stop(); - ProgressBarInputLevelL->setProgress ( 0 ); - ProgressBarInputLevelR->setProgress ( 0 ); + ProgressBarInputLevelL->setValue ( 0 ); + ProgressBarInputLevelR->setValue ( 0 ); // immediately update status bar OnTimerStatus(); @@ -256,7 +343,7 @@ void CLlconClientDlg::OnConnectDisconBut() { // Restart timer to ensure that the text is visible at // least the time for one complete interval - TimerStatus.changeInterval ( STATUSBAR_UPDATE_TIME ); + TimerStatus.setInterval ( STATUSBAR_UPDATE_TIME ); // show the error in the status bar TextLabelStatus->setText ( tr ( "invalid address" ) ); @@ -271,8 +358,7 @@ void CLlconClientDlg::OnOpenGeneralSettings() // make sure dialog is upfront and has focus ClientSettingsDlg.raise(); - ClientSettingsDlg.setActiveWindow(); - + ClientSettingsDlg.activateWindow(); } void CLlconClientDlg::OnFaderTagTextChanged ( const QString& strNewName ) @@ -286,7 +372,7 @@ void CLlconClientDlg::OnFaderTagTextChanged ( const QString& strNewName ) void CLlconClientDlg::OnTimerSigMet() { - /* get current input levels */ + // get current input levels double dCurSigLevelL = pClient->MicLevelL(); double dCurSigLevelR = pClient->MicLevelR(); @@ -312,14 +398,14 @@ void CLlconClientDlg::OnTimerSigMet() dCurSigLevelR = 0; } - /* show current level */ - ProgressBarInputLevelL->setProgress ( (int) ceil ( dCurSigLevelL ) ); - ProgressBarInputLevelR->setProgress ( (int) ceil ( dCurSigLevelR ) ); + // show current level + ProgressBarInputLevelL->setValue ( (int) ceil ( dCurSigLevelL ) ); + ProgressBarInputLevelR->setValue ( (int) ceil ( dCurSigLevelR ) ); } void CLlconClientDlg::UpdateDisplay() { - /* show connection status in status bar */ + // show connection status in status bar if ( pClient->IsConnected () && pClient->IsRunning () ) { TextLabelStatus->setText ( tr ( "connected" ) ); @@ -330,7 +416,7 @@ void CLlconClientDlg::UpdateDisplay() } } -void CLlconClientDlg::customEvent ( QCustomEvent* Event ) +void CLlconClientDlg::customEvent ( QEvent* Event ) { if ( Event->type() == QEvent::User + 11 ) { diff --git a/src/llconclientdlg.h b/src/llconclientdlg.h index 9b1c8c8c..11d037b8 100755 --- a/src/llconclientdlg.h +++ b/src/llconclientdlg.h @@ -77,13 +77,23 @@ protected: QTimer TimerSigMet; QTimer TimerStatus; - virtual void customEvent ( QCustomEvent* Event ); - virtual void closeEvent ( QCloseEvent * Event ); + virtual void customEvent ( QEvent* Event ); + virtual void closeEvent ( QCloseEvent* Event ); void UpdateDisplay(); - QPopupMenu* pSettingsMenu; + QMenu* pSettingsMenu; QMenuBar* pMenu; +/* + QAction* pActGeneralSettings; + QAction* pActExit; + QAction* pActAbout; + QMenu* pSettingsMenu; + QMenu* pHelpMenu; + QMenuBar* pMainMenuBar; +*/ + + CClientSettingsDlg ClientSettingsDlg; public slots: diff --git a/src/llconserverdlg.cpp b/src/llconserverdlg.cpp index 141aebfc..33d6301d 100755 --- a/src/llconserverdlg.cpp +++ b/src/llconserverdlg.cpp @@ -80,7 +80,6 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent ) /* Main menu bar -------------------------------------------------------- */ pMenu = new QMenuBar ( this ); - CHECK_PTR ( pMenu ); pMenu->insertItem ( tr ( "&?" ), new CLlconHelpMenu ( this ) ); pMenu->setSeparator ( QMenuBar::InWindowsStyle ); @@ -169,7 +168,7 @@ void CLlconServerDlg::OnTimer() } } -void CLlconServerDlg::customEvent ( QCustomEvent* Event ) +void CLlconServerDlg::customEvent ( QEvent* Event ) { if ( Event->type() == QEvent::User + 11 ) { diff --git a/src/llconserverdlg.h b/src/llconserverdlg.h index 13506d50..73aec7d0 100755 --- a/src/llconserverdlg.h +++ b/src/llconserverdlg.h @@ -67,7 +67,7 @@ protected: QMenuBar* pMenu; - virtual void customEvent ( QCustomEvent* Event ); + virtual void customEvent ( QEvent* Event ); void UpdateSliderNetBuf(); public slots: diff --git a/src/server.cpp b/src/server.cpp index 7ed95f59..b584424b 100755 --- a/src/server.cpp +++ b/src/server.cpp @@ -193,7 +193,7 @@ bool CServer::GetTimingStdDev ( double& dCurTiStdDev ) } } -void CServer::customEvent ( QCustomEvent* Event ) +void CServer::customEvent ( QEvent* Event ) { if ( Event->type() == QEvent::User + 11 ) { diff --git a/src/server.h b/src/server.h index 1ff695ba..56ec98a0 100755 --- a/src/server.h +++ b/src/server.h @@ -66,7 +66,7 @@ protected: CVector ProcessData ( CVector >& vecvecdData, CVector& vecdGains ); - virtual void customEvent ( QCustomEvent* Event ); + virtual void customEvent ( QEvent* Event ); QTimer Timer; CVector vecsSendData; diff --git a/src/util.cpp b/src/util.cpp index 4ba1476d..687f8800 100755 --- a/src/util.cpp +++ b/src/util.cpp @@ -354,13 +354,14 @@ QString CAboutDlg::GetVersionAndNameStr ( const bool bWithHtml ) /* Help menu ---------------------------------------------------------------- */ -CLlconHelpMenu::CLlconHelpMenu ( QWidget* parent ) : QPopupMenu ( parent ) +CLlconHelpMenu::CLlconHelpMenu ( QWidget* parent ) : QMenu ( "&?", parent ) { // standard help menu consists of about and what's this help - insertItem ( tr ( "What's &This" ), this, - SLOT ( OnHelpWhatsThis () ), SHIFT+Key_F1 ); - insertSeparator(); - insertItem ( tr ( "&About..." ), this, SLOT ( OnHelpAbout() ) ); + addAction ( tr ( "What's &This" ), this, + SLOT ( OnHelpWhatsThis() ), QKeySequence ( Qt::SHIFT + Qt::Key_F1 ) ); + + addSeparator(); + addAction ( tr ( "&About..." ), this, SLOT ( OnHelpAbout() ) ); } diff --git a/windows/sound.h b/windows/sound.h index f5e0b660..3a248ffa 100755 --- a/windows/sound.h +++ b/windows/sound.h @@ -36,7 +36,7 @@ /* Definitions ****************************************************************/ // switch here between ASIO (Steinberg) or native Windows(TM) sound interface #undef USE_ASIO_SND_INTERFACE -#define USE_ASIO_SND_INTERFACE +//#define USE_ASIO_SND_INTERFACE #define NUM_IN_OUT_CHANNELS 2 /* Stereo recording (but we only