Ignore scrolling for connection map combo boxes
This commit is contained in:
parent
7c73161ad0
commit
63b77a1fdc
4 changed files with 14 additions and 2 deletions
|
@ -16,9 +16,12 @@ public:
|
|||
void setClearButtonEnabled(bool enabled);
|
||||
void setEditable(bool editable);
|
||||
void setLineEdit(QLineEdit *edit);
|
||||
void setFocusedScrollingEnabled(bool enabled);
|
||||
|
||||
private:
|
||||
void setItem(int index, const QString &text);
|
||||
|
||||
bool focusedScrollingEnabled = true;
|
||||
};
|
||||
|
||||
#endif // NOSCROLLCOMBOBOX_H
|
||||
|
|
|
@ -1059,9 +1059,11 @@ bool MainWindow::setProjectUI() {
|
|||
ui->comboBox_DiveMap->clear();
|
||||
ui->comboBox_DiveMap->addItems(project->mapNames);
|
||||
ui->comboBox_DiveMap->setClearButtonEnabled(true);
|
||||
ui->comboBox_DiveMap->setFocusedScrollingEnabled(false);
|
||||
ui->comboBox_EmergeMap->clear();
|
||||
ui->comboBox_EmergeMap->addItems(project->mapNames);
|
||||
ui->comboBox_EmergeMap->setClearButtonEnabled(true);
|
||||
ui->comboBox_EmergeMap->setFocusedScrollingEnabled(false);
|
||||
|
||||
sortMapList();
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ ConnectionsListItem::ConnectionsListItem(QWidget *parent, MapConnection * connec
|
|||
|
||||
ui->comboBox_Map->setMinimumContentsLength(6);
|
||||
ui->comboBox_Map->addItems(mapNames);
|
||||
ui->comboBox_Map->setFocusedScrollingEnabled(false); // Scrolling could cause rapid changes to many different maps
|
||||
|
||||
ui->spinBox_Offset->setMinimum(INT_MIN);
|
||||
ui->spinBox_Offset->setMaximum(INT_MAX);
|
||||
|
|
|
@ -37,11 +37,17 @@ void NoScrollComboBox::setLineEdit(QLineEdit *edit) {
|
|||
|
||||
void NoScrollComboBox::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
// Only allow scrolling to modify contents when it explicitly has focus.
|
||||
if (hasFocus())
|
||||
// By default NoScrollComboBoxes will allow scrolling to modify its contents only when it explicitly has focus.
|
||||
// If focusedScrollingEnabled is false it won't allow scrolling even with focus.
|
||||
if (this->focusedScrollingEnabled && hasFocus())
|
||||
QComboBox::wheelEvent(event);
|
||||
}
|
||||
|
||||
void NoScrollComboBox::setFocusedScrollingEnabled(bool enabled)
|
||||
{
|
||||
this->focusedScrollingEnabled = enabled;
|
||||
}
|
||||
|
||||
void NoScrollComboBox::setItem(int index, const QString &text)
|
||||
{
|
||||
if (index >= 0) {
|
||||
|
|
Loading…
Reference in a new issue