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


    m_pOAuth2 = new OAuth2(this);
    m_API_key = m_pOAuth2->getSimpleAPIKey();

    connect(m_pOAuth2, SIGNAL(loginDone()), this, SLOT(loginDone()));


    m_managerPrediction.setAPIKey(m_API_key);

    connect(&m_managerPrediction, SIGNAL(replyText(QString)), this, SLOT(addReplyText(QString)));
    connect(&m_managerPrediction, SIGNAL(recvModelsList(QVariantList)), this, SLOT(recvModelsList(QVariantList)));
    connect(&m_managerPrediction, SIGNAL(recvModelDescription(QVariant)), this, SLOT(recvModelDescription(QVariant)));
    connect(&m_managerPrediction, SIGNAL(recvPredictionResult(QVariant)), this, SLOT(recvPredictionResult(QVariant)));
    connect(&m_managerPrediction, SIGNAL(recvAddToModelComplete(bool)), this, SLOT(recvAddToModelComplete(bool)));

    connect(ui->lwModelsList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedModelChanged()));

    connect(ui->actionDeleteModel, SIGNAL(triggered()), this, SLOT(deleteModel()));
    connect(ui->actionNewModel, SIGNAL(triggered()), this, SLOT(newModel()));
    connect(ui->actionUpdateModelsList, SIGNAL(triggered()), this, SLOT(updateModelsList()));
    connect(ui->actionUpdateModelInfo, SIGNAL(triggered()), this, SLOT(updateModelInfo()));
    connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(close()));
    connect(ui->predictButton, SIGNAL(clicked()), this, SLOT(predict()));


    connect(ui->lineEditTextToPredict, SIGNAL(returnPressed()), this, SLOT(predict()));
    connect(ui->actionLogin, SIGNAL(triggered()), this, SLOT(login()));

    connect(&timerTest, SIGNAL(timeout()), this, SLOT(testSendRequest()));

    startLogin(false);
}
Esempio n. 2
0
// Update GUI after model change (or different model selected) (accessible wrapper to call AtenWindow's function)
void AtenWindow::updateWidgets(int targets)
{
	Messenger::enter("AtenWindow::updateWidgets");

	refreshing_ = true;

	// Always update main window bottom-left status info, menu items, and titlebar
	updateMainWindow();

	// Update main view (always)
	ui.MainView->update();

	// Update model list
	if (targets&AtenWindow::ModelsListTarget) updateModelsList();

	// Get current model
	Model* currentModel = aten_.currentModelOrFrame();

	// Always update Home panel
	updateHomePanel(currentModel);

	// Enable / disable Selection panel
	ui.SelectionPanel->setEnabled(currentModel && currentModel->nSelected());

	// Update atoms table
	if (targets&AtenWindow::AtomsTableTarget) updateAtomsTable(currentModel);

	// Panels
	if (targets&AtenWindow::BuildPanelTarget) updateBuildPanel(currentModel);
	if (targets&AtenWindow::CellPanelTarget) updateCellPanel(currentModel);
	if (targets&AtenWindow::CalculatePanelTarget) updateCalculatePanel(currentModel);
	if (targets&AtenWindow::TransformPanelTarget) updateTransformPanel(currentModel);
	if (targets&AtenWindow::GridsPanelTarget) updateGridsPanel(currentModel);
	if (targets&AtenWindow::TrajectoryPanelTarget) updateTrajectoryPanel(currentModel);
	if (targets&AtenWindow::SelectPanelTarget) updateSelectPanel(currentModel);
	if (targets&AtenWindow::SelectionPanelTarget) updateSelectionPanel(currentModel);
	if (targets&AtenWindow::ToolsPanelTarget) updateToolsPanel(currentModel);
	if (targets&AtenWindow::ForcefieldsPanelTarget) updateForcefieldsPanel(currentModel);

	if (targets&AtenWindow::VibrationsTarget) vibrationsWidget->refresh();

	// Update contents of the glyph list
	if (targets&AtenWindow::GlyphsTarget) glyphsWidget->refresh();

	// Main window statusbar
	if (targets&AtenWindow::StatusBarTarget)
	{
		// Update mode help text
		QString text;
		text.sprintf("<b>%s:</b> %s", UserActions[selectedMode_].name, UserActions[selectedMode_].unModified);
		if (UserActions[selectedMode_].shiftModified[0] != '\0') text += ", <b>+shift</b> " + QString(UserActions[selectedMode_].shiftModified);
		if (UserActions[selectedMode_].ctrlModified[0] != '\0') text += ", <b>+ctrl</b> " + QString(UserActions[selectedMode_].ctrlModified);
		if (UserActions[selectedMode_].altModified[0] != '\0') text += ", <b>+alt</b> " + QString(UserActions[selectedMode_].altModified);

		this->setMessageLabel(text);
	}

	refreshing_ = false;

	Messenger::exit("AtenWindow::updateWidgets");
}