Пример #1
0
Konfigurator::Konfigurator(bool f, int startPage) : KPageDialog((QWidget *)0),
        firstTime(f), internalCall(false), sizeX(-1), sizeY(-1)
{
    setWindowTitle(i18n("Konfigurator - Creating Your Own Krusader"));
    setWindowModality(Qt::ApplicationModal);
    setFaceType(KPageDialog::List);

    setStandardButtons(QDialogButtonBox::Help|QDialogButtonBox::RestoreDefaults|QDialogButtonBox::Close|
                       QDialogButtonBox::Apply|QDialogButtonBox::Reset);
    button(QDialogButtonBox::Apply)->setDefault(true);

    connect(button(QDialogButtonBox::Close), SIGNAL(clicked()), SLOT(slotClose()));
    connect(button(QDialogButtonBox::Help), SIGNAL(clicked()), SLOT(slotShowHelp()));
    connect(button(QDialogButtonBox::RestoreDefaults), SIGNAL(clicked()), SLOT(slotRestoreDefaults()));
    connect(button(QDialogButtonBox::Reset), SIGNAL(clicked()), SLOT(slotReset()));
    connect(button(QDialogButtonBox::Apply), SIGNAL(clicked()), SLOT(slotApply()));
    connect(this, SIGNAL(currentPageChanged(KPageWidgetItem *, KPageWidgetItem *)), this, SLOT(slotPageSwitch(KPageWidgetItem *, KPageWidgetItem *)));
    connect(&restoreTimer, SIGNAL(timeout()), this, SLOT(slotRestorePage()));

    createLayout(startPage);

    KConfigGroup group(krConfig, "Konfigurator");
    int sx = group.readEntry("Window Width", -1);
    int sy = group.readEntry("Window Height", -1);

    if (sx != -1 && sy != -1)
        resize(sx, sy);
    else
        resize(900, 680);

    if (group.readEntry("Window Maximized",  false))
        showMaximized();
    else
        show();
}
void WidgetMain::createListWidget()
{
    {//创建Advanced面板的listWidget
        QMap<QString, QStringList>::iterator iter;
        int index = 0;
        for(iter = map_dirPath_blockNames_.begin(); iter != map_dirPath_blockNames_.end(); ++iter)
        {
            QString dirPath = iter.key();
            QStringList blocks = iter.value();

			ListWidgetAdvanceBlock *pListWidget = new ListWidgetAdvanceBlock();
			//调整QListView的item的字体大小,使用QSS设置失败,现在使用QFont的方式调整。。
			QFont font = pListWidget->font();
			font.setPixelSize(11);
			pListWidget->setFont(font);

            connect(pListWidget, SIGNAL(signalShowHelp(QString)), SLOT(slotShowHelp(QString)));
            pEditScene_->addListWidgetPointer(pListWidget);
            int tmp = 0;
            foreach (const QString &bbName, blocks)
            {
                QListWidgetItem *pItem = new QListWidgetItem(bbName);

                pItem->setData(Qt::UserRole, tmp++);
                pItem->setData(Qt::UserRole+1, bbName);

                pItem->setSizeHint(QSize(300, 20));
                pListWidget->addItem(pItem);
            }

            stackedWidgetBlockType->insertWidget(index, pListWidget);
            //map_treeWidgetItemPointer_pageIndex_.insert(dirPath, index);
            ++index;
        }
    }