~ubuntu-branches/ubuntu/saucy/konsole/saucy-proposed

« back to all changes in this revision

Viewing changes to src/HistorySizeDialog.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-06-06 14:29:24 UTC
  • mfrom: (1.1.12)
  • Revision ID: package-import@ubuntu.com-20120606142924-1rekqv6j25lw2k41
Tags: 4:4.8.80-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
    Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
 
3
    Copyright 2012 by Kurt Hindenburg <kurt.hindenburg@gmail.com>
3
4
 
4
5
    This program is free software; you can redistribute it and/or modify
5
6
    it under the terms of the GNU General Public License as published by
20
21
// Own
21
22
#include "HistorySizeDialog.h"
22
23
 
23
 
// Qt
24
 
#include <QtGui/QButtonGroup>
25
 
#include <QtGui/QBoxLayout>
26
 
#include <QtGui/QLabel>
27
 
#include <QtGui/QRadioButton>
28
 
#include <QtGui/QWidget>
29
 
 
30
 
// KDE
31
 
#include <KLocalizedString>
32
 
#include <KNumInput>
33
 
 
34
24
// Konsole
35
 
#include "SessionManager.h"
 
25
#include "ui_HistorySizeDialog.h"
36
26
 
37
27
using namespace Konsole;
38
28
 
39
 
HistorySizeDialog::HistorySizeDialog( QWidget* parent )
40
 
    :  KDialog(parent)
41
 
    ,  _noHistoryButton(0)
42
 
    ,  _fixedHistoryButton(0)
43
 
    ,  _unlimitedHistoryButton(0)
44
 
    ,  _lineCountBox(0)
45
 
{
46
 
    // basic dialog properties
47
 
    setPlainCaption( i18n("Adjust Scrollback") );
48
 
    setButtons( KDialog::Ok | KDialog::Cancel );
49
 
    setDefaultButton( KDialog::Ok );
50
 
    setModal( false );
51
 
 
52
 
    // dialog widgets
53
 
    QWidget* dialogWidget = new QWidget(this);
54
 
    setMainWidget(dialogWidget);
55
 
 
56
 
    QVBoxLayout* dialogLayout = new QVBoxLayout(dialogWidget);
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
 
    QButtonGroup* modeGroup = new QButtonGroup(this);
63
 
    modeGroup->addButton(_noHistoryButton);
64
 
    modeGroup->addButton(_fixedHistoryButton);
65
 
    modeGroup->addButton(_unlimitedHistoryButton);
66
 
 
67
 
    _lineCountBox = new KIntSpinBox(this);
68
 
 
69
 
    // minimum lines = 1 ( for 0 lines , "No History" mode should be used instead )
70
 
    // maximum lines is arbitrarily chosen, I do not think it is sensible to allow this
71
 
    // to be set to a very large figure because that will use large amounts of memory,
72
 
    // if a very large log is required, "Unlimited History" mode should be used
73
 
    _lineCountBox->setRange( 1 , 100000 );
74
 
 
75
 
    _lineCountBox->setValue( HistorySizeDialog::defaultLineCount );
76
 
    _lineCountBox->setSingleStep( HistorySizeDialog::defaultLineCount / 10 );
77
 
 
78
 
    _fixedHistoryButton->setFocusProxy(_lineCountBox);
79
 
    connect( _fixedHistoryButton , SIGNAL(clicked()) ,
80
 
             _lineCountBox , SLOT(selectAll()) );
81
 
 
82
 
    QLabel* lineCountLabel = new QLabel(i18n("lines"),this);
83
 
 
84
 
    QHBoxLayout* lineCountLayout = new QHBoxLayout();
85
 
    lineCountLayout->addWidget(_fixedHistoryButton);
86
 
    lineCountLayout->addWidget(_lineCountBox);
87
 
    lineCountLayout->addWidget(lineCountLabel);
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);
94
 
    dialogLayout->addWidget(_noHistoryButton);
95
 
    dialogLayout->addLayout(lineCountLayout);
96
 
    dialogLayout->addWidget(_unlimitedHistoryButton);
97
 
    dialogLayout->insertSpacing(-1, 10);
98
 
 
99
 
    connect(this,SIGNAL(accepted()),this,SLOT(emitOptionsChanged()));
100
 
}
101
 
 
102
 
void HistorySizeDialog::emitOptionsChanged()
103
 
{
104
 
    emit optionsChanged( mode() , lineCount() );
105
 
}
106
 
 
107
 
void HistorySizeDialog::setMode( HistoryMode mode )
108
 
{
109
 
    if ( mode == NoHistory )
110
 
    {
111
 
        _noHistoryButton->setChecked(true);
112
 
    }
113
 
    else if ( mode == FixedSizeHistory )
114
 
    {
115
 
        _fixedHistoryButton->setChecked(true);
116
 
    }
117
 
    else if ( mode == UnlimitedHistory )
118
 
    {
119
 
        _unlimitedHistoryButton->setChecked(true);
120
 
    }
121
 
 
122
 
}
123
 
 
124
 
HistorySizeDialog::HistoryMode HistorySizeDialog::mode() const
125
 
{
126
 
    if ( _noHistoryButton->isChecked() )
127
 
        return NoHistory;
128
 
    else if ( _fixedHistoryButton->isChecked() )
129
 
        return FixedSizeHistory;
130
 
    else if ( _unlimitedHistoryButton->isChecked() )
131
 
        return UnlimitedHistory;
132
 
 
133
 
    Q_ASSERT(false);
134
 
    return NoHistory;
 
29
HistorySizeDialog::HistorySizeDialog(QWidget* parent)
 
30
    : KDialog(parent)
 
31
{
 
32
    setCaption(i18nc("@title:window", "Adjust Scrollback"));
 
33
    setButtons(KDialog::Ok | KDialog::Cancel);
 
34
 
 
35
    setWindowModality(Qt::WindowModal);
 
36
 
 
37
    _ui = new Ui::HistorySizeDialog();
 
38
    _ui->setupUi(mainWidget());
 
39
 
 
40
    _ui->tempWarningWidget->setVisible(true);
 
41
    _ui->tempWarningWidget->setWordWrap(true);
 
42
    _ui->tempWarningWidget->setCloseButtonVisible(false);
 
43
    _ui->tempWarningWidget->setMessageType(KMessageWidget::Information);
 
44
    _ui->tempWarningWidget->setText(i18nc("@info:status",
 
45
        "Any adjustments are only temporary to this session."));
 
46
}
 
47
 
 
48
HistorySizeDialog::~HistorySizeDialog()
 
49
{
 
50
    delete _ui;
 
51
}
 
52
 
 
53
void HistorySizeDialog::setMode(Enum::HistoryModeEnum aMode)
 
54
{
 
55
    _ui->historySizeWidget->setMode(aMode);
 
56
}
 
57
 
 
58
Enum::HistoryModeEnum HistorySizeDialog::mode() const
 
59
{
 
60
    return _ui->historySizeWidget->mode();
135
61
}
136
62
 
137
63
int HistorySizeDialog::lineCount() const
138
64
{
139
 
    return _lineCountBox->value();
 
65
    return _ui->historySizeWidget->lineCount();
140
66
}
141
67
 
142
68
void HistorySizeDialog::setLineCount(int lines)
143
69
{
144
 
    _lineCountBox->setValue(lines);
145
 
    _lineCountBox->setSingleStep( lines / 10 );
 
70
    _ui->historySizeWidget->setLineCount(lines);
146
71
}
147
72
 
148
 
 
149
73
#include "HistorySizeDialog.moc"