Ejemplo n.º 1
0
// opens an Image specified by the path and returns its pixmap
QPixmap ExifScout::pixmapFromImage(const QString path, const QLabel &labelObject){
    //std::cerr << "Path is: "<< (std::string)path.toAscii() << "\n";

        QPixmap *pixmap, pixmapScaled;
        pixmap = new QPixmap();

        if(!path.isEmpty()) pixmap->load(path);

        if (pixmap->isNull()) {
                // if no image is found, show the 404 image
                //Ui_MainWindow::statusBar->showMessage("Cannot load "+path, 5000);
                std::cerr << "Cannot load "<< (std::string)path.toAscii();
                pixmap->load("./error404.jpg");
                pixmapScaled = pixmap->scaledToWidth(labelObject.width(), Qt::FastTransformation);
                return pixmapScaled;
        }


            //Scale the pixmap to the size of the label
            if(pixmap->width() > pixmap->height()) {
                pixmapScaled = pixmap->scaledToWidth(labelObject.width(), Qt::FastTransformation);
            }
            else {
                pixmapScaled = pixmap->scaledToHeight(labelObject.height(), Qt::FastTransformation);
            }
                //Ui_MainWindow::statusBar->showMessage("Image opened",5000);
                return pixmapScaled;

}
Ejemplo n.º 2
0
bool PersonalChatDlg::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();
                }else{
                    ui->btn_min->setPixmap(QPixmap(":/pixmap/image/miniButton.png"));
                }
            } else {
                return QObject::eventFilter(obj, event);
            }
        }
    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()){
                    this->close();
                    emit closePersonalchatdlg(bareJid);
                }else{
                    ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeButton.png"));
                }
            } else {
                return QObject::eventFilter(obj, event);
            }
        }

    if(obj==ui->closeButton||obj==ui->sendMessageButton
                            ||obj==ui->sendfileButton
                            ||obj==ui->saveFileButton
                            ||obj==ui->refuseButton)
    {
        if(event->type() == QEvent::MouseButtonPress)
        {
            QMouseEvent *me = (QMouseEvent *)event;
            dragPos = me->globalPos() - frameGeometry().topLeft();
        }else if(event->type() == QEvent::MouseButtonRelease)
        {
            setWindowOpacity(1);
        }
    }
    return QObject::eventFilter(obj, event);


}
Ejemplo n.º 3
0
void ViewerPageHandler::showEvent( QShowEvent* )
{
    qDebug() << Q_FUNC_INFO;
    if((m_visibleMask & EVPHM_PROGRESSBAR) && (m_visibleMask & EVPHM_CHAPTERLINE) && b_needToRepaint && m_currentPageIni != 0)
    {
        hideChapterLines();
        double realWidth = readingProgress->rect().width();
        //Create labels for each chapter and pos them into progressBar.
        for(int i = 0; i < linesPos.size(); i++)
        {
            QLabel* chapterLineLbl = new QLabel(readingProgressCont);
            chapterLineLbl->setFixedSize(m_chapterLineWidth,readingProgress->height());
            QImage myImage;
            myImage.load(":/res/chapter-progressbar.png");
            QImage image = myImage.scaled(chapterLineLbl->width(), chapterLineLbl->height(), Qt::IgnoreAspectRatio );
            chapterLineLbl->setPixmap(QPixmap::fromImage(image));
            int x = int((linesPos[i])*100/m_totalPages);
            double pos = double(x) * realWidth/100 - chapterLineLbl->width()/2;
            qDebug() << "Posicion" << pos;
            chapterLineLbl->move(pos,readingProgress->y());
            chapterLineLbl->show();
        }
        setNeedToPaint(false);
    }
}
Ejemplo n.º 4
0
bool WarningDialog::eventFilter(QObject *obj, QEvent *event) {
    if(obj == ui->btn_min){
            if(event->type() == QEvent::Enter){
                ui->btn_min->setPixmap(QPixmap(":/pixmap/image/minBtn-hover.png"));
            }else if(event->type() == QEvent::Leave){
                ui->btn_min->setPixmap(QPixmap(":/pixmap/image/minBtn.png"));
            }else if(event->type() == QEvent::MouseButtonPress){
                ui->btn_min->setPixmap(QPixmap(":/pixmap/image/minBtn-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();
                }else{
                    ui->btn_min->setPixmap(QPixmap(":/pixmap/image/minBtn.png"));
                }
            } else {
                return QObject::eventFilter(obj, event);
            }
    }
    if(obj == ui->btn_close){
            if(event->type() == QEvent::Enter){
                ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeBtn-hover.png"));
            }else if(event->type() == QEvent::Leave){
                ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeBtn.png"));
            }else if(event->type() == QEvent::MouseButtonPress){
                ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeBtn-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->close();
                }else{
                    ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeBtn.png"));
                }
            } else {
                return QObject::eventFilter(obj, event);
            }
    }
    if(obj == ui->okButton)
    {
        if(event->type() == QEvent::MouseButtonPress)
        {
            QMouseEvent *me = (QMouseEvent *)event;
            dragPos = me->globalPos() - frameGeometry().topLeft();
        }else if(event->type() == QEvent::MouseButtonRelease)
        {
            setWindowOpacity(1);
        }
    }
    return QObject::eventFilter(obj, event);


}
Ejemplo n.º 5
0
void ParamWidget::AddDouble(const QString& name,
    double min, double max, double step, double initial_value,
    DisplayHint display_hint) {
  ExpectNameNotFound(name);

  if (display_hint == DisplayHint::kSpinBox) {
    QDoubleSpinBox* spinbox = new QDoubleSpinBox(this);
    spinbox->setRange(min, max);
    spinbox->setSingleStep(step);
    spinbox->setValue(initial_value);
    spinbox->setProperty("param_widget_type", kParamDouble);
    widgets_[name] = spinbox;
    AddLabeledRow(name, spinbox);
    connect(spinbox,
        static_cast<void(QDoubleSpinBox::*)(double)>(
          &QDoubleSpinBox::valueChanged),
        [this, name](double value) {
          emit ParamChanged(name);
        });
  } else if (display_hint == DisplayHint::kSlider) {
    QWidget* row_widget = new QWidget(this);
    QHBoxLayout* row_hbox = new QHBoxLayout(row_widget);
    QSlider* slider = new QSlider(Qt::Horizontal, this);
    const int num_steps = static_cast<int>((max - min) / step);
    const int initial_value_int =
      static_cast<int>((initial_value - min) / step);
    slider->setRange(0, num_steps);
    slider->setSingleStep(1);
    slider->setValue(initial_value_int);
    slider->setProperty("min", min);
    slider->setProperty("max", max);
    slider->setProperty("step", step);
    slider->setProperty("param_widget_type", kParamDouble);
    QLabel* label = new QLabel(this);
    label->setText(QString::number((initial_value_int - min) * step));
    row_hbox->addWidget(new QLabel(name, this));
    row_hbox->addWidget(slider);
    row_hbox->addWidget(label);
    widgets_[name] = slider;
    layout_->addWidget(row_widget);
    slider->setProperty("param_widget_label", QVariant::fromValue(label));
    label->setProperty("format_str", "");
    connect(slider, &QSlider::valueChanged,
        [this, name, label, min, step](int position) {
          const double value = min + step * position;
          const QString format_str = label->property("format_str").toString();
          if (format_str == "") {
            label->setText(QString::number(value));
            label->setMinimumWidth(std::max(label->width(), label->minimumWidth()));
          } else {
            QString text;
            text.sprintf(format_str.toStdString().c_str(), value);
            label->setText(text);
          }
          emit ParamChanged(name);
        });
  } else {
    throw std::invalid_argument("Invalid display hint");
  }
}
Ejemplo n.º 6
0
void
ProgressView::setStatus(const QString &status)
{
    QLabel *label = this->status;
    label->setText(label->fontMetrics().elidedText(status, Qt::ElideRight,
                                                   label->width()));
}
Ejemplo n.º 7
0
ZLQtWaitMessage::ZLQtWaitMessage(const std::string &message) : QWidget(0, Qt::SplashScreen) {
	QWidget *main = qApp->activeWindow();
	if (main != 0) {
		myMainWidget = main;
		myStoredCursor = main->cursor();
		myMainWidget->setCursor(Qt::WaitCursor);
	} else {
		myMainWidget = 0;
	}
	setCursor(Qt::WaitCursor);

	qApp->processEvents();

	QBoxLayout layout(QBoxLayout::LeftToRight, this);
	QLabel *label = new QLabel(::qtString(message), this);
	layout.addWidget(label);

	if (main == 0) {
		main = QApplication::desktop();
	}
	move(
		main->x() + main->width() / 2 - label->width() / 2 - 10,
		main->y() + main->height() / 2 - label->height() / 2 - 10
	);
	show();

	qApp->processEvents();
	usleep(5000);
	qApp->processEvents();
}
Ejemplo n.º 8
0
    void TerrainWeightEditor::HandleMouseEventFromCanvas(QMouseEvent *ev, QString name)
    {
        if(ev->buttons() && Qt::LeftButton)
        {
            QLabel *canvas = editor_widget_->findChild<QLabel *>(name);
            if(!canvas)
                return;
            QImage image = canvas->pixmap()->toImage();

            //in canvas space, between [0,1]
            qreal brush_pos_x = ev->posF().x()/canvas->width();
            qreal brush_pos_y = ev->posF().y()/canvas->height();

            //in image space (texel coordinates)
            brush_pos_x = brush_pos_x*image.width();
            brush_pos_y = brush_pos_y*image.height();

            qreal half_brush_size = brush_size_*0.5f;

            int start_pos_x = brush_pos_x-half_brush_size;
            int start_pos_y = brush_pos_y-half_brush_size;
            int end_pos_x = brush_pos_x+half_brush_size;
            int end_pos_y = brush_pos_y+half_brush_size;

            //check limits
            start_pos_x = start_pos_x<0?0:start_pos_x;
            start_pos_y = start_pos_y<0?0:start_pos_y;
            end_pos_x = end_pos_x<image.width()? end_pos_x:image.width();
            end_pos_y = end_pos_y<image.height()? end_pos_y:image.height();

            for(int x = start_pos_x; x<end_pos_x;x++)
            {
                for(int y = start_pos_y; y<end_pos_y;y++)
                {
                    QRgb color = image.pixel(x,y);

                    f32 dist = sqrt(pow(x-brush_pos_x,2)+pow(y-brush_pos_y,2));
                    if(dist>half_brush_size)
                        continue;

                    int mod = abs(brush_modifier_) - abs(dist*(brush_modifier_*falloff_percentage_));

                    if(mod<1)
                        continue;

                    if(brush_modifier_<0)
                        mod = -mod;
                    int new_col = qBlue(color)+mod;
                    
                    //Limits (again)
                    new_col = new_col>255?255:new_col;
                    new_col = new_col<0?0:new_col;

                    image.setPixel(x,y, QColor(new_col,new_col,new_col).rgb());

                }
            }
            canvas->setPixmap(QPixmap::fromImage(image));
        }
    }
Ejemplo n.º 9
0
int MainWindow::plot()
{
    int width = 800;
    int height = 600;

    QLabel* label = ui->label;
    height = label->height();
    width = label->width();
    const QX11Info& info = label->x11Info();//label->x11Info();
    Drawable drawable = label->handle();//label->handle();
    Display* display = info.display();
    Screen* screen = XScreenOfDisplay(display, info.screen());
    Visual* visual = reinterpret_cast<Visual*>(info.visual());
    XRenderPictFormat * format = XRenderFindVisualFormat(display, visual);

    _QtCairoParam param;
    param.use_qt = 1;
    param.display = display;
    param.drawable = drawable;
    param.visual = visual;
    param.format = format;
    param.height = height;
    param.width = width;

    _QtCairoParam* p_param = &param;
    QMap<QString, QVariant> param_map;
    param_map["workstation_type"] = "X11";
    param_map["qt_cario_param"] = QVariant::fromValue(p_param);

    ContourPlotter plotter(param_map);
    plotter.plot();
}
QLabel * TASARIM_DESIGN_WIDGET::CREATE_NEW_LABEL ( const QString &text, QWidget * parent )
{
    if ( parent EQ NULL ) {
        parent = this;
    }

    QLabel * label = new QLabel(text.toUtf8(),parent);
    label->setMargin(0);
    label->setIndent(0);
    QFont label_font = label->font();
    label_font.setFixedPitch    ( false );
    label_font.setKerning       ( false );
    label_font.setLetterSpacing ( QFont::AbsoluteSpacing, 0.01 );
    label_font.setWordSpacing   ( 0.01 );
    label->setScaledContents    ( true );
    label->setFont              ( label_font );
    label->setFocusPolicy       ( Qt::StrongFocus );

    int width = label->width();
    label->setMinimumWidth( width + 5 );

    label->installEventFilter( this );

    SET_LABEL_FONTS_UNSELECTED( label );

    return label;
}
Ejemplo n.º 11
0
void StatusBar::showRestartRequired() {
  // Restart required notification
  const QString restart_text = tr("qBittorrent needs to be restarted");
  QLabel *restartIconLbl = new QLabel(m_bar);
  restartIconLbl->setPixmap(QPixmap(":/icons/oxygen/dialog-warning.png").scaled(QSize(24,24)));
  restartIconLbl->setToolTip(restart_text);
  m_bar->insertWidget(0,restartIconLbl);
  QLabel *restartLbl = new QLabel(m_bar);
  restartLbl->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
  m_bar->insertWidget(1, restartLbl);
  QFontMetrics fm(restartLbl->font());
  restartLbl->setText(fm.elidedText(restart_text, Qt::ElideRight, restartLbl->width()));
  Logger::instance()->addMessage(tr("qBittorrent was just updated and needs to be restarted for the changes to be effective."), Log::CRITICAL);
}
Ejemplo n.º 12
0
void Drive::preview(const QModelIndex & index)
{
    QFileInfo file = results_[index.row()];
    QString filetype = file.suffix().toLower();
    QLabel* label = this->parent_->ui->label;

    if (filetype == "jpg") {
        QPixmap pic(file.absoluteFilePath());
        if (pic.width() > pic.height())
            label->setPixmap(pic.scaledToWidth(label->width()));
        else
            label->setPixmap(pic.scaledToHeight(label->height()));
        //this->parent_->ui->label->setPixmap(*pic);
    }
}
Ejemplo n.º 13
0
void NodeTypesDelegate::updateItemWidgets(const QList< QWidget* > widgets, const QStyleOptionViewItem& option, const QPersistentModelIndex& index) const
{
    // widgets:
    // ColorButton | Title | ID

    if (!index.isValid()) {
        return;
    }

    Q_ASSERT(widgets.size() == 4);

    KColorButton *colorButton = qobject_cast<KColorButton*>(widgets.at(0));
    QLineEdit *title = qobject_cast<QLineEdit*>(widgets.at(1));
    QLabel *id = qobject_cast<QLabel*>(widgets.at(2));
    QToolButton *propertiesButton = qobject_cast<QToolButton*>(widgets.at(3));

    Q_ASSERT(title);
    Q_ASSERT(colorButton);
    Q_ASSERT(id);
    Q_ASSERT(propertiesButton);

    colorButton->setColor(index.data(NodeTypeModel::ColorRole).value<QColor>());
    title->setText(index.data(NodeTypeModel::TitleRole).toString());
    id->setText(index.data(NodeTypeModel::IdRole).toString());

    QRect outerRect(0, 0, option.rect.width(), option.rect.height());
    QRect contentRect = outerRect.adjusted(m_hPadding, m_vPadding, -m_hPadding, -m_vPadding);

    int colorButtonLeftMargin = contentRect.left();
    int colorButtonTopMargin = (outerRect.height() - colorButton->height()) / 2;
    colorButton->move(colorButtonLeftMargin, colorButtonTopMargin);

    int titleLeftMargin = colorButtonLeftMargin + colorButton->width() + 10;
    int titleTopMargin = (outerRect.height() - title->height()) / 2;
    title->move(titleLeftMargin, titleTopMargin);

    // construct remaining from right to left
    int propertiesLeftMargin = contentRect.right() - propertiesButton->width() - m_hPadding;
    int propertiesTopMargin = (outerRect.height() - propertiesButton->height()) / 2;
    propertiesButton->move(propertiesLeftMargin, propertiesTopMargin);

    int idLeftMargin = propertiesLeftMargin - id->width() - 10;
    int idTopMargin = (outerRect.height() - id->height()) / 2;
    id->move(idLeftMargin, idTopMargin);

    // title gets remaining space
    title->setFixedWidth(qMax(0, idLeftMargin - titleLeftMargin - 10));
}
Ejemplo n.º 14
0
Slider::Slider(int minValue, int maxValue, int pageStep, int tickStep,
        int value, Qt::Orientation orientation, const QString& label,
        QWidget * parent): QWidget(parent)
{
    slider = new QSlider(orientation, parent);
    slider->setTickInterval(tickStep);
    slider->setTickPosition(QSlider::TicksLeft);
    slider->setRange(minValue, maxValue);
    slider->setSingleStep(pageStep);
    slider->setValue(value);
    if (orientation == Qt::Vertical) {
        slider->setMinimumHeight(150);
    }
    else {
        slider->setMinimumWidth(150);
    }
    connect(slider, SIGNAL(valueChanged(int)), this, SLOT(updateSpinBox(int)));
    connect(slider, SIGNAL(sliderMoved(int)), this, SLOT(fillSpinBox(int)));

    sliderSpin = new QSpinBox(this);
    sliderSpin->setRange(minValue, maxValue);
    sliderSpin->setValue(value);
    sliderSpin->setKeyboardTracking(false);
    connect(sliderSpin, SIGNAL(valueChanged(int)), slider, SLOT(setValue(int)));
    connect(sliderSpin, SIGNAL(editingFinished()), this, SLOT(emitAsMoved()));

    QLabel* sliderLabel = new QLabel(this);
    sliderLabel->setText(label);
    sliderLabel->setBuddy(sliderSpin);
    sliderLabel->setMinimumWidth(5*sliderLabel->fontMetrics().maxWidth());
    QBoxLayout *sliderLayout = new QBoxLayout(QBoxLayout::LeftToRight,this);
    sliderLayout->setMargin(0);
    sliderLayout->addWidget(sliderLabel);
    sliderLayout->addWidget(slider);
    sliderLayout->addSpacing(2);
    sliderLayout->addWidget(sliderSpin);
    if (orientation == Qt::Vertical) {
        sliderLayout->setDirection(QBoxLayout::TopToBottom);
        sliderLayout->setAlignment(Qt::AlignHCenter);
    }
    else {
        sliderLayout->setDirection(QBoxLayout::LeftToRight);
        sliderLayout->setAlignment(Qt::AlignTop);
    }
    setMinimumWidth(155 + sliderLabel->width() + sliderLabel->fontMetrics().maxWidth() * 3);
    setLayout(sliderLayout);
}
Ejemplo n.º 15
0
		bool eventFilter(QObject *obj, QEvent *event) {
			if ( event->type() == QEvent::Paint ) {
				QLabel *l = static_cast<QLabel*>(obj);
				QPainter painter(l);

				int sep = 20;//l->height()*40/100;
				QLinearGradient grad(0,0,0,sep);
				grad.setColorAt(0,midBg);
				grad.setColorAt(0.25,midLightBg);
				grad.setColorAt(1,midLightBg);
				painter.fillRect(0,0,l->width(),sep,grad);

				grad = QLinearGradient(0,sep,0,40);//l->height());
				grad.setColorAt(0,midLightBg);
				grad.setColorAt(0.25,midBg);
				grad.setColorAt(1,midBg);
				painter.fillRect(0,sep,l->width(),l->height()-sep,grad);

				painter.setPen(borderBg);
				painter.drawLine(0,0,l->width(),0);
				/*
				painter.setPen(Qt::black);
				painter.drawLine(0,0,0,l->height());
				painter.drawLine(0,0,l->width(),0);
				*/

				if ( !l->text().isEmpty() ) {
					grad = QLinearGradient(0,0,l->width(),0);
					grad.setColorAt(0, QColor(255,255,255,0));
					grad.setColorAt(0.25, QColor(255,255,255,128));
					grad.setColorAt(0.5, QColor(255,255,255,192));
					grad.setColorAt(0.75, QColor(255,255,255,128));
					grad.setColorAt(1, QColor(255,255,255,0));
					painter.fillRect(0,l->height()-1,l->width(),1,grad);
				}

				const QPixmap *pm = l->pixmap();
				if ( pm != NULL ) {
					int xofs = (l->width() - pm->width()) / 2;
					int yofs = (l->height() - pm->height()) / 2;
					painter.drawPixmap(xofs,yofs, *pm);
				}

				painter.setPen(Qt::white);
				painter.drawText(l->rect().adjusted(20,0,0,0), Qt::AlignLeft | Qt::AlignVCenter, l->text());

				return true;
			}

			return QObject::eventFilter(obj, event);
		}
Ejemplo n.º 16
0
ConfirmWidget::ConfirmWidget(QListWidgetItem *it) :
    FloatingWidget(NULL)
{
    setFixedSize(150, 50);

    m_list = new FlatListWidget(false, this);
    m_list->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    m_list->addItem(it);

    QLabel *ic = new QLabel(this);
    ic->setPixmap(QIcon(":/icons/question").pixmap(16, 16));

    QLabel *l = new QLabel(tr("OK?"), this);
    l->setStyleSheet("color: gray");

    QVBoxLayout *main = new QVBoxLayout(this);
    QHBoxLayout *top = new QHBoxLayout;
    top->addWidget(ic);
    top->addWidget(l, 1);
    top->setContentsMargins(5, 0, 0, 0);
    main->addLayout(top);
    main->addWidget(m_list, 1);
    main->setContentsMargins(0, 5, 0, 5);

    show();
    move(QCursor::pos()-m_list->geometry().center());
    setFocus();

    int p = ic->x() + ic->width();
    // padding-left for QListWidgetItem does not work.
    //m_list->setStyleSheet(QString("QListWidget::item { padding-left: %1px; }").arg(p) + list->styleSheet());
    QLabel *it_text = new QLabel(it->text(), this);
    it_text->setStyleSheet(QString("color: white; padding-left: %1px;").arg(p));
    it_text->setFont(Utils::getMonospaceFont());
    m_list->setItemWidget(it, it_text);
    it->setText("");

    connect(m_list, SIGNAL(itemActivated(QListWidgetItem*)), SLOT(itemActivated(QListWidgetItem*)));
    connect(m_list, SIGNAL(itemClicked(QListWidgetItem*)),   SLOT(itemActivated(QListWidgetItem*)));
}
Ejemplo n.º 17
0
bool SkinsWidget::eventFilter(QObject *obj, QEvent *event) {
    if(obj == close_button) {
            if(event->type() == QEvent::Enter){
                close_button->setPixmap(QPixmap(":/pixmap/image/closeBtn-hover.png"));
            }else if(event->type() == QEvent::Leave){
                close_button->setPixmap(QPixmap(":/pixmap/image/closeBtn.png"));
            }else if(event->type() == QEvent::MouseButtonPress){
                close_button->setPixmap(QPixmap(":/pixmap/image/closeBtn-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->hide();
                }else{
                    close_button->setPixmap(QPixmap(":/pixmap/image/closeBtn.png"));
                }
            } else {
                return QObject::eventFilter(obj, event);
            }
        }
        return QObject::eventFilter(obj, event);
}
    ///////////////////////////////////////////////////////////
    // 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);
    }
Ejemplo n.º 19
0
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);
}
Ejemplo n.º 20
0
void BasicInfoRpt::initUI(const QString& titletext)
{
    this->setFixedSize(900, 600);

    QLabel* title = new QLabel(titletext, this);
    title->adjustSize();
    title->move(900 / 2 - title->width() / 2, 17);

    QLabel* icon = new QLabel(this);
    icon->setPixmap(QPixmap(":image/detailreport/logo"));
    icon->adjustSize();
    icon->move(900 / 2 - title->width() / 2 - 3 - icon->width(), 12);

    returnbtn = new StaticButton(":image/detailreport/returnbtn", 3, this);
    returnbtn->move(0, 0);

    osInfoBtn = new TaskButton(":image/detailreport/basicinfo/osInfoBtn", this);
    osInfoBtn->move(27, 60);
    cpuInfoBtn = new TaskButton(":image/detailreport/basicinfo/cpuInfoBtn", this);
    cpuInfoBtn->move(27 + 142, 60);
    biosInfoBtn = new TaskButton(":image/detailreport/basicinfo/biosInfoBtn", this);
    biosInfoBtn->move(27 + 142 * 2, 60);
    motherBoardInfoBtn = new TaskButton(":image/detailreport/basicinfo/motherBoardInfoBtn", this);
    motherBoardInfoBtn->move(27 + 142 * 3, 60);
    memoryInfoBtn = new TaskButton(":image/detailreport/basicinfo/memoryInfoBtn", this);
    memoryInfoBtn->move(27 + 142 * 4, 60);
    graphicsCardInfoBtn = new TaskButton(":image/detailreport/basicinfo/graphicsCardInfoBtn", this);
    graphicsCardInfoBtn->move(27 + 142 * 5, 60);

    taskbtnlist << osInfoBtn << cpuInfoBtn << biosInfoBtn << motherBoardInfoBtn << memoryInfoBtn << graphicsCardInfoBtn;

    for (TaskButton* task : taskbtnlist) {
        task->running_movie->move((task->running_defaultstatus->width()) / 2 - 10, 50);
    }
    osView = new QTableView(this);
    //hardDiskInfoView->setModel(hardDiskInfoMod);
    initViewDetail(osView);

    cpuInfoView = new QTableView(this);
    //virtualMachineInfoView->setModel(virtualMachineInfoMod);
    initViewDetail(cpuInfoView);

    biosInfoView = new QTableView(this);
    //netConfigView->setModel(netConfigMod);
    initViewDetail(biosInfoView);

    motherBoardInfoView = new QTableView(this);
    //adapterDeviceView->setModel(adapterDeviceMod);
    initViewDetail(motherBoardInfoView);

    memoryInfoView = new QTableView(this);
    //printDeviceView->setModel(printDeviceMod);
    initViewDetail(memoryInfoView);

    graphicsCardInfoView = new QTableView(this);
    //blueToothDeviceView->setModel(blueToothDeviceMod);
    initViewDetail(graphicsCardInfoView);
    //osView->setContextMenuPolicy(Qt::CustomContextMenu);
    //connect(osView, SIGNAL(customContextMenuRequested(const QPoint&)),
    //        SLOT(showFileCheckContextMenu(const QPoint&)));
    viewlist << osView << cpuInfoView << biosInfoView
             << motherBoardInfoView << memoryInfoView << graphicsCardInfoView;

    contextmenu = new QMenu(this);
    openfile = new QAction("打开文件", contextmenu);
    connect(openfile, &QAction::triggered,
            [=]() {
        QStringList argo;
        QProcess* exec ;
        exec = new QProcess();
        argo << "xdg-open"
             << openfile->data().toString();
        exec->start("/bin/bash", argo);
        connect(exec, static_cast<void (QProcess::*)(int)>(&QProcess::finished), this,
                [=](int exitCode) {
            qDebug()<<exitCode;
         delete exec;

        });
    });
    openfilepath = new QAction("打开文件所在文件夹", contextmenu);
    connect(openfilepath, &QAction::triggered,
            [=]() {
        QStringList argo;
        QProcess* exec ;
        exec = new QProcess();
        argo << "xdg-open"
             << openfilepath->data().toString();
        exec->start("/bin/bash", argo);
        connect(exec, static_cast<void (QProcess::*)(int)>(&QProcess::finished), this,
                [=](int exitCode) {
         delete exec;
         qDebug()<<exitCode;
        });
    });
    contextmenu->addAction(openfile);
    contextmenu->addAction(openfilepath);

}
Ejemplo n.º 21
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;


}
Ejemplo n.º 22
0
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;
}
Ejemplo n.º 23
0
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();
}
Ejemplo n.º 24
0
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++;
    }
}
Ejemplo n.º 25
0
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();
}
Ejemplo n.º 26
0
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);
}
Ejemplo n.º 27
0
void ItemsViewDelegate::updateItemWidgets(const QList<QWidget*> widgets,
        const QStyleOptionViewItem &option,
        const QPersistentModelIndex &index) const
{
    const QSortFilterProxyModel * model = qobject_cast<const QSortFilterProxyModel*>(index.model());
    if (model == NULL) {
        return;
    }

    const ItemsModel * realmodel = qobject_cast<const ItemsModel*>(model->sourceModel());
    if (realmodel == NULL || !index.isValid()) {
        return;
    }

    // setup the install button
    int margin = option.fontMetrics.height() / 2;

    int right = option.rect.width();
    //int bottom = option.rect.height();

    QSize size(option.fontMetrics.height() * 7, widgets.at(kInstall)->sizeHint().height());

    QLabel * infoLabel = qobject_cast<QLabel*>(widgets.at(kLabel));
	infoLabel->setWordWrap(true);
    if (infoLabel != NULL) {
        if (realmodel->hasPreviewImages()) {
            // move the text right by kPreviewWidth + margin pixels to fit the preview
            infoLabel->move(kPreviewWidth + margin * 2, 0);
            infoLabel->resize(QSize(option.rect.width() - kPreviewWidth - (margin * 6) - size.width(), option.fontMetrics.height() * 7));
        } else {
            infoLabel->move(margin, 0);
            infoLabel->resize(QSize(option.rect.width() - (margin * 4) - size.width(), option.fontMetrics.height() * 7));
        }

        QString text = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
			"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">p, li { white-space: pre-wrap; margin:0 0 0 0;}\n"
			"</style></head><body><p><b>" +
			index.data(ItemsModel::kNameRole).toString() + "</b></p>\n";

        QString summary = "<p>" + option.fontMetrics.elidedText(index.data(ItemsModel::kSummary).toString(),
		  Qt::ElideRight, infoLabel->width() * 3) + "</p>\n";
        text += summary;

        QString authorName = index.data(ItemsModel::kAuthorName).toString();
        QString email = index.data(ItemsModel::kAuthorEmail).toString();
        if (!authorName.isEmpty()) {
            if (email.isEmpty()) {
                text += "<p><i>" + authorName + "</i></p>\n";
            } else {
                text += "<p><i>" + authorName + "</i> <a href=\"mailto:" + email + "\">" + email + "</a></p>\n";
            }
        }

        unsigned int downloads = index.data(ItemsModel::kDownloads).toUInt();
        text += downloads == 0 ? i18n("<p>No Downloads</p>") : i18n("<p>Downloads: %1</p>\n", downloads);

		text += "</body></html>";
        text.replace("[b]", "<b>");
        text.replace("[/b]", "</b>");
        text.replace("[i]", "<i>");
        text.replace("[/i]", "</i>");
        text.replace("[u]", "<i>");
        text.replace("[/u]", "</i>");
        text.remove("[url]");
        text.remove("[/url]");
        text.replace("\\\'", "\'");
        infoLabel->setText(text.simplified());
    }

    QToolButton * button = qobject_cast<QToolButton*>(widgets.at(kInstall));
    if (button != NULL) {
        Entry::Status status = Entry::Status(model->data(index, ItemsModel::kStatus).toUInt());
        //if (!button->menu()) {
        //    button->setMenu(InstallMenu(button, status));
        //    button->setIconSize(QSize(16, 16));
            button->resize(size);
        //}
        button->move(right - button->width() - margin, option.rect.height() / 2 - button->height());
        button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
        //button->setPopupMode(QToolButton::MenuButtonPopup);

        // validate our assumptions
        //Q_ASSERT(button->menu());
        //Q_ASSERT(button->menu()->actions().count() == 2);

        // get the two actions
        //QAction * action_install = button->menu()->actions()[0];
        //QAction * action_uninstall = button->menu()->actions()[1];
        switch (status) {
        case Entry::Installed:
            button->setText(i18n("Uninstall"));
            //action_install->setVisible(false);
            //action_uninstall->setVisible(true);
            button->setIcon(QIcon(m_statusicons[Entry::Deleted]));
            break;
        case Entry::Updateable:
            button->setText(i18n("Update"));
            //action_uninstall->setVisible(false);
            //action_install->setText(i18n("Update"));
            //action_install->setVisible(true);
            //action_install->setIcon(QIcon(m_statusicons[Entry::Updateable]));
            button->setIcon(QIcon(m_statusicons[Entry::Updateable]));
            break;
        case Entry::Deleted:
            /// @todo Set different button text when string freeze is over? "Install again"
            button->setText(i18n("Install"));
            //action_uninstall->setVisible(false);
            //action_install->setText(i18n("Install"));
            //action_install->setVisible(true);
            //action_install->setIcon(QIcon(m_statusicons[Entry::Installed]));
            button->setIcon(QIcon(m_statusicons[Entry::Installed]));
            break;
        default:
            button->setText(i18n("Install"));
            //action_uninstall->setVisible(false);
            //action_install->setVisible(true);
            //action_install->setIcon(QIcon(m_statusicons[Entry::Installed]));
            button->setIcon(QIcon(m_statusicons[Entry::Installed]));
        }
    }

    QLabel * ratingLabel = qobject_cast<QLabel*>(widgets.at(kRating));
    if (ratingLabel != NULL) {
        ratingLabel->setText(i18n("Rating: %1", model->data(index, ItemsModel::kRating).toString()));

        // put the rating label below the install button
        ratingLabel->move(right - button->width() - margin, option.rect.height() / 2 + button->height()/2);
        ratingLabel->resize(size);
    }
}
Ejemplo n.º 28
0
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());
}
Ejemplo n.º 29
0
    void CbcRegistersTab::createCbcRegisterValue(const int idSh, const int idBe, const int idFe, const int idCbc,
                                                 const std::map<std::string, CbcRegItem> mapReg) //for initial creation - later should find inside map
    {
        int row = 0;
        int column = 0;
        int cSizeTitle = 0;
        int cSizeAddr = 0; //TODO size by page number
        QMap<QString, QLineEdit*> cWidgetMap;

        for (auto& kv : mapReg)
        {
            QFont font("Sans Serif", 8);
            QHBoxLayout *loHorz = new QHBoxLayout; //Lo to add to grid
            QSpacerItem *spacer = new QSpacerItem(50,50); //TODO play with this

            QLabel *lblRegTitle = new QLabel(this);
            QLabel *lblRegAddress = new QLabel(this);

            lblRegTitle->setText(QString::fromStdString(kv.first));
            lblRegTitle->setFont(font);

            auto cAddress = kv.second.fAddress;
            if (cAddress < 16) lblRegAddress->setText(QString("[0x0%1]").arg(QString::number(cAddress,16))); //appends padding 0
            else lblRegAddress->setText(QString("[0x%1]").arg(QString::number(cAddress,16)));
            lblRegAddress->setFont(font);

            QLineEdit *lineRegValue = new QLineEdit(this);
            lineRegValue->setFixedWidth(30);
            lineRegValue->setText(QString::number(kv.second.fValue));
            lineRegValue->setFont(font);

            //connect(lineRegValue, SIGNAL(textEdited(QString)),
            //        this, SLOT(onValueChanged(QString)));

            loHorz->addWidget(lblRegTitle);
            loHorz->setAlignment(lblRegTitle, Qt::AlignLeft);
            loHorz->addWidget(lblRegAddress);
            loHorz->setAlignment(lblRegAddress, Qt::AlignLeft);
            loHorz->addWidget(lineRegValue);
            loHorz->setAlignment(lineRegValue, Qt::AlignLeft);
            loHorz->addSpacerItem(spacer);
            loHorz->addStretch(5);

            m_mapTabPage[idSh][idBe][idFe][idCbc][kv.second.fPage]->addLayout(loHorz, row, column);

            cWidgetMap.insert(QString::fromStdString(kv.first),lineRegValue);

            if (cSizeTitle < lblRegTitle->width()) cSizeTitle = lblRegTitle->width(); //find min width needed
            if (cSizeAddr < lblRegAddress->width()) cSizeAddr = lblRegAddress->width();

            ++row;

            if (row == 20)
            {
                ++column;
                row = 0;
            }

        }
        m_mapWidgets[idSh][idBe][idFe][idCbc] = cWidgetMap;
    }