File indexing completed on 2024-05-05 05:53:55

0001 /*
0002   SPDX-FileCopyrightText: 2015 Kurt Hindenburg <kurt.hindenburg@gmail.com>
0003 
0004   SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005 */
0006 
0007 // Own
0008 #include "TemporaryFilesSettings.h"
0009 
0010 // Qt
0011 #include <QStandardPaths>
0012 
0013 using namespace Konsole;
0014 
0015 TemporaryFilesSettings::TemporaryFilesSettings(QWidget *aParent)
0016     : QWidget(aParent)
0017 {
0018     setupUi(this);
0019 
0020     const QString tempPath = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
0021     QString cachePath = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
0022     // Use "~" instead of full path. It looks nice and helps
0023     // in cases when home path is really long.
0024     const QString homePath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
0025     if (cachePath.startsWith(homePath)) {
0026         cachePath.replace(0, homePath.length(), QStringLiteral("~"));
0027     }
0028 
0029     // There's no way of doing this with strings placed in .ui file
0030     kcfg_scrollbackUseSystemLocation->setText(
0031         i18nc("@option:radio File location; <filename>%1</filename>: path to directory placeholder", "System temporary directory (%1)", tempPath));
0032     kcfg_scrollbackUseCacheLocation->setText(
0033         i18nc("@option:radio File location; <filename>%1</filename>: path to directory placeholder", "User cache directory (%1)", cachePath));
0034 
0035     kcfg_scrollbackUseSpecifiedLocationDirectory->setMode(KFile::Directory);
0036 }
0037 
0038 #include "moc_TemporaryFilesSettings.cpp"