X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fgui%2Ffilepicker.cpp;h=eeec7f4937448dbf613d0ded7376c0cbb7dc1978;hb=7a92a3a54da8634b6765fafd8e5a5724838941b1;hp=06e517d0e2d5235c4a014d6c46f5c46aa0c39c5f;hpb=f24ae2128609d5ab8c9a57dfd9dbb46afb7302a9;p=virtualjaguar diff --git a/src/gui/filepicker.cpp b/src/gui/filepicker.cpp index 06e517d..eeec7f4 100644 --- a/src/gui/filepicker.cpp +++ b/src/gui/filepicker.cpp @@ -86,14 +86,35 @@ printf("VSB size: %u, %u\n", sbSize3.width(), sbSize3.height()); // 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); +// printf("VSB size width: %u\n", sbWidth); int sbWidth2 = vsb->sizeHint().width(); - printf("VSB sizeHint width: %u\n", sbWidth2); +// 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->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); -// fileList->verticalScrollBar()->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); - fileList->setFixedWidth((488/4) + 4 + sbWidth);//ick +// 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); + // (488/4) + 4 is the width of the object in the filelistmodel. Dunno why the QListView + // isn't picking that up. :-( + // 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); + fileList->setUniformItemSizes(true); #endif // QVBoxLayout * layout = new QVBoxLayout; @@ -134,9 +155,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); @@ -179,6 +200,28 @@ New sizes: 373x172 (label), 420x340 (cart) connect(fileList->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(UpdateSelection(const QModelIndex &, const QModelIndex &))); connect(insertCart, SIGNAL(clicked()), this, SLOT(LoadButtonPressed())); + + connect(fileList, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(CatchDoubleClick(const QModelIndex &))); + +// connect(fileList, SIGNAL(doubleClicked()), this, SLOT(LoadButtonPressed())); +// This returns: +// Object::connect: No such signal QListView::QAbstractItemView::doubleClicked() in src/gui/filepicker.cpp:203 +} + +void FilePickerWindow::keyPressEvent(QKeyEvent * e) +{ + if (e->key() == Qt::Key_Escape) + { + hide(); + emit(FilePickerHiding()); + } + else if (e->key() == Qt::Key_Return) + LoadButtonPressed(); +} + +void FilePickerWindow::CatchDoubleClick(const QModelIndex &) +{ + LoadButtonPressed(); } QString FilePickerWindow::GetSelectedPrettyName(void) @@ -222,8 +265,8 @@ if (index != 0xFFFFFFFF) void FilePickerWindow::AddFileToList3(unsigned long index, QString str, QImage * img, unsigned long size, bool haveUniversalHeader, unsigned long fileType, unsigned long crc) { -if (index != 0xFFFFFFFF) - printf("FilePickerWindow(3): Found match [%s]...\n", romList[index].name); +//if (index != 0xFFFFFFFF) +// printf("FilePickerWindow(3): Found match [%s]...\n", romList[index].name); if (img) { @@ -239,7 +282,7 @@ void FilePickerWindow::LoadButtonPressed(void) { // TODO: Get the text of the current selection, call the MainWin slot for loading emit(RequestLoad(currentFile)); - this->hide(); + hide(); } // @@ -315,7 +358,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); @@ -323,11 +366,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)) { cart = QImage(":/res/homebrew-file.png"); } @@ -365,10 +413,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)) @@ -389,8 +447,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";