void AnimCurveControl::editGraphClicked() { #ifdef SEEXPR_USE_ANIMLIB QDialog* dialog = new QDialog(this); CETool* tool = new CETool; animlib::AnimAttrID attr1("", ""); animlib::AnimCurve& anim = *new animlib::AnimCurve(attr1); anim = _editable->curve; QWidget* widg; tool->map(widg, 0); QVBoxLayout* layout = new QVBoxLayout(); dialog->resize(QSize(1024, 640)); dialog->setLayout(layout); layout->addWidget(widg); tool->addCurve(&anim); QDialogButtonBox* buttonbar = new QDialogButtonBox(); buttonbar->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok); connect(buttonbar, SIGNAL(accepted()), dialog, SLOT(accept())); connect(buttonbar, SIGNAL(rejected()), dialog, SLOT(reject())); layout->addWidget(buttonbar); if (dialog->exec() == QDialog::Accepted) { // copy points back from child _editable->curve = anim; _preview->sample(_editable->curve); _preview->repaint(); emit controlChanged(_id); } #endif }
void UserFilters::on_Paste__released () { auto edit = new QPlainTextEdit (); QDialog dia (this); dia.setWindowTitle (tr ("Paste rules")); dia.resize (600, 400); dia.setLayout (new QVBoxLayout ()); dia.layout ()->addWidget (new QLabel (tr ("Paste your custom rules here:"))); dia.layout ()->addWidget (edit); auto box = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel); dia.layout ()->addWidget (box); connect (box, SIGNAL (accepted ()), &dia, SLOT (accept ())); connect (box, SIGNAL (rejected ()), &dia, SLOT (reject ())); if (dia.exec () != QDialog::Accepted) return; AddMulti (Model_, edit->toPlainText ()); }
void Fix8Log::aboutSlot() { QDialog *aboutDialog = new QDialog(); QVBoxLayout *aboutLayout = new QVBoxLayout(0); QDialogButtonBox *dialogButtonBox = new QDialogButtonBox(); dialogButtonBox->addButton(QDialogButtonBox::Ok); connect(dialogButtonBox,SIGNAL(clicked(QAbstractButton*)), aboutDialog,SLOT(close())); QQuickView *aboutView = new QQuickView(QUrl("qrc:qml/helpAbout.qml")); QQuickItem *qmlObject = aboutView->rootObject(); qmlObject->setProperty("color",aboutDialog->palette().color(QPalette::Window)); qmlObject->setProperty("bgColor",aboutDialog->palette().color(QPalette::Window)); qmlObject->setProperty("version",QString::number(Globals::version)); aboutView->setResizeMode(QQuickView::SizeRootObjectToView); QWidget *aboutWidget = QWidget::createWindowContainer(aboutView,0); aboutWidget->setPalette(aboutDialog->palette()); aboutWidget->setAutoFillBackground(false); aboutDialog->setLayout(aboutLayout); aboutLayout->addWidget(aboutWidget,1); aboutLayout->addWidget(dialogButtonBox,0); aboutDialog->resize(500,400); aboutDialog->setWindowTitle(GUI::Globals::appName); aboutDialog->exec(); aboutDialog->deleteLater(); }
void AboutDialog::displayFile(const QString &fileName, const QString &title) { QDialog *dialog = new QDialog(this); QLayout *layout = new QVBoxLayout(dialog); QTextEdit *textEdit = new QTextEdit(dialog); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, dialog); textEdit->setStyleSheet(QLatin1String("font-family: monospace")); QFile file(fileName); if (file.open(QIODevice::ReadOnly)) { QString text = QTextStream(&file).readAll(); textEdit->setPlainText(text); } textEdit->setReadOnly(true); connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(close())); buttonBox->setCenterButtons(true); layout->addWidget(textEdit); layout->addWidget(buttonBox); layout->setMargin(6); dialog->setLayout(layout); dialog->setWindowTitle(title); dialog->setWindowFlags(Qt::Sheet); dialog->resize(600, 350); dialog->exec(); }
int main(int argc,char** argv){ QApplication app(argc,argv); QDialog *parent; QLineEdit *add; QLabel *oper; QLineEdit *added; QPushButton *equ; QLineEdit *res; /* 指针赋值 */ parent=new QDialog(); parent->resize(650,300); /* 给界面中组件指针赋值 */ add=new QLineEdit(parent); oper=new QLabel("+",parent); added=new QLineEdit(parent); equ=new QPushButton("=",parent); res=new QLineEdit(parent); /* 调整位置 */ add->move(20,130); oper->move(170,130); added->move(220,130); equ->move(360,130); res->move(470,130); parent->show(); return app.exec(); }
void showabout() { QDialog vedit; vedit.setWindowTitle(QObject::tr("About vedit")); vedit.contentsRect(); vedit.resize(300, 150); vedit.exec(); }
void newWordManageWindow::insertWord(QString spell, QString meaning) { QDialog *dialog = new QDialog(addDialog); dialog->setWindowTitle("重复"); dialog->resize(200, 110); QLabel *label = new QLabel(dialog); QLabel *labelText = new QLabel(dialog); label->setStyleSheet("background-color:lightblue"); labelText->setAlignment(Qt::AlignCenter); labelText->setGeometry(30, 0, 140, 70); label->setGeometry(0, 0, this->width(), this->height()); QPushButton *yesButton = new QPushButton(dialog); yesButton->setGeometry(140, 70, 55, 20); yesButton->setText("返回"); yesButton->setStyleSheet("color:black"); bool fail = false; if(spell.size()==0) { labelText->setText("单词不能为空!"); fail = true; } else if(meaning.size()==0) { labelText->setText("释义不能为空!"); fail = true; } for(int i=0; i<newWordList.size(); i++) { if(newWordList[i].spell==spell) { labelText->setText("您已经添加过这个生词了!"); } fail = true; break; } if(fail) { dialog->show(); connect(yesButton,SIGNAL(clicked()), dialog, SLOT(close())); } if(!fail) { QDateTime sysTime = QDateTime::currentDateTime(); QStringList list = sysTime.toString("yyyy-MM-dd").split('-'); QString time = list[0]+list[1]+list[2]; NEWWORD newword = { meaning, spell, time }; newWordList.push_front(newword); qDebug() << currentPage << " " << TotalPages; update(); } }
// maximize first gantt void MainWidget::maximizeFirstGantt() { QDialog *temp = new QDialog(this); QVBoxLayout *tempLayout = new QVBoxLayout(temp); // temp->setAttribute(Qt::WA_DeleteOnClose); temp->resize(1600, 900); tempLayout->addWidget(max1); temp->setLayout(tempLayout); temp->show(); }
int main(int argc,char *argv[]) { QApplication a(argc,argv); QTextCodec::setCodecForTr(QTextCodec::codecForLocale()); QDialog w; w.resize(400,300); QLabel label(&w); label.move(120,120); label.setText(QObject::tr("Hello World!ÄãºÃQt£¡")); w.show(); return a.exec(); }
/************ * *功能:帮助操作界面 * * * **/ void mainview::helpoperator() { QDialog *dialog = new QDialog(); dialog->setWindowTitle("帮助"); dialog->resize(800,600); //QPushButton *button_ok = new QPushButton("OK",dialog); QWebView *view = new QWebView(dialog); //view->setGeometry(0,0,800,550); //button_ok->setGeometry(550,750,50,50); //view->load(QUrl("http://10.3.3.59/index.php?r=help/index")); view->load(QUrl("./help.html")); //connect(button_ok,SIGNAL(clicked()),dialog,SLOT(close())); dialog->exec(); }
void UpdateDetector::showDialog() { // if the version tag is set, there is a newer version. QString ver = QString::fromLatin1("%1.%2.%3") .arg(MIRALL_VERSION_MAJOR).arg(MIRALL_VERSION_MINOR).arg(MIRALL_VERSION_MICRO); QDialog *msgBox = new QDialog; QIcon info = msgBox->style()->standardIcon(QStyle::SP_MessageBoxInformation, 0, 0); int iconSize = msgBox->style()->pixelMetric(QStyle::PM_MessageBoxIconSize, 0, 0); msgBox->setWindowIcon(info); QVBoxLayout *layout = new QVBoxLayout(msgBox); QHBoxLayout *hlayout = new QHBoxLayout; layout->addLayout(hlayout); msgBox->setWindowTitle(tr("New Version Available")); QLabel *ico = new QLabel; ico->setFixedSize(iconSize, iconSize); ico->setPixmap(info.pixmap(iconSize)); QLabel *lbl = new QLabel; QString txt = tr("<p>A new version of the %1 Client is available.</p>" "<p><b>%2</b> is available for download. The installed version is %3.<p>") .arg(Theme::instance()->appNameGUI()).arg(ocClient.versionstring()).arg(ver); lbl->setText(txt); lbl->setTextFormat(Qt::RichText); lbl->setWordWrap(true); hlayout->addWidget(ico); hlayout->addWidget(lbl); QDialogButtonBox *bb = new QDialogButtonBox; QPushButton *skip = bb->addButton(tr("Skip update"), QDialogButtonBox::ResetRole); QPushButton *reject = bb->addButton(tr("Skip this time"), QDialogButtonBox::AcceptRole); QPushButton *getupdate = bb->addButton(tr("Get update"), QDialogButtonBox::AcceptRole); connect(skip, SIGNAL(clicked()), msgBox, SLOT(reject())); connect(reject, SIGNAL(clicked()), msgBox, SLOT(reject())); connect(getupdate, SIGNAL(clicked()), msgBox, SLOT(accept())); connect(skip, SIGNAL(clicked()), SLOT(slotSetVersionSeen())); connect(getupdate, SIGNAL(clicked()), SLOT(slotOpenUpdateUrl())); layout->addWidget(bb); msgBox->open(); msgBox->resize(400, msgBox->sizeHint().height()); }
void RadioView::newStation() { QDialog *dia = new QDialog(this); Ui_AddRadioDialog *ard = new Ui_AddRadioDialog; ard->setupUi(dia); ard->addRadioDialogLabel->setPixmap(IconManager::pixmap("addradiodialog", 32)); dia->resize(300, 100); if (dia->exec() == QDialog::Accepted) { if (!ard->title->text().isEmpty() && !ard->url->text().isEmpty()) { Config::instance()->addRadioStation(ard->title->text(), ard->url->text()); connected(); } } delete dia; }
//----------------------------------------------------------------------------- void ctkSettings::restoreState(const QString& key, QDialog& dialog) { this->beginGroup(key); if(this->contains("Size")) { dialog.resize(this->value("Size").toSize()); } if(this->contains("Position")) { dialog.move(this->value("Position").toPoint()); } this->endGroup(); }
void OpenGLQtMenu::shaderMenuCallback(QObject* obj) { QSize id = qobject_cast<QAction*>(obj)->data().toSize(); int shaderId = id.width(); int type = id.height(); const std::vector<Shader*> shaders{ShaderManager::getPtr()->getShaders()}; auto it = std::find_if(shaders.begin(), shaders.end(), [shaderId](Shader* shader) -> bool { return static_cast<int>(shader->getID()) == shaderId; }); if (it != shaders.end()) { ShaderObject* shaderObj; switch (type) { case 1: shaderObj = (*it)->getVertexShaderObject(); break; case 2: shaderObj = (*it)->getGeometryShaderObject(); break; case 3: shaderObj = (*it)->getFragmentShaderObject(); break; default: return; } QMainWindow* win = static_cast<InviwoApplicationQt*>(InviwoApplication::getPtr())->getMainWindow(); QTextBrowser* shadercode = new QTextBrowser(nullptr); shadercode->setText(shaderObj->print(true).c_str()); shadercode->setStyleSheet("font: 12pt \"Courier\";"); QDialog* dialog = new QDialog(win); QGridLayout* layout = new QGridLayout(dialog); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); layout->addWidget(shadercode); dialog->setLayout(layout); dialog->resize(600, 800); dialog->exec(); delete dialog; } }
void StandAloneJSConsole::toggleConsole() { QMainWindow* mainWindow = qApp->getWindow(); if (!_jsConsole && !qApp->getLoginDialogPoppedUp()) { QDialog* dialog = new QDialog(mainWindow, Qt::WindowStaysOnTopHint); QVBoxLayout* layout = new QVBoxLayout(dialog); dialog->setLayout(layout); dialog->resize(QSize(CONSOLE_WIDTH, CONSOLE_HEIGHT)); layout->setMargin(0); layout->setSpacing(0); layout->addWidget(new JSConsole(dialog)); dialog->setWindowOpacity(CONSOLE_WINDOW_OPACITY); dialog->setWindowTitle(CONSOLE_TITLE); _jsConsole = dialog; } _jsConsole->setVisible(!_jsConsole->isVisible()); }
void KisNodeViewTest::testColorLabels() { QDialog dlg; QFont font; font.setPointSizeF(8); dlg.setFont(font); KisColorLabelSelectorWidget *widget = new KisColorLabelSelectorWidget(&dlg); QSizePolicy policy(QSizePolicy::Preferred, QSizePolicy::Preferred); widget->setSizePolicy(policy); QVBoxLayout *layout = new QVBoxLayout(&dlg); layout->addWidget(widget); layout->addStretch(1); dlg.resize(280, 400); dlg.exec(); }
void MainWindow::showPlot() { if(!currentImageSteps->at(currentImageSteps->size()-2)) return; // if(!fp) // delete fp; QDialog* dlg = new QDialog(this); // QHBoxLayout* mainLayout = new QHBoxLayout(dlg); // fp = new FitnessPlot(currentImageSteps->at(currentImageSteps->size()-2)); // fp->activate(currentImageSteps->at(currentImageSteps->size()-2),ui->rBox->value()); // fp->resize(800,600); // mainLayout->addWidget(fp); // dlg->setLayout(mainLayout); dlg->setAttribute(Qt::WA_DeleteOnClose); dlg->resize(800,600); dlg->show(); }
void AlbumCoverChoiceController::ShowCover(const Song& song) { QDialog* dialog = new QDialog(this); dialog->setAttribute(Qt::WA_DeleteOnClose, true); // Use Artist - Album as the window title QString title_text(song.albumartist()); if (title_text.isEmpty()) title_text = song.artist(); if (!song.album().isEmpty()) title_text += " - " + song.album(); dialog->setWindowTitle(title_text); QLabel* label = new QLabel(dialog); label->setPixmap(AlbumCoverLoader::TryLoadPixmap( song.art_automatic(), song.art_manual(), song.url().toLocalFile())); dialog->resize(label->pixmap()->size()); dialog->show(); }
void MainWindow::on_actionYearlyStatistics_triggered() { QDialog d; QVBoxLayout *l = new QVBoxLayout(&d); YearlyStatisticsModel *m = new YearlyStatisticsModel(); QTreeView *view = new QTreeView(); view->setModel(m); l->addWidget(view); d.resize(width() * .8, height() / 2); d.move(width() * .1, height() / 4); QShortcut *close = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), &d); connect(close, SIGNAL(activated()), &d, SLOT(close())); QShortcut *quit = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), &d); connect(quit, SIGNAL(activated()), this, SLOT(close())); d.setWindowFlags(Qt::Window | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint | Qt::WindowTitleHint); d.setWindowTitle(tr("Yearly Statistics")); d.exec(); }
void UtmpWebView::SetFrameWindow(int flag) { switch(flag) { case 0: this->close(); break; case 1: this->showMinimized(); break; case 2: { //全局也就只能有一个 QDialog* d = new QDialog(this,(Qt::WindowMinimizeButtonHint|Qt::WindowMaximizeButtonHint|Qt::WindowCloseButtonHint)); d->setAttribute(Qt::WA_DeleteOnClose, true); QWebInspector* wi = new QWebInspector(d); wi->setPage(this->page()); d->setLayout(new QVBoxLayout()); d->layout()->setMargin(0); d->layout()->addWidget(wi); d->show(); d->resize(600,350); break; } case 3: { QMessageBox::StandardButton rb = QMessageBox::information(NULL, "from QT", "这是网页让QT弹出的对话框", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); if(rb == QMessageBox::Yes) { //这样直接调用,执行速度异常慢 //this->page()->mainFrame()->evaluateJavaScript("Ext.Msg.alert('from ext','这是QT让网页弹出的对话框');"); this->page()->mainFrame()->evaluateJavaScript("testFun();"); } break; } case 4: { this->reload(); } } }
void ctkCmdLineModuleExplorerShowXmlAction::run() { QDialog* dialog = new QDialog(); try { dialog->setWindowTitle(this->ModuleRef.description().title()); } catch (const ctkCmdLineModuleXmlException&) { dialog->setWindowTitle(this->ModuleRef.location().toString()); } dialog->setLayout(new QVBoxLayout()); QHBoxLayout* buttonLayout = new QHBoxLayout(); buttonLayout->addStretch(1); QPushButton* closeButton = new QPushButton(tr("Close"), dialog); buttonLayout->addWidget(closeButton); QTextEdit* textEdit = new QTextEdit(dialog); textEdit->setPlainText(this->ModuleRef.rawXmlDescription().data()); QLabel* statusLabel = new QLabel(dialog); statusLabel->setWordWrap(true); if (this->ModuleRef.xmlValidationErrorString().isEmpty()) { statusLabel->setText(tr("No validation errors.")); } else { statusLabel->setText(this->ModuleRef.xmlValidationErrorString()); } dialog->layout()->addWidget(statusLabel); dialog->layout()->addWidget(textEdit); dialog->layout()->addItem(buttonLayout); connect(closeButton, SIGNAL(clicked()), dialog, SLOT(close())); dialog->resize(800, 600); dialog->show(); }
void KasTaskItem::showPropertiesDialog() { // // Create Dialog // QDialog *dlg = new QDialog( /*kasbar()*/0L, "task_props", false ); // // Title // KPopupTitle *title = new KPopupTitle( dlg, "title" ); dlg->setCaption( i18n("Task Properties") ); title->setText( i18n("Task Properties") ); title->setIcon( icon() ); // // Tabbed View // QTabWidget *tabs = new QTabWidget( dlg ); tabs->addTab( createX11Props( tabs ), i18n("General") ); tabs->addTab( createTaskProps( task_, tabs ), i18n("Task") ); tabs->addTab( createTaskProps( this, tabs ), i18n("Item") ); tabs->addTab( createTaskProps( kasbar(), tabs, false ), i18n("Bar") ); #if 0 tabs->addTab( createNETProps( tabs ), i18n("NET") ); #endif // // Layout Dialog // QVBoxLayout *vbl = new QVBoxLayout( dlg, KDialog::marginHint(), KDialog::spacingHint() ); vbl->addWidget( title ); vbl->addWidget( tabs ); dlg->resize( 470, 500 ); dlg->show(); }
void KisNodeViewTest::testLayers() { QDialog dlg; QFont font; font.setPointSizeF(8); dlg.setFont(font); KisNodeModel *model = new KisNodeModel(this); KisNodeView *view = new KisNodeView(&dlg); view->setModel(model); constructImage(); addSelectionMasks(); m_shapeController->setImage(m_image); model->setDummiesFacade(m_shapeController, m_image, m_shapeController, 0, 0); QVBoxLayout *layout = new QVBoxLayout(&dlg); KisColorFilterCombo *cb = new KisColorFilterCombo(&dlg); QSet<int> labels; for (int i = 0; i < 6; i++) { labels.insert(i); } cb->updateAvailableLabels(labels); QHBoxLayout *hbox = new QHBoxLayout(&dlg); hbox->addStretch(1); hbox->addWidget(cb); layout->addLayout(hbox); layout->addWidget(view); dlg.resize(280, 400); view->expandAll(); dlg.exec(); }
//=========================================================================== void PointSizeSheet::createSheet(QWidget* parent, gvObserver* obs) //=========================================================================== { obs_ = obs; form_ = new Ui::PointSizeSheet_form();//parent); QDialog* dial = new QDialog(); form_->setupUi(dial); dial->resize(form_->box->size()); QObject::connect(form_->OkButton, SIGNAL(clicked()), this, SLOT(ok())); QObject::connect(form_->CancelButton, SIGNAL(clicked()), dial, SLOT(close())); int pspercent = int(size_/MAX_POINT_SIZE*100.0 + 0.5); form_->SizeSlider->setValue(pspercent); form_->LCDNumber1->display(pspercent); // form_->LCDNumber1->intValue->setValue(size_); dial->show(); }
//=========================================================================== void SurfaceResolutionSheet::createSheet(QWidget* parent, gvObserver* obs) //=========================================================================== { form_ = new Ui::SurfaceResolutionSheet_form();//parent); QDialog* w = new QDialog(); form_->setupUi(w); w->resize(form_->box->size()); connect(form_->OkButton, SIGNAL(clicked()), this, SLOT(ok())); connect(form_->CancelButton, SIGNAL(clicked()), w, SLOT(close())); connect(form_->button200x200, SIGNAL(clicked()), this, SLOT(setHighRes())); form_->UresSlider->setValue(ures_); form_->VresSlider->setValue(vres_); w->show(); }
void FileViewManager::PreviewStandalone(const QString& filePathName, QWidget* dialogParent) { QDialog* fpdialog = new QDialog(dialogParent); fpdialog->setWindowTitle(QString("Preview '%1'").arg(QFileInfo(filePathName).fileName())); fpdialog->setContentsMargins(0, 0, 0, 0); fpdialog->resize(640, 480); //Maximize button would be more useful than a Help button on this dialog, e.g to view big pictures. Qt::WindowFlags flags = fpdialog->windowFlags(); flags &= ~Qt::WindowContextHelpButtonHint; flags |= Qt::WindowMaximizeButtonHint; fpdialog->setWindowFlags(flags); QHBoxLayout* hlay = new QHBoxLayout(fpdialog); hlay->setContentsMargins(0, 0, 0, 0); fpdialog->setLayout(hlay); FilePreviewerWidget* fpw = new FilePreviewerWidget(fpdialog); hlay->addWidget(fpw, 1); Preview(filePathName, fpw); fpdialog->exec(); }
void MainWindow::ShowDatabase() { if(!_DatabaseAdmin) { _DatabaseAdmin = new DatabaseAdmin(); _DatabaseAdmin->SetDatabaseConnector(_DataBaseConnector); } QDialog d; QHBoxLayout *l = new QHBoxLayout(&d); l->setMargin(0); d.setLayout(l); d.resize(_DatabaseAdmin->width(),_DatabaseAdmin->height()); d.layout()->addWidget(_DatabaseAdmin); _DatabaseAdmin->Show(); d.exec(); _DatabaseAdmin->setParent(0); if(Ask) Ask->show(); }
//********************************************************************** void TulipApp::startTulip() { // adjust size if needed QRect sRect = QApplication::desktop()->availableGeometry(); QRect wRect(this->geometry()); QRect fRect(this->frameGeometry()); int deltaWidth = fRect.width() - wRect.width(); int deltaHeight = fRect.height() - wRect.height(); // adjust width if (fRect.width() > sRect.width()) { wRect.setWidth(sRect.width() - deltaWidth); } // screen width centering wRect.moveLeft(sRect.left() + (sRect.width() - wRect.width())/2); // adjust height if (fRect.height() > sRect.height()) { wRect.setHeight(sRect.height() - deltaHeight); } // screen height centering wRect.moveTop(sRect.top() + (deltaHeight - deltaWidth)/2 + (sRect.height() - wRect.height())/2); // adjust geometry this->setGeometry(wRect.x(), wRect.y(), wRect.width(), wRect.height()); UpdatePlugin::installWhenRestartTulip(); AppStartUp *appStart=new AppStartUp(this); QDialog *errorDlg; std::string errors; appStart->show(); appStart->initTulip(&pluginLoader,errors); //delete appStart; if (errors.size() > 0) { errorDlg = new QDialog(this); errorDlg->setWindowTitle("Errors when loading Tulip plugins !!!"); QVBoxLayout* errorDlgLayout = new QVBoxLayout(errorDlg); errorDlgLayout->setMargin(11); errorDlgLayout->setSpacing(6); QFrame *frame = new QFrame(errorDlg); QHBoxLayout* frameLayout = new QHBoxLayout(frame); frameLayout->setMargin(0); frameLayout->setSpacing(0); QSpacerItem* spacer = new QSpacerItem( 180, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); frameLayout->addItem( spacer ); QTextEdit* textWidget = new QTextEdit(QString(""),errorDlg); textWidget->setReadOnly(true); textWidget->setLineWrapMode(QTextEdit::NoWrap); errorDlgLayout->addWidget( textWidget ); QPushButton * closeB = new QPushButton( "Close", frame); frameLayout->addWidget( closeB ); errorDlgLayout->addWidget( frame ); QWidget::connect(closeB, SIGNAL(clicked()), errorDlg, SLOT(hide())); errorDlg->resize( QSize(400, 250).expandedTo(errorDlg->minimumSizeHint()) ); textWidget->setText(QString::fromUtf8(errors.c_str())); errorDlg->exec(); } if(ControllerFactory::factory->objMap.empty()) { QMessageBox::critical(this,tr("No controller found"),tr("No controller was found in Tulip plugins directory.\n Tulip cannot work without a controller.")); exit(-1); } buildMenus(); this->show(); enableElements(false); /*Load preference*/ PreferenceDialog::loadPreference(); OpenGlErrorViewer *oldErrorViewer=OpenGlConfigManager::getInst().setErrorViewer(new QtOpenGlErrorViewer); delete oldErrorViewer; if(PreferenceManager::getInst().getNetworkConnection()) { pluginsUpdateChecker = new PluginsUpdateChecker(pluginLoader.pluginsList,this); connect(pluginsUpdateChecker,SIGNAL(updateFinished()),this,SLOT(displayRestartForPlugins())); multiServerManager = pluginsUpdateChecker->getMultiServerManager(); } else { pluginsUpdateChecker=NULL; } /*QWidget *centralwidget = new QWidget(this); QGridLayout *gridLayout = new QGridLayout(centralwidget); tabWidget=new QTabWidget(centralwidget); centralwidget->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred)); tabWidget->setGeometry(0,0,800,600); //tabWidget->setSizePolicy(QSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum));*/ tabWidget->removeTab(0); connect(tabWidget,SIGNAL(currentChanged(int)),this,SLOT(tabChanged(int))); // set workspace background //newWorkspace->setBackground(QBrush(QPixmap(QString::fromUtf8(":/background_logo.png")))); aboutWidget=NULL; //======================================= //MDI //newWorkspace->setScrollBarsEnabled( true ); // Window Menu connect(windowsMenu, SIGNAL( aboutToShow() ), this, SLOT( windowsMenuAboutToShow() ) ); connect(windowsMenu, SIGNAL(triggered(QAction*)), this, SLOT( windowsMenuActivated(QAction*))); assistantProcess= new QProcess(this); std::string assistantPath(tlp::TulipLibDir); assistantPath += string("../"); #if defined(__linux__) assistantPath += string("bin"); // check if we are in a bundle if (QDir(assistantPath.c_str()).exists("assistant")) // assistant is in the bundle bin directory assistantProcessApp = QString::fromUtf8(assistantPath.c_str()) + "/assistant"; else // assistant is in the Qt binaries install directory assistantProcessApp = QLibraryInfo::location(QLibraryInfo::BinariesPath)+ "/assistant"; #else #if defined(_WIN32) assistantPath.append("bin/assistant.exe"); #else assistantPath.append("Assistant.app/Contents/MacOS/Assistant"); #endif assistantProcessApp = assistantPath.c_str(); #endif /*saveActions(menuBar(),NULL,controllerToMenu); saveActions(toolBar,NULL,controllerToToolBar);*/ tabIndexToController[-1]=NULL; saveInterface(-1); OpenGlErrorViewer *oldViewer=GlTextureManager::getInst().setErrorViewer(new QtOpenGlErrorViewer(this)); delete oldViewer; TemplateFactory<ControllerFactory, Controller, ControllerContext>::ObjectCreator::const_iterator it; it=ControllerFactory::factory->objMap.begin(); string name=(*it).first; ++it; if(it==ControllerFactory::factory->objMap.end()) { controllerAutoLoad=false; createController(name,newName()); currentTabIndex=0; Controller::currentActiveController(tabIndexToController[currentTabIndex]); controllerAutoLoad=true; } else { controllerAutoLoad=false; } int argc = qApp->argc(); if (argc>1) { char ** argv = qApp->argv(); for (int i=1; i<argc; ++i) { if(string(argv[i])=="--width") { int width = atoi(argv[i+1]); wRect.setWidth(width); ++i; continue; } if(string(argv[i])=="--height") { int height = atoi(argv[i+1]); wRect.setHeight(height); ++i; continue; } if(string(argv[i])=="--x") { int x = atoi(argv[i+1]); wRect.setX(x); ++i; continue; } if(string(argv[i])=="--y") { int y = atoi(argv[i+1]); wRect.setY(y); ++i; continue; } QFileInfo info(QString::fromUtf8(argv[i])); QString s = info.absoluteFilePath(); fileOpen(0, s); } } this->setGeometry(wRect.x(), wRect.y(),wRect.width(), wRect.height()); }
/*! Makes a scrolled text window with the text taken from the array of character strings in [msg] */ void dia_smsg(const char **msg) { char *p; char *buf; char *lineStart; char *temp; int maxline, maxrow, linesize; long bufsize; int i, twidth, doline; int lastspace, curpos; int maxWidth = (int)(0.8 * QApplication::desktop()->width()); int maxHeight = (int)(0.8 * QApplication::desktop()->height()); int height, width = 0; QString test; QDialog *dlg = new QDialog(); dlg->setAttribute(Qt::WA_DeleteOnClose); for (i = 0, bufsize = 0; msg[i]; i++){ linesize = strlen(msg[i]); bufsize += linesize; } buf = (char *)malloc(bufsize + i + 1); p = buf; for (p = buf, i = 0; msg[i]; i++) { p += strlen (strcpy (p, msg[i])); /* DNM: this macro call caused program built on Irix 6.5 to not run on earlier Irix's. Casting as (int) didn't help - just do explicit tests */ /*if (!isspace (p[-1])) spaces, tabs and newlines are spaces.. */ if (p[-1] != ' ' && p[-1] != '\t' && p[-1] != '\n') *p++ = ' '; /* lines are concatenated, insert a space */ } *--p = 0; /* get rid of trailing space... */ // DNM: count the actual lines and their lengths to get the right size window maxline = 0; maxrow = 1; curpos = 0; lastspace = 40; lineStart = buf; for (p = buf; *p; p++) { doline = 0; if (*p == '\t') curpos = 8 * (curpos/ 8 + 1); else if (*p == ' ') { lastspace = curpos; curpos++; } else if (*p == '\n') { if (curpos >= maxline) maxline = curpos + 1; curpos = 0; doline = p + 1 - lineStart; } else if (curpos > 78 ) { if (lastspace >= maxline) maxline = lastspace + 1; curpos -= lastspace; doline = lastspace; } else curpos++; if (doline) { temp = (char *)malloc(doline + 1); if (temp) { strncpy(temp, lineStart, doline); temp[doline] = 0x00; test = temp; twidth = dlg->fontMetrics().width(test); if (width < twidth) width = twidth; free(temp); } lineStart = p + 1; lastspace = 40; maxrow++; } } if (!maxline & !width) { maxline = curpos + 1; test = ""; for (i = 0; i < maxline + 2; i++) test += "8"; width = dlg->fontMetrics().width(test); } if (maxrow > 50) maxrow = 40; QString qmsg = buf; // Make a vertical layout with the text edit and a close button QVBoxLayout *vbox = new QVBoxLayout(dlg); QTextEdit *edit = new QTextEdit(dlg); edit->setText(qmsg); edit->setReadOnly(true); vbox->addWidget(edit); QHBoxLayout *hbox = diaHBoxLayout(vbox); QPushButton *button = diaPushButton("Close", dlg, hbox); diaSetButtonWidth(button, true, 1.4, "Close"); QObject::connect(button, SIGNAL(clicked()), dlg, SLOT(close())); // Figure out width and height of text and height of button, and set size if (width > maxWidth) width = maxWidth; height = (maxrow + 5) * edit->fontMetrics().height(); if (height > maxHeight) height = maxHeight; QSize hint = hbox->sizeHint(); // This was width + 20 when the width was based on character count alone dlg->resize(width + 60, height + hint.height()); // Set title test = Dia_title; test += " Help"; dlg->setWindowTitle(test); dlg->show(); }
//! //! Show stereo config dialog. //! void ViewportPanel::showStereoDialog () { // create stereo parameter spin box map m_stereoParameterSBMap.clear(); double rttSizeX = 0.0; double rttSizeY = 0.0; double eyeDist = 0.0; double fOffsetMultiplier = 0; double nearClip = 0.0; double farClip = 0.0; double fov = 0.0; double focalLength = 0.0; m_viewportWidget->getStereoParameters(rttSizeX, rttSizeY, eyeDist, fOffsetMultiplier, nearClip, farClip, fov, focalLength); m_stereoParameterSBMap["Rtt Size X"] = new QDoubleSpinBox(); m_stereoParameterSBMap["Rtt Size X"]->setMaximum(2048.0); m_stereoParameterSBMap["Rtt Size X"]->setValue(rttSizeX); m_stereoParameterSBMap["Rtt Size Y"] = new QDoubleSpinBox(); m_stereoParameterSBMap["Rtt Size Y"]->setMaximum(2048.0); m_stereoParameterSBMap["Rtt Size Y"]->setValue(rttSizeY); m_stereoParameterSBMap["Eye Dist"] = new QDoubleSpinBox(); m_stereoParameterSBMap["Eye Dist"]->setMaximum(1.0); m_stereoParameterSBMap["Eye Dist"]->setMinimum(-1.0); m_stereoParameterSBMap["Eye Dist"]->setDecimals(5); m_stereoParameterSBMap["Eye Dist"]->setValue(eyeDist); m_stereoParameterSBMap["Frustum Multiplier"] = new QDoubleSpinBox(); m_stereoParameterSBMap["Frustum Multiplier"]->setMaximum(5.0); m_stereoParameterSBMap["Frustum Multiplier"]->setMinimum(-5.0); m_stereoParameterSBMap["Frustum Multiplier"]->setValue(fOffsetMultiplier); m_stereoParameterSBMap["Near Clip"] = new QDoubleSpinBox(); m_stereoParameterSBMap["Near Clip"]->setMaximum(100.0); m_stereoParameterSBMap["Near Clip"]->setValue(nearClip); m_stereoParameterSBMap["Far Clip"] = new QDoubleSpinBox(); m_stereoParameterSBMap["Far Clip"]->setMaximum(10000.0); m_stereoParameterSBMap["Far Clip"]->setValue(farClip); m_stereoParameterSBMap["Fov"] = new QDoubleSpinBox(); m_stereoParameterSBMap["Fov"]->setMaximum(180.0); m_stereoParameterSBMap["Fov"]->setValue(fov); m_stereoParameterSBMap["Focal Length"] = new QDoubleSpinBox(); m_stereoParameterSBMap["Focal Length"]->setMaximum(1000.0); m_stereoParameterSBMap["Focal Length"]->setValue(focalLength); m_stereoParameterSBMap["Width Correction X"] = new QDoubleSpinBox(); m_stereoParameterSBMap["Height Correction Y"] = new QDoubleSpinBox(); m_stereoParameterSBMap["Offset X"] = new QDoubleSpinBox(); m_stereoParameterSBMap["Offset Y"] = new QDoubleSpinBox(); QMap<QString, QDoubleSpinBox *>::iterator iter = m_stereoParameterSBMap.begin(); QVBoxLayout *layout = new QVBoxLayout(); QHBoxLayout *hLayout; QLabel *label; while (iter != m_stereoParameterSBMap.end()) { hLayout = new QHBoxLayout(); label = new QLabel(iter.key()); hLayout->addWidget(label); hLayout->addWidget(iter.value()); layout->addLayout(hLayout); ++iter; } QPushButton *button = new QPushButton("Apply"); layout->addWidget(button); connect(button, SIGNAL(clicked()), SLOT(setStereoParameters())); QDialog *stereoDialog = new QDialog(this); stereoDialog->setModal(false); stereoDialog->resize(300, 300); stereoDialog->setWindowTitle(tr("Stereo Configuration")); stereoDialog->setLayout(layout); stereoDialog->show(); }