MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
    ui->setupUi(this);

    m_conf = new Config(this);
    m_upd  = new UpdateIndex(m_conf, this);
    m_avr  = new AVRRunner(this);

    m_curDevice    = 0;
    m_curUpdate    = 0;
    m_outputHidden = true;

    connect(m_upd, SIGNAL(updateComplete(bool)), this, SLOT(_updateCompleted(bool)));

    connect(m_avr, SIGNAL(avrOutput(QByteArray)), this, SLOT(_avrOutput(QByteArray)));
    connect(m_avr, SIGNAL(finished(bool)), this, SLOT(_avrDone(bool)));
    connect(m_avr, SIGNAL(status(AVRRunner::Status)), this, SLOT(_avrStatus(AVRRunner::Status)));

    UpdateDialog updateScreen(m_upd, this);

    updateSerialPorts();

    m_upd->checkUpdates();

    updateScreen.hideNoUpdate(true);
    updateScreen.exec();

    ui->actProgress->setRange(0, 4);
    ui->outputText->hide();

        // apply themeing
    setStyleSheet(SingleThemer::getStyleSheet("main"));
}
AddNetDialog::AddNetDialog(OMNetwork *c_net, QWidget *c_parent) : QDialog(c_parent), ui(new Ui::AddNetDialog) {
    ui->setupUi(this);

    _parent = c_parent;
    _net = c_net;

    this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);

    updateSerialPorts();

    QWidget::setTabOrder(ui->portCombo, ui->netName);

    setStyleSheet(SingleThemer::getStyleSheet("add_net"));
}
示例#3
0
QFrame * ProgramTab::createFooter() {
    QFrame * footerFrame = new QFrame();
    footerFrame->setObjectName("footer"); // Used for styling
	footerFrame->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);

    QLabel * languageLabel = new QLabel(tr("Language:"), this);

	m_languageComboBox = new QComboBox();
	m_languageComboBox->setEditable(false);
    m_languageComboBox->setEnabled(true);
    m_languageComboBox->addItems(m_programWindow->getAvailableLanguages());
	QSettings settings;
	QString currentLanguage = settings.value("programwindow/language", "").toString();
	if (currentLanguage.isEmpty()) {
		currentLanguage = m_languageComboBox->currentText();
	}
    setLanguage(currentLanguage, false);

	QPushButton * addButton = new QPushButton(tr("New"));
	//addButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	connect(addButton, SIGNAL(clicked()), m_programWindow, SLOT(addTab()));

    QPushButton * loadButton = new QPushButton(tr("Open..."));
	//loadButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    connect(loadButton, SIGNAL(clicked()), this, SLOT(loadProgramFile()));

    m_saveButton = new QPushButton(tr("Save"));
	//m_saveButton->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
    connect(m_saveButton, SIGNAL(clicked()), this, SLOT(save()));

    QLabel * portLabel = new QLabel(tr("Port:"), this);

    m_portComboBox = new SerialPortComboBox();
    m_portComboBox->setEditable(false);
    m_portComboBox->setEnabled(true);
	QStringList ports = m_programWindow->getSerialPorts();
    m_portComboBox->addItems(ports);

	QString currentPort = settings.value("programwindow/port", "").toString();
	if (currentPort.isEmpty()) {
		currentPort = m_portComboBox->currentText();
	}
	else if (!ports.contains(currentPort)) {
		currentPort = m_portComboBox->currentText();
	}
    setPort(currentPort);

	m_programButton = new QPushButton(tr("Program"));
	m_programButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    connect(m_programButton, SIGNAL(clicked()), this, SLOT(sendProgram()));
	m_programButton->setEnabled(false);

	QLabel * programmerLabel = new QLabel(tr("Programmer:"), this);

	m_programmerComboBox = new QComboBox();
	m_programmerComboBox->setEditable(false);
    m_programmerComboBox->setEnabled(true);
	updateProgrammers();
	QString currentProgrammer = ProgramWindow::LocateName;
	QString temp = settings.value("programwindow/programmer", "").toString();
	if (!temp.isEmpty()) {
		QFileInfo fileInfo(temp);
		if (fileInfo.exists()) {
			currentProgrammer = temp;
		}
	}
	chooseProgrammerAux(currentProgrammer, false);

	QHBoxLayout *footerLayout = new QHBoxLayout;

	footerLayout->setMargin(0);
	footerLayout->setSpacing(5);
    footerLayout->addWidget(addButton);
    footerLayout->addWidget(loadButton);
    footerLayout->addWidget(m_saveButton);

    footerLayout->addSpacerItem(new QSpacerItem(5,0,QSizePolicy::Expanding,QSizePolicy::Minimum));

    footerLayout->addWidget(languageLabel);
    footerLayout->addWidget(m_languageComboBox);
    footerLayout->addWidget(portLabel);
    footerLayout->addWidget(m_portComboBox);
	footerLayout->addWidget(programmerLabel);
	footerLayout->addWidget(m_programmerComboBox);
	footerLayout->addWidget(m_programButton);

	footerFrame->setLayout(footerLayout);

	// connect last so these signals aren't triggered during initialization
    connect(m_languageComboBox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(setLanguage(const QString &)));
    connect(m_portComboBox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(setPort(const QString &)));
	connect(m_portComboBox, SIGNAL(aboutToShow()), this, SLOT(updateSerialPorts()), Qt::DirectConnection);
    connect(m_programmerComboBox, SIGNAL(activated(int)), this, SLOT(chooseProgrammerTimed(int)));	

	return footerFrame;
}
示例#4
0
			if (language.compare(currentLanguage) == 0) {
				currentAction->setChecked(true);
			}
		}
    }

    connect(languageMenu, SIGNAL(triggered(QAction*)), this, SLOT(setLanguage(QAction*)));

    m_serialPortMenu = new QMenu(tr("Select port"), this);
    currentMenu->addMenu(m_serialPortMenu);

    m_serialPortActionGroup = new QActionGroup(this);
	updateSerialPorts();

    connect(m_serialPortMenu, SIGNAL(triggered(QAction*)), this, SLOT(setPort(QAction*)));
	connect(m_serialPortMenu, SIGNAL(aboutToShow()), this, SLOT(updateSerialPorts()), Qt::DirectConnection);

	m_programmerMenu = new QMenu(tr("Select programmer"), this);
    currentMenu->addMenu(m_programmerMenu);

	m_programmerActionGroup = new QActionGroup(this);
	QHash<QString, QString> programmerNames = getProgrammerNames();
	foreach (QString name, programmerNames.keys()) {
		addProgrammer(name, programmerNames.value(name));
	}
	
    connect(m_programmerMenu, SIGNAL(triggered(QAction*)), this, SLOT(setProgrammer(QAction*)));

    currentMenu->addSeparator();

    m_programAction = new QAction(tr("Program"), this);
示例#5
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    // Align last toolbar action to the right
    QWidget *empty = new QWidget(this);
    empty->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
    ui->mainToolBar->insertWidget(ui->actionMonitor, empty);

    // Align last action to the right in the monitor toolbar
    QWidget *emptyMonitor = new QWidget(this);
    emptyMonitor->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
    ui->monitorToolBar->insertWidget(ui->actionMonitor, emptyMonitor);
    // Hide monitor toolbar
    ui->monitorToolBar->setVisible(false);

    // Hide graphs widget
    ui->graphsWidget->setVisible(false);

    // Set monospaced font in the monitor
    const QFont fixedFont = QFontDatabase::systemFont(QFontDatabase::FixedFont);
    ui->consoleText->setFont(fixedFont);

    // Set environment
    settings = new SettingsStore(CONFIG_INI);
    setArduinoBoard();
    xmlFileName = "";
    serial = NULL;

    // Set zoom scale of the web view
    float zoomScale = settings->zoomScale();
    ui->webView->setZoomFactor(zoomScale);

    // Hide messages
    actionCloseMessages();
    serialPortClose();

    // Load blockly index
    loadBlockly();

    // Set timer to update list of available ports
    updateSerialPorts();
    QTimer *timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(updateSerialPorts()));
    timer->start(5000);

    ui->consoleText->document()->setMaximumBlockCount(100);

    // Show/hide icon labels in the menu bar
    iconLabels();

    // Set process
    process = new QProcess();
    process->setProcessChannelMode(QProcess::MergedChannels);
    connect(process,
            SIGNAL(started()),
            this,
            SLOT(onProcessStarted()));
    connect(process,
            SIGNAL(readyReadStandardOutput()),
            this,
            SLOT(onProcessOutputUpdated()));
    connect(process,
            SIGNAL(finished(int)),
            this,
            SLOT(onProcessFinished(int)));

    // Show opened file name in status bar
    connect(statusBar(),
            SIGNAL(messageChanged(QString)),
            this,
            SLOT(onStatusMessageChanged(QString)));

    // Filter events to capture backspace key
    ui->webView->installEventFilter(this);
}