qt: Add DnD support for cassette/cartridge media types
This commit is contained in:
@@ -361,7 +361,11 @@ void MachineStatus::refresh(QStatusBar* sbar) {
|
|||||||
connect((ClickableLabel*)d->cassette.label.get(), &ClickableLabel::clicked, [](QPoint pos) {
|
connect((ClickableLabel*)d->cassette.label.get(), &ClickableLabel::clicked, [](QPoint pos) {
|
||||||
MediaMenu::ptr->cassetteMenu->popup(pos - QPoint(0, MediaMenu::ptr->cassetteMenu->sizeHint().height()));
|
MediaMenu::ptr->cassetteMenu->popup(pos - QPoint(0, MediaMenu::ptr->cassetteMenu->sizeHint().height()));
|
||||||
});
|
});
|
||||||
|
connect((ClickableLabel*)d->cassette.label.get(), &ClickableLabel::dropped, [](QString str) {
|
||||||
|
MediaMenu::ptr->cassetteMount(str, false);
|
||||||
|
});
|
||||||
d->cassette.label->setToolTip(MediaMenu::ptr->cassetteMenu->title());
|
d->cassette.label->setToolTip(MediaMenu::ptr->cassetteMenu->title());
|
||||||
|
d->cassette.label->setAcceptDrops(true);
|
||||||
sbar->addWidget(d->cassette.label.get());
|
sbar->addWidget(d->cassette.label.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,7 +376,11 @@ void MachineStatus::refresh(QStatusBar* sbar) {
|
|||||||
connect((ClickableLabel*)d->cartridge[i].label.get(), &ClickableLabel::clicked, [i](QPoint pos) {
|
connect((ClickableLabel*)d->cartridge[i].label.get(), &ClickableLabel::clicked, [i](QPoint pos) {
|
||||||
MediaMenu::ptr->cartridgeMenus[i]->popup(pos - QPoint(0, MediaMenu::ptr->cartridgeMenus[i]->sizeHint().height()));
|
MediaMenu::ptr->cartridgeMenus[i]->popup(pos - QPoint(0, MediaMenu::ptr->cartridgeMenus[i]->sizeHint().height()));
|
||||||
});
|
});
|
||||||
|
connect((ClickableLabel*)d->cartridge[i].label.get(), &ClickableLabel::dropped, [i](QString str) {
|
||||||
|
MediaMenu::ptr->cartridgeMount(i, str);
|
||||||
|
});
|
||||||
d->cartridge[i].label->setToolTip(MediaMenu::ptr->cartridgeMenus[i]->title());
|
d->cartridge[i].label->setToolTip(MediaMenu::ptr->cartridgeMenus[i]->title());
|
||||||
|
d->cartridge[i].label->setAcceptDrops(true);
|
||||||
sbar->addWidget(d->cartridge[i].label.get());
|
sbar->addWidget(d->cartridge[i].label.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -230,6 +230,18 @@ void MediaMenu::cassetteUpdateMenu() {
|
|||||||
cassetteMenu->setTitle(QString::asprintf(tr("Cassette: %s").toUtf8().constData(), (name.isEmpty() ? tr("(empty)") : name).toUtf8().constData()));
|
cassetteMenu->setTitle(QString::asprintf(tr("Cassette: %s").toUtf8().constData(), (name.isEmpty() ? tr("(empty)") : name).toUtf8().constData()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MediaMenu::cartridgeMount(int i, const QString &filename)
|
||||||
|
{
|
||||||
|
cart_close(i);
|
||||||
|
QByteArray filenameBytes = filename.toUtf8();
|
||||||
|
cart_load(i, filenameBytes.data());
|
||||||
|
|
||||||
|
ui_sb_update_icon_state(SB_CARTRIDGE | i, filename.isEmpty() ? 1 : 0);
|
||||||
|
cartridgeUpdateMenu(i);
|
||||||
|
ui_sb_update_tip(SB_CARTRIDGE | i);
|
||||||
|
config_save();
|
||||||
|
}
|
||||||
|
|
||||||
void MediaMenu::cartridgeSelectImage(int i) {
|
void MediaMenu::cartridgeSelectImage(int i) {
|
||||||
auto filename = QFileDialog::getOpenFileName(
|
auto filename = QFileDialog::getOpenFileName(
|
||||||
parentWidget,
|
parentWidget,
|
||||||
@@ -243,14 +255,7 @@ void MediaMenu::cartridgeSelectImage(int i) {
|
|||||||
if (filename.isEmpty()) {
|
if (filename.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cart_close(i);
|
cartridgeMount(i, filename);
|
||||||
QByteArray filenameBytes = filename.toUtf8();
|
|
||||||
cart_load(i, filenameBytes.data());
|
|
||||||
|
|
||||||
ui_sb_update_icon_state(SB_CARTRIDGE | i, filename.isEmpty() ? 1 : 0);
|
|
||||||
cartridgeUpdateMenu(i);
|
|
||||||
ui_sb_update_tip(SB_CARTRIDGE | i);
|
|
||||||
config_save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaMenu::cartridgeEject(int i) {
|
void MediaMenu::cartridgeEject(int i) {
|
||||||
|
@@ -25,6 +25,7 @@ public:
|
|||||||
void cassetteUpdateMenu();
|
void cassetteUpdateMenu();
|
||||||
|
|
||||||
void cartridgeSelectImage(int i);
|
void cartridgeSelectImage(int i);
|
||||||
|
void cartridgeMount(int i, const QString& filename);
|
||||||
void cartridgeEject(int i);
|
void cartridgeEject(int i);
|
||||||
void cartridgeUpdateMenu(int i);
|
void cartridgeUpdateMenu(int i);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user