2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "openwithdialog.h"
|
|
|
|
|
|
2015-01-10 23:40:32 +02:00
|
|
|
#include <utils/fileutils.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QPushButton>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
using namespace Core;
|
|
|
|
|
using namespace Core::Internal;
|
|
|
|
|
|
2021-08-27 12:25:31 +02:00
|
|
|
OpenWithDialog::OpenWithDialog(const Utils::FilePath &filePath, QWidget *parent)
|
2008-12-02 14:09:21 +01:00
|
|
|
: QDialog(parent)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
setupUi(this);
|
2021-08-27 12:25:31 +02:00
|
|
|
label->setText(tr("Open file \"%1\" with:").arg(filePath.fileName()));
|
2008-12-02 12:01:29 +01:00
|
|
|
buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
|
|
|
|
|
|
2016-02-02 09:10:54 +02:00
|
|
|
connect(buttonBox->button(QDialogButtonBox::Ok), &QAbstractButton::clicked,
|
|
|
|
|
this, &QDialog::accept);
|
|
|
|
|
connect(buttonBox->button(QDialogButtonBox::Cancel), &QAbstractButton::clicked,
|
|
|
|
|
this, &QDialog::reject);
|
|
|
|
|
connect(editorListWidget, &QListWidget::itemDoubleClicked,
|
|
|
|
|
this, &QDialog::accept);
|
|
|
|
|
connect(editorListWidget, &QListWidget::currentItemChanged,
|
|
|
|
|
this, &OpenWithDialog::currentItemChanged);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
setOkButtonEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OpenWithDialog::setOkButtonEnabled(bool v)
|
|
|
|
|
{
|
|
|
|
|
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(v);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OpenWithDialog::setEditors(const QStringList &editors)
|
|
|
|
|
{
|
2022-05-02 17:25:11 +02:00
|
|
|
for (const QString &e : editors)
|
2008-12-02 12:01:29 +01:00
|
|
|
editorListWidget->addItem(e);
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-06 12:26:39 +04:00
|
|
|
int OpenWithDialog::editor() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2012-05-06 12:26:39 +04:00
|
|
|
return editorListWidget->currentRow();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OpenWithDialog::setCurrentEditor(int index)
|
|
|
|
|
{
|
|
|
|
|
editorListWidget->setCurrentRow(index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OpenWithDialog::currentItemChanged(QListWidgetItem *current, QListWidgetItem *)
|
|
|
|
|
{
|
|
|
|
|
setOkButtonEnabled(current);
|
|
|
|
|
}
|