Second and last part of the icon indicator work.
BIN
src/qt/icons/browse.ico
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
src/qt/icons/cartridge_image.ico
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
src/qt/icons/cassette_image.ico
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
src/qt/icons/cdrom_nomedia.ico
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
src/qt/icons/eject.ico
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
src/qt/icons/export.ico
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
src/qt/icons/fast_forward.ico
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
src/qt/icons/floppy_35_image.ico
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
src/qt/icons/floppy_525_image.ico
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
src/qt/icons/mo_image.ico
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
src/qt/icons/new.ico
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
src/qt/icons/record.ico
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
src/qt/icons/rewind.ico
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
src/qt/icons/superdisk.ico
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
src/qt/icons/superdisk_disabled.ico
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
src/qt/icons/superdisk_image.ico
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
|
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 9.4 KiB |
BIN
src/qt/icons/zip_image.ico
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
@@ -14,6 +14,14 @@ getIndicatorIcon(IconIndicator indicator)
|
||||
return QIcon(":/settings/qt/icons/disabled.ico");
|
||||
case WriteProtected:
|
||||
return QIcon(":/settings/qt/icons/write_protected.ico");
|
||||
case New:
|
||||
return QIcon(":/settings/qt/icons/new.ico");
|
||||
case Browse:
|
||||
return QIcon(":/settings/qt/icons/browse.ico");
|
||||
case Eject:
|
||||
return QIcon(":/settings/qt/icons/eject.ico");
|
||||
case Export:
|
||||
return QIcon(":/settings/qt/icons/eject.ico");
|
||||
default:
|
||||
return QIcon();
|
||||
}
|
||||
@@ -30,12 +38,18 @@ getIconWithIndicator(const QIcon &icon, const QSize &size, QIcon::Mode iconMode,
|
||||
auto painter = QPainter(&iconPixmap);
|
||||
auto indicatorPixmap = getIndicatorIcon((indicator == ReadWriteActive || indicator == WriteProtectedActive) ? Active : indicator).pixmap(size);
|
||||
|
||||
if (indicator == WriteProtectedBrowse)
|
||||
indicatorPixmap = getIndicatorIcon(WriteProtected).pixmap(size);
|
||||
|
||||
painter.drawPixmap(0, 0, indicatorPixmap);
|
||||
if (indicator == ReadWriteActive || indicator == WriteProtectedActive) {
|
||||
if ((indicator == ReadWriteActive) || (indicator == WriteProtectedActive)) {
|
||||
auto writeIndicatorPixmap = getIndicatorIcon(indicator == WriteProtectedActive ? WriteProtected : WriteActive).pixmap(size);
|
||||
painter.drawPixmap(0, 0, writeIndicatorPixmap);
|
||||
} else if (indicator == WriteProtectedBrowse) {
|
||||
auto browseIndicatorPixmap = getIndicatorIcon(Browse).pixmap(size);
|
||||
painter.drawPixmap(0, 0, browseIndicatorPixmap);
|
||||
}
|
||||
painter.end();
|
||||
|
||||
return iconPixmap;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,11 @@ enum IconIndicator {
|
||||
Disabled,
|
||||
WriteProtected,
|
||||
WriteProtectedActive,
|
||||
New,
|
||||
Browse,
|
||||
WriteProtectedBrowse,
|
||||
Export,
|
||||
Eject
|
||||
};
|
||||
|
||||
QPixmap getIconWithIndicator(const QIcon &icon, const QSize &size, QIcon::Mode iconMode, IconIndicator indicator);
|
||||
|
||||
@@ -617,7 +617,12 @@ MachineStatus::refresh(QStatusBar *sbar)
|
||||
if (cassette_enable) {
|
||||
d->cassette.label = std::make_unique<ClickableLabel>();
|
||||
d->cassette.setEmpty(QString(cassette_fname).isEmpty());
|
||||
d->cassette.setWriteProtected(cassette_ui_writeprot);
|
||||
if (QString(cassette_fname).isEmpty())
|
||||
d->cassette.setWriteProtected(false);
|
||||
else if (QString(cassette_fname).left(5) == "wp://")
|
||||
d->cassette.setWriteProtected(true);
|
||||
else
|
||||
d->cassette.setWriteProtected(cassette_ui_writeprot);
|
||||
d->cassette.refresh();
|
||||
connect((ClickableLabel *) d->cassette.label.get(), &ClickableLabel::clicked, [](QPoint pos) {
|
||||
MediaMenu::ptr->cassetteMenu->popup(pos - QPoint(0, MediaMenu::ptr->cassetteMenu->sizeHint().height()));
|
||||
@@ -658,7 +663,12 @@ MachineStatus::refresh(QStatusBar *sbar)
|
||||
}
|
||||
d->fdd[i].label = std::make_unique<ClickableLabel>();
|
||||
d->fdd[i].setEmpty(QString(floppyfns[i]).isEmpty());
|
||||
d->fdd[i].setWriteProtected(ui_writeprot[i]);
|
||||
if (QString(floppyfns[i]).isEmpty())
|
||||
d->fdd[i].setWriteProtected(false);
|
||||
else if (QString(floppyfns[i]).left(5) == "wp://")
|
||||
d->fdd[i].setWriteProtected(true);
|
||||
else
|
||||
d->fdd[i].setWriteProtected(ui_writeprot[i]);
|
||||
d->fdd[i].setActive(false);
|
||||
d->fdd[i].setWriteActive(false);
|
||||
d->fdd[i].refresh();
|
||||
@@ -693,7 +703,12 @@ MachineStatus::refresh(QStatusBar *sbar)
|
||||
iterateZIP([this, sbar](int i) {
|
||||
d->zip[i].label = std::make_unique<ClickableLabel>();
|
||||
d->zip[i].setEmpty(QString(zip_drives[i].image_path).isEmpty());
|
||||
d->zip[i].setWriteProtected(zip_drives[i].read_only);
|
||||
if (QString(zip_drives[i].image_path).isEmpty())
|
||||
d->zip[i].setWriteProtected(false);
|
||||
else if (QString(zip_drives[i].image_path).left(5) == "wp://")
|
||||
d->zip[i].setWriteProtected(true);
|
||||
else
|
||||
d->zip[i].setWriteProtected(zip_drives[i].read_only);
|
||||
d->zip[i].setActive(false);
|
||||
d->zip[i].setWriteActive(false);
|
||||
d->zip[i].refresh();
|
||||
@@ -711,7 +726,12 @@ MachineStatus::refresh(QStatusBar *sbar)
|
||||
iterateMO([this, sbar](int i) {
|
||||
d->mo[i].label = std::make_unique<ClickableLabel>();
|
||||
d->mo[i].setEmpty(QString(mo_drives[i].image_path).isEmpty());
|
||||
d->mo[i].setWriteProtected(mo_drives[i].read_only);
|
||||
if (QString(zip_drives[i].image_path).isEmpty())
|
||||
d->mo[i].setWriteProtected(false);
|
||||
else if (QString(zip_drives[i].image_path).left(5) == "wp://")
|
||||
d->mo[i].setWriteProtected(true);
|
||||
else
|
||||
d->mo[i].setWriteProtected(zip_drives[i].read_only);
|
||||
d->mo[i].setActive(false);
|
||||
d->mo[i].setWriteActive(false);
|
||||
d->mo[i].refresh();
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
#include <QStringBuilder>
|
||||
#include <utility>
|
||||
#include "qt_mediahistorymanager.hpp"
|
||||
#ifdef Q_OS_WINDOWS
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
#include <86box/timer.h>
|
||||
@@ -205,6 +208,8 @@ MediaHistoryManager::initialDeduplication()
|
||||
break;
|
||||
}
|
||||
deduplicateList(device_history, QVector<QString>(1, current_image));
|
||||
device_history = removeMissingImages(device_history);
|
||||
device_history = pathAdjustFull(device_history);
|
||||
// Fill in missing, if any
|
||||
int missing = MAX_PREV_IMAGES - device_history.size();
|
||||
if (missing) {
|
||||
@@ -213,6 +218,7 @@ MediaHistoryManager::initialDeduplication()
|
||||
}
|
||||
}
|
||||
setHistoryListForDeviceIndex(device_index, device_type, device_history);
|
||||
serializeImageHistoryType(device_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -343,24 +349,42 @@ MediaHistoryManager::removeMissingImages(device_index_list_t &device_history)
|
||||
|
||||
char temp[MAX_IMAGE_PATH_LEN * 2] = { 0 };
|
||||
|
||||
if (path_abs(checked_path.toUtf8().data())) {
|
||||
if (checked_path.length() > (MAX_IMAGE_PATH_LEN - 1))
|
||||
fatal("removeMissingImages(): checked_path.length() > %i\n", MAX_IMAGE_PATH_LEN - 1);
|
||||
else
|
||||
snprintf(temp, (MAX_IMAGE_PATH_LEN - 1), "%s", checked_path.toUtf8().constData());
|
||||
if (checked_path.left(8) == "ioctl://") {
|
||||
strncpy(temp, checked_path.toUtf8().data(), sizeof(temp));
|
||||
temp[sizeof(temp) - 1] = '\0';
|
||||
} else {
|
||||
if ((strlen(usr_path) + strlen(path_get_slash(usr_path)) + checked_path.length()) > (MAX_IMAGE_PATH_LEN - 1))
|
||||
fatal("removeMissingImages(): Combined absolute path length > %i\n", MAX_IMAGE_PATH_LEN - 1);
|
||||
QString path_only;
|
||||
if (checked_path.left(5) == "wp://")
|
||||
path_only = checked_path.right(checked_path.length() - 5);
|
||||
else
|
||||
snprintf(temp, (MAX_IMAGE_PATH_LEN - 1), "%s%s%s", usr_path,
|
||||
path_get_slash(usr_path), checked_path.toUtf8().constData());
|
||||
path_only = checked_path;
|
||||
|
||||
if (path_abs(path_only.toUtf8().data())) {
|
||||
if (path_only.length() > (MAX_IMAGE_PATH_LEN - 1))
|
||||
fatal("removeMissingImages(): path_only.length() > %i\n", MAX_IMAGE_PATH_LEN - 1);
|
||||
else
|
||||
snprintf(temp, (MAX_IMAGE_PATH_LEN - 1), "%s", path_only.toUtf8().constData());
|
||||
} else {
|
||||
if ((strlen(usr_path) + strlen(path_get_slash(usr_path)) + path_only.length()) > (MAX_IMAGE_PATH_LEN - 1))
|
||||
fatal("removeMissingImages(): Combined absolute path length > %i\n", MAX_IMAGE_PATH_LEN - 1);
|
||||
else
|
||||
snprintf(temp, (MAX_IMAGE_PATH_LEN - 1), "%s%s%s", usr_path,
|
||||
path_get_slash(usr_path), path_only.toUtf8().constData());
|
||||
}
|
||||
path_normalize(temp);
|
||||
}
|
||||
path_normalize(temp);
|
||||
|
||||
QString qstr = QString::fromUtf8(temp);
|
||||
QFileInfo new_fi(qstr);
|
||||
|
||||
if ((new_fi.filePath().left(8) != "ioctl://") && !new_fi.exists()) {
|
||||
bool file_exists = new_fi.exists();
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
if (new_fi.filePath().left(8) == "ioctl://")
|
||||
file_exists = (GetDriveType(new_fi.filePath().right(2).toUtf8().data()) == DRIVE_CDROM);
|
||||
#endif
|
||||
|
||||
if (!file_exists) {
|
||||
qWarning("Image file %s does not exist - removing from history", qPrintable(new_fi.filePath()));
|
||||
checked_path = "";
|
||||
}
|
||||
|
||||
@@ -69,9 +69,12 @@ extern "C" {
|
||||
#include "qt_deviceconfig.hpp"
|
||||
#include "qt_mediahistorymanager.hpp"
|
||||
#include "qt_mediamenu.hpp"
|
||||
#include "qt_iconindicators.hpp"
|
||||
|
||||
std::shared_ptr<MediaMenu> MediaMenu::ptr;
|
||||
|
||||
static QSize pixmap_size(16, 16);
|
||||
|
||||
MediaMenu::MediaMenu(QWidget *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
@@ -86,27 +89,28 @@ MediaMenu::refresh(QMenu *parentMenu)
|
||||
|
||||
if (MachineStatus::hasCassette()) {
|
||||
cassetteMenu = parentMenu->addMenu("");
|
||||
cassetteMenu->addAction(tr("&New image..."), [this]() { cassetteNewImage(); });
|
||||
QIcon img_icon = QIcon(":/settings/qt/icons/cassette_image.ico");
|
||||
cassetteMenu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, New), tr("&New image..."), [this]() { cassetteNewImage(); });
|
||||
cassetteMenu->addSeparator();
|
||||
cassetteMenu->addAction(tr("&Existing image..."), [this]() { cassetteSelectImage(false); });
|
||||
cassetteMenu->addAction(tr("Existing image (&Write-protected)..."), [this]() { cassetteSelectImage(true); });
|
||||
cassetteMenu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, Browse), tr("&Existing image..."), [this]() { cassetteSelectImage(false); });
|
||||
cassetteMenu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, WriteProtectedBrowse), tr("Existing image (&Write-protected)..."), [this]() { cassetteSelectImage(true); });
|
||||
cassetteMenu->addSeparator();
|
||||
for (int slot = 0; slot < MAX_PREV_IMAGES; slot++) {
|
||||
cassetteImageHistoryPos[slot] = cassetteMenu->children().count();
|
||||
cassetteMenu->addAction(tr("Image %1").arg(slot), [this, slot]() { cassetteMenuSelect(slot); })->setCheckable(false);
|
||||
cassetteMenu->addAction(img_icon, tr("Image %1").arg(slot), [this, slot]() { cassetteMenuSelect(slot); })->setCheckable(false);
|
||||
}
|
||||
cassetteMenu->addSeparator();
|
||||
cassetteRecordPos = cassetteMenu->children().count();
|
||||
cassetteMenu->addAction(tr("&Record"), [this] { pc_cas_set_mode(cassette, 1); cassetteUpdateMenu(); })->setCheckable(true);
|
||||
cassetteMenu->addAction(QIcon(":/settings/qt/icons/record.ico"), tr("&Record"), [this] { pc_cas_set_mode(cassette, 1); cassetteUpdateMenu(); })->setCheckable(true);
|
||||
cassettePlayPos = cassetteMenu->children().count();
|
||||
cassetteMenu->addAction(tr("&Play"), [this] { pc_cas_set_mode(cassette, 0); cassetteUpdateMenu(); })->setCheckable(true);
|
||||
cassetteMenu->addAction(QIcon(":/menuicons/qt/icons/run.ico"), tr("&Play"), [this] { pc_cas_set_mode(cassette, 0); cassetteUpdateMenu(); })->setCheckable(true);
|
||||
cassetteRewindPos = cassetteMenu->children().count();
|
||||
cassetteMenu->addAction(tr("&Rewind to the beginning"), [] { pc_cas_rewind(cassette); });
|
||||
cassetteMenu->addAction(QIcon(":/settings/qt/icons/rewind.ico"), tr("&Rewind to the beginning"), [] { pc_cas_rewind(cassette); });
|
||||
cassetteFastFwdPos = cassetteMenu->children().count();
|
||||
cassetteMenu->addAction(tr("&Fast forward to the end"), [] { pc_cas_append(cassette); });
|
||||
cassetteMenu->addAction(QIcon(":/settings/qt/icons/fast_forward.ico"), tr("&Fast forward to the end"), [] { pc_cas_append(cassette); });
|
||||
cassetteMenu->addSeparator();
|
||||
cassetteEjectPos = cassetteMenu->children().count();
|
||||
cassetteMenu->addAction(tr("E&ject"), [this]() { cassetteEject(); });
|
||||
cassetteMenu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, Eject), tr("E&ject"), [this]() { cassetteEject(); });
|
||||
cassetteUpdateMenu();
|
||||
}
|
||||
|
||||
@@ -114,15 +118,16 @@ MediaMenu::refresh(QMenu *parentMenu)
|
||||
if (machine_has_cartridge(machine)) {
|
||||
for (int i = 0; i < 2; i++) {
|
||||
auto *menu = parentMenu->addMenu("");
|
||||
menu->addAction(tr("&Image..."), [this, i]() { cartridgeSelectImage(i); });
|
||||
QIcon img_icon = QIcon(":/settings/qt/icons/cartridge_image.ico");
|
||||
menu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, Browse), tr("&Image..."), [this, i]() { cartridgeSelectImage(i); });
|
||||
menu->addSeparator();
|
||||
for (int slot = 0; slot < MAX_PREV_IMAGES; slot++) {
|
||||
cartridgeImageHistoryPos[slot] = menu->children().count();
|
||||
menu->addAction(tr("Image %1").arg(slot), [this, i, slot]() { cartridgeMenuSelect(i, slot); })->setCheckable(false);
|
||||
menu->addAction(img_icon, tr("Image %1").arg(slot), [this, i, slot]() { cartridgeMenuSelect(i, slot); })->setCheckable(false);
|
||||
}
|
||||
menu->addSeparator();
|
||||
cartridgeEjectPos = menu->children().count();
|
||||
menu->addAction(tr("E&ject"), [this, i]() { cartridgeEject(i); });
|
||||
menu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, Eject), tr("E&ject"), [this, i]() { cartridgeEject(i); });
|
||||
cartridgeMenus[i] = menu;
|
||||
cartridgeUpdateMenu(i);
|
||||
}
|
||||
@@ -131,21 +136,23 @@ MediaMenu::refresh(QMenu *parentMenu)
|
||||
floppyMenus.clear();
|
||||
MachineStatus::iterateFDD([this, parentMenu](int i) {
|
||||
auto *menu = parentMenu->addMenu("");
|
||||
menu->addAction(tr("&New image..."), [this, i]() { floppyNewImage(i); });
|
||||
QIcon img_icon = fdd_is_525(i) ? QIcon(":/settings/qt/icons/floppy_525_image.ico") :
|
||||
QIcon(":/settings/qt/icons/floppy_35_image.ico");
|
||||
menu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, New), tr("&New image..."), [this, i]() { floppyNewImage(i); });
|
||||
menu->addSeparator();
|
||||
menu->addAction(tr("&Existing image..."), [this, i]() { floppySelectImage(i, false); });
|
||||
menu->addAction(tr("Existing image (&Write-protected)..."), [this, i]() { floppySelectImage(i, true); });
|
||||
menu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, Browse), tr("&Existing image..."), [this, i]() { floppySelectImage(i, false); });
|
||||
menu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, WriteProtectedBrowse), tr("Existing image (&Write-protected)..."), [this, i]() { floppySelectImage(i, true); });
|
||||
menu->addSeparator();
|
||||
for (int slot = 0; slot < MAX_PREV_IMAGES; slot++) {
|
||||
floppyImageHistoryPos[slot] = menu->children().count();
|
||||
menu->addAction(tr("Image %1").arg(slot), [this, i, slot]() { floppyMenuSelect(i, slot); })->setCheckable(false);
|
||||
menu->addAction(img_icon, tr("Image %1").arg(slot), [this, i, slot]() { floppyMenuSelect(i, slot); })->setCheckable(false);
|
||||
}
|
||||
menu->addSeparator();
|
||||
floppyExportPos = menu->children().count();
|
||||
menu->addAction(tr("E&xport to 86F..."), [this, i]() { floppyExportTo86f(i); });
|
||||
menu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, Export), tr("E&xport to 86F..."), [this, i]() { floppyExportTo86f(i); });
|
||||
menu->addSeparator();
|
||||
floppyEjectPos = menu->children().count();
|
||||
menu->addAction(tr("E&ject"), [this, i]() { floppyEject(i); });
|
||||
menu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, Eject), tr("E&ject"), [this, i]() { floppyEject(i); });
|
||||
floppyMenus[i] = menu;
|
||||
floppyUpdateMenu(i);
|
||||
});
|
||||
@@ -156,8 +163,8 @@ MediaMenu::refresh(QMenu *parentMenu)
|
||||
cdromMutePos = menu->children().count();
|
||||
menu->addAction(QIcon(":/settings/qt/icons/cdrom_mute.ico"), tr("&Mute"), [this, i]() { cdromMute(i); })->setCheckable(true);
|
||||
menu->addSeparator();
|
||||
menu->addAction(QIcon(":/settings/qt/icons/cdrom_image.ico"), tr("&Image..."), [this, i]() { cdromMount(i, 0, nullptr); })->setCheckable(false);
|
||||
menu->addAction(QIcon(":/settings/qt/icons/cdrom_folder.ico"), tr("&Folder..."), [this, i]() { cdromMount(i, 1, nullptr); })->setCheckable(false);
|
||||
menu->addAction(getIconWithIndicator(QIcon(":/settings/qt/icons/cdrom_image.ico"), pixmap_size, QIcon::Normal, Browse), tr("&Image..."), [this, i]() { cdromMount(i, 0, nullptr); })->setCheckable(false);
|
||||
menu->addAction(getIconWithIndicator(QIcon(":/settings/qt/icons/cdrom_folder.ico"), pixmap_size, QIcon::Normal, Browse), tr("&Folder..."), [this, i]() { cdromMount(i, 1, nullptr); })->setCheckable(false);
|
||||
menu->addSeparator();
|
||||
for (int slot = 0; slot < MAX_PREV_IMAGES; slot++) {
|
||||
cdromImageHistoryPos[slot] = menu->children().count();
|
||||
@@ -183,18 +190,19 @@ MediaMenu::refresh(QMenu *parentMenu)
|
||||
zipMenus.clear();
|
||||
MachineStatus::iterateZIP([this, parentMenu](int i) {
|
||||
auto *menu = parentMenu->addMenu("");
|
||||
menu->addAction(tr("&New image..."), [this, i]() { zipNewImage(i); });
|
||||
QIcon img_icon = QIcon(":/settings/qt/icons/zip_image.ico");
|
||||
menu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, New), tr("&New image..."), [this, i]() { zipNewImage(i); });
|
||||
menu->addSeparator();
|
||||
menu->addAction(tr("&Existing image..."), [this, i]() { zipSelectImage(i, false); });
|
||||
menu->addAction(tr("Existing image (&Write-protected)..."), [this, i]() { zipSelectImage(i, true); });
|
||||
menu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, Browse), tr("&Existing image..."), [this, i]() { zipSelectImage(i, false); });
|
||||
menu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, WriteProtectedBrowse), tr("Existing image (&Write-protected)..."), [this, i]() { zipSelectImage(i, true); });
|
||||
menu->addSeparator();
|
||||
for (int slot = 0; slot < MAX_PREV_IMAGES; slot++) {
|
||||
zipImageHistoryPos[slot] = menu->children().count();
|
||||
menu->addAction(tr("Image %1").arg(slot), [this, i, slot]() { zipReload(i, slot); })->setCheckable(false);
|
||||
menu->addAction(img_icon, tr("Image %1").arg(slot), [this, i, slot]() { zipReload(i, slot); })->setCheckable(false);
|
||||
}
|
||||
menu->addSeparator();
|
||||
zipEjectPos = menu->children().count();
|
||||
menu->addAction(tr("E&ject"), [this, i]() { zipEject(i); });
|
||||
menu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, Eject), tr("E&ject"), [this, i]() { zipEject(i); });
|
||||
zipMenus[i] = menu;
|
||||
zipUpdateMenu(i);
|
||||
});
|
||||
@@ -202,18 +210,19 @@ MediaMenu::refresh(QMenu *parentMenu)
|
||||
moMenus.clear();
|
||||
MachineStatus::iterateMO([this, parentMenu](int i) {
|
||||
auto *menu = parentMenu->addMenu("");
|
||||
menu->addAction(tr("&New image..."), [this, i]() { moNewImage(i); });
|
||||
QIcon img_icon = QIcon(":/settings/qt/icons/mo_image.ico");
|
||||
menu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, New), tr("&New image..."), [this, i]() { moNewImage(i); });
|
||||
menu->addSeparator();
|
||||
menu->addAction(tr("&Existing image..."), [this, i]() { moSelectImage(i, false); });
|
||||
menu->addAction(tr("Existing image (&Write-protected)..."), [this, i]() { moSelectImage(i, true); });
|
||||
menu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, Browse), tr("&Existing image..."), [this, i]() { moSelectImage(i, false); });
|
||||
menu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, WriteProtectedBrowse), tr("Existing image (&Write-protected)..."), [this, i]() { moSelectImage(i, true); });
|
||||
menu->addSeparator();
|
||||
for (int slot = 0; slot < MAX_PREV_IMAGES; slot++) {
|
||||
moImageHistoryPos[slot] = menu->children().count();
|
||||
menu->addAction(tr("Image %1").arg(slot), [this, i, slot]() { moReload(i, slot); })->setCheckable(false);
|
||||
menu->addAction(img_icon, tr("Image %1").arg(slot), [this, i, slot]() { moReload(i, slot); })->setCheckable(false);
|
||||
}
|
||||
menu->addSeparator();
|
||||
moEjectPos = menu->children().count();
|
||||
menu->addAction(tr("E&ject"), [this, i]() { moEject(i); });
|
||||
menu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, Eject), tr("E&ject"), [this, i]() { moEject(i); });
|
||||
moMenus[i] = menu;
|
||||
moUpdateMenu(i);
|
||||
});
|
||||
@@ -277,6 +286,12 @@ MediaMenu::cassetteMount(const QString &filename, bool wp)
|
||||
|
||||
if (!filename.isEmpty()) {
|
||||
QByteArray filenameBytes = filename.toUtf8();
|
||||
|
||||
if (filename.left(5) == "wp://")
|
||||
cassette_ui_writeprot = 1;
|
||||
else if (cassette_ui_writeprot)
|
||||
filenameBytes = QString::asprintf(R"(wp://%s)", filename.toUtf8().data()).toUtf8();
|
||||
|
||||
strncpy(cassette_fname, filenameBytes.data(), sizeof(cassette_fname) - 1);
|
||||
pc_cas_set_fname(cassette, cassette_fname);
|
||||
}
|
||||
@@ -444,11 +459,18 @@ MediaMenu::floppyMount(int i, const QString &filename, bool wp)
|
||||
ui_writeprot[i] = wp ? 1 : 0;
|
||||
if (!filename.isEmpty()) {
|
||||
QByteArray filenameBytes = filename.toUtf8();
|
||||
|
||||
if (filename.left(5) == "wp://")
|
||||
ui_writeprot[i] = 1;
|
||||
else if (ui_writeprot[i])
|
||||
filenameBytes = QString::asprintf(R"(wp://%s)", filename.toUtf8().data()).toUtf8();
|
||||
|
||||
fdd_load(i, filenameBytes.data());
|
||||
}
|
||||
mhm.addImageToHistory(i, ui::MediaType::Floppy, previous_image.filePath(), QString(filenameBytes));
|
||||
} else
|
||||
mhm.addImageToHistory(i, ui::MediaType::Floppy, previous_image.filePath(), filename);
|
||||
ui_sb_update_icon_state(SB_FLOPPY | i, filename.isEmpty() ? 1 : 0);
|
||||
ui_sb_update_icon_wp(SB_FLOPPY | i, ui_writeprot[i]);
|
||||
mhm.addImageToHistory(i, ui::MediaType::Floppy, previous_image.filePath(), filename);
|
||||
floppyUpdateMenu(i);
|
||||
ui_sb_update_tip(SB_FLOPPY | i);
|
||||
config_save();
|
||||
@@ -569,7 +591,7 @@ MediaMenu::cdromMount(int i, int dir, const QString &arg)
|
||||
QFileInfo fi(cdrom[i].image_path);
|
||||
|
||||
if (dir > 1)
|
||||
filename = QString::asprintf(R"(ioctl://%s)", arg.toStdString().c_str());
|
||||
filename = QString::asprintf(R"(ioctl://%s)", arg.toUtf8().data());
|
||||
else if (dir == 1)
|
||||
filename = QFileDialog::getExistingDirectory(parentWidget);
|
||||
else {
|
||||
@@ -641,8 +663,18 @@ MediaMenu::updateImageHistory(int index, int slot, ui::MediaType type)
|
||||
menu = cassetteMenu;
|
||||
children = menu->children();
|
||||
imageHistoryUpdatePos = dynamic_cast<QAction *>(children[cassetteImageHistoryPos[slot]]);
|
||||
fi.setFile(fn);
|
||||
menu_item_name = fi.fileName().isEmpty() ? tr("Reload previous image") : fn;
|
||||
menu_icon = QIcon(":/settings/qt/icons/cassette_image.ico");
|
||||
if (fn.left(5) == "wp://")
|
||||
fi.setFile(fn.right(fn.length() - 5));
|
||||
else
|
||||
fi.setFile(fn);
|
||||
if (!fi.fileName().isEmpty() && (fn.left(5) == "wp://")) {
|
||||
menu_item_name = fi.fileName().isEmpty() ? tr("Reload previous image") : fn.right(fn.length() - 5);
|
||||
imageHistoryUpdatePos->setIcon(getIconWithIndicator(menu_icon, pixmap_size, QIcon::Normal, WriteProtected));
|
||||
} else {
|
||||
menu_item_name = fi.fileName().isEmpty() ? tr("Reload previous image") : fn;
|
||||
imageHistoryUpdatePos->setIcon(menu_icon);
|
||||
}
|
||||
break;
|
||||
case ui::MediaType::Cartridge:
|
||||
if (!machine_has_cartridge(machine))
|
||||
@@ -659,8 +691,19 @@ MediaMenu::updateImageHistory(int index, int slot, ui::MediaType type)
|
||||
menu = floppyMenus[index];
|
||||
children = menu->children();
|
||||
imageHistoryUpdatePos = dynamic_cast<QAction *>(children[floppyImageHistoryPos[slot]]);
|
||||
fi.setFile(fn);
|
||||
menu_item_name = fi.fileName().isEmpty() ? tr("Reload previous image") : fn;
|
||||
menu_icon = fdd_is_525(index) ? QIcon(":/settings/qt/icons/floppy_525_image.ico") :
|
||||
QIcon(":/settings/qt/icons/floppy_35_image.ico");
|
||||
if (fn.left(5) == "wp://")
|
||||
fi.setFile(fn.right(fn.length() - 5));
|
||||
else
|
||||
fi.setFile(fn);
|
||||
if (!fi.fileName().isEmpty() && (fn.left(5) == "wp://")) {
|
||||
menu_item_name = fi.fileName().isEmpty() ? tr("Reload previous image") : fn.right(fn.length() - 5);
|
||||
imageHistoryUpdatePos->setIcon(getIconWithIndicator(menu_icon, pixmap_size, QIcon::Normal, WriteProtected));
|
||||
} else {
|
||||
menu_item_name = fi.fileName().isEmpty() ? tr("Reload previous image") : fn;
|
||||
imageHistoryUpdatePos->setIcon(menu_icon);
|
||||
}
|
||||
break;
|
||||
case ui::MediaType::Optical:
|
||||
if (!cdromMenus.contains(index))
|
||||
@@ -688,8 +731,18 @@ MediaMenu::updateImageHistory(int index, int slot, ui::MediaType type)
|
||||
menu = zipMenus[index];
|
||||
children = menu->children();
|
||||
imageHistoryUpdatePos = dynamic_cast<QAction *>(children[zipImageHistoryPos[slot]]);
|
||||
fi.setFile(fn);
|
||||
menu_item_name = fi.fileName().isEmpty() ? tr("Reload previous image") : fn;
|
||||
menu_icon = QIcon(":/settings/qt/icons/mo_image.ico");
|
||||
if (fn.left(5) == "wp://")
|
||||
fi.setFile(fn.right(fn.length() - 5));
|
||||
else
|
||||
fi.setFile(fn);
|
||||
if (!fi.fileName().isEmpty() && (fn.left(5) == "wp://")) {
|
||||
menu_item_name = fi.fileName().isEmpty() ? tr("Reload previous image") : fn.right(fn.length() - 5);
|
||||
imageHistoryUpdatePos->setIcon(getIconWithIndicator(menu_icon, pixmap_size, QIcon::Normal, WriteProtected));
|
||||
} else {
|
||||
menu_item_name = fi.fileName().isEmpty() ? tr("Reload previous image") : fn;
|
||||
imageHistoryUpdatePos->setIcon(menu_icon);
|
||||
}
|
||||
break;
|
||||
case ui::MediaType::Mo:
|
||||
if (!moMenus.contains(index))
|
||||
@@ -697,8 +750,18 @@ MediaMenu::updateImageHistory(int index, int slot, ui::MediaType type)
|
||||
menu = moMenus[index];
|
||||
children = menu->children();
|
||||
imageHistoryUpdatePos = dynamic_cast<QAction *>(children[moImageHistoryPos[slot]]);
|
||||
fi.setFile(fn);
|
||||
menu_item_name = fi.fileName().isEmpty() ? tr("Reload previous image") : fn;
|
||||
menu_icon = QIcon(":/settings/qt/icons/mo_image.ico");
|
||||
if (fn.left(5) == "wp://")
|
||||
fi.setFile(fn.right(fn.length() - 5));
|
||||
else
|
||||
fi.setFile(fn);
|
||||
if (!fi.fileName().isEmpty() && (fn.left(5) == "wp://")) {
|
||||
menu_item_name = fi.fileName().isEmpty() ? tr("Reload previous image") : fn.right(fn.length() - 5);
|
||||
imageHistoryUpdatePos->setIcon(getIconWithIndicator(menu_icon, pixmap_size, QIcon::Normal, WriteProtected));
|
||||
} else {
|
||||
menu_item_name = fi.fileName().isEmpty() ? tr("Reload previous image") : fn;
|
||||
imageHistoryUpdatePos->setIcon(menu_icon);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -749,9 +812,12 @@ MediaMenu::cdromUpdateMenu(int i)
|
||||
|
||||
menu_item_name = name.isEmpty() ? QString() : fi.fileName();
|
||||
name2 = name;
|
||||
menu_icon = fi.isDir() ? QIcon(":/settings/qt/icons/cdrom_folder.ico") : QIcon(":/settings/qt/icons/cdrom_image.ico");
|
||||
if (name.isEmpty())
|
||||
menu_icon = QIcon(":/settings/qt/icons/cdrom.ico");
|
||||
else
|
||||
menu_icon = fi.isDir() ? QIcon(":/settings/qt/icons/cdrom_folder.ico") : QIcon(":/settings/qt/icons/cdrom_image.ico");
|
||||
}
|
||||
ejectMenu->setIcon(menu_icon);
|
||||
ejectMenu->setIcon(getIconWithIndicator(menu_icon, pixmap_size, QIcon::Normal, Eject));
|
||||
ejectMenu->setText(name.isEmpty() ? tr("E&ject") : tr("E&ject %1").arg(menu_item_name));
|
||||
|
||||
for (int slot = 0; slot < MAX_PREV_IMAGES; slot++)
|
||||
@@ -812,6 +878,12 @@ MediaMenu::zipMount(int i, const QString &filename, bool wp)
|
||||
zip_drives[i].read_only = wp;
|
||||
if (!filename.isEmpty()) {
|
||||
QByteArray filenameBytes = filename.toUtf8();
|
||||
|
||||
if (filename.left(5) == "wp://")
|
||||
zip_drives[i].read_only = 1;
|
||||
else if (zip_drives[i].read_only)
|
||||
filenameBytes = QString::asprintf(R"(wp://%s)", filename.toUtf8().data()).toUtf8();
|
||||
|
||||
zip_load(dev, filenameBytes.data(), 1);
|
||||
|
||||
/* Signal media change to the emulated machine. */
|
||||
@@ -951,6 +1023,12 @@ MediaMenu::moMount(int i, const QString &filename, bool wp)
|
||||
mo_drives[i].read_only = wp;
|
||||
if (!filename.isEmpty()) {
|
||||
QByteArray filenameBytes = filename.toUtf8();
|
||||
|
||||
if (filename.left(5) == "wp://")
|
||||
mo_drives[i].read_only = 1;
|
||||
else if (mo_drives[i].read_only)
|
||||
filenameBytes = QString::asprintf(R"(wp://%s)", filename.toUtf8().data()).toUtf8();
|
||||
|
||||
mo_load(dev, filenameBytes.data(), 1);
|
||||
|
||||
/* Signal media change to the emulated machine. */
|
||||
|
||||