|
8 | 8 | #include "capture/animated-png.h" |
9 | 9 | #include "keypad/qtkeypadbridge.h" |
10 | 10 | #include "tivars_lib_cpp/src/TIModels.h" |
| 11 | +#include "tivars_lib_cpp/src/TIVarFile.h" |
11 | 12 | #include "tivars_lib_cpp/src/TIVarTypes.h" |
12 | 13 | #include "tivars_lib_cpp/src/TypeHandlers/TypeHandlers.h" |
13 | 14 | #include "../../core/emu.h" |
|
24 | 25 | #include <QtCore/QLocale> |
25 | 26 | #include <QtCore/QProcess> |
26 | 27 | #include <QtCore/QRegularExpression> |
| 28 | +#include <QtCore/QTemporaryFile> |
27 | 29 | #include <QtGui/QFont> |
28 | 30 | #include <QtGui/QWindow> |
29 | 31 | #include <QtGui/QDesktopServices> |
@@ -264,6 +266,7 @@ MainWindow::MainWindow(CEmuOpts &cliOpts, QWidget *p) : QMainWindow(p), ui(new U |
264 | 266 | connect(ui->buttonReceiveFile, &QPushButton::clicked, this, &MainWindow::varSaveSelected); |
265 | 267 | connect(ui->buttonReceiveFiles, &QPushButton::clicked, this, &MainWindow::varSaveSelectedFiles); |
266 | 268 | connect(ui->buttonResendFiles, &QPushButton::clicked, this, &MainWindow::varResend); |
| 269 | + connect(ui->buttonClipboardListToL1, &QPushButton::clicked, this, &MainWindow::varClipboardListToL1); |
267 | 270 |
|
268 | 271 | // autotester |
269 | 272 | connect(ui->buttonOpenJSONconfig, &QPushButton::clicked, this, &MainWindow::autotesterLoad); |
@@ -528,14 +531,17 @@ MainWindow::MainWindow(CEmuOpts &cliOpts, QWidget *p) : QMainWindow(p), ui(new U |
528 | 531 | m_shortcutFullscreen = new QShortcut(QKeySequence(Qt::Key_F11), this); |
529 | 532 | m_shortcutAsm = new QShortcut(QKeySequence(Qt::Key_Pause), this); |
530 | 533 | m_shortcutResend = new QShortcut(QKeySequence(Qt::CTRL | Qt::Key_X), this); |
| 534 | + m_shortcutClipboardListToL1 = new QShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_L), this); |
531 | 535 |
|
532 | 536 | m_shortcutFullscreen->setAutoRepeat(false); |
533 | 537 | m_shortcutDebug->setAutoRepeat(false); |
534 | 538 | m_shortcutAsm->setAutoRepeat(false); |
535 | 539 | m_shortcutResend->setAutoRepeat(false); |
| 540 | + m_shortcutClipboardListToL1->setAutoRepeat(false); |
536 | 541 |
|
537 | 542 | connect(m_shortcutFullscreen, &QShortcut::activated, [this]{ setFullscreen(m_fullscreen + 1); }); |
538 | 543 | connect(m_shortcutResend, &QShortcut::activated, this, &MainWindow::varResend); |
| 544 | + connect(m_shortcutClipboardListToL1, &QShortcut::activated, this, &MainWindow::varClipboardListToL1); |
539 | 545 | connect(m_shortcutAsm, &QShortcut::activated, [this]{ sendEmuKey(CE_KEY_ASM); }); |
540 | 546 | connect(m_shortcutDebug, &QShortcut::activated, this, &MainWindow::debugToggle); |
541 | 547 | connect(m_shortcutStepIn, &QShortcut::activated, this, &MainWindow::stepIn); |
@@ -2338,6 +2344,46 @@ void MainWindow::varResend() { |
2338 | 2344 | sendingHandler->resendSelected(); |
2339 | 2345 | } |
2340 | 2346 |
|
| 2347 | +void MainWindow::varClipboardListToL1() { |
| 2348 | + const QString cbStr = qApp->clipboard()->text().replace(" ", "").trimmed(); |
| 2349 | + if (cbStr.isEmpty()) { |
| 2350 | + QMessageBox::warning(this, MSG_WARNING, tr("Empty clipboard")); |
| 2351 | + return; |
| 2352 | + } |
| 2353 | + |
| 2354 | + QTemporaryFile tempFile{"CEmu_temp_list_XXXXXX.8xl"}; |
| 2355 | + if (!tempFile.open()) { |
| 2356 | + QMessageBox::warning(this, MSG_ERROR, tr("Could not create temporary file")); |
| 2357 | + return; |
| 2358 | + } |
| 2359 | + |
| 2360 | + ui->buttonClipboardListToL1->setEnabled(false); |
| 2361 | + |
| 2362 | + const QString tempFilePath = tempFile.fileName(); |
| 2363 | + bool ok = false; |
| 2364 | + |
| 2365 | + try |
| 2366 | + { |
| 2367 | + tivars::TIVarFile testRealList = tivars::TIVarFile::createNew("RealList", "\x5D\x00"); // L₁ |
| 2368 | + testRealList.setContentFromString(cbStr.toStdString()); |
| 2369 | + testRealList.saveVarToFile(tempFilePath.toStdString()); |
| 2370 | + ok = true; |
| 2371 | + } catch (const std::exception &e) |
| 2372 | + { |
| 2373 | + QMessageBox::warning(this, MSG_ERROR, tr("Could not convert the clipboard's list: ") + e.what()); |
| 2374 | + } |
| 2375 | + |
| 2376 | + if (ok) |
| 2377 | + { |
| 2378 | + sendingHandler->sendFiles({ tempFilePath }, LINK_RAM); |
| 2379 | + while (guiSend) { |
| 2380 | + guiDelay(10); |
| 2381 | + } |
| 2382 | + } |
| 2383 | + |
| 2384 | + ui->buttonClipboardListToL1->setEnabled(true); |
| 2385 | +} |
| 2386 | + |
2341 | 2387 | // ------------------------------------------------ |
2342 | 2388 | // Autotester things |
2343 | 2389 | // ------------------------------------------------ |
|
0 commit comments