Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All fixes for appindicator, builds on older cmake #17

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
66 changes: 56 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
cmake_minimum_required(VERSION 3.0.0)
cmake_policy(SET CMP0048 NEW)
project(UTLauncher VERSION 0.3.6)
if(WITH_APPINDICATOR)
cmake_minimum_required(VERSION 2.8.12)
project(UTLauncher)
else()
cmake_minimum_required(VERSION 3.0.0)
cmake_policy(SET CMP0048 NEW)
project(UTLauncher VERSION 0.3.6)
endif()

set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMakeModules")
include(MingwResource)
include(Version)
include(DeployQt5) # For Mac
if(APPLE)
include(DeployQt5) # For Mac
endif()

# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
Expand All @@ -18,23 +25,52 @@ find_package(PkgConfig)
find_package(ZLIB)
#find_package(Boost COMPONENTS system REQUIRED)

# Ubuntu Appindicator GTK2--------------------------------------------
if(WITH_APPINDICATOR)
pkg_check_modules(PC_APPINDICATOR REQUIRED appindicator-0.1)
pkg_check_modules(GTK2 REQUIRED gtk+-2.0)

find_path(APPINDICATOR_INCLUDE_DIR NAMES libappindicator/app-indicator.h
HINTS ${PC_APPINDICATOR_INCLUDEDIR} ${PC_APPINDICATOR_INCLUDE_DIRS}
PATH_SUFFIXES libappindicator-0.1)

find_library(APPINDICATOR_LIBRARY NAMES appindicator)

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(APPINDICATOR DEFAULT_MSG APPINDICATOR_LIBRARY APPINDICATOR_INCLUDE_DIR)

if(APPINDICATOR_FOUND)
set(APPINDICATOR_LIBRARIES ${APPINDICATOR_LIBRARY})
set(APPINDICATOR_INCLUDE_DIRS ${APPINDICATOR_INCLUDE_DIR})
endif()

mark_as_advanced(APPINDICATOR_INCLUDE_DIR APPINDICATOR_LIBRARY)
endif()
# ------------------------------------------------------------

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC")

#pkg_check_modules(LIBTORRENT libtorrent-rasterbar)
#string (REPLACE ";" " " LIBTORRENT_CFLAGS_STR "${LIBTORRENT_CFLAGS} -DBOOST_THREAD_USE_LIB")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBTORRENT_CFLAGS_STR}")

if(CMAKE_BUILD_TYPE MATCHES Release)
add_definitions(-DQT_NO_DEBUG_OUTPUT)
add_definitions(-DQT_NO_DEBUG_OUTPUT)
endif()

add_subdirectory(3rdparty)
include_directories(${3rdparty_INCLUDE_DIRS})
if(APPINDICATOR_FOUND)
include_directories(${3rdparty_INCLUDE_DIRS} ${GTK2_INCLUDE_DIRS} ${APPINDICATOR_INCLUDE_DIR})
link_directories(${GTK2_LIBRARY_DIRS} ${APPINDICATOR_LIBRARY})
else()
include_directories(${3rdparty_INCLUDE_DIRS})
endif()

qt5_add_resources(resources files.qrc flags.qrc)

if(CMAKE_SYSTEM_NAME MATCHES Windows)
add_win32_resource(rc_srcs application.rc)
add_win32_resource(rc_srcs application.rc)
endif(CMAKE_SYSTEM_NAME MATCHES Windows)

add_definitions(-DLAUNCH_WITH_UE4)
Expand All @@ -50,8 +86,13 @@ else()
set(BUILD_TYPE "")
endif()

set(UTLauncher_VERSION "${PROJECT_VERSION}" CACHE STRING "Version number" FORCE INTERNAL)
set_version_number(UTLauncher)
if(APPINDICATOR_FOUND)
set(UTLauncher_VERSION "0.3.6" CACHE STRING "Version number" FORCE INTERNAL)
set_version_number(UTLauncher)
else()
set(UTLauncher_VERSION "${PROJECT_VERSION}" CACHE STRING "Version number" FORCE INTERNAL)
set_version_number(UTLauncher)
endif()

add_definitions(-DNO_DOWNLOAD -DVERSION_MAJOR=${UTLauncher_VERSION_MAJOR} -DVERSION_MINOR=${UTLauncher_VERSION_MINOR} -DVERSION_PATCH=${UTLauncher_VERSION_PATCH})
add_executable(UTLauncher ${BUILD_TYPE} ${resources} ${rc_srcs} main.cpp utlauncher.cpp download.cpp utsplash.cpp bootstrap.cpp serverbrowser.cpp configdialog.cpp $<TARGET_OBJECTS:QtAwesome> $<TARGET_OBJECTS:quazip>)
Expand All @@ -61,7 +102,12 @@ if(STATIC_BUILD_WIN32)
add_definitions(-DSTATIC_PLUGIN_WINDOWS)
target_link_libraries(UTLauncher Qt5::Widgets Qt5::QWindowsIntegrationPlugin Qt5::Network ${QT5WIDGETS_LDFLAGS} ${ZLIB_LIBRARY})
else()
target_link_libraries(UTLauncher Qt5::Widgets Qt5::Network ${Boost_SYSTEM_LIBRARY} ${ZLIB_LIBRARY})
if(APPINDICATOR_FOUND)
add_definitions(-DAPPINDICATOR)
target_link_libraries(UTLauncher Qt5::Widgets Qt5::Network ${Boost_SYSTEM_LIBRARY} ${ZLIB_LIBRARY} ${GTK2_LIBRARIES} ${APPINDICATOR_LIBRARY})
else()
target_link_libraries(UTLauncher Qt5::Widgets Qt5::Network ${Boost_SYSTEM_LIBRARY} ${ZLIB_LIBRARY})
endif()
endif()

install(TARGETS UTLauncher BUNDLE DESTINATION . RUNTIME DESTINATION bin)
Expand Down
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ pacman -U utlauncher-git*.pkg.tar.xz
### Build instructions

#### Requirements
You need to install Qt5 base development package, G++ compiler and cmake.
You need to install Qt5 base development package, libappindicator-dev, G++ compiler and cmake.

##### Ubuntu
```
sudo apt-add-repository ppa:ubuntu-sdk-team/ppa
sudo apt-get update
sudo apt-get install qtbase5-dev g++ cmake
sudo apt-get install qtbase5-dev g++ cmake libappindicator-dev
Important: Build will fail without "-DWITH_APPINDICATOR=1"
```
##### openSUSE
`sudo zypper install libqt5-qtbase-devel gcc-c++ cmake`
Expand All @@ -45,7 +44,17 @@ cd UTLauncher
git submodule update --init --recursive
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
```
to build with ubuntu appindicator:
```
cmake .. -DCMAKE_BUILD_TYPE=Release -DWITH_APPINDICATOR=1
```

```
make
```
optional:
```
sudo make install
```

Expand Down
143 changes: 143 additions & 0 deletions appindicator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
#ifndef APPINDICATOR_H
#define APPINDICATOR_H

#undef signals
extern "C" {

#include <libappindicator/app-indicator.h>
#include <gtk/gtk.h>

void serverlistIndicator(GtkMenu *, gpointer);
void runutIndicator(GtkMenu *, gpointer);
void runeditorIndicator(GtkMenu *, gpointer);
void quitIndicator(GtkMenu *, gpointer);
}
#define signals public
/*
void UTLauncher::startServerBrowser()
systemTrayMenu->addAction(showBrowser);
systemTrayMenu->addSeparator();
systemTrayMenu->addAction(runUTAction);
systemTrayMenu->addAction(runEditorAction);
systemTrayMenu->addSeparator();
systemTrayMenu->addAction(quitAction);
*/


void serverlistIndicator(GtkMenu *menu, gpointer data) {
Q_UNUSED(menu);
//UTLauncher *self = static_cast<UTLauncher *>(data);

//self->startServerBrowser().showBrowser.exec();
//showBrowser
}

void runutIndicator(GtkMenu *menu, gpointer data) {
Q_UNUSED(menu);
//runUTAction
}

void runeditorIndicator(GtkMenu *menu, gpointer data) {
Q_UNUSED(menu);
//runEditorAction
}

void quitIndicator(GtkMenu *menu, gpointer data) {
Q_UNUSED(menu);
QApplication *self = static_cast<QApplication *>(data);

self->quit();
}

void ShowUnityAppIndicator()
{
AppIndicator *indicator;
GtkWidget *menu, *quit_item, *serverlist_item, *runut_item, *runeditor_item;

menu = gtk_menu_new();

serverlist_item = gtk_menu_item_new_with_label("Server List");
gtk_menu_shell_append(GTK_MENU_SHELL(menu), serverlist_item);
g_signal_connect(serverlist_item, "activate",
G_CALLBACK(serverlistIndicator), qApp); // We cannot connect
// gtk signal and qt slot so we need to create proxy
// function later on, we pass qApp pointer as an argument.
// This is useful when we need to call signals on "this"
//object so external function can access current object
gtk_widget_show(serverlist_item);

runut_item = gtk_menu_item_new_with_label("Run UT");
gtk_menu_shell_append(GTK_MENU_SHELL(menu), runut_item);
g_signal_connect(runut_item, "activate",
G_CALLBACK(runutIndicator), qApp); // We cannot connect
// gtk signal and qt slot so we need to create proxy
// function later on, we pass qApp pointer as an argument.
// This is useful when we need to call signals on "this"
//object so external function can access current object
gtk_widget_show(runut_item);

runeditor_item = gtk_menu_item_new_with_label("Run Editor");
gtk_menu_shell_append(GTK_MENU_SHELL(menu), runeditor_item);
g_signal_connect(runeditor_item, "activate",
G_CALLBACK(runeditorIndicator), qApp); // We cannot connect
// gtk signal and qt slot so we need to create proxy
// function later on, we pass qApp pointer as an argument.
// This is useful when we need to call signals on "this"
//object so external function can access current object
gtk_widget_show(runeditor_item);

quit_item = gtk_menu_item_new_with_label("Quit");
gtk_menu_shell_append(GTK_MENU_SHELL(menu), quit_item);
g_signal_connect(quit_item, "activate",
G_CALLBACK(quitIndicator), qApp); // We cannot connect
// gtk signal and qt slot so we need to create proxy
// function later on, we pass qApp pointer as an argument.
// This is useful when we need to call signals on "this"
//object so external function can access current object
gtk_widget_show(quit_item);


/*
auto showBrowser = new QAction(awesome->icon(fa::listalt), "Server List", this);
connect(showBrowser, &QAction::triggered, [=]() {
browser->showNormal();
browser->raise();
browser->activateWindow();
});

auto runUTAction = new QAction(awesome->icon( fa::gamepad ),"Run UT", this);
connect(runUTAction, &QAction::triggered, [=]() {
QString exePath = bootstrap.programExePath();
if(!exePath.length()) {
browser->show();
openSettings();
return;
}
QProcess::startDetached(exePath);
});

auto runEditorAction = new QAction(awesome->icon( fa::code ),"Run Editor", this);
connect(runEditorAction, &QAction::triggered, [=]() {
QString editorPath = bootstrap.editorExePath();
QString projectPath = bootstrap.projectPath();
QProcess::startDetached(editorPath, QStringList() << projectPath);
});
*/
indicator = app_indicator_new(
"UTLauncher", //id
"indicator_utlauncher", //icon default:indicator-messages
APP_INDICATOR_CATEGORY_APPLICATION_STATUS //category
);

QFile tempfile;
tempfile.copy(":/indicator_utlauncher.png", QDir::tempPath()+"/indicator_utlauncher.png");
// not working...
//tempfile.setPermissions(QFile::ReadOwner | QFile::WriteOwner | QFile::ReadUser | QFile::WriteUser | QFile::ReadOther | QFile::WriteOther);

app_indicator_set_icon_theme_path(indicator, "/tmp");
app_indicator_set_icon_full(indicator, "indicator_utlauncher", "");

app_indicator_set_status(indicator, APP_INDICATOR_STATUS_ACTIVE);
app_indicator_set_menu(indicator, GTK_MENU(menu));
}
#endif
4 changes: 3 additions & 1 deletion configdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,16 @@ class ConfigDialog : public QDialog
locationsButton->setSizeHint(QSize(80, 64));
buttonMap[locationsButton] = 0;

//only show when appindicator is disabled
#ifndef APPINDICATOR
auto uiButton = new QListWidgetItem(contentsWidget);
uiButton->setIcon(awesome->icon(fa::desktop));
uiButton->setText(tr("UI"));
uiButton->setTextAlignment(Qt::AlignHCenter);
uiButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
uiButton->setSizeHint(QSize(80, 64));
buttonMap[uiButton] = 1;

#endif

connect(contentsWidget,
SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
Expand Down
1 change: 1 addition & 0 deletions files.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<qresource prefix="/">
<file>splash.jpg</file>
<file>icon.png</file>
<file>indicator_utlauncher.png</file>
</qresource>
</RCC>
Binary file added indicator_utlauncher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions serverbrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,12 @@ class ServerBrowser : public QMainWindow
this->hide();
return;
}

//not working --> file is read only...
#ifdef APPINDICATOR
QFile::remove(QDir::tempPath()+"/indicator_utlauncher.png");
#endif

QMainWindow::closeEvent(event);
}

Expand Down
3 changes: 3 additions & 0 deletions ubuntu_dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sudo apt-get install qtbase5-dev g++ cmake libappindicator-dev
sudo apt-get remove qtbase5-dev g++ cmake libappindicator-dev

15 changes: 14 additions & 1 deletion utlauncher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#include "configdialog.h"
#include <QProgressDialog>

#ifdef APPINDICATOR
#include "appindicator.h"
#endif

QtAwesome* awesome;

QColor UTLauncher::iconColor() const {
Expand Down Expand Up @@ -323,6 +327,15 @@ void UTLauncher::startServerBrowser()
systemTrayMenu->addAction(quitAction);

systemTray.setContextMenu(systemTrayMenu);

// shows unity appindicator
#ifdef APPINDICATOR
// hide qt systemtray - not working on unity
systemTray.hide();
ShowUnityAppIndicator(); //TODO: implement full appindicator
#endif

#ifndef APPINDICATOR
systemTray.show();

connect(&systemTray, &QSystemTrayIcon::activated, [=](QSystemTrayIcon::ActivationReason reason) {
Expand All @@ -344,5 +357,5 @@ void UTLauncher::startServerBrowser()

}
});

#endif
}