aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt22
-rw-r--r--src/net/instance.cpp4
-rw-r--r--src/widgets/tab_activity_list.cpp15
3 files changed, 32 insertions, 9 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 68c3d28..a81928c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,12 +15,17 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # For Kate's LSP
find_package(QT NAMES Qt5 REQUIRED COMPONENTS Widgets Concurrent)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Concurrent)
-find_package(mastodonpp REQUIRED)
+# Compile option for mastodonpp support
+option(MASTODONPP_BUILD "Build a version with mastodonpp support" ON)
+
+if(MASTODONPP_BUILD)
+ find_package(mastodonpp REQUIRED)
+endif()
# Get Git commit hash, from http://xit0.org/2013/04/cmake-use-git-branch-and-commit-details-in-project/
# Get a human-readable name of the latest commit on the current branch
execute_process(
- COMMAND git log -1 --format=%(describe)
+ COMMAND git log -1 "--format=%(describe)"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_DESCRIBE_TEXT
OUTPUT_STRIP_TRAILING_WHITESPACE
@@ -75,8 +80,6 @@ set(PROJECT_SOURCES
src/command_line.h
src/net/instance.cpp
src/net/instance.h
- src/net/mastodon_instance.cpp
- src/net/mastodon_instance.h
src/activitypub/fields.h
src/activitypub/apactivity.h
src/activitypub/apactor.h
@@ -96,6 +99,13 @@ set(PROJECT_SOURCES
src/activitypub/apquestion.cpp
)
+if(MASTODONPP_BUILD)
+ list(APPEND PROJECT_SOURCES
+ src/net/mastodon_instance.cpp
+ src/net/mastodon_instance.h
+ )
+endif()
+
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(ActorViewer
MANUAL_FINALIZATION
@@ -119,6 +129,10 @@ else()
endif()
endif()
+if(MASTODONPP_BUILD)
+ target_compile_definitions(ActorViewer PRIVATE MASTODONPP_BUILD)
+endif()
+
configure_file(gen/git_version.h.in gen/git_version.h)
target_include_directories(ActorViewer PRIVATE gen)
diff --git a/src/net/instance.cpp b/src/net/instance.cpp
index c3af86c..6982f64 100644
--- a/src/net/instance.cpp
+++ b/src/net/instance.cpp
@@ -1,5 +1,7 @@
#include "instance.h"
+#ifdef MASTODONPP_BUILD
#include "mastodon_instance.h"
+#endif
#include "src/settings_interface.h"
Instance* Instance::create_instance() {
@@ -8,8 +10,10 @@ Instance* Instance::create_instance() {
Instance* Instance::create_instance(AppSettingsTypes::InstanceType type) {
switch (type) {
+#ifdef MASTODONPP_BUILD
case AppSettingsTypes::InstanceType::MASTODON:
return new MastodonInstance;
+#endif
default:
return nullptr;
}
diff --git a/src/widgets/tab_activity_list.cpp b/src/widgets/tab_activity_list.cpp
index faa6138..63d6fbf 100644
--- a/src/widgets/tab_activity_list.cpp
+++ b/src/widgets/tab_activity_list.cpp
@@ -9,6 +9,7 @@
#include <QRandomGenerator>
#include <QClipboard>
#include <QMimeData>
+#include <QMessageBox>
TabActivityList::TabActivityList(Archive** archive, QWidget* parent)
: data_archive(archive), QWidget(parent), ui(new Ui::TabActivityList)
@@ -91,11 +92,15 @@ void TabActivityList::actionOpen_URL_triggered(bool checked) {
// Really hacky code but works as a PoC and allows testing
if (ok and not url.isEmpty()) {
Instance* instance = Instance::create_instance();
- APPost* post = instance->get_post_from_url(url);
- // Activity will be freed by StatusInfoWidget
- APActivity* activity = new APActivity({.object = post});
- status_info_widget->do_process_activity(activity);
- delete instance; instance = nullptr;
+ if (instance) {
+ APPost* post = instance->get_post_from_url(url);
+ // Activity will be freed by StatusInfoWidget
+ APActivity* activity = new APActivity({.object = post});
+ status_info_widget->do_process_activity(activity);
+ delete instance; instance = nullptr;
+ } else
+ // Best is to remove option from menu, should be douable if the preprocessor touches .ui files
+ QMessageBox::critical(this, tr("Open status from URL"), tr("Could not create Instance object.\nPerhaps network support was disabled at compile time?"));
}
}