Debian Codegraph @

src/lomiriappmenu/theme.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2016-2017 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 #include "theme.h"
18 #include "gmenumodelplatformmenu.h"
19 #include "logging.h"
20
21 #include <QtCore/QVariant>
22 #include <QDebug>
23
24 Q_LOGGING_CATEGORY(lomiriappmenu, "lomiriappmenu", QtWarningMsg)
25 const char *LomiriAppMenuTheme::name = "lomiriappmenu";
26
27 namespace {
28
29 bool useLocalMenu() {
30 QByteArray menuProxy = qgetenv("UBUNTU_MENUPROXY");
31 bool menuProxyIsZero = !menuProxy.isEmpty() && menuProxy.at(0) == '0';
32 return menuProxyIsZero;
33 }
34
35 }
36
37 LomiriAppMenuTheme::LomiriAppMenuTheme():
38 LomiriTheme()
39 {
40 qCDebug(lomiriappmenu, "LomiriAppMenuTheme::LomiriAppMenuTheme() - useLocalMenu=%s", useLocalMenu() ? "true" : "false");
41 }
42
43 QPlatformMenuItem *LomiriAppMenuTheme::createPlatformMenuItem() const
44 {
45 if (useLocalMenu()) return QGenericUnixTheme::createPlatformMenuItem();
46 return new LomiriPlatformMenuItem();
47 }
48
49 QPlatformMenu *LomiriAppMenuTheme::createPlatformMenu() const
50 {
51 if (useLocalMenu()) return QGenericUnixTheme::createPlatformMenu();
52 return new LomiriPlatformMenu();
53 }
54
55 QPlatformMenuBar *LomiriAppMenuTheme::createPlatformMenuBar() const
56 {
57 if (useLocalMenu()) return QGenericUnixTheme::createPlatformMenuBar();
58 return new LomiriPlatformMenuBar();
59 }
60
61 QPlatformSystemTrayIcon *LomiriAppMenuTheme::createPlatformSystemTrayIcon() const
62 {
63 // We can't use QGenericUnixTheme implementation since it needs the platformMenu to
64 // be a subclass of QDBusPlatformMenu and ours isn't
65 // TODO Investigate if we're fine with not supporting system trays or we should fix it
66 return nullptr;
67 }