KexiStartupDialog::KexiStartupDialog(
    int dialogType, int dialogOptions,
    KexiDBConnectionSet& connSet, KexiProjectSet& recentProjects,
    QWidget *parent)
        : KPageDialog(parent)
        , d(new Private())
{
    d->singlePage = dialogType == KexiStartupDialog::Templates
                    || dialogType == KexiStartupDialog::OpenExisting || dialogType == KexiStartupDialog::OpenRecent;
    setFaceType(d->singlePage ? Plain : Tabbed);
    setCaption(captionForDialogType(dialogType));
    setButtons(Help | Ok | Cancel);
    d->recentProjects = &recentProjects;
    d->connSet = &connSet;
    d->dialogType = dialogType;
    d->dialogOptions = dialogOptions;

    if (dialogType == OpenExisting) {//this dialog has "open" tab only!
        setWindowIcon(DesktopIcon("document-open"));
    } else {
        setWindowIcon(d->kexi_sqlite_icon);
    }

    setSizeGripEnabled(true);
// int id=0;
    KPageWidgetItem *firstPage = 0;
    if (d->dialogType & Templates) {
        setupPageTemplates();
        //d->pageTemplatesID = id++;
        d->templatesWidget->setFocus();
        if (!firstPage)
            firstPage = d->pageTemplates;
    }
    if (d->dialogType & OpenExisting) {
        setupPageOpenExisting();
//  d->pageOpenExistingID = id++;
        if (d->singlePage)
            d->openExistingConnWidget->setFocus();
        if (!firstPage)
            firstPage = d->pageOpenExisting;
    }
#ifdef KEXI_STARTUP_SHOW_RECENT
    if (d->dialogType & OpenRecent) {
        setupPageOpenRecent();
//  d->pageOpenRecentID = id++;
        if (d->singlePage)
            d->prj_selector->setFocus();
        if (!firstPage)
            firstPage = d->pageOpenRecent;
    }
#endif

    if (!d->singlePage) {
        connect(this, SIGNAL(currentPageChanged(KPageWidgetItem*, KPageWidgetItem*)),
                this, SLOT(slotCurrentPageChanged(KPageWidgetItem*, KPageWidgetItem*)));
        d->templatesWidget->setFocus();
    }
KexiStartupDialog::KexiStartupDialog(
    int dialogType, int dialogOptions,
    KexiDBConnectionSet& connSet,
    QWidget *parent)
        : KPageDialog(parent)
        , d(new Private())
{
    d->connSet = &connSet;
    d->dialogType = dialogType;
    d->dialogOptions = dialogOptions;
    d->singlePage = dialogType == KexiStartupDialog::Templates
                    || dialogType == KexiStartupDialog::OpenExisting;
    setFaceType(d->singlePage ? Plain : Tabbed);
    setWindowTitle(captionForDialogType(dialogType));

    // buttons
    QPushButton *okButton = buttonBox()->button(QDialogButtonBox::Ok);
    okButton->setDefault(true);
    okButton->setShortcut(Qt::CTRL | Qt::Key_Return);

    if (dialogType == OpenExisting) {//this dialog has "open" tab only!
        setWindowIcon(koIcon("document-open"));
    } else {
        setWindowIcon(d->kexi_sqlite_icon);
    }

    setSizeGripEnabled(true);
    KPageWidgetItem *firstPage = 0;
    if (d->dialogType & Templates) {
        setupPageTemplates();
        //d->pageTemplatesID = id++;
        d->templatesWidget->setFocus();
        if (!firstPage)
            firstPage = d->pageTemplates;
    }
    if (d->dialogType & OpenExisting) {
        setupPageOpenExisting();
        if (d->singlePage)
            d->openExistingConnWidget->setFocus();
        if (!firstPage)
            firstPage = d->pageOpenExisting;
    }

    if (!d->singlePage) {
        connect(this, SIGNAL(currentPageChanged(KPageWidgetItem*,KPageWidgetItem*)),
                this, SLOT(slotCurrentPageChanged(KPageWidgetItem*,KPageWidgetItem*)));
        d->templatesWidget->setFocus();
    }