From 0899724d901669512d607434d95630035f1d20b8 Mon Sep 17 00:00:00 2001 From: Tannin Date: Wed, 2 Mar 2016 21:22:26 +0100 Subject: profile- and group-dropdown no longer switch by mouse-wheel. Plus fixed refreshing of right-hand side tabs --- src/eventfilter.cpp | 33 +++++++++++++++++++++++++++++++++ src/eventfilter.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/mainwindow.cpp | 22 +++++++++++++++------- 3 files changed, 92 insertions(+), 7 deletions(-) create mode 100644 src/eventfilter.cpp create mode 100644 src/eventfilter.h (limited to 'src') diff --git a/src/eventfilter.cpp b/src/eventfilter.cpp new file mode 100644 index 00000000..69327f79 --- /dev/null +++ b/src/eventfilter.cpp @@ -0,0 +1,33 @@ +/* +Copyright (C) 2016 Sebastian Herbord. All rights reserved. + +This file is part of Mod Organizer. + +Mod Organizer is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Mod Organizer is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Mod Organizer. If not, see . +*/ + + +#include "eventfilter.h" + +EventFilter::EventFilter(QObject *parent, + const EventFilter::HandlerFunc &handler) + : QObject(parent) + , m_Handler(handler) +{ +} + +bool EventFilter::eventFilter(QObject *obj, QEvent *event) +{ + return m_Handler(obj, event); +} diff --git a/src/eventfilter.h b/src/eventfilter.h new file mode 100644 index 00000000..2400a853 --- /dev/null +++ b/src/eventfilter.h @@ -0,0 +1,44 @@ +/* +Copyright (C) 2016 Sebastian Herbord. All rights reserved. + +This file is part of Mod Organizer. + +Mod Organizer is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Mod Organizer is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Mod Organizer. If not, see . +*/ + +#pragma once + + +#include +#include + + +class EventFilter : public QObject { + + Q_OBJECT + + typedef std::function HandlerFunc; + +public: + + EventFilter(QObject *parent, const HandlerFunc &handler); + + virtual bool eventFilter(QObject *obj , QEvent *event) override; + +private: + + HandlerFunc m_Handler; + +}; + diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index db7bd682..05000761 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -74,6 +74,7 @@ along with Mod Organizer. If not, see . #include "safewritefile.h" #include "nxmaccessmanager.h" #include "appconfig.h" +#include "eventfilter.h" #include #include #include @@ -290,6 +291,17 @@ MainWindow::MainWindow(QSettings &initSettings ui->savegameList->installEventFilter(this); ui->savegameList->setMouseTracking(true); + // don't allow mouse wheel to switch grouping, too many people accidentally + // turn on grouping and then don't understand what happened + + EventFilter *noWheel + = new EventFilter(this, [](QObject *, QEvent *event) -> bool { + return event->type() == QEvent::Wheel; + }); + + ui->groupCombo->installEventFilter(noWheel); + ui->profileBox->installEventFilter(noWheel); + connect(ui->savegameList, SIGNAL(itemEntered(QListWidgetItem*)), this, SLOT(saveSelectionChanged(QListWidgetItem*))); connect(ui->modList, SIGNAL(dropModeUpdate(bool)), m_OrganizerCore.modList(), SLOT(dropModeUpdate(bool))); @@ -1064,9 +1076,7 @@ void MainWindow::on_profileBox_currentIndexChanged(int index) void MainWindow::updateTo(QTreeWidgetItem *subTree, const std::wstring &directorySoFar, const DirectoryEntry &directoryEntry, bool conflictsOnly) { { - std::vector files = directoryEntry.getFiles(); - for (auto iter = files.begin(); iter != files.end(); ++iter) { - FileEntry::Ptr current = *iter; + for (const FileEntry::Ptr current : directoryEntry.getFiles()) { if (conflictsOnly && (current->getAlternatives().size() == 0)) { continue; } @@ -1476,12 +1486,10 @@ void MainWindow::on_tabWidget_currentChanged(int index) if (index == 0) { m_OrganizerCore.refreshESPList(); } else if (index == 1) { - m_OrganizerCore.refreshBSAList(); - } else if (index == 2) { refreshDataTree(); - } else if (index == 3) { + } else if (index == 2) { refreshSaveList(); - } else if (index == 4) { + } else if (index == 3) { ui->downloadView->scrollToBottom(); } } -- cgit v1.3.1