~ubuntu-branches/ubuntu/precise/konsole/precise

« back to all changes in this revision

Viewing changes to src/HistorySizeDialog.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2011-12-16 13:14:43 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20111216131443-33q8agi3dii2gfqd
Tags: 4:4.7.90-0ubuntu1
New upstream beta release

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
// Qt
24
24
#include <QtGui/QButtonGroup>
25
25
#include <QtGui/QBoxLayout>
26
 
#include <QtGui/QCheckBox>
27
26
#include <QtGui/QLabel>
28
27
#include <QtGui/QRadioButton>
29
28
#include <QtGui/QWidget>
42
41
    ,  _noHistoryButton(0)
43
42
    ,  _fixedHistoryButton(0)
44
43
    ,  _unlimitedHistoryButton(0)
45
 
    ,  _saveToCurrentProfileButton(0)
46
44
    ,  _lineCountBox(0)
47
 
    ,  _defaultMode(FixedSizeHistory)
48
 
    ,  _defaultLineCount(1000)
49
45
{
50
46
    // basic dialog properties
51
 
    setPlainCaption( i18n("Scrollback Options") );
52
 
    setButtons(  Default | Ok | Cancel );
53
 
    setDefaultButton(Ok);
 
47
    setPlainCaption( i18n("Adjust Scrollback") );
 
48
    setButtons( KDialog::Ok | KDialog::Cancel );
 
49
    setDefaultButton( KDialog::Ok );
54
50
    setModal( false );
55
51
 
56
52
    // dialog widgets
59
55
 
60
56
    QVBoxLayout* dialogLayout = new QVBoxLayout(dialogWidget);
61
57
 
 
58
    _noHistoryButton        = new QRadioButton( i18n("No scrollback") );
 
59
    _fixedHistoryButton     = new QRadioButton( i18n("Fixed size scrollback: ") );
 
60
    _unlimitedHistoryButton = new QRadioButton( i18n("Unlimited scrollback") );
 
61
 
62
62
    QButtonGroup* modeGroup = new QButtonGroup(this);
63
 
 
64
 
    _noHistoryButton = new QRadioButton( i18n("No scrollback") );
65
 
    _fixedHistoryButton = new QRadioButton( i18n("Fixed size scrollback: ") );
66
 
    _unlimitedHistoryButton = new QRadioButton( i18n("Unlimited scrollback") );
67
 
    _saveToCurrentProfileButton = new QCheckBox( i18n("Save to current profile") );
68
 
 
69
63
    modeGroup->addButton(_noHistoryButton);
70
64
    modeGroup->addButton(_fixedHistoryButton);
71
65
    modeGroup->addButton(_unlimitedHistoryButton);
73
67
    _lineCountBox = new KIntSpinBox(this);
74
68
 
75
69
    // minimum lines = 1 ( for 0 lines , "No History" mode should be used instead )
76
 
    // maximum lines is abritrarily chosen, I do not think it is sensible to allow this
 
70
    // maximum lines is arbitrarily chosen, I do not think it is sensible to allow this
77
71
    // to be set to a very large figure because that will use large amounts of memory,
78
72
    // if a very large log is required, "Unlimited History" mode should be used
79
73
    _lineCountBox->setRange( 1 , 100000 );
80
74
 
81
 
    // 1000 lines was the default in the KDE 3 series
82
 
    // using that for now
83
 
    _lineCountBox->setValue( _defaultLineCount );
 
75
    _lineCountBox->setValue( HistorySizeDialog::defaultLineCount );
 
76
    _lineCountBox->setSingleStep( HistorySizeDialog::defaultLineCount / 10 );
84
77
 
85
 
    _lineCountBox->setSingleStep( _defaultLineCount / 10 );
 
78
    _fixedHistoryButton->setFocusProxy(_lineCountBox);
 
79
    connect( _fixedHistoryButton , SIGNAL(clicked()) ,
 
80
             _lineCountBox , SLOT(selectAll()) );
86
81
 
87
82
    QLabel* lineCountLabel = new QLabel(i18n("lines"),this);
 
83
 
88
84
    QHBoxLayout* lineCountLayout = new QHBoxLayout();
89
 
 
90
 
    _fixedHistoryButton->setFocusProxy(_lineCountBox);
91
 
 
92
 
    connect( _fixedHistoryButton , SIGNAL(clicked()) , _lineCountBox , SLOT(selectAll()) );
93
85
    lineCountLayout->addWidget(_fixedHistoryButton);
94
86
    lineCountLayout->addWidget(_lineCountBox);
95
87
    lineCountLayout->addWidget(lineCountLabel);
96
88
 
 
89
    QLabel* warningLabel = new QLabel(i18n("<center>The adjustment is only temporary</center>"),this);
 
90
    warningLabel->setStyleSheet("text-align:center; font-weight:normal; color:palette(dark)");
 
91
 
 
92
    dialogLayout->addWidget(warningLabel);
 
93
    dialogLayout->insertSpacing(-1, 5);
97
94
    dialogLayout->addWidget(_noHistoryButton);
98
95
    dialogLayout->addLayout(lineCountLayout);
99
96
    dialogLayout->addWidget(_unlimitedHistoryButton);
100
 
    dialogLayout->insertSpacing(3, 10);
101
 
    dialogLayout->addWidget(_saveToCurrentProfileButton);
102
 
 
103
 
    // select the fixed size mode by default
104
 
    _fixedHistoryButton->click();
105
 
    _fixedHistoryButton->setFocus( Qt::OtherFocusReason );
106
 
 
107
 
    connect(this,SIGNAL(defaultClicked()),this,SLOT(useDefaults()));
 
97
    dialogLayout->insertSpacing(-1, 10);
108
98
 
109
99
    connect(this,SIGNAL(accepted()),this,SLOT(emitOptionsChanged()));
110
100
}
111
101
 
112
102
void HistorySizeDialog::emitOptionsChanged()
113
103
{
114
 
    emit optionsChanged( mode() , lineCount(), saveToCurrentProfile() );
115
 
}
116
 
 
117
 
void HistorySizeDialog::setDefaultMode( HistoryMode mode ) { _defaultMode = mode; }
118
 
HistorySizeDialog::HistoryMode HistorySizeDialog::defaultMode() const { return _defaultMode; }
119
 
void HistorySizeDialog::setDefaultLineCount( int count ) { _defaultLineCount = count; }
120
 
int HistorySizeDialog::defaultLineCount() const { return _defaultLineCount; }
121
 
bool HistorySizeDialog::saveToCurrentProfile() const { return _saveToCurrentProfileButton->isChecked(); }
122
 
 
123
 
void HistorySizeDialog::useDefaults()
124
 
{
125
 
    setMode( _defaultMode );
126
 
    setLineCount( _defaultLineCount );
127
 
    _saveToCurrentProfileButton->setChecked(false);
 
104
    emit optionsChanged( mode() , lineCount() );
128
105
}
129
106
 
130
107
void HistorySizeDialog::setMode( HistoryMode mode )
132
109
    if ( mode == NoHistory )
133
110
    {
134
111
        _noHistoryButton->setChecked(true);
135
 
    } else if ( mode == FixedSizeHistory )
 
112
    }
 
113
    else if ( mode == FixedSizeHistory )
136
114
    {
137
115
        _fixedHistoryButton->setChecked(true);
138
 
    } else if ( mode == UnlimitedHistory )
 
116
    }
 
117
    else if ( mode == UnlimitedHistory )
139
118
    {
140
119
        _unlimitedHistoryButton->setChecked(true);
141
120
    }
 
121
 
142
122
}
143
123
 
144
124
HistorySizeDialog::HistoryMode HistorySizeDialog::mode() const
162
142
void HistorySizeDialog::setLineCount(int lines)
163
143
{
164
144
    _lineCountBox->setValue(lines);
 
145
    _lineCountBox->setSingleStep( lines / 10 );
165
146
}
166
147
 
167
148