Skip to content

Commit

Permalink
show copy button for all single fields
Browse files Browse the repository at this point in the history
  • Loading branch information
dpedu committed Mar 11, 2017
1 parent 2e5f3f1 commit ae3b948
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions item_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ class ItemView : public Gtk::Grid {
}

void processSingleField(const KeychainField& field) {
processSingleField(field.name, field.value, field.password);
processSingleField(field.name, field.value, field.password, true);
}

void processSingleField(std::string label, std::string value, bool conceal) {
void processSingleField(std::string label, std::string value, bool conceal, bool copy_button) {
auto my_index = row_index++;

auto label_widget = Gtk::manage(new Gtk::Label(label));
Expand All @@ -81,9 +81,9 @@ class ItemView : public Gtk::Grid {

if (conceal && !isTOTP)
value_widget->set_visibility(false);
attach(*value_widget, 1, my_index, conceal ? 1 : 3, 1);
attach(*value_widget, 1, my_index, conceal || copy_button ? 1 : 3, 1);

if (conceal) {
if (copy_button) {
auto copy_button = Gtk::manage(new Gtk::Button("_Copy", true));
copy_button->signal_clicked().connect([value_widget]() {
auto valueText = value_widget->get_text();
Expand All @@ -92,6 +92,9 @@ class ItemView : public Gtk::Grid {
clipboard->store();
});
attach(*copy_button, 2, my_index, 1, 1);
}

if (conceal) {
if (isTOTP) {
auto calculate_button = Gtk::manage(new Gtk::Button("_Calculate", true));
calculate_button->signal_clicked().connect([value, value_widget]() {
Expand Down

0 comments on commit ae3b948

Please sign in to comment.