diff --git a/src/config/configfile.cpp b/src/config/configfile.cpp index d5f57830..21c3f97f 100644 --- a/src/config/configfile.cpp +++ b/src/config/configfile.cpp @@ -48,7 +48,7 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly) myQtToolsInterface = CreateQtToolsWrapper(); // !!!! Revisionsnummer der Configdefaults !!!!! - configRev = 81; + configRev = 82; //standard defaults logOnOffDefault = "1"; @@ -270,8 +270,8 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly) configList.push_back(ConfigInfo("InternetLoginMode", CONFIG_TYPE_INT, "0")); configList.push_back(ConfigInfo("InternetLoginPassword", CONFIG_TYPE_STRING, "")); configList.push_back(ConfigInfo("InternetSavePassword", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("IfInfoMessageShowList", CONFIG_TYPE_STRING_LIST, "Msg")); - //fill tempList firstTime configBufferList = configList; diff --git a/src/gui/qt/gametable/gametableimpl.cpp b/src/gui/qt/gametable/gametableimpl.cpp index 4445edce..11b06df9 100755 --- a/src/gui/qt/gametable/gametableimpl.cpp +++ b/src/gui/qt/gametable/gametableimpl.cpp @@ -3064,26 +3064,21 @@ void gameTableImpl::leaveCurrentNetworkGame() { if (myStartWindow->getSession()->isNetworkClientRunning()) { - if(myConfig->readConfigInt("DisableBackToLobbyWarning")) { - assert(myStartWindow->getSession()); - myStartWindow->getSession()->sendLeaveCurrentGame(); +// T O D O !!!!!!! anzeigen? aus myMessageDialog auslesen per Config!!!!!!! T O D O + + myMessageDialogImpl dialog(myConfig, this); + + if(!dialog.checkIfMesssageWillBeDisplayed(1)) { + + assert(myStartWindow->getSession()); + myStartWindow->getSession()->sendLeaveCurrentGame(); } else { - myMessageDialogImpl dialog(this); - dialog.setWindowTitle(tr("PokerTH - Internet Game Message")); - dialog.label_icon->setPixmap(QPixmap::fromImage(QImage(myAppDataPath +"gfx/gui/misc/logoChip3D.png")).scaled(50,50,Qt::KeepAspectRatio,Qt::SmoothTransformation)); - dialog.label->setText(tr("Attention! Do you really want to leave the current game\nand go back to the lobby?")); - - if (dialog.exec() == QDialog::Accepted ) { - - if(dialog.checkBox->isChecked()) { - myConfig->writeConfigInt("DisableBackToLobbyWarning",1); - myConfig->writeBuffer(); - } - assert(myStartWindow->getSession()); - myStartWindow->getSession()->sendLeaveCurrentGame(); - } + if (dialog.exec(1, tr("Attention! Do you really want to leave the current game\nand go back to the lobby?"), "PokerTH - Internet Game Message", QPixmap(":/gfx/logoChip3D.png")) == QDialog::Accepted ) { + assert(myStartWindow->getSession()); + myStartWindow->getSession()->sendLeaveCurrentGame(); + } } } } diff --git a/src/gui/qt/mymessagedialog/mymessagedialogimpl.cpp b/src/gui/qt/mymessagedialog/mymessagedialogimpl.cpp index 5899e3de..31eeca13 100644 --- a/src/gui/qt/mymessagedialog/mymessagedialogimpl.cpp +++ b/src/gui/qt/mymessagedialog/mymessagedialogimpl.cpp @@ -19,9 +19,18 @@ ***************************************************************************/ #include "mymessagedialogimpl.h" +#include +#include "configfile.h" +#include +#include +#include +#include -myMessageDialogImpl::myMessageDialogImpl(QWidget *parent) - : QDialog(parent) +using namespace std; + + +myMessageDialogImpl::myMessageDialogImpl(ConfigFile *c, QWidget *parent) + : QDialog(parent), myConfig(c), currentMsgId(0) { #ifdef __APPLE__ setWindowModality(Qt::ApplicationModal); @@ -29,3 +38,104 @@ myMessageDialogImpl::myMessageDialogImpl(QWidget *parent) #endif setupUi(this); } + +int myMessageDialogImpl::exec(int messageId, QString msg, QString title, QPixmap pix) +{ + bool show = false; + bool found = false; + + currentMsgId = messageId; + + currentMsgShowList = myConfig->readConfigStringList("IfInfoMessageShowList"); + list::iterator it1; + for(it1= currentMsgShowList.begin(); it1 != currentMsgShowList.end(); it1++) { + + QString tmpString = QString::fromUtf8(it1->c_str()); + if(QString("%1").arg(messageId) == tmpString.split(",").at(1)) { + + found = true; + show = tmpString.split(",").at(0).toInt(); + + break; + } + } + + if(!found) { + currentMsgShowList.push_back(QString("1,%1").arg(messageId).toUtf8().constData()); + myConfig->writeConfigStringList("IfInfoMessageShowList", currentMsgShowList); + myConfig->writeBuffer(); + } + + if(!found || show) { + + setWindowTitle(title); + label_icon->setPixmap(pix.scaled(50,50,Qt::KeepAspectRatio,Qt::SmoothTransformation)); + label->setText(msg); + + return QDialog::exec(); + } + + return -1; +} + +void myMessageDialogImpl::accept() +{ + writeConfig(); + QDialog::accept(); +} + +void myMessageDialogImpl::reject() +{ + writeConfig(); + QDialog::reject(); +} + +void myMessageDialogImpl::writeConfig() +{ + qDebug() << "jo1"; + if(checkBox->isChecked()) { + + list::iterator it1; + for(it1= currentMsgShowList.begin(); it1 != currentMsgShowList.end(); it1++) { + + QString tmpString = QString::fromUtf8(it1->c_str()); + if(QString("%1").arg(currentMsgId) == tmpString.split(",").at(1)) { + + qDebug() << "jo2" << QString("0,%1").arg(currentMsgId).toUtf8().constData(); + (*it1) = QString("0,%1").arg(currentMsgId).toUtf8().constData(); + break; + } + } + + myConfig->writeConfigStringList("IfInfoMessageShowList", currentMsgShowList); + myConfig->writeBuffer(); + } +} + +bool myMessageDialogImpl::checkIfMesssageWillBeDisplayed(int id) +{ + bool found = false; + bool show = true; + + currentMsgShowList = myConfig->readConfigStringList("IfInfoMessageShowList"); + list::iterator it1; + for(it1= currentMsgShowList.begin(); it1 != currentMsgShowList.end(); it1++) { + + QString tmpString = QString::fromUtf8(it1->c_str()); + if(QString("%1").arg(id) == tmpString.split(",").at(1)) { + + found = true; + show = tmpString.split(",").at(0).toInt(); + + break; + } + } + + if(!found) { + currentMsgShowList.push_back(QString("1,%1").arg(id).toUtf8().constData()); + myConfig->writeConfigStringList("IfInfoMessageShowList", currentMsgShowList); + myConfig->writeBuffer(); + } + + return show; +} diff --git a/src/gui/qt/mymessagedialog/mymessagedialogimpl.h b/src/gui/qt/mymessagedialog/mymessagedialogimpl.h index 34c16f30..f1ec575e 100644 --- a/src/gui/qt/mymessagedialog/mymessagedialogimpl.h +++ b/src/gui/qt/mymessagedialog/mymessagedialogimpl.h @@ -22,10 +22,27 @@ #include "ui_mymessagedialog.h" +class ConfigFile; + class myMessageDialogImpl: public QDialog, public Ui::myMessageDialog { Q_OBJECT public: - myMessageDialogImpl(QWidget *parent = 0); + + myMessageDialogImpl(ConfigFile *, QWidget *parent = 0); + +public slots: + + bool checkIfMesssageWillBeDisplayed(int id); + int exec(int messageId, QString msg, QString title, QPixmap pix); + void accept(); + void reject(); + void writeConfig(); + +private: + + ConfigFile *myConfig; + int currentMsgId; + std::list currentMsgShowList; }; diff --git a/src/gui/qt/resources/logoChip3D.png b/src/gui/qt/resources/logoChip3D.png new file mode 100644 index 00000000..66161506 Binary files /dev/null and b/src/gui/qt/resources/logoChip3D.png differ diff --git a/src/gui/qt/resources/pokerth.qrc b/src/gui/qt/resources/pokerth.qrc index 469fd244..9b579829 100644 --- a/src/gui/qt/resources/pokerth.qrc +++ b/src/gui/qt/resources/pokerth.qrc @@ -40,6 +40,7 @@ list-remove.png transform-rotate.png player_play.png + logoChip3D.png cflags/ad.png