Commit ef7c91b1 authored by Kurt Hindenburg's avatar Kurt Hindenburg

Add checkbox to allow Scrollback->Scrollback Options dialog to save to current profile.

FEATURE: 155580

svn path=/trunk/KDE/kdebase/apps/konsole/; revision=920007
parent 1c53b18d
......@@ -23,6 +23,7 @@
// Qt
#include <QtGui/QButtonGroup>
#include <QtGui/QBoxLayout>
#include <QtGui/QCheckBox>
#include <QtGui/QLabel>
#include <QtGui/QRadioButton>
#include <QtGui/QSpinBox>
......@@ -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 )
......
......@@ -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;
......
......@@ -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()
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment