コード例 #1
0
frmOpenSubtitlesConfig::frmOpenSubtitlesConfig(QWidget *parent, Qt::WFlags f)
	: QDialog(parent, f)
{
	ui.setupUi(this);
	QNapi q;
	q.addEngines(q.enumerateEngines());
	setWindowIcon(q.engineByName("OpenSubtitles")->engineIcon());

	load();

	connect(ui.pbRegister, SIGNAL(clicked()), this, SLOT(pbRegisterClicked()));
}
コード例 #2
0
ファイル: frmlistsubtitles.cpp プロジェクト: zadziora/qnapi
void frmListSubtitles::setSubtitlesList(const QList<QNapiSubtitleInfo> & list)
{
    QNapi n;
    n.addEngines(n.enumerateEngines()); 

    ui.twSubtitles->clear();
    ui.twSubtitles->setColumnCount(4);
    ui.twSubtitles->setRowCount(list.size());

    ui.twSubtitles->horizontalHeader()->hide();
    ui.twSubtitles->verticalHeader()->hide();
    ui.twSubtitles->verticalHeader()->setDefaultSectionSize(20);
    ui.twSubtitles->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);

    int i = 0, good = 0, bad = 0;
    foreach(QNapiSubtitleInfo s, list)
    {
        QTableWidgetItem *item;

        bool highlight = (s.resolution != SUBTITLE_UNKNOWN);

        QBrush brush((s.resolution == SUBTITLE_GOOD) ? QColor(qRgb(200, 255, 200)) : QColor(qRgb(255, 200, 200)));      

        if(highlight && (s.resolution == SUBTITLE_GOOD))
            ++good;
        else if(highlight && (s.resolution == SUBTITLE_GOOD))
            ++bad;

        QString lang_path = QString(":/languages/") + s.lang + ".gif";
        if(QFile::exists(lang_path))
        {
            item = new QTableWidgetItem(QIcon(lang_path), "");
        }
        else
        {
            item = new QTableWidgetItem(s.lang);
        }

        if(highlight) item->setBackground(brush);
        item->setToolTip(s.comment);
        ui.twSubtitles->setItem(i, 1, item);

        item = new QTableWidgetItem(s.name);
        if(highlight) item->setBackground(brush);
        item->setToolTip(s.comment);
        ui.twSubtitles->setItem(i, 2, item);

        item = new QTableWidgetItem(s.format);
        if(highlight) item->setBackground(brush);
        item->setToolTip(s.comment);
        ui.twSubtitles->setItem(i, 3, item);

        QNapiAbstractEngine *e = n.engineByName(s.engine);
        if(e)
        {
            item = new QTableWidgetItem(e->engineIcon(), "");
            if(highlight) item->setBackground(brush);
            item->setToolTip(s.comment);
            ui.twSubtitles->setItem(i, 0, item);
        }

        ++i;
    }