ui: Added setting for graph zoom on mouse wheel by default to preferences

On popular demand.

bug id = 237
This commit is contained in:
Eberhard Graether
2016-10-25 22:52:36 +02:00
parent 2e10c65491
commit 76fb7c4e6c
6 changed files with 87 additions and 26 deletions
@@ -78,5 +78,6 @@
<controls> <controls>
<mouse_back_button><!-- INTEGER: mouse button code of back button, default is 8 --></mouse_back_button> <mouse_back_button><!-- INTEGER: mouse button code of back button, default is 8 --></mouse_back_button>
<mouse_forward_button><!-- INTEGER: mouse button code of forward button, default is 16 --></mouse_forward_button> <mouse_forward_button><!-- INTEGER: mouse button code of forward button, default is 16 --></mouse_forward_button>
<graph_zoom_on_mouse_wheel><!-- BOOL: set mouse wheel to zooming by default --></graph_zoom_on_mouse_wheel>
</controls> </controls>
</config> </config>
+10
View File
@@ -306,6 +306,16 @@ int ApplicationSettings::getControlsMouseForwardButton() const
return getValue<int>("controls/mouse_forward_button", 0x10); return getValue<int>("controls/mouse_forward_button", 0x10);
} }
bool ApplicationSettings::getControlsGraphZoomOnMouseWheel() const
{
return getValue<bool>("controls/graph_zoom_on_mouse_wheel", false);
}
void ApplicationSettings::setControlsGraphZoomOnMouseWheel(bool zoomingDefault)
{
setValue<bool>("controls/graph_zoom_on_mouse_wheel", zoomingDefault);
}
std::string ApplicationSettings::getLicenseString() const std::string ApplicationSettings::getLicenseString() const
{ {
return getValue<std::string>("user/license/license", ""); return getValue<std::string>("user/license/license", "");
+3
View File
@@ -93,6 +93,9 @@ public:
int getControlsMouseBackButton() const; int getControlsMouseBackButton() const;
int getControlsMouseForwardButton() const; int getControlsMouseForwardButton() const;
bool getControlsGraphZoomOnMouseWheel() const;
void setControlsGraphZoomOnMouseWheel(bool zoomingDefault);
// license // license
std::string getLicenseString() const; std::string getLicenseString() const;
void setLicenseString(const std::string& licenseString); void setLicenseString(const std::string& licenseString);
+38 -17
View File
@@ -9,6 +9,7 @@
#include <QParallelAnimationGroup> #include <QParallelAnimationGroup>
#include "qt/utility/QtContextMenu.h" #include "qt/utility/QtContextMenu.h"
#include "settings/ApplicationSettings.h"
QtGraphicsView::QtGraphicsView(QWidget* parent) QtGraphicsView::QtGraphicsView(QWidget* parent)
: QGraphicsView(parent) : QGraphicsView(parent)
@@ -168,13 +169,20 @@ void QtGraphicsView::keyReleaseEvent(QKeyEvent* event)
void QtGraphicsView::wheelEvent(QWheelEvent* event) void QtGraphicsView::wheelEvent(QWheelEvent* event)
{ {
if (event->modifiers() == Qt::ShiftModifier && event->delta() != 0.0f) bool zoomDefault = ApplicationSettings::getInstance()->getControlsGraphZoomOnMouseWheel();
{ bool shiftPressed = event->modifiers() == Qt::ShiftModifier;
updateZoom(event->delta());
return;
}
QGraphicsView::wheelEvent(event); if (zoomDefault != shiftPressed)
{
if (event->delta() != 0.0f)
{
updateZoom(event->delta());
}
}
else
{
QGraphicsView::wheelEvent(event);
}
} }
void QtGraphicsView::contextMenuEvent(QContextMenuEvent* event) void QtGraphicsView::contextMenuEvent(QContextMenuEvent* event)
@@ -247,34 +255,47 @@ void QtGraphicsView::stopTimer()
QString ShowSaveFileDialog(QWidget *parent, QString ShowSaveFileDialog(QWidget *parent,
const QString &title, const QString &title,
const QString &directory, const QString &directory,
const QString &filter) { const QString &filter)
{
#if defined(Q_WS_WIN) || defined(Q_WS_MAC) #if defined(Q_WS_WIN) || defined(Q_WS_MAC)
return QFileDialog::getSaveFileName(parent,
title, return QFileDialog::getSaveFileName(parent, title, directory, filter);
directory,
filter);
#else #else
QFileDialog dialog(parent, title, directory, filter); QFileDialog dialog(parent, title, directory, filter);
if (parent) {
if (parent)
{
dialog.setWindowModality(Qt::WindowModal); dialog.setWindowModality(Qt::WindowModal);
} }
QRegExp filter_regex(QLatin1String("(?:^\\*\\.(?!.*\\()|\\(\\*\\.)(\\w+)")); QRegExp filter_regex(QLatin1String("(?:^\\*\\.(?!.*\\()|\\(\\*\\.)(\\w+)"));
QStringList filters = filter.split(QLatin1String(";;")); QStringList filters = filter.split(QLatin1String(";;"));
if (!filters.isEmpty()) {
if (!filters.isEmpty())
{
dialog.setNameFilters(filters); dialog.setNameFilters(filters);
} }
dialog.setAcceptMode(QFileDialog::AcceptSave); dialog.setAcceptMode(QFileDialog::AcceptSave);
if (dialog.exec() == QDialog::Accepted) {
if (dialog.exec() == QDialog::Accepted)
{
QString file_name = dialog.selectedFiles().first(); QString file_name = dialog.selectedFiles().first();
QFileInfo info(file_name); QFileInfo info(file_name);
if (info.suffix().isEmpty() && !dialog.selectedNameFilter().isEmpty()) {
if (filter_regex.indexIn(dialog.selectedNameFilter()) != -1) { if (info.suffix().isEmpty() && !dialog.selectedNameFilter().isEmpty())
{
if (filter_regex.indexIn(dialog.selectedNameFilter()) != -1)
{
QString extension = filter_regex.cap(1); QString extension = filter_regex.cap(1);
file_name += QLatin1String(".") + extension; file_name += QLatin1String(".") + extension;
} }
} }
return file_name; return file_name;
} else { }
else
{
return QString(); return QString();
} }
#endif // Q_WS_MAC || Q_WS_WIN #endif // Q_WS_MAC || Q_WS_WIN
@@ -80,6 +80,26 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row)
layout->addWidget(m_colorSchemes, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft); layout->addWidget(m_colorSchemes, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
row++; row++;
// logging
m_loggingEnabled = new QCheckBox("Enable console and file logging", this);
layout->addWidget(createFormLabel("Logging"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_loggingEnabled, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
addHelpButton(
"Save log files and show log information in the console."
, layout, row
);
row++;
layout->setRowMinimumHeight(row++, 20);
// Controls
layout->addWidget(createFormTitle("CONTROLS"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignLeft);
row++;
// scroll speed // scroll speed
m_scrollSpeed = new QLineEdit(); m_scrollSpeed = new QLineEdit();
m_scrollSpeed->setObjectName("name"); m_scrollSpeed->setObjectName("name");
@@ -94,17 +114,16 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row)
); );
row++; row++;
// logging // graph zooming
m_loggingEnabled = new QCheckBox("Enable console and file logging", this); m_graphZooming = new QCheckBox("Zoom on mouse wheel by default", this);
layout->addWidget(createFormLabel("Logging"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight); layout->addWidget(createFormLabel("Graph Zoom"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_loggingEnabled, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft); layout->addWidget(m_graphZooming, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
addHelpButton( addHelpButton(
"Save log files and show log information in the console." "Switch graph zooming to mouse wheel by default, instead of SHIFT + mouse wheel."
, layout, row , layout, row
); );
row++; row++;
layout->setRowMinimumHeight(row++, 20); layout->setRowMinimumHeight(row++, 20);
@@ -222,6 +241,8 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row)
layout->setRowMinimumHeight(row, 30); layout->setRowMinimumHeight(row, 30);
row++; row++;
layout->setRowMinimumHeight(row++, 20);
// C/C++ // C/C++
layout->addWidget(createFormTitle("C/C++"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignLeft); layout->addWidget(createFormTitle("C/C++"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignLeft);
row++; row++;
@@ -247,9 +268,11 @@ void QtProjectWizzardContentPreferences::load()
} }
} }
m_scrollSpeed->setText(QString::number(appSettings->getScrollSpeed(), 'f', 1));
m_loggingEnabled->setChecked(appSettings->getLoggingEnabled()); m_loggingEnabled->setChecked(appSettings->getLoggingEnabled());
m_scrollSpeed->setText(QString::number(appSettings->getScrollSpeed(), 'f', 1));
m_graphZooming->setChecked(appSettings->getControlsGraphZoomOnMouseWheel());
m_coatiPort->setText(QString::number(appSettings->getCoatiPort())); m_coatiPort->setText(QString::number(appSettings->getCoatiPort()));
m_pluginPort->setText(QString::number(appSettings->getPluginPort())); m_pluginPort->setText(QString::number(appSettings->getPluginPort()));
@@ -275,10 +298,12 @@ void QtProjectWizzardContentPreferences::save()
appSettings->setColorSchemePath(m_colorSchemePaths[m_colorSchemes->currentIndex()]); appSettings->setColorSchemePath(m_colorSchemePaths[m_colorSchemes->currentIndex()]);
m_oldColorSchemeIndex = -1; m_oldColorSchemeIndex = -1;
appSettings->setLoggingEnabled(m_loggingEnabled->isChecked());
float scrollSpeed = m_scrollSpeed->text().toFloat(); float scrollSpeed = m_scrollSpeed->text().toFloat();
if (scrollSpeed) appSettings->setScrollSpeed(scrollSpeed); if (scrollSpeed) appSettings->setScrollSpeed(scrollSpeed);
appSettings->setLoggingEnabled(m_loggingEnabled->isChecked()); appSettings->setControlsGraphZoomOnMouseWheel(m_graphZooming->isChecked());
int coatiPort = m_coatiPort->text().toInt(); int coatiPort = m_coatiPort->text().toInt();
if (coatiPort) appSettings->setCoatiPort(coatiPort); if (coatiPort) appSettings->setCoatiPort(coatiPort);
@@ -40,9 +40,10 @@ private:
QComboBox* m_colorSchemes; QComboBox* m_colorSchemes;
std::vector<FilePath> m_colorSchemePaths; std::vector<FilePath> m_colorSchemePaths;
int m_oldColorSchemeIndex; int m_oldColorSchemeIndex;
QCheckBox* m_loggingEnabled;
QLineEdit* m_scrollSpeed; QLineEdit* m_scrollSpeed;
QCheckBox* m_loggingEnabled; QCheckBox* m_graphZooming;
QLineEdit* m_coatiPort; QLineEdit* m_coatiPort;
QLineEdit* m_pluginPort; QLineEdit* m_pluginPort;