diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -146,7 +146,6 @@ HistorySizeDialog.ui HistorySizeWidget.ui PrintOptions.ui - settings/FileLocationSettings.ui settings/GeneralSettings.ui settings/PartInfo.ui settings/ProfileSettings.ui @@ -170,7 +169,6 @@ Application.cpp MainWindow.cpp main.cpp - settings/FileLocationSettings.cpp settings/GeneralSettings.cpp settings/ProfileSettings.cpp settings/TabBarSettings.cpp) diff --git a/src/EditProfileDialog.cpp b/src/EditProfileDialog.cpp --- a/src/EditProfileDialog.cpp +++ b/src/EditProfileDialog.cpp @@ -20,6 +20,7 @@ // Own #include "EditProfileDialog.h" +#include "KonsoleSettings.h" // Standard #include @@ -49,6 +50,7 @@ #include #include #include +#include // Konsole #include "ui_EditProfileGeneralPage.h" @@ -170,15 +172,13 @@ auto *scrollingPageWidget = new QWidget(this); _scrollingUi = new Ui::EditProfileScrollingPage(); _scrollingUi->setupUi(scrollingPageWidget); + _scrollingUi->historySizeWidget->setTemporary(false); auto *scrollingPageItem = addPage(scrollingPageWidget, scrollingPageName); scrollingPageItem->setHeader(scrollingPageName); scrollingPageItem->setIcon(QIcon::fromTheme(QStringLiteral("transform-move-vertical"), defaultIcon)); _pages[scrollingPageItem] = Page(&EditProfileDialog::setupScrollingPage); - // adjust "history size" label height to match history size widget's first radio button - _scrollingUi->historySizeLabel->setFixedHeight(_scrollingUi->historySizeWidget->preferredLabelHeight()); - // Keyboard page const QString keyboardPageName = i18n("Keyboard"); @@ -230,6 +230,12 @@ this, &Konsole::EditProfileDialog::preparePage); createTempProfile(); + + KConfigDialogManager* manager = new KConfigDialogManager(this, KonsoleSettings::self()); + connect(_buttonBox, &QDialogButtonBox::accepted, manager, &KConfigDialogManager::updateSettings); + connect(_buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked, manager, &KConfigDialogManager::updateSettings); + connect(_buttonBox, &QDialogButtonBox::rejected, manager, &KConfigDialogManager::updateWidgets); + manager->addWidget(scrollingPageWidget); } EditProfileDialog::~EditProfileDialog() diff --git a/src/HistorySizeDialog.cpp b/src/HistorySizeDialog.cpp --- a/src/HistorySizeDialog.cpp +++ b/src/HistorySizeDialog.cpp @@ -52,7 +52,7 @@ _ui = new Ui::HistorySizeDialog(); _ui->setupUi(mainWidget); - + _ui->historySizeWidget->setTemporary(true); _ui->tempWarningWidget->setVisible(true); _ui->tempWarningWidget->setWordWrap(false); _ui->tempWarningWidget->setCloseButtonVisible(false); diff --git a/src/HistorySizeWidget.h b/src/HistorySizeWidget.h --- a/src/HistorySizeWidget.h +++ b/src/HistorySizeWidget.h @@ -48,6 +48,9 @@ /** Specifies the history mode. */ void setMode(Enum::HistoryModeEnum aMode); + /* Temporary specifies that this widget is transitory and the settings will not be saved. */ + void setTemporary(bool temporary); + /** Returns the history mode chosen by the user. */ Enum::HistoryModeEnum mode() const; @@ -61,25 +64,16 @@ */ int lineCount() const; - /** - * Return height which should be set on the widget's label - * to align with the first widget's item - */ - int preferredLabelHeight(); - Q_SIGNALS: /** Emitted when the history mode is changed. */ void historyModeChanged(Enum::HistoryModeEnum); /** Emitted when the history size is changed. */ void historySizeChanged(int); -private Q_SLOTS: - void buttonClicked(QAbstractButton *); - private: Ui::HistorySizeWidget *_ui; - + bool _temporary; // 1000 lines was the default in the KDE3 series static const int DefaultLineCount = 1000; }; diff --git a/src/HistorySizeWidget.cpp b/src/HistorySizeWidget.cpp --- a/src/HistorySizeWidget.cpp +++ b/src/HistorySizeWidget.cpp @@ -20,113 +20,106 @@ // Own #include "HistorySizeWidget.h" +#include "KonsoleSettings.h" // Qt #include #include #include #include - +#include #include +#include // Konsole #include "ui_HistorySizeWidget.h" using namespace Konsole; HistorySizeWidget::HistorySizeWidget(QWidget *parent) : QWidget(parent), - _ui(nullptr) + _ui(new Ui::HistorySizeWidget()) { - _ui = new Ui::HistorySizeWidget(); _ui->setupUi(this); + _ui->kcfg_scrollbackUseCacheLocation->setToolTip(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)); + _ui->kcfg_scrollbackUseSystemLocation->setToolTip(QStandardPaths::writableLocation(QStandardPaths::TempLocation)); // focus and select the spinner automatically when appropriate _ui->fixedSizeHistoryButton->setFocusProxy(_ui->historyLineSpinner); connect(_ui->fixedSizeHistoryButton, &QRadioButton::clicked, - _ui->historyLineSpinner, - &KPluralHandlingSpinBox::selectAll); + _ui->historyLineSpinner, &KPluralHandlingSpinBox::selectAll); - auto modeGroup = new QButtonGroup(this); - modeGroup->addButton(_ui->noHistoryButton); - modeGroup->addButton(_ui->fixedSizeHistoryButton); - modeGroup->addButton(_ui->unlimitedHistoryButton); - connect(modeGroup, - static_cast(&QButtonGroup::buttonClicked), - this, &Konsole::HistorySizeWidget::buttonClicked); + for(auto *widget : {_ui->noHistoryButton, _ui->fixedSizeHistoryButton, _ui->unlimitedHistoryButton}) { + connect(widget, &QRadioButton::clicked, this, [this]{ emit historyModeChanged(mode()); }); + } _ui->historyLineSpinner->setSuffix(ki18ncp("@label:textbox Unit of scrollback", " line", " lines")); setLineCount(HistorySizeWidget::DefaultLineCount); connect(_ui->historyLineSpinner, - static_cast(&KPluralHandlingSpinBox::valueChanged), - this, &Konsole::HistorySizeWidget::historySizeChanged); + static_cast(&KPluralHandlingSpinBox::valueChanged), + this, &Konsole::HistorySizeWidget::historySizeChanged); auto warningButtonSizePolicy = _ui->fixedSizeHistoryWarningButton->sizePolicy(); warningButtonSizePolicy.setRetainSizeWhenHidden(true); _ui->fixedSizeHistoryWarningButton->setSizePolicy(warningButtonSizePolicy); _ui->fixedSizeHistoryWarningButton->hide(); - connect(_ui->fixedSizeHistoryButton, &QAbstractButton::toggled, _ui->historyLineSpinner, &QWidget::setEnabled); - connect(_ui->fixedSizeHistoryButton, &QAbstractButton::toggled, _ui->fixedSizeHistoryWarningButton, &QWidget::setVisible); + connect(_ui->fixedSizeHistoryButton, &QAbstractButton::toggled, [this] (bool toggled) { + _ui->historyLineSpinner->setEnabled(toggled); + _ui->fixedSizeHistoryWarningButton->setVisible(toggled); + }); + connect(_ui->fixedSizeHistoryWarningButton, &QToolButton::clicked, this, [this](bool) { - const QString message = i18nc("@info:whatsthis", "When using this option, the scrollback data will be saved to RAM. If you choose a huge value, your system may run out of free RAM and cause serious issues with your system."); - const QPoint pos = QPoint(_ui->fixedSizeHistoryWrapper->width() / 2, _ui->fixedSizeHistoryWrapper->height()); - QWhatsThis::showText(_ui->fixedSizeHistoryWrapper->mapToGlobal(pos), message, _ui->fixedSizeHistoryWrapper); - }); + const QString message = i18nc("@info:whatsthis", + "When using this option, the scrollback data will be saved to RAM." + " If you choose a huge value, your system may run out of free RAM " + "and cause serious issues with your system."); + + const QPoint pos = QPoint(_ui->fixedSizeHistoryWarningButton->width() / 2, _ui->fixedSizeHistoryWarningButton->height()); + QWhatsThis::showText(_ui->fixedSizeHistoryWarningButton->mapToGlobal(pos), message, _ui->fixedSizeHistoryWarningButton); + }); _ui->unlimitedHistoryWarningButton->setSizePolicy(warningButtonSizePolicy); _ui->unlimitedHistoryWarningButton->hide(); - connect(_ui->unlimitedHistoryButton, &QAbstractButton::toggled, _ui->unlimitedHistoryWarningButton, &QWidget::setVisible); + connect(_ui->unlimitedHistoryButton, &QAbstractButton::toggled, [this](bool toggled) { + _ui->unlimitedHistoryWarningButton->setVisible(toggled); + _ui->unlimitedHistoryGroupBox->setVisible(!_temporary && toggled); + }); + connect(_ui->unlimitedHistoryWarningButton, &QToolButton::clicked, this, [this](bool) { - const auto message = xi18nc("@info:tooltip", "When using this option, the scrollback data will be written unencrypted to temporary files. Those temporary files will be deleted automatically when Konsole is closed in a normal manner.Use Settings → Configure Konsole → File Location to select the location of the temporary files."); - const QPoint pos = QPoint(_ui->unlimitedHistoryWrapper->width() / 2, _ui->unlimitedHistoryWrapper->height()); - QWhatsThis::showText(_ui->unlimitedHistoryWrapper->mapToGlobal(pos), message, _ui->unlimitedHistoryWrapper); - }); - - // Make radio buttons height equal - // fixedSizeHistoryWrapper contains radio + spinbox + toolbutton, so it - // has height always equal to or larger than single radio button, and - // radio + toolbutton - const int radioButtonHeight = _ui->fixedSizeHistoryWrapper->sizeHint().height(); - _ui->noHistoryButton->setMinimumHeight(radioButtonHeight); - _ui->unlimitedHistoryButton->setMinimumHeight(radioButtonHeight); + const auto message = xi18nc("@info:tooltip", + "When using this option, the scrollback data will be written unencrypted to " + "temporary files. Those temporary files will be deleted automatically when " + "Konsole is closed in a normal manner."); + const QPoint pos = QPoint(_ui->unlimitedHistoryWarningButton->width() / 2, _ui->unlimitedHistoryWarningButton->height()); + QWhatsThis::showText(_ui->unlimitedHistoryWarningButton->mapToGlobal(pos), message, _ui->unlimitedHistoryWarningButton); + }); } HistorySizeWidget::~HistorySizeWidget() { delete _ui; } -void HistorySizeWidget::buttonClicked(QAbstractButton *) +void HistorySizeWidget::setTemporary(bool temporary) { - Enum::HistoryModeEnum selectedMode = mode(); - emit historyModeChanged(selectedMode); + _temporary = temporary; } void HistorySizeWidget::setMode(Enum::HistoryModeEnum aMode) { - if (aMode == Enum::NoHistory) { - _ui->noHistoryButton->setChecked(true); - } else if (aMode == Enum::FixedSizeHistory) { - _ui->fixedSizeHistoryButton->setChecked(true); - } else if (aMode == Enum::UnlimitedHistory) { - _ui->unlimitedHistoryButton->setChecked(true); - } + auto widget = aMode == Enum::NoHistory ? _ui->noHistoryButton + : aMode == Enum::FixedSizeHistory ? _ui->fixedSizeHistoryButton + : /* aMode == Enum::UnlimitedHistory */ _ui->unlimitedHistoryButton; + widget->setChecked(true); } Enum::HistoryModeEnum HistorySizeWidget::mode() const { - if (_ui->noHistoryButton->isChecked()) { - return Enum::NoHistory; - } else if (_ui->fixedSizeHistoryButton->isChecked()) { - return Enum::FixedSizeHistory; - } else if (_ui->unlimitedHistoryButton->isChecked()) { - return Enum::UnlimitedHistory; - } - - Q_ASSERT(false); - return Enum::NoHistory; + return _ui->unlimitedHistoryButton->isChecked() ? Enum::UnlimitedHistory + : _ui->fixedSizeHistoryButton->isChecked() ? Enum::FixedSizeHistory + : /* _ui->noHistoryButton->isChecked() */ Enum::NoHistory; } void HistorySizeWidget::setLineCount(int lines) @@ -139,11 +132,3 @@ { return _ui->historyLineSpinner->value(); } - -int HistorySizeWidget::preferredLabelHeight() -{ - Q_ASSERT(_ui); - Q_ASSERT(_ui->noHistoryButton); - - return _ui->fixedSizeHistoryWrapper->sizeHint().height(); -} diff --git a/src/HistorySizeWidget.ui b/src/HistorySizeWidget.ui --- a/src/HistorySizeWidget.ui +++ b/src/HistorySizeWidget.ui @@ -6,17 +6,17 @@ 0 0 - 320 - 84 + 292 + 226 0 0 - + 0 @@ -33,160 +33,169 @@ 0 - + + + 0 + - - - 0 + + + Limit the remembered output to a fixed number of lines - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Limit the remembered output to a fixed number of lines - - - Fixed size: - - - - - - - false - - - Number of lines of output to remember - - - 1 - - - 1000000 - - - - - - - - .. - - - true - - - - - - - - - - Qt::Horizontal - - - - 0 - 20 - - - - - + + Fixed size: + + - - - 0 + + + false - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Remember all output produced by the terminal - - - Unlimited - - - - - - - - .. - - - true - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + + Number of lines of output to remember + + + 1 + + + 1000000 + + + + + + + + .. + + + true + + + + + + + + 0 + - + - Do not remember previous output + Remember all output produced by the terminal - None + Unlimited + + + + + + + + .. + + + true + + + + Unlimited scrollback file location + + + + 0 + + + + + System temporary directory + + + + + + + User cache directory + + + + + + + 0 + + + + + Custom: + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + KFile::Directory|KFile::ExistingOnly|KFile::LocalOnly + + + + + + + + + Warning: Konsole must be restarted after those changes + + + true + + + + + + + + + + Do not remember previous output + + + None + + + KPluralHandlingSpinBox QSpinBox -
KPluralHandlingSpinBox
+
kpluralhandlingspinbox.h
+
+ + KUrlRequester + QWidget +
kurlrequester.h
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -57,7 +57,6 @@ #include "KonsoleSettings.h" #include "WindowSystemInfo.h" #include "TerminalDisplay.h" -#include "settings/FileLocationSettings.h" #include "settings/GeneralSettings.h" #include "settings/ProfileSettings.h" #include "settings/TabBarSettings.h" @@ -746,11 +745,6 @@ i18nc("@title Preferences page name", "TabBar"), QStringLiteral("system-run")); - auto fileLocationSettings = new FileLocationSettings(settingsDialog); - settingsDialog->addPage(fileLocationSettings, - i18nc("@title Preferences page name", "File Location"), - QStringLiteral("configure")); - if (showProfilePage) { settingsDialog->setCurrentPage(profilePage); } diff --git a/src/settings/FileLocationSettings.h b/src/settings/FileLocationSettings.h deleted file mode 100644 --- a/src/settings/FileLocationSettings.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - Copyright 2015 Kurt Hindenburg - - 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) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor appro- - ved by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - 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, see http://www.gnu.org/licenses/. -*/ - -#ifndef FILELOCATIONSETTINGS_H -#define FILELOCATIONSETTINGS_H - -#include "ui_FileLocationSettings.h" - -namespace Konsole { -class FileLocationSettings : public QWidget, private Ui::FileLocationSettings -{ - Q_OBJECT - -public: - explicit FileLocationSettings(QWidget *aParent = nullptr); - ~FileLocationSettings() Q_DECL_OVERRIDE; -}; -} - -#endif diff --git a/src/settings/FileLocationSettings.cpp b/src/settings/FileLocationSettings.cpp deleted file mode 100644 --- a/src/settings/FileLocationSettings.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - Copyright 2015 Kurt Hindenburg - - 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) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor appro- - ved by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - 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, see http://www.gnu.org/licenses/. -*/ - -// Own -#include "FileLocationSettings.h" - -#include -#include - -using namespace Konsole; - -FileLocationSettings::FileLocationSettings(QWidget* aParent) : QWidget(aParent) -{ - setupUi(this); - - // TODO: worth adding gauge on free disk space? - useSystemLocationText->setText(QDir::tempPath()); - useUsersHomeLocationText->setText(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)); - kcfg_scrollbackUseSpecifiedLocationDirectory->setMode(KFile::Directory); - -} - -FileLocationSettings::~FileLocationSettings() = default; - diff --git a/src/settings/FileLocationSettings.ui b/src/settings/FileLocationSettings.ui deleted file mode 100644 --- a/src/settings/FileLocationSettings.ui +++ /dev/null @@ -1,252 +0,0 @@ - - - FileLocationSettings - - - - 0 - 0 - 494 - 354 - - - - - - - - 0 - 0 - - - - <b>Scrollback File Location</b><p>Use this groupbox to determine where Konsole will store the scrollback files.</p> - - - Scrollback File Location - - - - - - These settings only apply when Profile->Scrolling->Unlimited scrollback is selected. - - - true - - - - - - - Use system &location - - - true - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 50 - 20 - - - - - - - - - - - - - - - - - - 0 - 0 - - - - Use user specific location - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 50 - 20 - - - - - - - - - - - - - - - - - - 0 - 0 - - - - Use specified loca&tion - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 50 - 20 - - - - - - - - - 2 - 0 - - - - text/css - - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 30 - - - - - - - - QFrame::NoFrame - - - QFrame::Raised - - - For the 'Use user specific location', any application using KonsolePart will have the app name instead of konsole. - - - true - - - - - - - - 10 - 75 - true - true - - - - QFrame::NoFrame - - - QFrame::Raised - - - For any changes to take effect, quit Konsole and restart. - - - Qt::AlignCenter - - - true - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 50 - - - - - - - - - KUrlRequester - QFrame -
kurlrequester.h
- 1 -
-
- - -