ui: Added more settings to the preferences

Added font face, font size, tab width, analysis threads
This commit is contained in:
Eberhard Graether
2016-05-18 11:15:28 +02:00
parent e40459e71d
commit e943ef149e
7 changed files with 173 additions and 1 deletions
+6
View File
@@ -26,6 +26,12 @@
}
#label {
font-size: 12pt;
font-weight: bold;
}
#titleLabel {
font-size: 14pt;
font-weight: bold;
}
+2
View File
@@ -119,6 +119,8 @@ add_files(
qt/window/project_wizzard/QtProjectWizzardContentFlags.h
qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp
qt/window/project_wizzard/QtProjectWizzardContentPaths.h
qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp
qt/window/project_wizzard/QtProjectWizzardContentPreferences.h
qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp
qt/window/project_wizzard/QtProjectWizzardContentSelect.h
qt/window/project_wizzard/QtProjectWizzardContentSimple.cpp
@@ -13,12 +13,14 @@
#include "qt/window/project_wizzard/QtProjectWizzardContentExtensions.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentFlags.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentPaths.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentPreferences.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentSimple.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentSourceList.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentSummary.h"
#include "qt/window/project_wizzard/QtProjectWizzardWindow.h"
#include "utility/messaging/type/MessageDispatchWhenLicenseValid.h"
#include "utility/messaging/type/MessageLoadProject.h"
#include "utility/messaging/type/MessageRefresh.h"
#include "utility/solution/SolutionParserVisualStudio.h"
// #include "utility/solution/SolutionParserCodeBlocks.h"
@@ -195,8 +197,9 @@ void QtProjectWizzard::showPreferences()
ProjectSettings* settings = &m_settings;
summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(settings, window), false, false);
summary->addContent(new QtProjectWizzardContentPreferences(settings, window), false, false);
summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(settings, window), false, false);
if (QSysInfo::macVersion() != QSysInfo::MV_None)
{
summary->addContent(new QtProjectWizzardContentPathsFrameworkSearchGlobal(settings, window), false, false);
@@ -602,6 +605,10 @@ void QtProjectWizzard::savePreferences()
std::make_shared<MessageLoadProject>("", true)
).dispatch();
}
else
{
MessageRefresh().refreshUiOnly().dispatch();
}
cancelWizzard();
}
@@ -98,6 +98,14 @@ QLabel* QtProjectWizzardContent::createFormLabel(QString name) const
return label;
}
QLabel* QtProjectWizzardContent::createFormTitle(QString name) const
{
QLabel* label = new QLabel(name);
label->setObjectName("titleLabel");
label->setWordWrap(true);
return label;
}
QToolButton* QtProjectWizzardContent::createProjectButton(QString name, QString iconPath) const
{
QToolButton* button = new QToolButton();
@@ -58,6 +58,7 @@ signals:
protected:
QLabel* createFormLabel(QString name) const;
QLabel* createFormTitle(QString name) const;
QToolButton* createProjectButton(QString name, QString iconPath) const;
QtHelpButton* addHelpButton(QString helpString, QGridLayout* layout, int row) const;
@@ -0,0 +1,116 @@
#include "qt/window/project_wizzard/QtProjectWizzardContentPreferences.h"
#include "settings/ApplicationSettings.h"
QtProjectWizzardContentPreferences::QtProjectWizzardContentPreferences(
ProjectSettings* settings, QtProjectWizzardWindow* window
)
: QtProjectWizzardContent(settings, window)
{
}
void QtProjectWizzardContentPreferences::populateWindow(QGridLayout* layout)
{
int row = 0;
populateForm(layout, row);
}
void QtProjectWizzardContentPreferences::populateForm(QGridLayout* layout, int& row)
{
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
// ui
layout->addWidget(createFormTitle("USER INTERFACE"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignLeft);
row++;
// font face
QLabel* fontLabel = createFormLabel("Font face");
m_fontFace = new QLineEdit();
m_fontFace->setObjectName("name");
m_fontFace->setAttribute(Qt::WA_MacShowFocusRect, 0);
layout->addWidget(fontLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_fontFace, row, QtProjectWizzardWindow::BACK_COL);
row++;
// font size
QLabel* sizeLabel = createFormLabel("Font size");
m_fontSize = new QComboBox();
for (int i = appSettings->getFontSizeMin(); i <= appSettings->getFontSizeMax(); i++)
{
m_fontSize->insertItem(i, QString::number(i));
}
layout->addWidget(sizeLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_fontSize, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
row++;
// tab width
QLabel* tabLabel = createFormLabel("Tab width");
m_tabWidth = new QComboBox();
for (int i = 1; i < 17; i++)
{
m_tabWidth->insertItem(i, QString::number(i));
}
layout->addWidget(tabLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_tabWidth, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
row++;
layout->setRowMinimumHeight(row++, 20);
// analysis
layout->addWidget(createFormTitle("ANALYSIS"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignLeft);
row++;
// analysis threads
QLabel* threadsLabel = createFormLabel("Analysis threads");
m_threads = new QComboBox();
for (int i = 1; i <= 24; i++)
{
m_threads->insertItem(i, QString::number(i));
}
layout->addWidget(threadsLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_threads, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
addHelpButton(
"Number of parallel threads used to analyse your projects."
, layout, row
);
row++;
}
void QtProjectWizzardContentPreferences::load()
{
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
m_fontFace->setText(QString::fromStdString(appSettings->getFontName()));
m_fontSize->setCurrentIndex(appSettings->getFontSize() - appSettings->getFontSizeMin());
m_tabWidth->setCurrentIndex(appSettings->getCodeTabWidth() - 1);
m_threads->setCurrentIndex(appSettings->getIndexerThreadCount() - 1);
}
void QtProjectWizzardContentPreferences::save()
{
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
appSettings->setFontName(m_fontFace->text().toStdString());
appSettings->setFontSize(m_fontSize->currentIndex() + appSettings->getFontSizeMin());
appSettings->setCodeTabWidth(m_tabWidth->currentIndex() + 1);
appSettings->setIndexerThreadCount(m_threads->currentIndex() + 1);
}
bool QtProjectWizzardContentPreferences::check()
{
return true;
}
@@ -0,0 +1,32 @@
#ifndef QT_PROJECT_WIZZARD_CONTENT_PREFERENCES_H
#define QT_PROJECT_WIZZARD_CONTENT_PREFERENCES_H
#include <QComboBox>
#include <QLineEdit>
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
class QtProjectWizzardContentPreferences
: public QtProjectWizzardContent
{
Q_OBJECT
public:
QtProjectWizzardContentPreferences(ProjectSettings* settings, QtProjectWizzardWindow* window);
// QtProjectWizzardContent implementation
virtual void populateWindow(QGridLayout* layout) override;
virtual void populateForm(QGridLayout* layout, int& row) override;
virtual void load() override;
virtual void save() override;
virtual bool check() override;
private:
QLineEdit* m_fontFace;
QComboBox* m_fontSize;
QComboBox* m_tabWidth;
QComboBox* m_threads;
};
#endif // QT_PROJECT_WIZZARD_CONTENT_PREFERENCES_H