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>
<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>
<graph_zoom_on_mouse_wheel><!-- BOOL: set mouse wheel to zooming by default --></graph_zoom_on_mouse_wheel>
</controls>
</config>
+10
View File
@@ -306,6 +306,16 @@ int ApplicationSettings::getControlsMouseForwardButton() const
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
{
return getValue<std::string>("user/license/license", "");
+3
View File
@@ -93,6 +93,9 @@ public:
int getControlsMouseBackButton() const;
int getControlsMouseForwardButton() const;
bool getControlsGraphZoomOnMouseWheel() const;
void setControlsGraphZoomOnMouseWheel(bool zoomingDefault);
// license
std::string getLicenseString() const;
void setLicenseString(const std::string& licenseString);
+38 -17
View File
@@ -9,6 +9,7 @@
#include <QParallelAnimationGroup>
#include "qt/utility/QtContextMenu.h"
#include "settings/ApplicationSettings.h"
QtGraphicsView::QtGraphicsView(QWidget* parent)
: QGraphicsView(parent)
@@ -168,13 +169,20 @@ void QtGraphicsView::keyReleaseEvent(QKeyEvent* event)
void QtGraphicsView::wheelEvent(QWheelEvent* event)
{
if (event->modifiers() == Qt::ShiftModifier && event->delta() != 0.0f)
{
updateZoom(event->delta());
return;
}
bool zoomDefault = ApplicationSettings::getInstance()->getControlsGraphZoomOnMouseWheel();
bool shiftPressed = event->modifiers() == Qt::ShiftModifier;
QGraphicsView::wheelEvent(event);
if (zoomDefault != shiftPressed)
{
if (event->delta() != 0.0f)
{
updateZoom(event->delta());
}
}
else
{
QGraphicsView::wheelEvent(event);
}
}
void QtGraphicsView::contextMenuEvent(QContextMenuEvent* event)
@@ -247,34 +255,47 @@ void QtGraphicsView::stopTimer()
QString ShowSaveFileDialog(QWidget *parent,
const QString &title,
const QString &directory,
const QString &filter) {
const QString &filter)
{
#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
return QFileDialog::getSaveFileName(parent,
title,
directory,
filter);
return QFileDialog::getSaveFileName(parent, title, directory, filter);
#else
QFileDialog dialog(parent, title, directory, filter);
if (parent) {
if (parent)
{
dialog.setWindowModality(Qt::WindowModal);
}
QRegExp filter_regex(QLatin1String("(?:^\\*\\.(?!.*\\()|\\(\\*\\.)(\\w+)"));
QStringList filters = filter.split(QLatin1String(";;"));
if (!filters.isEmpty()) {
if (!filters.isEmpty())
{
dialog.setNameFilters(filters);
}
dialog.setAcceptMode(QFileDialog::AcceptSave);
if (dialog.exec() == QDialog::Accepted) {
if (dialog.exec() == QDialog::Accepted)
{
QString file_name = dialog.selectedFiles().first();
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);
file_name += QLatin1String(".") + extension;
}
}
return file_name;
} else {
}
else
{
return QString();
}
#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);
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
m_scrollSpeed = new QLineEdit();
m_scrollSpeed->setObjectName("name");
@@ -94,17 +114,16 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row)
);
row++;
// logging
m_loggingEnabled = new QCheckBox("Enable console and file logging", this);
// graph zooming
m_graphZooming = new QCheckBox("Zoom on mouse wheel by default", this);
layout->addWidget(createFormLabel("Logging"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_loggingEnabled, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
layout->addWidget(createFormLabel("Graph Zoom"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_graphZooming, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
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
);
row++;
layout->setRowMinimumHeight(row++, 20);
@@ -222,6 +241,8 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row)
layout->setRowMinimumHeight(row, 30);
row++;
layout->setRowMinimumHeight(row++, 20);
// C/C++
layout->addWidget(createFormTitle("C/C++"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignLeft);
row++;
@@ -247,9 +268,11 @@ void QtProjectWizzardContentPreferences::load()
}
}
m_scrollSpeed->setText(QString::number(appSettings->getScrollSpeed(), 'f', 1));
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_pluginPort->setText(QString::number(appSettings->getPluginPort()));
@@ -275,10 +298,12 @@ void QtProjectWizzardContentPreferences::save()
appSettings->setColorSchemePath(m_colorSchemePaths[m_colorSchemes->currentIndex()]);
m_oldColorSchemeIndex = -1;
appSettings->setLoggingEnabled(m_loggingEnabled->isChecked());
float scrollSpeed = m_scrollSpeed->text().toFloat();
if (scrollSpeed) appSettings->setScrollSpeed(scrollSpeed);
appSettings->setLoggingEnabled(m_loggingEnabled->isChecked());
appSettings->setControlsGraphZoomOnMouseWheel(m_graphZooming->isChecked());
int coatiPort = m_coatiPort->text().toInt();
if (coatiPort) appSettings->setCoatiPort(coatiPort);
@@ -40,9 +40,10 @@ private:
QComboBox* m_colorSchemes;
std::vector<FilePath> m_colorSchemePaths;
int m_oldColorSchemeIndex;
QCheckBox* m_loggingEnabled;
QLineEdit* m_scrollSpeed;
QCheckBox* m_loggingEnabled;
QCheckBox* m_graphZooming;
QLineEdit* m_coatiPort;
QLineEdit* m_pluginPort;