27 #include <QtGui/QBrush>
28 #include <QtGui/QPainter>
29 #include <QStandardItem>
30 #include <QtCore/QTextCodec>
31 #include <QtGui/QLinearGradient>
32 #include <QtGui/QRadialGradient>
33 #include <QtCore/QTimer>
36 #include <kdeversion.h>
37 #if KDE_IS_VERSION(4, 9, 1)
38 #include <KCodecAction>
40 #include <kcodecaction.h>
43 #include <KFontDialog>
45 #include <KIconDialog>
46 #include <KFileDialog>
47 #include <KUrlCompletion>
48 #include <KWindowSystem>
50 #include <KMessageBox>
56 #include "ui_EditProfileDialog.h"
65 using namespace Konsole;
69 , _delayedPreviewTimer(new
QTimer(this))
72 setCaption(i18n(
"Edit Profile"));
73 setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Apply);
76 enableButtonApply(
false);
78 connect(
this, SIGNAL(applyClicked()),
this, SLOT(save()));
80 connect(_delayedPreviewTimer, SIGNAL(timeout()),
this, SLOT(delayedPreviewActivate()));
82 _ui =
new Ui::EditProfileDialog();
83 _ui->setupUi(mainWidget());
95 _pageNeedsUpdate.
resize(_ui->tabWidget->count());
96 connect(_ui->tabWidget, SIGNAL(currentChanged(
int)),
this,
97 SLOT(preparePage(
int)));
105 void EditProfileDialog::save()
107 if (_tempProfile->isEmpty())
115 while (iter.hasNext()) {
117 _previewedProperties.
remove(iter.key());
122 enableButtonApply(
false);
132 Q_ASSERT(_tempProfile);
135 _tempProfile->name().isEmpty())
136 || (_profile->name().isEmpty() && _tempProfile->name().isEmpty())) {
137 KMessageBox::sorry(
this,
138 i18n(
"<p>Each profile must have a name before it can be saved "
149 int count = group->profiles().
count();
150 for (
int i = 0; i < count; i++) {
151 caption += group->profiles()[i]->name();
152 if (i < (count - 1)) {
155 if (maxLength > 0 && caption.
length() > maxLength) {
163 void EditProfileDialog::updateCaption(
const Profile::Ptr profile)
165 const int MAX_GROUP_CAPTION_LENGTH = 25;
167 if (group && group->profiles().count() > 1) {
168 QString caption = groupProfileNames(group, MAX_GROUP_CAPTION_LENGTH);
169 setCaption(i18np(
"Editing profile: %2",
170 "Editing %1 profiles: %2",
171 group->profiles().count(),
174 setCaption(i18n(
"Edit Profile \"%1\"", profile->name()));
184 updateCaption(profile);
190 _pageNeedsUpdate.
fill(
true);
191 preparePage(_ui->tabWidget->currentIndex());
201 void EditProfileDialog::preparePage(
int page)
205 Q_ASSERT(_pageNeedsUpdate.
count() > page);
208 QWidget* pageWidget = _ui->tabWidget->widget(page);
210 if (_pageNeedsUpdate[page]) {
211 if (pageWidget == _ui->generalTab)
212 setupGeneralPage(profile);
213 else if (pageWidget == _ui->tabsTab)
214 setupTabsPage(profile);
215 else if (pageWidget == _ui->appearanceTab)
216 setupAppearancePage(profile);
217 else if (pageWidget == _ui->scrollingTab)
218 setupScrollingPage(profile);
219 else if (pageWidget == _ui->keyboardTab)
220 setupKeyboardPage(profile);
221 else if (pageWidget == _ui->mouseTab)
222 setupMousePage(profile);
223 else if (pageWidget == _ui->advancedTab)
224 setupAdvancedPage(profile);
228 _pageNeedsUpdate[page] =
false;
233 _ui->profileNameEdit->setFocus();
234 _ui->profileNameEdit->selectAll();
236 void EditProfileDialog::setupGeneralPage(
const Profile::Ptr profile)
240 _ui->emptyNameWarningWidget->setWordWrap(
false);
241 _ui->emptyNameWarningWidget->setCloseButtonVisible(
false);
242 _ui->emptyNameWarningWidget->setMessageType(KMessageWidget::Warning);
245 if (!group || group->profiles().count() < 2) {
246 _ui->profileNameEdit->setText(profile->name());
247 _ui->profileNameEdit->setClearButtonShown(
true);
249 _ui->emptyNameWarningWidget->setVisible(profile->name().isEmpty());
250 _ui->emptyNameWarningWidget->setText(i18n(
"Profile name is empty."));
252 _ui->profileNameEdit->setText(groupProfileNames(group, -1));
253 _ui->profileNameEdit->setEnabled(
false);
254 _ui->profileNameLabel->setEnabled(
false);
256 _ui->emptyNameWarningWidget->setVisible(
false);
260 ShellCommand command(profile->command() , profile->arguments());
261 _ui->commandEdit->setText(command.fullCommand());
262 KUrlCompletion* exeCompletion =
new KUrlCompletion(KUrlCompletion::ExeCompletion);
263 exeCompletion->setParent(
this);
264 exeCompletion->setDir(
QString());
265 _ui->commandEdit->setCompletionObject(exeCompletion);
267 _ui->initialDirEdit->setText(profile->defaultWorkingDirectory());
268 KUrlCompletion* dirCompletion =
new KUrlCompletion(KUrlCompletion::DirCompletion);
269 dirCompletion->setParent(
this);
270 _ui->initialDirEdit->setCompletionObject(dirCompletion);
271 _ui->initialDirEdit->setClearButtonShown(
true);
273 _ui->dirSelectButton->setIcon(KIcon(
"folder-open"));
274 _ui->iconSelectButton->setIcon(KIcon(profile->icon()));
275 _ui->startInSameDirButton->setChecked(profile->startInCurrentSessionDir());
278 _ui->terminalColumnsEntry->setValue(profile->terminalColumns());
279 _ui->terminalRowsEntry->setValue(profile->terminalRows());
282 _ui->showTerminalSizeHintButton->setChecked(profile->showTerminalSizeHint());
285 connect(_ui->dirSelectButton, SIGNAL(clicked()),
this, SLOT(selectInitialDir()));
286 connect(_ui->iconSelectButton, SIGNAL(clicked()),
this, SLOT(selectIcon()));
287 connect(_ui->startInSameDirButton, SIGNAL(toggled(
bool)),
this ,
288 SLOT(startInSameDir(
bool)));
289 connect(_ui->profileNameEdit, SIGNAL(textChanged(
QString)),
this,
290 SLOT(profileNameChanged(
QString)));
291 connect(_ui->initialDirEdit, SIGNAL(textChanged(
QString)),
this,
292 SLOT(initialDirChanged(
QString)));
293 connect(_ui->commandEdit, SIGNAL(textChanged(
QString)),
this,
294 SLOT(commandChanged(
QString)));
295 connect(_ui->environmentEditButton , SIGNAL(clicked()),
this,
296 SLOT(showEnvironmentEditor()));
298 connect(_ui->terminalColumnsEntry, SIGNAL(valueChanged(
int)),
299 this, SLOT(terminalColumnsEntryChanged(
int)));
300 connect(_ui->terminalRowsEntry, SIGNAL(valueChanged(
int)),
301 this, SLOT(terminalRowsEntryChanged(
int)));
303 connect(_ui->showTerminalSizeHintButton, SIGNAL(toggled(
bool)),
this,
304 SLOT(showTerminalSizeHint(
bool)));
306 void EditProfileDialog::showEnvironmentEditor()
311 KTextEdit* edit =
new KTextEdit(dialog.
data());
313 QStringList currentEnvironment = profile->environment();
315 edit->setPlainText(currentEnvironment.join(
"\n"));
316 edit->setToolTip(i18nc(
"@info:tooltip",
"One environment variable per line"));
318 dialog.
data()->setPlainCaption(i18n(
"Edit Environment"));
319 dialog.
data()->setMainWidget(edit);
321 if (dialog.
data()->exec() == QDialog::Accepted) {
326 delete dialog.
data();
328 void EditProfileDialog::setupTabsPage(
const Profile::Ptr profile)
331 _ui->renameTabWidget->setTabTitleText(profile->localTabTitleFormat());
332 _ui->renameTabWidget->setRemoteTabTitleText(profile->remoteTabTitleFormat());
334 connect(_ui->renameTabWidget, SIGNAL(tabTitleFormatChanged(
QString)),
this,
335 SLOT(tabTitleFormatChanged(
QString)));
336 connect(_ui->renameTabWidget, SIGNAL(remoteTabTitleFormatChanged(
QString)),
this,
337 SLOT(remoteTabTitleFormatChanged(
QString)));
340 const int silenceSeconds = profile->silenceSeconds();
341 _ui->silenceSecondsSpinner->setValue(silenceSeconds);
342 _ui->silenceSecondsSpinner->setSuffix(ki18ncp(
"Unit of time",
" second",
" seconds"));
344 connect(_ui->silenceSecondsSpinner, SIGNAL(valueChanged(
int)),
345 this, SLOT(silenceSecondsChanged(
int)));
348 void EditProfileDialog::terminalColumnsEntryChanged(
int value)
352 void EditProfileDialog::terminalRowsEntryChanged(
int value)
356 void EditProfileDialog::showTerminalSizeHint(
bool value)
360 void EditProfileDialog::tabTitleFormatChanged(
const QString& format)
364 void EditProfileDialog::remoteTabTitleFormatChanged(
const QString& format)
369 void EditProfileDialog::silenceSecondsChanged(
int seconds)
374 void EditProfileDialog::selectIcon()
376 const QString& icon = KIconDialog::getIcon(KIconLoader::Desktop, KIconLoader::Application,
377 false, 0,
false,
this);
379 _ui->iconSelectButton->setIcon(KIcon(icon));
383 void EditProfileDialog::profileNameChanged(
const QString& text)
385 _ui->emptyNameWarningWidget->setVisible(text.
isEmpty());
389 updateCaption(_tempProfile);
391 void EditProfileDialog::startInSameDir(
bool sameDir)
395 void EditProfileDialog::initialDirChanged(
const QString& dir)
399 void EditProfileDialog::commandChanged(
const QString& command)
406 void EditProfileDialog::selectInitialDir()
408 const KUrl url = KFileDialog::getExistingDirectoryUrl(_ui->initialDirEdit->text(),
410 i18n(
"Select Initial Directory"));
413 _ui->initialDirEdit->setText(url.path());
415 void EditProfileDialog::setupAppearancePage(
const Profile::Ptr profile)
418 _ui->colorSchemeList->setItemDelegate(delegate);
420 _ui->transparencyWarningWidget->setVisible(
false);
421 _ui->transparencyWarningWidget->setWordWrap(
true);
422 _ui->transparencyWarningWidget->setCloseButtonVisible(
false);
423 _ui->transparencyWarningWidget->setMessageType(KMessageWidget::Warning);
425 _ui->editColorSchemeButton->setEnabled(
false);
426 _ui->removeColorSchemeButton->setEnabled(
false);
429 updateColorSchemeList(
true);
431 _ui->colorSchemeList->setMouseTracking(
true);
432 _ui->colorSchemeList->installEventFilter(
this);
433 _ui->colorSchemeList->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
435 connect(_ui->colorSchemeList->selectionModel(),
437 this, SLOT(colorSchemeSelected()));
438 connect(_ui->colorSchemeList, SIGNAL(entered(
QModelIndex)),
this,
441 updateColorSchemeButtons();
443 connect(_ui->editColorSchemeButton, SIGNAL(clicked()),
this,
444 SLOT(editColorScheme()));
445 connect(_ui->removeColorSchemeButton, SIGNAL(clicked()),
this,
446 SLOT(removeColorScheme()));
447 connect(_ui->newColorSchemeButton, SIGNAL(clicked()),
this,
448 SLOT(newColorScheme()));
451 const bool antialias = profile->antiAliasFonts();
453 QFont profileFont = profile->font();
454 profileFont.
setStyleStrategy(antialias ? QFont::PreferAntialias : QFont::NoAntialias);
456 _ui->fontPreviewLabel->installEventFilter(
this);
457 _ui->fontPreviewLabel->setFont(profileFont);
458 setFontInputValue(profileFont);
460 connect(_ui->fontSizeInput, SIGNAL(valueChanged(
double)),
this,
461 SLOT(setFontSize(
double)));
462 connect(_ui->selectFontButton, SIGNAL(clicked()),
this,
463 SLOT(showFontDialog()));
466 _ui->antialiasTextButton->setChecked(antialias);
467 connect(_ui->antialiasTextButton, SIGNAL(toggled(
bool)),
this,
468 SLOT(setAntialiasText(
bool)));
470 _ui->boldIntenseButton->setChecked(profile->boldIntense());
471 connect(_ui->boldIntenseButton, SIGNAL(toggled(
bool)),
this,
472 SLOT(setBoldIntense(
bool)));
473 _ui->enableMouseWheelZoomButton->setChecked(profile->mouseWheelZoomEnabled());
474 connect(_ui->enableMouseWheelZoomButton, SIGNAL(toggled(
bool)),
this,
475 SLOT(toggleMouseWheelZoom(
bool)));
477 void EditProfileDialog::setAntialiasText(
bool enable)
479 QFont profileFont = _ui->fontPreviewLabel->font();
480 profileFont.
setStyleStrategy(enable ? QFont::PreferAntialias : QFont::NoAntialias);
483 fontSelected(profileFont);
486 void EditProfileDialog::setBoldIntense(
bool enable)
491 void EditProfileDialog::toggleMouseWheelZoom(
bool enable)
495 void EditProfileDialog::updateColorSchemeList(
bool selectCurrentScheme)
497 if (!_ui->colorSchemeList->model())
518 if (currentScheme == scheme)
526 if (selectCurrentScheme && selectedItem) {
527 _ui->colorSchemeList->updateGeometry();
528 _ui->colorSchemeList->selectionModel()->setCurrentIndex(selectedItem->
index() ,
529 QItemSelectionModel::Select);
532 updateTransparencyWarning();
535 void EditProfileDialog::updateKeyBindingsList(
bool selectCurrentTranslator)
537 if (!_ui->keyBindingList->model())
554 foreach(
const QString& translatorName, translatorNames) {
560 item->
setIcon(KIcon(
"preferences-desktop-keyboard"));
562 if (translator == currentTranslator)
570 if (selectCurrentTranslator && selectedItem) {
571 _ui->keyBindingList->selectionModel()->setCurrentIndex(selectedItem->
index() ,
572 QItemSelectionModel::Select);
577 if (watched == _ui->colorSchemeList && aEvent->
type() == QEvent::Leave) {
583 if (watched == _ui->fontPreviewLabel && aEvent->
type() == QEvent::FontChange) {
584 const QFont& labelFont = _ui->fontPreviewLabel->font();
585 _ui->fontPreviewLabel->setText(i18n(
"%1", labelFont.
family()));
588 return KDialog::eventFilter(watched, aEvent);
590 void EditProfileDialog::unpreviewAll()
592 _delayedPreviewTimer->
stop();
593 _delayedPreviewProperties.
clear();
597 while (iter.hasNext()) {
606 void EditProfileDialog::unpreview(
int aProperty)
608 _delayedPreviewProperties.
remove(aProperty);
610 if (!_previewedProperties.
contains(aProperty))
617 _previewedProperties.
remove(aProperty);
619 void EditProfileDialog::delayedPreview(
int aProperty ,
const QVariant& value)
621 _delayedPreviewProperties.
insert(aProperty, value);
623 _delayedPreviewTimer->
stop();
624 _delayedPreviewTimer->
start(300);
626 void EditProfileDialog::delayedPreviewActivate()
628 Q_ASSERT(qobject_cast<QTimer*>(sender()));
631 if (iter.hasNext()) {
633 preview(iter.key(), iter.value());
636 void EditProfileDialog::preview(
int aProperty ,
const QVariant& value)
641 _delayedPreviewProperties.
remove(aProperty);
650 if (group && group->profiles().count() > 1 &&
654 if (!_previewedProperties.
contains(aProperty)) {
661 void EditProfileDialog::previewColorScheme(
const QModelIndex& index)
667 void EditProfileDialog::removeColorScheme()
669 QModelIndexList selected = _ui->colorSchemeList->selectionModel()->selectedIndexes();
671 if (!selected.isEmpty()) {
675 _ui->colorSchemeList->model()->removeRow(selected.first().row());
678 void EditProfileDialog::showColorSchemeEditor(
bool isNewScheme)
681 QModelIndexList selected = _ui->colorSchemeList->selectionModel()->selectedIndexes();
684 if (!selected.isEmpty())
685 colors = model->
data(selected.first(), Qt::UserRole + 1).value<const ColorScheme*>();
694 closeColorSchemeEditor();
698 connect(_colorDialog, SIGNAL(colorSchemeSaveRequested(
ColorScheme,
bool)),
700 _colorDialog->
setup(colors, isNewScheme);
702 _colorDialog->show();
704 void EditProfileDialog::closeColorSchemeEditor()
707 _colorDialog->close();
711 void EditProfileDialog::newColorScheme()
713 showColorSchemeEditor(
true);
715 void EditProfileDialog::editColorScheme()
717 showColorSchemeEditor(
false);
719 void EditProfileDialog::saveColorScheme(
const ColorScheme& scheme,
bool isNewScheme)
730 updateColorSchemeList(
true);
734 void EditProfileDialog::colorSchemeSelected()
736 QModelIndexList selected = _ui->colorSchemeList->selectionModel()->selectedIndexes();
738 if (!selected.isEmpty()) {
740 const ColorScheme* colors = model->
data(selected.first(), Qt::UserRole + 1).value<const ColorScheme*>();
743 previewColorScheme(selected.first());
745 updateTransparencyWarning();
749 updateColorSchemeButtons();
751 void EditProfileDialog::updateColorSchemeButtons()
753 enableIfNonEmptySelection(_ui->editColorSchemeButton, _ui->colorSchemeList->selectionModel());
754 enableIfNonEmptySelection(_ui->removeColorSchemeButton, _ui->colorSchemeList->selectionModel());
756 void EditProfileDialog::updateKeyBindingsButtons()
758 enableIfNonEmptySelection(_ui->editKeyBindingsButton, _ui->keyBindingList->selectionModel());
759 enableIfNonEmptySelection(_ui->removeKeyBindingsButton, _ui->keyBindingList->selectionModel());
765 void EditProfileDialog::updateTransparencyWarning()
768 foreach(
const QModelIndex & index , _ui->colorSchemeList->selectionModel()->selectedIndexes()) {
769 bool needTransparency = index.
data(Qt::UserRole + 1).
value<
const ColorScheme*>()->opacity() < 1.0;
771 if (!needTransparency) {
772 _ui->transparencyWarningWidget->setHidden(
true);
773 }
else if (!KWindowSystem::compositingActive()) {
774 _ui->transparencyWarningWidget->setText(i18n(
"This color scheme uses a transparent background"
775 " which does not appear to be supported on your"
777 _ui->transparencyWarningWidget->setHidden(
false);
779 _ui->transparencyWarningWidget->setText(i18n(
"Konsole was started before desktop effects were enabled."
780 " You need to restart Konsole to see transparent background."));
781 _ui->transparencyWarningWidget->setHidden(
false);
786 void EditProfileDialog::createTempProfile()
789 _tempProfile->setHidden(
true);
794 _tempProfile->setProperty(aProperty, value);
798 void EditProfileDialog::updateButtonApply()
800 bool userModified =
false;
803 while (iter.hasNext()) {
810 if (_previewedProperties.
contains(static_cast<int>(aProperty))) {
811 if (value != _previewedProperties.
value(static_cast<int>(aProperty))) {
816 }
else if ((value != _profile->property<
QVariant>(aProperty))) {
822 enableButtonApply(userModified);
825 void EditProfileDialog::setupKeyboardPage(
const Profile::Ptr )
828 updateKeyBindingsList(
true);
830 connect(_ui->keyBindingList->selectionModel(),
832 SLOT(keyBindingSelected()));
833 connect(_ui->newKeyBindingsButton, SIGNAL(clicked()),
this,
834 SLOT(newKeyBinding()));
836 updateKeyBindingsButtons();
838 connect(_ui->editKeyBindingsButton, SIGNAL(clicked()),
this,
839 SLOT(editKeyBinding()));
840 connect(_ui->removeKeyBindingsButton, SIGNAL(clicked()),
this,
841 SLOT(removeKeyBinding()));
843 void EditProfileDialog::keyBindingSelected()
845 QModelIndexList selected = _ui->keyBindingList->selectionModel()->selectedIndexes();
847 if (!selected.isEmpty()) {
850 .value<const KeyboardTranslator*>();
856 updateKeyBindingsButtons();
858 void EditProfileDialog::removeKeyBinding()
860 QModelIndexList selected = _ui->keyBindingList->selectionModel()->selectedIndexes();
862 if (!selected.isEmpty()) {
865 _ui->keyBindingList->model()->removeRow(selected.first().row());
868 void EditProfileDialog::showKeyBindingEditor(
bool isNewTranslator)
870 QModelIndexList selected = _ui->keyBindingList->selectionModel()->selectedIndexes();
874 if (!selected.isEmpty())
875 translator = model->
data(selected.first(), Qt::UserRole + 1).value<const KeyboardTranslator*>();
879 Q_ASSERT(translator);
884 dialog.
data()->setCaption(i18n(
"New Key Binding List"));
886 dialog.
data()->setCaption(i18n(
"Edit Key Binding List"));
889 dialog.
data()->setMainWidget(editor);
892 editor->
setup(translator);
897 if (dialog.
data()->exec() == QDialog::Accepted) {
905 updateKeyBindingsList();
910 if (newTranslator->
name() == currentTranslator) {
914 delete dialog.
data();
916 void EditProfileDialog::newKeyBinding()
918 showKeyBindingEditor(
true);
920 void EditProfileDialog::editKeyBinding()
922 showKeyBindingEditor(
false);
924 void EditProfileDialog::setupCheckBoxes(BooleanOption* options ,
const Profile::Ptr profile)
926 while (options->button != 0) {
927 options->button->setChecked(profile->property<
bool>(options->property));
928 connect(options->button, SIGNAL(toggled(
bool)),
this, options->slot);
933 void EditProfileDialog::setupRadio(RadioOption* possibilities ,
int actual)
935 while (possibilities->button != 0) {
936 if (possibilities->value == actual)
937 possibilities->button->setChecked(
true);
939 possibilities->button->setChecked(
false);
941 connect(possibilities->button, SIGNAL(clicked()),
this, possibilities->slot);
947 void EditProfileDialog::setupScrollingPage(
const Profile::Ptr profile)
952 RadioOption positions[] = { {_ui->scrollBarHiddenButton,
Enum::ScrollBarHidden, SLOT(hideScrollBar())},
958 setupRadio(positions , scrollBarPosition);
967 const int historySize = profile->historySize();
968 _ui->historySizeWidget->setLineCount(historySize);
973 RadioOption pageamounts[] = {
979 setupRadio(pageamounts, scrollFullPage);
982 connect(_ui->historySizeWidget, SIGNAL(historySizeChanged(
int)),
983 this, SLOT(historySizeChanged(
int)));
986 void EditProfileDialog::historySizeChanged(
int lineCount)
994 void EditProfileDialog::hideScrollBar()
998 void EditProfileDialog::showScrollBarLeft()
1002 void EditProfileDialog::showScrollBarRight()
1006 void EditProfileDialog::scrollFullPage()
1010 void EditProfileDialog::scrollHalfPage()
1014 void EditProfileDialog::setupMousePage(
const Profile::Ptr profile)
1016 BooleanOption options[] = { {
1018 SLOT(toggleUnderlineLinks(
bool))
1022 SLOT(toggleCtrlRequiredForDrag(
bool))
1026 SLOT(toggleCopyTextToClipboard(
bool))
1030 SLOT(toggleTrimTrailingSpacesInSelectedText(
bool))
1034 SLOT(toggleOpenLinksByDirectClick(
bool))
1038 setupCheckBoxes(options , profile);
1042 RadioOption pasteModes[] = {
1047 setupRadio(pasteModes , middleClickPasteMode);
1050 _ui->wordCharacterEdit->setText(profile->wordCharacters());
1052 connect(_ui->wordCharacterEdit, SIGNAL(textChanged(
QString)),
this,
1053 SLOT(wordCharactersChanged(
QString)));
1056 _ui->tripleClickModeCombo->setCurrentIndex(tripleClickMode);
1058 connect(_ui->tripleClickModeCombo, SIGNAL(activated(
int)),
this,
1059 SLOT(TripleClickModeChanged(
int)));
1061 _ui->openLinksByDirectClickButton->setEnabled(_ui->underlineLinksButton->isChecked());
1063 _ui->enableMouseWheelZoomButton->setChecked(profile->mouseWheelZoomEnabled());
1064 connect(_ui->enableMouseWheelZoomButton, SIGNAL(toggled(
bool)),
this,
1065 SLOT(toggleMouseWheelZoom(
bool)));
1067 void EditProfileDialog::setupAdvancedPage(
const Profile::Ptr profile)
1069 BooleanOption options[] = { {
1071 SLOT(toggleBlinkingText(
bool))
1075 SLOT(toggleFlowControl(
bool))
1079 SLOT(toggleBlinkingCursor(
bool))
1083 SLOT(togglebidiRendering(
bool))
1087 setupCheckBoxes(options , profile);
1089 const int lineSpacing = profile->lineSpacing();
1090 _ui->lineSpacingSpinner->setValue(lineSpacing);
1092 connect(_ui->lineSpacingSpinner, SIGNAL(valueChanged(
int)),
1093 this, SLOT(lineSpacingChanged(
int)));
1096 if (profile->useCustomCursorColor())
1097 _ui->customCursorColorButton->setChecked(
true);
1099 _ui->autoCursorColorButton->setChecked(
true);
1101 _ui->customColorSelectButton->setColor(profile->customCursorColor());
1103 connect(_ui->customCursorColorButton, SIGNAL(clicked()),
this, SLOT(customCursorColor()));
1104 connect(_ui->autoCursorColorButton, SIGNAL(clicked()),
this, SLOT(autoCursorColor()));
1105 connect(_ui->customColorSelectButton, SIGNAL(changed(
QColor)),
1106 SLOT(customCursorColorChanged(
QColor)));
1109 _ui->cursorShapeCombo->setCurrentIndex(shape);
1111 connect(_ui->cursorShapeCombo, SIGNAL(activated(
int)),
this, SLOT(setCursorShape(
int)));
1114 QAction* codecAction =
new KCodecAction(
this);
1115 _ui->selectEncodingButton->setMenu(codecAction->
menu());
1116 connect(codecAction, SIGNAL(triggered(
QTextCodec*)),
this, SLOT(setDefaultCodec(
QTextCodec*)));
1118 _ui->characterEncodingLabel->setText(profile->defaultEncoding());
1120 void EditProfileDialog::setDefaultCodec(
QTextCodec* codec)
1125 _ui->characterEncodingLabel->setText(codec->
name());
1127 void EditProfileDialog::customCursorColorChanged(
const QColor& color)
1132 _ui->customCursorColorButton->click();
1134 void EditProfileDialog::wordCharactersChanged(
const QString& text)
1138 void EditProfileDialog::autoCursorColor()
1142 void EditProfileDialog::customCursorColor()
1146 void EditProfileDialog::setCursorShape(
int index)
1150 void EditProfileDialog::togglebidiRendering(
bool enable)
1154 void EditProfileDialog::lineSpacingChanged(
int spacing)
1158 void EditProfileDialog::toggleBlinkingCursor(
bool enable)
1162 void EditProfileDialog::toggleUnderlineLinks(
bool enable)
1165 _ui->openLinksByDirectClickButton->setEnabled(enable);
1167 void EditProfileDialog::toggleCtrlRequiredForDrag(
bool enable)
1171 void EditProfileDialog::toggleOpenLinksByDirectClick(
bool enable)
1175 void EditProfileDialog::toggleCopyTextToClipboard(
bool enable)
1179 void EditProfileDialog::toggleTrimTrailingSpacesInSelectedText(
bool enable)
1183 void EditProfileDialog::pasteFromX11Selection()
1187 void EditProfileDialog::pasteFromClipboard()
1191 void EditProfileDialog::TripleClickModeChanged(
int newValue)
1195 void EditProfileDialog::toggleBlinkingText(
bool enable)
1199 void EditProfileDialog::toggleFlowControl(
bool enable)
1203 void EditProfileDialog::fontSelected(
const QFont& aFont)
1205 QFont previewFont = aFont;
1207 setFontInputValue(aFont);
1209 _ui->fontPreviewLabel->setFont(previewFont);
1214 void EditProfileDialog::showFontDialog()
1216 QString sampleText =
QString(
"ell 'lL', one '1', little eye 'i', big eye");
1217 sampleText +=
QString(
"'I', lL1iI, Zero '0', little oh 'o', big oh 'O', 0oO");
1218 sampleText +=
QString(
"`~!@#$%^&*()_+-=[]\\{}|:\";'<>?,./");
1219 sampleText +=
QString(
"0123456789");
1220 sampleText +=
QString(
"\nThe Quick Brown Fox Jumps Over The Lazy Dog\n");
1221 sampleText += i18n(
"--- Type anything in this box ---");
1222 QFont currentFont = _ui->fontPreviewLabel->font();
1225 dialog.
data()->setCaption(i18n(
"Select Fixed Width Font"));
1226 dialog.
data()->setFont(currentFont,
true);
1233 chooserList.
at(0)->setSampleText(sampleText);
1235 connect(dialog.
data(), SIGNAL(fontSelected(
QFont)),
this, SLOT(fontSelected(
QFont)));
1237 if (dialog.
data()->exec() == QDialog::Rejected)
1238 fontSelected(currentFont);
1239 delete dialog.
data();
1241 void EditProfileDialog::setFontSize(
double pointSize)
1243 QFont newFont = _ui->fontPreviewLabel->font();
1245 _ui->fontPreviewLabel->setFont(newFont);
1251 void EditProfileDialog::setFontInputValue(
const QFont& aFont)
1253 _ui->fontSizeInput->setValue(aFont.
pointSizeF());
1269 bool transparencyAvailable = KWindowSystem::compositingActive();
1284 backgroundGradient.setColorAt(1 , color.
darker(115));
1286 const int backgroundRectXRoundness = 4;
1287 const int backgroundRectYRoundness = 30;
1290 backgroundRectPath.
addRoundRect(backgroundRect , backgroundRectXRoundness , backgroundRectYRoundness);
1292 if (transparencyAvailable) {
1296 painter->
setBrush(backgroundGradient);
1298 painter->
drawPath(backgroundRectPath);
1301 painter->
setBrush(backgroundGradient);
1302 painter->
drawPath(backgroundRectPath);
1308 path.
lineTo(option.rect.width() / 10.0 , option.rect.top());
1309 path.lineTo(option.rect.bottomLeft());
1310 path.lineTo(option.rect.topLeft());
1312 painter->
drawPath(path.intersected(backgroundRectPath));
1316 QLinearGradient gradient(option.rect.topLeft() , option.rect.bottomLeft());
1318 gradient.setColorAt(1 , Qt::transparent);
1322 const bool isSelected = option.state & QStyle::State_Selected;
1326 static const int selectedBorderWidth = 6;
1331 QColor highlightColor = option.palette.highlight().color();
1340 painter->
drawRect(option.rect.adjusted(selectedBorderWidth / 2,
1341 selectedBorderWidth / 2,
1342 -selectedBorderWidth / 2,
1343 -selectedBorderWidth / 2));
1350 painter->
drawText(option.rect , Qt::AlignCenter ,
1357 const int width = 200;
1360 qreal heightForWidth = (colorWidth * 2) + option.fontMetrics.height() + margin;
1363 return QSize(width, static_cast<int>(heightForWidth));
1366 #include "EditProfileDialog.moc"
void addTranslator(KeyboardTranslator *translator)
Adds a new translator.
(HistoryModeEnum) Specifies the storage type used for keeping the output produced by terminal session...
(String) Default text codec
A converter which maps between key sequences pressed by the user and the character strings which shou...
(bool) Whether fonts should be aliased or not
iterator insert(const Key &key, const T &value)
QColor darker(int factor) const
void setIcon(const QIcon &icon)
(bool) Specifies whether show hint for terminal size after resizing the application window...
virtual QByteArray name() const =0
void setCompositionMode(CompositionMode mode)
void setRenderHint(RenderHint hint, bool on)
QString description() const
Returns the descriptive name of this keyboard translator.
Qt::ItemFlags flags() const
(bool) Specifies whether the flow control keys (typically Ctrl+S, Ctrl+Q) have any effect...
(QColor) The color used by terminal displays to draw the cursor.
void setColorAt(qreal position, const QColor &color)
QVector< T > & fill(const T &value, int size)
const T & at(int i) const
(QString) The format used for tab titles when the session is running a remote command (eg...
(bool) If true, trailing spaces are trimmed in selected text
KSharedPtr< ProfileGroup > Ptr
(QString) The name of the key bindings.
void setJoinStyle(Qt::PenJoinStyle style)
Paste from X11 Selection.
(QString) A string consisting of the characters used to delimit words when selecting text in the term...
(int) Specifies the threshold of detected silence in seconds.
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
(MiddleClickPasteModeEnum) Specifies the source from which mouse middle click pastes data...
(QFont) The font to use in terminal displays using this profile.
Represents a terminal set-up which can be used to set the initial state of new terminal sessions or a...
void setBrush(const QBrush &brush)
Property
This enum describes the available properties which a Profile may consist of.
ColorSchemeViewDelegate(QObject *parent=0)
Do not show the scroll-bar.
(QString) The initial working directory for sessions created using this profile.
KeyboardTranslator * translator() const
Returns the modified translator describing the changes to the bindings and other settings which the u...
(bool) Specifies whether text in terminal displays is allowed to blink.
virtual void setData(const QVariant &value, int role)
(QString) The command to execute ( excluding arguments ) when creating a new terminal session using t...
(bool) If true, terminal displays use a fixed color to draw the cursor, specified by the CustomCursor...
EditProfileDialog(QWidget *parent=0)
Constructs a new dialog with the specified parent.
virtual bool eventFilter(QObject *watched, QEvent *event)
(QString) The untranslated name of this profile.
void drawRect(const QRectF &rectangle)
QList< const ColorScheme * > allColorSchemes()
Returns a list of the all the available color schemes.
void setName(const QString &name)
Sets the name of this keyboard translator.
A class to parse and extract information about shell commands.
qreal opacity() const
Returns the opacity level for this color scheme, see setOpacity() TODO: More documentation.
(bool) Specifies whether the cursor blinks ( in a manner similar to text editing applications ) ...
QStringList allTranslators()
Returns a list of the names of available keyboard translators.
void setDescription(const QString &description)
Sets the text of the editor's description field.
(bool) If true, automatically copy selected text into the clipboard
static ProfileManager * instance()
Returns the profile manager instance.
(bool) Whether new sessions should be started in the same directory as the currently active session...
(bool) If true, text that matches a link or an email address is underlined when hovered by the mouse ...
(bool) Whether character with intense colors should be rendered in bold font or just in bright color...
void setPen(const QColor &color)
(bool) Specifies whether the PageUp/Down will scroll the full height or half height.
void lineTo(const QPointF &endPoint)
void setFlags(QFlags< Qt::ItemFlag > flags)
void setup(const KeyboardTranslator *translator)
Initializes the dialog with the bindings and other settings from the specified translator.
(int) Specifies the pixels between the terminal lines.
void setStyleStrategy(StyleStrategy s)
(QStringList) The arguments which are passed to the program specified by the Command property when cr...
void addColorScheme(ColorScheme *scheme)
Adds a new color scheme to the manager.
bool hasSelection() const
void setBrush(const QBrush &brush)
void drawText(const QPointF &position, const QString &text)
(QString) The name of the icon associated with this profile.
virtual QVariant data(const QModelIndex &index, int role) const =0
(TripleClickModeEnum) Specifies which part of current line should be selected with triple click actio...
int remove(const Key &key)
void setup(const ColorScheme *scheme, bool isNewScheme)
Initializes the dialog with the properties of the specified color scheme.
void drawRoundRect(const QRectF &r, int xRnd, int yRnd)
(bool) Specifies whether the terminal will enable Bidirectional text display
QString description() const
Returns the descriptive name of the color scheme.
static const bool HAVE_TRANSPARENCY
void setName(const QString &name)
Sets the name of the color scheme.
const T value(const Key &key) const
HistoryModeEnum
This enum describes the modes available to remember lines of output produced by the terminal...
QColor lighter(int factor) const
const KeyboardTranslator * defaultTranslator()
Returns the default translator for Konsole.
QVariant fromValue(const T &value)
void setPointSizeF(qreal pointSize)
const Profile::Ptr lookupProfile() const
KSharedPtr< Profile > Ptr
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
const ColorScheme * findColorScheme(const QString &name)
Returns the color scheme with the given name or 0 if no scheme with that name exists.
QString name() const
Returns the name of this keyboard translator.
(int) Specifies the number of lines of output to remember in terminal sessions using this profile...
A delegate which can display and edit color schemes in a view.
void changeProfile(Profile::Ptr profile, QHash< Profile::Property, QVariant > propertyMap, bool persistent=true)
Updates a profile with the changes specified in propertyMap.
(CursorShapeEnum) The shape used by terminal displays to represent the cursor.
void drawPath(const QPainterPath &path)
QVariant data(int role) const
A dialog for editing color schemes.
virtual ~EditProfileDialog()
(ScrollBarPositionEnum) Specifies the position of the scroll bar in terminal displays using this prof...
(int) Specifies the preferred columns.
void setProfile(Profile::Ptr profile)
Initializes the dialog with the settings for the specified session type.
int count(const T &value) const
static KeyboardTranslatorManager * instance()
Returns the global KeyboardTranslatorManager instance.
(QString) The name of the color scheme to use in terminal displays using this profile.
QStringList split(const QString &sep, const QString &str, bool allowEmptyEntries)
void addRoundRect(const QRectF &r, int xRnd, int yRnd)
QModelIndex index() const
void setAlphaF(qreal alpha)
QRectF adjusted(qreal dx1, qreal dy1, qreal dx2, qreal dy2) const
(bool) If true, mouse wheel scroll with Ctrl key pressed increases/decreases the terminal font size...
QString name() const
Returns the name of the color scheme.
Show the scroll-bar on the right of the terminal display.
bool contains(const Key &key) const
QColor backgroundColor() const
Convenience method.
(QString) The format used for tab titles when running normal commands.
virtual void sort(int column, Qt::SortOrder order)
QColor foregroundColor() const
Convenience method.
Manages the keyboard translations available for use by terminal sessions, see KeyboardTranslator.
A dialog which allows the user to edit a key bindings list which maps between key combinations input ...
void appendRow(const QList< QStandardItem * > &items)
Show the scroll-bar on the left of the terminal display.
(int) Specifies the preferred rows.
(bool) If true, links can be opened by direct mouse click.
void setEditable(bool editable)
const ColorScheme * defaultColorScheme() const
Returns the default color scheme for Konsole.
void selectProfileName()
Selects the text in the profile name edit area.
(QString) The descriptive name of this profile.
static ColorSchemeManager * instance()
Returns the global color scheme manager instance.
Represents a color scheme for a terminal display.
(bool) If true, control key must be pressed to click and drag selected text.
(QStringList) Additional environment variables (in the form of NAME=VALUE pairs) which are passed to ...
const KeyboardTranslator * findTranslator(const QString &name)
Returns the keyboard translator with the given name or 0 if no translator with that name exists...