mirror of
https://github.com/august-alt/gpui.git
synced 2025-03-14 12:58:39 +03:00
131 lines
3.6 KiB
C++
131 lines
3.6 KiB
C++
/***********************************************************************************************************************
|
|
**
|
|
** Copyright (C) 2021 BaseALT Ltd. <org@basealt.ru>
|
|
**
|
|
** 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.
|
|
**
|
|
** This program is distributed in the hope that it will be useful,
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
** GNU General Public License for more details.
|
|
**
|
|
** You should have received a copy of the GNU General Public License
|
|
** along with this program; if not, write to the Free Software
|
|
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
**
|
|
***********************************************************************************************************************/
|
|
|
|
#include "fileswidget.h"
|
|
#include "ui_fileswidget.h"
|
|
|
|
#include "gui/filedialogutils.h"
|
|
|
|
using namespace gpui;
|
|
|
|
namespace preferences
|
|
{
|
|
enum ViewMode
|
|
{
|
|
CREATE__MODE = 0,
|
|
REPLACE_MODE = 1,
|
|
UPDATE__MODE = 2,
|
|
DELETE__MODE = 3
|
|
};
|
|
|
|
void FilesWidget::on_actionComboBox_currentIndexChanged(int index)
|
|
{
|
|
bool createMode = false;
|
|
bool deleteMode = false;
|
|
switch (index)
|
|
{
|
|
case ViewMode::CREATE__MODE:
|
|
createMode = true;
|
|
break;
|
|
case ViewMode::UPDATE__MODE:
|
|
case ViewMode::REPLACE_MODE:
|
|
break;
|
|
case ViewMode::DELETE__MODE:
|
|
deleteMode = true;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
ui->supressErrorsCheckBox->setDisabled(createMode);
|
|
|
|
ui->archive->setDisabled(deleteMode);
|
|
ui->hidden->setDisabled(deleteMode);
|
|
ui->executable->setDisabled(deleteMode);
|
|
ui->readOnly->setDisabled(deleteMode);
|
|
ui->sourceLineEdit->setDisabled(deleteMode);
|
|
ui->sourceToolButton->setDisabled(deleteMode);
|
|
|
|
if (deleteMode)
|
|
{
|
|
ui->sourceLineEdit->clear();
|
|
ui->destinationLabel->setText(tr("Delete file(s):"));
|
|
}
|
|
else
|
|
{
|
|
ui->destinationLabel->setText(tr("Destination file:"));
|
|
}
|
|
}
|
|
|
|
void FilesWidget::on_sourceToolButton_clicked()
|
|
{
|
|
QString newText;
|
|
if (FileDialogUtils::getOpenFileName(newText, this, QObject::tr("All files (*)")))
|
|
{
|
|
ui->sourceLineEdit->setText(newText);
|
|
}
|
|
}
|
|
|
|
void FilesWidget::on_destinationToolButton_clicked()
|
|
{
|
|
if (fileMode)
|
|
{
|
|
QString newText;
|
|
if (FileDialogUtils::getOpenFileName(newText, this, QObject::tr("All files (*)")))
|
|
{
|
|
ui->destinationLineEdit->setText(newText);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
QString newText;
|
|
if (FileDialogUtils::getOpenDirectoryName(newText, this, QObject::tr("All files (*.*)")))
|
|
{
|
|
ui->destinationLineEdit->setText(newText);
|
|
}
|
|
}
|
|
}
|
|
|
|
void FilesWidget::on_destinationLineEdit_textChanged(const QString &text)
|
|
{
|
|
ui->inputMessage->updateInput("destination", text);
|
|
}
|
|
|
|
void FilesWidget::on_sourceLineEdit_textChanged(const QString &text)
|
|
{
|
|
if (text.contains('*') || text.contains('?'))
|
|
{
|
|
fileMode = false;
|
|
|
|
ui->destinationLabel->setText(tr("Destination folder:"));
|
|
ui->inputMessage->setMessage("destination", this->whitespaceDetector, tr("destination_folder_whitespace"));
|
|
}
|
|
else
|
|
{
|
|
fileMode = true;
|
|
|
|
ui->destinationLabel->setText(tr("Destination file:"));
|
|
ui->inputMessage->setMessage("destination", this->whitespaceDetector, tr("destination_whitespace"));
|
|
}
|
|
ui->inputMessage->updateInput("source_file", text);
|
|
}
|
|
|
|
} // namespace preferences
|