Mercurial > hg > easaier-soundaccess
view widgets/BrowseLineEdit.cpp @ 282:d9319859a4cf tip
(none)
author | benoitrigolleau |
---|---|
date | Fri, 31 Oct 2008 11:00:24 +0000 |
parents | a6b881972a62 |
children |
line wrap: on
line source
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ /* Sound Access EASAIER client application. Silogic 2007. Laure Bajard. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See the file COPYING included with this distribution for more information. */ #include <QFileDialog> #include <QMessageBox> #include <QHBoxLayout> #include "BrowseLineEdit.h" BrowseLineEdit::BrowseLineEdit(void) : QWidget() { QHBoxLayout *mainLayout = new QHBoxLayout; mainLayout->setSpacing(0); mainLayout->setMargin(0); m_lineEdit = new QLineEdit(); m_browseButton = new QPushButton(tr("&Browse...")); connect(m_lineEdit, SIGNAL(textChanged(const QString &)), this, SIGNAL(textChanged(const QString &))); connect(m_browseButton, SIGNAL(clicked()), this, SLOT(browse())); mainLayout->addWidget(m_lineEdit); mainLayout->addSpacing(10); mainLayout->addWidget(m_browseButton); setLayout(mainLayout); } BrowseLineEdit::~BrowseLineEdit(void) { } void BrowseLineEdit::browse() { QString curPath = m_lineEdit->text(); QString path = QFileDialog::getOpenFileName(this, tr("Select file"), curPath); if (path.isEmpty()) return; if (!(QFileInfo(path).exists() && QFileInfo(path).isFile() && QFileInfo(path).isReadable())) { QMessageBox::critical(this, tr("Failed to open file"), tr("File \"%1\" does not exist or is not a readable file").arg(path)); return; } m_lineEdit->setText(path); }