Commit 53f7666e authored by Robert Knight's avatar Robert Knight
Browse files

Allow the default encoding to be specified per-profile. Something has caused...

Allow the default encoding to be specified per-profile.  Something has caused the Edit Profile dialog's minimum size to become huge, I haven't figured out what it is yet.

svn path=/trunk/KDE/kdebase/apps/konsole/; revision=670153
parent 575e19ee
......@@ -2,7 +2,7 @@
########### install files ###############
install( FILES konsole.desktop konsolesu.desktop DESTINATION ${XDG_APPS_DIR} )
install( FILES konsole.desktop konsolesu.desktop quick-access-konsole.desktop DESTINATION ${XDG_APPS_DIR} )
install( FILES terminalemulator.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR} )
install( FILES konsolepart.desktop konsole-script.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
install( FILES konsolehere.desktop DESTINATION ${DATA_INSTALL_DIR}/konqueror/servicemenus )
......
......@@ -5,7 +5,6 @@
<Menu name="file"><text>File</text>
<Action name="new-tab" />
<Action name="new-window" />
<Action name="new-from-profile" />
<!-- <Action name="remote-connection" /> !-->
<Separator/>
<ActionList name="favorite-profiles"/>
......
[Desktop Entry]
Encoding=UTF-8
Type=Application
Exec=konsole --background-mode
Icon=konsole
DocPath=konsole/index.html
MimeType=application/x-konsole
Terminal=false
X-KDE-StartupNotify=false
Name=Quick Access Terminal
......@@ -26,8 +26,10 @@
#include <QtGui/QPainter>
#include <QtGui/QStandardItem>
#include <QtCore/QDebug>
#include <QtCore/QTextCodec>
// KDE
#include <kcodecaction.h>
#include <KFontDialog>
#include <KIcon>
#include <KIconDialog>
......@@ -745,6 +747,21 @@ void EditProfileDialog::setupAdvancedPage(const Profile* profile)
_ui->cursorShapeCombo->setCurrentIndex(shape);
connect( _ui->cursorShapeCombo , SIGNAL(activated(int)) , this , SLOT(setCursorShape(int)) );
// encoding options
QAction* codecAction = new KCodecAction(this);
_ui->selectEncodingButton->setMenu( codecAction->menu() );
connect( codecAction , SIGNAL(triggered(QTextCodec*)) , this , SLOT(setDefaultCodec(QTextCodec*)) );
_ui->characterEncodingLabel->setText( profile->property(Profile::DefaultEncoding).value<QString>() );
}
void EditProfileDialog::setDefaultCodec(QTextCodec* codec)
{
QString name = QString(codec->name());
_tempProfile->setProperty(Profile::DefaultEncoding,name);
_ui->characterEncodingLabel->setText(codec->name());
}
void EditProfileDialog::customCursorColorChanged(const QColor& color)
{
......
......@@ -30,6 +30,7 @@
#include <KDialog>
class QAbstractButton;
class QTextCodec;
namespace Ui
{
......@@ -145,7 +146,7 @@ private slots:
void customCursorColor();
void customCursorColorChanged(const QColor&);
void wordCharactersChanged(const QString&);
void setDefaultCodec(QTextCodec*);
private:
// initialize various pages of the dialog
......
......@@ -6,7 +6,7 @@
<x>0</x>
<y>0</y>
<width>581</width>
<height>679</height>
<height>590</height>
</rect>
</property>
<property name="windowTitle" >
......@@ -243,13 +243,19 @@
<bool>true</bool>
</property>
<layout class="QGridLayout" >
<item row="0" column="0" >
<item row="0" column="0" colspan="2" >
<widget class="QCheckBox" name="showMenuBarButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Show or hide the menu bar in terminal windows using this profile</string>
</property>
<property name="text" >
<string>Show menu bar</string>
<string>Show menu bar in new windows created from this profile</string>
</property>
</widget>
</item>
......@@ -578,6 +584,12 @@
<layout class="QVBoxLayout" >
<item>
<widget class="QRadioButton" name="disableScrollbackButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Disable scroll bar and do not remember previous output</string>
</property>
......@@ -590,6 +602,12 @@
<layout class="QHBoxLayout" >
<item>
<widget class="QRadioButton" name="fixedScrollbackButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Limit the remembered output to a fixed number of lines</string>
</property>
......@@ -628,6 +646,12 @@
</item>
<item>
<widget class="QRadioButton" name="unlimitedScrollbackButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Remember all output produced by the terminal</string>
</property>
......@@ -650,6 +674,12 @@
<layout class="QVBoxLayout" >
<item>
<widget class="QRadioButton" name="scrollBarLeftButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Show the scroll bar on the left side of the terminal window</string>
</property>
......@@ -660,6 +690,12 @@
</item>
<item>
<widget class="QRadioButton" name="scrollBarRightButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Show the scroll bar on the right side of the terminal window</string>
</property>
......@@ -670,6 +706,12 @@
</item>
<item>
<widget class="QRadioButton" name="scrollBarHiddenButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Hide the scroll bar</string>
</property>
......@@ -712,6 +754,12 @@
<layout class="QVBoxLayout" >
<item>
<widget class="QCheckBox" name="enableBlinkingTextButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Allow terminal programs to create blinking sections of text</string>
</property>
......@@ -722,6 +770,12 @@
</item>
<item>
<widget class="QCheckBox" name="enableFlowControlButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Allow the output to be suspended by pressing Ctrl+S</string>
</property>
......@@ -732,6 +786,12 @@
</item>
<item>
<widget class="QCheckBox" name="enableResizeWindowButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Allow terminal programs to resize the window</string>
</property>
......@@ -787,6 +847,12 @@
<layout class="QVBoxLayout" >
<item>
<widget class="QCheckBox" name="enableBlinkingCursorButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Make the cursor blink regularly</string>
</property>
......@@ -830,6 +896,12 @@
</item>
<item>
<widget class="QRadioButton" name="autoCursorColorButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Set the cursor to match the color of the character underneath it.</string>
</property>
......@@ -842,6 +914,12 @@
<layout class="QHBoxLayout" >
<item>
<widget class="QRadioButton" name="customCursorColorButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Use a custom, fixed color for the cursor</string>
</property>
......@@ -852,6 +930,12 @@
</item>
<item>
<widget class="KColorButton" name="customColorSelectButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Select the color used to draw the cursor</string>
</property>
......@@ -865,6 +949,45 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_11" >
<property name="title" >
<string>Encoding</string>
</property>
<property name="flat" >
<bool>true</bool>
</property>
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="label_14" >
<property name="text" >
<string>Default character encoding:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="characterEncodingLabel" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>DEFAULTENCODING</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="selectEncodingButton" >
<property name="text" >
<string>Select</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
......@@ -872,8 +995,8 @@
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
<width>559</width>
<height>151</height>
</size>
</property>
</spacer>
......
......@@ -148,10 +148,6 @@ void MainWindow::setupActions()
newWindowAction->setShortcut( QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_M) );
connect( newWindowAction , SIGNAL(triggered()) , this , SLOT(newWindow()) );
QAction* newFromProfileAction = collection->addAction("new-from-profile");
newFromProfileAction->setText( i18n("New From Profile...") );
// TODO Implement "New from Profile"
QAction* remoteConnectionAction = collection->addAction("remote-connection");
remoteConnectionAction->setText( i18n("Remote Connection...") );
remoteConnectionAction->setIcon( KIcon("network") );
......
......@@ -25,6 +25,7 @@
// Qt
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
#include <QtCore/QTextCodec>
// KDE
#include <KConfigGroup>
......@@ -71,6 +72,8 @@ FallbackProfile::FallbackProfile()
setProperty(UseCustomCursorColor,false);
setProperty(CustomCursorColor,Qt::black);
setProperty(DefaultEncoding,QString(QTextCodec::codecForLocale()->name()));
// default taken from KDE 3
setProperty(WordCharacters,":@-./_~?&=%+#");
......@@ -225,6 +228,10 @@ bool KDE4ProfileWriter::writeProfile(const QString& path , const Profile* profil
writeStandardElement( interactionOptions , "WordCharacters" , profile , Profile::WordCharacters );
// Encoding
KConfigGroup encodingOptions = config.group("Encoding Options");
writeStandardElement( encodingOptions , "DefaultEncoding" , profile , Profile::DefaultEncoding );
return true;
}
......@@ -300,6 +307,10 @@ bool KDE4ProfileReader::readProfile(const QString& path , Profile* profile)
readStandardElement<QString>(interactionOptions,"WordCharacters",profile,Profile::WordCharacters);
// encoding
KConfigGroup encodingOptions = config.group("Encoding Options");
readStandardElement<QString>(encodingOptions,"DefaultEncoding",profile,Profile::DefaultEncoding);
return true;
}
template <typename T>
......
......@@ -159,7 +159,10 @@ public:
WordCharacters, // QString
/** (TabBarPositionEnum) Position of the tab-bar relative to the terminal displays. */
TabBarPosition
TabBarPosition,
/** (String) Default text codec */
DefaultEncoding
};
/**
......
......@@ -130,6 +130,11 @@ bool Session::running() const
return _shellProcess->isRunning();
}
void Session::setCodec(QTextCodec* codec)
{
emulation()->setCodec(codec);
}
void Session::setProgram(const QString& program)
{
_program = program;
......
......@@ -340,7 +340,10 @@ public:
* @param size The size in lines and columns to request.
*/
void setSize(const QSize& size);
/** Sets the text codec used by this session's terminal emulation. */
void setCodec(QTextCodec* codec);
public slots:
/**
......
......@@ -521,7 +521,7 @@ void SessionController::updateCodecAction()
}
void SessionController::changeCodec(QTextCodec* codec)
{
_session->emulation()->setCodec(codec);
_session->setCodec(codec);
}
void SessionController::debugProcess()
{
......
......@@ -27,6 +27,7 @@
#include <QtCore/QList>
#include <QtCore/QSignalMapper>
#include <QtCore/QString>
#include <QtCore/QTextCodec>
// KDE
#include <klocale.h>
......@@ -388,6 +389,13 @@ void SessionManager::applyProfile(Session* session, const Profile* info , bool m
if ( !modifiedPropertiesOnly || info->isPropertySet(Profile::FlowControlEnabled) )
session->setFlowControlEnabled( info->property(Profile::FlowControlEnabled)
.value<bool>() );
// Encoding
if ( !modifiedPropertiesOnly || info->isPropertySet(Profile::DefaultEncoding) )
{
QByteArray name = info->property(Profile::DefaultEncoding).value<QString>().toUtf8();
session->setCodec( QTextCodec::codecForName(name) );
}
}
QString SessionManager::addProfile(Profile* type)
......
......@@ -39,9 +39,7 @@
class QSignalMapper;
class KConfigGroup;
class KDesktopFile;
class KConfig;
namespace Konsole
{
......
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