summaryrefslogtreecommitdiff
path: root/src/nexusview.cpp
diff options
context:
space:
mode:
authorTannin <Tannin@Miranda>2013-02-16 19:09:57 +0100
committerTannin <Tannin@Miranda>2013-02-16 19:09:57 +0100
commit5d1154c24e2475ed2b7ac248de27ab7b501a1e5e (patch)
tree265341b9c8d057da46b56ad9fde40c9b39963ebb /src/nexusview.cpp
parent44b96e6fb5f484e9a60fe03b99021a1c5f78488d (diff)
- hooks for CreateHardLink
- createprocess hook will now reroute the cwd (fixes SUM, may break other tools?) - profile code moved to separate file - executables can now be linked to toolbar - category filters are now represented as a tree - csv export of mod list - ModInfoDialog is now "window modal" instead of "application modal" - nexus dialog now updates the mod-id field while browsing - right-click in nexus browser allows to open in external browser - ini viewer is no longer modal - bugfix: another attempt to fix processing of invalid header lines in fomod xmls (bom now handled) - bugfix: integrated fomod installer will no longer overwrite detected mod name by the one from the xml - bugfix: "hide file" from conflicted files list now updates that list - bugfix: conflicted files list no longer offers to hide files in BSAs - bugfix: pressing delete on the mod list with multiplie files selected offered to delete the wrong files - regression: mod name guessing with the old regular expression was less likely to lead to an empty mod name. Now both are tried
Diffstat (limited to 'src/nexusview.cpp')
-rw-r--r--src/nexusview.cpp167
1 files changed, 99 insertions, 68 deletions
diff --git a/src/nexusview.cpp b/src/nexusview.cpp
index 1099fff2..c8c7f09d 100644
--- a/src/nexusview.cpp
+++ b/src/nexusview.cpp
@@ -17,71 +17,102 @@ You should have received a copy of the GNU General Public License
along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "nexusview.h"
-
-#include <QEvent>
-#include <QKeyEvent>
-#include <QWebFrame>
-#include <QWebElement>
-#include <QNetworkDiskCache>
-#include <QMenu>
-#include <Shlwapi.h>
-#include "utility.h"
-
-NexusView::NexusView(QWidget *parent)
- : QWebView(parent), m_LastSeenModID(0)
-{
- installEventFilter(this);
-// this->pageAction(QWebPage::OpenLinkInNewWindow)
- connect(this, SIGNAL(urlChanged(QUrl)), this, SLOT(urlChanged(QUrl)));
-
- page()->settings()->setMaximumPagesInCache(10);
-}
-
-
-void NexusView::urlChanged(const QUrl &url)
-{
- QRegExp modidExp(QString("http://([a-zA-Z0-9]*).nexusmods.com/downloads/file.php\\?id=(\\d+)"), Qt::CaseInsensitive);
- if (modidExp.indexIn(url.toString()) != -1) {
- m_LastSeenModID = modidExp.cap(2).toInt();
- }
-}
-
-
-QWebView *NexusView::createWindow(QWebPage::WebWindowType)
-{
- NexusView *newView = new NexusView(parentWidget());
- emit initTab(newView);
- return newView;
-}
-
-
-bool NexusView::eventFilter(QObject *obj, QEvent *event)
-{
- if (event->type() == QEvent::ShortcutOverride) {
- QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
- if (keyEvent->matches(QKeySequence::Find)) {
- emit startFind();
- } else if (keyEvent->matches(QKeySequence::FindNext)) {
- emit findAgain();
- }
- } else if (event->type() == QEvent::MouseButtonPress) {
- QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
- if (mouseEvent->button() == Qt::MidButton) {
- mouseEvent->ignore();
- return true;
- }
- } else if (event->type() == QEvent::MouseButtonRelease) {
- QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
- if (mouseEvent->button() == Qt::MidButton) {
- QWebHitTestResult hitTest = page()->frameAt(mouseEvent->pos())->hitTestContent(mouseEvent->pos());
- if (hitTest.linkUrl().isValid()) {
- emit openUrlInNewTab(hitTest.linkUrl());
- }
- mouseEvent->ignore();
-
- return true;
- }
- }
- return QWebView::eventFilter(obj, event);
-}
+#include "nexusview.h"
+
+#include <QEvent>
+#include <QKeyEvent>
+#include <QWebFrame>
+#include <QWebElement>
+#include <QNetworkDiskCache>
+#include <QMenu>
+#include <Shlwapi.h>
+#include "utility.h"
+
+NexusView::NexusView(QWidget *parent)
+ : QWebView(parent), m_LastSeenModID(0)
+{
+ installEventFilter(this);
+// this->pageAction(QWebPage::OpenLinkInNewWindow)
+ connect(this, SIGNAL(urlChanged(QUrl)), this, SLOT(urlChanged(QUrl)));
+
+ page()->settings()->setMaximumPagesInCache(10);
+}
+
+
+void NexusView::urlChanged(const QUrl &url)
+{
+ QRegExp modidExp(QString("http://([a-zA-Z0-9]*).nexusmods.com/downloads/file.php\\?id=(\\d+)"), Qt::CaseInsensitive);
+ if (modidExp.indexIn(url.toString()) != -1) {
+ m_LastSeenModID = modidExp.cap(2).toInt();
+ }
+}
+
+void NexusView::openPageExternal()
+{
+ ::ShellExecuteW(NULL, L"open", ToWString(url().toString()).c_str(), NULL, NULL, SW_SHOWNORMAL);
+}
+
+void NexusView::openLinkExternal()
+{
+ ::ShellExecuteW(NULL, L"open", ToWString(m_ContextURL.toString()).c_str(), NULL, NULL, SW_SHOWNORMAL);
+}
+
+
+QWebView *NexusView::createWindow(QWebPage::WebWindowType)
+{
+ NexusView *newView = new NexusView(parentWidget());
+ emit initTab(newView);
+ return newView;
+}
+
+
+bool NexusView::eventFilter(QObject *obj, QEvent *event)
+{
+ if (event->type() == QEvent::ShortcutOverride) {
+ QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
+ if (keyEvent->matches(QKeySequence::Find)) {
+ emit startFind();
+ } else if (keyEvent->matches(QKeySequence::FindNext)) {
+ emit findAgain();
+ }
+ } else if (event->type() == QEvent::MouseButtonPress) {
+ QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
+ if (mouseEvent->button() == Qt::MidButton) {
+ mouseEvent->ignore();
+ return true;
+ }
+ } else if (event->type() == QEvent::MouseButtonRelease) {
+ QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
+ if (mouseEvent->button() == Qt::MidButton) {
+ QWebHitTestResult hitTest = page()->frameAt(mouseEvent->pos())->hitTestContent(mouseEvent->pos());
+ if (hitTest.linkUrl().isValid()) {
+ emit openUrlInNewTab(hitTest.linkUrl());
+ }
+ mouseEvent->ignore();
+
+ return true;
+ }
+ }
+ return QWebView::eventFilter(obj, event);
+}
+
+
+void NexusView::contextMenuEvent(QContextMenuEvent *event)
+{
+ if (!page()->swallowContextMenuEvent(event)) {
+ QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos());
+
+ QMenu *menu = page()->createStandardContextMenu();
+ QAction *openExternalAction = new QAction("Open in external browser", menu);
+ if (r.linkUrl().isEmpty()) {
+ connect(openExternalAction, SIGNAL(triggered()), this, SLOT(openPageExternal()));
+ } else {
+ m_ContextURL = r.linkUrl();
+ connect(openExternalAction, SIGNAL(triggered()), this, SLOT(openLinkExternal()));
+ }
+
+ menu->addSeparator();
+ menu->addAction(openExternalAction);
+ menu->exec(mapToGlobal(event->pos()));
+ }
+}