1#include "FrmParameterTerminalAppearanceSettings.h"
2#include "ui_FrmParameterTerminalAppearanceSettings.h"
3#include "RabbitCommonDir.h"
4#include "qtermwidget.h"
6#include "RabbitCommonDir.h"
8#include <QCoreApplication>
13#include <QLoggingCategory>
15Q_DECLARE_LOGGING_CATEGORY(Terminal)
22 QString szTranslatorFile = RabbitCommon::CDir::Instance()->GetDirTranslations()
23 + QDir::separator() +
"Terminal_" + QLocale::system().name() +
".qm";
24 if(!m_Translator.load(szTranslatorFile))
25 qCritical(Terminal) <<
"Open translator file fail:" << szTranslatorFile;
26 qApp->installTranslator(&m_Translator);
31 qApp->removeTranslator(&m_Translator);
32 qDebug(Terminal) <<
"CTerminal::~CTerminal()";
36 QTranslator m_Translator;
41CFrmParameterTerminalAppearanceSettings::CFrmParameterTerminalAppearanceSettings(
CParameterTerminal *pPara, QWidget *parent) :
51 QFont f = pPara->GetFont();
52 ui->spFontSize->setValue(f.pointSize());
53 ui->lbFont->setFont(f);
55 ui->fontComboBox->setFontFilters(QFontComboBox::MonospacedFonts
56 | QFontComboBox::NonScalableFonts
57 | QFontComboBox::ScalableFonts);
58 ui->fontComboBox->setCurrentFont(f);
59 ui->fontComboBox->setEditable(
false);
61 ui->cbShowResize->setChecked(pPara->GetSizeHint());
63 ui->cbCursorShape->addItem(tr(
"BlockCursor"), (
int)Konsole::Emulation::KeyboardCursorShape::BlockCursor);
64 ui->cbCursorShape->addItem(tr(
"UnderlineCursor"), (
int)Konsole::Emulation::KeyboardCursorShape::UnderlineCursor);
65 ui->cbCursorShape->addItem(tr(
"IBeamCursor"), (
int)Konsole::Emulation::KeyboardCursorShape::BlockCursor);
66 ui->cbCursorShape->setCurrentIndex((
int)pPara->GetCursorShape());
68 ui->cbColorScheme->addItems(QTermWidget::availableColorSchemes());
69 if(!m_pPara->GetColorScheme().isEmpty())
70 ui->cbColorScheme->setCurrentText(pPara->GetColorScheme());
72 ui->cbScrollBarPositioin->addItem(tr(
"No"), QTermWidget::NoScrollBar);
73 ui->cbScrollBarPositioin->addItem(tr(
"Left"), QTermWidget::ScrollBarLeft);
74 ui->cbScrollBarPositioin->addItem(tr(
"Right"), QTermWidget::ScrollBarRight);
75 ui->cbScrollBarPositioin->setCurrentIndex(pPara->GetScrollBarPosition());
77 ui->spTerminalTransparecy->setValue(pPara->GetTransparency());
78 ui->cbFlowControl->setChecked(m_pPara->GetFlowControl());
79 ui->cbBiDirectional->setChecked(m_pPara->GetDirectional());
80 ui->leImage->setText(m_pPara->GetBackgroupImage());
83CFrmParameterTerminalAppearanceSettings::~CFrmParameterTerminalAppearanceSettings()
88void CFrmParameterTerminalAppearanceSettings::on_fontComboBox_currentFontChanged(
const QFont &f)
91 font.setPointSize(ui->spFontSize->value());
92 ui->lbFont->setFont(font);
93 ui->lbFont->setText(tr(
"Example: Display font"));
96void CFrmParameterTerminalAppearanceSettings::on_spFontSize_valueChanged(
int size)
98 QFont font = ui->fontComboBox->currentFont();
99 font.setPointSize(size);
100 ui->lbFont->setFont(font);
101 ui->lbFont->setText(tr(
"Example: Display font"));
104int CFrmParameterTerminalAppearanceSettings::AcceptSettings()
106 if(!m_pPara)
return -1;
107 m_pPara->SetFont(ui->fontComboBox->currentFont());
108 QFont font = m_pPara->GetFont();
109 font.setPointSize(ui->spFontSize->value());
110 m_pPara->SetFont(font);
111 m_pPara->SetSizeHint(ui->cbShowResize->isChecked());
112 m_pPara->SetColorScheme(ui->cbColorScheme->currentText());
113 m_pPara->SetCursorShape(
static_cast<Konsole::Emulation::KeyboardCursorShape
>(ui->cbCursorShape->currentData().toInt()));
114 m_pPara->SetScrollBarPosition(
static_cast<QTermWidget::ScrollBarPosition
>(ui->cbScrollBarPositioin->currentData().toInt()));
115 m_pPara->SetTransparency(ui->spTerminalTransparecy->value());
116 m_pPara->SetFlowControl(ui->cbFlowControl->isChecked());
117 m_pPara->SetBackgroupImage(ui->leImage->text());
118 m_pPara->SetDirectional(ui->cbBiDirectional->isChecked());
122void CFrmParameterTerminalAppearanceSettings::on_pbBrowser_clicked()
124 QString file = QFileDialog::getOpenFileName(
this,
125 tr(
"Backgroup image"), QString(),
126 tr(
"Images (*.png *.xpm *.jpg *.bmp *.jpeg);;All files (*.*)"));
128 ui->leImage->setText(file);