• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

Konsole

HistorySizeDialog.cpp

Go to the documentation of this file.
00001 /*
00002     Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
00003 
00004     This program is free software; you can redistribute it and/or modify
00005     it under the terms of the GNU General Public License as published by
00006     the Free Software Foundation; either version 2 of the License, or
00007     (at your option) any later version.
00008 
00009     This program is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012     GNU General Public License for more details.
00013 
00014     You should have received a copy of the GNU General Public License
00015     along with this program; if not, write to the Free Software
00016     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017     02110-1301  USA.
00018 */
00019 
00020 // Own
00021 #include "HistorySizeDialog.h"
00022 
00023 // Qt
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 // KDE
00032 #include <KLocalizedString>
00033 
00034 // Konsole
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     // basic dialog properties
00049     setPlainCaption( i18n("Scrollback Options") );
00050     setButtons(  Default | Ok | Cancel );
00051     setDefaultButton(Ok);
00052     setModal( false );
00053 
00054     // dialog widgets
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     // minimum lines = 1 ( for 0 lines , "No History" mode should be used instead )
00073     // maximum lines is abritrarily chosen, I do not think it is sensible to allow this
00074     // to be set to a very large figure because that will use large amounts of memory,
00075     // if a very large log is required, "Unlimited History" mode should be used
00076     _lineCountBox->setRange( 1 , 100000 );
00077 
00078     // 1000 lines was the default in the KDE 3 series
00079     // using that for now
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     // select the fixed size mode by default
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"

Konsole

Skip menu "Konsole"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • Konsole
  • Libraries
  •   libkonq
Generated for API Reference by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal