mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-19 10:32:02 -05:00
Palette editor improvements.
Added an "Insert after..." context menu entry so it is possible to add new entires to the end of the list when the scroll area is full. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3988 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
c3d1eb5cee
commit
feb47d5791
@ -169,6 +169,18 @@ namespace
|
|||||||
ui_.colour_table_widget->setItem (row, 0, item.release ());
|
ui_.colour_table_widget->setItem (row, 0, item.release ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void insert_new_item (int row, QColor const& default_colour)
|
||||||
|
{
|
||||||
|
// use the prior row colour as default if available
|
||||||
|
auto new_colour = QColorDialog::getColor (row > 0 ? colours_[row - 1] : default_colour, this);
|
||||||
|
if (new_colour.isValid ())
|
||||||
|
{
|
||||||
|
ui_.colour_table_widget->insertRow (row);
|
||||||
|
colours_.insert (row, new_colour);
|
||||||
|
insert_item (row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void context_menu (QPoint const& p)
|
void context_menu (QPoint const& p)
|
||||||
{
|
{
|
||||||
context_menu_.clear ();
|
context_menu_.clear ();
|
||||||
@ -188,21 +200,15 @@ namespace
|
|||||||
{
|
{
|
||||||
auto item = ui_.colour_table_widget->itemAt (menu_pos_);
|
auto item = ui_.colour_table_widget->itemAt (menu_pos_);
|
||||||
int row = item ? item->row () : colours_.size ();
|
int row = item ? item->row () : colours_.size ();
|
||||||
|
insert_new_item (row, QColor {0, 0, 0});
|
||||||
|
});
|
||||||
|
|
||||||
auto default_colour = QColor {0, 0, 0};
|
auto insert_after_action = context_menu_.addAction (tr ("Insert &after ..."));
|
||||||
if (row > 0)
|
connect (insert_after_action, &QAction::triggered, [this] ()
|
||||||
{
|
{
|
||||||
// use the prior row colour
|
auto item = ui_.colour_table_widget->itemAt (menu_pos_);
|
||||||
default_colour = colours_[row - 1];
|
int row = item ? item->row () + 1 : colours_.size ();
|
||||||
}
|
insert_new_item( row, QColor {255, 255, 255});
|
||||||
|
|
||||||
auto new_colour = QColorDialog::getColor (default_colour, this);
|
|
||||||
if (new_colour.isValid ())
|
|
||||||
{
|
|
||||||
ui_.colour_table_widget->insertRow (row);
|
|
||||||
colours_.insert (row, new_colour);
|
|
||||||
insert_item (row);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
menu_pos_ = p; // save for context menu action handlers
|
menu_pos_ = p; // save for context menu action handlers
|
||||||
|
Loading…
Reference in New Issue
Block a user