void GettingStartedWelcomePageWidget::slotOpenExample()
{
    QAction *action = qobject_cast<QAction*>(sender());
    if (!action)
        return;

    QString helpFile = action->property(HelpPathPropertyName).toString();
    QString proFile = action->property(ExamplePathPropertyName).toString();
    QString qmlMainFileName;
    bool isQmlProject = false;
    if (action->dynamicPropertyNames().contains(QmlMainFileName)) {
        qmlMainFileName = action->property(QmlMainFileName).toString();
        isQmlProject = true;
    }
    QStringList files;

    QFileInfo proFileInfo(proFile);
    // If the Qt is a distro Qt on Linux, it will not be writable, hence compilation will fail
    if (!proFileInfo.isWritable())
    {
        QDialog d;
        QGridLayout *lay = new QGridLayout(&d);
        QLabel *descrLbl = new QLabel;
        d.setWindowTitle(tr("Copy Project to writable Location?"));
        descrLbl->setTextFormat(Qt::RichText);
        descrLbl->setWordWrap(true);
        descrLbl->setText(tr("<p>The project you are about to open is located in the "
                             "write-protected location:</p><blockquote>%1</blockquote>"
                             "<p>Please select a writable location below and click \"Copy Project and Open\" "
                             "to open a modifiable copy of the project or click \"Keep Project and Open\" "
                             "to open the project in location.</p><p><b>Note:</b> You will not "
                             "be able to alter or compile your project in the current location.</p>")
                          .arg(QDir::toNativeSeparators(proFileInfo.dir().absolutePath())));
        lay->addWidget(descrLbl, 0, 0, 1, 2);
        QLabel *txt = new QLabel(tr("&Location:"));
        Utils::PathChooser *chooser = new Utils::PathChooser;
        txt->setBuddy(chooser);
        chooser->setExpectedKind(Utils::PathChooser::ExistingDirectory);
        QSettings *settings = Core::ICore::instance()->settings();
        chooser->setPath(settings->value(
                QString::fromLatin1("General/ProjectsFallbackRoot"), QDir::homePath()).toString());
        lay->addWidget(txt, 1, 0);
        lay->addWidget(chooser, 1, 1);
        QDialogButtonBox *bb = new QDialogButtonBox;
        connect(bb, SIGNAL(accepted()), &d, SLOT(accept()));
        connect(bb, SIGNAL(rejected()), &d, SLOT(reject()));
        QPushButton *copyBtn = bb->addButton(tr("&Copy Project and Open"), QDialogButtonBox::AcceptRole);
        copyBtn->setDefault(true);
        bb->addButton(tr("&Keep Project and Open"), QDialogButtonBox::RejectRole);
        lay->addWidget(bb, 2, 0, 1, 2);
        connect(chooser, SIGNAL(validChanged(bool)), copyBtn, SLOT(setEnabled(bool)));
        if (d.exec() == QDialog::Accepted) {
            QString exampleDirName = proFileInfo.dir().dirName();
            QString toDir = chooser->path();
            settings->setValue(QString::fromLatin1("General/ProjectsFallbackRoot"), toDir);
            QDir toDirWithExamplesDir(toDir);
            if (toDirWithExamplesDir.cd(exampleDirName)) {
                toDirWithExamplesDir.cdUp(); // step out, just to not be in the way
                QMessageBox::warning(topLevelWidget(), tr("Warning"),
                                     tr("The specified location already exists. "
                                        "Please specify a valid location."),
                                     QMessageBox::Ok, QMessageBox::NoButton);
                return;
            } else {
                QDir from = proFileInfo.dir();
                from.cdUp();
                copyRecursive(from, toDir, exampleDirName);
                // set vars to new location
                proFileInfo = QFileInfo(toDir + '/'+ exampleDirName + '/' + proFileInfo.fileName());
                proFile = proFileInfo.absoluteFilePath();
            }
        }
    }

    QString tryFile;
    files << proFile;
    if (isQmlProject) {
        tryFile = proFileInfo.path() + '/' + "/main.qml";
        if(!QFile::exists(tryFile))
            tryFile = proFileInfo.path() + "/qml/" + qmlMainFileName + ".qml";
        // legacy qmlproject case
        if(!QFile::exists(tryFile))
            tryFile = proFileInfo.path() + '/' + qmlMainFileName + ".qml";
        if(QFile::exists(tryFile))
            files << tryFile;
    } else {
        tryFile = proFileInfo.path() + "/main.cpp";
        if(!QFile::exists(tryFile))
            tryFile = proFileInfo.path() + '/' + proFileInfo.baseName() + ".cpp";
    }
    Core::ICore::instance()->openFiles(files, static_cast<Core::ICore::OpenFilesFlags>(Core::ICore::SwitchMode | Core::ICore::StopOnLoadFail));
    if (!tryFile.isEmpty() && Core::EditorManager::instance()->hasEditor(tryFile) && !helpFile.isEmpty())
        slotOpenContextHelpPage(helpFile);
}
QWidget* GCF::ActionContainerWidget::createWidget(QAction* action, int rowSpan, int colSpan)
{
    QWidget* ret = 0;
    int gSize=int((fontMetrics().height()+fontMetrics().ascent())*1.2);
    int minWidth = gSize*colSpan;

    QWidgetAction* wAction = qobject_cast<QWidgetAction*>(action);
    if(wAction)
        ret = wAction->requestWidget(this);
    else
    {
        QToolButton* tb = new QToolButton(this);
        tb->setDefaultAction(action);
        tb->setAutoRaise(true);
        /*if(action->menu())
            tb->setMenu(action->menu());*/
        tb->setIconSize(QSize(gSize-4,gSize-4));

        if(action->icon().isNull())
            tb->setToolButtonStyle(Qt::ToolButtonTextOnly);
        else if(colSpan == rowSpan && colSpan >= 2)
            tb->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
        else if(colSpan == rowSpan && colSpan == 1)
            tb->setToolButtonStyle(Qt::ToolButtonIconOnly);
        else if(colSpan >= 2 || rowSpan == 1)
            tb->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
        else if(rowSpan >= 3)
            tb->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);

        int mw = 0;
        if(tb->toolButtonStyle() != Qt::ToolButtonIconOnly)
            mw += fontMetrics().width(action->iconText())+2*fontMetrics().width("_");

        if(!action->icon().isNull())
        {
            switch(tb->toolButtonStyle())
            {
            case Qt::ToolButtonTextUnderIcon:
                if(mw < gSize-4)
                    mw = gSize-4;
                break;
            case Qt::ToolButtonTextBesideIcon:
                mw += gSize-4;
                break;
            }
        }
        if(minWidth < mw)
            minWidth = mw;

        if(action->menu())
        {
            // Connect the default action object to the tool button. This way
            // when the toolbutton with menu is clicked, the default action is
            // shown.
            QList<QAction*> actions = action->menu()->actions();
            QAction* defAction = 0;
            for(int i=0; i<actions.count(); i++)
            {
                QAction* action = actions[i];
                QList<QByteArray> propNames = action->dynamicPropertyNames();
                if(propNames.contains("_default_"))
                {
                    bool val = action->property("_default_").toBool();
                    if(val)
                    {
                        defAction = action;
                        break;
                    }
                }
            }

            if(defAction)
            {
                if(defAction->isCheckable())
                    connect(tb, SIGNAL(clicked()), defAction, SLOT(toggle()));
                else
                    connect(tb, SIGNAL(clicked()), defAction, SLOT(trigger()));

                QFont font = defAction->font();
                font.setBold(true);
                defAction->setFont(font);
            }
        }

        ret = tb;
    }

    ret->setMinimumSize(minWidth, gSize*rowSpan);

    if(!action->icon().isNull())
    {
        QFont font = ret->font();
        // font.setPointSize(font.pointSize()-1);
        ret->setFont(font);
    }

    /*static QPlastiqueStyle Style;
    ret->setStyle(&Style);*/

    return ret;
}