void MainWindow::DisplayImage(cv::Mat matImage,int SrcOrDst) { //不能使用image=matImage,会影响matImage,进而影响ingSRC cv::Mat image; matImage.copyTo(image);//创建新的拷贝 QLabel *labelImage; QLabel *labelImageInfos; int W_Img = image.cols; int H_Img = image.rows; int N_Channels = image.channels(); if(SrcOrDst==0) { labelSrcImgTitle->setText("源图像"); labelImage = labelSrcImg; labelImageInfos = labelSrcImgInfos; labelSrcImgPath->setText("原始图像路径:"+pathSrcImg); } else { labelDstImgTitle->setText("目标图像"); labelImage = labelDstImg; labelImageInfos = labelDstImgInfos; } int W_LabelImg = labelImage->width(); int H_LabelImg = labelImage->height(); //显示图像信息 labelImageInfos->setText("宽度:" + QString::number(W_Img) + ",高度:" + QString::number(H_Img) + ",通道数:" + QString::number(N_Channels)); //根据显示图像的label大小改变图像尺寸 if(W_Img>W_LabelImg && H_Img<=H_LabelImg) { cv::resize(image,image, cv::Size(W_LabelImg,H_Img/((float)W_Img/W_LabelImg))); } else if(W_Img<=W_LabelImg && H_Img>H_LabelImg) { cv::resize(image,image, cv::Size(W_Img/((float)H_Img/H_LabelImg),H_LabelImg)); } else if(W_Img>W_LabelImg && H_Img>H_LabelImg) { if(W_LabelImg>=H_LabelImg) { if(W_Img<=H_Img) { cv::resize(image,image, cv::Size(W_Img/((float)H_Img/H_LabelImg),H_LabelImg)); } else { if(W_Img/(float)H_Img >= W_LabelImg/(float)H_LabelImg) { cv::resize(image,image, cv::Size(W_LabelImg,H_Img/((float)W_Img/W_LabelImg))); } else { cv::resize(image,image, cv::Size(W_Img/((float)H_Img/H_LabelImg),H_LabelImg)); } } } else { if(W_Img>=H_Img) { cv::resize(image,image, cv::Size(W_LabelImg,H_Img/((float)W_Img/W_LabelImg))); } else { if(H_Img/(float)W_Img <= H_LabelImg/(float)W_LabelImg) { cv::resize(image,image, cv::Size(W_LabelImg,H_Img/((float)W_Img/W_LabelImg))); } else { cv::resize(image,image, cv::Size(W_Img/((float)H_Img/H_LabelImg),H_LabelImg)); } } } } QImage qImg; if(image.type() == CV_8UC3) { cv::cvtColor(image,image,CV_BGR2RGB); qImg = QImage((const unsigned char*)(image.data), image.cols,image.rows, image.cols*image.channels(), QImage::Format_RGB888); } if(image.type() == CV_8UC1)// 8-bits unsigned, NO. OF CHANNELS = 1 { qImg = QImage(image.cols, image.rows, QImage::Format_Indexed8); // Set the color table (used to translate colour indexes to qRgb values) qImg.setColorCount(256); for(int i = 0; i < 256; i++) { qImg.setColor(i, qRgb(i, i, i)); } // Copy input image uchar *pSrc = image.data; for(int row = 0; row < image.rows; row ++) { uchar *pDest = qImg.scanLine(row); memcpy(pDest, pSrc, image.cols); pSrc += image.step; } } labelImage->setPixmap(QPixmap::fromImage(qImg)); //labelImage->resize(labelImage->pixmap()->size()); }
void BaseWindow::displayAttack() { PublicPlayerMonster * otherMonster=CatchChallenger::ClientFightEngine::fightEngine.getOtherMonster(); PublicPlayerMonster * currentMonster=CatchChallenger::ClientFightEngine::fightEngine.getCurrentMonster(); if(otherMonster==NULL) { error("displayAttack(): crash: unable to get the other monster to display an attack"); doNextAction(); return; } if(currentMonster==NULL) { newError(tr("Internal error")+", file: "+QString(__FILE__)+":"+QString::number(__LINE__),"displayAttack(): crash: unable to get the current monster"); doNextAction(); return; } if(CatchChallenger::ClientFightEngine::fightEngine.getAttackReturnList().isEmpty()) { newError(tr("Internal error")+", file: "+QString(__FILE__)+":"+QString::number(__LINE__),"displayAttack(): crash: display an empty attack return"); doNextAction(); return; } if( CatchChallenger::ClientFightEngine::fightEngine.getAttackReturnList().first().lifeEffectMonster.empty() && CatchChallenger::ClientFightEngine::fightEngine.getAttackReturnList().first().buffLifeEffectMonster.empty() && CatchChallenger::ClientFightEngine::fightEngine.getAttackReturnList().first().addBuffEffectMonster.empty() && CatchChallenger::ClientFightEngine::fightEngine.getAttackReturnList().first().removeBuffEffectMonster.empty() && CatchChallenger::ClientFightEngine::fightEngine.getAttackReturnList().first().success ) { qDebug() << QStringLiteral("displayAttack(): strange: display an empty lifeEffect list into attack return, attack: %1, doByTheCurrentMonster: %2, success: %3") .arg(CatchChallenger::ClientFightEngine::fightEngine.getAttackReturnList().first().attack) .arg(CatchChallenger::ClientFightEngine::fightEngine.getAttackReturnList().first().doByTheCurrentMonster) .arg(CatchChallenger::ClientFightEngine::fightEngine.getAttackReturnList().first().success); CatchChallenger::ClientFightEngine::fightEngine.removeTheFirstAttackReturn(); doNextAction(); return; } //if start, display text if(displayAttackProgression==0) { updateAttackTime.restart(); if(!displayFirstAttackText(true)) return; } const Skill::AttackReturn &attackReturn=CatchChallenger::ClientFightEngine::fightEngine.getFirstAttackReturn(); //get the life effect to display Skill::LifeEffectReturn lifeEffectReturn; if(!attackReturn.lifeEffectMonster.empty()) lifeEffectReturn=attackReturn.lifeEffectMonster.front(); else if(!attackReturn.buffLifeEffectMonster.empty()) lifeEffectReturn=attackReturn.buffLifeEffectMonster.front(); else { newError(tr("Internal error")+", file: "+QString(__FILE__)+":"+QString::number(__LINE__),QStringLiteral("displayAttack(): strange: nothing to display, lifeEffectMonster.size(): %1, buffLifeEffectMonster.size(): %2, addBuffEffectMonster.size(): %3, removeBuffEffectMonster.size(): %4, AttackReturnList: %5") .arg(attackReturn.lifeEffectMonster.size()) .arg(attackReturn.buffLifeEffectMonster.size()) .arg(attackReturn.addBuffEffectMonster.size()) .arg(attackReturn.removeBuffEffectMonster.size()) .arg(CatchChallenger::ClientFightEngine::fightEngine.getAttackReturnList().size())); CatchChallenger::ClientFightEngine::fightEngine.removeTheFirstAttackReturn(); //doNextAction(); return; } bool applyOnOtherMonster=false; if(attackReturn.doByTheCurrentMonster) { if((lifeEffectReturn.on==ApplyOn_AloneEnemy) || (lifeEffectReturn.on==ApplyOn_AllEnemy)) applyOnOtherMonster=true; } else { if((lifeEffectReturn.on==ApplyOn_Themself) || (lifeEffectReturn.on==ApplyOn_AllAlly)) applyOnOtherMonster=true; } QLabel * attackMovie; if(applyOnOtherMonster) attackMovie=ui->labelFightMonsterAttackTop; else attackMovie=ui->labelFightMonsterAttackBottom; //attack animation { uint32_t attackId=attackReturn.attack; QString skillAnimation=DatapackClientLoader::datapackLoader.getDatapackPath()+QStringLiteral(DATAPACK_BASE_PATH_SKILLANIMATION); QString fileAnimation=skillAnimation+QStringLiteral("%1.mng").arg(attackId); if(QFile(fileAnimation).exists()) { movie=new QMovie(fileAnimation,QByteArray(),attackMovie); movie->setScaledSize(QSize(attackMovie->width(),attackMovie->height())); if(movie->isValid()) { attackMovie->setMovie(movie); movie->start(); } else qDebug() << QStringLiteral("movie loaded is not valid for: %1").arg(fileAnimation); } else { QString fileAnimation=skillAnimation+QStringLiteral("%1.gif").arg(attackId); if(QFile(fileAnimation).exists()) { movie=new QMovie(fileAnimation,QByteArray(),attackMovie); movie->setScaledSize(QSize(attackMovie->width(),attackMovie->height())); if(movie->isValid()) { attackMovie->setMovie(movie); movie->start(); } else qDebug() << QStringLiteral("movie loaded is not valid for: %1").arg(fileAnimation); } } } if(displayAttackProgression%100 /* each 400ms */ && attack_quantity_changed<0) { if(applyOnOtherMonster) { if(updateAttackTime.elapsed()<2000 /* 2000ms */) ui->labelFightMonsterTop->setVisible(!ui->labelFightMonsterTop->isVisible()); } else { if(updateAttackTime.elapsed()<2000 /* 2000ms */) ui->labelFightMonsterBottom->setVisible(!ui->labelFightMonsterBottom->isVisible()); } } if(updateAttackTime.elapsed()>2000) { ui->labelFightMonsterBottom->setVisible(true); ui->labelFightMonsterTop->setVisible(true); if(movie!=NULL) { movie->stop(); delete movie; } movie=NULL; ui->labelFightMonsterAttackTop->setMovie(NULL); ui->labelFightMonsterAttackBottom->setMovie(NULL); } int hp_to_change; if(applyOnOtherMonster) hp_to_change=ui->progressBarFightTopHP->maximum()/200;//0.5% else hp_to_change=ui->progressBarFightBottomHP->maximum()/200;//0.5% if(hp_to_change==0) hp_to_change=1; if(updateAttackTime.elapsed()>3000 /*3000ms*/) { //only if passe here before have updated all the stats { int hp_to_change; if(applyOnOtherMonster) hp_to_change=ui->progressBarFightTopHP->maximum(); else hp_to_change=ui->progressBarFightBottomHP->maximum(); if(attackReturn.lifeEffectMonster.empty()) hp_to_change=0; else if(attackReturn.lifeEffectMonster.front().quantity!=0) hp_to_change=attackReturn.lifeEffectMonster.front().quantity; else hp_to_change=0; if(hp_to_change!=0) { CatchChallenger::ClientFightEngine::fightEngine.firstLifeEffectQuantityChange(-hp_to_change); if(applyOnOtherMonster) { ui->progressBarFightTopHP->setValue(ui->progressBarFightTopHP->value()+hp_to_change); ui->progressBarFightTopHP->repaint(); } else { ui->progressBarFightBottomHP->setValue(ui->progressBarFightBottomHP->value()+hp_to_change); ui->progressBarFightBottomHP->repaint(); ui->labelFightBottomHP->setText(QStringLiteral("%1/%2").arg(ui->progressBarFightBottomHP->value()).arg(ui->progressBarFightBottomHP->maximum())); } } } displayAttackProgression=0; attack_quantity_changed=0; if(!attackReturn.lifeEffectMonster.empty()) CatchChallenger::ClientFightEngine::fightEngine.removeTheFirstLifeEffectAttackReturn(); else CatchChallenger::ClientFightEngine::fightEngine.removeTheFirstBuffEffectAttackReturn(); if(!CatchChallenger::ClientFightEngine::fightEngine.firstAttackReturnHaveMoreEffect()) { #ifdef CATCHCHALLENGER_DEBUG_FIGHT { qDebug() << "after display attack: currentMonster have hp" << ui->progressBarFightBottomHP->value() << "and buff" << ui->bottomBuff->count(); qDebug() << "after display attack: otherMonster have hp" << ui->progressBarFightTopHP->value() << "and buff" << ui->topBuff->count(); } #endif CatchChallenger::ClientFightEngine::fightEngine.removeTheFirstAttackReturn(); } //attack is finish doNextAction(); } else { if(attackReturn.lifeEffectMonster.empty()) hp_to_change=0; else if(attackReturn.lifeEffectMonster.front().quantity<0) { hp_to_change=-hp_to_change; if(abs(hp_to_change)>abs(attackReturn.lifeEffectMonster.front().quantity)) hp_to_change=attackReturn.lifeEffectMonster.front().quantity; } else if(attackReturn.lifeEffectMonster.front().quantity>0) { if(hp_to_change>attackReturn.lifeEffectMonster.front().quantity) hp_to_change=attackReturn.lifeEffectMonster.front().quantity; } else hp_to_change=0; if(hp_to_change!=0) { CatchChallenger::ClientFightEngine::fightEngine.firstLifeEffectQuantityChange(-hp_to_change); if(applyOnOtherMonster) { ui->progressBarFightTopHP->setValue(ui->progressBarFightTopHP->value()+hp_to_change); ui->progressBarFightTopHP->repaint(); } else { ui->progressBarFightBottomHP->setValue(ui->progressBarFightBottomHP->value()+hp_to_change); ui->progressBarFightBottomHP->repaint(); ui->labelFightBottomHP->setText(QStringLiteral("%1/%2").arg(ui->progressBarFightBottomHP->value()).arg(ui->progressBarFightBottomHP->maximum())); } } displayAttackTimer.start(); displayAttackProgression++; } }
void UIShowPanel::setTvShow( TVShow *tvshow ) { if( tvshow != NULL ) { this->destroyShowUI(); this->tvshow = tvshow; this->show_status->setText( this->engineLanguage->get( "translation.status" ) + " " + tvshow->getStatus() ); this->show_status->adjustSize(); this->show_started->setText( this->engineLanguage->get( "translation.started" ) + " " + tvshow->getStarted() ); this->show_started->adjustSize(); this->show_ended->setText( this->engineLanguage->get( "translation.ended" ) + " " + tvshow->getEnded() ); this->show_ended->adjustSize(); this->show_country->setText( this->engineLanguage->get( "translation.country" ) + " " + tvshow->getCountry() ); this->show_country->adjustSize(); this->optionsPanel->setTVShow( tvshow ); this->title->setText( this->tvshow->getName() ); this->title->adjustSize(); this->categorie->setText( this->tvshow->getCategory() ); int i, size = this->stars.size(); for( i = 0; i < size; i++ ) { if( i < this->tvshow->getStars() ) stars.at(i)->setPixmap( *this->enginePicture->getPicture( PICTURE_STAR_FULL ) ); } const vector< vector<Episode*> > *showSeasons = tvshow->getSeasons(); size = showSeasons->size(); int top = 0, space = 3; for( i = size - 1; i >= 0; i-- ) { QLabel *season = new QLabel( this->engineLanguage->get( "translation.season" ) + " " + QString::number( i + 1 ), this->moveConteneur ); season->setFixedWidth( 430 ); season->setStyleSheet( "background-color: #1D1D1D; border-radius: 8px; padding-left: 10px; color: #ECECEC;" ); season->move( 0, top ); int j, sizeEpisode = showSeasons->at(i).size(); for( j = sizeEpisode - 1; j >= 0; j-- ) { Episode *episode = showSeasons->at(i).at(j); JLabel *labelEpisode = new JLabel( this->moveConteneur ); labelEpisode->setText( this->engineLanguage->get( "translation.episode" ) + " " + QString::number( j + 1 ) + ": " + episode->getName() + " - " + episode->getDate().toString() ); labelEpisode->setStyleSheet( "padding-left: 2px;" ); labelEpisode->setNormalHoverStyle( "padding-left: 2px;", "background-color: #D1D1D1; border-radius: 5px; padding-left: 2px;" ); labelEpisode->adjustSize(); labelEpisode->setFixedWidth( 400 ); labelEpisode->setToolTip( episode->getName() + " - " + episode->getDate().toString() ); JLabel *check = NULL; if( tvshow->isAfterLast( i + 1, j + 1 ) != 2 ) // Do we need checkbox ? { check = new JLabel( this->moveConteneur ); if( tvshow->getEpisode( i + 1, j + 1 )->isSaw() ) // Episode already saw check->setPixmap( *this->enginePicture->getPicture( PICTURE_CHECK ) ); else check->setPixmap( *this->enginePicture->getPicture( PICTURE_UNCHECK ) ); this->checks.push_back( check ); } if( j != 0 ) { QLabel *separator = new QLabel( this->moveConteneur ); separator->setStyleSheet( "background-color: #C4C4C4;" ); separator->setFixedSize( 400, 1 ); this->separators.push_back( separator ); top += labelEpisode->height() + separator->height() + space * 2; labelEpisode->move( 20, top ); separator->move( 20, labelEpisode->pos().y() + labelEpisode->height() + space ); } else { top += labelEpisode->height() + space * 2; labelEpisode->move( 20, top ); top += 30; } if( check != NULL ) check->move( 0, labelEpisode->pos().y() ); this->episodes.push_back( labelEpisode ); } this->seasons.push_back( season ); } this->moveConteneur->adjustSize(); this->listConteneur->adjustSize(); } else cout << "WARNING: Try to set an NULL show - void UIShowPanel::setTvShow( TVShow *tvshow )" << endl; }
TrayNotificationWidget::TrayNotificationWidget(QPixmap pixmapIcon, QString headerText, QString messageText) : QWidget(0) { setWindowFlags( #ifdef Q_OS_MAC Qt::SubWindow | // This type flag is the second point #else Qt::Tool | #endif Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowStaysOnTopHint ); setAttribute(Qt::WA_NoSystemBackground, true); // set the parent widget's background to translucent setAttribute(Qt::WA_TranslucentBackground, true); //setAttribute(Qt::WA_ShowWithoutActivating, true); setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); // create a display widget for displaying child widgets QWidget* displayWidget = new QWidget; displayWidget->setStyleSheet(".QWidget { background-color: rgba(0, 0, 0, 75%); border-width: 1px; border-style: solid; border-radius: 10px; border-color: #555555; } .QWidget:hover { background-color: rgba(68, 68, 68, 75%); border-width: 2px; border-style: solid; border-radius: 10px; border-color: #ffffff; }"); QLabel* icon = new QLabel; icon->setPixmap(pixmapIcon); icon->setMaximumSize(32, 32); QLabel* header = new QLabel; header->setMaximumSize(250, 50); header->setWordWrap(true); header->setText(headerText); header->setStyleSheet("QLabel { color: #ffffff; font-weight: bold; font-size: 12px; }"); QTextEdit *message = new QTextEdit; message->setReadOnly(true); message->setFrameStyle(QFrame::NoFrame); message->setLineWrapMode(QTextEdit::WidgetWidth); message->setWordWrapMode(QTextOption::WrapAnywhere); QPalette pal = palette(); pal.setColor(QPalette::Base, Qt::transparent); message->setPalette(pal); message->setStyleSheet("QTextEdit { color: #ffffff; font-size: 10px; }"); message->setText(messageText); message->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); QVBoxLayout* vl = new QVBoxLayout; vl->addWidget(header); vl->addWidget(message); QHBoxLayout* displayMainLayout = new QHBoxLayout; displayMainLayout->addWidget(icon); displayMainLayout->addLayout(vl); displayWidget->setLayout(displayMainLayout); QHBoxLayout* containerLayout = new QHBoxLayout; containerLayout->addWidget(displayWidget); setLayout(containerLayout); show(); setMinimumHeight((int)(message->document()->size().height() *1.5 + header->height() +70)); timeout = new QTimer(this); connect(timeout, SIGNAL(timeout()), this, SLOT(fadeOut())); timeout->start(3000); }
/////////////////////////////////////////////////////////// // Function type: Virtual // Contributors: Pokedude // Last edit by: Pokedude // Date of edit: 8/25/2016 // /////////////////////////////////////////////////////////// bool MovePermissionListener::eventFilter(QObject *o, QEvent *event) { QLabel *obj = dynamic_cast<QLabel *>(o); if (event->type() == QEvent::MouseButtonPress) { QMouseEvent *me = reinterpret_cast<QMouseEvent *>(event); int mouseX = me->pos().x(); int mouseY = me->pos().y(); if (mouseX < 0 || mouseY < 0 || mouseX >= obj->width() || mouseY >= obj->height() || me->buttons() != Qt::MouseButton::LeftButton) { return QObject::eventFilter(o, event); } m_ShowCursor = false; m_Selecting = true; // Align the position to a block mouseX /= 16; mouseY /= 16; // Sets the position m_SelectedIndex = mouseX + (mouseY * 4); obj->repaint(); // Simulates mouse button press on label return QObject::eventFilter(o, event); } if (event->type() == QEvent::MouseButtonRelease) { m_ShowCursor = true; m_Selecting = false; } else if (event->type() == QEvent::MouseMove) { QMouseEvent *me = reinterpret_cast<QMouseEvent *>(event); int mouseX = me->pos().x(); int mouseY = me->pos().y(); if (mouseX < 0) mouseX = 0; if (mouseY < 0) mouseY = 0; if (mouseX >= obj->width()) mouseX = obj->width() - 1; if (mouseY >= obj->height()) mouseY = obj->height() - 1; if (!m_Selecting) m_ShowCursor = true; // Align the position to a block mouseX /= 16; mouseY /= 16; // Sets the position if (m_HighlightedBlock != mouseX + (mouseY * 4)) { m_HighlightedBlock = mouseX + (mouseY * 4); if (m_Selecting) m_SelectedIndex = m_HighlightedBlock; obj->repaint(); } // Simulates mouse button press on label return QObject::eventFilter(o, event); } else if (event->type() == QEvent::Leave) { m_ShowCursor = false; } else if (event->type() == QEvent::Paint/* && m_SelectedIndex.first != -1 && m_SelectedIndex.second != -1*/) { bool result = QObject::eventFilter(o, event); QPixmap pm(":/images/Permissions_16x16.png"); QPainter painter(&pm); painter.setPen(Qt::GlobalColor::red); painter.drawRect((m_SelectedIndex % 4) * 16, (m_SelectedIndex / 4) * 16, 15, 15); if (m_ShowCursor) { painter.setPen(Qt::GlobalColor::green); painter.drawRect((m_HighlightedBlock % 4) * 16, (m_HighlightedBlock / 4) * 16, 15, 15); } painter.end(); obj->setPixmap(pm); return result; } return QObject::eventFilter(o, event); }
void AccountsListDelegate::updateItemWidgets(const QList<QWidget *> widgets, const QStyleOptionViewItem &option, const QPersistentModelIndex &index) const { // draws: // AccountName // Checkbox | Icon | | ConnectionIcon | ConnectionState // errorMessage if (!index.isValid()) { return; } Q_ASSERT(widgets.size() == 6); // Get the widgets QCheckBox* checkbox = qobject_cast<QCheckBox*>(widgets.at(0)); ChangeIconButton* changeIconButton = qobject_cast<ChangeIconButton*>(widgets.at(1)); QLabel *statusTextLabel = qobject_cast<QLabel*>(widgets.at(2)); QLabel *statusIconLabel = qobject_cast<QLabel*>(widgets.at(3)); EditDisplayNameButton *displayNameButton = qobject_cast<EditDisplayNameButton*>(widgets.at(4)); QLabel *connectionErrorLabel = qobject_cast<QLabel*>(widgets.at(5)); Q_ASSERT(checkbox); Q_ASSERT(changeIconButton); Q_ASSERT(statusTextLabel); Q_ASSERT(statusIconLabel); Q_ASSERT(displayNameButton); Q_ASSERT(connectionErrorLabel); bool isSelected(itemView()->selectionModel()->isSelected(index) && itemView()->hasFocus()); bool isEnabled(index.data(KTp::AccountsListModel::EnabledRole).toBool()); KIcon accountIcon(index.data(Qt::DecorationRole).value<QIcon>()); KIcon statusIcon(index.data(KTp::AccountsListModel::ConnectionStateIconRole).value<QIcon>()); QString statusText(index.data(KTp::AccountsListModel::ConnectionStateDisplayRole).toString()); QString displayName(index.data(Qt::DisplayRole).toString()); QString connectionError(index.data(KTp::AccountsListModel::ConnectionErrorMessageDisplayRole).toString()); Tp::AccountPtr account(index.data(KTp::AccountsListModel::AccountRole).value<Tp::AccountPtr>()); if (!account->isEnabled()) { connectionError = i18n("Click checkbox to enable"); } QRect outerRect(0, 0, option.rect.width(), option.rect.height()); QRect contentRect = outerRect.adjusted(m_hpadding,m_vpadding,-m_hpadding,-m_vpadding); //add some padding // checkbox if (isEnabled) { checkbox->setChecked(true);; checkbox->setToolTip(i18n("Disable account")); } else { checkbox->setChecked(false); checkbox->setToolTip(i18n("Enable account")); } int checkboxLeftMargin = contentRect.left(); int checkboxTopMargin = (outerRect.height() - checkbox->height()) / 2; checkbox->move(checkboxLeftMargin, checkboxTopMargin); // changeIconButton changeIconButton->setIcon(accountIcon); changeIconButton->setAccount(account); // At the moment (KDE 4.8.1) decorationSize is not passed from KWidgetItemDelegate // through the QStyleOptionViewItem, therefore we leave default size unless // the user has a more recent version. if (option.decorationSize.width() > -1) { changeIconButton->setButtonIconSize(option.decorationSize.width()); } int changeIconButtonLeftMargin = checkboxLeftMargin + checkbox->width(); int changeIconButtonTopMargin = (outerRect.height() - changeIconButton->height()) / 2; changeIconButton->move(changeIconButtonLeftMargin, changeIconButtonTopMargin); // statusTextLabel QFont statusTextFont = option.font; QPalette statusTextLabelPalette = option.palette; if (isEnabled) { statusTextLabel->setEnabled(true); statusTextFont.setItalic(false); } else { statusTextLabel->setDisabled(true); statusTextFont.setItalic(true); } if (isSelected) { statusTextLabelPalette.setColor(QPalette::Text, statusTextLabelPalette.color(QPalette::Active, QPalette::HighlightedText)); } statusTextLabel->setPalette(statusTextLabelPalette); statusTextLabel->setFont(statusTextFont); statusTextLabel->setText(statusText); statusTextLabel->setFixedSize(statusTextLabel->fontMetrics().boundingRect(statusText).width(), statusTextLabel->height()); int statusTextLabelLeftMargin = contentRect.right() - statusTextLabel->width(); int statusTextLabelTopMargin = (outerRect.height() - statusTextLabel->height()) / 2; statusTextLabel->move(statusTextLabelLeftMargin, statusTextLabelTopMargin); // statusIconLabel statusIconLabel->setPixmap(statusIcon.pixmap(KIconLoader::SizeSmall)); statusIconLabel->setFixedSize(statusIconLabel->minimumSizeHint()); int statusIconLabelLeftMargin = contentRect.right() - statusTextLabel->width() - statusIconLabel->width() - 6; int statusIconLabelTopMargin = (outerRect.height() - statusIconLabel->height()) / 2; statusIconLabel->move(statusIconLabelLeftMargin, statusIconLabelTopMargin); QRect innerRect = contentRect.adjusted(changeIconButton->geometry().right() - contentRect.left(), 0, -statusTextLabel->width() - statusIconLabel->width() - 6, 0); // rect containing account name and error message // displayNameButton QFont displayNameButtonFont = option.font; QPalette displayNameButtonPalette = option.palette; if (isEnabled) { displayNameButtonPalette.setColor(QPalette::WindowText, displayNameButtonPalette.color(QPalette::Active, QPalette::Text)); displayNameButtonFont.setBold(true); } else { displayNameButtonFont.setItalic(true); // NOTE: Flat QPushButton use WindowText instead of ButtonText for button text color displayNameButtonPalette.setColor(QPalette::WindowText, displayNameButtonPalette.color(QPalette::Disabled, QPalette::Text)); } if (isSelected) { // Account is selected displayNameButtonPalette.setColor(QPalette::WindowText, displayNameButtonPalette.color(QPalette::Active, QPalette::HighlightedText)); } displayNameButton->setFont(displayNameButtonFont); displayNameButton->setPalette(displayNameButtonPalette); QString displayNameButtonText = displayNameButton->fontMetrics().elidedText(displayName, Qt::ElideRight, innerRect.width() - (m_hpadding*2)); displayNameButton->setText(displayNameButtonText); displayNameButton->setFixedSize(displayNameButton->fontMetrics().boundingRect(displayNameButtonText).width() + (m_hpadding*2), displayNameButton->minimumSizeHint().height()); displayNameButton->setAccount(account); int displayNameButtonLeftMargin = innerRect.left(); int displayNameButtonTopMargin = innerRect.top(); displayNameButton->move(displayNameButtonLeftMargin, displayNameButtonTopMargin); // connectionErrorLabel QFont connectionErrorLabelFont = option.font; QPalette connectionErrorLabelPalette = option.palette; if (isEnabled) { connectionErrorLabelPalette.setColor(QPalette::WindowText, connectionErrorLabelPalette.color(QPalette::Active, QPalette::Text)); } else { connectionErrorLabelFont.setItalic(true); connectionErrorLabelPalette.setColor(QPalette::Text, connectionErrorLabelPalette.color(QPalette::Disabled, QPalette::Text)); } if (isSelected) { // Account is selected connectionErrorLabelPalette.setColor(QPalette::Text, connectionErrorLabelPalette.color(QPalette::Active, QPalette::HighlightedText)); } connectionErrorLabel->setFont(connectionErrorLabelFont); connectionErrorLabel->setPalette(connectionErrorLabelPalette); QString connectionErrorLabelText = connectionErrorLabel->fontMetrics().elidedText(connectionError, Qt::ElideRight, innerRect.width() - (m_hpadding*2)); connectionErrorLabel->setText(connectionErrorLabelText); connectionErrorLabel->setFixedSize(connectionErrorLabel->fontMetrics().boundingRect(connectionErrorLabelText).width(), displayNameButton->height()); int connectionErrorLabelLeftMargin = innerRect.left() + m_hpadding; int connectionErrorLabelTopMargin = contentRect.bottom() - displayNameButton->height(); connectionErrorLabel->move(connectionErrorLabelLeftMargin, connectionErrorLabelTopMargin); }
void HudScheduling::refresh() { int highestPriority = findHighestPriority(); int lowestCycles = findLowestCycles(); int highestCycles = findHighestCycles(); // Update progressbar const int kPrecition = 500; float timeUntilScheduling = SETTINGS->timeUntilScheduling; if(timeUntilScheduling < 0.0f) timeUntilScheduling = 0.0f; float schedulerTime = SETTINGS->schedulerTime; float schedulingRatio = timeUntilScheduling /schedulerTime; int test = timeUntilScheduling /schedulerTime * kPrecition; int schedulingProgressbarRatio = kPrecition - test; if(progressbar->value() != schedulingProgressbarRatio) { progressbar->setValue(schedulingProgressbarRatio); progressbar->update(); // Turn bar red if at scheduling if(schedulingProgressbarRatio == kPrecition) { if(!isScheduling) { isScheduling = true; progressbar->setStyleSheet("QProgressBar::chunk{background-color: rgba(255, 0, 0, 75);}"); } } else if(isScheduling) { isScheduling = false; progressbar->setStyleSheet(""); } } // Put each item (player) into the correct place relative // to each other based on their priority int labelSize = subWindow->height(); int areaWidth = subWindow->width() - itemWidth; float sectionSize = 0; if(highestPriority > 0) sectionSize = areaWidth/highestPriority; // Determine size and location for each label for(int i=0; i<items.size(); i++) { HudScheduling_Item* item = &items[i]; int priority = item->ptr_player->priority; int cycles = item->ptr_player->cycles; // Find our relative index and number of neighbours CountAndIndex countAndIndex = findRelativeIndex(priority, i); int numNeighbours = countAndIndex.count; int relativeIndex = countAndIndex.index; // Compute size float cycleRatio = 1.0f; int deltaCycles = highestCycles - lowestCycles; if(deltaCycles > 0) cycleRatio = ((float)(cycles - lowestCycles)) / deltaCycles; const float kCycleRatioInfluence = 0.4f; int newItemHeight = itemHeight * (1.0f - kCycleRatioInfluence) + itemHeight * kCycleRatioInfluence * cycleRatio; if(item->label->height() != newItemHeight) item->label->resize(itemWidth, newItemHeight); // Compute location int index = item->ptr_player->priority; if(index < 0) index = 0; // Make sure all indicators fits by // flipping them if they reach the left // edge (reaches max priority) if(priority > 0 && priority == highestPriority) relativeIndex = -relativeIndex; float crowdOffset = relativeIndex * itemWidth; int offset = (int)(sectionSize * index + crowdOffset); Float2 target; target.x = subWindow->x() + offset; target.y = subWindow->y() + (itemHeight - newItemHeight); item->targetPosition = target; } // Update labels so they can // interpolate to the correct // position for(int i=0; i<items.size(); i++) { HudScheduling_Item* item = &items[i]; item->update(); } // Update advantage label QLabel* ownerLabel = items[ownerIndex].label; if(advantageLabel->x() != ownerLabel->x() || advantageLabel->y() != ownerLabel->y() + ownerLabel->height()) advantageLabel->move(ownerLabel->x(), ownerLabel->y() + ownerLabel->height()); }
StepsNewGesture::StepsNewGesture(ExecutionManager *pExecutionManager, int pNumberOfGesture, QWidget *parent) { int labelFontSize = 23; QColor labelColor = QColor(210,210,210); this->executionManager = pExecutionManager; this->commandChooser = new CommandChooser(parent); this->stepper = new StepperNewGesture(this->executionManager, this->commandChooser, pNumberOfGesture, parent); /* Local */ QString locale = QLocale::system().name().section('_', 0, 0); XmlConf* conf = Xml().importConfig(Utils::getConfigLocation()); if (conf != NULL) { if (conf->language != NULL) { locale = conf->language; } } if (locale.compare("en") != 0 && locale.compare("fr") != 0) { locale = "en"; } /* STEP 0 */ QWidget *step = new QWidget(stepper); QVBoxLayout* vLayoutStep = new QVBoxLayout(step); vLayoutStep->setMargin(0); Label* lblStepTop = new Label(tr("\n\nThe recording of a gesture MUST start and end with a neutral stance.\n\n"),step); lblStepTop->setTextColor(labelColor); lblStepTop->changeFontSize(16); lblStepTop->setPaintShadow(false); lblStepTop->setFixedHeight(60); lblStepTop->setPaintShadow(false); QLabel *picNeutral = new QLabel(step); QPixmap pix = QPixmap(Utils::getResourcesDirectory() + "/tuto/neutral_" + locale + ".png"); picNeutral->setPixmap(pix); vLayoutStep->addWidget(lblStepTop); vLayoutStep->addWidget(picNeutral); stepper->addStep(tr("Information"),true,false,true, StepperNewGesture::First ,step); /* STEP 1 */ Label *step1 = new Label(tr("You will have 5 seconds to place\nbefore registering your gesture\n1/") + QString::number(pNumberOfGesture),stepper); step1->changeFontSize(labelFontSize); step1->setTextColor(labelColor); step1->setPaintShadow(false); stepper->addStep(tr("Add a new gesture"),true,true,true, StepperNewGesture::StartTimer ,step1); /* STEP 2 */ Label *step2 = new Label(tr("Ready ?"),stepper); step2->changeFontSize(labelFontSize); step2->setTextColor(labelColor); step2->setPaintShadow(false); stepper->addStep(tr("Add a new gesture"),false,true,true,StepperNewGesture::StartRecording ,step2); /* STEP 3 */ QWidget* step3 = new QWidget(parent); QVBoxLayout* vLayoutStep3 = new QVBoxLayout(step3); GlView* glViewStep3= new GlView(step3); DAOLayer* dao = DAOLayer::getInstance(); connect(dao, SIGNAL(skeletonDataReceived(QString)), glViewStep3,SLOT(skeletonDataReceived(QString))); Label* labelStep3 = new Label(tr("Realtime visualizer"), step3); labelStep3->setFixedHeight(50); labelStep3->changeFontSize(labelFontSize); labelStep3->setTextColor(labelColor); labelStep3->setPaintShadow(false); vLayoutStep3->addWidget(labelStep3); vLayoutStep3->addWidget(glViewStep3); glViewStep3->startAnimating(); stepper->addStep(tr("Add a new gesture"),false,true,true,StepperNewGesture::VisualizeRecording ,step3); /* STEP 4 */ QWidget* step4 = new QWidget(parent); QVBoxLayout* vLayoutStep4 = new QVBoxLayout(step4); this->glViewStep4= new GlView(step4); connect(this->executionManager, SIGNAL(gestureRecorded(Gesture*)), this, SLOT(gestureReceived(Gesture*))); Label *labelStep4 = new Label(tr("Is it the right gesture ?"),stepper); labelStep4->setFixedHeight(50); labelStep4->changeFontSize(labelFontSize); labelStep4->setTextColor(labelColor); labelStep4->setPaintShadow(false); vLayoutStep4->addWidget(labelStep4); vLayoutStep4->addWidget(this->glViewStep4); this->glViewStep4->startAnimating(); stepper->addStep(tr("Add a new gesture"),true,true,true,StepperNewGesture::ConfigureAction,step4); /* STEP 5 */ QWidget* step5 = new QWidget(parent); QVBoxLayout* vLayout = new QVBoxLayout(step5); QWidget* step5Bottom = new QWidget(step5); QHBoxLayout* hLayoutStep5 = new QHBoxLayout(step5Bottom); this->commandChooser->setParent(step5Bottom); ComboBox *combo = this->commandChooser->getCommandComboBox(); KeyListener *keyListener = this->commandChooser->getCommandKeyListener(); TextField *tfNewGesture = this->commandChooser->getCommandTextField(); ButtonElement *btnCommand = this->commandChooser->getCommandButton(); Label* labelRecordName = new Label("Record name : ",step5); labelRecordName->setPaintShadow(false); labelRecordName->setTextColor(labelColor); TextField *tfRecordName = this->commandChooser->getRecordNameTextField(); hLayoutStep5->addWidget(combo); hLayoutStep5->addWidget(keyListener); hLayoutStep5->addWidget(tfNewGesture); hLayoutStep5->addWidget(btnCommand); hLayoutStep5->addWidget(labelRecordName); hLayoutStep5->addWidget(tfRecordName); Label *labelStep5 = new Label(tr("Command linked to your gesture"),step5); labelStep5->setPaintShadow(false); labelStep5->changeFontSize(labelFontSize); labelStep5->setTextColor(labelColor); labelStep5->setFixedHeight(50); vLayout->addWidget(labelStep5); vLayout->addWidget(step5Bottom); stepper->addStep(tr("Add a new gesture"),true,false,true,StepperNewGesture::SaveRecord,step5); /* STEP 6 */ QWidget* step6 = new QWidget(parent); QLabel* labelLoading = new QLabel(step6); QMovie* loading = new QMovie(Utils::getResourcesDirectory() + "loader.gif", QByteArray(), labelLoading); labelLoading->resize(128, 128); labelLoading->setMovie(loading); loading->start(); stepper->addStep(tr("Add a new gesture"),false,false,false,StepperNewGesture::Close,step6); labelLoading->move(step6->width()/2 - labelLoading->width()/2, step6->height()/2 - labelLoading->height()/2); }
void KMix::placeWidgets() { int sliderHeight=100; int qsMaxY=0; int ix = 0; int iy = 0; QSlider *qs; QLabel *qb; // Place Sliders (Volume indicators) ix = 0; if (mainmenuOn) mainmenu->show(); else mainmenu->hide(); bool first = true; MixDevice *MixPtr = mix->First; while (MixPtr) { if (MixPtr->is_disabled) { MixPtr->picLabel->hide(); MixPtr->Left->slider->hide(); if (MixPtr->is_stereo) MixPtr->Right->slider->hide(); MixPtr=MixPtr->Next; continue; } if ( !first ) ix += 6; else ix += 4; // On first loop add 4 int old_x=ix; qb = MixPtr->picLabel; // left slider qs = MixPtr->Left->slider; if (tickmarksOn) { qs->setTickmarks(QSlider::Left); qs->setTickInterval(10); } else qs->setTickmarks(QSlider::NoMarks); QSize VolSBsize = qs->sizeHint(); qs->setValue(100-MixPtr->Left->volume); qs->setGeometry( ix, iy+qb->height(), VolSBsize.width(), sliderHeight); qs->move(ix,iy+qb->height()); qs->show(); // Its a good point to find out the maximum y pos of the slider right here if (first) qsMaxY = qs->y()+qs->height(); ix += qs->width(); // But make sure it isn't linked to the left channel. bool BothSliders = (MixPtr->is_stereo == true ) && (MixPtr->StereoLink == false); QString ToolTipString; ToolTipString = MixPtr->name(); if ( BothSliders) ToolTipString += " (Left)"; QToolTip::add( qs, ToolTipString ); // Mark record source(s) and muted channel(s). This is done by ordinary // color marks on the slider, but this will be changed by red and green // and black "bullets" below the slider. TODO !!! if (MixPtr->is_recsrc) qs->setBackgroundColor( red ); else { if (MixPtr->is_muted) qs->setBackgroundColor( black ); else qs->setBackgroundColor( colorGroup().mid() ); } if (MixPtr->is_stereo == true) { qs = MixPtr->Right->slider; if (MixPtr->StereoLink == false) { // Show right slider if (tickmarksOn) { qs->setTickmarks(QSlider::Right); qs->setTickInterval(10); } else qs->setTickmarks(QSlider::NoMarks); QSize VolSBsize = qs->sizeHint(); qs->setValue(100-MixPtr->Right->volume); qs->setGeometry( ix, iy+qb->height(), VolSBsize.width(), sliderHeight); ix += qs->width(); ToolTipString = MixPtr->name(); ToolTipString += " (Right)"; QToolTip::add( qs, ToolTipString ); if (MixPtr->is_recsrc) qs->setBackgroundColor( red ); else { if (MixPtr->is_muted) qs->setBackgroundColor( black ); else qs->setBackgroundColor( colorGroup().mid() ); } qs->show(); } else // Don't show right slider qs->hide(); } // Pixmap label. Place it horizontally centered to volume slider(s) qb->move((int)((ix + old_x - qb->width() )/2),iy); qb->show(); first=false; MixPtr=MixPtr->Next; } ix += 4; iy = qsMaxY; LeftRightSB->setGeometry(0,iy,ix,LeftRightSB->sizeHint().height()); iy+=LeftRightSB->height(); Container->setFixedSize( ix, iy ); updateRects(); }
void FCenterWindow::cloudAntimation(animation_Direction direction) { QLabel* circle = new QLabel(stackWidget->currentWidget()); QLabel* line = new QLabel(this); line->setObjectName(QString("AntimationLine")); line->resize(0, 2); line->show(); #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) circle->setPixmap(QPixmap::grabWidget(stackWidget->widget(preindex), stackWidget->widget(preindex)->geometry())); #else circle->setPixmap(stackWidget->widget(preindex)->grab()); #endif // circle->setScaledContents(true); circle->show(); circle->resize(stackWidget->currentWidget()->size()); QPropertyAnimation *animation = new QPropertyAnimation(circle, "geometry"); animation->setDuration(500); animation->setStartValue(circle->geometry()); // QPropertyAnimation* animation_line = new QPropertyAnimation(line, "size"); // animation_line->setDuration(500); // animation_line->setEasingCurve(QEasingCurve::OutQuart); switch (direction) { case animationTop: animation->setEndValue(QRect(circle->x(), circle->y() - 10, circle->width(), 0)); break; case animationTopRight: animation->setEndValue(QRect(circle->width(), 0, 0, 0)); break; case animationRight: line->move(0, stackWidget->y() - 2); animation->setEndValue(QRect(circle->width() + 3, 0, 0, circle->height())); // animation_line->setStartValue(QSize(0, 2)); // animation_line->setEndValue(QSize(stackWidget->width(), 2)); break; case animationBottomRight: animation->setEndValue(QRect(circle->width(), circle->height(), 0, 0)); break; case animationBottom: animation->setEndValue(QRect(0, circle->height() + 10, circle->width(), 0)); break; case animationBottomLeft: animation->setEndValue(QRect(0, circle->height(), 0, 0)); break; case animationLeft: animation->setEndValue(QRect(-3, 0, 0, circle->height())); line->move(stackWidget->x(), stackWidget->y() - 2); // animation_line->setStartValue(QSize(0, 2)); // animation_line->setEndValue(QSize(stackWidget->width(), 2)); break; case animationTopLeft: animation->setEndValue(QRect(0, 0, 0, 0)); break; case animationCenter: animation->setEndValue(QRect(circle->width()/2, circle->height()/2, 0, 0)); break; default: break; } animation->setEasingCurve(QEasingCurve::OutQuart); QPropertyAnimation* animation_opacity = new QPropertyAnimation(circle, "windowOpacity"); animation_opacity->setDuration(500); animation_opacity->setStartValue(1); animation_opacity->setEndValue(0); animation_opacity->setEasingCurve(QEasingCurve::OutQuart); QParallelAnimationGroup *group = new QParallelAnimationGroup; connect(group,SIGNAL(finished()), circle, SLOT(hide())); connect(group,SIGNAL(finished()), circle, SLOT(deleteLater())); connect(group,SIGNAL(finished()), line, SLOT(deleteLater())); connect(group,SIGNAL(finished()), group, SLOT(deleteLater())); connect(group,SIGNAL(finished()), animation, SLOT(deleteLater())); connect(group,SIGNAL(finished()), animation_opacity, SLOT(deleteLater())); // connect(group,SIGNAL(finished()), animation_line, SLOT(deleteLater())); group->addAnimation(animation); group->addAnimation(animation_opacity); // group->addAnimation(animation_line); group->start(); }
TimeProfilerWindow::TimeProfilerWindow(Foundation::Framework *fw) : framework_(fw) { QUiLoader loader; QFile file("./data/ui/profiler.ui"); file.open(QFile::ReadOnly); contents_widget_ = loader.load(&file, this); assert(contents_widget_); file.close(); QVBoxLayout *layout = new QVBoxLayout; assert(layout); layout->addWidget(contents_widget_); layout->setContentsMargins(0,0,0,0); setLayout(layout); tree_profiling_data_ = findChild<QTreeWidget*>("treeProfilingData"); combo_timing_refresh_interval_ = findChild<QComboBox*>("comboTimingRefreshInterval"); tab_widget_ = findChild<QTabWidget*>("tabWidget"); label_frame_time_history_ = findChild<QLabel*>("labelFrameTimeHistory"); label_top_frame_time_ = findChild<QLabel*>("labelTopFrameTime"); label_time_per_frame_ = findChild<QLabel*>("labelTimePerFrame"); assert(tab_widget_); assert(tree_profiling_data_); assert(combo_timing_refresh_interval_); assert(label_frame_time_history_); assert(label_top_frame_time_); // Create a QImage object and set it in label. QImage frameTimeHistory(label_frame_time_history_->width(), label_frame_time_history_->height(), QImage::Format_RGB32); frameTimeHistory.fill(0xFF000000); label_frame_time_history_->setPixmap(QPixmap::fromImage(frameTimeHistory)); QLabel *label = findChild<QLabel*>("labelDataInSecGraph"); QImage img(label->width(), label->height(), QImage::Format_RGB32); img.fill(0xFF000000); label->setPixmap(QPixmap::fromImage(img)); label = findChild<QLabel*>("labelDataOutSecGraph"); img = QImage(label->width(), label->height(), QImage::Format_RGB32); img.fill(0xFF000000); label->setPixmap(QPixmap::fromImage(img)); label = findChild<QLabel*>("labelPacketsInSecGraph"); img = QImage(label->width(), label->height(), QImage::Format_RGB32); img.fill(0xFF000000); label->setPixmap(QPixmap::fromImage(img)); label = findChild<QLabel*>("labelPacketsOutSecGraph"); img = QImage(label->width(), label->height(), QImage::Format_RGB32); img.fill(0xFF000000); label->setPixmap(QPixmap::fromImage(img)); const int headerHeight = tree_profiling_data_->headerItem()->sizeHint(0).height(); tree_profiling_data_->header()->resizeSection(0, 300); tree_profiling_data_->header()->resizeSection(1, 60); tree_profiling_data_->header()->resizeSection(2, 50); tree_profiling_data_->header()->resizeSection(3, 50); tree_profiling_data_->header()->resizeSection(4, 50); QObject::connect(tab_widget_, SIGNAL(currentChanged(int)), this, SLOT(OnProfilerWindowTabChanged(int))); label_region_map_coords_ = findChild<QLabel*>("labelRegionMapCoords"); label_region_object_capacity_ = findChild<QLabel*>("labelRegionObjectCapacity"); tree_sim_stats_ = findChild<QTreeWidget*>("treeSimStats"); label_pid_stat_ = findChild<QLabel*>("labelPidStat"); assert(label_pid_stat_); assert(label_region_map_coords_); assert(label_region_object_capacity_); assert(tree_sim_stats_); tree_sim_stats_->header()->resizeSection(0, 400); tree_sim_stats_->header()->resizeSection(1, 100); show_profiler_tree_ = false; show_unused_ = false; push_button_toggle_tree_ = findChild<QPushButton*>("pushButtonToggleTree"); push_button_collapse_all_ = findChild<QPushButton*>("pushButtonCollapseAll"); push_button_expand_all_ = findChild<QPushButton*>("pushButtonExpandAll"); push_button_show_unused_ = findChild<QPushButton*>("pushButtonShowUnused"); assert(push_button_toggle_tree_); assert(push_button_collapse_all_); assert(push_button_expand_all_); assert(push_button_show_unused_); tree_asset_cache_ = findChild<QTreeWidget*>("treeAssetCache"); tree_asset_transfers_ = findChild<QTreeWidget*>("treeAssetTransfers"); assert(tree_asset_cache_); assert(tree_asset_transfers_); tree_asset_cache_->header()->resizeSection(1, 60); tree_asset_transfers_->header()->resizeSection(0, 240); tree_asset_transfers_->header()->resizeSection(1, 90); tree_asset_transfers_->header()->resizeSection(2, 90); QObject::connect(push_button_toggle_tree_, SIGNAL(pressed()), this, SLOT(ToggleTreeButtonPressed())); QObject::connect(push_button_collapse_all_, SIGNAL(pressed()), this, SLOT(CollapseAllButtonPressed())); QObject::connect(push_button_expand_all_, SIGNAL(pressed()), this, SLOT(ExpandAllButtonPressed())); QObject::connect(push_button_show_unused_, SIGNAL(pressed()), this, SLOT(ShowUnusedButtonPressed())); frame_time_update_x_pos_ = 0; }
bool Lotus::eventFilter(QObject *obj, QEvent *event) { if(obj == ui->btn_min){ //最小化、最大化、关闭按钮换图 if(event->type() == QEvent::Enter){ ui->btn_min->setPixmap(QPixmap(":/pixmap/image/miniButton-hover.png")); }else if(event->type() == QEvent::Leave){ ui->btn_min->setPixmap(QPixmap(":/pixmap/image/miniButton.png")); }else if(event->type() == QEvent::MouseButtonPress){ ui->btn_min->setPixmap(QPixmap(":/pixmap/image/miniButton-hover.png")); }else if(event->type() == QEvent::MouseButtonRelease){ QMouseEvent *me = (QMouseEvent *)event; QLabel *lb = (QLabel *)obj; if(me->x() > 0 && me->x() < lb->width() && me->y() > 0 && me->y() < lb->height()){ //this->showMinimized(); this->hide(); }else{ ui->btn_min->setPixmap(QPixmap(":/pixmap/image/miniButton.png")); } } else { return QObject::eventFilter(obj, event); } return false; } if(obj == ui->btn_close){ //最小化、最大化、关闭按钮换图 if(event->type() == QEvent::Enter){ ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeButton-hover.png")); }else if(event->type() == QEvent::Leave){ ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeButton.png")); }else if(event->type() == QEvent::MouseButtonPress){ ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeButton-hover.png")); }else if(event->type() == QEvent::MouseButtonRelease){ QMouseEvent *me = (QMouseEvent *)event; QLabel *lb = (QLabel *)obj; if(me->x() > 0 && me->x() < lb->width() && me->y() > 0 && me->y() < lb->height()){ exitEvent(); }else{ ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeButton.png")); } } else { return QObject::eventFilter(obj, event); } return false; } if(obj==ui->avatar) { if(event->type() == QEvent::MouseButtonDblClick) { //qDebug()<<"click avatar"; emit clickAvatarLabel(); } return false; } if(obj==ui->aboutButton) { if(event->type() == QEvent::MouseButtonRelease) { //qDebug()<<"click avatar"; clickAboutButton(); } return false; } if(obj==systemTrayIcon) { if(event->type() == QEvent::MouseButtonPress||event->type() == QEvent::MouseButtonRelease) { qDebug()<<"systemTrayIcon systemTrayIcon"; this->showNormal(); } return false; } if(obj==ui->friendLabel||obj==ui->roomLabel||obj==ui->otherLabel) { if(event->type() == QEvent::MouseButtonRelease) { setWindowOpacity(1); } return false; } if(obj==ui->searchButton) { if(event->type() == QEvent::MouseButtonPress) { QMouseEvent *me = (QMouseEvent *)event; dragPos = me->globalPos() - frameGeometry().topLeft(); }else if(event->type() == QEvent::MouseButtonRelease) { setWindowOpacity(1); } return false; } if(event->type() == QEvent::Enter){ qDebug()<<"eventFilter~~~~Enter"; if(lotusStatus==-1){ if(topHide==true){ topHideAnimation->setStartValue(QSize( lotusWidth,this->size().height())); topHideAnimation->setEndValue(QSize( lotusWidth, lotusHeight)); topHideAnimation->start(); lotusStatus=1; }else if(rightHide==true){ rightHideAnimation->setStartValue(QRect(this->x(),this->y(), this->size().width(),lotusHeight)); rightHideAnimation->setEndValue(QRect(QApplication::desktop()->width()-lotusWidth,this->y(), lotusWidth, lotusHeight)); rightHideAnimation->start(); lotusStatus=1; } } }else if(event->type() == QEvent::Leave){ qDebug()<<"eventFilter~~~~Leave"; if(lotusStatus==1){ if(topHide==true){ topHideAnimation->setStartValue(QSize( lotusWidth, lotusHeight)); topHideAnimation->setEndValue(QSize( lotusWidth, 5)); topHideAnimation->start(); lotusStatus=-1; }else if(rightHide==true){ rightHideAnimation->setStartValue(QRect(this->x(),this->y(),lotusWidth,lotusHeight)); rightHideAnimation->setEndValue(QRect(QApplication::desktop()->width()-5,this->y(),5,lotusHeight)); rightHideAnimation->start(); lotusStatus=-1; } } } //return QObject::eventFilter(obj, event); return false; }