X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=inline;f=src%2Fgui%2Ffilepicker.cpp;h=d7f1507293885e82c4910a6b6967b0bd6390f2ec;hb=ea10984eaf09364d9f6e08114caa4bcfcaa72d9e;hp=150a2753c66101fddd5009d239a4808e2bdbf4ea;hpb=b79e71ad6d2f71a2c1ccacb3d37ff02be60f2538;p=virtualjaguar
diff --git a/src/gui/filepicker.cpp b/src/gui/filepicker.cpp
index 150a275..d7f1507 100644
--- a/src/gui/filepicker.cpp
+++ b/src/gui/filepicker.cpp
@@ -53,7 +53,8 @@ Data strategy:
//could use Window as well...
//FilePickerWindow::FilePickerWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Dialog)
-FilePickerWindow::FilePickerWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Window)
+FilePickerWindow::FilePickerWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Window),
+ currentFile("")
{
setWindowTitle(tr("Insert Cartridge..."));
@@ -138,6 +139,14 @@ printf("VSB size: %u, %u\n", sbSize3.width(), sbSize3.height());
)));
data->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
dataLayout->addWidget(data);
+
+//#warning "!!! Icon size for pushbutton is tiny !!!"
+ insertCart = new QPushButton(this);
+ insertCart->setIconSize(QSize(40, 40));
+ insertCart->setIcon(QIcon(":/res/insert.png"));
+ 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(
"
"
@@ -161,6 +170,13 @@ 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 &)));
+
+ connect(insertCart, SIGNAL(clicked()), this, SLOT(LoadButtonPressed()));
+}
+
+QString FilePickerWindow::GetSelectedPrettyName(void)
+{
+ return prettyFilename;
}
//
@@ -188,6 +204,13 @@ printf("FilePickerWindow(2): Found match [%s]...\n", romList[index].name);
model->AddData(index, str, QImage(), size);
}
+void FilePickerWindow::LoadButtonPressed(void)
+{
+ // TODO: Get the text of the current selection, call the MainWin slot for loading
+ emit(RequestLoad(currentFile));
+ this->hide();
+}
+
//
// This slot gets called when the QListView gets clicked on. Updates
// the cart graphic and accompanying text.
@@ -201,13 +224,19 @@ void FilePickerWindow::UpdateSelection(const QModelIndex & current, const QModel
// printf("FPW: %s\n", s.toAscii().data());
unsigned long fileSize = current.model()->data(current, Qt::WhatsThisRole).toUInt();
#else
- QString s = current.model()->data(current, FLM_FILENAME).toString();
+// QString s = current.model()->data(current, FLM_FILENAME).toString();
+ currentFile = current.model()->data(current, FLM_FILENAME).toString();
unsigned long i = current.model()->data(current, FLM_INDEX).toUInt();
QImage label = current.model()->data(current, FLM_LABEL).value();
unsigned long fileSize = current.model()->data(current, FLM_FILESIZE).toUInt();
// printf("FPW: %s\n", s.toAscii().data());
#endif
+
+//hm.
+//currentFile = s;
+
//373x172 is label size...
+//365x168 now...
if (!label.isNull())
{
/*
@@ -222,8 +251,27 @@ void FilePickerWindow::UpdateSelection(const QModelIndex & current, const QModel
//Though this should probably be done when this is loaded, instead of every time here...
//QImage scaledImg = label.scaled(373, 172, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
//painter.drawPixmap(23, 87, QPixmap::fromImage(scaledImg));
- painter.drawPixmap(23, 87, QPixmap::fromImage(label));
+ // Now, looks like it is...
+// painter.drawPixmap(23, 87, QPixmap::fromImage(label));
+ painter.drawPixmap(27, 89, QPixmap::fromImage(label));
// painter.drawPixmap(23, 87, 373, 172, QPixmap::fromImage(label));
+
+// Well, heck. This should be done to the label *before* we get here.
+ painter.drawPixmap(27, 89, QPixmap::fromImage(QImage(":/res/upper-left.png")));
+ painter.drawPixmap(27+355, 89, QPixmap::fromImage(QImage(":/res/upper-right.png")));
+
+ painter.end();
+ cartImage->setPixmap(QPixmap::fromImage(cart));
+ }
+ else
+ {
+ // We should try to be intelligent with our updates here, and only redraw when
+ // we're going from a selection with a label to a selection without. Now, we
+ // redraw regardless.
+ QImage cart(":/res/cart-blank.png");
+ QPainter painter(&cart);
+// painter.drawPixmap(23, 87, QPixmap::fromImage(QImage(":/res/label-blank.png")));
+ painter.drawPixmap(27, 89, QPixmap::fromImage(QImage(":/res/label-blank.png")));
painter.end();
cartImage->setPixmap(QPixmap::fromImage(cart));
}
@@ -231,6 +279,7 @@ void FilePickerWindow::UpdateSelection(const QModelIndex & current, const QModel
//1048576
//2097152
//4194304
+ prettyFilename = romList[i].name;
title->setText(QString("%1
").arg(romList[i].name));
//Kludge for now, we'll have to fix this later...
QString fileType = QString(romList[i].flags & FF_ROM ? "%1MB Cartridge" : "%1*** UNKNOWN ***")