Gui: implementation classes don't inherit from UI classes any more

This commit is contained in:
wmayer
2020-01-09 14:30:45 +01:00
parent a441cb95c8
commit 71818b466d
43 changed files with 1168 additions and 992 deletions

View File

@@ -29,6 +29,7 @@
#endif
#include "DlgEditorImp.h"
#include "ui_DlgEditor.h"
#include "PrefWidgets.h"
#include "PythonEditor.h"
@@ -55,9 +56,10 @@ struct DlgSettingsEditorP
*/
DlgSettingsEditorImp::DlgSettingsEditorImp( QWidget* parent )
: PreferencePage( parent )
, ui(new Ui_DlgEditorSettings)
{
this->setupUi(this);
this->EnableFolding->hide(); // Switch off until we have an editor with folding
ui->setupUi(this);
ui->EnableFolding->hide(); // Switch off until we have an editor with folding
d = new DlgSettingsEditorP();
QColor col;
@@ -123,14 +125,14 @@ DlgSettingsEditorImp::DlgSettingsEditorImp( QWidget* parent )
(QString::fromLatin1(QT_TR_NOOP("Current line highlight")), lCLine));
QStringList labels; labels << tr("Items");
this->displayItems->setHeaderLabels(labels);
this->displayItems->header()->hide();
ui->displayItems->setHeaderLabels(labels);
ui->displayItems->header()->hide();
for (QVector<QPair<QString, unsigned int> >::ConstIterator it = d->colormap.begin(); it != d->colormap.end(); ++it) {
QTreeWidgetItem* item = new QTreeWidgetItem(this->displayItems);
QTreeWidgetItem* item = new QTreeWidgetItem(ui->displayItems);
item->setText(0, tr((*it).first.toLatin1()));
}
pythonSyntax = new PythonSyntaxHighlighter(textEdit1);
pythonSyntax->setDocument(textEdit1->document());
pythonSyntax = new PythonSyntaxHighlighter(ui->textEdit1);
pythonSyntax->setDocument(ui->textEdit1->document());
}
/** Destroys the object and frees any allocated resources */
@@ -147,30 +149,30 @@ DlgSettingsEditorImp::~DlgSettingsEditorImp()
*/
void DlgSettingsEditorImp::on_displayItems_currentItemChanged(QTreeWidgetItem *item)
{
int index = displayItems->indexOfTopLevelItem(item);
int index = ui->displayItems->indexOfTopLevelItem(item);
unsigned int col = d->colormap[index].second;
colorButton->setColor(QColor((col >> 24) & 0xff, (col >> 16) & 0xff, (col >> 8) & 0xff));
ui->colorButton->setColor(QColor((col >> 24) & 0xff, (col >> 16) & 0xff, (col >> 8) & 0xff));
}
/** Updates the color map if a color was changed */
void DlgSettingsEditorImp::on_colorButton_changed()
{
QColor col = colorButton->color();
QColor col = ui->colorButton->color();
unsigned int lcol = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8);
int index = displayItems->indexOfTopLevelItem(displayItems->currentItem());
int index = ui->displayItems->indexOfTopLevelItem(ui->displayItems->currentItem());
d->colormap[index].second = lcol;
pythonSyntax->setColor( d->colormap[index].first, col );
}
void DlgSettingsEditorImp::saveSettings()
{
EnableLineNumber->onSave();
EnableFolding->onSave();
tabSize->onSave();
indentSize->onSave();
radioTabs->onSave();
radioSpaces->onSave();
ui->EnableLineNumber->onSave();
ui->EnableFolding->onSave();
ui->tabSize->onSave();
ui->indentSize->onSave();
ui->radioTabs->onSave();
ui->radioSpaces->onSave();
// Saves the color map
ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("Editor");
@@ -179,20 +181,20 @@ void DlgSettingsEditorImp::saveSettings()
hGrp->SetUnsigned((*it).first.toLatin1(), col);
}
hGrp->SetInt( "FontSize", fontSize->value() );
hGrp->SetASCII( "Font", fontFamily->currentText().toLatin1() );
hGrp->SetInt( "FontSize", ui->fontSize->value() );
hGrp->SetASCII( "Font", ui->fontFamily->currentText().toLatin1() );
}
void DlgSettingsEditorImp::loadSettings()
{
EnableLineNumber->onRestore();
EnableFolding->onRestore();
tabSize->onRestore();
indentSize->onRestore();
radioTabs->onRestore();
radioSpaces->onRestore();
ui->EnableLineNumber->onRestore();
ui->EnableFolding->onRestore();
ui->tabSize->onRestore();
ui->indentSize->onRestore();
ui->radioTabs->onRestore();
ui->radioSpaces->onRestore();
textEdit1->setPlainText(QString::fromLatin1(
ui->textEdit1->setPlainText(QString::fromLatin1(
"# Short Python sample\n"
"import sys\n"
"def foo(begin, end):\n"
@@ -217,20 +219,20 @@ void DlgSettingsEditorImp::loadSettings()
// fill up font styles
//
fontSize->setValue(10);
fontSize->setValue( hGrp->GetInt("FontSize", fontSize->value()) );
ui->fontSize->setValue(10);
ui->fontSize->setValue( hGrp->GetInt("FontSize", ui->fontSize->value()) );
QByteArray fontName = this->font().family().toLatin1();
QFontDatabase fdb;
QStringList familyNames = fdb.families( QFontDatabase::Any );
fontFamily->addItems(familyNames);
ui->fontFamily->addItems(familyNames);
int index = familyNames.indexOf(QString::fromLatin1(hGrp->GetASCII("Font", fontName).c_str()));
if (index < 0) index = 0;
fontFamily->setCurrentIndex(index);
on_fontFamily_activated(this->fontFamily->currentText());
ui->fontFamily->setCurrentIndex(index);
on_fontFamily_activated(ui->fontFamily->currentText());
displayItems->setCurrentItem(displayItems->topLevelItem(0));
ui->displayItems->setCurrentItem(ui->displayItems->topLevelItem(0));
}
/**
@@ -241,8 +243,8 @@ void DlgSettingsEditorImp::changeEvent(QEvent *e)
if (e->type() == QEvent::LanguageChange) {
int index = 0;
for (QVector<QPair<QString, unsigned int> >::ConstIterator it = d->colormap.begin(); it != d->colormap.end(); ++it)
this->displayItems->topLevelItem(index++)->setText(0, tr((*it).first.toLatin1()));
this->retranslateUi(this);
ui->displayItems->topLevelItem(index++)->setText(0, tr((*it).first.toLatin1()));
ui->retranslateUi(this);
} else {
QWidget::changeEvent(e);
}
@@ -250,14 +252,14 @@ void DlgSettingsEditorImp::changeEvent(QEvent *e)
void DlgSettingsEditorImp::on_fontFamily_activated(const QString& fontFamily)
{
int fontSize = this->fontSize->value();
int fontSize = ui->fontSize->value();
QFont ft(fontFamily, fontSize);
textEdit1->setFont(ft);
ui->textEdit1->setFont(ft);
}
void DlgSettingsEditorImp::on_fontSize_valueChanged(const QString&)
{
on_fontFamily_activated(this->fontFamily->currentText());
on_fontFamily_activated(ui->fontFamily->currentText());
}
#include "moc_DlgEditorImp.cpp"