X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fgui%2Ffilepicker.cpp;h=5733de6ace1a29b635579e80d9a9ff3c317b95dd;hb=32f569e1bd09f5d7f07005d119f6408805106381;hp=86fbe55b410d25cb62cc1776099a5aed63c06a78;hpb=54f5867e394981dd72548990064238454a6e2395;p=virtualjaguar diff --git a/src/gui/filepicker.cpp b/src/gui/filepicker.cpp index 86fbe55..5733de6 100644 --- a/src/gui/filepicker.cpp +++ b/src/gui/filepicker.cpp @@ -1,10 +1,10 @@ // // filepicker.cpp - A ROM chooser // -// by James L. Hammons +// by James Hammons // (C) 2010 Underground Software // -// JLH = James L. Hammons +// JLH = James Hammons // // Who When What // --- ---------- ------------------------------------------------------------- @@ -85,30 +85,32 @@ printf("VSB size: %u, %u\n", sbSize3.width(), sbSize3.height()); #else // This sets it to the "too large size" as the minimum! QScrollBar * vsb = new QScrollBar(Qt::Vertical, this); - int sbWidth = vsb->size().width(); - printf("VSB size width: %u\n", sbWidth); +// int sbWidth = vsb->size().width(); +// printf("VSB size width: %u\n", sbWidth); int sbWidth2 = vsb->sizeHint().width(); - printf("VSB sizeHint width: %u\n", sbWidth2); - int sbWidth3 = vsb->minimumSize().width(); - printf("VSB minimum width: %u\n", sbWidth3); - int sbWidth4 = vsb->frameSize().width(); - printf("VSB frame width: %u\n", sbWidth4); +// printf("VSB sizeHint width: %u\n", sbWidth2); +// int sbWidth3 = vsb->minimumSize().width(); +// printf("VSB minimum width: %u\n", sbWidth3); +// int sbWidth4 = vsb->frameSize().width(); +// printf("VSB frame width: %u\n", sbWidth4); delete vsb; // fileList->setFixedWidth((488/4) + 4); int sbWidth5 = fileList->frameWidth(); - printf("List frame width: %u, (diff=%d)\n", sbWidth5, sbWidth5 - ((488/4) + 4)); - int sbWidth6 = fileList->sizeHint().width(); - printf("List sizeHint width: %u\n", sbWidth6); - int sbWidth7 = fileList->minimumSize().width(); - printf("List minimum width: %u\n", sbWidth7); - int sbWidth8 = fileList->minimumSizeHint().width(); - printf("List minimum hint width: %u\n", sbWidth8); -// fileList->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); -// fileList->verticalScrollBar()->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); +// printf("List frame width: %u, (diff=%d)\n", sbWidth5, sbWidth5 - ((488/4) + 4)); +// int sbWidth6 = fileList->sizeHint().width(); +// printf("List sizeHint width: %u\n", sbWidth6); +// int sbWidth7 = fileList->minimumSize().width(); +// printf("List minimum width: %u\n", sbWidth7); +// int sbWidth8 = fileList->minimumSizeHint().width(); +// printf("List minimum hint width: %u\n", sbWidth8); +//// fileList->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); +//// fileList->verticalScrollBar()->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); // (488/4) + 4 is the width of the object in the filelistmodel. Dunno why the QListView // isn't picking that up. :-( - fileList->setFixedWidth((488/4) + 4 + sbWidth);//ick + // 488/4 + 4 = 126 + // 126 + 17 + 4 = 147 <-- correct width + fileList->setFixedWidth((488/4) + 4 + sbWidth2 + sbWidth5 + 1);//ick // fileList->setFixedWidth((488/4) + 4 + 17 + 4);//sbWidth);//ick // fileList->setSpacing(4); @@ -136,9 +138,13 @@ printf("VSB size: %u, %u\n", sbSize3.width(), sbSize3.height()); title = new QLabel(QString(tr("

...

"))); title->setMargin(6); title->setAlignment(Qt::AlignCenter); +//no. +//title->setFixedWidth(cartImage->width()); +//title->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); +//YESH!!!! + title->setFixedWidth(cartImage->sizeHint().width()); vLayout->addWidget(title); -#if 1 QHBoxLayout * dataLayout = new QHBoxLayout; vLayout->addLayout(dataLayout); @@ -153,9 +159,9 @@ printf("VSB size: %u, %u\n", sbSize3.width(), sbSize3.height()); dataLayout->addWidget(labels); data = new QLabel(QString(tr( "?MB Cartridge
" - "????????
" - "???
" - "???" + "00000000
" + "?
" + "?" ))); data->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); dataLayout->addWidget(data); @@ -167,17 +173,6 @@ printf("VSB size: %u, %u\n", sbSize3.width(), sbSize3.height()); insertCart->setDefault(true); // We want this button to be the default insertCart->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); dataLayout->addWidget(insertCart); -#else - QLabel * text2 = new QLabel(QString(tr( - "" - "" - "" - "" - "" - "
Type: 4MB Cartridge
CRC32: FEDCBA98
Compatibility: DOES NOT WORK
Notes: Universal Header detected; Requires DSP
" - ))); - vLayout->addWidget(text2); -#endif fileThread = new FileThread(this); // connect(fileThread, SIGNAL(FoundAFile(unsigned long)), this, SLOT(AddFileToList(unsigned long))); @@ -204,12 +199,17 @@ New sizes: 373x172 (label), 420x340 (cart) // connect(fileList, SIGNAL(doubleClicked()), this, SLOT(LoadButtonPressed())); // This returns: // Object::connect: No such signal QListView::QAbstractItemView::doubleClicked() in src/gui/filepicker.cpp:203 +//can't do this, nothing's rendered yet... +//setFixedWidth(width()); } void FilePickerWindow::keyPressEvent(QKeyEvent * e) { if (e->key() == Qt::Key_Escape) + { hide(); + emit(FilePickerHiding()); + } else if (e->key() == Qt::Key_Return) LoadButtonPressed(); } @@ -300,7 +300,7 @@ void FilePickerWindow::UpdateSelection(const QModelIndex & current, const QModel unsigned long fileSize = current.model()->data(current, FLM_FILESIZE).toUInt(); bool haveUniversalHeader = current.model()->data(current, FLM_UNIVERSALHDR).toBool(); unsigned long fileType = current.model()->data(current, FLM_FILETYPE).toUInt(); - uint32 crc = (uint32)current.model()->data(current, FLM_CRC).toUInt(); + uint32_t crc = (uint32_t)current.model()->data(current, FLM_CRC).toUInt(); // printf("FPW: %s\n", s.toAscii().data()); bool haveUnknown = (i == 0xFFFFFFFF ? true : false); #endif @@ -353,7 +353,7 @@ void FilePickerWindow::UpdateSelection(const QModelIndex & current, const QModel // should be valid. // The DB takes precedence over the fileType. if ((!haveUnknown && (romList[i].flags & FF_ROM)) - || (haveUnknown && (fileType == JST_ROM))) + || (haveUnknown && (fileType == JST_ROM) && !haveUniversalHeader)) { cart = QImage(":/res/cart-blank.png"); QPainter painter(&cart); @@ -361,11 +361,16 @@ void FilePickerWindow::UpdateSelection(const QModelIndex & current, const QModel painter.end(); } else if ((!haveUnknown && (romList[i].flags & FF_ALPINE)) - || (haveUnknown && (fileType == JST_ALPINE))) + || (haveUnknown + && ((fileType == JST_ALPINE) || ((fileType == JST_ROM) && haveUniversalHeader)))) { - cart = QImage(":/res/alpine-file.png"); + if (haveUniversalHeader) + cart = QImage(":/res/skunkboard-file.png"); + else + cart = QImage(":/res/alpine-file.png"); } - else if (haveUnknown && (fileType == JST_ABS_TYPE1 || fileType == JST_ABS_TYPE2 || fileType == JST_JAGSERVER)) + else if (haveUnknown && (fileType == JST_ABS_TYPE1 || fileType == JST_ABS_TYPE2 + || fileType == JST_JAGSERVER) || fileType == JST_WTFOMGBBQ) { cart = QImage(":/res/homebrew-file.png"); } @@ -386,7 +391,15 @@ void FilePickerWindow::UpdateSelection(const QModelIndex & current, const QModel prettyFilename = "\"" + currentFile.mid(lastSlashPos + 1) + "\""; } + // Ensure that the title isn't longer than the width of the dialog... +#if 1 title->setText(QString("

%1

").arg(prettyFilename)); +#else + // This doesn't work... + QFontMetrics metrics(title->font()); + QString elidedText = metrics.elidedText(QString("

%1

").arg(prettyFilename), Qt::ElideRight, title->sizeHint().width()); + title->setText(elidedText); +#endif //Kludge for now, we'll have to fix this later... // So let's fix it now! @@ -403,10 +416,20 @@ void FilePickerWindow::UpdateSelection(const QModelIndex & current, const QModel fileTypeString = QString(tr("*** UNKNOWN *** (%1 bytes)")).arg(fileSize); } #else - if ((!haveUnknown && (romList[i].flags & FF_ROM)) || (haveUnknown && (fileType == JST_ROM))) + if ((!haveUnknown && (romList[i].flags & FF_ROM)) + || (haveUnknown && (fileType == JST_ROM) && !haveUniversalHeader)) fileTypeString = QString(tr("%1MB Cartridge")).arg(fileSize / 1048576); - else if ((!haveUnknown && (romList[i].flags & FF_ALPINE)) || (haveUnknown && (fileType == JST_ALPINE))) - fileTypeString = QString(tr("%1MB Alpine ROM")).arg(fileSize / 1048576); + else if ((!haveUnknown && (romList[i].flags & FF_ALPINE)) + || (haveUnknown + && ((fileType == JST_ALPINE) || ((fileType == JST_ROM) && haveUniversalHeader)))) + { + if (haveUniversalHeader) + fileTypeString = QString(tr("%1MB Alpine ROM w/Universal Header")); + else + fileTypeString = QString(tr("%1MB Alpine ROM")); + + fileTypeString = fileTypeString.arg((fileSize + 8192) / 1048576); + } else if (haveUnknown && (fileType == JST_ABS_TYPE1 || fileType == JST_ABS_TYPE2)) fileTypeString = QString(tr("ABS/COF Executable (%1 bytes)")).arg(fileSize); else if (haveUnknown && (fileType == JST_JAGSERVER)) @@ -427,8 +450,11 @@ void FilePickerWindow::UpdateSelection(const QModelIndex & current, const QModel if (!haveUnknown && (romList[i].flags & FF_BAD_DUMP)) notes = "BAD DUMP"; - if (haveUniversalHeader) - notes += " Universal Header detected"; +// if (haveUniversalHeader) +// notes += " Universal Header detected"; + + if (!haveUnknown && (romList[i].flags & FF_REQ_BIOS)) + notes += " Requires BIOS"; if (!haveUnknown && (romList[i].flags & FF_REQ_DSP)) notes += " Requires DSP";