Commit 33678e7c authored by Jekyll Wu's avatar Jekyll Wu
Browse files

Add more convenient methods for accessing profile option

parent 6511de62
......@@ -269,11 +269,11 @@ void EditProfileDialog::setupGeneralPage(const Profile::Ptr profile)
_ui->dirSelectButton->setIcon(KIcon("folder-open"));
_ui->iconSelectButton->setIcon(KIcon(profile->icon()));
_ui->startInSameDirButton->setChecked(profile->property<bool>(Profile::StartInCurrentSessionDir));
_ui->startInSameDirButton->setChecked(profile->startInCurrentSessionDir());
// window options
_ui->showTerminalSizeHintButton->setChecked(profile->property<bool>(Profile::ShowTerminalSizeHint));
_ui->saveGeometryOnExitButton->setChecked(profile->property<bool>(Profile::SaveGeometryOnExit));
_ui->showTerminalSizeHintButton->setChecked(profile->showTerminalSizeHint());
_ui->saveGeometryOnExitButton->setChecked(profile->saveGeometryOnExit());
// signals and slots
connect(_ui->dirSelectButton, SIGNAL(clicked()), this, SLOT(selectInitialDir()));
......@@ -321,12 +321,11 @@ void EditProfileDialog::setupTabsPage(const Profile::Ptr profile)
// tab title format
_ui->tabTitleEdit->setClearButtonShown(true);
_ui->remoteTabTitleEdit->setClearButtonShown(true);
_ui->tabTitleEdit->setText(profile->property<QString>(Profile::LocalTabTitleFormat));
_ui->remoteTabTitleEdit->setText(
profile->property<QString>(Profile::RemoteTabTitleFormat));
_ui->tabTitleEdit->setText(profile->localTabTitleFormat());
_ui->remoteTabTitleEdit->setText(profile->remoteTabTitleFormat());
// tab monitoring
int silenceSeconds = profile->property<int>(Profile::SilenceSeconds);
int silenceSeconds = profile->silenceSeconds();
_ui->silenceSecondsSpinner->setValue(silenceSeconds);
_ui->silenceSecondsSpinner->setSuffix(ki18ncp("Unit of time", " second", " seconds"));
......@@ -458,7 +457,7 @@ void EditProfileDialog::setupAppearancePage(const Profile::Ptr profile)
SLOT(newColorScheme()));
// setup font preview
bool antialias = profile->property<bool>(Profile::AntiAliasFonts);
bool antialias = profile->antiAliasFonts();
QFont profileFont = profile->font();
profileFont.setStyleStrategy(antialias ? QFont::PreferAntialias : QFont::NoAntialias);
......@@ -478,7 +477,7 @@ void EditProfileDialog::setupAppearancePage(const Profile::Ptr profile)
connect(_ui->antialiasTextButton, SIGNAL(toggled(bool)), this,
SLOT(setAntialiasText(bool)));
bool boldIntense = profile->property<bool>(Profile::BoldIntense);
bool boldIntense = profile->boldIntense();
_ui->boldIntenseButton->setChecked(boldIntense);
connect(_ui->boldIntenseButton, SIGNAL(toggled(bool)), this,
SLOT(setBoldIntense(bool)));
......@@ -974,7 +973,7 @@ void EditProfileDialog::setupScrollingPage(const Profile::Ptr profile)
setupRadio(types , scrollBackType);
// setup scrollback line count spinner
int historySize = profile->property<int>(Profile::HistorySize);
int historySize = profile->historySize();
_ui->scrollBackLinesSpinner->setValue(historySize);
_ui->scrollBackLinesSpinner->setSingleStep(historySize / 10);
_ui->scrollBackLinesSpinner->setSuffix(ki18ncp("Unit of scrollback", " line", " lines"));
......@@ -1039,7 +1038,7 @@ void EditProfileDialog::setupAdvancedPage(const Profile::Ptr profile)
setupCheckBoxes(options , profile);
// interaction options
_ui->wordCharacterEdit->setText(profile->property<QString>(Profile::WordCharacters));
_ui->wordCharacterEdit->setText(profile->wordCharacters());
connect(_ui->wordCharacterEdit, SIGNAL(textChanged(QString)), this,
SLOT(wordCharactersChanged(QString)));
......@@ -1051,12 +1050,12 @@ void EditProfileDialog::setupAdvancedPage(const Profile::Ptr profile)
SLOT(TripleClickModeChanged(int)));
// cursor options
if (profile->property<bool>(Profile::UseCustomCursorColor))
if (profile->useCustomCursorColor())
_ui->customCursorColorButton->setChecked(true);
else
_ui->autoCursorColorButton->setChecked(true);
_ui->customColorSelectButton->setColor(profile->property<QColor>(Profile::CustomCursorColor));
_ui->customColorSelectButton->setColor(profile->customCursorColor());
connect(_ui->customCursorColorButton, SIGNAL(clicked()), this, SLOT(customCursorColor()));
connect(_ui->autoCursorColorButton, SIGNAL(clicked()), this, SLOT(autoCursorColor()));
......@@ -1073,7 +1072,7 @@ void EditProfileDialog::setupAdvancedPage(const Profile::Ptr profile)
_ui->selectEncodingButton->setMenu(codecAction->menu());
connect(codecAction, SIGNAL(triggered(QTextCodec*)), this, SLOT(setDefaultCodec(QTextCodec*)));
_ui->characterEncodingLabel->setText(profile->property<QString>(Profile::DefaultEncoding));
_ui->characterEncodingLabel->setText(profile->defaultEncoding());
}
void EditProfileDialog::setDefaultCodec(QTextCodec* codec)
......
......@@ -445,8 +445,7 @@ Session* MainWindow::createSession(Profile::Ptr profile, const QString& director
Session* session = SessionManager::instance()->createSession(profile);
if (!directory.isEmpty()
&& profile->property<bool>(Profile::StartInCurrentSessionDir))
if (!directory.isEmpty() && profile->startInCurrentSessionDir() )
session->setInitialWorkingDirectory(directory);
session->addEnvironmentEntry( QString("KONSOLE_DBUS_WINDOW=/Windows/%1").arg(_viewManager->managerId()) );
......
......@@ -28,6 +28,7 @@
#include <QtCore/QStringList>
#include <QtCore/QVariant>
#include <QtGui/QFont>
#include <QtGui/QColor>
// KDE
#include <KSharedPtr>
......@@ -331,6 +332,26 @@ public:
return property<QStringList>(Profile::Arguments);
}
/** Convenience method for property<QString>(Profile::LocalTabTitleFormat) */
QString localTabTitleFormat() const {
return property<QString>(Profile::LocalTabTitleFormat);
}
/** Convenience method for property<QString>(Profile::RemoteTabTitleFormat) */
QString remoteTabTitleFormat() const {
return property<QString>(Profile::RemoteTabTitleFormat);
}
/** Convenience method for property<bool>(Profile::ShowTerminalSizeHint) */
bool showTerminalSizeHint() const {
return property<bool>(Profile::ShowTerminalSizeHint);
}
/** Convenience method for property<bool>(Profile::SaveGeometryOnExit) */
bool saveGeometryOnExit() const {
return property<bool>(Profile::SaveGeometryOnExit);
}
/** Convenience method for property<QFont>(Profile::Font) */
QFont font() const {
return property<QFont>(Profile::Font);
......@@ -346,6 +367,81 @@ public:
return property<QStringList>(Profile::Environment);
}
/** Convenience method for property<QString>(Profile::KeyBindings) */
QString keyBindings() const {
return property<QString>(Profile::KeyBindings);
}
/** Convenience method for property<QString>(Profile::HistorySize) */
int historySize() const {
return property<int>(Profile::HistorySize);
}
/** Convenience method for property<bool>(Profile::BidiRenderingEnabled) */
bool bidiRenderingEnabled() const {
return property<bool>(Profile::BidiRenderingEnabled);
}
/** Convenience method for property<bool>(Profile::BlinkingTextEnabled) */
bool blinkingTextEnabled() const {
return property<bool>(Profile::BlinkingTextEnabled);
}
/** Convenience method for property<bool>(Profile::BlinkingCursorEnabled) */
bool blinkingCursorEnabled() const {
return property<bool>(Profile::BlinkingCursorEnabled);
}
/** Convenience method for property<bool>(Profile::FlowControlEnabled) */
bool flowControlEnabled() const {
return property<bool>(Profile::FlowControlEnabled);
}
/** Convenience method for property<bool>(Profile::UseCustomCursorColor) */
bool useCustomCursorColor() const {
return property<bool>(Profile::UseCustomCursorColor);
}
/** Convenience method for property<bool>(Profile::CustomCursorColor) */
QColor customCursorColor() const {
return property<QColor>(Profile::CustomCursorColor);
}
/** Convenience method for property<QString>(Profile::WordCharacters) */
QString wordCharacters() const {
return property<QString>(Profile::WordCharacters);
}
/** Convenience method for property<bool>(Profile::UnderlineLinksEnabled) */
bool underlineLinksEnabled() const {
return property<bool>(Profile::UnderlineLinksEnabled);
}
/** Convenience method for property<QString>(Profile::DefaultEncoding) */
QString defaultEncoding() const {
return property<QString>(Profile::DefaultEncoding);
}
/** Convenience method for property<bool>(Profile::AntiAliasFonts) */
bool antiAliasFonts() const {
return property<bool>(Profile::AntiAliasFonts);
}
/** Convenience method for property<bool>(Profile::BoldIntense) */
bool boldIntense() const {
return property<bool>(Profile::BoldIntense);
}
/** Convenience method for property<bool>(Profile::StartInCurrentSessionDir) */
bool startInCurrentSessionDir() const {
return property<bool>(Profile::StartInCurrentSessionDir);
}
/** Convenience method for property<QString>(Profile::SilenceSeconds) */
int silenceSeconds() const {
return property<int>(Profile::SilenceSeconds);
}
/** Convenience method for property<QString>(Profile::MenuIndex) */
QString menuIndex() const {
return property<QString>(Profile::MenuIndex);
......
......@@ -1091,7 +1091,7 @@ void SessionController::clearHistory()
void SessionController::clearHistoryAndReset()
{
Profile::Ptr profile = SessionManager::instance()->sessionProfile(_session);
QByteArray name = profile->property<QString>(Profile::DefaultEncoding).toUtf8();
QByteArray name = profile->defaultEncoding().toUtf8();
Emulation* emulation = _session->emulation();
emulation->reset();
......
......@@ -476,15 +476,15 @@ void SessionManager::applyProfile(Session* session, const Profile::Ptr profile ,
// Key bindings
if (apply.shouldApply(Profile::KeyBindings))
session->setKeyBindings(profile->property<QString>(Profile::KeyBindings));
session->setKeyBindings(profile->keyBindings());
// Tab formats
if (apply.shouldApply(Profile::LocalTabTitleFormat))
session->setTabTitleFormat(Session::LocalTabTitle ,
profile->property<QString>(Profile::LocalTabTitleFormat));
profile->localTabTitleFormat());
if (apply.shouldApply(Profile::RemoteTabTitleFormat))
session->setTabTitleFormat(Session::RemoteTabTitle ,
profile->property<QString>(Profile::RemoteTabTitleFormat));
profile->remoteTabTitleFormat());
// History
if (apply.shouldApply(Profile::HistoryMode) || apply.shouldApply(Profile::HistorySize)) {
......@@ -495,7 +495,7 @@ void SessionManager::applyProfile(Session* session, const Profile::Ptr profile ,
break;
case Enum::FixedSizeHistory: {
int lines = profile->property<int>(Profile::HistorySize);
int lines = profile->historySize();
session->setHistoryType(CompactHistoryType(lines));
}
break;
......@@ -508,17 +508,17 @@ void SessionManager::applyProfile(Session* session, const Profile::Ptr profile ,
// Terminal features
if (apply.shouldApply(Profile::FlowControlEnabled))
session->setFlowControlEnabled(profile->property<bool>(Profile::FlowControlEnabled));
session->setFlowControlEnabled(profile->flowControlEnabled());
// Encoding
if (apply.shouldApply(Profile::DefaultEncoding)) {
QByteArray name = profile->property<QString>(Profile::DefaultEncoding).toUtf8();
QByteArray name = profile->defaultEncoding().toUtf8();
session->setCodec(QTextCodec::codecForName(name));
}
// Monitor Silence
if (apply.shouldApply(Profile::SilenceSeconds))
session->setMonitorSilenceSeconds(profile->property<int>(Profile::SilenceSeconds));
session->setMonitorSilenceSeconds(profile->silenceSeconds());
}
void SessionManager::addProfile(Profile::Ptr profile)
......
......@@ -765,7 +765,7 @@ void ViewManager::applyProfileToView(TerminalDisplay* view , const Profile::Ptr
{
Q_ASSERT(profile);
emit setSaveGeometryOnExitRequest(profile->property<bool>(Profile::SaveGeometryOnExit));
emit setSaveGeometryOnExitRequest(profile->saveGeometryOnExit());
emit updateWindowIcon();
......@@ -778,8 +778,8 @@ void ViewManager::applyProfileToView(TerminalDisplay* view , const Profile::Ptr
view->setWallpaper(colorScheme->wallpaper());
// load font
view->setAntialias(profile->property<bool>(Profile::AntiAliasFonts));
view->setBoldIntense(profile->property<bool>(Profile::BoldIntense));
view->setAntialias(profile->antiAliasFonts());
view->setBoldIntense(profile->boldIntense());
view->setVTFont(profile->font());
// set scroll-bar position
......@@ -793,21 +793,21 @@ void ViewManager::applyProfileToView(TerminalDisplay* view , const Profile::Ptr
view->setScrollBarPosition(Enum::ScrollBarHidden);
// show hint about termianl size after resizing
view->setShowTerminalSizeHint(profile->property<bool>(Profile::ShowTerminalSizeHint));
view->setShowTerminalSizeHint(profile->showTerminalSizeHint());
// terminal features
bool blinkingCursor = profile->property<bool>(Profile::BlinkingCursorEnabled);
bool blinkingCursor = profile->blinkingCursorEnabled();
view->setBlinkingCursorEnabled(blinkingCursor);
bool blinkingText = profile->property<bool>(Profile::BlinkingTextEnabled);
bool blinkingText = profile->blinkingTextEnabled();
view->setBlinkingTextEnabled(blinkingText);
int tripleClickMode = profile->property<int>(Profile::TripleClickMode);
view->setTripleClickMode(Enum::TripleClickModeEnum(tripleClickMode));
view->setUnderlineLinks(profile->property<bool>(Profile::UnderlineLinksEnabled));
view->setUnderlineLinks(profile->underlineLinksEnabled());
bool bidiEnabled = profile->property<bool>(Profile::BidiRenderingEnabled);
bool bidiEnabled = profile->bidiRenderingEnabled();
view->setBidiEnabled(bidiEnabled);
// cursor shape
......@@ -821,13 +821,13 @@ void ViewManager::applyProfileToView(TerminalDisplay* view , const Profile::Ptr
view->setKeyboardCursorShape(Enum::UnderlineCursor);
// cursor color
bool useCustomColor = profile->property<bool>(Profile::UseCustomCursorColor);
const QColor& cursorColor = profile->property<QColor>(Profile::CustomCursorColor);
bool useCustomColor = profile->useCustomCursorColor();
const QColor& cursorColor = profile->customCursorColor();
view->setKeyboardCursorColor(!useCustomColor, cursorColor);
// word characters
view->setWordCharacters(profile->property<QString>(Profile::WordCharacters));
view->setWordCharacters(profile->wordCharacters());
// bell mode
view->setBellMode(profile->property<int>(Profile::BellMode));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment