WindowMenu::WindowMenu(QWidget *parent) : QMenu(QString::fromUtf8("&Window"), parent) { pMinimize_ = addAction(QString::fromUtf8("Minimize")); pMinimize_->setShortcut(QKeySequence(QString::fromAscii("Meta+M"))); connect(pMinimize_, SIGNAL(triggered()), this, SLOT(onMinimize())); pZoom_ = addAction(QString::fromUtf8("Zoom")); connect(pZoom_, SIGNAL(triggered()), this, SLOT(onZoom())); addSeparator(); pWindowPlaceholder_ = addAction(QString::fromAscii("__PLACEHOLDER__")); pWindowPlaceholder_->setVisible(false); addSeparator(); pBringAllToFront_ = addAction(QString::fromUtf8("Bring All to Front")); connect(pBringAllToFront_, SIGNAL(triggered()), this, SLOT(onBringAllToFront())); connect(this, SIGNAL(aboutToShow()), this, SLOT(onAboutToShow())); connect(this, SIGNAL(aboutToHide()), this, SLOT(onAboutToHide())); }
void SDLWindow::handleWindowEvent() { switch (m_sdlEvent.window.event) { case SDL_WINDOWEVENT_MOVED: onMove(m_sdlEvent.window.data1, m_sdlEvent.window.data2); break; case SDL_WINDOWEVENT_RESIZED: case SDL_WINDOWEVENT_SIZE_CHANGED: onResize(m_sdlEvent.window.data1, m_sdlEvent.window.data2); break; case SDL_WINDOWEVENT_MINIMIZED: onMinimize(); break; case SDL_WINDOWEVENT_MAXIMIZED: onMaximize(); break; case SDL_WINDOWEVENT_RESTORED: onRestore(); break; case SDL_WINDOWEVENT_SHOWN: onDisplay(); break; default: break; } }
//METHODS void Event::onEvent(SDL_Event* event) { switch(event->type) { case SDL_ACTIVEEVENT: { switch (event->active.state) { case SDL_APPMOUSEFOCUS: { if (event->active.gain) onMouseFocus(); else onMouseBlur(); break; } case SDL_APPINPUTFOCUS: { if (event->active.gain) onInputFocus(); else onInputBlur(); break; } case SDL_APPACTIVE: { if (event->active.gain) onRestore(); else onMinimize(); break; } } break; } case SDL_KEYDOWN: { onKeyDown(event->key.keysym.sym, event->key.keysym.mod, event->key.keysym.unicode); break; } case SDL_KEYUP: { onKeyUp(event->key.keysym.sym, event->key.keysym.mod, event->key.keysym.unicode); break; } case SDL_MOUSEMOTION: { onMouseMove(event->motion.x, event->motion.y, event->motion.xrel, event->motion.yrel, (event->motion.state & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0, (event->motion.state & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0, (event->motion.state & SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0); break; } case SDL_MOUSEBUTTONDOWN: { switch(event->button.button) { case SDL_BUTTON_LEFT: { onLButtonDown(event->button.x, event->button.y); break; } case SDL_BUTTON_RIGHT: { onRButtonDown(event->button.x, event->button.y); break; } case SDL_BUTTON_MIDDLE: { onMButtonDown(event->button.x, event->button.y); break; } } break; } case SDL_MOUSEBUTTONUP: { switch(event->button.button) { case SDL_BUTTON_LEFT: { onLButtonUp(event->button.x, event->button.y); break; } case SDL_BUTTON_RIGHT: { onRButtonUp(event->button.x, event->button.y); break; } case SDL_BUTTON_MIDDLE: { onMButtonUp(event->button.x, event->button.y); break; } } break; } case SDL_JOYAXISMOTION: { onJoyAxis(event->jaxis.which, event->jaxis.axis, event->jaxis.value); break; } case SDL_JOYBALLMOTION: { onJoyBall(event->jball.which, event->jball.ball, event->jball.xrel, event->jball.yrel); break; } case SDL_JOYHATMOTION: { onJoyHat(event->jhat.which, event->jhat.hat, event->jhat.value); break; } case SDL_JOYBUTTONDOWN: { onJoyButtonDown(event->jbutton.which, event->jbutton.button); break; } case SDL_JOYBUTTONUP: { onJoyButtonUp(event->jbutton.which, event->jbutton.button); break; } case SDL_QUIT: { onExit(); break; } case SDL_SYSWMEVENT: { //Ignore break; } case SDL_VIDEORESIZE: { onResize(event->resize.w, event->resize.h); break; } case SDL_VIDEOEXPOSE: { onExpose(); break; } default: { onUser(event->user.type, event->user.code, event->user.data1, event->user.data2); break; } } }
void SDL2Window::tick() { SDL_Event event; while(SDL_PollEvent(&event)) { switch(event.type) { case SDL_WINDOWEVENT: { switch(event.window.event) { case SDL_WINDOWEVENT_SHOWN: onShow(true); break; case SDL_WINDOWEVENT_HIDDEN: onShow(false); break; case SDL_WINDOWEVENT_EXPOSED: onPaint(); break; case SDL_WINDOWEVENT_MINIMIZED: onMinimize(); break; case SDL_WINDOWEVENT_MAXIMIZED: onMaximize(); break; case SDL_WINDOWEVENT_RESTORED: onRestore(); break; case SDL_WINDOWEVENT_FOCUS_GAINED: onFocus(true); break; case SDL_WINDOWEVENT_FOCUS_LOST: onFocus(false); break; case SDL_WINDOWEVENT_MOVED: { onMove(event.window.data1, event.window.data2); break; } case SDL_WINDOWEVENT_SIZE_CHANGED: { Vec2i newSize(event.window.data1, event.window.data2); if(newSize != m_size && !m_fullscreen) { m_renderer->beforeResize(false); updateSize(); } else { // SDL regrettably sends resize events when a fullscreen window // is minimized - we'll have none of that! } break; } case SDL_WINDOWEVENT_CLOSE: { // The user has requested to close a single window // TODO we only support one main window for now break; } } break; } case SDL_QUIT: { // The user has requested to close the whole program // TODO onDestroy() fits SDL_WINDOWEVENT_CLOSE better, but SDL captures Ctrl+C // evenst and *only* sends the SDL_QUIT event for them while normal close // generates *both* SDL_WINDOWEVENT_CLOSE and SDL_QUIT onDestroy(); return; // abort event loop! } } if(m_input) { m_input->onEvent(event); } } if(!m_renderer->isInitialized()) { updateSize(); m_renderer->afterResize(); m_renderer->SetViewport(Rect(m_size.x, m_size.y)); } }
void Ui::VideoPanelHeader::_onMinimize() { emit onMinimize(); }
/// event handlers void Module::onEvent(const SDL_Event& inEvent) { switch (inEvent.type) { case SDL_ACTIVEEVENT: { switch (inEvent.active.state) { case SDL_APPMOUSEFOCUS: { if (inEvent.active.gain) onMouseFocus(); else onMouseBlur(); break; } case SDL_APPINPUTFOCUS: { if (inEvent.active.gain) onInputFocus(); else onInputBlur(); break; } case SDL_APPACTIVE: { if (inEvent.active.gain) onRestore(); else onMinimize(); break; } } break; } case SDL_KEYDOWN: { onKeyDown(inEvent.key.keysym.sym, inEvent.key.keysym.mod, inEvent.key.keysym.unicode); break; } case SDL_KEYUP: { onKeyUp(inEvent.key.keysym.sym, inEvent.key.keysym.mod, inEvent.key.keysym.unicode); break; } case SDL_MOUSEMOTION: { onMouseMove(inEvent.motion.x, inEvent.motion.y, inEvent.motion.xrel, inEvent.motion.yrel, inEvent.motion.state & SDL_BUTTON(SDL_BUTTON_LEFT), inEvent.motion.state & SDL_BUTTON(SDL_BUTTON_RIGHT), inEvent.motion.state & SDL_BUTTON(SDL_BUTTON_MIDDLE)); break; } case SDL_MOUSEBUTTONDOWN: { switch (inEvent.button.button) { case SDL_BUTTON_LEFT: { onLButtonDown(inEvent.button.x, inEvent.button.y); break; } case SDL_BUTTON_RIGHT: { onRButtonDown(inEvent.button.x, inEvent.button.y); break; } case SDL_BUTTON_MIDDLE: { onMButtonDown(inEvent.button.x, inEvent.button.y); break; } } break; } case SDL_MOUSEBUTTONUP: { switch (inEvent.button.button) { case SDL_BUTTON_LEFT: { onLButtonUp(inEvent.button.x, inEvent.button.y); break; } case SDL_BUTTON_RIGHT: { onRButtonUp(inEvent.button.x, inEvent.button.y); break; } case SDL_BUTTON_MIDDLE: { onMButtonUp(inEvent.button.x, inEvent.button.y); break; } case SDL_BUTTON_WHEELUP: { onMouseWheel(true, false); break; } case SDL_BUTTON_WHEELDOWN: { onMouseWheel(false, true); break; } } break; } case SDL_JOYAXISMOTION: { onJoyAxis(inEvent.jaxis.which, inEvent.jaxis.axis, inEvent.jaxis.value); break; } case SDL_JOYBALLMOTION: { onJoyBall(inEvent.jball.which, inEvent.jball.ball, inEvent.jball.xrel, inEvent.jball.yrel); break; } case SDL_JOYHATMOTION: { onJoyHat(inEvent.jhat.which, inEvent.jhat.hat, inEvent.jhat.value); break; } case SDL_JOYBUTTONDOWN: { onJoyButtonDown(inEvent.jbutton.which, inEvent.jbutton.button); break; } case SDL_JOYBUTTONUP: { onJoyButtonUp(inEvent.jbutton.which, inEvent.jbutton.button); break; } case SDL_QUIT: { onExit(); break; } case SDL_SYSWMEVENT: { break; } case SDL_VIDEORESIZE: { onResize(inEvent.resize.w, inEvent.resize.h); break; } case SDL_VIDEOEXPOSE: { onExpose(); break; } default: { onUser(inEvent.user.type, inEvent.user.code, inEvent.user.data1, inEvent.user.data2); break; } } }
void SDLWindow::tick() { SDL_Event event; while(SDL_PollEvent(&event)) { switch(event.type) { case SDL_ACTIVEEVENT: { if(event.active.state & SDL_APPINPUTFOCUS) { // ignored } if(event.active.state & SDL_APPACTIVE) { if(event.active.gain) { onRestore(); } else { onMinimize(); } } if(input != NULL && (event.active.state & SDL_APPMOUSEFOCUS)) { input->onInputEvent(event); } break; } case SDL_KEYDOWN: // For some reason, release notes from SDL 1.2.12 says a SDL_QUIT message // should be sent when Command+Q is pressed on Mac OS or ALT-F4 on other platforms // but it doesn't look like it's working as expected... #if ARX_PLATFORM == ARX_PLATFORM_MACOSX if(event.key.keysym.sym == SDLK_q && (event.key.keysym.mod & KMOD_META) != KMOD_NONE) { #else if(event.key.keysym.sym == SDLK_F4 && (event.key.keysym.mod & KMOD_ALT) != KMOD_NONE) { #endif onDestroy(); break; } #if ARX_PLATFORM != ARX_PLATFORM_WIN32 // The SDL X11 backend always grabs all keys when in fullscreen mode, // ufortunately breaking window manager shortcuts. // At least provide users with a way to switch to other windows. if(event.key.keysym.sym == SDLK_TAB && (event.key.keysym.mod & KMOD_ALT) != KMOD_NONE) { SDL_WM_IconifyWindow(); } #endif case SDL_KEYUP: case SDL_MOUSEMOTION: case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: case SDL_JOYAXISMOTION: case SDL_JOYBALLMOTION: case SDL_JOYHATMOTION: case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONUP: { if(input) { input->onInputEvent(event); } break; } case SDL_QUIT: { onDestroy(); break; } case SDL_VIDEORESIZE: { Vec2i newSize(event.resize.w, event.resize.h); if(newSize != size_ && !isFullscreen_) { setMode(DisplayMode(newSize, depth_), false); updateSize(false); } break; } case SDL_VIDEOEXPOSE: { onPaint(); break; } } } } Vec2i SDLWindow::getCursorPosition() const { int cursorPosX, cursorPosY; SDL_GetMouseState(&cursorPosX, &cursorPosY); return Vec2i(cursorPosX, cursorPosY); }
void SDL2Window::tick() { SDL_Event event; while(SDL_PollEvent(&event)) { switch(event.type) { case SDL_WINDOWEVENT: { switch(event.window.event) { case SDL_WINDOWEVENT_SHOWN: onShow(true); break; case SDL_WINDOWEVENT_HIDDEN: onShow(false); break; case SDL_WINDOWEVENT_EXPOSED: onPaint(); break; case SDL_WINDOWEVENT_MINIMIZED: onMinimize(); break; case SDL_WINDOWEVENT_MAXIMIZED: onMaximize(); break; case SDL_WINDOWEVENT_RESTORED: onRestore(); break; case SDL_WINDOWEVENT_FOCUS_GAINED: onFocus(true); break; case SDL_WINDOWEVENT_FOCUS_LOST: onFocus(false); break; case SDL_WINDOWEVENT_MOVED: { onMove(event.window.data1, event.window.data2); break; } case SDL_WINDOWEVENT_SIZE_CHANGED: { Vec2i newSize(event.window.data1, event.window.data2); if(newSize != m_size && !m_fullscreen) { m_renderer->beforeResize(false); updateSize(); } else { // SDL regrettably sends resize events when a fullscreen window // is minimized - we'll have none of that! } break; } case SDL_WINDOWEVENT_CLOSE: { // The user has requested to close a single window // TODO we only support one main window for now break; } } break; } #if ARX_PLATFORM == ARX_PLATFORM_WIN32 case SDL_KEYDOWN: { // SDL2 is still eating our ALT+F4 under windows... // See bug report here: https://bugzilla.libsdl.org/show_bug.cgi?id=1555 if(event.key.keysym.sym == SDLK_F4 && (event.key.keysym.mod & KMOD_ALT) != KMOD_NONE) { SDL_Event quitevent; quitevent.type = SDL_QUIT; SDL_PushEvent(&quitevent); } break; } #endif case SDL_QUIT: { // The user has requested to close the whole program // TODO onDestroy() fits SDL_WINDOWEVENT_CLOSE better, but SDL captures Ctrl+C // evenst and *only* sends the SDL_QUIT event for them while normal close // generates *both* SDL_WINDOWEVENT_CLOSE and SDL_QUIT onDestroy(); return; // abort event loop! } } if(m_input) { m_input->onEvent(event); } } if(!m_renderer->isInitialized()) { updateSize(); m_renderer->afterResize(); m_renderer->SetViewport(Rect(m_size.x, m_size.y)); } }
QSkinDialog::QSkinDialog(bool sizable, bool closable, bool mainDialog, bool preview, QWidget* parent) : QDialog(parent), ui(new Ui::QSkinDialog) { ui->setupUi(this); maximized = false; minimized = false; movable = false; moving = false; dialogSizable = sizable; dialogClosable = closable; dialogPreview = preview; isMainDialog = mainDialog; sizableTopLeft = false; sizableLeft = false; sizableBottomLeft = false; sizableBottom = false; sizableTopRight = false; sizableRight = false; sizableBottomRight = false; systemMenu = new QMenu(this); systemRestoreAction = new QAction(tr("Restore"), this); systemRestoreAction->setIcon(style()->standardIcon(QStyle::SP_TitleBarNormalButton)); systemRestoreAction->setEnabled(false); systemMenu->addAction(systemRestoreAction); systemMinimizeAction = new QAction(tr("Minimize"), this); systemMinimizeAction->setIcon(style()->standardIcon(QStyle::SP_TitleBarMinButton)); systemMenu->addAction(systemMinimizeAction); systemMinimizeAction->setEnabled(dialogSizable); systemMaximizeAction = new QAction(tr("Maximize"), this); systemMaximizeAction->setIcon(style()->standardIcon(QStyle::SP_TitleBarMaxButton)); systemMenu->addAction(systemMaximizeAction); systemMaximizeAction->setEnabled(dialogSizable); systemMenu->addSeparator(); systemCloseAction = new QAction(tr("Close"), this); systemCloseAction->setIcon(style()->standardIcon(QStyle::SP_TitleBarCloseButton)); systemCloseAction->setShortcut(QKeySequence::Close); systemCloseAction->setEnabled(dialogClosable); systemMenu->addAction(systemCloseAction); // We are using our own frame of course instead of the system frame if(!parent == 0) { this->setWindowFlags(Qt::FramelessWindowHint | Qt::Window); } else { this->setWindowFlags(Qt::FramelessWindowHint); } // To enable alpha blending and transparency in the frame setAttribute(Qt::WA_TranslucentBackground); setAttribute(Qt::WA_StaticContents); this->setMaximumSize(QApplication::desktop()->availableGeometry(this).width(), QApplication::desktop()->availableGeometry(this).height()); ui->minimizeButton->setEnabled(dialogSizable); ui->maximizeButton->setEnabled(dialogSizable); ui->closeButton->setEnabled(dialogClosable); if(!dialogSizable) { ui->windowFrameTopLeft->setCursor(QCursor(Qt::ArrowCursor)); ui->windowFrameLeft->setCursor(QCursor(Qt::ArrowCursor)); ui->windowFrameBottomLeft->setCursor(QCursor(Qt::ArrowCursor)); ui->windowFrameTop->setCursor(QCursor(Qt::ArrowCursor)); ui->windowFrameBottom->setCursor(QCursor(Qt::ArrowCursor)); ui->windowFrameTopRight->setCursor(QCursor(Qt::ArrowCursor)); ui->windowFrameRight->setCursor(QCursor(Qt::ArrowCursor)); ui->windowFrameBottomRight->setCursor(QCursor(Qt::ArrowCursor)); } connect(systemRestoreAction, SIGNAL(triggered()), this, SLOT(onMaximize())); connect(systemMaximizeAction, SIGNAL(triggered()), this, SLOT(onMaximize())); connect(systemMinimizeAction, SIGNAL(triggered()), this, SLOT(onMinimize())); connect(systemCloseAction, SIGNAL(triggered()), this, SLOT(onClose())); connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(onClose())); connect(ui->minimizeButton, SIGNAL(clicked()), this, SLOT(onMinimize())); connect(ui->maximizeButton, SIGNAL(clicked()), this, SLOT(onMaximize())); connect(&skinSettings, SIGNAL(skinChanged()), this, SLOT(skinChangeEvent())); if(quazaaSettings.Skin.File.isEmpty()) { quazaaSettings.loadSkinSettings(); } skinSettings.loadSkin(quazaaSettings.Skin.File); quazaaSettings.saveSkinSettings(); // Load the previously set skin if(!dialogPreview) { if(isMainDialog) { ui->windowFrameTopLeft->setStyleSheet(skinSettings.windowFrameTopLeftStyleSheet); ui->windowFrameLeft->setStyleSheet(skinSettings.windowFrameLeftStyleSheet); ui->windowFrameBottomLeft->setStyleSheet(skinSettings.windowFrameBottomLeftStyleSheet); ui->windowFrameTop->setStyleSheet(skinSettings.windowFrameTopStyleSheet); ui->windowFrameBottom->setStyleSheet(skinSettings.windowFrameBottomStyleSheet); ui->windowFrameTopRight->setStyleSheet(skinSettings.windowFrameTopRightStyleSheet); ui->windowFrameRight->setStyleSheet(skinSettings.windowFrameRightStyleSheet); ui->windowFrameBottomRight->setStyleSheet(skinSettings.windowFrameBottomRightStyleSheet); ui->titlebarButtonsFrame->setStyleSheet(skinSettings.titlebarButtonsFrameStyleSheet); ui->minimizeButton->setStyleSheet(skinSettings.minimizeButtonStyleSheet); ui->maximizeButton->setStyleSheet(skinSettings.maximizeButtonStyleSheet); ui->closeButton->setStyleSheet(skinSettings.closeButtonStyleSheet); ui->windowFrameTopSpacer->setStyleSheet(skinSettings.windowFrameTopSpacerStyleSheet); ui->windowText->setStyleSheet(skinSettings.windowTextStyleSheet); ui->windowIconFrame->setStyleSheet(skinSettings.windowIconFrameStyleSheet); ui->windowIcon->setVisible(skinSettings.windowIconVisible); quazaaSettings.loadSkinWindowSettings(this); } else { ui->windowFrameTopLeft->setStyleSheet(skinSettings.childWindowFrameTopLeftStyleSheet); ui->windowFrameLeft->setStyleSheet(skinSettings.childWindowFrameLeftStyleSheet); ui->windowFrameBottomLeft->setStyleSheet(skinSettings.childWindowFrameBottomLeftStyleSheet); ui->windowFrameTop->setStyleSheet(skinSettings.childWindowFrameTopStyleSheet); ui->windowFrameBottom->setStyleSheet(skinSettings.childWindowFrameBottomStyleSheet); ui->windowFrameTopRight->setStyleSheet(skinSettings.childWindowFrameTopRightStyleSheet); ui->windowFrameRight->setStyleSheet(skinSettings.childWindowFrameRightStyleSheet); ui->windowFrameBottomRight->setStyleSheet(skinSettings.childWindowFrameBottomRightStyleSheet); ui->titlebarButtonsFrame->setStyleSheet(skinSettings.childTitlebarButtonsFrameStyleSheet); ui->minimizeButton->setStyleSheet(skinSettings.childMinimizeButtonStyleSheet); ui->maximizeButton->setStyleSheet(skinSettings.childMaximizeButtonStyleSheet); ui->closeButton->setStyleSheet(skinSettings.childCloseButtonStyleSheet); ui->windowFrameTopSpacer->setStyleSheet(skinSettings.childWindowFrameTopSpacerStyleSheet); ui->windowText->setStyleSheet(skinSettings.childWindowTextStyleSheet); ui->windowIconFrame->setStyleSheet(skinSettings.childWindowIconFrameStyleSheet); ui->windowIcon->setVisible(skinSettings.childWindowIconVisible); } } }
acDockWidgetTitlebar::acDockWidgetTitlebar(QWidget *parent) : parent(parent) { QString PushButtonStyle("QPushButton {border:none; margin: 0px; padding: 0px } QPushButton:hover {border:1px solid black}"); QPalette Pal(palette()); Pal.setColor(QPalette::Background, Qt::lightGray); setAutoFillBackground(true); setPalette(Pal); setMaximumHeight(20); m_close = false; m_parent = parent; // Create a close button and set its icon to that of the OS m_ToolBarIcon = new QIcon(":/CompressonatorGUI/Images/settings.png"); m_buttonToolBar = new QPushButton(this); m_buttonToolBar->setIcon(*m_ToolBarIcon); m_buttonToolBar->setStyleSheet(PushButtonStyle); m_buttonToolBar->setToolTip("Show Tool Bar"); m_buttonToolBarEnabled = true; // Get the OS close button icon QStyle*style = qApp->style(); QIcon minimizeIcon = style->standardIcon(QStyle::SP_TitleBarMinButton); // Create a maximize button and set its icon to that of the OS m_buttonMinimize = new QPushButton(this); m_buttonMinimize->setIcon(minimizeIcon); m_buttonMinimize->setStyleSheet(PushButtonStyle); m_buttonMinimize->setToolTip("Minimize Window"); QIcon maximizeIcon = style->standardIcon(QStyle::SP_TitleBarMaxButton); // Create a maximize button and set its icon to that of the OS m_buttonMaximize = new QPushButton(this); m_buttonMaximize->setIcon(maximizeIcon); m_buttonMaximize->setStyleSheet(PushButtonStyle); m_buttonMaximize->setToolTip("Maximize Window"); QIcon normalIcon = style->standardIcon(QStyle::SP_TitleBarNormalButton); // Create a maximize button and set its icon to that of the OS m_buttonNormal = new QPushButton(this); m_buttonNormal->setIcon(normalIcon); m_buttonNormal->setStyleSheet(PushButtonStyle); m_buttonNormal->setToolTip("Normal Window"); m_buttonNormal->hide(); QIcon closeIcon = style->standardIcon(QStyle::SP_TitleBarCloseButton); // Create a close button and set its icon to that of the OS m_buttonClose = new QPushButton(this); //m_buttonClose->setIcon(QIcon(":/CompressonatorGUI/Images/cxClose.png")); m_buttonClose->setIcon(closeIcon); m_buttonClose->setStyleSheet(PushButtonStyle); m_buttonClose->setToolTip("Close Window"); m_ButtonCloseEnabled = true; // Reserve a label for the Titlebar m_label = new QLabel("",this); // Set a layout for the new label and pushbutton m_layout = new QHBoxLayout(this); m_layout->addWidget(m_label,Qt::AlignLeading); m_layout->addWidget(m_buttonToolBar); m_layout->addWidget(m_buttonMinimize); m_layout->addWidget(m_buttonNormal); m_layout->addWidget(m_buttonMaximize); m_layout->addWidget(m_buttonClose); m_layout->setSpacing(0); m_layout->setMargin(0); m_layout->setContentsMargins(0, 0, 0, 0); setLayout(m_layout); connect(m_buttonMinimize, SIGNAL(clicked()), this, SLOT(onMinimize())); connect(m_buttonNormal, SIGNAL(clicked()), this, SLOT(onNormal())); connect(m_buttonMaximize, SIGNAL(clicked()), this, SLOT(onMaximize())); connect(m_buttonClose, SIGNAL(clicked()), this, SLOT(onClose())); connect(m_buttonToolBar, SIGNAL(clicked()), this, SLOT(OnToolBarClicked())); setButtonMinMaxEnabled(false); }
//============================================================================== void CEvent::onEvent(SDL_Event *anEvent) { switch(anEvent->type) { case SDL_WINDOWEVENT: { switch(anEvent->window.event) { case SDL_WINDOWEVENT_ENTER:{ onMouseFocus(); break; } case SDL_WINDOWEVENT_LEAVE:{ onMouseBlur(); break; } case SDL_WINDOWEVENT_FOCUS_GAINED: { onInputFocus(); break; } case SDL_WINDOWEVENT_FOCUS_LOST: { onInputBlur(); break; } case SDL_WINDOWEVENT_RESTORED: { onRestore(); break; } case SDL_WINDOWEVENT_MINIMIZED: { onMinimize(); break; } } break; } case SDL_KEYDOWN: { onKeyPress(anEvent->key.keysym.sym, anEvent->key.keysym.mod); break; } case SDL_KEYUP: { onKeyRelease(anEvent->key.keysym.sym,anEvent->key.keysym.mod); break; } case SDL_MOUSEMOTION: { onMouseMove(anEvent->motion.x, anEvent->motion.y, anEvent->motion.xrel, anEvent->motion.yrel,(anEvent->motion.state&SDL_BUTTON(SDL_BUTTON_LEFT))!=0,(anEvent->motion.state&SDL_BUTTON(SDL_BUTTON_RIGHT))!=0,(anEvent->motion.state&SDL_BUTTON(SDL_BUTTON_MIDDLE))!=0); break; } case SDL_MOUSEBUTTONDOWN: { switch(anEvent->button.button) { case SDL_BUTTON_LEFT: { onLButtonDown(anEvent->button.x,anEvent->button.y); break; } case SDL_BUTTON_RIGHT: { onRButtonDown(anEvent->button.x,anEvent->button.y); break; } case SDL_BUTTON_MIDDLE: { onMButtonDown(anEvent->button.x,anEvent->button.y); break; } } break; } case SDL_MOUSEBUTTONUP: { switch(anEvent->button.button) { case SDL_BUTTON_LEFT: { onLButtonUp(anEvent->button.x,anEvent->button.y); break; } case SDL_BUTTON_RIGHT: { onRButtonUp(anEvent->button.x,anEvent->button.y); break; } case SDL_BUTTON_MIDDLE: { onMButtonUp(anEvent->button.x,anEvent->button.y); break; } } break; } case SDL_QUIT: { onExit(); break; } case SDL_SYSWMEVENT: { //Ignore break; } case SDL_WINDOWEVENT_RESIZED: { onResize(anEvent->window.data1,anEvent->window.data2); break; } case SDL_WINDOWEVENT_EXPOSED: { onExpose(); break; } default: { onUser(anEvent->user.type,anEvent->user.code,anEvent->user.data1,anEvent->user.data2); break; } } }
void Event::onEvent(SDL_Event *event) { switch (event->type) { case SDL_ACTIVEEVENT: switch (event->active.state) { case SDL_APPMOUSEFOCUS: if (event->active.gain) { onMouseFocus(); } else { onMouseBlur(); } break; case SDL_APPINPUTFOCUS: if (event->active.gain) { onInputFocus(); } else { onInputBlur(); } break; case SDL_APPACTIVE: if (event->active.gain) { onRestore(); } else { onMinimize(); } break; } break; //SDL_ACTIVEEVENT case SDL_KEYDOWN: onKeyDown(event->key.keysym.sym, event->key.keysym.mod, event->key.keysym.unicode); break; case SDL_KEYUP: onKeyUp(event->key.keysym.sym, event->key.keysym.mod, event->key.keysym.unicode); break; case SDL_MOUSEBUTTONDOWN: onMouseDown(event->button.button, event->button.x, event->button.y); break; case SDL_MOUSEBUTTONUP: onMouseUp(event->button.button, event->button.x, event->button.y); break; case SDL_JOYAXISMOTION: onJoyAxis(event->jaxis.which, event->jaxis.axis, event->jaxis.value); break; case SDL_JOYBALLMOTION: onJoyBall(event->jball.which, event->jball.ball, event->jball.xrel, event->jball.yrel); break; case SDL_JOYHATMOTION: onJoyHat(event->jhat.which, event->jhat.hat, event->jhat.value); break; case SDL_JOYBUTTONDOWN: onJoyButtonDown(event->jbutton.which, event->jbutton.button); break; case SDL_JOYBUTTONUP: onJoyButtonUp(event->jbutton.which, event->jbutton.button); break; case SDL_QUIT: onQuit(); break; case SDL_VIDEORESIZE: onResize(event->resize.w, event->resize.h); break; default: onUser(event->user.type, event->user.code, event->user.data1, event->user.data2); break; } }
Ui::DetachedVideoWindow::DetachedVideoWindow(QWidget* parent) : AspectRatioResizebleWnd() , parent_(parent) , closed_manualy_(false) , show_panel_timer_(this) , video_panel_header_(new VideoPanelHeader(this, kVPH_ShowClose)) { if (this->objectName().isEmpty()) this->setObjectName(QStringLiteral("detachedVideoWnd")); this->resize(400, 300); this->setMinimumSize(QSize(0, 0)); this->setMaximumSize(QSize(16777215, 16777215)); this->setProperty("DetachedVideoWindowCommon", QVariant(true)); horizontal_layout_ = new QHBoxLayout(this); horizontal_layout_->setObjectName(QStringLiteral("horizontalLayout")); horizontal_layout_->setContentsMargins(0, 0, 0, 0); horizontal_layout_->setSpacing(0); horizontal_layout_->setAlignment(Qt::AlignVCenter); QMetaObject::connectSlotsByName(this); #ifdef _WIN32 setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::SubWindow); #else setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Window | Qt::WindowDoesNotAcceptFocus/*| Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint | Qt::WindowMaximizeButtonHint*/); setAttribute(Qt::WA_ShowWithoutActivating); setAttribute(Qt::WA_X11DoNotAcceptFocus); #endif video_panel_header_effect_ = new UIEffects(*video_panel_header_.get()); #ifndef __linux__ std::vector<QWidget*> panels; panels.push_back(video_panel_header_.get()); _rootWidget = platform_specific::GraphicsPanel::create(this, panels); _rootWidget->setContentsMargins(0, 0, 0, 0); //_rootWidget->setProperty("WidgetWithBG", true); _rootWidget->setAttribute(Qt::WA_UpdatesDisabled); _rootWidget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); layout()->addWidget(_rootWidget); #endif //__linux__ std::vector<QWidget*> topPanels; topPanels.push_back(video_panel_header_.get()); std::vector<QWidget*> bottomPanels; event_filter_ = new video_window::ResizeEventFilter(topPanels, bottomPanels, this); installEventFilter(event_filter_); setAttribute(Qt::WA_UpdatesDisabled); setAttribute(Qt::WA_ShowWithoutActivating); connect(&show_panel_timer_, SIGNAL(timeout()), this, SLOT(_check_panels_vis()), Qt::QueuedConnection); show_panel_timer_.setInterval(1500); assert(!!video_panel_header_); if (!!video_panel_header_) { //video_panel_header_->setWindowFlags(Qt::SubWindow | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); //video_panel_header_->setAttribute(Qt::WA_NoSystemBackground, true); //video_panel_header_->setAttribute(Qt::WA_TranslucentBackground, true); video_panel_header_->setWindowFlags(Qt::SubWindow | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); video_panel_header_->setAttribute(Qt::WA_NoSystemBackground, true); video_panel_header_->setAttribute(Qt::WA_TranslucentBackground, true); connect(video_panel_header_.get(), SIGNAL(onMouseEnter()), this, SLOT(onPanelMouseEnter()), Qt::QueuedConnection); connect(video_panel_header_.get(), SIGNAL(onMouseLeave()), this, SLOT(onPanelMouseLeave()), Qt::QueuedConnection); connect(video_panel_header_.get(), SIGNAL(onClose()), this, SLOT(onPanelClickedClose()), Qt::QueuedConnection); connect(video_panel_header_.get(), SIGNAL(onMinimize()), this, SLOT(onPanelClickedMinimize()), Qt::QueuedConnection); connect(video_panel_header_.get(), SIGNAL(onMaximize()), this, SLOT(onPanelClickedMaximize()), Qt::QueuedConnection); } connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipWindowRemoveComplete(quintptr)), this, SLOT(onVoipWindowRemoveComplete(quintptr)), Qt::DirectConnection); connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipWindowAddComplete(quintptr)), this, SLOT(onVoipWindowAddComplete(quintptr)), Qt::DirectConnection); connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipCallDestroyed(const voip_manager::ContactEx&)), this, SLOT(onVoipCallDestroyed(const voip_manager::ContactEx&)), Qt::DirectConnection); setMinimumSize(Utils::scale_value(320), Utils::scale_value(80)); QDesktopWidget dw; const auto screen_rect = dw.screenGeometry(dw.primaryScreen()); const auto detached_wnd_rect = rect(); auto detached_wnd_pos = screen_rect.topRight(); detached_wnd_pos.setX(detached_wnd_pos.x() - detached_wnd_rect.width() - 0.01f * screen_rect.width()); detached_wnd_pos.setY(detached_wnd_pos.y() + 0.05f * screen_rect.height()); const QRect rc(detached_wnd_pos.x(), detached_wnd_pos.y(), detached_wnd_rect.width(), detached_wnd_rect.height()); setGeometry(rc); }