Commit e3ff8c3b authored by René J.V. Bertin's avatar René J.V. Bertin

Mac UI adaptations

- support for opening documents from the Finder, like a native application
- protect the embedded application icon
- Ark doesn't have a fullscreen menu action; disable the fullscreen
  titlebar button.

https: //phabricator.kde.org/D5990
parent 0f8bf1f6
......@@ -29,6 +29,24 @@ target_link_libraries(ark
KF5::KIOFileWidgets
KF5::Parts)
# we provide our own Info.plist containing a simple "we open anything" instruction.
if(APPLE)
# own plist template
set_target_properties (ark PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/MacOSXBundleInfo.plist.in)
# the MacOSX bundle display name property (CFBundleDisplayName) is not currently supported by cmake,
# so has to be set for all targets in this cmake file
set(MACOSX_BUNDLE_DISPLAY_NAME Ark)
set_target_properties(ark PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER "org.kde.Ark")
set_target_properties(ark PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Ark")
set_target_properties(ark PROPERTIES MACOSX_BUNDLE_DISPLAY_NAME "Ark")
set_target_properties(ark PROPERTIES MACOSX_BUNDLE_INFO_STRING "Ark - KDE Archiving Tool")
set_target_properties(ark PROPERTIES MACOSX_BUNDLE_LONG_VERSION_STRING "Ark ${KDE_APPLICATIONS_VERSION}")
set_target_properties(ark PROPERTIES MACOSX_BUNDLE_SHORT_VERSION_STRING "${KDE_APPLICATIONS_VERSION}")
set_target_properties(ark PROPERTIES MACOSX_BUNDLE_BUNDLE_VERSION "${KDE_APPLICATIONS_VERSION}")
set_target_properties(ark PROPERTIES MACOSX_BUNDLE_COPYRIGHT "1997-2017, The Ark Developers")
endif()
# Remove duplicate mimetypes from list of supported formats.
list(REMOVE_DUPLICATES SUPPORTED_ARK_MIMETYPES)
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSHighResolutionCapable</key>
<string>True</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</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>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>LSRequiresCarbon</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
<key>LSMultipleInstancesProhibited</key>
<true/>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>*</string>
</array>
<key>CFBundleTypeName</key>
<string>NSStringPboardType</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
</dict>
</array>
</dict>
</plist>
......@@ -31,6 +31,7 @@
#include <QCommandLineParser>
#include <QByteArray>
#include <QFileInfo>
#include <QFileOpenEvent>
#include <KAboutData>
#include <KCrash>
......@@ -40,6 +41,31 @@
using Kerfuffle::AddToArchive;
class OpenFileEventHandler : public QObject
{
Q_OBJECT
public:
OpenFileEventHandler(QApplication *parent, MainWindow *w)
: QObject(parent)
, m_window(w)
{
parent->installEventFilter(this);
}
bool eventFilter(QObject *obj, QEvent *event) override
{
if (event->type() == QEvent::FileOpen) {
QFileOpenEvent *openEvent = static_cast<QFileOpenEvent*>(event);
qCDebug(ARK) << "File open event:" << openEvent->url() << "for window" << m_window;
m_window->openUrl(openEvent->url());
return true;
}
return QObject::eventFilter(obj, event);
}
private:
MainWindow *m_window;
};
int main(int argc, char **argv)
{
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts); // Required for the webengine part.
......@@ -127,7 +153,7 @@ int main(int argc, char **argv)
QStringLiteral("http://littlesvr.ca/misc/contactandrew.php"));
KAboutData::setApplicationData(aboutData);
application.setWindowIcon(QIcon::fromTheme(QStringLiteral("ark")));
application.setWindowIcon(QIcon::fromTheme(QStringLiteral("ark"), application.windowIcon()));
QCommandLineParser parser;
parser.addHelpOption();
......@@ -293,6 +319,7 @@ int main(int argc, char **argv)
}
window->openUrl(QUrl::fromUserInput(urls.at(0), QString(), QUrl::AssumeLocalFile));
}
new OpenFileEventHandler(&application, window);
window->show();
}
}
......@@ -300,3 +327,5 @@ int main(int argc, char **argv)
qCDebug(ARK) << "Entering application loop";
return application.exec();
}
#include "main.moc"
......@@ -64,6 +64,8 @@ MainWindow::MainWindow(QWidget *)
{
setupActions();
setAcceptDrops(true);
// Ark doesn't provide a fullscreen mode; remove the corresponding window button
setWindowFlags(windowFlags() & ~Qt::WindowFullscreenButtonHint);
}
MainWindow::~MainWindow()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment