fix permissions matrix GUI freeze

This commit is contained in:
David Bears 2025-10-18 15:03:37 -04:00
parent 0dd1d1562a
commit e1906a9819
No known key found for this signature in database
GPG key ID: FB975E12C69F7177

View file

@ -250,7 +250,7 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *)
/* Fill in the background */ /* Fill in the background */
//_painter->fillRect(_rec, QBrush(BACK_COLOR)); //_painter->fillRect(_rec, QBrush(BACK_COLOR));
_painter->drawRect(_rec); _painter->drawRect(_rec);
if (Settings->getSheetName() == ":Standard_Dark"){ if (Settings->getSheetName() == ":Standard_Dark"){
brushColor = Qt::gray ; brushColor = Qt::gray ;
} else { } else {
@ -612,20 +612,24 @@ bool RSPermissionMatrixWidget::computeServiceAndPeer(int x,int y,uint32_t& servi
x -= matrix_start_x ; x -= matrix_start_x ;
y -= S*fMATRIX_START_Y ; y -= S*fMATRIX_START_Y ;
float fi = x / (S*fCOL_SIZE);
float fj = y / (S*fROW_SIZE);
int i = (int)fi;
int j = (int)fj;
const float icoFracX = fICON_SIZE_X/fCOL_SIZE;
const float icoFracY = fICON_SIZE_Y/fROW_SIZE;
if(x < 0 || x >= service_ids.size() * S*fCOL_SIZE) return false ; if(
if(y < 0 || y >= peer_ids.size() * S*fROW_SIZE) return false ; i < 0 || i >= service_ids.size() ||
j < 0 || j >= peer_ids.size() ||
if( (x % (int)(S*fCOL_SIZE)) < (S*fCOL_SIZE - S*fICON_SIZE_X)/2) return false ; std::fmod(fi + icoFracX/2 + .5f, 1.f) >= icoFracX ||
if( (x % (int)(S*fCOL_SIZE)) > (S*fCOL_SIZE + S*fICON_SIZE_X)/2) return false ; std::fmod(fj + icoFracY/2 + .5f, 1.f) >= icoFracY
) return false;
if( (y % (int)(S*fROW_SIZE)) < (S*fROW_SIZE - S*fICON_SIZE_Y)/2) return false ;
if( (y % (int)(S*fROW_SIZE)) > (S*fROW_SIZE + S*fICON_SIZE_Y)/2) return false ;
// 2 - find which widget, by looking into the service perm matrix // 2 - find which widget, by looking into the service perm matrix
service_id = service_ids[x / (int)(S*fCOL_SIZE)] ; service_id = service_ids[i];
peer_id = peer_ids[y / (int)(S*fCOL_SIZE)] ; peer_id = peer_ids[j];
return true ; return true ;
} }
@ -636,22 +640,23 @@ bool RSPermissionMatrixWidget::computeServiceGlobalSwitch(int x,int y,uint32_t&
float S = QFontMetricsF(font()).height(); float S = QFontMetricsF(font()).height();
x -= matrix_start_x ; x -= matrix_start_x;
y -= S*fMATRIX_START_Y ; y -= S*fMATRIX_START_Y;
float fi = x / (S*fCOL_SIZE);
int i = (int)fi;
const float icoFracX = fICON_SIZE_X/fCOL_SIZE;
if(x < 0 || x >= service_ids.size() * S*fCOL_SIZE) return false ; if(
i < 0 || i >= service_ids.size() ||
if( (x % (int)(S*fCOL_SIZE)) < (S*fCOL_SIZE - S*fICON_SIZE_X)/2) return false ; y < -S*fROW_SIZE || y > 0 ||
if( (x % (int)(S*fCOL_SIZE)) > (S*fCOL_SIZE + S*fICON_SIZE_X)/2) return false ; std::fmod(fi + icoFracX/2 + .5f, 1.f) >= icoFracX
) return false;
if( y < -S*fROW_SIZE ) return false ;
if( y > 0 ) return false ;
// 2 - find which widget, by looking into the service perm matrix // 2 - find which widget, by looking into the service perm matrix
service_id = service_ids[x / (int)(S*fCOL_SIZE)] ; service_id = service_ids[i];
return true ; return true;
} }
void RSPermissionMatrixWidget::defaultPermissionSwitched(uint32_t /* ServiceId */,bool /* b */) void RSPermissionMatrixWidget::defaultPermissionSwitched(uint32_t /* ServiceId */,bool /* b */)