Ticket #9235: mythui_mythgame.diff
File mythui_mythgame.diff, 5.7 KB (added by , 15 years ago) |
---|
-
mythplugins/mythgame/mythgame/gamehandler.cpp
1 1 2 #include "gamehandler.h" 2 3 #include "rominfo.h" 3 4 #include "rom_metadata.h" … … 7 8 #include <QDir> 8 9 #include <QList> 9 10 10 #include <mythcontext.h> 11 11 12 #include <mythdbcon.h> 12 #include <mythdialogs.h>13 13 #include <util.h> 14 14 #include <mythdb.h> 15 16 #include <mythcontext.h> 17 #include <mythdialogs.h> 18 15 19 #include <mythuihelper.h> 20 #include <mythdialogbox.h> 21 #include <mythmainwindow.h> 16 22 17 23 #define LOC_ERR QString("MythGame:GAMEHANDLER Error: ") 18 24 #define LOC QString("MythGame:GAMEHANDLER: ") … … 214 220 215 221 } 216 222 217 void GameHandler::promptForRemoval( QString filename, QString RomPath)223 void GameHandler::promptForRemoval(GameScan scan) 218 224 { 225 QString filename = scan.Rom(); 226 QString RomPath = scan.RomFullPath(); 227 219 228 if (m_RemoveAll) 220 229 purgeGameDB(filename , RomPath); 221 230 222 231 if (m_KeepAll || m_RemoveAll) 223 232 return; 224 233 225 QStringList buttonText; 226 buttonText += QObject::tr("No"); 227 buttonText += QObject::tr("No to all"); 228 buttonText += QObject::tr("Yes"); 229 buttonText += QObject::tr("Yes to all"); 234 MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); 235 MythDialogBox *removalPopup = new MythDialogBox( 236 tr("%1 appears to be missing.\nRemove it from the database?") 237 .arg(filename), popupStack, "chooseSystemPopup"); 230 238 231 232 DialogCode result = MythPopupBox::ShowButtonPopup( 233 GetMythMainWindow(), 234 QObject::tr("File Missing"), 235 QString(QObject::tr("%1 appears to be missing.\nRemove it" 236 " from the database?")).arg(filename), 237 buttonText, kDialogCodeButton0); 238 239 switch (result) 239 if (removalPopup->Create()) 240 240 { 241 case kDialogCodeButton0: 242 case kDialogCodeRejected: 243 default: 244 break; 245 case kDialogCodeButton1: 246 m_KeepAll = true; 247 break; 248 case kDialogCodeButton2: 249 purgeGameDB(filename , RomPath); 250 break; 251 case kDialogCodeButton3: 252 m_RemoveAll = true; 253 purgeGameDB(filename , RomPath); 254 break; 255 }; 241 removalPopup->SetReturnEvent(this, "removalPopup"); 256 242 243 removalPopup->AddButton(tr("No")); 244 removalPopup->AddButton(tr("No to all")); 245 removalPopup->AddButton(tr("Yes"), qVariantFromValue(scan)); 246 removalPopup->AddButton(tr("Yes to all"), qVariantFromValue(scan)); 247 popupStack->AddScreen(removalPopup); 257 248 } 249 else 250 delete removalPopup; 251 } 258 252 259 253 void updateDisplayRom(QString romname, int display, QString Systemname) 260 254 { … … 488 482 else if ((iter.value().FoundLoc() == inDatabase) && (removalprompt)) 489 483 { 490 484 491 promptForRemoval( iter.value() .Rom() , iter.value().RomPath());485 promptForRemoval( iter.value() ); 492 486 } 493 487 494 488 progressDlg->setProgress(++counter); … … 939 933 handlers->append(handler); 940 934 } 941 935 936 void GameHandler::customEvent(QEvent *event) 937 { 938 if (event->type() == DialogCompletionEvent::kEventType) 939 { 940 DialogCompletionEvent *dce = (DialogCompletionEvent*)(event); 941 942 QString resultid = dce->GetId(); 943 QString resulttext = dce->GetResultText(); 944 945 if (resultid == "removalPopup") 946 { 947 int buttonNum = dce->GetResult(); 948 GameScan scan = qVariantValue<GameScan>(dce->GetData()); 949 switch (buttonNum) 950 { 951 case 1: 952 m_KeepAll = true; 953 break; 954 case 2: 955 purgeGameDB(scan.Rom() , scan.RomFullPath()); 956 break; 957 case 3: 958 m_RemoveAll = true; 959 purgeGameDB(scan.Rom() , scan.RomFullPath()); 960 break; 961 default: 962 break; 963 }; 964 } 965 } 966 } -
mythplugins/mythgame/mythgame/gamehandler.h
4 4 5 5 #include <QStringList> 6 6 #include <QMap> 7 #include <QObject> 8 #include <QEvent> 7 9 8 10 #include <mythdbcon.h> 9 11 10 12 #include "rom_metadata.h" 11 13 #include "rominfo.h" 12 14 15 class MythUIProgressDialog; 13 16 class MythMainWindow; 14 17 class GameHandler; 15 class QObject;16 18 17 19 enum GameFound 18 20 { … … 46 48 int foundloc; 47 49 }; 48 50 51 Q_DECLARE_METATYPE(GameScan) 52 49 53 typedef QMap<QString, GameScan> GameScanMap; 50 54 51 55 class MythProgressDialog; 52 class GameHandler 56 class GameHandler : public QObject 53 57 { 58 Q_OBJECT 59 54 60 public: 55 GameHandler() : 61 GameHandler() : QObject(), 56 62 rebuild(false), spandisks(0), 57 63 systemname(QString::null), rompath(QString::null), 58 64 commandline(QString::null), workingpath(QString::null), … … 71 77 QString* Plot, QString* Publisher, QString* Version, 72 78 QString* Fanart, QString* Boxart); 73 79 74 void promptForRemoval( QString filename, QString RomPath);80 void promptForRemoval(GameScan scan); 75 81 void UpdateGameDB(GameHandler *handler); 76 82 void VerifyGameDB(GameHandler *handler); 77 83 … … 105 111 protected: 106 112 static GameHandler* GetHandler(RomInfo *rominfo); 107 113 static GameHandler* GetHandlerByName(QString systemname); 114 void customEvent(QEvent *event); 108 115 109 116 bool rebuild; 110 117 int spandisks;