remove unused controls from General preference page
This commit is contained in:
@@ -156,26 +156,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="windowStyleLabel">
|
||||
<property name="text">
|
||||
<string>Window style:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="WindowStyle"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
@@ -235,26 +215,6 @@
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="tabReportLabel">
|
||||
<property name="text">
|
||||
<string>Switch to tab of report window:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="AutoloadModuleCombo"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="Gui::PrefComboBox" name="AutoloadTabCombo">
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>AutoloadTab</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>General</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="autoModuleLabel">
|
||||
<property name="text">
|
||||
@@ -262,6 +222,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="AutoloadModuleCombo"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -336,7 +299,6 @@
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>Languages</tabstop>
|
||||
<tabstop>WindowStyle</tabstop>
|
||||
<tabstop>RecentFiles</tabstop>
|
||||
<tabstop>SplashScreen</tabstop>
|
||||
<tabstop>PythonWordWrap</tabstop>
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#endif
|
||||
|
||||
#include "DlgGeneralImp.h"
|
||||
#include "ui_DlgGeneral.h"
|
||||
#include "Action.h"
|
||||
#include "Application.h"
|
||||
#include "DockWindowManager.h"
|
||||
@@ -50,12 +51,10 @@ using namespace Gui::Dialog;
|
||||
* true to construct a modal dialog.
|
||||
*/
|
||||
DlgGeneralImp::DlgGeneralImp( QWidget* parent )
|
||||
: PreferencePage( parent ), watched(0)
|
||||
: PreferencePage(parent)
|
||||
, ui(new Ui_DlgGeneral)
|
||||
{
|
||||
this->setupUi(this);
|
||||
// hide to fix 0000375: Mac Interface window style setting not saved
|
||||
windowStyleLabel->hide();
|
||||
WindowStyle->hide();
|
||||
ui->setupUi(this);
|
||||
|
||||
// fills the combo box with all available workbenches
|
||||
// sorted by their menu text
|
||||
@@ -69,27 +68,9 @@ DlgGeneralImp::DlgGeneralImp( QWidget* parent )
|
||||
for (QMap<QString, QString>::Iterator it = menuText.begin(); it != menuText.end(); ++it) {
|
||||
QPixmap px = Application::Instance->workbenchIcon(it.value());
|
||||
if (px.isNull())
|
||||
AutoloadModuleCombo->addItem(it.key(), QVariant(it.value()));
|
||||
ui->AutoloadModuleCombo->addItem(it.key(), QVariant(it.value()));
|
||||
else
|
||||
AutoloadModuleCombo->addItem(px, it.key(), QVariant(it.value()));
|
||||
}
|
||||
|
||||
// do not save the content but the current item only
|
||||
QWidget* dw = DockWindowManager::instance()->getDockWindow("Report view");
|
||||
if (dw)
|
||||
{
|
||||
watched = dw->findChild<QTabWidget*>();
|
||||
if (watched)
|
||||
{
|
||||
for (int i=0; i<watched->count(); i++)
|
||||
AutoloadTabCombo->addItem( watched->tabText(i) );
|
||||
watched->installEventFilter(this);
|
||||
}
|
||||
}
|
||||
if (!watched) {
|
||||
// use separate dock widgets instead of the old tab widget
|
||||
tabReportLabel->hide();
|
||||
AutoloadTabCombo->hide();
|
||||
ui->AutoloadModuleCombo->addItem(px, it.key(), QVariant(it.value()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,9 +79,6 @@ DlgGeneralImp::DlgGeneralImp( QWidget* parent )
|
||||
*/
|
||||
DlgGeneralImp::~DlgGeneralImp()
|
||||
{
|
||||
// no need to delete child widgets, Qt does it all for us
|
||||
if (watched)
|
||||
watched->removeEventFilter(this);
|
||||
}
|
||||
|
||||
/** Sets the size of the recent file list from the user parameters.
|
||||
@@ -118,16 +96,15 @@ void DlgGeneralImp::setRecentFileSize()
|
||||
|
||||
void DlgGeneralImp::saveSettings()
|
||||
{
|
||||
int index = AutoloadModuleCombo->currentIndex();
|
||||
QVariant data = AutoloadModuleCombo->itemData(index);
|
||||
int index = ui->AutoloadModuleCombo->currentIndex();
|
||||
QVariant data = ui->AutoloadModuleCombo->itemData(index);
|
||||
QString startWbName = data.toString();
|
||||
App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/General")->
|
||||
SetASCII("AutoloadModule", startWbName.toLatin1());
|
||||
|
||||
AutoloadTabCombo->onSave();
|
||||
RecentFiles->onSave();
|
||||
SplashScreen->onSave();
|
||||
PythonWordWrap->onSave();
|
||||
|
||||
ui->RecentFiles->onSave();
|
||||
ui->SplashScreen->onSave();
|
||||
ui->PythonWordWrap->onSave();
|
||||
|
||||
QWidget* pc = DockWindowManager::instance()->getDockWindow("Python console");
|
||||
PythonConsole *pcPython = qobject_cast<PythonConsole*>(pc);
|
||||
@@ -149,24 +126,24 @@ void DlgGeneralImp::saveSettings()
|
||||
ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("General");
|
||||
QString lang = QLocale::languageToString(QLocale::system().language());
|
||||
QByteArray language = hGrp->GetASCII("Language", (const char*)lang.toLatin1()).c_str();
|
||||
QByteArray current = Languages->itemData(Languages->currentIndex()).toByteArray();
|
||||
QByteArray current = ui->Languages->itemData(ui->Languages->currentIndex()).toByteArray();
|
||||
if (current != language)
|
||||
{
|
||||
hGrp->SetASCII("Language", current.constData());
|
||||
Translator::instance()->activateLanguage(current.constData());
|
||||
}
|
||||
|
||||
QVariant size = this->toolbarIconSize->itemData(this->toolbarIconSize->currentIndex());
|
||||
QVariant size = ui->toolbarIconSize->itemData(ui->toolbarIconSize->currentIndex());
|
||||
int pixel = size.toInt();
|
||||
hGrp->SetInt("ToolbarIconSize", pixel);
|
||||
getMainWindow()->setIconSize(QSize(pixel,pixel));
|
||||
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/MainWindow");
|
||||
hGrp->SetBool("TiledBackground", this->tiledBackground->isChecked());
|
||||
hGrp->SetBool("TiledBackground", ui->tiledBackground->isChecked());
|
||||
QMdiArea* mdi = getMainWindow()->findChild<QMdiArea*>();
|
||||
mdi->setProperty("showImage", this->tiledBackground->isChecked());
|
||||
mdi->setProperty("showImage", ui->tiledBackground->isChecked());
|
||||
|
||||
QVariant sheet = this->StyleSheets->itemData(this->StyleSheets->currentIndex());
|
||||
QVariant sheet = ui->StyleSheets->itemData(ui->StyleSheets->currentIndex());
|
||||
if (this->selectedStyleSheet != sheet.toString()) {
|
||||
this->selectedStyleSheet = sheet.toString();
|
||||
hGrp->SetASCII("StyleSheet", (const char*)sheet.toByteArray());
|
||||
@@ -185,7 +162,7 @@ void DlgGeneralImp::saveSettings()
|
||||
}
|
||||
|
||||
if (sheet.toString().isEmpty()) {
|
||||
if (this->tiledBackground->isChecked()) {
|
||||
if (ui->tiledBackground->isChecked()) {
|
||||
qApp->setStyleSheet(QString());
|
||||
ActionStyleEvent e(ActionStyleEvent::Restore);
|
||||
qApp->sendEvent(getMainWindow(), &e);
|
||||
@@ -225,32 +202,18 @@ void DlgGeneralImp::loadSettings()
|
||||
start = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/General")->
|
||||
GetASCII("AutoloadModule", start.c_str());
|
||||
QString startWbName = QLatin1String(start.c_str());
|
||||
AutoloadModuleCombo->setCurrentIndex(AutoloadModuleCombo->findData(startWbName));
|
||||
ui->AutoloadModuleCombo->setCurrentIndex(ui->AutoloadModuleCombo->findData(startWbName));
|
||||
|
||||
AutoloadTabCombo->onRestore();
|
||||
RecentFiles->onRestore();
|
||||
SplashScreen->onRestore();
|
||||
PythonWordWrap->onRestore();
|
||||
|
||||
// fill up styles
|
||||
//
|
||||
QStringList styles = QStyleFactory::keys();
|
||||
WindowStyle->addItems(styles);
|
||||
QString style = QApplication::style()->objectName().toLower();
|
||||
int i=0;
|
||||
for (QStringList::ConstIterator it = styles.begin(); it != styles.end(); ++it, i++) {
|
||||
if (style == (*it).toLower()) {
|
||||
WindowStyle->setCurrentIndex( i );
|
||||
break;
|
||||
}
|
||||
}
|
||||
ui->RecentFiles->onRestore();
|
||||
ui->SplashScreen->onRestore();
|
||||
ui->PythonWordWrap->onRestore();
|
||||
|
||||
// search for the language files
|
||||
ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("General");
|
||||
QString lang = QLocale::languageToString(QLocale::system().language());
|
||||
QByteArray language = hGrp->GetASCII("Language", (const char*)lang.toLatin1()).c_str();
|
||||
int index = 1;
|
||||
Languages->addItem(QString::fromLatin1("English"), QByteArray("English"));
|
||||
ui->Languages->addItem(QString::fromLatin1("English"), QByteArray("English"));
|
||||
TStringMap list = Translator::instance()->supportedLocales();
|
||||
for (TStringMap::iterator it = list.begin(); it != list.end(); ++it, index++) {
|
||||
QLocale locale(QString::fromLatin1(it->second.c_str()));
|
||||
@@ -264,26 +227,26 @@ void DlgGeneralImp::loadSettings()
|
||||
langname = native;
|
||||
}
|
||||
#endif
|
||||
Languages->addItem(langname, lang);
|
||||
ui->Languages->addItem(langname, lang);
|
||||
if (language == lang) {
|
||||
Languages->setCurrentIndex(index);
|
||||
ui->Languages->setCurrentIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
int current = getMainWindow()->iconSize().width();
|
||||
this->toolbarIconSize->addItem(tr("Small (%1px)").arg(16), QVariant((int)16));
|
||||
this->toolbarIconSize->addItem(tr("Medium (%1px)").arg(24), QVariant((int)24));
|
||||
this->toolbarIconSize->addItem(tr("Large (%1px)").arg(32), QVariant((int)32));
|
||||
this->toolbarIconSize->addItem(tr("Extra large (%1px)").arg(48), QVariant((int)48));
|
||||
index = this->toolbarIconSize->findData(QVariant(current));
|
||||
ui->toolbarIconSize->addItem(tr("Small (%1px)").arg(16), QVariant((int)16));
|
||||
ui->toolbarIconSize->addItem(tr("Medium (%1px)").arg(24), QVariant((int)24));
|
||||
ui->toolbarIconSize->addItem(tr("Large (%1px)").arg(32), QVariant((int)32));
|
||||
ui->toolbarIconSize->addItem(tr("Extra large (%1px)").arg(48), QVariant((int)48));
|
||||
index = ui->toolbarIconSize->findData(QVariant(current));
|
||||
if (index < 0) {
|
||||
this->toolbarIconSize->addItem(tr("Custom (%1px)").arg(current), QVariant((int)current));
|
||||
index = this->toolbarIconSize->findData(QVariant(current));
|
||||
ui->toolbarIconSize->addItem(tr("Custom (%1px)").arg(current), QVariant((int)current));
|
||||
index = ui->toolbarIconSize->findData(QVariant(current));
|
||||
}
|
||||
this->toolbarIconSize->setCurrentIndex(index);
|
||||
ui->toolbarIconSize->setCurrentIndex(index);
|
||||
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/MainWindow");
|
||||
this->tiledBackground->setChecked(hGrp->GetBool("TiledBackground", false));
|
||||
ui->tiledBackground->setChecked(hGrp->GetBool("TiledBackground", false));
|
||||
|
||||
// List all .qss/.css files
|
||||
QMap<QString, QString> cssFiles;
|
||||
@@ -306,38 +269,28 @@ void DlgGeneralImp::loadSettings()
|
||||
}
|
||||
|
||||
// now add all unique items
|
||||
this->StyleSheets->addItem(tr("No style sheet"), QString::fromLatin1(""));
|
||||
ui->StyleSheets->addItem(tr("No style sheet"), QString::fromLatin1(""));
|
||||
for (QMap<QString, QString>::iterator it = cssFiles.begin(); it != cssFiles.end(); ++it) {
|
||||
this->StyleSheets->addItem(it.key(), it.value());
|
||||
ui->StyleSheets->addItem(it.key(), it.value());
|
||||
}
|
||||
|
||||
this->selectedStyleSheet = QString::fromLatin1(hGrp->GetASCII("StyleSheet").c_str());
|
||||
index = this->StyleSheets->findData(this->selectedStyleSheet);
|
||||
if (index > -1) this->StyleSheets->setCurrentIndex(index);
|
||||
index = ui->StyleSheets->findData(this->selectedStyleSheet);
|
||||
if (index > -1) ui->StyleSheets->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
void DlgGeneralImp::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
retranslateUi(this);
|
||||
for (int i = 0; i < Languages->count(); i++) {
|
||||
QByteArray lang = Languages->itemData(i).toByteArray();
|
||||
Languages->setItemText(i, Gui::Translator::tr(lang.constData()));
|
||||
ui->retranslateUi(this);
|
||||
for (int i = 0; i < ui->Languages->count(); i++) {
|
||||
QByteArray lang = ui->Languages->itemData(i).toByteArray();
|
||||
ui->Languages->setItemText(i, Gui::Translator::tr(lang.constData()));
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
QWidget::changeEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
bool DlgGeneralImp::eventFilter(QObject* o, QEvent* e)
|
||||
{
|
||||
// make sure that report tabs have been translated
|
||||
if (o == watched && e->type() == QEvent::LanguageChange) {
|
||||
for (int i=0; i<watched->count(); i++)
|
||||
AutoloadTabCombo->setItemText( i, watched->tabText(i) );
|
||||
}
|
||||
|
||||
return QWidget::eventFilter(o, e);
|
||||
}
|
||||
|
||||
#include "moc_DlgGeneralImp.cpp"
|
||||
|
||||
@@ -24,19 +24,20 @@
|
||||
#ifndef GUI_DIALOG_DLGGENERALIMP_H
|
||||
#define GUI_DIALOG_DLGGENERALIMP_H
|
||||
|
||||
#include "ui_DlgGeneral.h"
|
||||
#include "PropertyPage.h"
|
||||
#include <memory>
|
||||
|
||||
class QTabWidget;
|
||||
|
||||
namespace Gui {
|
||||
namespace Dialog {
|
||||
class Ui_DlgGeneral;
|
||||
|
||||
/** This class implements the settings for the application.
|
||||
* You can change window style, size of pixmaps, size of recent file list and so on
|
||||
* \author Werner Mayer
|
||||
*/
|
||||
class DlgGeneralImp : public PreferencePage, public Ui_DlgGeneral
|
||||
class DlgGeneralImp : public PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -46,14 +47,15 @@ public:
|
||||
|
||||
void saveSettings();
|
||||
void loadSettings();
|
||||
bool eventFilter ( QObject* o, QEvent* e );
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
||||
private:
|
||||
void setRecentFileSize();
|
||||
QTabWidget* watched;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui_DlgGeneral> ui;
|
||||
QString selectedStyleSheet;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user