diff --git a/src/EditProfileDialog.cpp b/src/EditProfileDialog.cpp index 739aeb0a1..e7652b75e 100644 --- a/src/EditProfileDialog.cpp +++ b/src/EditProfileDialog.cpp @@ -55,6 +55,7 @@ #include "SessionManager.h" #include "ShellCommand.h" #include "WindowSystemInfo.h" +#include "Enumeration.h" using namespace Konsole; @@ -965,9 +966,9 @@ void EditProfileDialog::setupScrollingPage(const Profile::Ptr profile) // setup scrollback type radio int scrollBackType = profile->property(Profile::HistoryMode); - RadioOption types[] = { {_ui->disableScrollbackButton, Profile::DisableHistory, SLOT(noScrollBack())}, - {_ui->fixedScrollbackButton, Profile::FixedSizeHistory, SLOT(fixedScrollBack())}, - {_ui->unlimitedScrollbackButton, Profile::UnlimitedHistory, SLOT(unlimitedScrollBack())}, + RadioOption types[] = { {_ui->disableScrollbackButton, Enum::NoHistory, SLOT(noScrollBack())}, + {_ui->fixedScrollbackButton, Enum::FixedSizeHistory, SLOT(fixedScrollBack())}, + {_ui->unlimitedScrollbackButton, Enum::UnlimitedHistory, SLOT(unlimitedScrollBack())}, {0, 0, 0} }; setupRadio(types , scrollBackType); @@ -989,15 +990,15 @@ void EditProfileDialog::scrollBackLinesChanged(int lineCount) } void EditProfileDialog::noScrollBack() { - updateTempProfileProperty(Profile::HistoryMode , Profile::DisableHistory); + updateTempProfileProperty(Profile::HistoryMode , Enum::NoHistory); } void EditProfileDialog::fixedScrollBack() { - updateTempProfileProperty(Profile::HistoryMode , Profile::FixedSizeHistory); + updateTempProfileProperty(Profile::HistoryMode , Enum::FixedSizeHistory); } void EditProfileDialog::unlimitedScrollBack() { - updateTempProfileProperty(Profile::HistoryMode , Profile::UnlimitedHistory); + updateTempProfileProperty(Profile::HistoryMode , Enum::UnlimitedHistory); } void EditProfileDialog::hideScrollBar() { diff --git a/src/Enumeration.h b/src/Enumeration.h new file mode 100644 index 000000000..12629f4e6 --- /dev/null +++ b/src/Enumeration.h @@ -0,0 +1,57 @@ +/* + Copyright 2012 Jekyll Wu + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License or (at your option) version 3 or any later version + accepted by the membership of KDE e.V. (or its successor appro- + ved by the membership of KDE e.V.), which shall act as a proxy + defined in Section 14 of version 3 of the license. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see http://www.gnu.org/licenses/. +*/ + +#ifndef ENUMERATION_H +#define ENUMERATION_H + +#include "konsole_export.h" + +namespace Konsole +{ + +class Enum +{ +public: + + /** + * This enum describes the modes available to remember lines of output + * produced by the terminal. + */ + enum HistoryModeEnum { + /** No output is remembered. As soon as lines of text are scrolled + * off-screen they are lost. + */ + NoHistory = 0, + /** A fixed number of lines of output are remembered. Once the + * limit is reached, the oldest lines are lost. + */ + FixedSizeHistory = 1, + /** All output is remembered for the duration of the session. + * Typically this means that lines are recorded to + * a file as they are scrolled off-screen. + */ + UnlimitedHistory = 2 + }; + +}; + +} +#endif // ENUMERATION_H + diff --git a/src/HistorySizeDialog.cpp b/src/HistorySizeDialog.cpp index 0c6e95bf9..6da6f1b32 100644 --- a/src/HistorySizeDialog.cpp +++ b/src/HistorySizeDialog.cpp @@ -102,29 +102,29 @@ void HistorySizeDialog::emitOptionsChanged() emit optionsChanged(mode() , lineCount()); } -void HistorySizeDialog::setMode(HistoryMode historyMode) +void HistorySizeDialog::setMode(Enum::HistoryModeEnum historyMode) { - if (historyMode == NoHistory) { + if (historyMode == Enum::NoHistory) { _noHistoryButton->setChecked(true); - } else if (historyMode == FixedSizeHistory) { + } else if (historyMode == Enum::FixedSizeHistory) { _fixedHistoryButton->setChecked(true); - } else if (historyMode == UnlimitedHistory) { + } else if (historyMode == Enum::UnlimitedHistory) { _unlimitedHistoryButton->setChecked(true); } } -HistorySizeDialog::HistoryMode HistorySizeDialog::mode() const +Enum::HistoryModeEnum HistorySizeDialog::mode() const { if (_noHistoryButton->isChecked()) - return NoHistory; + return Enum::NoHistory; else if (_fixedHistoryButton->isChecked()) - return FixedSizeHistory; + return Enum::FixedSizeHistory; else if (_unlimitedHistoryButton->isChecked()) - return UnlimitedHistory; + return Enum::UnlimitedHistory; Q_ASSERT(false); - return NoHistory; + return Enum::NoHistory; } int HistorySizeDialog::lineCount() const diff --git a/src/HistorySizeDialog.h b/src/HistorySizeDialog.h index ab5229846..1ced7d740 100644 --- a/src/HistorySizeDialog.h +++ b/src/HistorySizeDialog.h @@ -23,6 +23,9 @@ // KDE #include +// Konsole +#include "Enumeration.h" + class QAbstractButton; class KIntSpinBox; @@ -43,29 +46,10 @@ public: */ explicit HistorySizeDialog(QWidget* parent); - /** Specifies the type of history scroll */ - enum HistoryMode { - /** - * No history. Lines of output are lost - * as soon as they are scrolled off-screen. - */ - NoHistory, - /** - * A history which stores up to a fixed number of lines - * in memory. - */ - FixedSizeHistory, - /** - * An 'unlimited' history which stores lines of output in - * a file on disk. - */ - UnlimitedHistory - }; - /** Specifies the history mode. */ - void setMode(HistoryMode mode); + void setMode(Enum::HistoryModeEnum mode); /** Returns the history mode chosen by the user. */ - HistoryMode mode() const; + Enum::HistoryModeEnum mode() const; /** * Returns the number of lines of history to remember. * This is only valid when mode() == FixedSizeHistory, diff --git a/src/Profile.cpp b/src/Profile.cpp index 2b40229d5..a0e0bfa89 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -39,6 +39,7 @@ // Konsole #include "ShellCommand.h" +#include "Enumeration.h" using namespace Konsole; @@ -158,7 +159,7 @@ FallbackProfile::FallbackProfile() setProperty(ColorScheme, "Linux"); //use DarkPastels when is start support blue ncurses UI properly setProperty(Font, KGlobalSettings::fixedFont()); - setProperty(HistoryMode, FixedSizeHistory); + setProperty(HistoryMode, Enum::FixedSizeHistory); setProperty(HistorySize, 1000); setProperty(ScrollBarPosition, ScrollBarRight); diff --git a/src/Profile.h b/src/Profile.h index b2bbeedb3..e3c3f33fb 100644 --- a/src/Profile.h +++ b/src/Profile.h @@ -211,26 +211,6 @@ public: MenuIndex }; - /** - * This enum describes the modes available to remember lines of output - * produced by the terminal. - */ - enum HistoryModeEnum { - /** No output is remembered. As soon as lines of text are scrolled - * off-screen they are lost. - */ - DisableHistory = 0, - /** A fixed number of lines of output are remembered. Once the - * limit is reached, the oldest lines are lost. - */ - FixedSizeHistory = 1, - /** All output is remembered for the duration of the session. - * Typically this means that lines are recorded to - * a file as they are scrolled off-screen. - */ - UnlimitedHistory = 2 - }; - /** * This enum describes the positions where the terminal display's * scroll bar may be placed. diff --git a/src/SessionController.cpp b/src/SessionController.cpp index 040b5ccf1..92f2e574e 100644 --- a/src/SessionController.cpp +++ b/src/SessionController.cpp @@ -60,6 +60,7 @@ #include "ProfileList.h" #include "TerminalDisplay.h" #include "SessionManager.h" +#include "Enumeration.h" // for SaveHistoryTask #include @@ -1039,13 +1040,13 @@ void SessionController::showHistoryOptions() if (currentHistory.isEnabled()) { if (currentHistory.isUnlimited()) { - dialog->setMode(HistorySizeDialog::UnlimitedHistory); + dialog->setMode(Enum::UnlimitedHistory); } else { - dialog->setMode(HistorySizeDialog::FixedSizeHistory); + dialog->setMode(Enum::FixedSizeHistory); dialog->setLineCount(currentHistory.maximumLineCount()); } } else { - dialog->setMode(HistorySizeDialog::NoHistory); + dialog->setMode(Enum::NoHistory); } connect(dialog, SIGNAL(optionsChanged(int,int)), @@ -1061,13 +1062,13 @@ void SessionController::sessionResizeRequest(const QSize& size) void SessionController::scrollBackOptionsChanged(int mode, int lines) { switch (mode) { - case HistorySizeDialog::NoHistory: + case Enum::NoHistory: _session->setHistoryType(HistoryTypeNone()); break; - case HistorySizeDialog::FixedSizeHistory: + case Enum::FixedSizeHistory: _session->setHistoryType(CompactHistoryType(lines)); break; - case HistorySizeDialog::UnlimitedHistory: + case Enum::UnlimitedHistory: _session->setHistoryType(HistoryTypeFile()); break; } diff --git a/src/SessionManager.cpp b/src/SessionManager.cpp index a4f8ebc47..05e43ee73 100644 --- a/src/SessionManager.cpp +++ b/src/SessionManager.cpp @@ -44,6 +44,7 @@ #include "History.h" #include "ProfileReader.h" #include "ProfileWriter.h" +#include "Enumeration.h" using namespace Konsole; @@ -488,18 +489,18 @@ void SessionManager::applyProfile(Session* session, const Profile::Ptr profile , // History if (apply.shouldApply(Profile::HistoryMode) || apply.shouldApply(Profile::HistorySize)) { int mode = profile->property(Profile::HistoryMode); - switch ((Profile::HistoryModeEnum)mode) { - case Profile::DisableHistory: + switch ((Enum::HistoryModeEnum)mode) { + case Enum::NoHistory: session->setHistoryType(HistoryTypeNone()); break; - case Profile::FixedSizeHistory: { + case Enum::FixedSizeHistory: { int lines = profile->property(Profile::HistorySize); session->setHistoryType(CompactHistoryType(lines)); } break; - case Profile::UnlimitedHistory: + case Enum::UnlimitedHistory: session->setHistoryType(HistoryTypeFile()); break; }