Skip to content
Permalink
Browse files

macOS: add basic menubar support

  • Loading branch information
selsta committed Jul 1, 2019
1 parent eb7fae9 commit 8e78e84784c0d66dda2b7220d5e2899e4865eb72
Showing with 76 additions and 1 deletion.
  1. +1 −1 .github/workflows/build.yml
  2. +56 −0 components/MenuBar.qml
  3. +2 −0 main.qml
  4. +1 −0 qml.qrc
  5. +7 −0 src/main/main.cpp
  6. +1 −0 src/qt/macoshelper.h
  7. +8 −0 src/qt/macoshelper.mm
@@ -29,7 +29,7 @@ jobs:
- name: install monero dependencies
run: sudo apt -y install build-essential cmake libboost-all-dev miniupnpc libunbound-dev graphviz doxygen libunwind8-dev pkg-config libssl-dev libzmq3-dev libsodium-dev libhidapi-dev libnorm-dev libusb-1.0-0-dev libpgm-dev
- name: install monero gui dependencies
run: sudo apt -y install qtbase5-dev qt5-default qtdeclarative5-dev qml-module-qtquick-controls qml-module-qtquick-controls2 qml-module-qtquick-dialogs qml-module-qtquick-xmllistmodel qml-module-qt-labs-settings qml-module-qt-labs-folderlistmodel qttools5-dev-tools qml-module-qtquick-templates2 libqt5svg5-dev xvfb
run: sudo apt -y install qtbase5-dev qt5-default qtdeclarative5-dev qml-module-qtquick-controls qml-module-qtquick-controls2 qml-module-qtquick-dialogs qml-module-qtquick-xmllistmodel qml-module-qt-labs-settings qml-module-qt-labs-platform qml-module-qt-labs-folderlistmodel qttools5-dev-tools qml-module-qtquick-templates2 libqt5svg5-dev xvfb
- name: build
run: ./build.sh
- name: test qml
@@ -0,0 +1,56 @@
// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import Qt.labs.platform 1.0 as PlatformLabs
import "../components" as MoneroComponents

PlatformLabs.MenuBar {
PlatformLabs.Menu {
title: qsTr("File")
PlatformLabs.MenuItem {
enabled: appWindow.viewState === "normal"
text: qsTr("Close Wallet")
onTriggered: appWindow.showWizard()
}
}
PlatformLabs.Menu {
title: qsTr("View")
PlatformLabs.MenuItem {
text: MoneroComponents.Style.blackTheme ? qsTr("Light Theme") : qsTr("Dark Theme")
onTriggered: {
MoneroComponents.Style.blackTheme = !MoneroComponents.Style.blackTheme;
persistentSettings.blackTheme = MoneroComponents.Style.blackTheme;
}
}
PlatformLabs.MenuItem {
text: qsTr("Change Language")
onTriggered: appWindow.toggleLanguageView();
}
}
}

@@ -2168,6 +2168,8 @@ ApplicationWindow {
}
}

MoneroComponents.MenuBar { }

// @TODO: QML type 'Drawer' has issues with buildbot; debug after Qt 5.9 migration
// MoneroComponents.LanguageSidebar {
// id: languageSidebar
@@ -34,6 +34,7 @@
<file>images/prevMonth.png</file>
<file>images/prevMonth@2x.png</file>
<file>components/TitleBar.qml</file>
<file>components/MenuBar.qml</file>
<file>images/moneroLogo2.png</file>
<file>images/resize.png</file>
<file>images/resize@2x.png</file>
@@ -68,6 +68,9 @@
#include "qt/KeysFiles.h"
#include "qt/MoneroSettings.h"
#include "qt/prices.h"
#ifdef Q_OS_MAC
#include "qt/macoshelper.h"
#endif

// IOS exclusions
#ifndef Q_OS_IOS
@@ -163,6 +166,10 @@ int main(int argc, char *argv[])
if(qgetenv("QMLSCENE_DEVICE") == "softwarecontext")
isOpenGL = false;

#ifdef Q_OS_MAC
// macOS window tabbing is not supported
MacOSHelper::disableWindowTabbing();
#endif
// disable "QApplication: invalid style override passed" warning
if (isDesktop) putenv((char*)"QT_STYLE_OVERRIDE=fusion");
#ifdef Q_OS_LINUX
@@ -36,6 +36,7 @@ class MacOSHelper
public:
static bool isCapsLock();
static bool openFolderAndSelectItem(const QUrl &path);
static void disableWindowTabbing();
};

#endif //MACOSHELPER_H
@@ -37,6 +37,14 @@
#include <ApplicationServices/ApplicationServices.h>
#include <Availability.h>

void MacOSHelper::disableWindowTabbing()
{
#ifdef __MAC_10_12
if ([NSWindow respondsToSelector:@selector(allowsAutomaticWindowTabbing)])
[NSWindow setAllowsAutomaticWindowTabbing: false];
#endif
}

bool MacOSHelper::isCapsLock()
{
#ifdef __MAC_10_12

0 comments on commit 8e78e84

Please sign in to comment.
You can’t perform that action at this time.