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 );
}
예제 #2
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;
}
예제 #3
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();
}