Пример #1
0
void IntroduceForm::initData()
{
    WidgetMain *p = qobject_cast<WidgetMain *>(parentWidget());
    EditScene *pScene =  p->getScenePointer();
    //pScene->setListWidgetIntroducePointer(listWidget);

    QStringList listComponentsName = getComponentsName("./resource/Blocks/");
    connect(listWidget, SIGNAL(signalHideSubWindows()), this, SIGNAL(signalHideSubWindows()));
    connect(listWidget, SIGNAL(signalShowSubWindows()), this, SIGNAL(signalShowSubWindows()));
    //填充ListWidget的数据
    int itemIndex = 0;
    foreach (QString bbName, listComponentsName)
    {
        qDebug() << bbName;

        QString name = pHash_moduelName_dataStruct_->value(bbName).ui.name;
        QString type = pHash_moduelName_dataStruct_->value(bbName).ui.type;

        //根据type来判断是否是自己关心的类型
        if(type_ != type)
        {
            continue;
        }

        QImage image;
        QByteArray imageData = pHash_moduelName_dataStruct_->value(bbName).description.imageData;
        QString description = pHash_moduelName_dataStruct_->value(bbName).description.text;
        image.loadFromData(imageData, "PNG");
        if(imageData.isEmpty())
        {
            qDebug() << "数据库中没有图片数据";
        }

        ListWidgetItemWidget_Component *pItemWidget = new ListWidgetItemWidget_Component(name, listWidget);
        pItemWidget->setEnabledHoverEvent(true);
        pItemWidget->setIntroduceInfor(QPixmap::fromImage(image), description);
        connect(pItemWidget, SIGNAL(signalIntroduce(QPixmap,QString)), this, SLOT(slotIntroduce(QPixmap,QString)));
        ListWidgetItem *pItem = new ListWidgetItem(pItemWidget);
        pItem->setData(Qt::UserRole, itemIndex++);
        pItem->setData(Qt::UserRole+1, name);
        pItem->setData(Qt::UserRole+2, description);
        pItem->data_ = pHash_moduelName_dataStruct_->value(bbName);

        //解决了左边icon右边Widget的问题
        pItem->setSizeHint(QSize(41, 31));
        listWidget->addItem(pItem);
        listWidget->setItemWidget(pItem, pItemWidget);
    }
Пример #2
0
void OpenAsDialog::m_launch()
{
    if(!m_list->selectedItems().count() > 0)
        return;     // why did this f*ckin user clicked, if he just didn't select anything ?!

    // there shouldn't be more than 1 item selected, get it
    ListWidgetItem *it = static_cast<ListWidgetItem*>(m_list->selectedItems().first());

    // i love this class and my property system ! :)
    QString cmd = it->filePath().path();
    QProcess p(this);
    p.startDetached(cmd);

    // close this dialog
    close();
}
Пример #3
0
void Cocos2dxView::mouseReleaseInCommonEdit(QMouseEvent *event)
{
	if (m_commonPos != event->localPos())
		return;

	ListWidgetItem *item = (ListWidgetItem*)m_listwidget->currentItem();
	if (!item) return;
	EditorScene *scene = getEditorScene();

	//执行操作
	std::string tpname = std::string(item->text().toLatin1().data());
	std::string filename = std::string(item->getAbsoluteFilePath().toLatin1().data());
	OperationManageX->exec(new CommonEditOper(tpname, scene->getObjectLayer(), 
									convertToOpenglPoint(QCursor::pos()), item->file_info));

}
void
MsmWindow::addPageWidget( PageWidget& page )
{
    // Add list widget item
    ListWidgetItem* item = new ListWidgetItem( ui->listWidget );
    item->setText( page.getTitle() );
    item->setIcon( QIcon( page.getIcon() ) );
    item->setSizeHint( QSize( 135, 100 ) );
    item->page = &page;

    // Add to stacked widget
    ui->stackedWidget->addWidget( &page );

    connect( &page, &PageWidget::setApplyEnabled,
             this, &MsmWindow::setApplyEnabled );
    connect( &page, &PageWidget::closePage,
             this, &MsmWindow::closePageRequested );
}
Пример #5
0
bool ListWidget::addSpriteToList(QString path)
{
    //允许重复
    //忽略重复项
    QFileInfo fileinfo= QFileInfo(path);
//    QList<QListWidgetItem *> res = findItems(fileinfo.baseName(),Qt::MatchCaseSensitive);
//    if(res.count() > 0)
//        return false;
    qDebug("%s", fileinfo.baseName().toLatin1().data() );

    ListWidgetItem *item = new ListWidgetItem(fileinfo);
    item->setIcon(QIcon(path));
    item->setText(fileinfo.baseName());
//      item1->setBackgroundColor(QColor(100,0,0));
//      item->setSizeHint(QSize(100,100));

    this->addItem(item);
    return true;
}
Пример #6
0
void Cocos2dxView::attachSpriteToMouse()
{
	ListWidgetItem *item = (ListWidgetItem*)m_listwidget->currentItem();
	if (!item) return;
	EditorScene *scene = getEditorScene();
	if (scene)
	{
		QRect r = this->geometry();
		if (!m_mouseSprite)
		{
			m_mouseSprite = CCSprite::create(item->getAbsoluteFilePath().toLatin1().data());
			m_mouseSprite->setOpacity(128);
			scene->addChild(m_mouseSprite);
		}
		QPoint	pos = mapFromGlobal(QCursor::pos());
		m_mouseSprite->setPosition(ccp(pos.rx(), r.height() - pos.ry()));	//qt的ui y轴坐标转换为opengl的y轴坐标

		m_mouseTimer.setParent(this);
		connect(&m_mouseTimer, SIGNAL(timeout()), this, SLOT(mouseMoveInView()));
		
		m_mouseTimer.start(20);
	}
}
Пример #7
0
void OpenAsDialog::m_add_application(const QString &application_desktop_file_path)
{
    // we said above that QSettings couldn't work for a string list, but it's a bit
    // better (faster) than QFile for single values, we will use it here
    QSettings s(application_desktop_file_path, QSettings::NativeFormat);
    s.beginGroup("Desktop Entry");

    // first of all get the name and the icon of the application
    QIcon ic = QIcon::fromTheme(s.value("Icon").toString());
    QString name = s.value("Name[" + QLocale::system().name().section('_',0,0) + "]").toString();

    // if we dont have a name with the locale, fallback to the default one
    name = name.isEmpty() ? s.value("Name").toString() : name;

    // we will use a ListWidgetItem, but replacing the filePath property used by the filenav by the Exec property of the .desktop ! :D
    // it's necessary to pass this information to the slot called when the user selects its application, that does'nt know anything about it
    ListWidgetItem *it = new ListWidgetItem(false, s.value("Exec").toString().replace("%u", m_file_path).replace("%U", m_file_path), m_list);
    it->setText(name);
    it->setIcon(ic);
    m_list->addItem(it);

    // close the QSettings
    s.endGroup();
}