custom context menus (including tray menu for windows) done

This commit is contained in:
John Preston
2014-09-28 19:47:30 -07:00
parent a4e9dadc2d
commit 0d85f91453
28 changed files with 375 additions and 126 deletions
+16 -20
View File
@@ -24,21 +24,13 @@ Button::Button(QWidget *parent) : TWidget(parent), _state(StateNone), _acceptBot
void Button::leaveEvent(QEvent *e) {
if (_state & StateDown) return;
if (_state & StateOver) {
int oldState = _state;
_state &= ~StateOver;
emit stateChanged(oldState, ButtonByHover);
}
setOver(false, ButtonByHover);
setMouseTracking(false);
return TWidget::leaveEvent(e);
}
void Button::enterEvent(QEvent *e) {
if (!(_state & StateOver)) {
int oldState = _state;
_state |= StateOver;
emit stateChanged(oldState, ButtonByHover);
}
setOver(true, ButtonByHover);
setMouseTracking(true);
return TWidget::enterEvent(e);
}
@@ -64,17 +56,9 @@ void Button::mousePressEvent(QMouseEvent *e) {
void Button::mouseMoveEvent(QMouseEvent *e) {
if (rect().contains(e->pos())) {
if (!(_state & StateOver)) {
int oldState = _state;
_state |= StateOver;
emit stateChanged(oldState, ButtonByHover);
}
setOver(true, ButtonByHover);
} else {
if (_state & StateOver) {
int oldState = _state;
_state &= ~StateOver;
emit stateChanged(oldState, ButtonByHover);
}
setOver(false, ButtonByHover);
}
}
@@ -91,6 +75,18 @@ void Button::mouseReleaseEvent(QMouseEvent *e) {
}
}
void Button::setOver(bool over, ButtonStateChangeSource source) {
if (over && !(_state & StateOver)) {
int oldState = _state;
_state |= StateOver;
emit stateChanged(oldState, source);
} else if (!over && (_state & StateOver)) {
int oldState = _state;
_state &= ~StateOver;
emit stateChanged(oldState, source);
}
}
void Button::setDisabled(bool disabled) {
int oldState = _state;
if (disabled && !(_state & StateDisabled)) {