OpenCores
URL https://opencores.org/ocsvn/riscv_vhdl/riscv_vhdl/trunk

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [debugger/] [src/] [gui_plugin/] [qt_wrapper.cpp] - Blame information for rev 3

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 sergeykhbr
/**
2
 * @file
3
 * @copyright  Copyright 2017 GNSS Sensor Ltd. All right reserved.
4
 * @author     Sergey Khabarov - sergeykhbr@gmail.com
5
 * @brief      QT Wrapper connects QT libs to debugger core library.
6
 */
7
 
8
#include "api_core.h"
9
#include "qt_wrapper.h"
10
#include "moc_qt_wrapper.h"
11
#include <string>
12
#include <QtWidgets/QApplication>
13
 
14
#define QT_EXEC_IMPL
15
 
16
namespace debugger {
17
 
18
static event_def eventAppDestroyed_;
19
 
20
/** It's a blocking event that runs only once */
21
void ui_events_update(void *args) {
22
    QtWrapper *ui = reinterpret_cast<QtWrapper *>(args);
23
    ui->eventsUpdate();
24
    RISCV_event_set(&eventAppDestroyed_);
25
}
26
 
27
QtWrapper::QtWrapper(IGui *igui)
28
    : QObject() {
29
    igui_ = igui;
30
    exiting_ = false;
31
    RISCV_event_create(&eventAppDestroyed_, "eventAppDestroyed_");
32
}
33
 
34
QtWrapper::~QtWrapper() {
35
}
36
 
37
void QtWrapper::postInit(AttributeType *gui_cfg) {
38
    RISCV_register_timer(1, 1, ui_events_update, this);
39
}
40
 
41
void QtWrapper::eventsUpdate() {
42
    int argc = 0;
43
    char *argv[] = {0};
44
 
45
    QApplication app(argc, argv);
46
    app.setQuitOnLastWindowClosed(true);
47
 
48
    mainWindow_ = new DbgMainWindow(igui_);
49
    connect(mainWindow_, SIGNAL(signalAboutToClose()),
50
            this, SLOT(slotMainWindowAboutToClose()));
51
 
52
    mainWindow_->show();
53
    app.exec();
54
    delete mainWindow_;
55
    app.quit();
56
}
57
 
58
void QtWrapper::gracefulClose() {
59
    if (!exiting_) {
60
        /** Exit through console command 'exit' */
61
        mainWindow_->close();
62
        RISCV_event_wait_ms(&eventAppDestroyed_, 10000);
63
    }
64
    RISCV_event_close(&eventAppDestroyed_);
65
}
66
 
67
void QtWrapper::slotMainWindowAboutToClose() {
68
    if (exiting_) {
69
        return;
70
    }
71
    /** Exit from GUI button push */
72
    exiting_ = true;
73
    RISCV_break_simulation();
74
}
75
 
76
}  // namespace debugger

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.