void SensorsWindow::changeForm(int formIndex) { delete m_currentCentralWidget; m_currentCentralWidget = createForm(formIndex); setCentralWidget(m_currentCentralWidget); setWindowTitle(QString("Sensors - ") + m_formNames.at(formIndex)); }
//---------------------------------------------------------------------------------------------- EditSerieDialog::EditSerieDialog(SeriesProvider * seriesProvider) { Q_ASSERT(seriesProvider); createForm(seriesProvider); createLayout(); createConnection(); }
/* * Adds a row to the list, keeping the null row and '...' row in the correct positions. * Must copy data to new array due to limitations in the forms library. */ void ListBox::addRow(const std::string& str) { FIELD **pNewFields = new FIELD*[m_numRows + (m_editable ? 2 : 1)]; //Copy existing fields, up to the second last ('...') row for (int i = 0; i < m_numRows - 1; i++) { pNewFields[i] = m_pFields[i]; } //Create '...' row if (m_editable) { //Create new field at third-to-last index (before '...' row) createField(&pNewFields[m_numRows - 1], m_numRows - 1, str); createField(&pNewFields[m_numRows], m_numRows, "..."); set_field_userptr(pNewFields[m_numRows], (void*)true); } else { createField(&pNewFields[m_numRows], m_numRows, str); } //Create null field pNewFields[m_editable ? m_numRows + 1 : m_numRows] = 0; for (int i = 0; i < m_numRows; i++) { if (m_pFields[i] != 0) { free_field(m_pFields[i]); } } m_numRows++; m_pFields = pNewFields; createForm(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), scene(new QGraphicsScene(this)), view(new QGraphicsView(scene, this)), pbLoadFile(new QPushButton("Load Input", this)), lbLoadFile(new QLabel("<input file>", this)), pbLoadLog(new QPushButton("Load Log", this)), lbLoadLog(new QLabel("<input log>", this)), pbLoadMap(new QPushButton("Load Map", this)), lbLoadMap(new QLabel("<input map>", this)), pbSaveMap(new QPushButton("Save Map", this)), lbSaveMap(new QLabel("<output map>", this)), pbDumpLog(new QPushButton("Save Log", this)), lbDumpLog(new QLabel("<output log>", this)), pbRun(new QPushButton("Run", this)), pbCancel(new QPushButton("Cancel", this)), pbSave(new QPushButton("Save", this)), prog(new QProgressBar(this)), mapper(prog) { initWidgets(); createForm(); createConnections(); }
/// PUBLIC UFindReplaceTextDialog::UFindReplaceTextDialog(QWidget *parent): QWidget(parent), colorSelection(Qt::green), deleteWhenClose(true) { setWindowFlags(Qt::Tool); createForm(); }
personForm::personForm(sqlI *_db, Person *p, QWidget *parent) : QDialog(parent), addingNew(false), _person(p), ownPerson(true), db(_db) { createForm(); fillForm(); setWindowTitle(tr("Edit person")); btnSubmit->setText(tr("&Save")); }
contractForm::contractForm(sqlI *_db,Contract *c, QWidget *parent) : QDialog(parent),addingNew(false),db(_db),_contract(c),ownContract(true) { createForm(); fillForm(); setWindowTitle(tr("Edit contract")); btnSubmit->setText(tr("&Save")); }
void Main :: createInsertCritterForm() { _formInsertCritter = createForm(950, 400, false); _formInsertCritter->setPosition(-_formInsertCritter->getWidth(), -_formInsertCritter->getHeight()); mInsertOK_1 = createButton(_formInsertCritter, "Insert", "", Vector2(120,330), Vector2(180, 40)); mInsertOK_25 = createButton(_formInsertCritter, "Insert x 25", "", Vector2(320,330), Vector2(180, 40)); mInsertOK_500 = createButton(_formInsertCritter, "Insert x 500", "", Vector2(520,330), Vector2(180, 40)); mInsertCancel = createButton(_formInsertCritter, "Cancel", "", Vector2(740,330), Vector2(120, 40)); mInsertCritterGenome = createContainer(_formInsertCritter, true, Vector2(20,20), Vector2(720, 56)); mInsertClear = createButton(_formInsertCritter, "Clear", "", Vector2(755,28), Vector2(80, 40)); updateInsertCritterForm(); setInsertCritterFormVisible(false); set<char> availableInstructions = InstructionSet::getAllAvailableInstructions(); float x = 20; float y = 80; for (set<char>::iterator i = availableInstructions.begin(); i != availableInstructions.end(); i++) { bool supportsConditions = InstructionSet::instructionSupportsConditions(*i); string idAlways, idIf, idNotIf; if (supportsConditions) { idAlways += (*i | eAlways); } else { idAlways += (*i | eAlways); } idIf += (*i | eIf); idNotIf += (*i | eNotIf); float yb = y; Button * pInstruction = createButton(_formInsertCritter, " ", idAlways.c_str(), Vector2(x, yb), Vector2(60, 60)); mInsertInstructionButtons.push_back(pInstruction); if (supportsConditions) { yb += 60; Button * pInstructionIf = createButton(_formInsertCritter, " ", idIf.c_str(), Vector2(x, yb), Vector2(60, 60)); mInsertInstructionButtons.push_back(pInstructionIf); yb += 60; Button * pInstructionNotIf = createButton(_formInsertCritter, " ", idNotIf.c_str(), Vector2(x, yb), Vector2(60, 60)); mInsertInstructionButtons.push_back(pInstructionNotIf); } x += 60; } createControlHeader(_formInsertCritter, "Click on the instructions above to build your genome, then press 'Insert x 500'.\nClick on 'What is this?' for a full description of each instruction.", Vector2(40,250), Vector2(900, 60), Vector4(1,1,1,1)); }
// --- QGAMES::Form* QGAMES::FormBuilder::form (int fId) { QGAMES::Forms::const_iterator i = _forms.find (fId); if (i != _forms.end ()) return ((*i).second); QGAMES::FormBuilder::Definitions::const_iterator j = _definitions.find (fId); assert (j != _definitions.end ()); // It doesn't exist... QGAMES::Form* form = createForm ((*j).second); assert (form); // createForm is an user's method...just in case! _forms.insert (QGAMES::Forms::value_type (fId, form)); return (form); }
QString upload(PuushFile file) { QDateTime time = QDateTime::currentDateTime(); QList<FormField> formData = { textField("k", settings.apiKey.toUtf8()), textField("z", "poop"), dataField("f", file.name, file.data) }; QHttpMultiPart *form = createForm(formData); QNetworkReply *reply = apiCall("/api/up", form); if (!reply) return QString(); QString replyText = QString::fromUtf8(reply->readAll()); QStringList replyParts = replyText.split(','); if (replyParts.length() < 3) { if (!replyParts.isEmpty()) { if (replyParts.first() == "-2") trayicon->showMessage(QObject::tr("Upload error."), QObject::tr("Server rejected request."), QSystemTrayIcon::Critical); else if (replyParts.first() == "-1") trayicon->showMessage(QObject::tr("Upload error."), QObject::tr("Server error."), QSystemTrayIcon::Critical); else trayicon->showMessage(QObject::tr("Upload error."), QObject::tr("Unknown server error."), QSystemTrayIcon::Critical); } else { trayicon->showMessage(QObject::tr("Upload error."), QObject::tr("Empty response."), QSystemTrayIcon::Critical); } return QString(); } recent.prepend({replyParts.at(2).toInt(), time, replyParts.at(1), file.name}); setupMenu(); QString url = replyParts.at(1); trayicon->showMessage(QObject::tr("Upload successful."), url, QSystemTrayIcon::Information, 5000); if (settings.onPuushActions & Settings::PlaySound) playSound("qrc:/notify.wav"); if (settings.onPuushActions & Settings::CopyLink) setClipboardText(url); if (settings.onPuushActions & Settings::OpenInBrowser) QDesktopServices::openUrl(url); return url; }
ListBox::ListBox(Panel *pPanel, int x, int y, int w, int h, bool editable) : Component(pPanel, x, y, w, h) { setSelectable(true); m_editable = true;//editable; TODO: revisit m_numRows = m_editable ? 1 : 0; m_pForm = 0; m_curRow = 0; //Create field array, init to null if (m_editable) { m_pFields = new FIELD*[2]; createField(&m_pFields[0], 0, "..."); set_field_userptr(m_pFields[0], (void*)true); m_pFields[1] = 0; } else { m_pFields = new FIELD*[1]; m_pFields[0] = 0; } createForm(); }
QWidget* MainWindow::createCentralWidget1() { QGridLayout* layout = new QGridLayout(); QGraphicsScene* scene = new QGraphicsScene(this); QGraphicsView* view = new QGraphicsView(scene); QTableView* tbl = new QTableView(); QWidget* w = new QWidget(); int iCol = 0; scene->addItem(new GraphicsWidget1()); layout->addWidget(view, 0, iCol++); tbl->setModel(m_itemModel); layout->addWidget(tbl, 0, iCol++); layout->addWidget(createForm(m_itemModel), 0, iCol++); w->setLayout(layout); return w; }
void DynamicConnectionPageWindow::createUi() { QVBoxLayout *mainLayout = new QVBoxLayout(); QLabel *captionLabel = new QLabel(QString("<h3>%1</h3>").arg(windowInfo->caption)); mainLayout->addWidget(captionLabel); QTabWidget *tab = new SubTabWidget(); tab->setDocumentMode(false); formWidget = new QWidget(); QFormLayout *form = new QFormLayout(); createForm(form); formWidget->setLayout(form); tab->addTab(formWidget, IconUtil::getIcon("form"), tr("Options")); editor = new CodeEditor(); editor->setWordWrapMode(QTextOption::WordWrap); editor->setReadOnly(true); tab->addTab(editor, IconUtil::getIcon("query"), tr("Query")); mainLayout->addWidget(tab); buttonBox=DialogHelper::createButtonBox(this); mainLayout->addWidget(buttonBox); setLayout(mainLayout); connect(tab, SIGNAL(currentChanged(int)), this, SLOT(tabIndexChanged(int))); QSize size = sizeHint(); if(size.width() < 350){ size.setWidth(350); } resize(size); DialogHelper::centerWindow(this); }
void QDesignerFormWindow::closeEvent(QCloseEvent *ev) { if (m_editor->isDirty()) { // Сохраняем автоматически bool ok = workbench()->saveForm(m_editor); ev->setAccepted(ok); m_editor->setDirty(!ok); /* raise(); QMessageBox box(tr("Save Form?"), tr("Do you want to save the changes you made to \"%1\" before closing?") .arg(m_editor->fileName().isEmpty() ? action()->text() : m_editor->fileName()), QMessageBox::Information, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::Cancel | QMessageBox::Escape, m_editor, Qt::Sheet); box.setButtonText(QMessageBox::Yes, m_editor->fileName().isEmpty() ? tr("Save...") : tr("Save")); box.setButtonText(QMessageBox::No, tr("Don't Save")); switch (box.exec()) { case QMessageBox::Yes: { bool ok = workbench()->saveForm(m_editor); ev->setAccepted(ok); m_editor->setDirty(!ok); break; } case QMessageBox::No: m_editor->setDirty(false); // Not really necessary, but stops problems if we get close again. ev->accept(); break; case QMessageBox::Cancel: ev->ignore(); break; }*/ } if (m_workbench->core()->formWindowManager()->formWindowCount() == 1 && ev->isAccepted() && QDesignerSettings().showNewFormOnStartup()) QTimer::singleShot(200, m_workbench->actionManager(), SLOT(createForm())); // Use timer in case we are quitting. }
NewAppDialogue::NewAppDialogue(QWidget* parent): QDialog(parent), name(new QLineEdit(this)), address(new QLineEdit(this)), port(new QLineEdit(this)), login(new QLineEdit(this)), pass(new QLineEdit(this)), log(new QLineEdit(this)), command(new QLineEdit(this)) { QVBoxLayout* mainLayout = new QVBoxLayout(this); QHBoxLayout* buttonsLayout = new QHBoxLayout(); QFormLayout* formLayout = new QFormLayout(); mainLayout->addLayout(formLayout); mainLayout->addStretch(); mainLayout->addLayout(buttonsLayout); setLayout(mainLayout); createButtons(buttonsLayout); createForm(formLayout); }
void DbObjectCreatorSimplePane::createUi() { QVBoxLayout *mainLayout=new QVBoxLayout(); QWidget *formContainerWidget=new QWidget(); formContainerWidget->setMinimumWidth(350); QLayout *form=createForm(); formContainerWidget->setLayout(form); QScrollArea *scrollArea=new QScrollArea(); scrollArea->setContentsMargins(0,0,0,0); scrollArea->setWidget(formContainerWidget); //scrollArea->setWidgetResizable(true); mainLayout->addWidget(scrollArea); mainLayout->setContentsMargins(0,0,0,0); setLayout(mainLayout); if(getCreatorMode() == DbObjectCreator::EditExisting){ disableControlsForEditMode(); } }
QString authenticate(QString user, QString pass) { QList<FormField> formData = { textField("e", user), textField("p", pass) }; QHttpMultiPart *form = createForm(formData); QNetworkReply *reply = apiCall("/api/auth", form); if (!reply) return QString(); QString replyText = QString::fromUtf8(reply->readAll()); QStringList replyParts = replyText.split(','); if (replyParts.length() < 4) return QString(); settings.loginName = user; settings.apiKey = replyParts[1]; return replyParts[1]; }
QStringList history() { QList<FormField> formData = { textField("k", settings.apiKey.toUtf8()) }; QHttpMultiPart *form = createForm(formData); QNetworkReply *reply = apiCall("/api/hist", form); if (!reply) return QStringList(); QString replyText = QString::fromUtf8(reply->readAll()); QStringList lines = replyText.split('\n', QString::SkipEmptyParts); if (lines.isEmpty()) return QStringList(); else if (lines.at(0).trimmed() != "0") return QStringList(); else lines.removeFirst(); for (int i = 0; i < lines.count(); ++i) { QStringList lineParts = lines.at(i).split(','); if (lineParts.length() < 4) continue; int id = lineParts[0].toInt(); QDateTime time = QDateTime::fromString(lineParts[1], "yyyy-MM-dd HH:mm:ss"); QString url = lineParts[2]; QString fn = lineParts[3]; recent << PuushedEntry{id, time, url, fn}; } return QStringList(); }
contractForm::contractForm(sqlI *_db,QWidget *parent) : QDialog(parent),addingNew(true),db(_db),ownContract(false) { createForm(); setWindowTitle(tr("Add contract")); }
personForm::personForm(sqlI *_db, QWidget *parent) : QDialog(parent), addingNew(true), ownPerson(false), db(_db) { createForm(); setWindowTitle(tr("Create person")); }
QDesignerActions::QDesignerActions(QDesignerWorkbench *workbench) : QObject(workbench), m_workbench(workbench), m_assistantClient(0), m_openDirectory(QString()) { Q_ASSERT(m_workbench != 0); m_core = m_workbench->core(); Q_ASSERT(m_core != 0); QDesignerFormWindowManagerInterface *formWindowManager = m_core->formWindowManager(); Q_ASSERT(formWindowManager != 0); QDesignerSettings settings; m_fileActions = new QActionGroup(this); m_fileActions->setExclusive(false); m_recentFilesActions = new QActionGroup(this); m_recentFilesActions->setExclusive(false); m_editActions = new QActionGroup(this); m_editActions->setExclusive(false); m_formActions = new QActionGroup(this); m_formActions->setExclusive(false); m_windowActions = new QActionGroup(this); m_windowActions->setExclusive(false); m_toolActions = new QActionGroup(this); m_toolActions->setExclusive(true); m_helpActions = new QActionGroup(this); m_helpActions->setExclusive(false); // // file actions // m_newFormAction = new QAction(tr("&New Form..."), this); m_newFormAction->setShortcut(tr("CTRL+N")); connect(m_newFormAction, SIGNAL(triggered()), this, SLOT(createForm())); m_fileActions->addAction(m_newFormAction); m_openFormAction = new QAction(tr("&Open Form..."), this); m_openFormAction->setShortcut(tr("CTRL+O")); connect(m_openFormAction, SIGNAL(triggered()), this, SLOT(openForm())); m_fileActions->addAction(m_openFormAction); QAction *act; // Need to insert this into the QAction. for (int i = 0; i < MaxRecentFiles; ++i) { act = new QAction(this); act->setVisible(false); connect(act, SIGNAL(triggered()), this, SLOT(openRecentForm())); m_recentFilesActions->addAction(act); } updateRecentFileActions(); act = new QAction(this); act->setSeparator(true); m_recentFilesActions->addAction(act); act = new QAction(tr("Clear &Menu"), this); connect(act, SIGNAL(triggered()), this, SLOT(clearRecentFiles())); m_recentFilesActions->addAction(act); QAction *sep = new QAction(this); sep->setSeparator(true); m_fileActions->addAction(sep); m_saveFormAction = new QAction(tr("&Save Form"), this); m_saveFormAction->setShortcut(tr("CTRL+S")); connect(m_saveFormAction, SIGNAL(triggered()), this, SLOT(saveForm())); m_fileActions->addAction(m_saveFormAction); m_saveFormAsAction = new QAction(tr("Save Form &As..."), this); connect(m_saveFormAsAction, SIGNAL(triggered()), this, SLOT(saveFormAs())); m_fileActions->addAction(m_saveFormAsAction); m_saveFormAsTemplateAction = new QAction(tr("Save Form As &Template..."), this); connect(m_saveFormAsTemplateAction, SIGNAL(triggered()), this, SLOT(saveFormAsTemplate())); m_fileActions->addAction(m_saveFormAsTemplateAction); sep = new QAction(this); sep->setSeparator(true); m_fileActions->addAction(sep); m_closeFormAction = new QAction(tr("&Close Form"), this); m_closeFormAction->setShortcut(tr("CTRL+W")); connect(m_closeFormAction, SIGNAL(triggered()), this, SLOT(closeForm())); m_fileActions->addAction(m_closeFormAction); sep = new QAction(this); sep->setSeparator(true); m_fileActions->addAction(sep); m_quitAction = new QAction(tr("&Quit"), this); m_quitAction->setShortcut(tr("CTRL+Q")); connect(m_quitAction, SIGNAL(triggered()), this, SLOT(shutdown())); m_fileActions->addAction(m_quitAction); // // edit actions // m_undoAction = formWindowManager->actionUndo(); m_undoAction->setShortcut(tr("CTRL+Z")); m_editActions->addAction(m_undoAction); m_redoAction = formWindowManager->actionRedo(); m_redoAction->setShortcut(tr("CTRL+SHIFT+Z")); m_editActions->addAction(m_redoAction); sep = new QAction(this); sep->setSeparator(true); m_editActions->addAction(sep); m_cutAction = formWindowManager->actionCut(); m_editActions->addAction(m_cutAction); m_copyAction = formWindowManager->actionCopy(); m_editActions->addAction(m_copyAction); m_pasteAction = formWindowManager->actionPaste(); m_editActions->addAction(m_pasteAction); m_deleteAction = formWindowManager->actionDelete(); m_editActions->addAction(m_deleteAction); m_selectAllAction = formWindowManager->actionSelectAll(); m_editActions->addAction(m_selectAllAction); sep = new QAction(this); sep->setSeparator(true); m_editActions->addAction(sep); m_sendToBackAction = formWindowManager->actionLower(); m_editActions->addAction(m_sendToBackAction); m_bringToFrontAction = formWindowManager->actionRaise(); m_editActions->addAction(m_bringToFrontAction); // // edit mode actions // m_editWidgetsAction = new QAction(tr("Edit Widgets"), this); m_editWidgetsAction->setCheckable(true); m_editWidgetsAction->setShortcut(tr("F3")); m_editWidgetsAction->setIcon(QIcon(m_core->resourceLocation() + QLatin1String("/widgettool.png"))); connect(formWindowManager, SIGNAL(activeFormWindowChanged(QDesignerFormWindowInterface*)), this, SLOT(activeFormWindowChanged(QDesignerFormWindowInterface*))); connect(m_editWidgetsAction, SIGNAL(triggered()), this, SLOT(editWidgetsSlot())); m_toolActions->addAction(m_editWidgetsAction); m_editWidgetsAction->setChecked(true); m_editWidgetsAction->setEnabled(false); QList<QObject*> builtinPlugins = QPluginLoader::staticInstances(); builtinPlugins += m_core->pluginManager()->instances(); foreach (QObject *plugin, builtinPlugins) { if (QDesignerFormEditorPluginInterface *formEditorPlugin = qobject_cast<QDesignerFormEditorPluginInterface*>(plugin)) { m_toolActions->addAction(formEditorPlugin->action()); formEditorPlugin->action()->setCheckable(true); } } m_uiMode = new QActionGroup(this); m_uiMode->setExclusive(true); m_sdiAction = m_uiMode->addAction(tr("Multiple Top-Level Windows")); m_sdiAction->setCheckable(true); m_dockedMdiAction = m_uiMode->addAction(tr("Docked Window")); m_dockedMdiAction->setCheckable(true); switch (settings.uiMode()) { default: Q_ASSERT(0); break; case QDesignerWorkbench::TopLevelMode: m_sdiAction->setChecked(true); break; case QDesignerWorkbench::DockedMode: m_dockedMdiAction->setChecked(true); break; } connect(m_uiMode, SIGNAL(triggered(QAction*)), this, SLOT(updateUIMode(QAction*))); // // form actions // m_layoutHorizontallyAction = formWindowManager->actionHorizontalLayout(); m_formActions->addAction(m_layoutHorizontallyAction); m_layoutVerticallyAction = formWindowManager->actionVerticalLayout(); m_formActions->addAction(m_layoutVerticallyAction); m_layoutHorizontallyInSplitterAction = formWindowManager->actionSplitHorizontal(); m_formActions->addAction(m_layoutHorizontallyInSplitterAction); m_layoutVerticallyInSplitterAction = formWindowManager->actionSplitVertical(); m_formActions->addAction(m_layoutVerticallyInSplitterAction); m_layoutGridAction = formWindowManager->actionGridLayout(); m_formActions->addAction(m_layoutGridAction); m_breakLayoutAction = formWindowManager->actionBreakLayout(); m_formActions->addAction(m_breakLayoutAction); m_adjustSizeAction = formWindowManager->actionAdjustSize(); m_formActions->addAction(m_adjustSizeAction); sep = new QAction(this); sep->setSeparator(true); m_formActions->addAction(sep); m_previewFormAction = new QAction(tr("&Preview"), this); m_previewFormAction->setShortcut(tr("CTRL+R")); connect(m_previewFormAction, SIGNAL(triggered()), this, SLOT(previewFormLater())); m_formActions->addAction(m_previewFormAction); m_styleActions = new QActionGroup(this); m_styleActions->setExclusive(true); connect(m_styleActions, SIGNAL(triggered(QAction*)), this, SLOT(previewForm(QAction*))); QAction *sep2 = new QAction(this); sep2->setSeparator(true); m_formActions->addAction(sep2); m_formSettings = new QAction(tr("Form &Settings..."), this); m_formSettings->setEnabled(false); connect(m_formSettings, SIGNAL(triggered()), this, SLOT(showFormSettings())); m_formActions->addAction(m_formSettings); QStringList availableStyleList = QStyleFactory::keys(); foreach (QString style, availableStyleList) { QAction *a = new QAction(this); a->setText(tr("%1 Style").arg(style)); a->setObjectName(QLatin1String("__qt_action_style_") + style); m_styleActions->addAction(a); }