bool FlashTool::winEvent(MSG *message, long *)
{
    //qDebug() << message;
    if(message->message == WM_DEVICECHANGE)
        updatePorts();
    return false;
}
void BubbleHardwareManager::popUpPortList()
{
    if (IsShownOnScreen())
    {
        updatePorts();
        if (comboBootPortName)
            comboBootPortName->popUpList();
    }
}
Exemple #3
0
SRFlipFlop::SRFlipFlop( QGraphicsItem *parent ) : GraphicElement( 3, 3, 2, 2, parent ) {
  setPixmap( QPixmap( ":/memory/SR-flipflop.png" ) );
  setRotatable( false );
  updatePorts( );
  lastClk = false;
  setPortName( "FlipFlop SR" );

  inputs( ).at( 0 )->setName( "S" );
  inputs( ).at( 1 )->setName( "Clock" );
  inputs( ).at( 2 )->setName( "R" );
  output( 0 )->setName( "Q" );
  output( 1 )->setName( "~Q" );
  inputs( ).at( 0 )->setRequired( false );
  inputs( ).at( 2 )->setRequired( false );
}
Exemple #4
0
TFlipFlop::TFlipFlop( QGraphicsItem *parent ) : GraphicElement( 4, 4, 2, 2, parent ) {
  setPixmap( QPixmap( ":/memory/T-flipflop.png" ) );
  setRotatable( false );
  updatePorts( );
  lastClk = 0;
  setPortName( "FlipFlop T" );

  inputs( ).at( 0 )->setName( "T" );
  inputs( ).at( 1 )->setName( "Clock" );
  inputs( ).at( 2 )->setName( "~Preset" );
  inputs( ).at( 3 )->setName( "~Clear" );
  output( 0 )->setName( "Q" );
  output( 1 )->setName( "~Q" );
  inputs( ).at( 0 )->setRequired( false );
  inputs( ).at( 2 )->setRequired( false );
  inputs( ).at( 3 )->setRequired( false );
  inputs( ).at( 2 )->setDefaultValue( 1 );
  inputs( ).at( 3 )->setDefaultValue( 1 );
}
FlashTool::FlashTool(QWidget *parent)
 : QWidget(parent)
 , ui(new Ui::FlashTool)
{
    ui->setupUi(this);

    updatePorts();

    // Listen to device events
    DEV_BROADCAST_DEVICEINTERFACE devInt;
    ZeroMemory(&devInt, sizeof(devInt));
    devInt.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE);
    devInt.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
    devInt.dbcc_classguid = GUID_DEVINTERFACE_COMPORT;

    HANDLE blub;
    blub = RegisterDeviceNotification(winId(), &devInt, DEVICE_NOTIFY_WINDOW_HANDLE);


    connect(ui->bootFlashButton, SIGNAL(clicked()), SLOT(flashBootloader()));
    connect(ui->flashButton, SIGNAL(clicked()), SLOT(flashFirmware()));
}
void BubbleHardwareManager::onComboBoardNameChanged(wxCommandEvent &event)
{

    if (comboBoardName)
    {
        if (bubble && parent)
        {
            bool currentComponentSaved = bubble->isSaved();
            wxString currentComponentName = bubble->getComponentFilesPath() + wxString(".mbqc"); //##Unhardcode
            if (getCurrentBoardProperties())
            {
                //Find new seleted board's properties:
                BubbleBoardProperties *iterator = NULL;
                for (unsigned int i = 0; i < boardsProperties.GetCount(); i++)
                {
                    iterator = &(boardsProperties.Item(i)); //##In theory, this is faster than the other index based form, but I'm not sure yet...
                    if (iterator)
                    {
                        if (iterator->getName() == event.GetString())
                        {
                            currentBoardProperties->set(iterator);
                        }
                    }
                }

                bubble->setBoardName(event.GetString(), parent);
                changeImage();
                //##Debug:
                //wxMessageDialog dialog0(bubble->getParent(), getCurrentBoardProperties()->getPortType(),
                //                                             getCurrentBoardProperties()->getName()); //##Debug.
                //dialog0.ShowModal(); //##Debug.

                if ( ((getCurrentBoardProperties())->getPortType() == wxString("HID")) || //##Unhardcode
                     ((getCurrentBoardProperties())->getPortType() == wxString("HID2"))
                   )
                {
                    setPortSelectorEnabled(false);
                    setPortNameString((getCurrentBoardProperties())->getPortType());
                }
                else
                {
                    if (comboBootPortName)
                    {
                        wxString selectedPort = comboBootPortName->getText();
                        setPortSelectorEnabled(true);
                        updatePorts();
                        if ( (comboBootPortName->getText() == wxString("HID")) || //##Unhardcode
                             (comboBootPortName->getText() == wxString("HID2"))
                           )
                        {
                            setPortNameString(wxString(""));
                        }
                        else
                        {
                            if (comboBootPortName->textExists(selectedPort))
                                comboBootPortName->setSelection(selectedPort);
                            else
                                setPortNameString(wxString(""));
                        }
                    }
                }

                //Updates the generated code (for example, with the include files):
                bubble->loadBoardRelations();

                if (getCurrentBoardProperties())
                {
                    if (buttonGoToDriversDir)
                    {
                        //Are there device drivers for this board?
                        buttonGoToDriversDir->Enable(getCurrentBoardProperties()->getDriverPath() != wxString(""));

                        //Are there links for this board?
                        if (lblURL0)
                        {
                            lblURL0->SetURL(getCurrentBoardProperties()->getUrl0());
                            lblURL0->SetLabel(getCurrentBoardProperties()->getUrl0());
                            lblURL0->SetPosition(wxPoint(buttonGoToDriversDir->GetPosition().x, lblURL0->GetPosition().y));
                        }
                        if (lblURL1)
                        {
                            lblURL1->SetURL(getCurrentBoardProperties()->getUrl1());
                            lblURL1->SetLabel(getCurrentBoardProperties()->getUrl1());
                            lblURL1->SetPosition(wxPoint(buttonGoToDriversDir->GetPosition().x, lblURL1->GetPosition().y));
                        }
                    }
                }
            }
            ((MainFrame*)parent)->createComponent(true);
            if (currentComponentSaved)
                ((MainFrame*)parent)->loadFileComponent(currentComponentName);
            if ( ((MainFrame*)parent)->isShowingGeneratedCode() )
            {
                ((MainFrame*)parent)->toggleGeneratedCode();
                ((MainFrame*)parent)->toggleGeneratedCode();
            }
        }
    }
}
void BubbleHardwareManager::onUpdatePorts(wxCommandEvent &event)
{
    updatePorts();
    event.Skip();
}
BubbleHardwareManager::BubbleHardwareManager(   wxWindow* parent,
                                                wxWindowID id,
                                                Bubble *const bubble,
                                                const wxString& boardName,
                                                const wxColour& colour,
                                                const wxPoint& pos,
                                                const wxSize& size,
                                                long style,
                                                const wxString& name) : BubblePanel(parent,
                                                                                    id,
                                                                                    colour,
                                                                                    true,
                                                                                    pos,
                                                                                    size,
                                                                                    style,
                                                                                    name
                                                                                   ),
                                                                        parent(parent),
                                                                        bubble(bubble),
                                                                        boardName(boardName),
                                                                        currentBoardProperties(NULL),
                                                                        lblBootPortName(NULL),
                                                                        comboBootPortName(NULL),
                                                                        lblBoardName(NULL),
                                                                        comboBoardName(NULL),
                                                                        buttonReloadBlocks(NULL),
                                                                        buttonReloadHardware(NULL),
                                                                        lblURL0(NULL),
                                                                        lblURL1(NULL),
                                                                        buttonGoToDriversDir(NULL),
                                                                        buttonMainImage(NULL),
                                                                        emptyDummyString(wxString(""))
{
    if (bubble == NULL)
        return; //Nothing to do.

    currentBoardProperties = new BubbleBoardProperties();

    //Hide();

    //##The following line crashes the application when the BubbleHardwareManager is closed by the user, so
    //##don't delete it, because it may be possibly a wxAUI's bug, and I would like to document it:
    //SetSize(400, 450);

    lblBoardName = new wxStaticText(   this,
                                        wxNewId(), //##
                                        //##Future: Make configurable by the user if he want to see these
                                        //shorcuts on screen or not:
                                        _("Hardware (Alt+W):"), //##Load shorcuts from XML.
                                        wxPoint(10, 10),
                                        wxSize(150, 20),
                                        wxALIGN_CENTRE,
                                        wxString("lblBoardName")
                                   );

    comboBoardName = new BubbleCombo(   this,
                                        wxNewId(),
                                        wxImage(bubble->getThemePath() + wxString("/ComboSelectDefault.png")),
                                        wxImage(bubble->getThemePath() + wxString("/ComboSelectPressed.png")),
                                        wxImage(bubble->getThemePath() + wxString("/ComboSelectHover.png")),
                                        wxImage(bubble->getThemePath() + wxString("/ComboSelectDisabled.png")),
                                        false,
                                        wxPoint(10, 25), //##Make this automatic.
                                        wxSize(190, 16),
                                        //wxTAB_TRAVERSAL|
                                        //wxNO_BORDER|
                                        //wxBORDER_SIMPLE|
                                        //wxBORDER_RAISED|
                                        wxBORDER_SUNKEN|
                                        wxTRANSPARENT_WINDOW,
                                        //wxDefaultSize,
                                        //##wxALIGN_CENTRE,
                                        wxString("comboBoardName")
                                    );
    if (comboBoardName)
    {
        comboBoardName->setSorted(false);
        bubble->loadHardwareTargets(this);

        boardName = "DuinoBot.v2.3 HID";
        if (boardName == wxString(""))
        {
            selectFirstBoard();
        }
        else
        {
            BubbleBoardProperties *initialBoard = NULL;
            initialBoard = &(boardsProperties.Item(0));

            //Find board:
            bool found = false;
            BubbleBoardProperties *iterator = NULL;
            for (unsigned int i = 0; i < boardsProperties.GetCount(); i++)
            {
                iterator = &(boardsProperties.Item(i)); //##In theory, this is faster than the other index based form, but I'm not sure yet...
                if (iterator)
                {
                    if (iterator->getName() == boardName)
                    {
                        initialBoard = iterator;
                        currentBoardProperties->set(iterator);
                        comboBoardName->setSelection(boardName);
                        found = true;
                    }
                }
            }
            if (!found)
            {
                selectFirstBoard();
            }
        }
        comboBoardName->Connect(wxEVT_COMMAND_TEXT_UPDATED,
                                wxCommandEventHandler(BubbleHardwareManager::onComboBoardNameChanged),
                                NULL,
                                this
                               );
    }

    lblBootPortName = new wxStaticText( this,
                                        wxNewId(),
                                        //In the future there may be IP sockets, and other comm
                                        //channels, so here it's just "Port", not "Serial port":

                                        //##Future: Make configurable by the user if he want to see these
                                        //shorcuts on screen or not:
                                        _("Port (Alt+R):"), //##Load shorcuts from XML.
                                        wxPoint(210, 10),   //##Un-hardcode!
                                        wxSize(150, 20),    //##Un-hardcode!
                                        wxALIGN_CENTRE,
                                        wxString("lblBootSerialPortName")
                                       );
    comboBootPortName = new BubbleCombo(this,
                                        wxNewId(),
                                        wxImage(bubble->getThemePath() + wxString("/ComboSelectDefault.png")),
                                        wxImage(bubble->getThemePath() + wxString("/ComboSelectPressed.png")),
                                        wxImage(bubble->getThemePath() + wxString("/ComboSelectHover.png")),
                                        wxImage(bubble->getThemePath() + wxString("/ComboSelectDisabled.png")),
                                        false,
                                        wxPoint(210, 25),   //##Un-hardcode!
                                        wxSize(100, 16),    //##Un-hardcode!
                                        wxBORDER_SUNKEN|
                                        wxTRANSPARENT_WINDOW,
                                        wxString("comboBootSerialPortName")
                                       );
    if (comboBootPortName)
    {
        comboBootPortName->Connect( wxEVT_COMMAND_TOOL_CLICKED,
                                    wxCommandEventHandler(BubbleHardwareManager::onUpdatePorts),
                                    NULL,
                                    this
                                  );
        comboBootPortName->Connect( wxEVT_COMMAND_TEXT_UPDATED,
                                    wxCommandEventHandler(BubbleHardwareManager::onComboBootPortNameChanged),
                                    NULL,
                                    this
                                  );
        updatePorts();
        setPortType();

        if (getCurrentBoardProperties())
        {
            //This is necessary for the first time the system loads the boards:
            if ( (getCurrentBoardProperties()->getPortType() == wxString("HID")) ||
                 (getCurrentBoardProperties()->getPortType() == wxString("HID2"))
               )
            {
                setPortSelectorEnabled(false);
                setPortNameString((getCurrentBoardProperties())->getPortType());
            }
        }
//        comboBootPortName->setSelection(0); //##Un-hardcode and get the port from the config file...
//        wxString strCommRealName = wxString("//./") + comboBootPortName->getText();
//        bubble->setBootPortName(strCommRealName);
    }

    buttonReloadBlocks = new wxButton(  this,
                                        wxNewId(),
                                        _("Reload blocks"),
                                        wxPoint(10, 55), //##Un-hardcode!
                                        //wxDefaultSize,
                                        wxSize(160, 25), //##Future: The autosize (with the label) feature does now work. Make it work!
                                        wxBU_EXACTFIT
                                     ); //##

    if (buttonReloadBlocks)
    {
        buttonReloadBlocks->Connect(wxEVT_LEFT_UP,
                                    wxMouseEventHandler(BubbleHardwareManager::onButtonReloadBlocksLeftUp),
                                    NULL,
                                    this
                                   );
        //buttonReloadBlocks->Hide(); //##Testing.
//        wxMessageDialog dialog0(bubble->getParent(), bubble->getProfile(), wxString("profile")); //##Debug.
//        dialog0.ShowModal(); //##Debug.
//        buttonReloadBlocks->Show(bubble->getProfile() == wxString("developer"));
    }

    buttonReloadHardware = new wxButton(  this,
                                        wxNewId(),
                                        _("Reload hardware"),
                                        wxPoint(175, 55), //##Un-hardcode!
                                        //wxDefaultSize,
                                        wxSize(160, 25), //##Future: The autosize (with the label) feature does now work. Make it work!
                                        wxBU_EXACTFIT
                                     ); //##

    if (buttonReloadHardware)
    {
        buttonReloadHardware->Connect(wxEVT_LEFT_UP,
                                    wxMouseEventHandler(BubbleHardwareManager::onButtonButtonReloadHardwareLeftUp),
                                    NULL,
                                    this
                                   );
        //buttonReloadHardware->Show(bubble->getProfile() == wxString("developer"));
    }

    buttonGoToDriversDir = new wxButton(  this,
                                        wxNewId(),
                                        _("Open folder with drivers"),
                                        wxPoint(10, 85), //##Un-hardcode!
                                        //wxDefaultSize,
                                        wxSize(160, 25), //##Future: autosize.
                                        wxBU_EXACTFIT
                                     );
    if (buttonGoToDriversDir)
    {
        buttonGoToDriversDir->Connect(  wxEVT_LEFT_UP,
                                        wxMouseEventHandler(BubbleHardwareManager::onButtonGoToDriversDirLeftUp),
                                        NULL,
                                        this
                                     );

        if (getCurrentBoardProperties())
        {
            buttonGoToDriversDir->Enable(getCurrentBoardProperties()->getDriverPath() != wxString(""));
            lblURL0 = new wxHyperlinkCtrl(  this,
                                            wxNewId(),
                                            getCurrentBoardProperties()->getUrl0(),
                                            getCurrentBoardProperties()->getUrl0(),
                                            wxPoint(buttonGoToDriversDir->GetPosition().x,
                                                    buttonGoToDriversDir->GetPosition().y +
                                                    buttonGoToDriversDir->GetSize().GetHeight() + 10),
                                            wxDefaultSize,
                                            wxHL_ALIGN_LEFT
                                         );
            if (lblURL0)
            {
                lblURL0->SetVisitedColour(lblURL0->GetNormalColour());
                //wxHyperlinkCtrl Bug: the first time, it should be created big.
                if (buttonReloadHardware)
                {
                    lblURL0->SetSize(wxSize(buttonReloadHardware->GetPosition().x +
                                            buttonReloadHardware->GetSize().GetWidth() -
                                            buttonGoToDriversDir->GetPosition().x,
                                            lblURL0->GetSize().GetHeight()
                                           )
                                    );
                }
                lblURL1 = new wxHyperlinkCtrl(  this,
                                                wxNewId(),
                                                getCurrentBoardProperties()->getUrl1(),
                                                getCurrentBoardProperties()->getUrl1(),
                                                wxPoint(lblURL0->GetPosition().x,
                                                        lblURL0->GetPosition().y +
                                                        lblURL0->GetSize().GetHeight() + 10),
                                                wxDefaultSize,
                                                wxHL_ALIGN_LEFT
                                             );
                if (lblURL1)
                {
                    lblURL1->SetVisitedColour(lblURL1->GetNormalColour());
                    if (lblURL0)
                        lblURL1->SetSize(lblURL0->GetSize());
                }
            }
        }
    }

    buttonMainImage = new BubbleButton( this,
                                        wxNewId(),
                                        wxPoint(0, 0),  //##Un-hardcode!
                                        wxSize(32, 32)  //##Un-hardcode!
                                      );
    //##buttonIcon->SetValidator(wxDefaultValidator);

    changeImage();

    //SetBackgroundColour(colour);
    SetBackgroundColourAndRefresh(colour);
}
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
    setWindowTitle(QCoreApplication::applicationName());
    ui.setupUi(this);

    // setup preferences dialog
    connect(&preferences,   SIGNAL(accepted()),                     this,   SLOT(getApplicationSettings()));

    connect(&builder,   SIGNAL(highlightLine(const QString &,
                                             int,
                                             int,
                                             const QString &)),

            this,       SLOT(highlightFileLine(const QString &,
                                               int,
                                               int)));

    connect(&builder,   SIGNAL(finished()),     this,           SLOT(setBuildAvailable()));
    connect(&builder,   SIGNAL(buildError()),   &preferences,   SLOT(showPreferences()));

    parser = language.parser();

    connect(&preferences, SIGNAL(updateColors()),               this,   SLOT(recolorProjectView()));
    connect(&preferences, SIGNAL(updateFonts(const QFont &)),   this,   SLOT(recolorProjectView()));

    connect(&preferences, SIGNAL(updateFonts(const QFont &)),   this,   SLOT(recolorBuildManager()));

    connect(&preferences, SIGNAL(accepted()),                   ui.editorTabs,   SIGNAL(accepted()));
    connect(&preferences, SIGNAL(updateColors()),               ui.editorTabs,   SIGNAL(updateColors()));
    connect(&preferences, SIGNAL(updateFonts(const QFont &)),   ui.editorTabs,   SIGNAL(updateFonts(const QFont &)));

    recolorProjectView();
    recolorBuildManager();

    // project editor tabs
    ui.finder->connectFileManager(ui.editorTabs);
    QSplitterHandle *hndl = ui.splitter->handle(1);
    hndl->setEnabled(false);

    connect(ui.editorTabs, SIGNAL(fileUpdated(int)),    this,   SLOT(setProject()));

    // File Menu
    connect(ui.action_New,              SIGNAL(triggered()),    ui.editorTabs,  SLOT(newFile()));
    connect(ui.actionNew_From_File,     SIGNAL(triggered()),    ui.editorTabs,  SLOT(newFromFile()));
    connect(ui.actionNew_From_Template, SIGNAL(triggered()),    this,           SLOT(newFromTemplate()));
    connect(ui.action_Open,             SIGNAL(triggered()),    ui.editorTabs,  SLOT(open()));

    connect(ui.action_Save,SIGNAL(triggered()),ui.editorTabs,SLOT(save()));
    connect(ui.actionSave_As,SIGNAL(triggered()),ui.editorTabs,SLOT(saveAs()));
    connect(ui.actionSave_All,SIGNAL(triggered()),ui.editorTabs,SLOT(saveAll()));

    ui.actionPrint->setEnabled(true);
    connect(ui.actionPrint,SIGNAL(triggered()),this,SLOT(printFile()));

    ui.action_Zip->setEnabled(true);
    connect(ui.action_Zip,SIGNAL(triggered()),this,SLOT(zipFiles()));

    recentFiles = findChildren<QAction *>(QRegExp("action_[0-9]+_File"));
    for (int i = 0; i < recentFiles.size(); i++)
        connect(recentFiles.at(i), SIGNAL(triggered()),this, SLOT(openRecentFile()));
    
    connect(ui.action_Close,       SIGNAL(triggered()),    ui.editorTabs, SLOT(closeFile()));
    connect(ui.actionClose_All,    SIGNAL(triggered()),    ui.editorTabs, SLOT(closeAll()));
    connect(ui.action_Quit,        SIGNAL(triggered()),    this,          SLOT(quitProgram()));

    connect(ui.editorTabs, SIGNAL(saveAvailable(bool)),    this,          SLOT(setSaveAvailable(bool)));
    connect(ui.editorTabs, SIGNAL(saveAvailable(bool)),    this,          SLOT(setSaveAvailable(bool)));
    connect(ui.editorTabs, SIGNAL(closeAvailable(bool)),   this,          SLOT(setCloseAvailable(bool)));
    connect(ui.editorTabs, SIGNAL(closeAvailable(bool)),   this,          SLOT(setCloseAvailable(bool)));
    connect(ui.editorTabs, SIGNAL(closeAvailable(bool)),   this,          SLOT(setBuildAvailable(bool)));

    // Edit Menu
    connect(ui.action_Undo,        SIGNAL(triggered()), ui.editorTabs, SLOT(undo()));
    connect(ui.action_Redo,        SIGNAL(triggered()), ui.editorTabs, SLOT(redo()));

    connect(ui.action_Cut,         SIGNAL(triggered()), ui.editorTabs, SLOT(cut()));
    connect(ui.action_Copy,        SIGNAL(triggered()), ui.editorTabs, SLOT(copy()));
    connect(ui.action_Paste,       SIGNAL(triggered()), ui.editorTabs, SLOT(paste()));
    connect(ui.actionSelect_All,   SIGNAL(triggered()), ui.editorTabs, SLOT(selectAll()));

    connect(ui.action_Find,        SIGNAL(triggered()), ui.finder, SLOT(showFinder()));
    connect(ui.actionFind_Next,    SIGNAL(triggered()), ui.finder, SLOT(findNext()));
    connect(ui.actionFind_Previous,SIGNAL(triggered()), ui.finder, SLOT(findPrevious()));

    connect(ui.actionPreferences,  SIGNAL(triggered()), &preferences, SLOT(showPreferences()));

    connect(ui.editorTabs, SIGNAL(undoAvailable(bool)), ui.action_Undo,SLOT(setEnabled(bool)));
    connect(ui.editorTabs, SIGNAL(redoAvailable(bool)), ui.action_Redo,SLOT(setEnabled(bool)));
    connect(ui.editorTabs, SIGNAL(copyAvailable(bool)), ui.action_Cut,SLOT(setEnabled(bool)));
    connect(ui.editorTabs, SIGNAL(copyAvailable(bool)), ui.action_Copy,SLOT(setEnabled(bool)));

    // View Menu
    connect(ui.actionShow_Browser, SIGNAL(triggered()), this, SLOT(showBrowser()));
    connect(ui.actionBigger_Font,  SIGNAL(triggered()), this, SLOT(fontBigger()));
    connect(ui.actionSmaller_Font, SIGNAL(triggered()), this, SLOT(fontSmaller()));

    ui.actionBigger_Font->setShortcuts(QList<QKeySequence>() << QKeySequence::ZoomIn
                                                             << Qt::CTRL+Qt::Key_Equal);

    // Project Menu
    connect(ui.actionMemory_Map,SIGNAL(triggered()), this, SLOT(spawnMemoryMap()));
    connect(ui.actionBuild,     SIGNAL(triggered()), this, SLOT(programBuild()));
    connect(ui.actionRun,       SIGNAL(triggered()), this, SLOT(programRun()));
    connect(ui.actionWrite,     SIGNAL(triggered()), this, SLOT(programWrite()));
    connect(ui.actionTerminal,  SIGNAL(triggered()), this, SLOT(spawnTerminal()));

    // Help Menu
    connect(ui.actionPropeller_Quick_Reference, SIGNAL(triggered()), this, SLOT(propellerQuickReference()));
    connect(ui.actionPropeller_Datasheet,       SIGNAL(triggered()), this, SLOT(propellerDatasheet()));
    connect(ui.actionPropeller_Manual,          SIGNAL(triggered()), this, SLOT(propellerManual()));
    connect(ui.actionPropBASIC_Manual,          SIGNAL(triggered()), this, SLOT(propBasicManual()));
    connect(ui.action_About,                    SIGNAL(triggered()), this, SLOT(about()));

    // Toolbar Extras
    cbPort = new QComboBox(this);
    cbPort->setLayoutDirection(Qt::LeftToRight);
    cbPort->setToolTip(tr("Select Serial Port"));
    cbPort->setSizeAdjustPolicy(QComboBox::AdjustToContents);
    ui.toolBar->addWidget(cbPort);

    connect(ui.projectview, SIGNAL(showFileLine(QString, int)),
            this,           SLOT(highlightFileLine(QString, int)));

    updateRecentFileActions();

    connect(ui.editorTabs, SIGNAL(sendMessage(const QString &)),   this,SLOT(showMessage(const QString &)));
    connect(ui.finder,     SIGNAL(sendMessage(const QString &)),   this,SLOT(showMessage(const QString &)));

    restoreGeometry(QSettings().value("windowSize").toByteArray());

    getApplicationSettings();

    connect(&manager, SIGNAL(portListChanged()), this, SLOT(updatePorts()));
    manager.enablePortMonitor(true);
    updatePorts();

    
    QSettings settings;
    QString lastport = settings.value("lastPort", QString()).toString();
    if (!lastport.isEmpty())
    {
        int index = cbPort->findText(lastport);
        if (index != -1)
            cbPort->setCurrentIndex(index);
    }

    ui.editorTabs->newFile();
    loadSession();

    installEventFilter(this);
    statusBar();
}
Exemple #10
0
Xnor::Xnor( QGraphicsItem *parent ) : GraphicElement( 2, 8, 1, 1, parent ) {
  setOutputsOnTop( true );
  setPixmap( QPixmap( ":/basic/xnor.png" ) );
  updatePorts( );
  setPortName( "XNOR" );
}
shared_ptr<SwitchState> ThriftConfigApplier::run() {
    auto newState = orig_->clone();
    bool changed = false;

    processVlanPorts();

    {
        auto newPorts = updatePorts();
        if (newPorts) {
            newState->resetPorts(std::move(newPorts));
            changed = true;
        }
    }

    {
        auto newIntfs = updateInterfaces();
        if (newIntfs) {
            newState->resetIntfs(std::move(newIntfs));
            changed = true;
        }
    }

    // Note: updateInterfaces() must be called before updateVlans(),
    // as updateInterfaces() populates the vlanInterfaces_ data structure.
    {
        auto newVlans = updateVlans();
        if (newVlans) {
            newState->resetVlans(std::move(newVlans));
            changed = true;
        }
    }

    // Note: updateInterfaces() must be called before updateRouteTables(),
    // as updateInterfaces() populates the intfRouteTables_ data structure.
    {
        auto newTables = updateRouteTables();
        if (newTables) {
            newState->resetRouteTables(std::move(newTables));
            changed = true;
        }
    }

    // Make sure all interfaces refer to valid VLANs.
    auto newVlans = newState->getVlans();
    for (const auto& vlanInfo : vlanInterfaces_) {
        if (newVlans->getVlanIf(vlanInfo.first) == nullptr) {
            throw FbossError("Interface ",
                             *(vlanInfo.second.interfaces.begin()),
                             " refers to non-existent VLAN ", vlanInfo.first);
        }
    }

    VlanID dfltVlan(cfg_->defaultVlan);
    if (orig_->getDefaultVlan() != dfltVlan) {
        if (newVlans->getVlanIf(dfltVlan) == nullptr) {
            throw FbossError("Default VLAN ", dfltVlan, " does not exist");
        }
        newState->setDefaultVlan(dfltVlan);
        changed = true;
    }

    std::chrono::seconds arpAgerInterval(cfg_->arpAgerInterval);
    if (orig_->getArpAgerInterval() != arpAgerInterval) {
        newState->setArpAgerInterval(arpAgerInterval);
        changed = true;
    }

    if (!changed) {
        return nullptr;
    }
    return newState;
}