NumberEdit::NumberEdit(QWidget* parent): QLineEdit(parent) { setMinimumHeight(23); resize(200,23); //validator=new QMyDoubleValidator(this); setRange(-10,10); setDecimals(2); setSingleStep(1.0); suffix=""; //setValidator(validator); setValue(0); buttonUp=new QToolButton(this); buttonDown=new QToolButton(this); buttonUp->setIcon(QIcon(":/NumberEdit/btn_up.png")); buttonDown->setIcon(QIcon(":/NumberEdit/btn_down.png")); int bw=(int)floor((double)height()/2.0); buttonUp->resize(bw, bw); buttonUp->move(width()-bw, 0); buttonUp->setCursor(Qt::ArrowCursor); buttonUp->setFocusPolicy(Qt::NoFocus); QFont f=buttonUp->font(); f.setPointSizeF(f.pointSizeF()*0.85); buttonUp->setFont(f); buttonDown->setFont(f); buttonDown->resize(bw, bw+1); buttonDown->move(width()-bw, bw-1); buttonDown->setCursor(Qt::ArrowCursor); buttonDown->setFocusPolicy(Qt::NoFocus); connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(texttChanged(const QString&))); connect(this, SIGNAL(cursorPositionChanged(int,int)), this, SLOT(cursorChanged(int,int))); connect(buttonUp, SIGNAL(clicked()), this, SLOT(stepUp())); connect(buttonDown, SIGNAL(clicked()), this, SLOT(stepDown())); pal=palette(); palError=pal; palError.setColor(QPalette::Base, QColor("tomato")); }
HIC::QHSpinBox::QHSpinBox(double minValue,double maxValue,double initialValue,double step,QWidget * parent,const char * name):QWidget(parent,name) { m_min_value = minValue; m_max_value = maxValue; m_step = step; m_value = initialValue; m_leftbutton = new QPushButton("<<",this,"leftbutton"); m_leftbutton->setAutoRepeat(true); QObject::connect(m_leftbutton, SIGNAL(clicked()), this, SLOT(stepDown())); m_rightbutton = new QPushButton(">>",this,"rightbutton"); m_rightbutton->setAutoRepeat(true); QObject::connect(m_rightbutton ,SIGNAL(clicked()),this, SLOT(stepUp())); m_lineedit = new QLineEdit(QString::number(m_value),this,"lineedit"); m_lineedit->setMaximumSize(60,20); QObject::connect(m_lineedit, SIGNAL(returnPressed()), this, SLOT(returnPressed())); Q3HBoxLayout * layout = new Q3HBoxLayout(this,1,5,"hspinlayout"); layout->addWidget(m_leftbutton); layout->addWidget(m_lineedit); layout->addWidget(m_rightbutton); layout->setResizeMode(QLayout::SetFixedSize); }
void Tree::stepPriv(float v) { for(std::vector<Link*>::iterator l = links.begin(); l!=links.end();) { switch((*l)->state) { case Link::LS_NORMAL: (*l)->age++; break; case Link::LS_DIED: l = links.erase(l); continue; case Link::LS_CUTTING: { float linkCuttingStep = normalLinkCuttingStep * genus->linkFactor; if((*l)->length > linkCuttingStep) { (*l)->stepDown(linkCuttingStep); v += linkCuttingStep; } else { v += (*l)->length; delete (*l); l = links.erase(l); continue; } } break; } ++l; } int linkGrowingCount = 0, linkNormalCount = 0; for(std::vector<Link*>::iterator l = links.begin(); l!=links.end(); ++l) { switch((*l)->state) { case Link::LS_GROWING: linkGrowingCount++; break; case Link::LS_NORMAL: linkNormalCount++; break; } } float linkGrowingStep = normalLinkGrowingStep * genus->linkFactor; if(linkGrowingCount > 0) { float needForGroving = linkGrowingCount * linkGrowingStep; if(needForGroving > v + coma.getLength() + root.getLength()) { for(std::vector<Link*>::iterator l = links.begin(); l!=links.end(); ++l) if((*l)->state == Link::LS_GROWING) (*l)->cut(); } else { for(std::vector<Link*>::iterator l = links.begin(); l!=links.end(); ++l) if((*l)->state == Link::LS_GROWING) { (*l)->stepUp(linkGrowingStep); v -= linkGrowingStep; } } } float cl = coma.getLength(); if(cl<EPSILON) { int cutCount = 0; if(linkGrowingCount>0) for(std::vector<Link*>::iterator l = links.begin(); l!=links.end(); ++l) { if((*l)->state == Link::LS_GROWING) { (*l)->cut(); cutCount++; } } else if(linkNormalCount>0) for(std::vector<Link*>::iterator l = links.begin(); l!=links.end(); ++l) { if((*l)->state == Link::LS_NORMAL) { (*l)->cut(); cutCount++; } } if(cutCount>0) planet->playFX(SND_WEAK_TREE); } if(absf(v) < EPSILON) return; if(v>0) { if(cl<EPSILON) { v *= 0.5f; root.stepUp(v); coma.stepUp(v); return; } stepUp(v); } else { stepDown(-v); } }
void MainWindow::buildToolBar() { m_fileToolBar = addToolBar("File Tool Bar"); m_fileToolBar->setMovable(true); QAction * newSystemAction = new QAction(QIcon("Icons/New.png"), "New", this); connect(newSystemAction, SIGNAL(triggered()), m_system, SLOT(newSystem())); QAction * openSystemAction = new QAction(QIcon("Icons/Open.png"), "Open", this); connect(openSystemAction, SIGNAL(triggered()), m_system, SLOT(openSystem())); QAction * saveSystemAction = new QAction(QIcon("Icons/Save.png"), "Save", this); connect(saveSystemAction, SIGNAL(triggered()), m_system, SLOT(saveSystem())); QAction * saveSystemAsAction = new QAction(QIcon("Icons/SaveAs.png"), QString::fromUtf8("Save As\u2026"), this); saveSystemAsAction->setIconText("AA"); connect(saveSystemAsAction, SIGNAL(triggered()), m_system, SLOT(saveSystemAs())); m_fileToolBar->addAction(newSystemAction); m_fileToolBar->addAction(openSystemAction); m_fileToolBar->addAction(saveSystemAction); m_fileToolBar->addAction(saveSystemAsAction); m_deviceToolBar = addToolBar("Device Tool Bar"); m_deviceToolBar->setMovable(true); QAction * addPlaneMirrorAction = new QAction(QIcon("Icons/PlaneMirror.png"), "Add Plane Mirror", this); connect(addPlaneMirrorAction, SIGNAL(triggered()), m_system, SLOT(addPlaneMirror())); QAction * addConcaveMirrorAction = new QAction(QIcon("Icons/ConcaveMirror.png"), "Add Concave Mirror", this); connect(addConcaveMirrorAction, SIGNAL(triggered()), m_system, SLOT(addConcaveMirror())); QAction * addDiffractionGratingAction = new QAction(QIcon("Icons/DiffractionGrating.png"), "Add Diffraction Grating", this); connect(addDiffractionGratingAction, SIGNAL(triggered()), m_system, SLOT(addDiffractionGrating())); QAction * addSlitAction = new QAction(QIcon("Icons/Slit.png"), "Add Slit", this); connect(addSlitAction, SIGNAL(triggered()), m_system, SLOT(addSlit())); QAction * addPointSourceAction = new QAction(QIcon("Icons/PointSource.png"), "Add Point Source", this); connect(addPointSourceAction, SIGNAL(triggered()), m_system, SLOT(addPointSource())); QAction * removeReflectorAction = new QAction(QIcon("Icons/RemoveReflector.png"), "Remove Reflector", this); connect(removeReflectorAction, SIGNAL(triggered()), m_system, SLOT(removeReflector())); QAction * removeLightSourceAction = new QAction(QIcon("Icons/RemoveLightSource.png"), "Remove Light Source", this); connect(removeLightSourceAction, SIGNAL(triggered()), m_system, SLOT(removeLightSource())); m_deviceToolBar->addAction(addPlaneMirrorAction); m_deviceToolBar->addAction(addConcaveMirrorAction); m_deviceToolBar->addAction(addDiffractionGratingAction); m_deviceToolBar->addAction(addSlitAction); m_deviceToolBar->addSeparator(); m_deviceToolBar->addAction(addPointSourceAction); m_deviceToolBar->addSeparator(); m_deviceToolBar->addAction(removeReflectorAction); m_deviceToolBar->addAction(removeLightSourceAction); m_zoomToolBar = addToolBar("Zoom Tool Bar"); m_zoomToolBar->setMovable(true); ZoomWidget * zoomWidget = new ZoomWidget(this); connect(zoomWidget, SIGNAL(valueChanged(int)), m_system, SLOT(zoom(int))); m_zoomToolBar->addAction(QIcon("Icons/ZoomIn.png"), "Zoom In", zoomWidget, SLOT(stepUp())); m_zoomToolBar->addWidget(zoomWidget); m_zoomToolBar->addAction(QIcon("Icons/ZoomOut.png"), "Zoom Out", zoomWidget, SLOT(stepDown())); }
void btKinematicCharacterController::playerStep( btCollisionWorld* collisionWorld, btScalar dt ) { BT_PROFILE( "playerStep" ); if( !m_useWalkDirection && m_velocityTimeInterval <= btScalar( 0.0 ) ) return; bool wasOnGround = onGround(); // Handle the gravity // m_verticalVelocity -= m_gravity * dt; if( m_verticalVelocity > 0.0 && m_verticalVelocity > m_jumpSpeed ) m_verticalVelocity = m_jumpSpeed; if( m_verticalVelocity < 0.0 && btFabs( m_verticalVelocity ) > btFabs( m_fallSpeed ) ) m_verticalVelocity = -btFabs( m_fallSpeed ); m_verticalOffset = m_verticalVelocity * dt; // This forced stepping up can cause problems when the character // walks (jump in fact...) under too low ceilings. // btVector3 currentPosition = externalGhostObject->getWorldTransform().getOrigin(); btScalar currentStepOffset; currentPosition = stepUp( collisionWorld, currentPosition, currentStepOffset ); // Move in the air and slide against the walls ignoring the stair steps. // if( m_useWalkDirection ) currentPosition = stepForwardAndStrafe( collisionWorld, currentPosition, m_walkDirection ); else { btScalar dtMoving = ( dt < m_velocityTimeInterval ) ? dt : m_velocityTimeInterval; m_velocityTimeInterval -= dt; // How far will we move while we are moving ? // btVector3 moveDirection = m_walkDirection * dtMoving; currentPosition = stepForwardAndStrafe( collisionWorld, currentPosition, moveDirection ); } // Finally find the ground. // currentStepOffset = addFallOffset( wasOnGround, currentStepOffset, dt ); currentPosition = stepDown( collisionWorld, currentPosition, currentStepOffset ); // Apply the new position to the collision objects. // btTransform tranform; tranform = externalGhostObject->getWorldTransform(); tranform.setOrigin( currentPosition ); externalGhostObject->setWorldTransform( tranform ); internalGhostObject->setWorldTransform( tranform ); }
// Initialise Toolbar, Menus ScrollBar and other void ktvschedule::init() { // Creates central widgets tvgridbox = new QGroupBox ( this ); // Group box tvgridbox->setInsideMargin ( 15 ); t_TVGrid=new TvGuideTable(this->tvgridbox, "t_TVGrid"); // Add TvGuideTable custom QTable QGridLayout *tvgridboxLayout = new QGridLayout( tvgridbox->layout() ); //Layout tvgridboxLayout->setAlignment ( Qt::AlignTop ); tvgridboxLayout->addWidget ( t_TVGrid , 0 , 0 ); setCentralWidget( tvgridbox ); tvgridbox->show(); //////////////////////////////// //Check for home directory, if it does not exist, create it QString qstr(QDir::homeDirPath()+"/.kde/share/apps/ktvschedule"); //for some reason this only works with gcc 3.3 and not the previous version QDir d(qstr); if ( !d.exists() ) { d.mkdir(qstr); } /*QDir d( QString(QDir::homeDirPath()+"/.kde/share/apps/ktvschedule") ); if ( !d.exists() ) { d.mkdir(QString(QDir::homeDirPath()+"/.kde/share/apps/ktvschedule")); }*/ // This worked for gcc 3.4 but not for 3.3 //setRightJustification( TRUE ); //////////////////////////////// this->setIcon( KGlobal::iconLoader()->loadIcon("ktvschedule", KIcon::Desktop) ); // Creates the ToolBar KToolBar * TvToolBar = new KToolBar( this, KMainWindow::Top ); ////////////////////////////// // Creates a QDateEdit Widget for future use date_show = new QDateEdit( QDate::currentDate() , TvToolBar ); date_show->setOrder(QDateEdit::DMY); //////////////////////////////// // Define KActions //KAction *actionGoHome = new KAction ( "Now Playing", KGlobal::iconLoader()->loadIcon("gohome", KIcon::NoGroup), CTRL+Key_P , t_TVGrid, SLOT (SetToCurrentTime() ), collector, "Now Playing"); KAction *actionGoHome = new KAction ( i18n("Now &Playing"), "gohome", CTRL+Key_P , this, SLOT (SetToCurrentTime() ), actionCollection(), "Now Playing"); KAction *actionRefreshGuide = new KAction ( i18n("&Refresh Guide"), "reload", CTRL+Key_R , this, SLOT (RefreshXMLGuide() ), actionCollection(), "Refresh Guide"); KAction *actionManageChannels = new KAction ( i18n("&Manage Channels"), "toggle_log", CTRL+Key_M , this, SLOT (channelList() ), actionCollection(), "Manage Channels"); KAction *actionConfigure = new KAction ( i18n("&Configure"), "configure", CTRL+Key_C , this, SLOT (runConfig() ), actionCollection(), "Configure"); KAction *actionExit = KStdAction::quit(this, SLOT(close()), 0); KAction *actionPrevious = new KAction ( i18n("Pre&vious Day"), "previous", CTRL+Key_V , date_show, SLOT ( stepDown() ), actionCollection(), "PreviousDay"); KAction *actionNext = new KAction ( i18n("&Next Day"), "forward", CTRL+Key_N , date_show, SLOT ( stepUp() ), actionCollection(), "NextDay"); KAction *actionEvent = KStdAction::configureNotifications(this, SLOT( notificationsEvent() ), actionCollection(), "settings_notifications" ); KAction *actionFindCategory = new KAction (i18n("&Find Next Show"), "find", CTRL+Key_F , this, SLOT( findNextCategory() ), actionCollection(), "findnextshow"); ////////////////////////////////// // Plug actions to ToolBar actionGoHome->plug ( TvToolBar); actionRefreshGuide->plug (TvToolBar); actionExit->plug (TvToolBar); TvToolBar->insertLineSeparator(); actionManageChannels->plug (TvToolBar); actionConfigure->plug (TvToolBar); TvToolBar->insertLineSeparator(); actionPrevious->plug (TvToolBar); // Add a QDateEdit widget for the ToolBar TvToolBar->insertWidget (actionCollection()->count()+1,13, date_show ); actionNext->plug (TvToolBar); // Creates the KComboBox and adds it to the Toolbar combo_Categories = new KComboBox(TvToolBar); combo_Categories->setMinimumWidth( combo_Categories->width ()+60); combo_Categories->insertStringList(Categories); TvToolBar->insertWidget (actionCollection()->count()+1,15, combo_Categories); actionFindCategory->plug (TvToolBar); ////////////////////////////////// // Create menus KPopupMenu *menuGrid = new KPopupMenu( this ); KPopupMenu *menuConf = new KPopupMenu( this ); menuBar()->insertItem( i18n("&Grid"), menuGrid ); menuBar()->insertItem( i18n("&Configure"), menuConf ); // Plug KActions to menus actionGoHome->plug(menuGrid); actionRefreshGuide->plug(menuGrid); actionExit->plug(menuGrid); actionManageChannels->plug(menuConf); actionConfigure->plug(menuConf); actionEvent->plug(menuConf); KAboutData *_aboutData = new KAboutData("kTvSchedule", I18N_NOOP("KTvSchedule"), "0.1.8", I18N_NOOP("TV Schedule.\n\n" "KDE Front end for TV Schedule programs.\n" "created by xmltv (tv_grab_xx)"), KAboutData::License_GPL, "(c) 2005, Alexios Beveratos",0,"http://www.kde-apps.org/content/show.php?content=22747","*****@*****.**"); _aboutData->addAuthor("Alexios Beveratos", I18N_NOOP("Main Developper"), "*****@*****.**"); _aboutData->addAuthor("Benoit Philipps",0,"*****@*****.**"); //_aboutData->setHomepage("http://www.kde-apps.org/content/show.php?content=22747"); //_aboutData->setBugAddress("http://developer.berlios.de/projects/ktvschedule/"); KHelpMenu *HelpMenu = new KHelpMenu( this, _aboutData ); menuBar()->insertItem(i18n("&Help"), HelpMenu->menu() ); ////////////////////////////////// // Creates StatusBar StatusBar = this->statusBar(); led = new KLed(QColor ("#2EBB16"), KLed::On, KLed::Raised, KLed::Circular); StatusBar->addWidget ( led, 0, TRUE ); ////////////////////////////////// // Other Initialisations date_show->setDate(QDate::currentDate ()); date_show->setOrder(QDateEdit::DMY); FirstInput=QDate::currentDate(); LastInput=QDate::currentDate(); ////////////////////////////////// //Add connections connect( date_show, SIGNAL( valueChanged(const QDate&) ), this, SLOT( PopulateTvGrid() ) ); //connect( combo_Categories, SIGNAL( activated(const QString &)),t_TVGrid,SLOT( highlightCategory(const QString& ))); connect( combo_Categories, SIGNAL( activated(const QString &)),this,SLOT( highlightCategory(const QString& ))); // Creates the scheduler class, and connects it. can be made better tvShowScheduler= new tvscheduler(); connect( t_TVGrid, SIGNAL (infoContext(TvItem*) ), tvShowScheduler, SLOT (doNotMiss(TvItem*) ) ); connect( t_TVGrid, SIGNAL (recordProgramSignal(TvItem* ) ), tvShowScheduler, SLOT (recordProgram(TvItem* ) ) ); ///////////////////////////////// //If we use nxtvepg then disable some buttons if (Config().m_GrabberToUse == "nxtvepg") { actionRefreshGuide->setEnabled(FALSE); actionManageChannels->setEnabled(FALSE); } }