Merge lp:~mcintire-evan/ubuntu-terminal-app/disable-copy into lp:~ubuntu-terminal-dev/ubuntu-terminal-app/reboot

Proposed by Evan McIntire
Status: Merged
Approved by: Niklas Wenzel
Approved revision: 170
Merged at revision: 171
Proposed branch: lp:~mcintire-evan/ubuntu-terminal-app/disable-copy
Merge into: lp:~ubuntu-terminal-dev/ubuntu-terminal-app/reboot
Diff against target: 60 lines (+13/-3)
3 files modified
src/app/qml/AlternateActionPopover.qml (+2/-1)
src/plugin/qmltermwidget/lib/TerminalDisplay.cpp (+7/-0)
src/plugin/qmltermwidget/lib/TerminalDisplay.h (+4/-2)
To merge this branch: bzr merge lp:~mcintire-evan/ubuntu-terminal-app/disable-copy
Reviewer Review Type Date Requested Status
Jenkins Bot continuous-integration Approve
Niklas Wenzel (community) Approve
Stefano Verzegnassi Approve
Review via email: mp+285287@code.launchpad.net

Commit message

Disable copy if selection is empty

Description of the change

Disable copy if selection is empty

To post a comment you must log in.
Revision history for this message
Evan McIntire (mcintire-evan) wrote :

As Stefano said[1], I do think we should avoid adding too much to the C++ code. Whenever we end up redoing the clipboard stuff we could maybe remove this and the isClipboardEmpty() functions?

There are a few bugs relating to improving the clipboard experience, maybe we could make a blueprint or something to organize all that and how we want to redo it?

[1] - https://code.launchpad.net/~mcintire-evan/ubuntu-terminal-app/disable-paste/+merge/283244/comments/725331

Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Stefano Verzegnassi (verzegnassi-stefano) wrote :

> As Stefano said[1], I do think we should avoid adding too much to the C++ code. Whenever we end
> up redoing the clipboard stuff we could maybe remove this and the isClipboardEmpty() functions?

I think we can keep them as long as they are pure Qt implementations.
I had a further look at the usage of Ubuntu.Components.Clipboard, in particular for uri type, which seems to be handled differently in Gnome Terminal.

e.g.
1) Open Nautilus
2) Choose a file from your home and copy it (Ctrl+C)
3) Open gnome-terminal and paste (Ctrl+Alt+V)
   RESULT: the object is pasted as "file:///home/<username>/<file_name+ext>"
4) Do the same with ubuntu-terminal-app
   RESULT: the object is pasted as "/home/<username>/<file_name+ext>"

Fortunately, the Ubuntu UITK implementation is just a wrapper around QClipboard, which is already used in QmlTermWidget, so we can go on with a pure Qt/C++ implementation with no many changes.

A different case is the drop of a file into the terminal window, which is something ubuntu-terminal-app does not handle yet.

This could be done through QML, although it would be better to do via C++, since all the mouse/keyb events are currently handled by the terminal widget itself.
In this case we would end up with a bigger change to the source code.

> There are a few bugs relating to improving the clipboard experience, maybe we could make a
> blueprint or something to organize all that and how we want to redo it?

Blueprints + bugs sounds as a good plan.

I believe we should review the code of the terminal plugin. I had a look some week ago, and only the console has been ported from QWidget to QtQuick (e.g. see the search functionalities, still QWidget-based).

As we have a list of things we need to improve, we can start planning the changes to the C++ sources, being sure we won't break the compatibility with QTermWidget or cool-retro-term.

I will try to get in touch with Filippo, since he's the author of the porting.

It could be useful to discuss of this somewhere else.
I know Niklas is quite busy in this period, and restoring the weekly meeting could be complicated.
What about moving our discussion on mails?

Revision history for this message
Stefano Verzegnassi (verzegnassi-stefano) wrote :

BTW, code looks good! Great work!

review: Approve
Revision history for this message
Evan McIntire (mcintire-evan) wrote :

Thanks! Mailing lists could work for me, I don't know where we do that though. I have some other questions/ideas, but those are better left for when we figure out mailing list stuff :)

Revision history for this message
Niklas Wenzel (nikwen) wrote :

Thank you for the patch! The code looks good to me and I assume Stefano tested it already.

However, I'm sorry that I am _that_ guy again. :p

For comments we usually put a whitespace after the two leading slashes. Additionally, we only put semi-colons after QML properties when there are two in the same line.

Again, sorry for that, but I think it makes sense to agree on a common code style. Nevertheless, good work! :)

review: Needs Fixing
Revision history for this message
Niklas Wenzel (nikwen) wrote :

Oh, and I'll set up an email to Alan regarding the mailing list thing. :)

Revision history for this message
Niklas Wenzel (nikwen) wrote :

Email sent. :)

Revision history for this message
Evan McIntire (mcintire-evan) wrote :

It's all good Niklas, let me fix that real quick :)

169. By Evan McIntire

Slight stlye changes

Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Niklas Wenzel (nikwen) wrote :

I should have made it a bit clearer what I've been referring to with the semicolons. :D

We do use semicolons for executions of commands, e.g. in JavaScript code blocks surrounded by {} and in other execution blocks like onTriggered or onClicked listeners.
We do not use semicolons for QML bindings, i.e. when a value is assigned to a property using a colon.

Examples for when we do use a semicolon:

onTriggered: {
    console.log("test");
    terminalPage.state = "SELECTION";
}

onTriggered: terminalPage.state = "SELECTION";

Examples for when we don't use semicolons:

width: units.gu(2)

text: i18n.tr("Select")

enabled: !terminal.isSelectionEmpty()

I hope that this has made it a little bit clearer. If not, please ask! ;)

Revision history for this message
Evan McIntire (mcintire-evan) wrote :

Alright, that makes total sense, thanks :)

170. By Evan McIntire

Small style change again

Revision history for this message
Niklas Wenzel (nikwen) wrote :

For my personal projects I also use a different code style but that's what the terminal app uses. ;)

Revision history for this message
Evan McIntire (mcintire-evan) wrote :

I also didn't know the code in there was JS, that's pretty cool!

Revision history for this message
Niklas Wenzel (nikwen) wrote :

Yes, it is. You'll really come to appreciate QML after a while.

Furthermore, thanks for fixing it. Let's get this merged now. Good job! :)

review: Approve
Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/app/qml/AlternateActionPopover.qml'
2--- src/app/qml/AlternateActionPopover.qml 2016-02-06 20:16:58 +0000
3+++ src/app/qml/AlternateActionPopover.qml 2016-02-08 22:27:23 +0000
4@@ -15,12 +15,13 @@
5 }
6 Action {
7 text: i18n.tr("Copy")
8+ enabled: !terminal.isSelectionEmpty()
9 onTriggered: terminal.copyClipboard();
10 }
11 Action {
12 text: i18n.tr("Paste")
13+ enabled: !terminal.isClipboardEmpty()
14 onTriggered: terminal.pasteClipboard();
15- enabled: !terminal.isClipboardEmpty();
16 }
17 }
18 }
19
20=== modified file 'src/plugin/qmltermwidget/lib/TerminalDisplay.cpp'
21--- src/plugin/qmltermwidget/lib/TerminalDisplay.cpp 2016-02-06 20:16:58 +0000
22+++ src/plugin/qmltermwidget/lib/TerminalDisplay.cpp 2016-02-08 22:27:23 +0000
23@@ -2570,11 +2570,18 @@
24 emitSelection(true,false);
25 }
26
27+// TODO: These 2 functions are not in the upstream LxQt version
28+// See https://code.launchpad.net/~mcintire-evan/ubuntu-terminal-app/disable-paste/+merge/283244/comments/725331
29 bool TerminalDisplay::isClipboardEmpty()
30 {
31 return QApplication::clipboard()->text().isEmpty();
32 }
33
34+bool TerminalDisplay::isSelectionEmpty()
35+{
36+ return _screenWindow->selectedText(_preserveLineBreaks).isEmpty();
37+}
38+
39 /* ------------------------------------------------------------------------- */
40 /* */
41 /* Keyboard */
42
43=== modified file 'src/plugin/qmltermwidget/lib/TerminalDisplay.h'
44--- src/plugin/qmltermwidget/lib/TerminalDisplay.h 2016-02-06 20:16:58 +0000
45+++ src/plugin/qmltermwidget/lib/TerminalDisplay.h 2016-02-08 22:27:23 +0000
46@@ -482,10 +482,12 @@
47 */
48 void pasteSelection();
49
50- /** Checks if the clipboard is empty
51- */
52+ /** Checks if the clipboard is empty */
53 bool isClipboardEmpty();
54
55+ /** Checks if the selection is empty */
56+ bool isSelectionEmpty();
57+
58 /**
59 * Changes whether the flow control warning box should be shown when the flow control
60 * stop key (Ctrl+S) are pressed.

Subscribers

People subscribed via source and target branches