Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/configuration/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ ConstString KEY_TAB_COMPLETION_DICTIONARY_SIZE = "Tab completion dictionary size
ConstString KEY_THEME = "Theme";
ConstString KEY_TLS_ENCRYPTION = "TLS encryption";
ConstString KEY_USE_INTERNAL_EDITOR = "Use internal editor";
ConstString KEY_EDITOR_DIRECTORY = "Editor directory";
ConstString KEY_USE_TRILINEAR_FILTERING = "Use trilinear filtering";
ConstString KEY_WEATHER_ATMOSPHERE_INTENSITY = "weather.atmosphereIntensity";
ConstString KEY_WEATHER_PRECIPITATION_INTENSITY = "weather.precipitationIntensity";
Expand Down Expand Up @@ -573,6 +574,7 @@ void Configuration::reset()

ConstString DEFAULT_MMAPPER_SUBDIR = "/MMapper";
ConstString DEFAULT_LOGS_SUBDIR = "/Logs";
ConstString DEFAULT_EDITOR_SUBDIR = "/Editor";
ConstString DEFAULT_RESOURCES_SUBDIR = "/Resources";

NODISCARD static QString getDefaultDirectory()
Expand Down Expand Up @@ -736,6 +738,11 @@ void Configuration::MumeClientProtocolSettings::read(const QSettings &conf)
internalRemoteEditor = conf.value(KEY_USE_INTERNAL_EDITOR, true).toBool();
externalRemoteEditorCommand = conf.value(KEY_EXTERNAL_EDITOR_COMMAND, getPlatformEditor())
.toString();
editorDirectory = conf.value(KEY_EDITOR_DIRECTORY,
getDefaultDirectory()
.append(DEFAULT_MMAPPER_SUBDIR)
.append(DEFAULT_EDITOR_SUBDIR))
.toString();
}

void Configuration::MumeNativeSettings::read(const QSettings &conf)
Expand Down Expand Up @@ -930,6 +937,7 @@ void Configuration::MumeClientProtocolSettings::write(QSettings &conf) const
{
conf.setValue(KEY_USE_INTERNAL_EDITOR, internalRemoteEditor);
conf.setValue(KEY_EXTERNAL_EDITOR_COMMAND, externalRemoteEditorCommand);
conf.setValue(KEY_EDITOR_DIRECTORY, editorDirectory);
}

void Configuration::PathMachineSettings::write(QSettings &conf) const
Expand Down
1 change: 1 addition & 0 deletions src/configuration/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class NODISCARD Configuration final
{
bool internalRemoteEditor = false;
QString externalRemoteEditorCommand;
QString editorDirectory;

private:
SUBGROUP();
Expand Down
2 changes: 2 additions & 0 deletions src/global/AsyncTasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ std::string get_type_name(const AsyncTaskTypeEnum type)
return "IO Task";
case Task:
return "Task";
case RemoteEdit:
return "RemoteEdit";
}
return "(error)";
}
Expand Down
2 changes: 1 addition & 1 deletion src/global/AsyncTasks.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class AnsiOstream;

enum class NODISCARD AsyncTaskTypeEnum : uint8_t { IO, Task };
enum class NODISCARD AsyncTaskTypeEnum : uint8_t { IO, Task, RemoteEdit };

namespace async_tasks {

Expand Down
19 changes: 17 additions & 2 deletions src/mainwindow/TasksPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#include "../global/PrintUtils.h"
#include "../global/SendToUser.h"
#include "../global/thread_utils.h"
#include "../mpi/remoteedit.h"
#include "../proxy/connectionlistener.h"
#include "../proxy/proxy.h"
#include "AsyncTypes.h"
#include "mainwindow.h"

Expand Down Expand Up @@ -71,15 +74,27 @@ struct NODISCARD TasksPanel::ListItem final : public QWidget
return QScopedPointer<QProgressBar>{progress.release()};
});
QScopedPointer<CancelTaskButton> m_cancelButton;
QScopedPointer<QPushButton> m_actionButton;

public:
explicit ListItem(async_tasks::AsyncTaskHandle moved_task)
explicit ListItem(async_tasks::AsyncTaskHandle moved_task, MainWindow &mainWindow)
: m_task{std::move(moved_task)}
, m_cancelButton{mmqt::makeQScopedPointer<CancelTaskButton>(m_task)}
, m_actionButton{mmqt::makeQScopedPointer<QPushButton>()}
{
const auto layout = mmqt::makeQPointer<QVBoxLayout>(this);
layout->addWidget(m_label.get());
layout->addWidget(m_progress.get());

if (m_task.getType() == AsyncTaskTypeEnum::RemoteEdit) {
auto btn = m_actionButton.get();
btn->setText("Show Editor / View Draft");
layout->addWidget(btn);
connect(btn, &QPushButton::clicked, this, [&mainWindow, task_id = m_task.getId()]() {
mainWindow.getRemoteEdit().slot_showDraft(task_id);
});
}

layout->addWidget(m_cancelButton.get());
layout->insertStretch(-1); // must be after all the addWidget() calls
updateProgress();
Expand Down Expand Up @@ -370,7 +385,7 @@ void TasksPanel::add_new_item(const TaskHandle &handle)
{
const auto &task = handle.task;
// NOLINTNEXTLINE (no, this is not leaked; Qt manages it)
if (auto *const item = new ListItem(task)) {
if (auto *const item = new ListItem(task, m_mainWindow)) {
getLayout().addWidget(item);
getKnownTasks().emplace(task.getId(), task);
}
Expand Down
26 changes: 26 additions & 0 deletions src/mainwindow/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "../media/AudioManager.h"
#include "../media/DescriptionWidget.h"
#include "../media/MediaLibrary.h"
#include "../mpi/remoteedit.h"
#include "../pathmachine/mmapper2pathmachine.h"
#include "../preferences/configdialog.h"
#include "../proxy/connectionlistener.h"
Expand Down Expand Up @@ -136,6 +137,8 @@ MainWindow::MainWindow()

m_prespammedPath = new PrespammedPath(this);

m_remoteEdit = new RemoteEdit(this);

m_groupManager = new Mmapper2Group(this);
m_groupManager->setObjectName("GroupManager");

Expand Down Expand Up @@ -401,6 +404,8 @@ MainWindow::MainWindow()

readSettings();
g_mainWindow = this;

QTimer::singleShot(0, this, [this]() { m_remoteEdit->recoverDrafts(); });
}

void MainWindow::startServices()
Expand Down Expand Up @@ -609,6 +614,27 @@ void MainWindow::wireConnections()
&FindRoomsDlg::sig_editSelection,
this,
&MainWindow::slot_onEditRoomSelection);

connect(m_listener, &ConnectionListener::sig_proxyCreated, this, [this](QPointer<Proxy> proxy) {
if (!proxy)
return;

connect(m_remoteEdit, &RemoteEdit::sig_sendGmcp, proxy.data(), &Proxy::slot_sendGmcp);
connect(proxy.data(), &Proxy::sig_remoteEditRequested, m_remoteEdit, &RemoteEdit::slot_remoteEdit);
connect(proxy.data(), &Proxy::sig_remoteViewRequested, m_remoteEdit, &RemoteEdit::slot_remoteView);
connect(proxy.data(),
&Proxy::sig_remoteWriteResult,
m_remoteEdit,
&RemoteEdit::slot_remoteWriteResult);
connect(proxy.data(),
&Proxy::sig_remoteCancelResult,
m_remoteEdit,
&RemoteEdit::slot_remoteCancelResult);
});

deref(m_gameObserver).sig2_disconnected.connect(m_lifetime, [this]() {
m_remoteEdit->onDisconnected();
});
}

void MainWindow::slot_log(const QString &mod, const QString &message)
Expand Down
3 changes: 3 additions & 0 deletions src/mainwindow/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class DescriptionWidget;
class MediaLibrary;
class TimerWidget;
class MapDestination;
class RemoteEdit;

struct MapLoadData;

Expand Down Expand Up @@ -117,6 +118,7 @@ class NODISCARD_QOBJECT MainWindow final : public QMainWindow
DescriptionWidget *m_descriptionWidget = nullptr;
TimerWidget *m_timerWidget = nullptr;
std::unique_ptr<HotkeyManager> m_hotkeyManager;
RemoteEdit *m_remoteEdit = nullptr;

QPointer<QMenu> m_contextMenu;

Expand Down Expand Up @@ -258,6 +260,7 @@ class NODISCARD_QOBJECT MainWindow final : public QMainWindow

NODISCARD HotkeyManager &getHotkeyManager() const { return deref(m_hotkeyManager); }
NODISCARD CTimers &getTimers() const { return deref(m_timers); }
NODISCARD RemoteEdit &getRemoteEdit() const { return deref(m_remoteEdit); }

NODISCARD bool saveFile(const QString &fileName, SaveModeEnum mode, SaveFormatEnum format);
void loadFile(std::shared_ptr<MapSource> source);
Expand Down
Loading
Loading