Ticket #9235: mythui_mythgame.diff

File mythui_mythgame.diff, 5.7 KB (added by stuartm, 15 years ago)

Replace the deletion menu dialog with the mythui equivalent

  • mythplugins/mythgame/mythgame/gamehandler.cpp

     
     1
    12#include "gamehandler.h"
    23#include "rominfo.h"
    34#include "rom_metadata.h"
     
    78#include <QDir>
    89#include <QList>
    910
    10 #include <mythcontext.h>
     11
    1112#include <mythdbcon.h>
    12 #include <mythdialogs.h>
    1313#include <util.h>
    1414#include <mythdb.h>
     15
     16#include <mythcontext.h>
     17#include <mythdialogs.h>
     18
    1519#include <mythuihelper.h>
     20#include <mythdialogbox.h>
     21#include <mythmainwindow.h>
    1622
    1723#define LOC_ERR QString("MythGame:GAMEHANDLER Error: ")
    1824#define LOC QString("MythGame:GAMEHANDLER: ")
     
    214220
    215221}
    216222
    217 void GameHandler::promptForRemoval(QString filename, QString RomPath)
     223void GameHandler::promptForRemoval(GameScan scan)
    218224{
     225    QString filename = scan.Rom();
     226    QString RomPath = scan.RomFullPath();
     227
    219228    if (m_RemoveAll)
    220229        purgeGameDB(filename , RomPath);
    221230
    222231    if (m_KeepAll || m_RemoveAll)
    223232        return;
    224233
    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");
    230238
    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())
    240240    {
    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");
    256242
     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);
    257248}
     249    else
     250        delete removalPopup;
     251}
    258252
    259253void updateDisplayRom(QString romname, int display, QString Systemname)
    260254{
     
    488482        else if ((iter.value().FoundLoc() == inDatabase) && (removalprompt))
    489483        {
    490484
    491             promptForRemoval( iter.value().Rom() , iter.value().RomPath() );
     485            promptForRemoval( iter.value() );
    492486        }
    493487
    494488        progressDlg->setProgress(++counter);
     
    939933    handlers->append(handler);
    940934}
    941935
     936void 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

     
    44
    55#include <QStringList>
    66#include <QMap>
     7#include <QObject>
     8#include <QEvent>
    79
    810#include <mythdbcon.h>
    911
    1012#include "rom_metadata.h"
    1113#include "rominfo.h"
    1214
     15class MythUIProgressDialog;
    1316class MythMainWindow;
    1417class GameHandler;
    15 class QObject;
    1618
    1719enum GameFound
    1820{
     
    4648    int     foundloc;
    4749};
    4850
     51Q_DECLARE_METATYPE(GameScan)
     52
    4953typedef QMap<QString, GameScan> GameScanMap;
    5054
    5155class MythProgressDialog;
    52 class GameHandler
     56class GameHandler : public QObject
    5357{
     58    Q_OBJECT
     59
    5460  public:
    55     GameHandler() :
     61    GameHandler() : QObject(),
    5662        rebuild(false),             spandisks(0),
    5763        systemname(QString::null),  rompath(QString::null),
    5864        commandline(QString::null), workingpath(QString::null),
     
    7177                             QString* Plot, QString* Publisher, QString* Version,
    7278                             QString* Fanart, QString* Boxart);
    7379
    74     void promptForRemoval(QString filename, QString RomPath );
     80    void promptForRemoval(GameScan scan);
    7581    void UpdateGameDB(GameHandler *handler);
    7682    void VerifyGameDB(GameHandler *handler);
    7783
     
    105111  protected:
    106112    static GameHandler* GetHandler(RomInfo *rominfo);
    107113    static GameHandler* GetHandlerByName(QString systemname);
     114    void customEvent(QEvent *event);
    108115
    109116    bool rebuild;
    110117    int spandisks;