added get member name from Social Club
This commit is contained in:
		
							parent
							
								
									0f17791e59
								
							
						
					
					
						commit
						49d29aa3ec
					
				
					 11 changed files with 391 additions and 11 deletions
				
			
		
							
								
								
									
										54
									
								
								CrewDatabase.cpp
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										54
									
								
								CrewDatabase.cpp
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,54 @@ | ||||||
|  | /*****************************************************************************
 | ||||||
|  | * gta5sync GRAND THEFT AUTO V SYNC | ||||||
|  | * Copyright (C) 2016 Syping Gaming Team | ||||||
|  | * | ||||||
|  | * This program is free software: you can redistribute it and/or modify | ||||||
|  | * it under the terms of the GNU General Public License as published by | ||||||
|  | * the Free Software Foundation, either version 3 of the License, or | ||||||
|  | * (at your option) any later version. | ||||||
|  | * | ||||||
|  | * This program is distributed in the hope that it will be useful, | ||||||
|  | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  | * GNU General Public License for more details. | ||||||
|  | * | ||||||
|  | * You should have received a copy of the GNU General Public License | ||||||
|  | * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | ||||||
|  | *****************************************************************************/ | ||||||
|  | 
 | ||||||
|  | #include "CrewDatabase.h" | ||||||
|  | #include <QDesktopServices> | ||||||
|  | #include <QFile> | ||||||
|  | #include <QDir> | ||||||
|  | 
 | ||||||
|  | CrewDatabase::CrewDatabase(QObject *parent) : QObject(parent) | ||||||
|  | { | ||||||
|  |     QDir dir; | ||||||
|  |     dir.setPath(QDesktopServices::storageLocation(QDesktopServices::DataLocation)); | ||||||
|  |     dir.mkdir("../gta5sync"); | ||||||
|  |     QString dirPath = dir.absolutePath(); | ||||||
|  |     QString defaultConfPath = dirPath + "/crews.ini"; | ||||||
|  | 
 | ||||||
|  |     QSettings confPathSettings("Syping Gaming Team","gta5sync"); | ||||||
|  |     confPathSettings.beginGroup("Database"); | ||||||
|  |     QString confPathFile = confPathSettings.value("Location", defaultConfPath).toString(); | ||||||
|  |     confPathSettings.endGroup(); | ||||||
|  | 
 | ||||||
|  |     crewDB = new QSettings(confPathFile, QSettings::IniFormat); | ||||||
|  |     crewDB->beginGroup("Crews"); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | CrewDatabase::~CrewDatabase() | ||||||
|  | { | ||||||
|  |     crewDB->endGroup(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | QStringList CrewDatabase::getCrews() | ||||||
|  | { | ||||||
|  |     return crewDB->childKeys(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void CrewDatabase::addCrew(int crewID) | ||||||
|  | { | ||||||
|  |     crewDB->setValue(QString::number(crewID), crewID); | ||||||
|  | } | ||||||
							
								
								
									
										41
									
								
								CrewDatabase.h
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										41
									
								
								CrewDatabase.h
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,41 @@ | ||||||
|  | /*****************************************************************************
 | ||||||
|  | * gta5sync GRAND THEFT AUTO V SYNC | ||||||
|  | * Copyright (C) 2016 Syping Gaming Team | ||||||
|  | * | ||||||
|  | * This program is free software: you can redistribute it and/or modify | ||||||
|  | * it under the terms of the GNU General Public License as published by | ||||||
|  | * the Free Software Foundation, either version 3 of the License, or | ||||||
|  | * (at your option) any later version. | ||||||
|  | * | ||||||
|  | * This program is distributed in the hope that it will be useful, | ||||||
|  | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  | * GNU General Public License for more details. | ||||||
|  | * | ||||||
|  | * You should have received a copy of the GNU General Public License | ||||||
|  | * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | ||||||
|  | *****************************************************************************/ | ||||||
|  | 
 | ||||||
|  | #ifndef CREWDATABASE_H | ||||||
|  | #define CREWDATABASE_H | ||||||
|  | 
 | ||||||
|  | #include <QSettings> | ||||||
|  | #include <QObject> | ||||||
|  | #include <QMap> | ||||||
|  | 
 | ||||||
|  | class CrewDatabase : public QObject | ||||||
|  | { | ||||||
|  |     Q_OBJECT | ||||||
|  | public: | ||||||
|  |     explicit CrewDatabase(QObject *parent = 0); | ||||||
|  |     QStringList getCrews(); | ||||||
|  |     ~CrewDatabase(); | ||||||
|  | 
 | ||||||
|  | private: | ||||||
|  |     QSettings *crewDB; | ||||||
|  | 
 | ||||||
|  | public slots: | ||||||
|  |     void addCrew(int crewID); | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | #endif // CREWDATABASE_H
 | ||||||
							
								
								
									
										90
									
								
								DatabaseThread.cpp
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										90
									
								
								DatabaseThread.cpp
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,90 @@ | ||||||
|  | /*****************************************************************************
 | ||||||
|  | * gta5sync GRAND THEFT AUTO V SYNC | ||||||
|  | * Copyright (C) 2016 Syping Gaming Team | ||||||
|  | * | ||||||
|  | * This program is free software: you can redistribute it and/or modify | ||||||
|  | * it under the terms of the GNU General Public License as published by | ||||||
|  | * the Free Software Foundation, either version 3 of the License, or | ||||||
|  | * (at your option) any later version. | ||||||
|  | * | ||||||
|  | * This program is distributed in the hope that it will be useful, | ||||||
|  | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  | * GNU General Public License for more details. | ||||||
|  | * | ||||||
|  | * You should have received a copy of the GNU General Public License | ||||||
|  | * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | ||||||
|  | *****************************************************************************/ | ||||||
|  | 
 | ||||||
|  | #include "DatabaseThread.h" | ||||||
|  | #include "CrewDatabase.h" | ||||||
|  | #include <QNetworkAccessManager> | ||||||
|  | #include <QNetworkRequest> | ||||||
|  | #include <QNetworkReply> | ||||||
|  | #include <QJsonDocument> | ||||||
|  | #include <QJsonObject> | ||||||
|  | #include <QStringList> | ||||||
|  | #include <QVariantMap> | ||||||
|  | #include <QEventLoop> | ||||||
|  | #include <QTimer> | ||||||
|  | #include <QDebug> | ||||||
|  | #include <QUrl> | ||||||
|  | 
 | ||||||
|  | DatabaseThread::DatabaseThread(CrewDatabase *crewDB, QObject *parent) : QThread(parent), crewDB(crewDB) | ||||||
|  | { | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void DatabaseThread::run() | ||||||
|  | { | ||||||
|  |     QNetworkAccessManager *netManager = new QNetworkAccessManager(); | ||||||
|  |     QEventLoop threadLoop; | ||||||
|  |     dbtBegin: | ||||||
|  | 
 | ||||||
|  |     QStringList crewList = crewDB->getCrews(); | ||||||
|  |     foreach (const QString &crewID, crewList) | ||||||
|  |     { | ||||||
|  |         QString memberListUrl = "http://socialclub.rockstargames.com/crewsapi/GetMembersList?crewId=" + crewID; | ||||||
|  | 
 | ||||||
|  |         QNetworkRequest netRequest(memberListUrl); | ||||||
|  |         netRequest.setRawHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:45.0) Gecko/20100101 Firefox/45.0"); | ||||||
|  |         netRequest.setRawHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); | ||||||
|  |         netRequest.setRawHeader("Accept-Language", "en-US;q=0.5,en;q=0.3"); | ||||||
|  |         netRequest.setRawHeader("Connection", "keep-alive"); | ||||||
|  | 
 | ||||||
|  |         QNetworkReply *netReply = netManager->get(netRequest); | ||||||
|  | 
 | ||||||
|  |         QEventLoop downloadLoop; | ||||||
|  |         QObject::connect(netReply, SIGNAL(finished()), &downloadLoop, SLOT(quit())); | ||||||
|  |         QTimer::singleShot(30000, &downloadLoop, SLOT(quit())); | ||||||
|  |         downloadLoop.exec(); | ||||||
|  | 
 | ||||||
|  |         if (netReply->isFinished()) | ||||||
|  |         { | ||||||
|  |             QByteArray crewJson = netReply->readAll(); | ||||||
|  |             QJsonDocument crewDocument = QJsonDocument::fromJson(crewJson); | ||||||
|  |             QJsonObject crewObject = crewDocument.object(); | ||||||
|  |             QVariantMap crewMap = crewObject.toVariantMap(); | ||||||
|  |             if (crewMap.contains("Members")) | ||||||
|  |             { | ||||||
|  |                 QList<QVariant> memberList = crewMap["Members"].toList(); | ||||||
|  |                 foreach (const QVariant &memberVariant, memberList) | ||||||
|  |                 { | ||||||
|  |                     QMap<QString, QVariant> memberMap = memberVariant.toMap(); | ||||||
|  |                     if (memberMap.contains("RockstarId") && memberMap.contains("Name")) | ||||||
|  |                     { | ||||||
|  |                         int RockstarId = memberMap["RockstarId"].toInt(); | ||||||
|  |                         QString memberName = memberMap["Name"].toString(); | ||||||
|  |                         if (memberName != "" && RockstarId != 0) | ||||||
|  |                         { | ||||||
|  |                             emit playerNameFound(RockstarId, memberName); | ||||||
|  |                         } | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     QTimer::singleShot(300000, &threadLoop, SLOT(quit())); | ||||||
|  |     threadLoop.exec(); | ||||||
|  |     goto dbtBegin; | ||||||
|  | } | ||||||
							
								
								
									
										43
									
								
								DatabaseThread.h
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										43
									
								
								DatabaseThread.h
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,43 @@ | ||||||
|  | /*****************************************************************************
 | ||||||
|  | * gta5sync GRAND THEFT AUTO V SYNC | ||||||
|  | * Copyright (C) 2016 Syping Gaming Team | ||||||
|  | * | ||||||
|  | * This program is free software: you can redistribute it and/or modify | ||||||
|  | * it under the terms of the GNU General Public License as published by | ||||||
|  | * the Free Software Foundation, either version 3 of the License, or | ||||||
|  | * (at your option) any later version. | ||||||
|  | * | ||||||
|  | * This program is distributed in the hope that it will be useful, | ||||||
|  | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  | * GNU General Public License for more details. | ||||||
|  | * | ||||||
|  | * You should have received a copy of the GNU General Public License | ||||||
|  | * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | ||||||
|  | *****************************************************************************/ | ||||||
|  | 
 | ||||||
|  | #ifndef DATABASETHREAD_H | ||||||
|  | #define DATABASETHREAD_H | ||||||
|  | 
 | ||||||
|  | #include "CrewDatabase.h" | ||||||
|  | #include <QObject> | ||||||
|  | #include <QThread> | ||||||
|  | 
 | ||||||
|  | class DatabaseThread : public QThread | ||||||
|  | { | ||||||
|  |     Q_OBJECT | ||||||
|  | public: | ||||||
|  |     explicit DatabaseThread(CrewDatabase *crewDB, QObject *parent = 0); | ||||||
|  | 
 | ||||||
|  | private: | ||||||
|  |     CrewDatabase *crewDB; | ||||||
|  | 
 | ||||||
|  | protected: | ||||||
|  |     void run(); | ||||||
|  | 
 | ||||||
|  | signals: | ||||||
|  |     void playerNameFound(int playerID, QString playerName); | ||||||
|  | 
 | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | #endif // DATABASETHREAD_H
 | ||||||
|  | @ -17,22 +17,29 @@ | ||||||
| *****************************************************************************/ | *****************************************************************************/ | ||||||
| 
 | 
 | ||||||
| #include "PictureDialog.h" | #include "PictureDialog.h" | ||||||
|  | #include "ProfileDatabase.h" | ||||||
| #include "ui_PictureDialog.h" | #include "ui_PictureDialog.h" | ||||||
| 
 | 
 | ||||||
| #include <QJsonDocument> | #include <QJsonDocument> | ||||||
|  | #include <QFileDialog> | ||||||
| #include <QMessageBox> | #include <QMessageBox> | ||||||
| #include <QJsonObject> | #include <QJsonObject> | ||||||
| #include <QVariantMap> | #include <QVariantMap> | ||||||
| #include <QJsonArray> | #include <QJsonArray> | ||||||
|  | #include <QTimer> | ||||||
| #include <QDebug> | #include <QDebug> | ||||||
| 
 | 
 | ||||||
| PictureDialog::PictureDialog(QWidget *parent) : | PictureDialog::PictureDialog(ProfileDatabase *profileDB, QWidget *parent) : | ||||||
|     QDialog(parent), |     QDialog(parent), profileDB(profileDB), | ||||||
|     ui(new Ui::PictureDialog) |     ui(new Ui::PictureDialog) | ||||||
| { | { | ||||||
|     ui->setupUi(this); |     ui->setupUi(this); | ||||||
|     windowTitleStr = this->windowTitle(); |     windowTitleStr = this->windowTitle(); | ||||||
|     jsonDrawString = ui->labJSON->text(); |     jsonDrawString = ui->labJSON->text(); | ||||||
|  |     ui->cmdExport->setEnabled(0); | ||||||
|  |     ui->cmdExport->setDefault(0); | ||||||
|  |     ui->cmdClose->setDefault(1); | ||||||
|  |     ui->cmdClose->setFocus(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| PictureDialog::~PictureDialog() | PictureDialog::~PictureDialog() | ||||||
|  | @ -51,6 +58,7 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk) | ||||||
|     if (picture->isPicOk()) |     if (picture->isPicOk()) | ||||||
|     { |     { | ||||||
|         ui->labPicture->setPixmap(picture->getPixmap()); |         ui->labPicture->setPixmap(picture->getPixmap()); | ||||||
|  |         ui->cmdExport->setEnabled(true); | ||||||
|     } |     } | ||||||
|     if (picture->isJsonOk()) |     if (picture->isJsonOk()) | ||||||
|     { |     { | ||||||
|  | @ -66,7 +74,7 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk) | ||||||
|             foreach (const QString &player, plyrsList) |             foreach (const QString &player, plyrsList) | ||||||
|             { |             { | ||||||
|                 plyrsStr.append(", "); |                 plyrsStr.append(", "); | ||||||
|                 plyrsStr.append(player); |                 plyrsStr.append(profileDB->getPlayerName(player.toInt())); | ||||||
|             } |             } | ||||||
|             plyrsStr.remove(0,2); |             plyrsStr.remove(0,2); | ||||||
|         } |         } | ||||||
|  | @ -91,3 +99,8 @@ void PictureDialog::on_cmdClose_clicked() | ||||||
| { | { | ||||||
|     this->close(); |     this->close(); | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | void PictureDialog::on_cmdExport_clicked() | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -20,6 +20,7 @@ | ||||||
| #define PICTUREDIALOG_H | #define PICTUREDIALOG_H | ||||||
| 
 | 
 | ||||||
| #include "SnapmaticPicture.h" | #include "SnapmaticPicture.h" | ||||||
|  | #include "ProfileDatabase.h" | ||||||
| #include <QDialog> | #include <QDialog> | ||||||
| 
 | 
 | ||||||
| namespace Ui { | namespace Ui { | ||||||
|  | @ -30,17 +31,19 @@ class PictureDialog : public QDialog | ||||||
| { | { | ||||||
|     Q_OBJECT |     Q_OBJECT | ||||||
| public: | public: | ||||||
|     explicit PictureDialog(QWidget *parent = 0); |     explicit PictureDialog(ProfileDatabase *profileDB, QWidget *parent = 0); | ||||||
|     void setSnapmaticPicture(SnapmaticPicture *picture, bool readOk); |     void setSnapmaticPicture(SnapmaticPicture *picture, bool readOk); | ||||||
|     ~PictureDialog(); |     ~PictureDialog(); | ||||||
| 
 | 
 | ||||||
| private slots: | private slots: | ||||||
|     void on_cmdClose_clicked(); |     void on_cmdClose_clicked(); | ||||||
|  |     void on_cmdExport_clicked(); | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     Ui::PictureDialog *ui; |     Ui::PictureDialog *ui; | ||||||
|     QString jsonDrawString; |     QString jsonDrawString; | ||||||
|     QString windowTitleStr; |     QString windowTitleStr; | ||||||
|  |     ProfileDatabase *profileDB; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| #endif // PICTUREDIALOG_H
 | #endif // PICTUREDIALOG_H
 | ||||||
|  |  | ||||||
|  | @ -33,6 +33,19 @@ | ||||||
|      </property> |      </property> | ||||||
|     </widget> |     </widget> | ||||||
|    </item> |    </item> | ||||||
|  |    <item> | ||||||
|  |     <spacer name="vsDialog"> | ||||||
|  |      <property name="orientation"> | ||||||
|  |       <enum>Qt::Vertical</enum> | ||||||
|  |      </property> | ||||||
|  |      <property name="sizeHint" stdset="0"> | ||||||
|  |       <size> | ||||||
|  |        <width>0</width> | ||||||
|  |        <height>0</height> | ||||||
|  |       </size> | ||||||
|  |      </property> | ||||||
|  |     </spacer> | ||||||
|  |    </item> | ||||||
|    <item> |    <item> | ||||||
|     <layout class="QHBoxLayout" name="hlJSON"> |     <layout class="QHBoxLayout" name="hlJSON"> | ||||||
|      <property name="leftMargin"> |      <property name="leftMargin"> | ||||||
|  | @ -74,6 +87,13 @@ | ||||||
|        </property> |        </property> | ||||||
|       </widget> |       </widget> | ||||||
|      </item> |      </item> | ||||||
|  |      <item> | ||||||
|  |       <widget class="QPushButton" name="cmdExport"> | ||||||
|  |        <property name="text"> | ||||||
|  |         <string>Export</string> | ||||||
|  |        </property> | ||||||
|  |       </widget> | ||||||
|  |      </item> | ||||||
|     </layout> |     </layout> | ||||||
|    </item> |    </item> | ||||||
|   </layout> |   </layout> | ||||||
|  |  | ||||||
							
								
								
									
										54
									
								
								ProfileDatabase.cpp
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										54
									
								
								ProfileDatabase.cpp
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,54 @@ | ||||||
|  | /*****************************************************************************
 | ||||||
|  | * gta5sync GRAND THEFT AUTO V SYNC | ||||||
|  | * Copyright (C) 2016 Syping Gaming Team | ||||||
|  | * | ||||||
|  | * This program is free software: you can redistribute it and/or modify | ||||||
|  | * it under the terms of the GNU General Public License as published by | ||||||
|  | * the Free Software Foundation, either version 3 of the License, or | ||||||
|  | * (at your option) any later version. | ||||||
|  | * | ||||||
|  | * This program is distributed in the hope that it will be useful, | ||||||
|  | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  | * GNU General Public License for more details. | ||||||
|  | * | ||||||
|  | * You should have received a copy of the GNU General Public License | ||||||
|  | * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | ||||||
|  | *****************************************************************************/ | ||||||
|  | 
 | ||||||
|  | #include "ProfileDatabase.h" | ||||||
|  | #include <QDesktopServices> | ||||||
|  | #include <QFile> | ||||||
|  | #include <QDir> | ||||||
|  | 
 | ||||||
|  | ProfileDatabase::ProfileDatabase(QObject *parent) : QObject(parent) | ||||||
|  | { | ||||||
|  |     QDir dir; | ||||||
|  |     dir.setPath(QDesktopServices::storageLocation(QDesktopServices::DataLocation)); | ||||||
|  |     dir.mkdir("../gta5sync"); | ||||||
|  |     QString dirPath = dir.absolutePath(); | ||||||
|  |     QString defaultConfPath = dirPath + "/players.ini"; | ||||||
|  | 
 | ||||||
|  |     QSettings confPathSettings("Syping Gaming Team","gta5sync"); | ||||||
|  |     confPathSettings.beginGroup("Database"); | ||||||
|  |     QString confPathFile = confPathSettings.value("Location", defaultConfPath).toString(); | ||||||
|  |     confPathSettings.endGroup(); | ||||||
|  | 
 | ||||||
|  |     profileDB = new QSettings(confPathFile, QSettings::IniFormat); | ||||||
|  |     profileDB->beginGroup("Players"); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | ProfileDatabase::~ProfileDatabase() | ||||||
|  | { | ||||||
|  |     profileDB->endGroup(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | QString ProfileDatabase::getPlayerName(int playerID) | ||||||
|  | { | ||||||
|  |     return profileDB->value(QString::number(playerID), playerID).toString(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void ProfileDatabase::setPlayerName(int playerID, QString playerName) | ||||||
|  | { | ||||||
|  |     profileDB->setValue(QString::number(playerID), playerName); | ||||||
|  | } | ||||||
							
								
								
									
										42
									
								
								ProfileDatabase.h
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										42
									
								
								ProfileDatabase.h
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,42 @@ | ||||||
|  | /*****************************************************************************
 | ||||||
|  | * gta5sync GRAND THEFT AUTO V SYNC | ||||||
|  | * Copyright (C) 2016 Syping Gaming Team | ||||||
|  | * | ||||||
|  | * This program is free software: you can redistribute it and/or modify | ||||||
|  | * it under the terms of the GNU General Public License as published by | ||||||
|  | * the Free Software Foundation, either version 3 of the License, or | ||||||
|  | * (at your option) any later version. | ||||||
|  | * | ||||||
|  | * This program is distributed in the hope that it will be useful, | ||||||
|  | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  | * GNU General Public License for more details. | ||||||
|  | * | ||||||
|  | * You should have received a copy of the GNU General Public License | ||||||
|  | * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | ||||||
|  | *****************************************************************************/ | ||||||
|  | 
 | ||||||
|  | #ifndef PROFILEDATABASE_H | ||||||
|  | #define PROFILEDATABASE_H | ||||||
|  | 
 | ||||||
|  | #include <QSettings> | ||||||
|  | #include <QObject> | ||||||
|  | #include <QMap> | ||||||
|  | 
 | ||||||
|  | class ProfileDatabase : public QObject | ||||||
|  | { | ||||||
|  |     Q_OBJECT | ||||||
|  | public: | ||||||
|  |     explicit ProfileDatabase(QObject *parent = 0); | ||||||
|  |     QString getPlayerName(int playerID); | ||||||
|  |     ~ProfileDatabase(); | ||||||
|  | 
 | ||||||
|  | private: | ||||||
|  |     QSettings *profileDB; | ||||||
|  | 
 | ||||||
|  | public slots: | ||||||
|  |     void setPlayerName(int playerID, QString playerName); | ||||||
|  | 
 | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | #endif // PROFILEDATABASE_H
 | ||||||
							
								
								
									
										12
									
								
								gta5sync.pro
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								gta5sync.pro
									
										
									
									
									
								
							|  | @ -16,7 +16,7 @@ | ||||||
| #* along with this program.  If not, see <http://www.gnu.org/licenses/>. | #* along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||||||
| #*****************************************************************************/ | #*****************************************************************************/ | ||||||
| 
 | 
 | ||||||
| QT       += core gui | QT       += core gui network | ||||||
| 
 | 
 | ||||||
| greaterThan(QT_MAJOR_VERSION, 4): QT += widgets | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets | ||||||
| isEqual(QT_MAJOR_VERSION, 5): DEFINES += QT5_MODE | isEqual(QT_MAJOR_VERSION, 5): DEFINES += QT5_MODE | ||||||
|  | @ -27,11 +27,17 @@ TEMPLATE = app | ||||||
| 
 | 
 | ||||||
| SOURCES += main.cpp\ | SOURCES += main.cpp\ | ||||||
|     SnapmaticPicture.cpp \ |     SnapmaticPicture.cpp \ | ||||||
|     PictureDialog.cpp |     PictureDialog.cpp \ | ||||||
|  |     ProfileDatabase.cpp \ | ||||||
|  |     DatabaseThread.cpp \ | ||||||
|  |     CrewDatabase.cpp | ||||||
| 
 | 
 | ||||||
| HEADERS  += \ | HEADERS  += \ | ||||||
|     SnapmaticPicture.h \ |     SnapmaticPicture.h \ | ||||||
|     PictureDialog.h |     PictureDialog.h \ | ||||||
|  |     ProfileDatabase.h \ | ||||||
|  |     DatabaseThread.h \ | ||||||
|  |     CrewDatabase.h | ||||||
| 
 | 
 | ||||||
| FORMS    += \ | FORMS    += \ | ||||||
|     PictureDialog.ui |     PictureDialog.ui | ||||||
|  |  | ||||||
							
								
								
									
										22
									
								
								main.cpp
									
										
									
									
									
								
							
							
						
						
									
										22
									
								
								main.cpp
									
										
									
									
									
								
							|  | @ -17,15 +17,21 @@ | ||||||
| *****************************************************************************/ | *****************************************************************************/ | ||||||
| 
 | 
 | ||||||
| #include "SnapmaticPicture.h" | #include "SnapmaticPicture.h" | ||||||
|  | #include "ProfileDatabase.h" | ||||||
|  | #include "DatabaseThread.h" | ||||||
| #include "PictureDialog.h" | #include "PictureDialog.h" | ||||||
|  | #include "CrewDatabase.h" | ||||||
| #include <QApplication> | #include <QApplication> | ||||||
| #include <QStringList> | #include <QStringList> | ||||||
|  | #include <QObject> | ||||||
| #include <QString> | #include <QString> | ||||||
| #include <QFile> | #include <QFile> | ||||||
| 
 | 
 | ||||||
| int main(int argc, char *argv[]) | int main(int argc, char *argv[]) | ||||||
| { | { | ||||||
|     QApplication a(argc, argv); |     QApplication a(argc, argv); | ||||||
|  |     a.setApplicationName("gta5sync"); | ||||||
|  |     a.setApplicationVersion("1.0.0"); | ||||||
| 
 | 
 | ||||||
|     QStringList applicationArgs = a.arguments(); |     QStringList applicationArgs = a.arguments(); | ||||||
|     QString selectedAction; |     QString selectedAction; | ||||||
|  | @ -52,15 +58,23 @@ int main(int argc, char *argv[]) | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     CrewDatabase *crewDB = new CrewDatabase(); | ||||||
|  |     ProfileDatabase *profileDB = new ProfileDatabase(); | ||||||
|  |     DatabaseThread *threadDB = new DatabaseThread(crewDB); | ||||||
|  |     QObject::connect(threadDB, SIGNAL(playerNameFound(int,QString)), profileDB, SLOT(setPlayerName(int,QString))); | ||||||
|  |     threadDB->start(); | ||||||
|  | 
 | ||||||
|     if (selectedAction == "showpic") |     if (selectedAction == "showpic") | ||||||
|     { |     { | ||||||
|         PictureDialog picDialog; |         PictureDialog *picDialog = new PictureDialog(profileDB); | ||||||
|         SnapmaticPicture picture; |         SnapmaticPicture picture; | ||||||
|         bool readOk = picture.readingPictureFromFile(arg1); |         bool readOk = picture.readingPictureFromFile(arg1); | ||||||
|         picDialog.setWindowFlags(picDialog.windowFlags()^Qt::WindowContextHelpButtonHint); |         picDialog->setWindowFlags(picDialog->windowFlags()^Qt::WindowContextHelpButtonHint); | ||||||
|         picDialog.setSnapmaticPicture(&picture, readOk); |         picDialog->setSnapmaticPicture(&picture, readOk); | ||||||
|  |         int crewID = picture.getCrewNumber(); | ||||||
|  |         if (crewID != 0) { crewDB->addCrew(crewID); } | ||||||
|         if (!readOk) { return 1; } |         if (!readOk) { return 1; } | ||||||
|         picDialog.show(); |         picDialog->show(); | ||||||
| 
 | 
 | ||||||
|         return a.exec(); |         return a.exec(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue