Ejemplo n.º 1
0
static void pickFilePath(QWidget *parent, QLineEdit *target)
{
	QFileDialog *dlg = new QFileDialog(parent, QString(), QDir(target->text()).absolutePath());
	dlg->setAttribute(Qt::WA_DeleteOnClose);
	QObject::connect(dlg, &QFileDialog::fileSelected, target, &QLineEdit::setText);
	dlg->show();
}
void GPlainTextLogger::ChooseFolder(QString folderPath /*= ""*/)
{
	if(folderPath.isEmpty()) {
		QFileDialog* pDialog = new QFileDialog(0, "Select folder", m_FolderPath);
		pDialog->setFileMode(QFileDialog::Directory);
		pDialog->setOption(QFileDialog::ShowDirsOnly);
		pDialog->show();
		pDialog->setAttribute(Qt::WA_DeleteOnClose);

		connect(pDialog, SIGNAL(fileSelected(QString)), this, SLOT(ChooseFolder(QString)));
		return;
	}
	
	QDir theFolder(folderPath);
	// if the folder doesn't exists, offer to create it
	if(!theFolder.exists()) {
		QMessageBox msgBox;
		msgBox.setIcon(QMessageBox::Question);
		QString strMess("The folder %1 doesn't exist.");
		strMess = strMess.arg(folderPath);
		msgBox.setText(strMess);
		msgBox.setInformativeText("Do you want to create it?");
		msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
		msgBox.setDefaultButton(QMessageBox::Yes);
		int ret = msgBox.exec();
		if(ret == QMessageBox::Yes) {
			theFolder.mkpath(folderPath);
		}
	}
	if(folderPath != m_FolderPath)
		if(theFolder.exists())
			m_FolderPath = folderPath;
}
Ejemplo n.º 3
0
 void askForFile() {
    QFileDialog * dialog = new QFileDialog(aView());
    connect(dialog, SIGNAL(fileSelected(QString)), SLOT(loadFile(QString)));
    dialog->setAcceptMode(QFileDialog::AcceptOpen);
    dialog->setAttribute(Qt::WA_DeleteOnClose);
    dialog->show();
 }
Ejemplo n.º 4
0
void ListEditor::exportData()
{
    QFileDialog* dialog = new QFileDialog(this);
    dialog->setAttribute(Qt::WA_DeleteOnClose, true);
    dialog->setAcceptMode(QFileDialog::AcceptSave);
    dialog->open();
    connect(dialog, SIGNAL(accepted()), this, SLOT(exportFileSelected()));
}
void GImageSaver::ChooseFolder()
{
	QFileDialog* pDialog = new QFileDialog(0, "Select folder", m_Folder);
	pDialog->setFileMode(QFileDialog::Directory);
	pDialog->setOption(QFileDialog::ShowDirsOnly);
	pDialog->show();	
	pDialog->setAttribute(Qt::WA_DeleteOnClose);

	connect(pDialog, SIGNAL(fileSelected(QString)), this, SLOT(SetFolder(QString)));
}
Ejemplo n.º 6
0
void CategoryDialog::showDirDialog()
{
    QFileDialog *dlg = new QFileDialog(this);
    dlg->setDirectory(ui->catpath->text());
    dlg->setAttribute(Qt::WA_DeleteOnClose);
    dlg->setFileMode(QFileDialog::DirectoryOnly);
    dlg->setWindowTitle(tr("Выбор директории"));
    dlg->setOption(QFileDialog::DontUseNativeDialog);
    dlg->setModal(true);
    connect(dlg,SIGNAL(fileSelected(QString)),this,SLOT(setCategoryDir(QString)));
    dlg->show();
}
void LXQtMainMenuConfiguration::chooseMenuFile()
{
    QFileDialog *d = new QFileDialog(this,
                                     tr("Choose menu file"),
                                     QLatin1String("/etc/xdg/menus"),
                                     tr("Menu files (*.menu)"));
    d->setWindowModality(Qt::WindowModal);
    d->setAttribute(Qt::WA_DeleteOnClose);
    connect(d, &QFileDialog::fileSelected, [&] (const QString &file) {
        ui->menuFilePathLE->setText(file);
    });
    d->show();
}
Ejemplo n.º 8
0
void loadTTeamDialog(Team &team, QObject *receiver, const char *slot)
{
    QSettings s;
    QString defaultPath = s.value("Teams/Folder").toString();
    QFileDialog *f = new QFileDialog(NULL, QObject::tr("Loading the Team"),defaultPath);
    //f->setWindowFlags(Qt::Window); //maybe the reason for crashes
    f->setAttribute(Qt::WA_DeleteOnClose);
    f->setAcceptMode(QFileDialog::AcceptOpen);
    f->setFileMode(QFileDialog::ExistingFile);
    f->show();

    TeamSaver *t = new TeamSaver(&team);
    t->setParent(f);

    QObject::connect(f, SIGNAL(fileSelected(QString)), t, SLOT(fileNameReceivedL(QString)));
    if (receiver)
        QObject::connect(f, SIGNAL(fileSelected(QString)), receiver, slot);
}
Ejemplo n.º 9
0
void saveTTeamDialog(const Team &team, QObject *receiver, const char *slot)
{
    QSettings s;
    QString defaultPath = s.value("Teams/Folder").toString();
    QFileDialog *f = new QFileDialog(NULL, QObject::tr("Saving the Team"),defaultPath, QObject::tr("Team(*.tp)"));
    //f->setWindowFlags(Qt::Window); //maybe the reason for crashes for some people
    f->setAttribute(Qt::WA_DeleteOnClose);
    f->setAcceptMode(QFileDialog::AcceptSave);
#if defined(Q_OS_MAC)
    f->setOption(QFileDialog::DontUseNativeDialog);
#endif
    f->show();

    TeamSaver *t = new TeamSaver(const_cast<Team*>(&team));
    t->setParent(f);

    QObject::connect(f, SIGNAL(fileSelected(QString)), t, SLOT(fileNameReceived(QString)));
    if (receiver)
        QObject::connect(f, SIGNAL(fileSelected(QString)), receiver, slot);
}