void CheckBoxImpl::setChecked(bool checked) { if (checked != m_checked) { m_checked = checked; emit checkedChanged(); } }
void DeleteItem::setChecked(bool arg) { if (m_checked != arg) { m_checked = arg; qDebug()<<"setChecked"<<getLocalName()<<m_checked; emit checkedChanged(arg); } }
/* Public Member Functions */ void CheckBox::fingerAdded(const FingerEventArgs &e) { UIElement::fingerAdded(e); isChecked = !isChecked; if(checkedChanged != NULL) { checkedChanged(isChecked); } }
void QuickSwitchButton::mouseReleaseEvent(QMouseEvent *e) { QLabel::mouseReleaseEvent(e); emit clicked(m_index); if (m_checkable) { setChecked(!m_checked); emit checkedChanged(m_checked); } }
void ToDoPapers::cleanAndRefresh() { while( !p->items.isEmpty() ) deleteItem(p->items.first()); const QString & text = p->text; int lastPos = 0; int pos = text.indexOf("\n",lastPos); while( pos != text.length() ) { if( pos == -1 ) pos = text.length(); const QString & str = text.mid(lastPos,pos-lastPos); const QString & slc = str.mid(0,2); bool checkable = (slc=="* " || slc=="- "); if( !checkable && !p->items.isEmpty() ) { p->signal_blocker = true; ToDoPapersItem *item = p->items.last(); item->setText( item->text() + "\n" + str ); p->signal_blocker = false; } else { ToDoPapersItem *item = new ToDoPapersItem(this); item->setCheckable(checkable); item->setText( checkable? str.mid(2) : str ); item->setChecked( slc=="* " ); connect( item, SIGNAL(textChanged()) , SLOT(refreshText()) ); connect( item, SIGNAL(checkedChanged()), SLOT(refreshText()) ); connect( item, SIGNAL(accepted(ToDoPapersItem*)) , SLOT(createItemAfter(ToDoPapersItem*)) ); connect( item, SIGNAL(removed(ToDoPapersItem*)) , SLOT(removeItem(ToDoPapersItem*)) ); connect( item, SIGNAL(removeNext(ToDoPapersItem*)), SLOT(removeNextItem(ToDoPapersItem*)) ); connect( item, SIGNAL(upPressed(ToDoPapersItem*)) , SLOT(focusOnUp(ToDoPapersItem*)) ); connect( item, SIGNAL(downPressed(ToDoPapersItem*)), SLOT(focusOnDown(ToDoPapersItem*)) ); p->items << item; p->base_layout->insertWidget(p->base_layout->count()-1,item); item->show(); } lastPos = pos+1; if( pos != text.length() ) pos = text.indexOf("\n",lastPos); } }
void ContentAction::setChecked( const bool value ) { if( !checkable_ || checked_ == value ) return; checked_ = value; emit checkedChanged(); if( checked_ ) emit checked(); else emit unchecked(); }
void DSwitchButton::setChecked(bool arg) { if (m_checked != arg) { m_checked = arg; if(arg){ m_innerAnimation->setStartValue(m_animationStartValue); m_innerAnimation->setEndValue(m_animationEndValue); }else{ m_innerAnimation->setStartValue(m_animationEndValue); m_innerAnimation->setEndValue(m_animationStartValue); } m_innerAnimation->start(); emit checkedChanged(arg); } }
void SpeedOutButton::mouseReleaseEvent(QMouseEvent *e) { if (e->button() != Qt::LeftButton) { e->ignore(); return; } if(rect().contains(e->pos())) { m_isChecked = !m_isChecked; setButtonStatus(BUTTON_ENTER); emit checkedChanged(m_isChecked); }else { setButtonStatus(BUTTON_LEAVE); } }
void ToDoPapers::createItemAfter(ToDoPapersItem *item) { int index = p->items.indexOf(item); if( index == -1 ) return; QString extra_text = item->text().mid(item->cursorPosition()); item->setText( item->text().mid(0,item->cursorPosition()) ); ToDoPapersItem *item_new = new ToDoPapersItem(this); item_new->setCheckable( true ); item_new->setChecked( false ); connect( item_new, SIGNAL(textChanged()) , SLOT(refreshText()) ); connect( item_new, SIGNAL(checkedChanged()), SLOT(refreshText()) ); connect( item_new, SIGNAL(accepted(ToDoPapersItem*)) , SLOT(createItemAfter(ToDoPapersItem*)) ); connect( item_new, SIGNAL(removed(ToDoPapersItem*)) , SLOT(removeItem(ToDoPapersItem*)) ); connect( item_new, SIGNAL(removeNext(ToDoPapersItem*)), SLOT(removeNextItem(ToDoPapersItem*)) ); connect( item_new, SIGNAL(upPressed(ToDoPapersItem*)) , SLOT(focusOnUp(ToDoPapersItem*)) ); connect( item_new, SIGNAL(downPressed(ToDoPapersItem*)), SLOT(focusOnDown(ToDoPapersItem*)) ); p->items << item_new; p->base_layout->insertWidget(p->base_layout->count()-1,item_new); p->signal_blocker = true; for( int i=p->items.count()-1; i>index+1; i-- ) { ToDoPapersItem *item_a = p->items.at(i); ToDoPapersItem *item_b = p->items.at(i-1); item_a->setCheckable( item_b->isCheckable() ); item_a->setText( item_b->text() ); item_a->setChecked( item_b->isChecked() ); } ToDoPapersItem *app_item = p->items.at(index+1); app_item->setCheckable( true ); app_item->setText( extra_text ); app_item->setChecked( false ); app_item->setTextFocus( true ); p->signal_blocker = false; refreshText(); }
void SwitchButton::mousePressEvent(QMouseEvent *) { checked = !checked; emit checkedChanged(checked); //每次移动的步长 step = width() / 10; //状态切换改变后自动计算终点坐标 if (checked) { if (buttonStyle == ButtonStyle_Rect) { endX = width() - width() / 2; } else if (buttonStyle == ButtonStyle_CircleIn) { endX = width() - height(); } else if (buttonStyle == ButtonStyle_CircleOut) { endX = width() - height(); } } else { endX = 0; } timer->start(); }