bool DateEntryEditor::showDialog( QString caption, OPimEvent& event ) { QDialog newDlg( m_parent, 0, TRUE ); newDlg.setCaption( caption ); QVBoxLayout *vb = new QVBoxLayout( &newDlg ); QScrollView *sv = new QScrollView( &newDlg ); sv->setResizePolicy( QScrollView::AutoOneFit ); sv->setFrameStyle( QFrame::NoFrame ); sv->setHScrollBarMode( QScrollView::AlwaysOff ); vb->addWidget( sv ); DateEntry *de = new DateEntry( weekStartOnMonday(), isAP(), &newDlg ); de->comboLocation->clear(); de->comboLocation->insertItem(""); de->comboLocation->insertStringList( locations().names() ); de->comboDescription->clear(); de->comboDescription->insertItem(""); de->comboDescription->insertStringList( descriptions().names() ); de->setEvent( event ); sv->addChild( de ); while ( QPEApplication::execDialog( &newDlg ) ) { de->getEvent( event ); QString error = checkEvent( event ); if ( !error.isNull() ) { if ( QMessageBox::warning( m_parent, QObject::tr("Error!"), error, QObject::tr("Fix it"), QObject::tr("Continue"), 0, 0, 1 ) == 0 ) continue; } return true; } return false; }
void RenderFrame::slotViewCleared() { if(element() && m_widget->inherits("QScrollView")) { #ifdef DEBUG_LAYOUT kdDebug(6031) << "frame is a scrollview!" << endl; #endif QScrollView *view = static_cast<QScrollView *>(m_widget); if(!element()->frameBorder || !((static_cast<HTMLFrameSetElementImpl *>(element()->parentNode()))->frameBorder())) view->setFrameStyle(QFrame::NoFrame); #if APPLE_CHANGES // Qt creates QScrollView w/ a default style of QFrame::StyledPanel | QFrame::Sunken. else view->setFrameStyle( QFrame::StyledPanel | QFrame::Sunken ); #else view->setHScrollBarMode(element()->scrolling ); view->setVScrollBarMode(element()->scrolling ); #endif if(view->inherits("KHTMLView")) { #ifdef DEBUG_LAYOUT kdDebug(6031) << "frame is a KHTMLview!" << endl; #endif KHTMLView *htmlView = static_cast<KHTMLView *>(view); if(element()->marginWidth != -1) htmlView->setMarginWidth(element()->marginWidth); if(element()->marginHeight != -1) htmlView->setMarginHeight(element()->marginHeight); } } }
void RenderPartObject::slotViewCleared() { if(element() && m_widget->inherits("QScrollView") ) { #ifdef DEBUG_LAYOUT kdDebug(6031) << "iframe is a scrollview!" << endl; #endif QScrollView *view = static_cast<QScrollView *>(m_widget); int frameStyle = QFrame::NoFrame; QScrollView::ScrollBarMode scroll = QScrollView::Auto; int marginw = -1; int marginh = -1; if ( element()->id() == ID_IFRAME) { HTMLIFrameElementImpl *frame = static_cast<HTMLIFrameElementImpl *>(element()); if(frame->frameBorder) frameStyle = QFrame::Box; scroll = frame->scrolling; marginw = frame->marginWidth; marginh = frame->marginHeight; } view->setFrameStyle(frameStyle); #if !APPLE_CHANGES view->setVScrollBarMode(scroll); view->setHScrollBarMode(scroll); #endif if(view->inherits("KHTMLView")) { #ifdef DEBUG_LAYOUT kdDebug(6031) << "frame is a KHTMLview!" << endl; #endif KHTMLView *htmlView = static_cast<KHTMLView *>(view); htmlView->setIgnoreWheelEvents( element()->id() == ID_IFRAME ); if(marginw != -1) htmlView->setMarginWidth(marginw); if(marginh != -1) htmlView->setMarginHeight(marginh); } } }
HelixConfigDialogBase::HelixConfigDialogBase( HelixEngine *engine, amaroK::PluginConfig *config, QWidget *p ) : QTabWidget( p ) , m_core(0) , m_plugin(0) , m_codec(0) , m_device(0) , m_engine( engine ) { int row = 0; QString currentPage; QWidget *parent = 0; QGridLayout *grid = 0; QScrollView *sv = 0; QString pageName( i18n("Main") ); addTab( sv = new QScrollView, pageName ); parent = new QWidget( sv->viewport() ); sv->setResizePolicy( QScrollView::AutoOneFit ); sv->setHScrollBarMode( QScrollView::AlwaysOff ); sv->setFrameShape( QFrame::NoFrame ); sv->addChild( parent ); grid = new QGridLayout( parent, /*rows*/20, /*cols*/2, /*margin*/10, /*spacing*/10 ); grid->setColStretch( 0, 1 ); grid->setColStretch( 1, 1 ); if( sv ) sv->setMinimumWidth( grid->sizeHint().width() + 20 ); engine->m_coredir = HelixConfig::coreDirectory(); m_core = new HelixConfigEntry( parent, engine->m_coredir, config, row, i18n("Helix/Realplay core directory"), HelixConfig::coreDirectory().utf8(), i18n("This is the directory where clntcore.so is located")); ++row; engine->m_pluginsdir = HelixConfig::pluginDirectory(); m_plugin = new HelixConfigEntry( parent, engine->m_pluginsdir, config, row, i18n("Helix/Realplay plugins directory"), HelixConfig::pluginDirectory().utf8(), i18n("This is the directory where, for example, vorbisrend.so is located")); ++row; engine->m_codecsdir = HelixConfig::codecsDirectory(); m_codec = new HelixConfigEntry( parent, engine->m_codecsdir, config, row, i18n("Helix/Realplay codecs directory"), HelixConfig::codecsDirectory().utf8(), i18n("This is the directory where, for example, cvt1.so is located")); ++row; grid->addMultiCellWidget( new KSeparator( KSeparator::Horizontal, parent ), row, row, 0, 1 ); ++row; m_device = new HelixSoundDevice( parent, config, row, engine ); // lets find the logo if we can QPixmap *pm = 0; QString logo = HelixConfig::coreDirectory(); if (logo.isEmpty()) logo = HELIX_LIBS "/common"; logo.append("/../share/"); QString tmp = logo; tmp.append("hxplay/logo.png"); if (QFileInfo(tmp).exists()) { logo = tmp; pm = new QPixmap(logo); } else { tmp = logo; tmp.append("realplay/logo.png"); if (QFileInfo(tmp).exists()) { logo = tmp; pm = new QPixmap(logo); } } if (pm) { QLabel *l = new QLabel(parent); l->setPixmap(*pm); grid->addMultiCellWidget( l, 20, 20, 1, 1, Qt::AlignRight ); } entries.setAutoDelete( true ); pageName = i18n("Plugins"); addTab( sv = new QScrollView, pageName ); parent = new QWidget( sv->viewport() ); sv->setResizePolicy( QScrollView::AutoOneFit ); sv->addChild( parent ); QTextEdit *le = new QTextEdit( parent ); if( sv ) sv->setMinimumWidth( le->sizeHint().width() ); grid = new QGridLayout( parent, /*rows*/1, /*cols*/1, /*margin*/2, /*spacing*/1 ); grid->addMultiCellWidget( le, 0, 1, 0, 1, 0 ); le->setWordWrap(QTextEdit::NoWrap); int n = engine->numPlugins(); const char *description, *copyright, *moreinfourl; row = 0; for (int i=0; i<n; i++) { if (!engine->getPluginInfo(i, description, copyright, moreinfourl)) { le->append(QString(description)); le->append(QString(copyright)); le->append(QString(moreinfourl)); le->append(QString(" ")); } } le->setReadOnly(true); le->setContentsPos(0,0); }
// The constructor sets up the GUI, laying out the parameters on the left and // the two plots on the right. There's nothing special here, it's just long. // The code for the labels and text boxes for the parameters (on the left) is // boilerplate ripped directly from default_gui_model, and should really be // refactored out of here. Istep::Istep(void) : QWidget(MainWindow::getInstance()->centralWidget()), Workspace::Instance("Istep", ::vars, ::num_vars), period(1.0), delay(0.0), Amin(-100.0), Amax(100.0), Nsteps(20), Ncycles(1), duty(50), offset(0.0), factor(200.0), periodsSincePlot(0) { setCaption(QString::number(getID()) + " Istep"); QBoxLayout *layout = new QHBoxLayout(this); // overall GUI layout QBoxLayout *leftLayout = new QVBoxLayout(); QHBox *utilityBox = new QHBox(this); pauseButton = new QPushButton("Pause", utilityBox); pauseButton->setToggleButton(true); QPushButton *modifyButton = new QPushButton("Modify", utilityBox); QPushButton *unloadButton = new QPushButton("Unload", utilityBox); QObject::connect(pauseButton, SIGNAL(toggled(bool)), this, SLOT(pause(bool))); QObject::connect(modifyButton, SIGNAL(clicked(void)), this, SLOT(modify(void))); QObject::connect(unloadButton, SIGNAL(clicked(void)), this, SLOT(exit(void))); QObject::connect(pauseButton, SIGNAL(toggled(bool)), modifyButton, SLOT(setEnabled(bool))); QToolTip::add(pauseButton, "Start/Stop Istep protocol"); QToolTip::add(modifyButton, "Commit changes to parameter values and reset"); QToolTip::add(unloadButton, "Close plug-in"); // create default_gui_model GUI DO NOT EDIT QScrollView *sv = new QScrollView(this); sv->setResizePolicy(QScrollView::AutoOneFit); sv->setHScrollBarMode(QScrollView::AlwaysOff); QWidget *viewport = new QWidget(sv->viewport()); sv->addChild(viewport); QGridLayout *scrollLayout = new QGridLayout(viewport, 1, 2); size_t nstate = 0, nparam = 0, nevent = 0, ncomment = 0; for (size_t i = 0; i < num_vars; i++) { if (vars[i].flags & (PARAMETER | STATE | EVENT | COMMENT)) { param_t param = {0}; param.label = new QLabel(vars[i].name, viewport); scrollLayout->addWidget(param.label, parameter.size(), 0); param.edit = new DefaultGUILineEdit(viewport); scrollLayout->addWidget(param.edit, parameter.size(), 1); QToolTip::add(param.label, vars[i].description); QToolTip::add(param.edit, vars[i].description); if (vars[i].flags & PARAMETER) { if (vars[i].flags & DOUBLE) { param.edit->setValidator(new QDoubleValidator(param.edit)); param.type = PARAMETER | DOUBLE; } else if (vars[i].flags & UINTEGER) { QIntValidator *validator = new QIntValidator(param.edit); param.edit->setValidator(validator); validator->setBottom(0); param.type = PARAMETER | UINTEGER; } else if (vars[i].flags & INTEGER) { param.edit->setValidator(new QIntValidator(param.edit)); param.type = PARAMETER | INTEGER; } else param.type = PARAMETER; param.index = nparam++; param.str_value = new QString; } else if (vars[i].flags & STATE) { param.edit->setReadOnly(true); param.type = STATE; param.index = nstate++; } else if (vars[i].flags & EVENT) { param.edit->setReadOnly(true); param.type = EVENT; param.index = nevent++; } else if (vars[i].flags & COMMENT) { param.type = COMMENT; param.index = ncomment++; } parameter[vars[i].name] = param; } } // end default_gui_model GUI DO NOT EDIT leftLayout->addWidget(sv); leftLayout->addWidget(utilityBox); layout->addLayout(leftLayout); QBoxLayout *rightLayout = new QVBoxLayout(); rightLayout->setSpacing(15); rightLayout->setMargin(10); vplot = new IncrementalPlot(this); vplot->setMinimumSize(400, 200); rightLayout->addWidget(vplot, 2); iplot = new IncrementalPlot(this); iplot->setMinimumSize(400, 100); rightLayout->addWidget(iplot, 1); layout->addLayout(rightLayout); layout->setResizeMode(QLayout::Minimum); layout->setStretchFactor(leftLayout, 0); layout->setStretchFactor(rightLayout, 1); QRect thisRect = this->geometry(); thisRect.setHeight(350); this->setGeometry(thisRect); // set GUI refresh rate QTimer *timer = new QTimer(this); timer->start(1000); QObject::connect(timer, SIGNAL(timeout(void)), this, SLOT(refresh(void))); show(); stepSize = (Amax - Amin) / Nsteps; update(PERIOD); update(INIT); refresh(); }
Expert::Expert( QWidget *parent ) : QTabDialog( parent ) { m_dependencies = new QDict< QList<IInput> >(257); m_dependencies->setAutoDelete(TRUE); m_inputWidgets = new QDict< IInput >; m_switches = new QDict< QObject >; m_changed = FALSE; setHelpButton(); QListIterator<ConfigOption> options = Config::instance()->iterator(); QVBoxLayout *pageLayout = 0; QFrame *page = 0; ConfigOption *option = 0; for (options.toFirst();(option=options.current());++options) { switch(option->kind()) { case ConfigOption::O_Info: { if (pageLayout) pageLayout->addStretch(1); QScrollView *view = new QScrollView(this); view->setVScrollBarMode(QScrollView::Auto); view->setHScrollBarMode(QScrollView::AlwaysOff); view->setResizePolicy(QScrollView::AutoOneFit); page = new QFrame( view->viewport(), option->name() ); pageLayout = new QVBoxLayout(page); pageLayout->setMargin(10); view->addChild(page); addTab(view,option->name()); QWhatsThis::add(page, option->docs().simplifyWhiteSpace() ); QToolTip::add(page, option->docs() ); } break; case ConfigOption::O_String: { ASSERT(page!=0); InputString::StringMode sm=InputString::StringFree; switch(((ConfigString *)option)->widgetType()) { case ConfigString::String: sm=InputString::StringFree; break; case ConfigString::File: sm=InputString::StringFile; break; case ConfigString::Dir: sm=InputString::StringDir; break; } InputString *inputString = new InputString( option->name(), // name page, // widget *((ConfigString *)option)->valueRef(), // variable sm // type ); pageLayout->addWidget(inputString); QWhatsThis::add(inputString, option->docs().simplifyWhiteSpace() ); QToolTip::add(inputString,option->docs()); connect(inputString,SIGNAL(changed()),SLOT(changed())); m_inputWidgets->insert(option->name(),inputString); addDependency(m_switches,option->dependsOn(),option->name()); } break; case ConfigOption::O_Enum: { ASSERT(page!=0); InputString *inputString = new InputString( option->name(), // name page, // widget *((ConfigEnum *)option)->valueRef(), // variable InputString::StringFixed // type ); pageLayout->addWidget(inputString); QStrListIterator sli=((ConfigEnum *)option)->iterator(); for (sli.toFirst();sli.current();++sli) { inputString->addValue(sli.current()); } inputString->init(); QWhatsThis::add(inputString, option->docs().simplifyWhiteSpace() ); QToolTip::add(inputString, option->docs()); connect(inputString,SIGNAL(changed()),SLOT(changed())); m_inputWidgets->insert(option->name(),inputString); addDependency(m_switches,option->dependsOn(),option->name()); } break; case ConfigOption::O_List: { ASSERT(page!=0); InputStrList::ListMode lm=InputStrList::ListString; switch(((ConfigList *)option)->widgetType()) { case ConfigList::String: lm=InputStrList::ListString; break; case ConfigList::File: lm=InputStrList::ListFile; break; case ConfigList::Dir: lm=InputStrList::ListDir; break; case ConfigList::FileAndDir: lm=InputStrList::ListFileDir; break; } InputStrList *inputStrList = new InputStrList( option->name(), // name page, // widget *((ConfigList *)option)->valueRef(), // variable lm // type ); pageLayout->addWidget(inputStrList); QWhatsThis::add(inputStrList, option->docs().simplifyWhiteSpace() ); QToolTip::add(inputStrList, option->docs()); connect(inputStrList,SIGNAL(changed()),SLOT(changed())); m_inputWidgets->insert(option->name(),inputStrList); addDependency(m_switches,option->dependsOn(),option->name()); } break; break; case ConfigOption::O_Bool: { ASSERT(page!=0); InputBool *inputBool = new InputBool( option->name(), // name page, // widget *((ConfigBool *)option)->valueRef() // variable ); pageLayout->addWidget(inputBool); QWhatsThis::add(inputBool, option->docs().simplifyWhiteSpace() ); QToolTip::add(inputBool, option->docs() ); connect(inputBool,SIGNAL(changed()),SLOT(changed())); m_inputWidgets->insert(option->name(),inputBool); addDependency(m_switches,option->dependsOn(),option->name()); } break; case ConfigOption::O_Int: { ASSERT(page!=0); InputInt *inputInt = new InputInt( option->name(), // name page, // widget *((ConfigInt *)option)->valueRef(), // variable ((ConfigInt *)option)->minVal(), // min value ((ConfigInt *)option)->maxVal() // max value ); pageLayout->addWidget(inputInt); QWhatsThis::add(inputInt, option->docs().simplifyWhiteSpace() ); QToolTip::add(inputInt, option->docs() ); connect(inputInt,SIGNAL(changed()),SLOT(changed())); m_inputWidgets->insert(option->name(),inputInt); addDependency(m_switches,option->dependsOn(),option->name()); } break; case ConfigOption::O_Obsolete: break; } } if (pageLayout) pageLayout->addStretch(1); QDictIterator<QObject> di(*m_switches); QObject *obj = 0; for (di.toFirst();(obj=di.current());++di) { connect(obj,SIGNAL(toggle(const char *,bool)),SLOT(toggle(const char *,bool))); // UGLY HACK: assumes each item depends on a boolean without checking! emit toggle(di.currentKey(),((InputBool *)obj)->getState()); } connect(this,SIGNAL(helpButtonPressed()),this,SLOT(handleHelp())); }