mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-12-16 09:03:51 -05:00
fix permissions matrix GUI freeze
This commit is contained in:
parent
0dd1d1562a
commit
e1906a9819
1 changed files with 27 additions and 22 deletions
|
|
@ -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 */)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue