Skip to content

Commit 4e00f28

Browse files
committed
Reworking.
1 parent 845f5b6 commit 4e00f28

6 files changed

Lines changed: 70 additions & 2 deletions

File tree

source/client/ui/chat/chat_window.cc

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "base/crypto/generic_hash.h"
2323
#include "client/client_text_chat.h"
2424
#include "common/ui/chat_widget.h"
25+
#include "common/ui/session_type.h"
2526
#include "ui_chat_window.h"
2627

2728
namespace {
@@ -62,6 +63,21 @@ ChatWindow::ChatWindow(QWidget* parent)
6263
chat.mutable_chat_status()->CopyFrom(status);
6364
emit sig_chatMessage(chat);
6465
});
66+
67+
auto make_action = [this](proto::peer::SessionType type)
68+
{
69+
QAction* action = new QAction(sessionIcon(type), sessionName(type), this);
70+
connect(action, &QAction::triggered, this, [this, type]()
71+
{
72+
const ComputerConfig& computer = sessionState()->computer();
73+
emit sig_connectRequested(computer.id, computer, type);
74+
});
75+
return action;
76+
};
77+
78+
action_desktop_ = make_action(proto::peer::SESSION_TYPE_DESKTOP);
79+
action_file_transfer_ = make_action(proto::peer::SESSION_TYPE_FILE_TRANSFER);
80+
action_system_info_ = make_action(proto::peer::SESSION_TYPE_SYSTEM_INFO);
6581
}
6682

6783
//--------------------------------------------------------------------------------------------------
@@ -96,7 +112,10 @@ void ChatWindow::setTabbedMode(bool tabbed)
96112
//--------------------------------------------------------------------------------------------------
97113
QList<QPair<Tab::ActionRole, QList<QAction*>>> ChatWindow::tabActionGroups() const
98114
{
99-
return {{ Tab::ActionRole::FILE, ui->text_chat_widget->tabActions() }};
115+
return {
116+
{ Tab::ActionRole::FILE, ui->text_chat_widget->tabActions() },
117+
{ Tab::ActionRole::ACTION, { action_desktop_, action_file_transfer_, action_system_info_ } }
118+
};
100119
}
101120

102121
//--------------------------------------------------------------------------------------------------

source/client/ui/chat/chat_window.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ public slots:
5656

5757
private:
5858
std::unique_ptr<Ui::ChatWindow> ui;
59+
QAction* action_desktop_ = nullptr;
60+
QAction* action_file_transfer_ = nullptr;
61+
QAction* action_system_info_ = nullptr;
5962
Q_DISABLE_COPY_MOVE(ChatWindow)
6063
};
6164

source/client/ui/file_transfer/file_transfer_window.cc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "client/ui/file_transfer/file_transfer_widget.h"
3030

3131
#include "common/ui/msg_box.h"
32+
#include "common/ui/session_type.h"
3233

3334
//--------------------------------------------------------------------------------------------------
3435
FileTransferWindow::FileTransferWindow(QWidget* parent)
@@ -49,6 +50,21 @@ FileTransferWindow::FileTransferWindow(QWidget* parent)
4950
connect(ui->remove_widget, &FileRemoveWidget::sig_finished,
5051
this, &FileTransferWindow::onRemoveWidgetFinished);
5152

53+
auto make_action = [this](proto::peer::SessionType type)
54+
{
55+
QAction* action = new QAction(sessionIcon(type), sessionName(type), this);
56+
connect(action, &QAction::triggered, this, [this, type]()
57+
{
58+
const ComputerConfig& computer = sessionState()->computer();
59+
emit sig_connectRequested(computer.id, computer, type);
60+
});
61+
return action;
62+
};
63+
64+
action_desktop_ = make_action(proto::peer::SESSION_TYPE_DESKTOP);
65+
action_text_chat_ = make_action(proto::peer::SESSION_TYPE_TEXT_CHAT);
66+
action_system_info_ = make_action(proto::peer::SESSION_TYPE_SYSTEM_INFO);
67+
5268
ui->local_panel->setFocus();
5369
}
5470

@@ -94,6 +110,12 @@ Client* FileTransferWindow::createClient()
94110
return client;
95111
}
96112

113+
//--------------------------------------------------------------------------------------------------
114+
QList<QPair<Tab::ActionRole, QList<QAction*>>> FileTransferWindow::tabActionGroups() const
115+
{
116+
return {{ Tab::ActionRole::ACTION, { action_desktop_, action_text_chat_, action_system_info_ }}};
117+
}
118+
97119
//--------------------------------------------------------------------------------------------------
98120
QByteArray FileTransferWindow::saveState() const
99121
{

source/client/ui/file_transfer/file_transfer_window.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class FileTransferWindow final : public ClientWindow
3939

4040
// ClientWindow implementation.
4141
Client* createClient() final;
42+
QList<QPair<Tab::ActionRole, QList<QAction*>>> tabActionGroups() const final;
4243
QByteArray saveState() const final;
4344
void restoreState(const QByteArray& state) final;
4445

@@ -95,6 +96,9 @@ private slots:
9596
void setFilePanelsEnabled(bool enabled);
9697

9798
std::unique_ptr<Ui::FileTransferWindow> ui;
99+
QAction* action_desktop_ = nullptr;
100+
QAction* action_text_chat_ = nullptr;
101+
QAction* action_system_info_ = nullptr;
98102

99103
Q_DISABLE_COPY_MOVE(FileTransferWindow)
100104
};

source/client/ui/sys_info/system_info_window.cc

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#include "client/ui/sys_info/sys_info_widget_video_adapters.h"
5353
#include "client/ui/sys_info/tree_to_html.h"
5454
#include "common/system_info_constants.h"
55+
#include "common/ui/session_type.h"
5556
#include "ui_system_info_window.h"
5657

5758
namespace {
@@ -295,6 +296,21 @@ SystemInfoWindow::SystemInfoWindow(QWidget* parent)
295296
layout_ = new QHBoxLayout(ui->widget);
296297
layout_->setContentsMargins(0, 0, 0, 0);
297298
layout_->addWidget(sys_info_widgets_[current_widget_]);
299+
300+
auto make_action = [this](proto::peer::SessionType type)
301+
{
302+
QAction* action = new QAction(sessionIcon(type), sessionName(type), this);
303+
connect(action, &QAction::triggered, this, [this, type]()
304+
{
305+
const ComputerConfig& computer = sessionState()->computer();
306+
emit sig_connectRequested(computer.id, computer, type);
307+
});
308+
return action;
309+
};
310+
311+
action_desktop_ = make_action(proto::peer::SESSION_TYPE_DESKTOP);
312+
action_file_transfer_ = make_action(proto::peer::SESSION_TYPE_FILE_TRANSFER);
313+
action_text_chat_ = make_action(proto::peer::SESSION_TYPE_TEXT_CHAT);
298314
}
299315

300316
//--------------------------------------------------------------------------------------------------
@@ -332,7 +348,8 @@ QList<QPair<Tab::ActionRole, QList<QAction*>>> SystemInfoWindow::tabActionGroups
332348
{
333349
return {
334350
{ Tab::ActionRole::FILE, { ui->action_save, ui->action_print } },
335-
{ Tab::ActionRole::VIEW, { ui->action_refresh } }
351+
{ Tab::ActionRole::VIEW, { ui->action_refresh } },
352+
{ Tab::ActionRole::ACTION, { action_desktop_, action_file_transfer_, action_text_chat_ } }
336353
};
337354
}
338355

source/client/ui/sys_info/system_info_window.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ private slots:
6666
QHBoxLayout* layout_ = nullptr;
6767
QList<SysInfoWidget*> sys_info_widgets_;
6868
int current_widget_ = 0;
69+
QAction* action_desktop_ = nullptr;
70+
QAction* action_file_transfer_ = nullptr;
71+
QAction* action_text_chat_ = nullptr;
6972

7073
Q_DISABLE_COPY_MOVE(SystemInfoWindow)
7174
};

0 commit comments

Comments
 (0)