Skip to content

Commit

Permalink
Add copy commands to clipboard button (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean28518 committed Aug 4, 2024
1 parent 6d7af53 commit 8323ab4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/l10n/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@
"startLastBootedEntry": "Starte den zuletzt gebooteten Eintrag",
"save": "Speichern",
"distribution_selection": "Distributions-Auswahl",
"copyCommands": "Befehle kopieren",
"@helloWorld": {
"placeholders": {},
"description": "",
Expand Down
1 change: 1 addition & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@
"startLastBootedEntry": "Start the last booted entry",
"save": "Save",
"distribution_selection": "Distribution selection",
"copyCommands": "Copy commands",
"@helloWorld": {
"placeholders": {},
"description": "The conventional newborn programmer greeting",
Expand Down
1 change: 1 addition & 0 deletions lib/l10n/app_it.arb
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@
"diskUsage": "Utilizzo del disco",
"settingUpFirewall": "Configura firewall...",
"distribution_selection": "Selezione della distribuzione",
"copyCommands": "Copia comandi",
"@helloWorld": {
"placeholders": {},
"description": "Il saluto convenzionale del programmatore appena nato",
Expand Down
15 changes: 15 additions & 0 deletions lib/layouts/run_command_queue.dart
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,21 @@ class _CommandTableState extends State<CommandTable> {
child: MintYTable(data: widget.tableData),
)
: Container(),
showTable
? MintYButton(
text: Text(AppLocalizations.of(context)!.copyCommands,
style: MintY.heading4),
onPressed: () {
// Get all commands as a string
String commands = "";
// Skip first row
for (int i = 1; i < widget.tableData.length; i++) {
commands += "${widget.tableData[i][0]}\n";
}
Linux.copyToClipboard(commands);
},
)
: Container(),
],
);
}
Expand Down
5 changes: 5 additions & 0 deletions lib/services/linux.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:linux_assistant/enums/browsers.dart';
import 'package:linux_assistant/enums/desktops.dart';
import 'package:linux_assistant/enums/distros.dart';
Expand Down Expand Up @@ -2887,4 +2888,8 @@ class Linux {
));
}
}

static void copyToClipboard(String text) {
Clipboard.setData(ClipboardData(text: text));
}
}

0 comments on commit 8323ab4

Please sign in to comment.