Konsole
HistorySizeDialog.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "HistorySizeDialog.h"
00022
00023
00024 #include <QtGui/QButtonGroup>
00025 #include <QtGui/QBoxLayout>
00026 #include <QtGui/QLabel>
00027 #include <QtGui/QRadioButton>
00028 #include <QtGui/QSpinBox>
00029 #include <QtGui/QWidget>
00030
00031
00032 #include <KLocalizedString>
00033
00034
00035 #include "SessionManager.h"
00036
00037 using namespace Konsole;
00038
00039 HistorySizeDialog::HistorySizeDialog( QWidget* parent )
00040 : KDialog(parent)
00041 , _noHistoryButton(0)
00042 , _fixedHistoryButton(0)
00043 , _unlimitedHistoryButton(0)
00044 , _lineCountBox(0)
00045 , _defaultMode(FixedSizeHistory)
00046 , _defaultLineCount(1000)
00047 {
00048
00049 setPlainCaption( i18n("Scrollback Options") );
00050 setButtons( Default | Ok | Cancel );
00051 setDefaultButton(Ok);
00052 setModal( false );
00053
00054
00055 QWidget* dialogWidget = new QWidget(this);
00056 setMainWidget(dialogWidget);
00057
00058 QVBoxLayout* dialogLayout = new QVBoxLayout(dialogWidget);
00059
00060 QButtonGroup* modeGroup = new QButtonGroup(this);
00061
00062 _noHistoryButton = new QRadioButton( i18n("No scrollback") );
00063 _fixedHistoryButton = new QRadioButton( i18n("Fixed size scrollback: ") );
00064 _unlimitedHistoryButton = new QRadioButton( i18n("Unlimited scrollback") );
00065
00066 modeGroup->addButton(_noHistoryButton);
00067 modeGroup->addButton(_fixedHistoryButton);
00068 modeGroup->addButton(_unlimitedHistoryButton);
00069
00070 _lineCountBox = new QSpinBox(this);
00071
00072
00073
00074
00075
00076 _lineCountBox->setRange( 1 , 100000 );
00077
00078
00079
00080 _lineCountBox->setValue( _defaultLineCount );
00081
00082 _lineCountBox->setSingleStep( _defaultLineCount / 10 );
00083
00084 QLabel* lineCountLabel = new QLabel(i18n("lines"),this);
00085 QHBoxLayout* lineCountLayout = new QHBoxLayout();
00086
00087 _fixedHistoryButton->setFocusProxy(_lineCountBox);
00088
00089 connect( _fixedHistoryButton , SIGNAL(clicked()) , _lineCountBox , SLOT(selectAll()) );
00090 lineCountLayout->addWidget(_fixedHistoryButton);
00091 lineCountLayout->addWidget(_lineCountBox);
00092 lineCountLayout->addWidget(lineCountLabel);
00093
00094 dialogLayout->addWidget(_noHistoryButton);
00095 dialogLayout->addLayout(lineCountLayout);
00096 dialogLayout->addWidget(_unlimitedHistoryButton);
00097
00098
00099 _fixedHistoryButton->click();
00100 _fixedHistoryButton->setFocus( Qt::OtherFocusReason );
00101
00102 connect(this,SIGNAL(defaultClicked()),this,SLOT(useDefaults()));
00103
00104 connect(this,SIGNAL(accepted()),this,SLOT(emitOptionsChanged()));
00105 }
00106
00107 void HistorySizeDialog::emitOptionsChanged()
00108 {
00109 emit optionsChanged( mode() , lineCount() );
00110 }
00111
00112 void HistorySizeDialog::setDefaultMode( HistoryMode mode ) { _defaultMode = mode; }
00113 HistorySizeDialog::HistoryMode HistorySizeDialog::defaultMode() const { return _defaultMode; }
00114 void HistorySizeDialog::setDefaultLineCount( int count ) { _defaultLineCount = count; }
00115 int HistorySizeDialog::defaultLineCount() const { return _defaultLineCount; }
00116
00117 void HistorySizeDialog::useDefaults()
00118 {
00119 setMode( _defaultMode );
00120 setLineCount( _defaultLineCount );
00121 }
00122
00123 void HistorySizeDialog::setMode( HistoryMode mode )
00124 {
00125 if ( mode == NoHistory )
00126 {
00127 _noHistoryButton->setChecked(true);
00128 } else if ( mode == FixedSizeHistory )
00129 {
00130 _fixedHistoryButton->setChecked(true);
00131 } else if ( mode == UnlimitedHistory )
00132 {
00133 _unlimitedHistoryButton->setChecked(true);
00134 }
00135 }
00136
00137 HistorySizeDialog::HistoryMode HistorySizeDialog::mode() const
00138 {
00139 if ( _noHistoryButton->isChecked() )
00140 return NoHistory;
00141 else if ( _fixedHistoryButton->isChecked() )
00142 return FixedSizeHistory;
00143 else if ( _unlimitedHistoryButton->isChecked() )
00144 return UnlimitedHistory;
00145
00146 Q_ASSERT(false);
00147 return NoHistory;
00148 }
00149
00150 int HistorySizeDialog::lineCount() const
00151 {
00152 return _lineCountBox->value();
00153 }
00154
00155 void HistorySizeDialog::setLineCount(int lines)
00156 {
00157 _lineCountBox->setValue(lines);
00158 }
00159
00160
00161 #include "HistorySizeDialog.moc"