Esempio n. 1
0
FileDialog::FileDialog(QWidget *parent)
    : QFileDialog(parent)
{
    // Remove the default Choose button to prevent it being updated elsewhere
    QDialogButtonBox *box = qFindChild<QDialogButtonBox*>(this);
    Q_ASSERT(box);
    box->removeButton(box->button(QDialogButtonBox::Open));

    // Add our own button so we can disable/enable it
    mChooseButton = new QPushButton(tr("&Choose"));
    mChooseButton->setIcon(QIcon::fromTheme("document-open"));
    mChooseButton->setEnabled(false);
    box->addButton(mChooseButton, QDialogButtonBox::AcceptRole);

    connect(this, SIGNAL(directoryEntered(const QString&)), this, SLOT(updateChooseButton(const QString&)));
    emit directoryEntered(directory().absolutePath());
}