fix cm elevate button visibility of different conn type

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages 2022-12-04 18:47:02 +08:00
parent 9bbe236651
commit 5a7f610b59
4 changed files with 36 additions and 7 deletions

View File

@ -238,7 +238,7 @@ Widget buildConnectionCard(Client client) {
key: ValueKey(client.id), key: ValueKey(client.id),
children: [ children: [
_CmHeader(client: client), _CmHeader(client: client),
client.isFileTransfer || client.disconnected client.type_() != ClientType.remote || client.disconnected
? Offstage() ? Offstage()
: _PrivilegeBoard(client: client), : _PrivilegeBoard(client: client),
Expanded( Expanded(
@ -376,7 +376,7 @@ class _CmHeaderState extends State<_CmHeader>
), ),
), ),
Offstage( Offstage(
offstage: !client.authorized || client.isFileTransfer, offstage: !client.authorized || client.type_() != ClientType.remote,
child: IconButton( child: IconButton(
onPressed: () => checkClickTime( onPressed: () => checkClickTime(
client.id, () => gFFI.chatModel.toggleCMChatPage(client.id)), client.id, () => gFFI.chatModel.toggleCMChatPage(client.id)),
@ -510,7 +510,9 @@ class _CmControlPanel extends StatelessWidget {
buildAuthorized(BuildContext context) { buildAuthorized(BuildContext context) {
final bool canElevate = bind.cmCanElevate(); final bool canElevate = bind.cmCanElevate();
final model = Provider.of<ServerModel>(context); final model = Provider.of<ServerModel>(context);
final showElevation = canElevate && model.showElevation; final showElevation = canElevate &&
model.showElevation &&
client.type_() == ClientType.remote;
return Column( return Column(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
@ -560,7 +562,9 @@ class _CmControlPanel extends StatelessWidget {
buildUnAuthorized(BuildContext context) { buildUnAuthorized(BuildContext context) {
final bool canElevate = bind.cmCanElevate(); final bool canElevate = bind.cmCanElevate();
final model = Provider.of<ServerModel>(context); final model = Provider.of<ServerModel>(context);
final showElevation = canElevate && model.showElevation; final showElevation = canElevate &&
model.showElevation &&
client.type_() == ClientType.remote;
final showAccept = model.approveMode != 'password'; final showAccept = model.approveMode != 'password';
return Column( return Column(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,

View File

@ -581,10 +581,17 @@ class ServerModel with ChangeNotifier {
} }
} }
enum ClientType {
remote,
file,
portForward,
}
class Client { class Client {
int id = 0; // client connections inner count id int id = 0; // client connections inner count id
bool authorized = false; bool authorized = false;
bool isFileTransfer = false; bool isFileTransfer = false;
String portForward = "";
String name = ""; String name = "";
String peerId = ""; // peer user's id,show at app String peerId = ""; // peer user's id,show at app
bool keyboard = false; bool keyboard = false;
@ -604,6 +611,7 @@ class Client {
id = json['id']; id = json['id'];
authorized = json['authorized']; authorized = json['authorized'];
isFileTransfer = json['is_file_transfer']; isFileTransfer = json['is_file_transfer'];
portForward = json['port_forward'];
name = json['name']; name = json['name'];
peerId = json['peer_id']; peerId = json['peer_id'];
keyboard = json['keyboard']; keyboard = json['keyboard'];
@ -620,6 +628,7 @@ class Client {
data['id'] = id; data['id'] = id;
data['is_start'] = authorized; data['is_start'] = authorized;
data['is_file_transfer'] = isFileTransfer; data['is_file_transfer'] = isFileTransfer;
data['port_forward'] = portForward;
data['name'] = name; data['name'] = name;
data['peer_id'] = peerId; data['peer_id'] = peerId;
data['keyboard'] = keyboard; data['keyboard'] = keyboard;
@ -631,6 +640,16 @@ class Client {
data['disconnected'] = disconnected; data['disconnected'] = disconnected;
return data; return data;
} }
ClientType type_() {
if (isFileTransfer) {
return ClientType.file;
} else if (portForward.isNotEmpty) {
return ClientType.portForward;
} else {
return ClientType.remote;
}
}
} }
String getLoginDialogTag(int id) { String getLoginDialogTag(int id) {

View File

@ -29,7 +29,7 @@ class Body: Reactor.Component
}; };
var right_style = show_chat ? "" : "display: none"; var right_style = show_chat ? "" : "display: none";
var disconnected = c.disconnected; var disconnected = c.disconnected;
var show_elevation_btn = handler.can_elevate() && show_elevation; var show_elevation_btn = handler.can_elevate() && show_elevation && !c.is_file_transfer && c.port_forward.length == 0;
var show_accept_btn = handler.get_option('approve-mode') != 'password'; var show_accept_btn = handler.get_option('approve-mode') != 'password';
// below size:* is work around for Linux, it alreayd set in css, but not work, shit sciter // below size:* is work around for Linux, it alreayd set in css, but not work, shit sciter
return <div .content style="size:*"> return <div .content style="size:*">

View File

@ -200,7 +200,7 @@ impl<T: InvokeUiSession> Session<T> {
h265 = h265 && encoding_265; h265 = h265 && encoding_265;
return (h264, h265); return (h264, h265);
} }
#[allow(dead_code)] #[allow(unreachable_code)]
(false, false) (false, false)
} }
@ -1211,7 +1211,13 @@ impl<T: InvokeUiSession> Interface for Session<T> {
input_os_password(p, true, self.clone()); input_os_password(p, true, self.clone());
} }
let current = &pi.displays[pi.current_display as usize]; let current = &pi.displays[pi.current_display as usize];
self.set_display(current.x, current.y, current.width, current.height, current.cursor_embeded); self.set_display(
current.x,
current.y,
current.width,
current.height,
current.cursor_embeded,
);
} }
self.update_privacy_mode(); self.update_privacy_mode();
// Save recent peers, then push event to flutter. So flutter can refresh peer page. // Save recent peers, then push event to flutter. So flutter can refresh peer page.