commit
c4d19d9aca
|
@ -0,0 +1,19 @@
|
|||
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [2.1.0] - 2025-05-19
|
||||
|
||||
### Changed
|
||||
|
||||
- Use DBus, allow to change the browser's URL
|
||||
|
||||
## [2.0.0] - 2024-10-14
|
||||
|
||||
### Added
|
||||
|
||||
- Initial release of the QT6 browser
|
|
@ -1,4 +1,4 @@
|
|||
cmake_minimum_required(VERSION 3.16)
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
project(Browser)
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
cmake_minimum_required(VERSION 3.16)
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
project(DigitalClock LANGUAGES CXX)
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
|
||||
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
|
||||
# CMP0000: Call the cmake_minimum_required() command at the beginning of the top-level
|
||||
# CMakeLists.txt file even before calling the project() command.
|
||||
# The cmake_minimum_required(VERSION) command implicitly invokes the cmake_policy(VERSION)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
cmake_minimum_required(VERSION 3.16)
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
project(OGBrowser LANGUAGES CXX)
|
||||
|
||||
|
@ -17,7 +17,7 @@ endif()
|
|||
|
||||
|
||||
if (NOT DEFINED CPACK_PACKAGE_VERSION_MINOR)
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "0")
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "1")
|
||||
endif()
|
||||
|
||||
|
||||
|
@ -29,8 +29,8 @@ endif()
|
|||
set(KB_LAYOUT_DIR "/usr/lib/qtermwidget/kb" CACHE INTERNAL "")
|
||||
|
||||
|
||||
find_package(QT NAMES Qt6 COMPONENTS Widgets LinguistTools Network WebEngineWidgets REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets LinguistTools Network WebEngineWidgets REQUIRED)
|
||||
find_package(QT NAMES Qt6 COMPONENTS Widgets LinguistTools Network WebEngineWidgets DBus REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets LinguistTools Network WebEngineWidgets DBus REQUIRED)
|
||||
|
||||
|
||||
message(STATUS "Building browser with Qt ${QT_VERSION}")
|
||||
|
@ -42,6 +42,7 @@ set(SOURCES
|
|||
ogurlhandler.cpp
|
||||
desktopparser.cpp
|
||||
ogwebpage.cpp
|
||||
dbusinterface.cpp
|
||||
)
|
||||
|
||||
file(GLOB TRANSLATIONS "${PROJECT_SOURCE_DIR}/i18n/*.ts")
|
||||
|
@ -50,7 +51,8 @@ message(STATUS "Translations: ${TRANSLATIONS}")
|
|||
|
||||
|
||||
|
||||
add_executable(OGBrowser ${SOURCES})
|
||||
add_executable(OGBrowser ${SOURCES}
|
||||
dbusinterface.h dbusinterface.cpp)
|
||||
|
||||
qt6_add_translations(OGBrowser TS_FILES ${TRANSLATIONS} QM_FILES_OUTPUT_VARIABLE qm_files)
|
||||
|
||||
|
@ -58,7 +60,7 @@ set_property(TARGET OGBrowser PROPERTY CXX_STANDARD 17)
|
|||
set_property(TARGET OGBrowser PROPERTY CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
target_include_directories(OGBrowser PRIVATE "digitalclock" "qtermwidget/lib")
|
||||
target_link_libraries(OGBrowser PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network Qt${QT_VERSION_MAJOR}::WebEngineWidgets DigitalClock qtermwidget6)
|
||||
target_link_libraries(OGBrowser PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network Qt${QT_VERSION_MAJOR}::WebEngineWidgets Qt${QT_VERSION_MAJOR}::DBus DigitalClock qtermwidget6)
|
||||
|
||||
message(STATUS "Looking for headers in ${PROJECT_BINARY_DIR}")
|
||||
target_include_directories(OGBrowser PRIVATE ${qtermwidget_INCLUDE_DIRS} ${DigitalClock_INCLUDE_DIRS} ${qtermwidget_LIB_DIRS}/lib ${PROJECT_BINARY_DIR}/../lib)
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
#include "dbusinterface.h"
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QUrl>
|
||||
|
||||
|
||||
DBusInterface::DBusInterface(QObject *parent) : QObject{parent} {
|
||||
|
||||
|
||||
}
|
||||
|
||||
void DBusInterface::quit() {
|
||||
qInfo() << "Quitting";
|
||||
QCoreApplication::quit();
|
||||
}
|
||||
|
||||
|
||||
void DBusInterface::setURL(const QString &url) {
|
||||
if (_mainWindow) {
|
||||
qInfo() << "Setting URL to" << url;
|
||||
_mainWindow->slotSetUrl(QUrl(url));
|
||||
} else {
|
||||
qWarning() << "Can't set URL, no window reference";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
#ifndef DBUSINTERFACE_H
|
||||
#define DBUSINTERFACE_H
|
||||
|
||||
#include <QObject>
|
||||
#include "mainwindow.h"
|
||||
|
||||
|
||||
class DBusInterface : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DBusInterface(QObject *parent = nullptr);
|
||||
|
||||
void setMainWindow(MainWindow *window) { _mainWindow = window; };
|
||||
|
||||
public slots:
|
||||
void quit();
|
||||
void setURL(const QString &url);
|
||||
|
||||
signals:
|
||||
private:
|
||||
MainWindow* _mainWindow{nullptr};
|
||||
};
|
||||
|
||||
#endif // DBUSINTERFACE_H
|
54
src/main.cpp
54
src/main.cpp
|
@ -2,12 +2,17 @@
|
|||
#include <QTranslator>
|
||||
#include <QDebug>
|
||||
#include <QCommandLineParser>
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusInterface>
|
||||
#include <QDBusError>
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "ogcommandline.h"
|
||||
#include "desktopparser.h"
|
||||
#include "dbusinterface.h"
|
||||
|
||||
|
||||
const QString SERVICE_NAME{"es.opengnsys.OGBrowser.browser"};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -19,6 +24,9 @@ int main(int argc, char *argv[])
|
|||
QTranslator translator;
|
||||
QStringList translationDirs{QCoreApplication::applicationDirPath(), "", "."};
|
||||
|
||||
DBusInterface dbus_interface = DBusInterface();
|
||||
|
||||
|
||||
bool translationsOk = false;
|
||||
|
||||
for(const QString &dir : translationDirs) {
|
||||
|
@ -59,17 +67,60 @@ int main(int argc, char *argv[])
|
|||
QCommandLineOption ignoreSslErrors("ignore-ssl-errors", "Ignore SSL certificate errors");
|
||||
parser.addOption(ignoreSslErrors);
|
||||
|
||||
QCommandLineOption stopRunning("stop-running", "Stop any running instances");
|
||||
parser.addOption(stopRunning);
|
||||
|
||||
|
||||
QCommandLineOption helpOption = parser.addHelpOption();
|
||||
|
||||
OGCommandLineOptions &options = OGCommandLineOptions::getInstance();
|
||||
|
||||
|
||||
parser.process(a);
|
||||
QStringList positional = parser.positionalArguments();
|
||||
|
||||
if (parser.isSet(helpOption)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto connection = QDBusConnection::sessionBus();
|
||||
if (!connection.isConnected()) {
|
||||
qWarning() << "Can't connect to the D-Bus session bus!";
|
||||
} else {
|
||||
if (parser.isSet(stopRunning)) {
|
||||
QDBusInterface iface(SERVICE_NAME, "/");
|
||||
if(iface.isValid()) {
|
||||
auto reply = iface.call("quit");
|
||||
return 0;
|
||||
} else {
|
||||
qCritical() << "Can't connect to running browser";
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (!connection.registerService(SERVICE_NAME)) {
|
||||
qCritical() << "Can't register service" << SERVICE_NAME << ", browser already running";
|
||||
|
||||
if (positional.length() > 0) {
|
||||
qInfo() << "Setting URL on running browser";
|
||||
QDBusInterface iface(SERVICE_NAME, "/");
|
||||
if (iface.isValid()) {
|
||||
auto reply = iface.call("setURL", positional[0]);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
||||
qDebug() << "DBus service" << SERVICE_NAME << "registered";
|
||||
|
||||
connection.registerObject("/", &dbus_interface, QDBusConnection::ExportAllSlots);
|
||||
qDebug() << "DBus object registered";
|
||||
}
|
||||
|
||||
if (parser.isSet(openInNewTabOption)) {
|
||||
options.setNewTabBehavior(OGCommandLineOptions::NewTabBehavior::NewTab);
|
||||
}
|
||||
|
@ -86,12 +137,13 @@ int main(int argc, char *argv[])
|
|||
options.setIgnoreSslErrors(true);
|
||||
}
|
||||
|
||||
QStringList positional = parser.positionalArguments();
|
||||
|
||||
if ( positional.length() > 0) {
|
||||
options.setUrl( positional[0 ] );
|
||||
}
|
||||
|
||||
MainWindow w;
|
||||
dbus_interface.setMainWindow(&w);
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
||||
|
|
|
@ -190,18 +190,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
|
||||
m_webBar->setText(url.toString());
|
||||
|
||||
qInfo() << "Page set to" << url;
|
||||
m_web->load(url);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// auto ktm = Konsole::KeyboardTranslatorManager::instance();
|
||||
|
||||
slotSetUrl(url);
|
||||
|
||||
|
||||
showMaximized();
|
||||
|
@ -335,6 +324,11 @@ void MainWindow::slotWebLoadFinished(bool ok)
|
|||
|
||||
}
|
||||
|
||||
void MainWindow::slotSetUrl(const QUrl &url) {
|
||||
qInfo() << "Page set to" << url;
|
||||
m_web->load(url);
|
||||
}
|
||||
|
||||
void MainWindow::slotUrlChanged(const QUrl &url)
|
||||
{
|
||||
m_webBar->setText(url.toString());
|
||||
|
|
|
@ -73,6 +73,7 @@ class MainWindow : public QMainWindow
|
|||
void slotDeleteTerminal();
|
||||
|
||||
// Funcion para el webar
|
||||
void slotSetUrl(const QUrl &url);
|
||||
void slotUrlChanged(const QUrl &url);
|
||||
|
||||
void commandQueued(const QString &command, bool confirm, bool returnOutput);
|
||||
|
|
Loading…
Reference in New Issue