]> Shamusworld >> Repos - virtualjaguar/commitdiff
Changed executable from vj to virtualjaguar to avoid possible future naming
authorShamus Hammons <jlhamm@acm.org>
Fri, 9 Apr 2010 16:24:11 +0000 (16:24 +0000)
committerShamus Hammons <jlhamm@acm.org>
Fri, 9 Apr 2010 16:24:11 +0000 (16:24 +0000)
collision. Also some minor changes which I can't remember (isn't that what svn
diff is for?)...

Makefile
src/gui/filepicker.cpp
src/gui/filepicker.h
src/gui/imagedelegate.cpp
src/gui/imagedelegate.h

index 31d3d9d8cca45517a27d24737461e8e9869ce0f7..eaa5953d11f28e5442a09e76263be517ad028675 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -46,7 +46,7 @@ endif
 
 CC         = gcc
 LD         = gcc
-TARGET     = vj
+TARGET     = virtualjaguar
 
 # Note that we use optimization level 2 instead of 3--3 doesn't seem to gain much over 2
 CFLAGS   = -MMD -Wall -Wno-switch -O2 -D$(SYSTYPE) -ffast-math -fomit-frame-pointer `sdl-config --cflags`
index 8d9afb38f79045e910f0104761f942b21723c489..b30124a54bd271df5df24472023ffc08042fdd0e 100644 (file)
@@ -10,6 +10,7 @@
 // ---  ----------  -------------------------------------------------------------
 // JLH  01/22/2010  Created this file
 // JLH  02/06/2010  Modified to use Qt model/view framework
+// JLH  03/08/2010  Added large cart view and info text
 //
 
 #include "filepicker.h"
@@ -37,13 +38,24 @@ Maybe box art, screenshots will go as well...
 
 I'm thinking compatibility info should be displayed as well... Just to stop the
 inevitable stupid questions from people too lazy to do basic research for themselves.
+
+
+Data strategy:
+
+- Should keep a QImage of the blank cart with blank label
+- Should keep a QImage of the blank cart? (For overpainting the ROMs label)
+- Should we have a special Alpine image? Floppy image (for COF/ABS)?
+
+- Need some way of keeping track of cart size and compatibility info
+  [compat info needs to be BAD DUMP or % of what works]
+- Need to properly scale the thumbnails images in the list
 */
 
 //could use Window as well...
 //FilePickerWindow::FilePickerWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Dialog)
 FilePickerWindow::FilePickerWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Window)
 {
-       setWindowTitle("Insert Cartridge...");
+       setWindowTitle(tr("Insert Cartridge..."));
 
 //is there any reason why this must be cast as a QAbstractListModel? No
 //Also, need to think about data structure for the model...
@@ -62,24 +74,42 @@ FilePickerWindow::FilePickerWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt:
        QVBoxLayout * vLayout = new QVBoxLayout;
        layout->addLayout(vLayout);
 
-       QLabel * image = new QLabel;
-//     image->setAlignment(Qt::AlignRight);
-//     image->setPixmap(QPixmap(":/res/cart-blank.png"));
+       cartImage = new QLabel;
        QImage cartImg(":/res/cart-blank.png");
        QPainter painter(&cartImg);
-       painter.drawPixmap(23, 87, 373, 172, QPixmap(":/res/label-blank.png"));
+       painter.drawPixmap(23, 87, QPixmap(":/res/label-blank.png"));
        painter.end();
-       image->setPixmap(QPixmap::fromImage(cartImg));
-       image->setMargin(4);
-       vLayout->addWidget(image);
-
-       QLabel * text1 = new QLabel(QString(tr(
-               "<h2>Attack of the Mutant Penguins (World)</h2>"
+       cartImage->setPixmap(QPixmap::fromImage(cartImg));
+       cartImage->setMargin(4);
+       vLayout->addWidget(cartImage);
+
+       title = new QLabel(QString(tr("<h2>...</h2>")));
+       title->setMargin(6);
+       title->setAlignment(Qt::AlignCenter);
+       vLayout->addWidget(title);
+
+#if 1
+       QHBoxLayout * dataLayout = new QHBoxLayout;
+       vLayout->addLayout(dataLayout);
+
+       QLabel * labels = new QLabel(QString(tr(
+               "<b>Type: </b><br>"
+               "<b>CRC32: </b><br>"
+               "<b>Compatibility: </b><br>"
+               "<b>Notes:</b>"
        )));
-       text1->setMargin(6);
-       text1->setAlignment(Qt::AlignCenter);
-       vLayout->addWidget(text1);
-
+       labels->setAlignment(Qt::AlignRight);
+       labels->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
+       dataLayout->addWidget(labels);
+       data = new QLabel(QString(tr(
+               "4MB Cartridge<br>"
+               "FEDCBA98<br>"
+               "DOES NOT WORK<br>"
+               "Universal Header detected; Requires DSP"
+       )));
+       data->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
+       dataLayout->addWidget(data);
+#else
        QLabel * text2 = new QLabel(QString(tr(
                "<table>"
                "<tr><td align='right'><b>Type: </b></td><td>4MB Cartridge</td></tr>"
@@ -89,6 +119,7 @@ FilePickerWindow::FilePickerWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt:
                "</table>"
        )));
        vLayout->addWidget(text2);
+#endif
 
        fileThread = new FileThread(this);
 //     connect(fileThread, SIGNAL(FoundAFile(unsigned long)), this, SLOT(AddFileToList(unsigned long)));
@@ -97,6 +128,10 @@ FilePickerWindow::FilePickerWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt:
 /*
 New sizes: 373x172 (label), 420x340 (cart)
 */
+
+//     QItemSelectionModel * ism = fileList->selectionModel();
+//     connect(ism, SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(UpdateSelection(const QModelIndex &, const QModelIndex &)));
+       connect(fileList->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(UpdateSelection(const QModelIndex &, const QModelIndex &)));
 }
 
 //
@@ -120,6 +155,31 @@ printf("FilePickerWindow(2): Found match [%s]...\n", romList[index].name);
                model->AddData(index, str, QImage());
 }
 
+//
+// This slot gets called when the QListView gets clicked on. Updates
+// the cart graphic and accompanying text.
+//
+void FilePickerWindow::UpdateSelection(const QModelIndex & current, const QModelIndex &/*previous*/)
+{
+       QString s = current.model()->data(current, Qt::EditRole).toString();
+       unsigned long i = current.model()->data(current, Qt::DisplayRole).toUInt();
+       QImage label = current.model()->data(current, Qt::DecorationRole).value<QImage>();
+//     printf("FPW: %s\n", s.toAscii().data());
+
+       if (!label.isNull())
+       {
+               QImage cart(":/res/cart-blank.png");
+               QPainter painter(&cart);
+               painter.drawPixmap(23, 87, QPixmap::fromImage(label));
+               painter.end();
+               cartImage->setPixmap(QPixmap::fromImage(cart));
+       }
+
+       title->setText(QString("<h2>%1</h2>").arg(romList[i].name));
+       QString crcString = QString("%1").arg(romList[i].crc32, 8, 16, QChar('0')).toUpper();
+       data->setText(QString("%1<br>%2<br>%3<br>%4").arg("Cart").arg(crcString).arg("100%").arg("Requires BIOS"));
+}
+
 /*
     Super Duper Awesome Guy (World)
 
index 447162efb7ccb56f491169c887f0cb2288e655e4..a8c588847614cd9896000747618f5a09f2b06b4b 100644 (file)
@@ -22,6 +22,7 @@ class FilePickerWindow: public QWidget
        public slots:
                void AddFileToList(unsigned long index);
                void AddFileToList2(unsigned long index, QString, QImage *);
+               void UpdateSelection(const QModelIndex &, const QModelIndex &);
 
        protected:
 //             void PopulateList(void);
@@ -29,7 +30,9 @@ class FilePickerWindow: public QWidget
        private:
                QListWidget * fileList2;
                FileThread * fileThread;
-//             QAbstractItemModel * model;
                FileListModel * model;
                QListView * fileList;
+               QLabel * cartImage;
+               QLabel * title;
+               QLabel * data;
 };
index 6d81005b7c19924164f3e154d47c1dd53af27e8b..eaae05fc00ed1ac3e3b2478bcf6ee4f00f4036e6 100644 (file)
 //{
 //}
 
+ImageDelegate::ImageDelegate()
+{
+       QImage cartImg(":/res/cart-blank.png");
+       QPainter painter(&cartImg);
+       painter.drawPixmap(23, 87, QPixmap(":/res/label-blank.png"));
+       painter.end();
+       cartSmall = cartImg.scaled(488/4, 395/4, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+}
+
 /*
 Each item is rendered by the delegate's paint() function. The view calls this function with a ready-to-use QPainter object, style information that the delegate should use to correctly draw the item, and an index to the item in the model:
 */
@@ -74,7 +83,11 @@ The foreground of the item (the circle representing a pixel) must be rendered us
 //     painter->drawPixmap(option.rect.x()+8, option.rect.y()+8, 200, 94, QPixmap(":/res/labels/rayman.jpg"));
 //     painter->drawPixmap(option.rect.x()+13, option.rect.y()+51, 433/2, 203/2, QPixmap(":/res/labels/rayman.jpg"));
 //     painter->drawPixmap(option.rect.x(), option.rect.y(), 488/2, 395/2, QPixmap(":/res/cart-blank.png"));
-       painter->drawPixmap(option.rect.x(), option.rect.y(), 488/4, 395/4, QPixmap(":/res/cart-blank.png"));
+
+
+       // This is crappy. We really should have a properly scaled image ready to go so we
+       // don't get Qt's default ugly looking fast scaling...
+#warning "!!! FIX !!! Need to create properly scaled down cart/label images!"
 //     unsigned long i = index.model()->data(index, Qt::DisplayRole).toUInt();
        unsigned long i = index.model()->data(index, Qt::DisplayRole).toUInt();
        QString filename = index.model()->data(index, Qt::EditRole).toString();
@@ -93,7 +106,8 @@ The foreground of the item (the circle representing a pixel) must be rendered us
        if (label.isNull())
        {
 //     painter->drawPixmap(option.rect.x()+14, option.rect.y()+50, 433/2, 203/2, QPixmap(":/res/label-blank.png"));
-               painter->drawPixmap(option.rect.x()+7, option.rect.y()+25, 433/4, 203/4, QPixmap(":/res/label-blank.png"));
+//             painter->drawPixmap(option.rect.x()+7, option.rect.y()+25, 433/4, 203/4, QPixmap(":/res/label-blank.png"));
+               painter->drawImage(option.rect.x() + 2, option.rect.y() + 2, cartSmall);
 //Need to query the model for the data we're supposed to draw here...
 //     painter->drawText(17, 73, QString(romList[i].name));
 //     painter->setPen(Qt::white);
@@ -109,7 +123,8 @@ The foreground of the item (the circle representing a pixel) must be rendered us
                QImage img(filename);
                painter->drawImage(QRect(option.rect.x()+7, option.rect.y()+25, 433/4, 203/4), img);
 #else
-               painter->drawImage(QRect(option.rect.x()+7, option.rect.y()+25, 433/4, 203/4), label);
+               painter->drawPixmap(option.rect.x() + 2, option.rect.y() + 2, 488/4, 395/4, QPixmap(":/res/cart-blank.png"));
+               painter->drawImage(QRect(option.rect.x()+2+7, option.rect.y()+2+25, 433/4, 203/4), label);
 #endif
        }
 //26x100
@@ -134,7 +149,7 @@ QSize ImageDelegate::sizeHint(const QStyleOptionViewItem & /* option */, const Q
 //     return QSize(100, 47);
 //     return QSize(216, 110);
 //     return QSize(488/2, 395/2);
-       return QSize(488/4, 395/4);
+       return QSize((488/4) + 4, (395/4) + 4);
 }
 
 /*
index 303e9255e44c176e1aa2aef863b802294e4ff484..3c77ff30bbec2b441a31174c0b89e4014e865b30 100644 (file)
@@ -13,6 +13,7 @@ class ImageDelegate: public QAbstractItemDelegate
 
        public:
 //             ImageDelegate(QObject * parent = 0);
+               ImageDelegate();
 
                void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
                QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index ) const;
@@ -20,8 +21,9 @@ class ImageDelegate: public QAbstractItemDelegate
 //     public slots:
 //             void setPixelSize(int size);
 
-//     private:
+       private:
 //             int pixelSize;
+               QImage cartSmall;
 };
 
 #endif // __IMAGEDELEGATE_H__