diff --git a/src/HistorySizeDialog.cpp b/src/HistorySizeDialog.cpp index 3f7a38f01..79f215a6f 100644 --- a/src/HistorySizeDialog.cpp +++ b/src/HistorySizeDialog.cpp @@ -23,6 +23,7 @@ // Qt #include #include +#include #include #include #include @@ -41,6 +42,7 @@ HistorySizeDialog::HistorySizeDialog( QWidget* parent ) , _noHistoryButton(0) , _fixedHistoryButton(0) , _unlimitedHistoryButton(0) + , _saveToCurrentProfileButton(0) , _lineCountBox(0) , _defaultMode(FixedSizeHistory) , _defaultLineCount(1000) @@ -62,6 +64,7 @@ HistorySizeDialog::HistorySizeDialog( QWidget* parent ) _noHistoryButton = new QRadioButton( i18n("No scrollback") ); _fixedHistoryButton = new QRadioButton( i18n("Fixed size scrollback: ") ); _unlimitedHistoryButton = new QRadioButton( i18n("Unlimited scrollback") ); + _saveToCurrentProfileButton = new QCheckBox( i18n("Save to current profile") ); modeGroup->addButton(_noHistoryButton); modeGroup->addButton(_fixedHistoryButton); @@ -94,6 +97,8 @@ HistorySizeDialog::HistorySizeDialog( QWidget* parent ) dialogLayout->addWidget(_noHistoryButton); dialogLayout->addLayout(lineCountLayout); dialogLayout->addWidget(_unlimitedHistoryButton); + dialogLayout->insertSpacing(3, 10); + dialogLayout->addWidget(_saveToCurrentProfileButton); // select the fixed size mode by default _fixedHistoryButton->click(); @@ -106,18 +111,20 @@ HistorySizeDialog::HistorySizeDialog( QWidget* parent ) void HistorySizeDialog::emitOptionsChanged() { - emit optionsChanged( mode() , lineCount() ); + emit optionsChanged( mode() , lineCount(), saveToCurrentProfile() ); } void HistorySizeDialog::setDefaultMode( HistoryMode mode ) { _defaultMode = mode; } HistorySizeDialog::HistoryMode HistorySizeDialog::defaultMode() const { return _defaultMode; } void HistorySizeDialog::setDefaultLineCount( int count ) { _defaultLineCount = count; } int HistorySizeDialog::defaultLineCount() const { return _defaultLineCount; } +bool HistorySizeDialog::saveToCurrentProfile() const { return _saveToCurrentProfileButton->isChecked(); } void HistorySizeDialog::useDefaults() { setMode( _defaultMode ); setLineCount( _defaultLineCount ); + _saveToCurrentProfileButton->setChecked(false); } void HistorySizeDialog::setMode( HistoryMode mode ) diff --git a/src/HistorySizeDialog.h b/src/HistorySizeDialog.h index 8c82a47de..1baffa271 100644 --- a/src/HistorySizeDialog.h +++ b/src/HistorySizeDialog.h @@ -95,6 +95,8 @@ public: /** Returns the default line count, as set with setDefaultLineCount() */ int defaultLineCount() const; + bool saveToCurrentProfile() const; + signals: /** * Emitted when the user changes the scroll-back mode or line count and @@ -104,7 +106,7 @@ signals: * @param lineCount The current line count. This is only applicable if mode is * FixedSizeHistory */ - void optionsChanged(int mode , int lineCount); + void optionsChanged(int mode , int lineCount, bool saveToCurrentProfile); private slots: // changes the mode and line count back to the defaults @@ -119,6 +121,7 @@ private: QAbstractButton* _noHistoryButton; QAbstractButton* _fixedHistoryButton; QAbstractButton* _unlimitedHistoryButton; + QAbstractButton* _saveToCurrentProfileButton; QSpinBox* _lineCountBox; HistoryMode _defaultMode; diff --git a/src/SessionController.cpp b/src/SessionController.cpp index 5b2ae7fed..4b9aa373c 100644 --- a/src/SessionController.cpp +++ b/src/SessionController.cpp @@ -831,8 +831,8 @@ void SessionController::showHistoryOptions() else dialog->setMode( HistorySizeDialog::NoHistory ); - connect( dialog , SIGNAL(optionsChanged(int,int)) , - this , SLOT(scrollBackOptionsChanged(int,int)) ); + connect( dialog , SIGNAL(optionsChanged(int,int,bool)) , + this , SLOT(scrollBackOptionsChanged(int,int,bool)) ); dialog->show(); } @@ -841,7 +841,7 @@ void SessionController::sessionResizeRequest(const QSize& size) kDebug(1211) << "View resize requested to " << size; _view->setSize(size.width(),size.height()); } -void SessionController::scrollBackOptionsChanged( int mode , int lines ) +void SessionController::scrollBackOptionsChanged(int mode, int lines, bool saveToCurrentProfile ) { switch (mode) { @@ -855,6 +855,25 @@ void SessionController::scrollBackOptionsChanged( int mode , int lines ) _session->setHistoryType( HistoryTypeFile() ); break; } + if (saveToCurrentProfile) + { + Profile::Ptr profile = SessionManager::instance()->sessionProfile(_session); + + switch (mode) + { + case HistorySizeDialog::NoHistory: + profile->setProperty(Profile::HistoryMode , Profile::DisableHistory); + break; + case HistorySizeDialog::FixedSizeHistory: + profile->setProperty(Profile::HistoryMode , Profile::FixedSizeHistory); + profile->setProperty(Profile::HistorySize , lines); + break; + case HistorySizeDialog::UnlimitedHistory: + profile->setProperty(Profile::HistoryMode , Profile::UnlimitedHistory); + break; + } + SessionManager::instance()->changeProfile(profile, profile->setProperties()); + } } void SessionController::saveHistory() diff --git a/src/SessionController.h b/src/SessionController.h index c368aebf1..80be1ed5f 100644 --- a/src/SessionController.h +++ b/src/SessionController.h @@ -201,7 +201,7 @@ private slots: void requireUrlFilterUpdate(); void highlightMatches(bool highlight); - void scrollBackOptionsChanged(int mode , int lines); + void scrollBackOptionsChanged(int mode , int lines, bool saveToCurrentProfile); void sessionResizeRequest(const QSize& size); void trackOutput(QKeyEvent* event); // move view to end of current output // when a key press occurs in the