1 /* 2 SPDX-FileCopyrightText: 2015 Kurt Hindenburg <kurt.hindenburg@gmail.com> 3 4 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 5 */ 6 7 // Own 8 #include "TemporaryFilesSettings.h" 9 10 // Qt 11 #include <QStandardPaths> 12 13 using namespace Konsole; 14 TemporaryFilesSettings(QWidget * aParent)15TemporaryFilesSettings::TemporaryFilesSettings(QWidget *aParent) 16 : QWidget(aParent) 17 { 18 setupUi(this); 19 20 const QString tempPath = QStandardPaths::writableLocation(QStandardPaths::TempLocation); 21 QString cachePath = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); 22 #ifdef Q_OS_UNIX 23 // Use "~" instead of full path. It looks nice and helps 24 // in cases when home path is really long. 25 const QString homePath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); 26 if (cachePath.startsWith(homePath)) { 27 cachePath.replace(0, homePath.length(), QStringLiteral("~")); 28 } 29 #endif 30 31 // There's no way of doing this with strings placed in .ui file 32 kcfg_scrollbackUseSystemLocation->setText( 33 i18nc("@option:radio File location; <filename>%1</filename>: path to directory placeholder", "System temporary directory (%1)", tempPath)); 34 kcfg_scrollbackUseCacheLocation->setText( 35 i18nc("@option:radio File location; <filename>%1</filename>: path to directory placeholder", "User cache directory (%1)", cachePath)); 36 37 kcfg_scrollbackUseSpecifiedLocationDirectory->setMode(KFile::Directory); 38 } 39