Showing with 22 additions and 0 deletions.
  1. +18 −0 src/SessionController.cpp
  2. +4 −0 src/SessionController.h
18 changes: 18 additions & 0 deletions src/SessionController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,19 @@ void SessionController::sessionTitleChanged()
setTitle(title);
}

void SessionController::setEncodingByQAction(){
QString ename = ((QAction*)sender())->data().toString();
QTextCodec* codec = QTextCodec::codecForName(ename.toAscii());
changeCodec(codec);
}
QAction * SessionController::setupEncodingChanger(QAction* qa, QString ename){
qa->setText("Set Encoding to "+ ename);
qa->setData(ename);
qa->setIcon(KIcon("character-set"));
connect(qa, SIGNAL(triggered()), this, SLOT(setEncodingByQAction()));
return qa;
}

void SessionController::showDisplayContextMenu(const QPoint& position)
{
// needed to make sure the popup menu is available, even if a hosting
Expand All @@ -1113,6 +1126,11 @@ void SessionController::showDisplayContextMenu(const QPoint& position)
contentSeparator->setSeparator(true);
contentActions << contentSeparator;

contentActions << setupEncodingChanger(new QAction(popup), "utf-8");
contentActions << setupEncodingChanger(new QAction(popup), "windows-1251");

contentActions << contentSeparator;

_preventClose = true;

popup->insertActions(popup->actions().value(0, 0), contentActions);
Expand Down
4 changes: 4 additions & 0 deletions src/SessionController.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ private slots:
void renameSession();
void switchProfile(Profile::Ptr profile);

// Custom popup menu encodings:
void setEncodingByQAction();

// other
void prepareSwitchProfileMenu();
void updateCodecAction();
Expand Down Expand Up @@ -258,6 +261,7 @@ private slots:
void listenForScreenWindowUpdates();

private:
QAction * setupEncodingChanger(QAction* qa, QString ename);
void updateSessionIcon();

QPointer<Session> _session;
Expand Down