// Initialize the dialog widgets and connect the signals/slots void TelescopeDialog::createDialogContent() { ui->setupUi(dialog); #ifdef Q_OS_WIN //Kinetic scrolling for tablet pc and pc QList<QWidget *> addscroll; addscroll << ui->telescopeTreeView << ui->textBrowserHelp << ui->textBrowserAbout; installKineticScrolling(addscroll); #endif //Inherited connect connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate())); connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())); connect(ui->TitleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMovedTo(QPoint))); //Connect: sender, signal, receiver, method //Page: Telescopes connect(ui->pushButtonChangeStatus, SIGNAL(clicked()), this, SLOT(buttonChangeStatusPressed())); connect(ui->pushButtonConfigure, SIGNAL(clicked()), this, SLOT(buttonConfigurePressed())); connect(ui->pushButtonAdd, SIGNAL(clicked()), this, SLOT(buttonAddPressed())); connect(ui->pushButtonRemove, SIGNAL(clicked()), this, SLOT(buttonRemovePressed())); connect(ui->telescopeTreeView, SIGNAL(clicked (const QModelIndex &)), this, SLOT(selectTelecope(const QModelIndex &))); //connect(ui->telescopeTreeView, SIGNAL(activated (const QModelIndex &)), this, SLOT(configureTelescope(const QModelIndex &))); //Page: Options: connect(ui->checkBoxReticles, SIGNAL(clicked(bool)), telescopeManager, SLOT(setFlagTelescopeReticles(bool))); connect(ui->checkBoxLabels, SIGNAL(clicked(bool)), telescopeManager, SLOT(setFlagTelescopeLabels(bool))); connect(ui->checkBoxCircles, SIGNAL(clicked(bool)), telescopeManager, SLOT(setFlagTelescopeCircles(bool))); connect(ui->checkBoxEnableLogs, SIGNAL(toggled(bool)), telescopeManager, SLOT(setFlagUseTelescopeServerLogs(bool))); connect(ui->checkBoxUseExecutables, SIGNAL(toggled(bool)), ui->labelExecutablesDirectory, SLOT(setEnabled(bool))); connect(ui->checkBoxUseExecutables, SIGNAL(toggled(bool)), ui->lineEditExecutablesDirectory, SLOT(setEnabled(bool))); connect(ui->checkBoxUseExecutables, SIGNAL(toggled(bool)), ui->pushButtonPickExecutablesDirectory, SLOT(setEnabled(bool))); connect(ui->checkBoxUseExecutables, SIGNAL(toggled(bool)), this, SLOT(checkBoxUseExecutablesToggled(bool))); connect(ui->pushButtonPickExecutablesDirectory, SIGNAL(clicked()), this, SLOT(buttonBrowseServerDirectoryPressed())); //In other dialogs: connect(&configurationDialog, SIGNAL(changesDiscarded()), this, SLOT(discardChanges())); connect(&configurationDialog, SIGNAL(changesSaved(QString, ConnectionType)), this, SLOT(saveChanges(QString, ConnectionType))); //Initialize the style updateStyle(); //Initializing the list of telescopes telescopeListModel->setColumnCount(ColumnCount); setHeaderNames(); ui->telescopeTreeView->setModel(telescopeListModel); ui->telescopeTreeView->header()->setSectionsMovable(false); ui->telescopeTreeView->header()->setSectionResizeMode(ColumnSlot, QHeaderView::ResizeToContents); ui->telescopeTreeView->header()->setStretchLastSection(true); //Populating the list //Cycle the slots for (int slotNumber = MIN_SLOT_NUMBER; slotNumber < SLOT_NUMBER_LIMIT; slotNumber++) { //Slot # //int slotNumber = (i+1)%SLOT_COUNT;//Making sure slot 0 is last //Make sure that this is initialized for all slots telescopeStatus[slotNumber] = StatusNA; //Read the telescope properties QString name; ConnectionType connectionType; QString equinox; QString host; int portTCP; int delay; bool connectAtStartup; QList<double> circles; QString serverName; QString portSerial; if(!telescopeManager->getTelescopeAtSlot(slotNumber, connectionType, name, equinox, host, portTCP, delay, connectAtStartup, circles, serverName, portSerial)) continue; //Determine the server type telescopeType[slotNumber] = connectionType; //Determine the telescope's status if (telescopeManager->isConnectedClientAtSlot(slotNumber)) { telescopeStatus[slotNumber] = StatusConnected; } else { //TODO: Fix this! //At startup everything exists and attempts to connect telescopeStatus[slotNumber] = StatusConnecting; } addModelRow(slotNumber, connectionType, telescopeStatus[slotNumber], name); //After everything is done, count this as loaded telescopeCount++; } //Finished populating the table, let's sort it by slot number //ui->telescopeTreeView->setSortingEnabled(true);//Set in the .ui file ui->telescopeTreeView->sortByColumn(ColumnSlot, Qt::AscendingOrder); //(Works even when the table is empty) //(Makes redundant the delay of 0 above) //TODO: Reuse code. if(telescopeCount > 0) { ui->telescopeTreeView->setFocus(); ui->telescopeTreeView->header()->setSectionResizeMode(ColumnType, QHeaderView::ResizeToContents); } else { ui->pushButtonChangeStatus->setEnabled(false); ui->pushButtonConfigure->setEnabled(false); ui->pushButtonRemove->setEnabled(false); ui->pushButtonAdd->setFocus(); } updateWarningTexts(); if(telescopeCount >= SLOT_COUNT) ui->pushButtonAdd->setEnabled(false); //Checkboxes ui->checkBoxReticles->setChecked(telescopeManager->getFlagTelescopeReticles()); ui->checkBoxLabels->setChecked(telescopeManager->getFlagTelescopeLabels()); ui->checkBoxCircles->setChecked(telescopeManager->getFlagTelescopeCircles()); ui->checkBoxEnableLogs->setChecked(telescopeManager->getFlagUseTelescopeServerLogs()); //Telescope server directory ui->checkBoxUseExecutables->setChecked(telescopeManager->getFlagUseServerExecutables()); ui->lineEditExecutablesDirectory->setText(telescopeManager->getServerExecutablesDirectoryPath()); //About page setAboutText(); //Everything must be initialized by now, start the updateTimer //TODO: Find if it's possible to run it only when the dialog is visible QTimer* updateTimer = new QTimer(this); connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateTelescopeStates())); updateTimer->start(200); }