From 68a3abdc75c15101ac50453b975b68eca7b13d72 Mon Sep 17 00:00:00 2001 From: doitux Date: Thu, 31 May 2007 07:46:19 +0000 Subject: [PATCH] sound free? --- src/gui/qt/mainwindow.ui | 13 +++--- src/gui/qt/mainwindow/mainwindowimpl.cpp | 56 +++++++++++++++++------- src/gui/qt/mainwindow/mainwindowimpl.h | 2 +- 3 files changed, 48 insertions(+), 23 deletions(-) diff --git a/src/gui/qt/mainwindow.ui b/src/gui/qt/mainwindow.ui index 638bd8e0..0242bb4f 100644 --- a/src/gui/qt/mainwindow.ui +++ b/src/gui/qt/mainwindow.ui @@ -6138,6 +6138,9 @@ Quit + + Ctrl+Q + @@ -6169,6 +6172,11 @@ + + MyRightTabWidget + QTabWidget +
myrighttabwidget.h
+
MyLeftTabWidget QTabWidget @@ -6179,11 +6187,6 @@ QLabel
mysetlabel.h
- - MyRightTabWidget - QTabWidget -
myrighttabwidget.h
-
spinBox_set diff --git a/src/gui/qt/mainwindow/mainwindowimpl.cpp b/src/gui/qt/mainwindow/mainwindowimpl.cpp index a3aadcd6..cc117996 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.cpp +++ b/src/gui/qt/mainwindow/mainwindowimpl.cpp @@ -486,9 +486,6 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent) int width = tempMetrics.width(tr("Stop")); pushButton_break->setMinimumSize(width+10,20); - //ShortCuts -// QShortcut *startNewGameKeys = new QShortcut(QKeySequence(Qt::Key_Control + Qt::Key_N), this); -// connect( startNewGameKeys, SIGNAL(activated() ), actionNewGame, SLOT( trigger() ) ); //Clear Focus groupBox_LeftToolBox->clearFocus(); @@ -521,6 +518,12 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent) myWaitingForServerGameDialog = new waitForServerToStartGameDialogImpl(this); myAboutPokerthDialog = new aboutPokerthImpl(this); + +// //ShortCuts +// QShortcut *quitPokerTHKeys = new QShortcut(QKeySequence(Qt::Key_Control + Qt::Key_Q), this); +// connect( quitPokerTHKeys, SIGNAL(activated() ), actionQuit, SLOT( trigger() ) ); + + //Connects connect(dealFlopCards0Timer, SIGNAL(timeout()), this, SLOT( dealFlopCards1() )); connect(dealFlopCards1Timer, SIGNAL(timeout()), this, SLOT( dealFlopCards2() )); @@ -638,16 +641,18 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent) audio_buffers = 4096; music = NULL; - SDL_Init(SDL_INIT_AUDIO); + if (myConfig->readConfigInt("PlaySoundEffects")) { - if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)) { - printf("Unable to open audio!\n"); - exit(1); - } - - Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels); - //SOUNDTESTING + SDL_Init(SDL_INIT_AUDIO); + if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)) { + printf("Unable to open audio!\n"); + exit(1); + } + + Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels); + //SOUNDTESTING + } } mainWindowImpl::~mainWindowImpl() { @@ -869,8 +874,18 @@ void mainWindowImpl::callSettingsDialog() { } } } - - + //Audio Clean? + if (myConfig->readConfigInt("PlaySoundEffects") == 0) { SDLMixerClean(); } + else { +// SDL_Init(SDL_INIT_AUDIO); +// +// if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)) { +// printf("Unable to open audio!\n"); +// exit(1); +// } +// +// Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels); + } } } @@ -2519,7 +2534,7 @@ void mainWindowImpl::keyPressEvent ( QKeyEvent * event ) { if (event->key() == Qt::Key_D) { setLabelArray[0]->startTimeOutAnimation(myConfig->readConfigInt("NetTimeOutPlayerAction")); } //f if (event->key() == Qt::Key_E) { setLabelArray[0]->stopTimeOutAnimation(); } //f if (event->key() == Qt::Key_S) { playSound(); } //s - if (event->key() == Qt::Key_W) { qApp->quit(); } //s +// if (event->key() == Qt::Key_W) { qApp->quit(); } //s if (event->key() == 16777249) { pushButton_break->click(); ctrlPressed = TRUE; @@ -2610,6 +2625,15 @@ void mainWindowImpl::musicDone() { music = NULL; } +void mainWindowImpl::SDLMixerClean() { + //SOUND close + Mix_HaltMusic(); + Mix_FreeMusic(music); + music = NULL; +// Mix_CloseAudio(); +// SDL_Quit(); +} + void mainWindowImpl::playSound() { if(myConfig->readConfigInt("PlaySoundEffects")) { @@ -2638,9 +2662,7 @@ void mainWindowImpl::quitPokerTH() { mySession->terminateNetworkClient(); if (myServerGuiInterface.get()) myServerGuiInterface->getSession().terminateNetworkServer(); - //SOUND close - Mix_CloseAudio(); - SDL_Quit(); + SDLMixerClean(); // cout << "PokerTH finished" << endl; qApp->quit(); diff --git a/src/gui/qt/mainwindow/mainwindowimpl.h b/src/gui/qt/mainwindow/mainwindowimpl.h index ce5576a4..0b3037a0 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.h +++ b/src/gui/qt/mainwindow/mainwindowimpl.h @@ -253,9 +253,9 @@ public slots: void userActionTimeOutReached(); - //SOUND TESTING void playSound(); void musicDone(); + void SDLMixerClean(); void quitPokerTH();