mirror of
https://github.com/yann64/haikuports.git
synced 2026-05-02 13:08:53 +02:00
Otter-Browser: add platform integration module
* "Open with..." for download manager * Native notifications * Use application icon for system tray
This commit is contained in:
Binary file not shown.
@@ -4,7 +4,7 @@ classic Opera (12.x) UI using Qt5."
|
||||
HOMEPAGE="https://otter-browser.org/"
|
||||
COPYRIGHT="2013-2019 Otter Browser Team"
|
||||
LICENSE="GNU GPL v3"
|
||||
REVISION="6"
|
||||
REVISION="7"
|
||||
SOURCE_URI="https://github.com/OtterBrowser/otter-browser/archive/v$portVersion.tar.gz"
|
||||
CHECKSUM_SHA256="85aef7c74277cf94de237e516c3c2d507b3d19b9ad16853de938540b8bf2f16b"
|
||||
SOURCE_FILENAME="otter-browser-$portVersion.tar.gz"
|
||||
@@ -72,7 +72,7 @@ defineDebugInfoPackage otter_browser$secondaryArchSuffix \
|
||||
|
||||
PATCH()
|
||||
{
|
||||
unzip -o $sourceDir/../../additional-files/haikuicons.zip -d $sourceDir/resources/icons/theme
|
||||
unzip -o $sourceDir/../../additional-files/haikuicons.zip -d $sourceDir/resources/icons
|
||||
}
|
||||
|
||||
BUILD()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
From ba9fd1f8f8b3c5cc0fa819f645ea586bade5a038 Mon Sep 17 00:00:00 2001
|
||||
From 5c52f0ab82e4ba06391e67f4f3e359f181fc5863 Mon Sep 17 00:00:00 2001
|
||||
From: Gerasim Troeglazov <3dEyes@gmail.com>
|
||||
Date: Thu, 3 Jan 2019 17:08:40 +1000
|
||||
Subject: Fix for Haiku
|
||||
@@ -103,14 +103,14 @@ index bec0f9c..d2d6581 100644
|
||||
2.19.1
|
||||
|
||||
|
||||
From e84f821939a5b4b3f7a607e08506fdffd52fff8d Mon Sep 17 00:00:00 2001
|
||||
From 3e92b28544aa663f84d8e0707ecca12068ddbe91 Mon Sep 17 00:00:00 2001
|
||||
From: Gerasim Troeglazov <3dEyes@gmail.com>
|
||||
Date: Sat, 2 Mar 2019 23:13:15 +1000
|
||||
Subject: Add haiku hunspell paths
|
||||
|
||||
|
||||
diff --git a/3rdparty/sonnet/src/plugins/hunspell/hunspellclient.cpp b/3rdparty/sonnet/src/plugins/hunspell/hunspellclient.cpp
|
||||
index e9767a9..1956528 100644
|
||||
index e9767a9..78694a9 100644
|
||||
--- a/3rdparty/sonnet/src/plugins/hunspell/hunspellclient.cpp
|
||||
+++ b/3rdparty/sonnet/src/plugins/hunspell/hunspellclient.cpp
|
||||
@@ -56,6 +56,8 @@ HunspellClient::HunspellClient(QObject *parent)
|
||||
@@ -125,3 +125,420 @@ index e9767a9..1956528 100644
|
||||
--
|
||||
2.19.1
|
||||
|
||||
|
||||
From f62530291720990392c793a93273f39835951ce4 Mon Sep 17 00:00:00 2001
|
||||
From: Gerasim Troeglazov <3dEyes@gmail.com>
|
||||
Date: Sun, 10 Mar 2019 14:18:43 +1000
|
||||
Subject: Add platform integration module for Haiku
|
||||
|
||||
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 6bd212f..38873bc 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -504,6 +504,16 @@ elseif (APPLE)
|
||||
)
|
||||
|
||||
set_source_files_properties(resources/icons/otter-browser.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
|
||||
+elseif (HAIKU)
|
||||
+ set(otter_src
|
||||
+ ${otter_src}
|
||||
+ src/modules/platforms/haiku/HaikuPlatformIntegration.cpp
|
||||
+ src/modules/platforms/haiku/HaikuPlatformStyle.cpp
|
||||
+ 3rdparty/libmimeapps/ConfigReader.cpp
|
||||
+ 3rdparty/libmimeapps/DesktopEntry.cpp
|
||||
+ 3rdparty/libmimeapps/Index.cpp
|
||||
+ 3rdparty/libmimeapps/Tools.cpp
|
||||
+ )
|
||||
elseif (UNIX)
|
||||
find_package(Qt5DBus 5.6.0 QUIET)
|
||||
|
||||
@@ -554,6 +564,10 @@ elseif (UNIX)
|
||||
target_link_libraries(otter-browser Qt5::DBus)
|
||||
endif ()
|
||||
|
||||
+ if (HAIKU)
|
||||
+ target_link_libraries(otter-browser -lbe)
|
||||
+ endif ()
|
||||
+
|
||||
if (ENABLE_CRASHREPORTS)
|
||||
target_link_libraries(otter-browser -lpthread)
|
||||
endif ()
|
||||
diff --git a/src/core/Application.cpp b/src/core/Application.cpp
|
||||
index 64b6cc6..1b041e2 100644
|
||||
--- a/src/core/Application.cpp
|
||||
+++ b/src/core/Application.cpp
|
||||
@@ -46,6 +46,8 @@
|
||||
#include "../modules/platforms/windows/WindowsPlatformIntegration.h"
|
||||
#elif defined(Q_OS_MAC)
|
||||
#include "../modules/platforms/mac/MacPlatformIntegration.h"
|
||||
+#elif defined(Q_OS_HAIKU)
|
||||
+#include "../modules/platforms/haiku/HaikuPlatformIntegration.h"
|
||||
#elif defined(Q_OS_UNIX)
|
||||
#include "../modules/platforms/freedesktoporg/FreeDesktopOrgPlatformIntegration.h"
|
||||
#endif
|
||||
@@ -454,6 +456,8 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv), Act
|
||||
m_platformIntegration = new WindowsPlatformIntegration(this);
|
||||
#elif defined(Q_OS_MAC)
|
||||
m_platformIntegration = new MacPlatformIntegration(this);
|
||||
+#elif defined(Q_OS_HAIKU)
|
||||
+ m_platformIntegration = new HaikuPlatformIntegration(this);
|
||||
#elif defined(Q_OS_UNIX)
|
||||
m_platformIntegration = new FreeDesktopOrgPlatformIntegration(this);
|
||||
#endif
|
||||
diff --git a/src/modules/platforms/haiku/HaikuPlatformIntegration.cpp b/src/modules/platforms/haiku/HaikuPlatformIntegration.cpp
|
||||
new file mode 100644
|
||||
index 0000000..8e0d6d7
|
||||
--- /dev/null
|
||||
+++ b/src/modules/platforms/haiku/HaikuPlatformIntegration.cpp
|
||||
@@ -0,0 +1,191 @@
|
||||
+/**************************************************************************
|
||||
+* Otter Browser: Web browser controlled by the user, not vice-versa.
|
||||
+* Copyright (C) 2019 Gerasim Troeglazov <3dEyes@gmail.com>
|
||||
+*
|
||||
+* This program 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.
|
||||
+*
|
||||
+* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
+*
|
||||
+**************************************************************************/
|
||||
+
|
||||
+#include "HaikuPlatformIntegration.h"
|
||||
+#include "HaikuPlatformStyle.h"
|
||||
+#include "../../../core/Application.h"
|
||||
+#include "../../../core/NotificationsManager.h"
|
||||
+#include "../../../core/SettingsManager.h"
|
||||
+#include "../../../core/TransfersManager.h"
|
||||
+#include "../../../core/Utils.h"
|
||||
+#include "../../../../3rdparty/libmimeapps/DesktopEntry.h"
|
||||
+#include "../../../../3rdparty/libmimeapps/Index.h"
|
||||
+
|
||||
+#include <QtConcurrent/QtConcurrent>
|
||||
+#include <QtGui/QDesktopServices>
|
||||
+#include <QtGui/QIcon>
|
||||
+#include <QtGui/QRgb>
|
||||
+
|
||||
+#include <Bitmap.h>
|
||||
+#include <Entry.h>
|
||||
+#include <Path.h>
|
||||
+#include <Message.h>
|
||||
+#include <MimeType.h>
|
||||
+#include <NodeInfo.h>
|
||||
+#include <Notification.h>
|
||||
+#include <String.h>
|
||||
+
|
||||
+namespace Otter
|
||||
+{
|
||||
+
|
||||
+HaikuPlatformIntegration::HaikuPlatformIntegration(QObject *parent) : PlatformIntegration(parent)
|
||||
+{
|
||||
+}
|
||||
+
|
||||
+HaikuPlatformIntegration::~HaikuPlatformIntegration()
|
||||
+{
|
||||
+}
|
||||
+
|
||||
+void HaikuPlatformIntegration::runApplication(const QString &command, const QUrl &url) const
|
||||
+{
|
||||
+ if (command.isEmpty())
|
||||
+ QDesktopServices::openUrl(url);
|
||||
+
|
||||
+ std::vector<std::string> fileNames;
|
||||
+ fileNames.push_back((url.isLocalFile() ? QDir::toNativeSeparators(url.toLocalFile()) : url.url()).toStdString());
|
||||
+
|
||||
+ const std::vector<std::string> parsed(LibMimeApps::DesktopEntry::parseExec(command.toStdString(), \
|
||||
+ fileNames, LibMimeApps::DesktopEntry::ParseOptions::NecessarilyUseUrl));
|
||||
+
|
||||
+ if (parsed.size() < 1)
|
||||
+ return;
|
||||
+
|
||||
+ QStringList arguments;
|
||||
+ arguments.reserve(static_cast<int>(parsed.size()));
|
||||
+
|
||||
+ for (std::vector<std::string>::size_type i = 1; i < parsed.size(); ++i)
|
||||
+ arguments.append(QString::fromStdString(parsed.at(i)));
|
||||
+
|
||||
+ QProcess::startDetached(QString::fromStdString(parsed.at(0)), arguments);
|
||||
+}
|
||||
+
|
||||
+void HaikuPlatformIntegration::showNotification(Notification *notification)
|
||||
+{
|
||||
+ notification_type ntype = B_INFORMATION_NOTIFICATION;
|
||||
+
|
||||
+ QString title;
|
||||
+ switch (notification->getLevel())
|
||||
+ {
|
||||
+ case Notification::ErrorLevel:
|
||||
+ title = tr("Error");
|
||||
+ ntype = B_ERROR_NOTIFICATION;
|
||||
+ break;
|
||||
+ case Notification::WarningLevel:
|
||||
+ title = tr("Warning");
|
||||
+ ntype = B_IMPORTANT_NOTIFICATION;
|
||||
+ break;
|
||||
+ default:
|
||||
+ title = tr("Information");
|
||||
+ notification_type ntype = B_INFORMATION_NOTIFICATION;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ QFileInfo appFileInfo(QCoreApplication::applicationFilePath());
|
||||
+ BString stitle((const char *)(title.toUtf8()));
|
||||
+ BString smessage((const char *)(notification->getMessage().toUtf8()));
|
||||
+ BString smessageId((const char *)(appFileInfo.fileName().toUtf8()));
|
||||
+ BString group((const char*)(appFileInfo.baseName().toUtf8()));
|
||||
+
|
||||
+ BFile file(appFileInfo.filePath().toUtf8(), O_RDONLY);
|
||||
+ BNodeInfo nodeInfo(&file);
|
||||
+ BRect rect(0, 0, B_LARGE_ICON - 1, B_LARGE_ICON -1);
|
||||
+ BBitmap bitmap(rect, B_RGBA32);
|
||||
+
|
||||
+ BNotification notification(ntype);
|
||||
+ notification.SetGroup(group);
|
||||
+ notification.SetTitle(stitle);
|
||||
+ notification.SetMessageID(smessageId);
|
||||
+ notification.SetContent(smessage);
|
||||
+
|
||||
+ if (nodeInfo.GetTrackerIcon(&bitmap, B_LARGE_ICON) == B_NO_ERROR)
|
||||
+ notification.SetIcon(&bitmap);
|
||||
+
|
||||
+ const int visibilityDuration(SettingsManager::getOption(SettingsManager::Interface_NotificationVisibilityDurationOption).toInt());
|
||||
+
|
||||
+ notification.Send((visibilityDuration <= 0) ? 3000000 : visibilityDuration * 1000000);
|
||||
+}
|
||||
+
|
||||
+void HaikuPlatformIntegration::updateTransfersProgress()
|
||||
+{
|
||||
+}
|
||||
+
|
||||
+void HaikuPlatformIntegration::setTransfersProgress(qint64 bytesTotal, qint64 bytesReceived, qint64 transferAmount)
|
||||
+{
|
||||
+}
|
||||
+
|
||||
+Style* HaikuPlatformIntegration::createStyle(const QString &name) const
|
||||
+{
|
||||
+ return nullptr;
|
||||
+}
|
||||
+
|
||||
+QVector<ApplicationInformation> HaikuPlatformIntegration::getApplicationsForMimeType(const QMimeType &mimeType)
|
||||
+{
|
||||
+ QVector<ApplicationInformation> result;
|
||||
+
|
||||
+ BMimeType type(mimeType.name().toLatin1());
|
||||
+ BMessage applications;
|
||||
+ if (type.GetSupportingApps(&applications) != B_OK)
|
||||
+ return result;
|
||||
+
|
||||
+ ApplicationInformation application;
|
||||
+ application.command = QString("/bin/open");
|
||||
+ application.name = QString("Default application");
|
||||
+ application.icon = QIcon::fromTheme("application-x-executable");
|
||||
+ result.append(application);
|
||||
+
|
||||
+ const char* signature;
|
||||
+ int32 i = 0;
|
||||
+ while (applications.FindString("applications", i, &signature) == B_OK) {
|
||||
+ char name[B_FILE_NAME_LENGTH];
|
||||
+ BMimeType applicationType(signature);
|
||||
+ entry_ref app_ref;
|
||||
+ applicationType.GetAppHint(&app_ref);
|
||||
+ icon_size iconSize = B_MINI_ICON;
|
||||
+ BRect iconRect(0, 0, iconSize - 1, iconSize - 1);
|
||||
+ BBitmap* appIcon = new BBitmap(iconRect, 0, B_RGBA32);
|
||||
+ if (applicationType.GetIcon(appIcon, iconSize) < B_OK) {
|
||||
+ delete appIcon;
|
||||
+ appIcon = NULL;
|
||||
+ }
|
||||
+ BPath path(&app_ref);
|
||||
+ if (applicationType.GetShortDescription(name) == B_OK) {
|
||||
+ ApplicationInformation application;
|
||||
+ application.command = QString(path.Path());
|
||||
+ application.name = QString(name);
|
||||
+ if (appIcon != NULL) {
|
||||
+ QImage image(iconSize, iconSize, QImage::Format_ARGB32);
|
||||
+ memcpy((uchar*)image.bits(), (uchar*)appIcon->Bits(), iconSize * iconSize * 4);
|
||||
+ QPixmap pixmap = QPixmap::fromImage(image);
|
||||
+ application.icon = QIcon(pixmap);
|
||||
+ delete appIcon;
|
||||
+ }
|
||||
+ result.append(application);
|
||||
+ }
|
||||
+ i++;
|
||||
+ }
|
||||
+
|
||||
+ return result;
|
||||
+}
|
||||
+
|
||||
+bool HaikuPlatformIntegration::canShowNotifications() const
|
||||
+{
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+}
|
||||
diff --git a/src/modules/platforms/haiku/HaikuPlatformIntegration.h b/src/modules/platforms/haiku/HaikuPlatformIntegration.h
|
||||
new file mode 100644
|
||||
index 0000000..f49bb32
|
||||
--- /dev/null
|
||||
+++ b/src/modules/platforms/haiku/HaikuPlatformIntegration.h
|
||||
@@ -0,0 +1,53 @@
|
||||
+/**************************************************************************
|
||||
+* Otter Browser: Web browser controlled by the user, not vice-versa.
|
||||
+* Copyright (C) 2019 Gerasim Troeglazov <3dEyes@gmail.com>
|
||||
+*
|
||||
+* This program 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.
|
||||
+*
|
||||
+* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
+*
|
||||
+**************************************************************************/
|
||||
+
|
||||
+#ifndef OTTER_HAIKUPLATFORMINTEGRATION_H
|
||||
+#define OTTER_HAIKUPLATFORMINTEGRATION_H
|
||||
+
|
||||
+#include "../../../core/PlatformIntegration.h"
|
||||
+
|
||||
+namespace Otter
|
||||
+{
|
||||
+
|
||||
+class HaikuPlatformIntegration final : public PlatformIntegration
|
||||
+{
|
||||
+ Q_OBJECT
|
||||
+
|
||||
+public:
|
||||
+ explicit HaikuPlatformIntegration(QObject *parent);
|
||||
+ ~HaikuPlatformIntegration();
|
||||
+
|
||||
+ void runApplication(const QString &command, const QUrl &url = {}) const override;
|
||||
+ Style* createStyle(const QString &name) const override;
|
||||
+ QVector<ApplicationInformation> getApplicationsForMimeType(const QMimeType &mimeType) override;
|
||||
+ bool canShowNotifications() const override;
|
||||
+
|
||||
+public slots:
|
||||
+ void showNotification(Notification *notification) override;
|
||||
+
|
||||
+protected:
|
||||
+ void setTransfersProgress(qint64 bytesTotal, qint64 bytesReceived, qint64 transferAmount);
|
||||
+
|
||||
+protected slots:
|
||||
+ void updateTransfersProgress();
|
||||
+};
|
||||
+
|
||||
+}
|
||||
+
|
||||
+#endif
|
||||
diff --git a/src/modules/platforms/haiku/HaikuPlatformStyle.cpp b/src/modules/platforms/haiku/HaikuPlatformStyle.cpp
|
||||
new file mode 100644
|
||||
index 0000000..2258226
|
||||
--- /dev/null
|
||||
+++ b/src/modules/platforms/haiku/HaikuPlatformStyle.cpp
|
||||
@@ -0,0 +1,46 @@
|
||||
+/**************************************************************************
|
||||
+* Otter Browser: Web browser controlled by the user, not vice-versa.
|
||||
+* Copyright (C) 2019 Gerasim Troeglazov <3dEyes@gmail.com>
|
||||
+*
|
||||
+* This program 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.
|
||||
+*
|
||||
+* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
+*
|
||||
+**************************************************************************/
|
||||
+
|
||||
+#include "HaikuPlatformStyle.h"
|
||||
+#include "../../../core/ThemesManager.h"
|
||||
+#include "../../../ui/MainWindow.h"
|
||||
+#include "../../../ui/ToolBarWidget.h"
|
||||
+
|
||||
+#include <QtCore/QProcess>
|
||||
+#include <QtGui/QPainter>
|
||||
+#include <QtWidgets/QStyleOption>
|
||||
+
|
||||
+namespace Otter
|
||||
+{
|
||||
+
|
||||
+HaikuPlatformStyle::HaikuPlatformStyle(const QString &name) : Style(name)
|
||||
+{
|
||||
+}
|
||||
+
|
||||
+void HaikuPlatformStyle::drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
|
||||
+{
|
||||
+ Style::drawControl(element, option, painter, widget);
|
||||
+}
|
||||
+
|
||||
+int HaikuPlatformStyle::getExtraStyleHint(Style::ExtraStyleHint hint) const
|
||||
+{
|
||||
+ return Style::getExtraStyleHint(hint);
|
||||
+}
|
||||
+
|
||||
+}
|
||||
diff --git a/src/modules/platforms/haiku/HaikuPlatformStyle.h b/src/modules/platforms/haiku/HaikuPlatformStyle.h
|
||||
new file mode 100644
|
||||
index 0000000..8b50d01
|
||||
--- /dev/null
|
||||
+++ b/src/modules/platforms/haiku/HaikuPlatformStyle.h
|
||||
@@ -0,0 +1,39 @@
|
||||
+/**************************************************************************
|
||||
+* Otter Browser: Web browser controlled by the user, not vice-versa.
|
||||
+* Copyright (C) 2019 Gerasim Troeglazov <3dEyes@gmail.com>
|
||||
+*
|
||||
+* This program 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.
|
||||
+*
|
||||
+* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
+*
|
||||
+**************************************************************************/
|
||||
+
|
||||
+#ifndef OTTER_HAIKUPLATFORMSTYLE_H
|
||||
+#define OTTER_HAIKUPLATFORMSTYLE_H
|
||||
+
|
||||
+#include "../../../ui/Style.h"
|
||||
+
|
||||
+namespace Otter
|
||||
+{
|
||||
+
|
||||
+class HaikuPlatformStyle final : public Style
|
||||
+{
|
||||
+ Q_OBJECT
|
||||
+public:
|
||||
+ explicit HaikuPlatformStyle(const QString &name);
|
||||
+ void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const override;
|
||||
+ int getExtraStyleHint(ExtraStyleHint hint) const override;
|
||||
+};
|
||||
+
|
||||
+}
|
||||
+
|
||||
+#endif
|
||||
--
|
||||
2.19.1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user