// Serial settings and window/dock settings handled here
// Other user configurable values are set in settingsDialog
void MainWindow::restoreSettings()
{
    serialConfigured = appSettings->value("Serial/configured", false).toBool();
    serialSettings tmp;
    bool ok;
    tmp.name = appSettings->value("Serial/portName", QString("COM1")).toString();
    tmp.rate = appSettings->value("Serial/rate", SerialPort::Rate115200).toInt(&ok);
    tmp.dataBits = static_cast<SerialPort::DataBits>(appSettings->value("Serial/dataBits", SerialPort::Data8).toInt(&ok));
    tmp.parity = static_cast<SerialPort::Parity>(appSettings->value("Serial/parity", SerialPort::NoParity).toInt(&ok));
    tmp.stopBits = static_cast<SerialPort::StopBits>(appSettings->value("Serial/stopBits", SerialPort::OneStop).toInt(&ok));
    tmp.flowControl = static_cast<SerialPort::FlowControl>(appSettings->value("Serial/flowControl", SerialPort::NoFlowControl).toInt(&ok));
    serSettings->setSettings(tmp);

    logLevel = appSettings->value("Log/logLevel", stdLog | serialConfigLog).toInt();

    settingsDialog->load();
    updateSettings();

    restoreGeometry(appSettings->value("MainWindow/geometry").toByteArray());
    restoreState(appSettings->value("MainWindow/state").toByteArray());

    showLogDock = appSettings->value("DockVisibility/log", true).toBool();
    showModuleDock = appSettings->value("DockVisibility/module", true).toBool();
    showInfoDock = appSettings->value("DockVisibility/info", true).toBool();
    showPlotDock = appSettings->value("DockVisibility/plot", true).toBool();
    restoreDocks();
}
Beispiel #2
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    core(new QRCore()),
    ui(new Ui::MainWindow),
    webserverThread(core, this)
{
    ui->setupUi(this);

    doLock = false;

    // Add custom font
    QFontDatabase::addApplicationFont(":/new/prefix1/fonts/Anonymous Pro.ttf");

    /*
    * Toolbar
    */
    // Hide central tab widget tabs
    QTabBar *centralbar = ui->centralTabWidget->tabBar();
    centralbar->setVisible(false);
    // Adjust console lineedit
    ui->consoleInputLineEdit->setTextMargins(10, 0, 0, 0);
    /*
    ui->consoleOutputTextEdit->setFont(QFont("Monospace", 8));
    ui->consoleOutputTextEdit->setStyleSheet("background-color:black;color:gray;");
    ui->consoleInputLineEdit->setStyleSheet("background-color:black;color:gray;");
    */

    // Adjust text margins of consoleOutputTextEdit
    QTextDocument *console_docu = ui->consoleOutputTextEdit->document();
    console_docu->setDocumentMargin(10);

    // Sepparator between back/forward and undo/redo buttons
    QWidget* spacer4 = new QWidget();
    spacer4->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
    spacer4->setMinimumSize(10, 10);
    ui->mainToolBar->insertWidget(ui->actionForward, spacer4);

    // Popup menu on theme toolbar button
    QToolButton *backButton = new QToolButton(this);
    backButton->setIcon(QIcon(":/new/prefix1/img/icons/arrow_left.png"));
    //backButton->setPopupMode(QToolButton::DelayedPopup);
    ui->mainToolBar->insertWidget(ui->actionForward, backButton);
    connect(backButton, SIGNAL(clicked()), this, SLOT(on_backButton_clicked()));

    // Sepparator between undo/redo and goto lineEdit
    QWidget* spacer3 = new QWidget();
    spacer3->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    spacer3->setMinimumSize(20, 20);
    spacer3->setMaximumWidth(300);
    ui->mainToolBar->insertWidget(ui->actionShow_Hide_mainsidebar, spacer3);

    // Omnibar LineEdit
    this->omnibar = new Omnibar(this);
    ui->mainToolBar->insertWidget(ui->actionShow_Hide_mainsidebar, this->omnibar);

    // Add special sepparators to the toolbar that expand to separate groups of elements
    QWidget* spacer2 = new QWidget();
    spacer2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    spacer2->setMinimumSize(10, 10);
    spacer2->setMaximumWidth(300);
    ui->mainToolBar->insertWidget(ui->actionShow_Hide_mainsidebar, spacer2);

    // Sepparator between back/forward and undo/redo buttons
    QWidget* spacer = new QWidget();
    spacer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
    spacer->setMinimumSize(20, 20);
    ui->mainToolBar->addWidget(spacer);

    // codeGraphics tool bar
    this->graphicsBar = new GraphicsBar(this);
    this->graphicsBar->setMovable(false);
    addToolBarBreak(Qt::TopToolBarArea);
    addToolBar(graphicsBar);

    // Fix output panel font
    QHelpers *help = new QHelpers();
    help->normalizeFont(ui->consoleOutputTextEdit);

    /*
     * Dock Widgets
     */

    // Add Memory DockWidget
    this->memoryDock = new MemoryWidget(this);
    this->dockList << this->memoryDock;
    // To use in the future when we handle more than one memory views
    // this->memoryDock->setAttribute(Qt::WA_DeleteOnClose);
    // this->add_debug_output( QString::number(this->dockList.length()) );

    // Add Sections dock panel
    this->sectionsWidget = new SectionsWidget(this);
    this->sectionsDock = new QDockWidget("Sections");
    this->sectionsDock->setObjectName("sectionsDock");
    this->sectionsDock->setAllowedAreas(Qt::AllDockWidgetAreas);
    this->sectionsDock->setWidget(this->sectionsWidget);
    this->sectionsWidget->setContentsMargins(0,0,0,5);
    this->sectionsDock->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
    this->sectionsDock->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(this->sectionsDock, SIGNAL(customContextMenuRequested(const QPoint &)),
            this, SLOT(showSectionsContextMenu(const QPoint &)));

    // Add functions DockWidget
    this->functionsDock = new FunctionsWidget(this);

    // Add imports DockWidget
    this->importsDock = new ImportsWidget(this);

    // Add symbols DockWidget
    this->symbolsDock = new SymbolsWidget(this);

    // Add relocs DockWidget
    this->relocsDock = new RelocsWidget(this);

    // Add comments DockWidget
    this->commentsDock = new CommentsWidget(this);

    // Add strings DockWidget
    this->stringsDock = new StringsWidget(this);

    // Add flags DockWidget
    this->flagsDock = new FlagsWidget(this);

    // Add Notepad Dock panel
    this->notepadDock = new Notepad(this);

    //Add Dashboard Dock panel
    this->dashboardDock = new Dashboard(this);

    // Set up dock widgets default layout
    restoreDocks();
    hideAllDocks();
    showDefaultDocks();

    // Restore saved settings
    this->readSettings();
    // TODO: Allow the user to select this option visually in the GUI settings
    // Adjust the DockWidget areas
    setCorner( Qt::TopLeftCorner, Qt::LeftDockWidgetArea );
    //setCorner( Qt::TopRightCorner, Qt::RightDockWidgetArea );
    setCorner( Qt::BottomLeftCorner, Qt::LeftDockWidgetArea );
    //setCorner( Qt::BottomRightCorner, Qt::RightDockWidgetArea );

    this->flagsDock->flagsTreeWidget->clear();

    // Set omnibar completer for flags
    this->omnibar->setupCompleter();

    // Set console output context menu
    ui->consoleOutputTextEdit->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(ui->consoleOutputTextEdit, SIGNAL(customContextMenuRequested(const QPoint &)),
            this, SLOT(showConsoleContextMenu(const QPoint &)));

    // Hide dummy columns so we can reorder the rest
    hideDummyColumns();

    // Setup and hide sidebar by default
    this->sideBar = new SideBar(this);
    this->sidebar_action = ui->sideToolBar->addWidget(this->sideBar);
    ui->sideToolBar->hide();

    // Show dashboard by default
    this->dashboardDock->raise();

    //qDebug() << "FOLDER: " << QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
    /*
     *  Some global shortcuts
     */
    // Period goes to command entry
    QShortcut* cmd_shortcut = new QShortcut(QKeySequence(Qt::Key_Period), this);
    connect(cmd_shortcut, SIGNAL(activated()), ui->consoleInputLineEdit, SLOT(setFocus()));

    // G and S goes to goto entry
    QShortcut* goto_shortcut = new QShortcut(QKeySequence(Qt::Key_G), this);
    connect(goto_shortcut, SIGNAL(activated()), this->omnibar, SLOT(setFocus()));
    QShortcut* seek_shortcut = new QShortcut(QKeySequence(Qt::Key_S), this);
    connect(seek_shortcut, SIGNAL(activated()), this->omnibar, SLOT(setFocus()));

    // : goes to goto entry
    QShortcut* commands_shortcut = new QShortcut(QKeySequence(Qt::Key_Colon), this);
    connect(commands_shortcut, SIGNAL(activated()), this->omnibar, SLOT(showCommands()));

    connect(&webserverThread, SIGNAL(finished()), this, SLOT(webserverThreadFinished()));
}