Add support for open with on MacOS
This commit is contained in:
@@ -29,6 +29,7 @@ add_subdirectory(libXISF)
|
|||||||
|
|
||||||
set(TENMON_SRC
|
set(TENMON_SRC
|
||||||
src/about.cpp src/about.h
|
src/about.cpp src/about.h
|
||||||
|
src/application.cpp src/application.h
|
||||||
src/batchprocessing.cpp src/batchprocessing.h src/batchprocessing.ui
|
src/batchprocessing.cpp src/batchprocessing.h src/batchprocessing.ui
|
||||||
src/chartgraph.h src/chartgraph.cpp
|
src/chartgraph.h src/chartgraph.cpp
|
||||||
src/database.cpp src/database.h
|
src/database.cpp src/database.h
|
||||||
@@ -74,6 +75,8 @@ elseif(APPLE)
|
|||||||
set(tenmon_ICON ${CMAKE_CURRENT_SOURCE_DIR}/resources/tenmon.icns)
|
set(tenmon_ICON ${CMAKE_CURRENT_SOURCE_DIR}/resources/tenmon.icns)
|
||||||
find_package(Qt6 COMPONENTS DBus REQUIRED)
|
find_package(Qt6 COMPONENTS DBus REQUIRED)
|
||||||
set_source_files_properties(${tenmon_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
|
set_source_files_properties(${tenmon_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
|
||||||
|
set(MACOSX_BUNDLE_INFO_PLIST "Info.plist")
|
||||||
|
set(MACOSX_BUNDLE_ICON_FILE ${tenmon_ICON})
|
||||||
else()
|
else()
|
||||||
set(tenmon_ICON "")
|
set(tenmon_ICON "")
|
||||||
find_package(Qt6 COMPONENTS DBus REQUIRED)
|
find_package(Qt6 COMPONENTS DBus REQUIRED)
|
||||||
|
|||||||
+50
@@ -0,0 +1,50 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>English</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>tenmon</string>
|
||||||
|
<key>CFBundleGetInfoString</key>
|
||||||
|
<string>${MACOSX_BUNDLE_INFO_STRING}</string>
|
||||||
|
<key>CFBundleIconFile</key>
|
||||||
|
<string>${MACOSX_BUNDLE_ICON_FILE}</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleLongVersionString</key>
|
||||||
|
<string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>APPL</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
|
||||||
|
<key>CSResourcesFileMapped</key>
|
||||||
|
<true/>
|
||||||
|
<key>NSHumanReadableCopyright</key>
|
||||||
|
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
|
||||||
|
<key>CFBundleDocumentTypes</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeExtensions</key>
|
||||||
|
<array>
|
||||||
|
<string>fits</string>
|
||||||
|
<string>fit</string>
|
||||||
|
<string>xisf</string>
|
||||||
|
<string>png</string>
|
||||||
|
<string>jpg</string>
|
||||||
|
<string>jpeg</string>
|
||||||
|
<string>tiff</string>
|
||||||
|
<string>tif</string>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Viewer</string>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#include "application.h"
|
||||||
|
|
||||||
|
#include <QFileOpenEvent>
|
||||||
|
|
||||||
|
Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Application::event(QEvent *event)
|
||||||
|
{
|
||||||
|
if (event->type() == QEvent::FileOpen) {
|
||||||
|
QFileOpenEvent *openEvent = static_cast<QFileOpenEvent *>(event);
|
||||||
|
emit openFileEvent(openEvent->file());
|
||||||
|
}
|
||||||
|
|
||||||
|
return QApplication::event(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#ifndef APPLICATION_H
|
||||||
|
#define APPLICATION_H
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
class Application : public QApplication
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
Application(int &argc, char **argv);
|
||||||
|
bool event(QEvent *event) override;
|
||||||
|
signals:
|
||||||
|
void openFileEvent(const QString &file);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // APPLICATION_H
|
||||||
+4
-4
@@ -1,5 +1,5 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include <QApplication>
|
#include "application.h"
|
||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QSurfaceFormat>
|
#include <QSurfaceFormat>
|
||||||
@@ -102,11 +102,10 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
QSurfaceFormat::setDefaultFormat(format);
|
QSurfaceFormat::setDefaultFormat(format);
|
||||||
|
|
||||||
|
Application a(argc, argv);
|
||||||
QApplication a(argc, argv);
|
|
||||||
a.setOrganizationName("nou");
|
a.setOrganizationName("nou");
|
||||||
a.setApplicationName("Tenmon");
|
a.setApplicationName("Tenmon");
|
||||||
a.setWindowIcon(QIcon(":/space.nouspiro.tenmon.png"));
|
a.setWindowIcon(QIcon(":/space.nouspiro.tenmon_64.png"));
|
||||||
|
|
||||||
QTranslator translator;
|
QTranslator translator;
|
||||||
QTranslator translator2;
|
QTranslator translator2;
|
||||||
@@ -127,6 +126,7 @@ int main(int argc, char *argv[])
|
|||||||
a.installTranslator(&translator2);
|
a.installTranslator(&translator2);
|
||||||
|
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
|
QObject::connect(&a, &Application::openFileEvent, &w, static_cast<void (MainWindow::*)(const QString&)>(&MainWindow::loadFile));
|
||||||
w.show();
|
w.show();
|
||||||
|
|
||||||
if(!cmd.positionalArguments().isEmpty() && !cmd.isSet("script"))
|
if(!cmd.positionalArguments().isEmpty() && !cmd.isSet("script"))
|
||||||
|
|||||||
Reference in New Issue
Block a user