void
CSecondaryScreen::enter(SInt32 x, SInt32 y, KeyModifierMask mask)
{
	CLock lock(&m_mutex);
	assert(m_active == false);

	LOG((CLOG_INFO "entering screen at %d,%d mask=%04x", x, y, mask));

	getScreen()->syncDesktop();

	// now active
	m_active = true;

	// subclass hook
	onPreEnter();

	// update our keyboard state to reflect the local state
	updateKeys();

	// remember toggle key state
	m_toggleKeys = getToggleState();

	// toggle modifiers that don't match the desired state
	setToggleState(mask);

	// warp to requested location
	warpCursor(x, y);

	// show mouse
	hideWindow();

	// subclass hook
	onPostEnter();
}
Example #2
0
/**
 * Méthode initialisant l'icône de la zone de notification
 *
 * @return void
 * @since  1.0.0
 */
void ConvertWindow::initIcon()
{
    tray_icon = new QSystemTrayIcon(this);

    QMenu* menu = new QMenu(this);

    QAction* action_show = new QAction(QString::fromUtf8("Afficher"), this);
    QAction* action_hide = new QAction(QString::fromUtf8("Réduire"), this);
    QAction* action_about = new QAction(QString::fromUtf8("A propos de QOpenConvert"), this);
    QAction* action_close = new QAction(QString::fromUtf8("Fermer QOpenConvert"), this);

    connect(action_show, SIGNAL(triggered()), this, SLOT(showWindow()));
    connect(action_hide, SIGNAL(triggered()), this, SLOT(hideWindow()));
    connect(action_close, SIGNAL(triggered()), qApp, SLOT(quit()));
    connect(action_about, SIGNAL(triggered()), this, SLOT(showAbout()));
    connect(tray_icon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));


    menu->addAction(action_show);
    menu->addAction(action_hide);
    menu->addAction(action_about);
    menu->addAction(action_close);

    tray_icon->setContextMenu(menu);

    QIcon image = QIcon(":/images/icon.png");
    tray_icon->setIcon(image);

    tray_icon->show();
}
Example #3
0
/**
 * Méthode interceptant l'événement de fermeture de la fenêtre
 *
 * @param  QCloseEvent*     event   l'événement intercepté
 * @return void
 * @since  1.0.0
 */
void ConvertWindow::closeEvent(QCloseEvent *event)
{
    if (tray_icon->isVisible()) {
        hideWindow();
        event->ignore();
    }
}
Example #4
0
File: main.cpp Project: jhasse/jngl
void showWindow(const std::string& title, const int width, const int height, bool fullscreen) {
    debug("jngl::showWindow(\"");
    debug(title);
    debug("\", ");
    debug(width);
    debug(", ");
    debug(height);
    debug(", ");
    debug(fullscreen);
    debug(");\n");
    if (pWindow &&
            width == pWindow->getWidth() &&
            height == pWindow->getHeight() &&
            fullscreen == pWindow->getFullscreen()) {
        return jngl::setTitle(title);
    }
    bool isMouseVisible = pWindow ? pWindow->getMouseVisible() : true;
    hideWindow();
    if (width == 0) {
        throw std::runtime_error("Width Is 0");
    }
    if (height == 0) {
        throw std::runtime_error("Height Is 0");
    }
    pWindow.Set(new Window(title, width, height, fullscreen));
    pWindow->SetMouseVisible(isMouseVisible);
    setAntiAliasing(antiAliasingEnabled);
}
Example #5
0
void MainWindow::showWindow()
{
    f=new FileWindow(this);
    f->show();
    ui->pushButton->disconnect();
    connect(ui->pushButton,SIGNAL(clicked()),this,SLOT(hideWindow()));
}
Example #6
0
void ATMainWindow_c::iconActivated(QSystemTrayIcon::ActivationReason reason)
{
	switch (reason) {
	case QSystemTrayIcon::Trigger:
		if ( m_lastTrayTrigger.elapsed() > MIN_TRIGGER_TIMER )
		{
			if ( isVisible() )
			{
				hideWindow();
			}
			else
			{
				showNormal();
				IF_WIN32( ::SetForegroundWindow( winId() ) );
			}
			m_lastTrayTrigger.restart();
		}
		break;
	//case QSystemTrayIcon::DoubleClick:
	//	break;
	//case QSystemTrayIcon::MiddleClick:
	//	break;
	default:
		;
	}
}
void UBDesktopAnnotationController::goToUniboard()
{
    hideWindow();

    UBPlatformUtils::setDesktopMode(false);

    emit restoreUniboard();
}
Example #8
0
void KueueWindow::toggleWindow()
{
    if ( isHidden() )
    {
        showWindow();
    }
    else 
    {
        hideWindow();
    }
}
void StatusIndicatorMenuWindow::displayInActive()
{
    if (menuWidget && menuWidget->sceneWindowState() != MSceneWindow::Disappeared) {
        sceneManager()->disappearSceneWindowNow(menuWidget);
    }

    // Hide the window when the it is obscured by another view
    // Note: Dialogs and notifications won't close it anyways,
    // as they are not supposed to be full screen and don't completely
    // obstruct the status menu window fully.
    hideWindow();
}
Example #10
0
void ATMainWindow_c::HotKey( unsigned short /*lo*/, unsigned short /*hi*/ )
{
	if ( isVisible() )
	{
		hideWindow();
	}
	else
	{
		showNormal();
		IF_WIN32( ::SetForegroundWindow( winId() ) );
	}
}
Example #11
0
void KueueWindow::closeEvent( QCloseEvent* e )
{
    if ( e->spontaneous() )
    {
        e->ignore();
        hideWindow();
    }
    else
    {
        qApp->quit();
    }
}
void StatusIndicatorMenuWindow::setWindowStateAccordingToDeviceLockState(MeeGo::QmLocks::Lock what, MeeGo::QmLocks::State how)
{
    switch (what) {
    case MeeGo::QmLocks::Device:
        if (how == MeeGo::QmLocks::Unlocked) {
            deviceLocked = false;
        } else {
            deviceLocked = true;
            if (isVisible()) {
                hideWindow();
            }
        }
        break;
    case MeeGo::QmLocks::TouchAndKeyboard:
        if (how == MeeGo::QmLocks::Locked && isVisible()) {
            hideWindow();
        }
        break;
    default:
        break;
    }
}
void StatusIndicatorMenuWindow::resetMenuWidget()
{
    if (menuWidget)
        delete menuWidget;

    menuWidget = new StatusIndicatorMenu();
    connect(menuWidget, SIGNAL(showRequested()), this, SLOT(makeVisible()));
    connect(menuWidget, SIGNAL(hideRequested()), menuWidget, SLOT(disappear()));
    connect(menuWidget, SIGNAL(disappeared()), this, SLOT(hideWindow()));

    // Initialize the status indicator menu after the first USB banner has been shown
    QTimer::singleShot(7000, this, SLOT(initializeMenuWidget()));
}
Example #14
0
void UBDesktopAnnotationController::goToUniboard()
{
    hideWindow();

    UBPlatformUtils::setDesktopMode(false);
    UBDrawingController::drawingController()->setInDestopMode(false);

    if(UBStylusTool::Eraser != UBDrawingController::drawingController()->stylusTool()) {
        UBDrawingController::drawingController()->setDrawingMode(eDrawingMode_Vector);
    }

    emit restoreUniboard();
}
Example #15
0
/**
 * SLOT de gestion du clic sur l'icône de la zone de notification
 * double-clic : on affiche ou on cache selon l'état actuel
 * simple-clic gauche : on affiche au premier place si l'état n'est pas hidden
 *
 * @param  QSystemTrayIcon::ActivationReason   reason     l'objet ActivationReason intercepté par le SIGNAL
 * @return void
 * @since  1.0.0
 */
void ConvertWindow::iconActivated(QSystemTrayIcon::ActivationReason reason)
{
    switch (reason) {
        case QSystemTrayIcon::DoubleClick:
            if (this->isHidden()) {
                showWindow();
            } else {
                hideWindow();
            }
            break;
        default:
            ;
    }
}
Example #16
0
	void MainWindow::closeEvent(QCloseEvent* event)
	{
		Previewer::ClosePreview();

        if (!platform::is_windows())
        {
            if (event->spontaneous())
            {
                event->ignore();

                hideWindow();
            }
        }
	}
Example #17
0
    void MainWindow::minimize()
    {
        if (get_gui_settings()->get_value<bool>(settings_show_in_taskbar, true))
        {
            showMinimized();
#ifdef _WIN32
            SetWindowPos((HWND)Shadow_->winId(), (HWND)winId(), 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_HIDEWINDOW);
#endif //_WIN32
        }
        else
        {
            hideWindow();
        }
    }
Example #18
0
void ATMainWindow_c::closeEvent( QCloseEvent * event )
{
	if ( m_bMinimizeToTray )
	{
		hideWindow();
		event->ignore();
	}
	else
	{
		if ( m_pMainWindow->onClose() )
			event->accept();
		else
			event->ignore();
	}
}
Example #19
0
void Window::addHeading() {
  static const px_t UNINIT = 0;
  _heading =
      new Label({0, 0, UNINIT, HEADING_HEIGHT}, _title, CENTER_JUSTIFIED);
  _heading->setLeftMouseDownFunction(&startDragging, this);
  Element::addChild(_heading);

  _headingLine = new Line(0, HEADING_HEIGHT, UNINIT);
  _headingLine->setLeftMouseDownFunction(&startDragging, this);
  Element::addChild(_headingLine);

  _closeButton = new Button({UNINIT, 1, CLOSE_BUTTON_SIZE, CLOSE_BUTTON_SIZE},
                            "", [this]() { hideWindow(this); });
  _closeButton->addChild(new Label({0, 0, CLOSE_BUTTON_SIZE, CLOSE_BUTTON_SIZE},
                                   "x", CENTER_JUSTIFIED, CENTER_JUSTIFIED));
  Element::addChild(_closeButton);
}
void WindowSystem::handleRequest()
{
    // read request(s)
    QTcpSocket *connection = qobject_cast<QTcpSocket*>(sender());
    QDataStream stream(connection);
    while (!stream.atEnd()) {
        qDebug() << "SERVER: reading request";
        Request request;
        stream >> request;
        // ### FIXME: verify that message type is request
        switch (request.type) {
        case Request::CreateWindowRequest: {
            quint32 id = createWindow(request.id);
            m_connections.insert(id, connection);
            Response response(Response::CreatedWindowResponse, id);
            qDebug() << "SERVER: sending response";
            stream << response;
            break; }
        case Request::DestroyWindowRequest:
            destroyWindow(request.id);
            break;
        case Request::ShowWindowRequest:
            showWindow(request.id);
            break;
        case Request::HideWindowRequest:
            hideWindow(request.id);
            break;
        case Request::RaiseWindowRequest:
            raiseWindow(request.id);
            break;
        case Request::LowerWindowRequest:
            lowerWindow(request.id);
            break;
        case Request::UpdateWindowRequest:
            updateWindow(request.id, request.rect);
            break;
        case Request::SetWindowGeometryRequest:
            setWindowGeometry(request.id, request.rect);
            break;
        default:
            qWarning() << "SERVER: unknown request type" << request.type;
            break;
        };
    } // while (!stream.atEnd())
}
Example #21
0
void QWidget::destroy( bool destroyWindow, bool destroySubWindows )
{
    deactivateWidgetCleanup();
    if ( testWState(WState_Created) ) {
	clearWState( WState_Created );
	if ( children() ) {
	    QObjectListIt it(*children());
	    register QObject *obj;
	    while ( (obj=it.current()) ) {	// destroy all widget children
		++it;
		if ( obj->isWidgetType() )
		    ((QWidget*)obj)->destroy(destroySubWindows,
					     destroySubWindows);
	    }
	}
	releaseMouse();
	if ( qt_pressGrab == this )
	  qt_pressGrab = 0;
#ifndef QT_NO_QWS_MANAGER
	if (QWSManager::grabbedMouse() == this) {
	    if ( extra && extra->topextra && extra->topextra->qwsManager ) {
		extra->topextra->qwsManager->releaseGrab();
	    }
	}
#endif
	if ( keyboardGrb == this )
	    releaseKeyboard();
	if ( testWFlags(WShowModal) )		// just be sure we leave modal
	    qt_leave_modal( this );
	else if ( testWFlags(WType_Popup) )
	    qApp->closePopup( this );
	if ( testWFlags(WType_Desktop) ) {
	} else {
	    if ( parentWidget() && parentWidget()->testWState(WState_Created) ) {
		hideWindow();
	    }
	    if ( destroyWindow && isTopLevel() )
		qwsDisplay()->destroyRegion( winId() );
	}
	setWinId( 0 );
    }
}
Example #22
0
void KSysTrayCmd::setTargetWindow( const KWin::WindowInfo &info )
{
  disconnect( kwinmodule, SIGNAL(windowAdded(WId)), this, SLOT(windowAdded(WId)) );
  connect( kwinmodule, SIGNAL(windowChanged(WId)), SLOT(windowChanged(WId)) );
  win = info.win();
  KWin::setSystemTrayWindowFor( winId(), win );
  refresh();
  show();

  if ( isVisible )
    KWin::activateWindow( win );
  else
    hideWindow();

  // Always on top ?
  if (onTop)
  {
    KWin::setState(win, NET::StaysOnTop);
  }
}
Example #23
0
void MainWindow::closeEvent(QCloseEvent * event)
{
    if (logdialog) {
        logdialog->close();
        logdialog = NULL;
    }

    if (trayIcon && trayIcon->isVisible()) {
    	static int shown = 0;

    	if (shown == 0) {
	        QMessageBox::information(this, tr("Systray"),
        	                         tr("The program will keep running in the "
                	                    "system tray. To terminate the program, "
                        	            "choose <b>Quit</b> in the system tray entry."));
		shown = 1;
	}
        hideWindow();
        event->ignore();
    }
}
Example #24
0
int Player::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: hideWindow(); break;
        case 1: open(); break;
        case 2: durationChanged((*reinterpret_cast< qint64(*)>(_a[1]))); break;
        case 3: positionChanged((*reinterpret_cast< qint64(*)>(_a[1]))); break;
        case 4: metaDataChanged(); break;
        case 5: previousClicked(); break;
        case 6: seek((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 7: jump((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 8: playlistPositionChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 9: statusChanged((*reinterpret_cast< QMediaPlayer::MediaStatus(*)>(_a[1]))); break;
        case 10: bufferingProgress((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 11: displayErrorMessage(); break;
        case 12: handleAspectRatio((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 13: handleStateChange((*reinterpret_cast< QMediaPlayer::State(*)>(_a[1]))); break;
        case 14: showPlayList(); break;
        case 15: hideOrShowCoverArt(); break;
        case 16: launchYoutubeDialog(); break;
        case 17: youtubeHttpRequestFinished((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< bool(*)>(_a[2]))); break;
        case 18: youtubeReadResponseHeader((*reinterpret_cast< const QHttpResponseHeader(*)>(_a[1]))); break;
        case 19: searchYoutubeVideo(); break;
        case 20: addYoutubeVideo(); break;
        case 21: handleAudioOutputDefault(); break;
        case 22: handleAudioOutputAll(); break;
        case 23: handleAudioOutputNone(); break;
        case 24: handleAudioOutputEarphone(); break;
        case 25: handleAudioOutputSpeaker(); break;
        case 26: handleAudioOutputChangedSignal((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 27;
    }
    return _id;
}
Example #25
0
void MusE::startMidiInputPlugin(int id)
      {
      bool flag = false;
      QWidget* w = 0;
      QAction* act = 0;
      if (id == 0) {
            if (!MusEGlobal::mitPluginTranspose) {
                  // NOTE: For deleting parentless dialogs and widgets, please add them to MusE::deleteParentlessDialogs().
                  MusEGlobal::mitPluginTranspose = new MITPluginTranspose();
                  MusECore::mitPlugins.push_back(MusEGlobal::mitPluginTranspose);
                  connect(MusEGlobal::mitPluginTranspose, SIGNAL(hideWindow()),
                     SLOT(hideMitPluginTranspose()));
                  }
            w = MusEGlobal::mitPluginTranspose;
            act = midiTrpAction;
            }
      else if (id == 1) {
            if (!midiInputTransform) {
                  // NOTE: For deleting parentless dialogs and widgets, please add them to MusE::deleteParentlessDialogs().
                  midiInputTransform = new MidiInputTransformDialog();
                  connect(midiInputTransform, SIGNAL(hideWindow()),
                     SLOT(hideMidiInputTransform()));
                  }
            w = midiInputTransform;
            act = midiInputTrfAction;
            }
      else if (id == 2) {
            if (!midiFilterConfig) {
                  // NOTE: For deleting parentless dialogs and widgets, please add them to MusE::deleteParentlessDialogs().
                  midiFilterConfig = new MidiFilterConfig();
                  connect(midiFilterConfig, SIGNAL(hideWindow()),
                     SLOT(hideMidiFilterConfig()));
                  }
            w = midiFilterConfig;
            act = midiInputFilterAction;
            }
      else if (id == 3) {
            if (!midiRemoteConfig) {
                  // NOTE: For deleting parentless dialogs and widgets, please add them to MusE::deleteParentlessDialogs().
                  midiRemoteConfig = new MRConfig();
                  connect(midiRemoteConfig, SIGNAL(hideWindow()),
                     SLOT(hideMidiRemoteConfig()));
                  }
            w = midiRemoteConfig;
            act = midiRemoteAction;
            }
#ifdef BUILD_EXPERIMENTAL
      else if (id == 4) {
            if (!midiRhythmGenerator) {
                  // NOTE: For deleting parentless dialogs and widgets, please add them to MusE::deleteParentlessDialogs().
                  midiRhythmGenerator = new RhythmGen();
                  connect(midiRhythmGenerator, SIGNAL(hideWindow()),
                     SLOT(hideMidiRhythmGenerator()));
                  }
            w = midiRhythmGenerator;
            act = midiRhythmAction;
            }
#endif
      if (w) {
            flag = !w->isVisible();
            if (flag)
                  w->show();
            else
                  w->hide();
            }
      if (act) act->setChecked(flag);
      }
Example #26
0
	bool MainWindow::nativeEventFilter(const QByteArray& data, void *message, long *result)
	{
#ifdef _WIN32
		MSG* msg = (MSG*)(message);
		if (msg->message == WM_NCHITTEST)
		{
			if (msg->hwnd != (HANDLE)winId())
			{
				return false;
			}

			int boxWidth = Utils::scale_value(SIZE_BOX_WIDTH);
			if (isMaximized())
			{
				*result = HTCLIENT;
				return true;
			}

			int x = GET_X_LPARAM(msg->lParam);
			int y = GET_Y_LPARAM(msg->lParam);

			QPoint topLeft = QWidget::mapToGlobal(rect().topLeft());
			QPoint bottomRight = QWidget::mapToGlobal(rect().bottomRight());

			if (x <= topLeft.x() + boxWidth)
			{
				if (y <= topLeft.y() + boxWidth)
					*result = HTTOPLEFT;
				else if (y >= bottomRight.y() - boxWidth)
					*result = HTBOTTOMLEFT;
				else
					*result = HTLEFT;
			}
			else if (x >= bottomRight.x() - boxWidth)
			{
				if (y <= topLeft.y() + boxWidth)
					*result = HTTOPRIGHT;
				else if (y >= bottomRight.y() - boxWidth)
					*result = HTBOTTOMRIGHT;
				else
					*result = HTRIGHT;
			}
			else
			{
				if (y <= topLeft.y() + boxWidth)
					*result = HTTOP;
				else if (y >= bottomRight.y() - boxWidth)
					*result = HTBOTTOM;
				else
					*result = HTCLIENT;
			}
			return true;
		}
		else if ((msg->message == WM_SYSCOMMAND && msg->wParam == SC_RESTORE && msg->hwnd == (HWND)winId()) || (msg->message == WM_SHOWWINDOW && msg->hwnd == (HWND)winId() && msg->wParam == TRUE))
		{
			setVisible(true);
            SetWindowPos((HWND)Shadow_->winId(), (HWND)winId(), 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
            tray_icon_->Hide();
            if (!SkipRead_)
			    Logic::GetRecentsModel()->sendLastRead();
            if (!TaskBarIconHidden_)
                SkipRead_ = false;
            TaskBarIconHidden_ = false;
		}
        else if (msg->message == WM_SYSCOMMAND && msg->wParam == SC_CLOSE)
        {
            hideWindow();
            return true;
        }
        else if (msg->message == WM_SYSCOMMAND && msg->wParam  == SC_MINIMIZE)
        {
            minimize();
            return true;
        }
        else if (msg->message == WM_WINDOWPOSCHANGING || msg->message == WM_WINDOWPOSCHANGED)
        {
            if (msg->hwnd != (HANDLE)winId())
            {
                return false;
            }

            WINDOWPOS* pos = (WINDOWPOS*)msg->lParam;
            if (pos->flags == 0x8170 || pos->flags == 0x8130)
            {
                SetWindowPos((HWND)Shadow_->winId(), (HWND)winId(), 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_HIDEWINDOW);
                return false;
            }
            if (Shadow_)
            {
                if (!(pos->flags & SWP_NOSIZE) && !(pos->flags & SWP_NOMOVE) && !(pos->flags & SWP_DRAWFRAME))
                {
                    int shadowWidth = get_gui_settings()->get_shadow_width();
                    SetWindowPos((HWND)Shadow_->winId(), (HWND)winId(), pos->x - shadowWidth, pos->y - shadowWidth, pos->cx + shadowWidth * 2, pos->cy + shadowWidth * 2, SWP_NOACTIVATE | SWP_NOOWNERZORDER);
                }
                else if (!(pos->flags & SWP_NOZORDER))
                {
                    UINT flags = SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE;
                    if (pos->flags & SWP_SHOWWINDOW)
                        flags |= SWP_SHOWWINDOW;
                    if (pos->flags & SWP_HIDEWINDOW)
                        flags |= SWP_HIDEWINDOW;

                    SetWindowPos((HWND)Shadow_->winId(), (HWND)winId(), 0, 0, 0, 0, flags);
                }
            }
        }
        else if (msg->message == WM_ACTIVATE)
        {
            if (!Shadow_)
                return false;

            if (msg->hwnd == (HWND)Shadow_->winId() && msg->wParam != WA_INACTIVE)
            {
                activate();
                return false;
            }
        }
        else if (msg->message == WM_DEVICECHANGE)
        {
            GetSoundsManager()->reinit();
        }
#else

#ifdef __APPLE__
        return MacSupport::nativeEventFilter(data, message, result);
#endif

#endif //_WIN32
		return false;
	}
Example #27
0
    MainWindow::MainWindow(QApplication* app)
		: main_page_(nullptr)
		, login_page_(nullptr)
#ifdef __APPLE__
        , accounts_page_(nullptr)
#endif //_APPLE__
		, app_(app)
		, event_filter_(new TitleWidgetEventFilter(this))
		, tray_icon_(new TrayIcon(this))
                , backgroundPixmap_(QPixmap())
        , Shadow_(0)
        , SkipRead_(false)
        , TaskBarIconHidden_(false)
        , liveChats_(new LiveChats(this))
	{
        Utils::InterConnector::instance().setMainWindow(this);

#ifdef _WIN32
        Utils::init_crash_handlers_in_core();
        core::dump::crash_handler chandler;
        chandler.set_process_exception_handlers();
        chandler.set_thread_exception_handlers();
#endif //_WIN32

		setStyleSheet(Utils::LoadStyle(":/main_window/main_window.qss", Utils::get_scale_coefficient(), true));
#ifdef __APPLE__
        mac_support_ = new MacSupport(this);
        mac_support_->enableMacCrashReport();
#endif

        app_->installNativeEventFilter(this);

        if (this->objectName().isEmpty())
            this->setObjectName(QStringLiteral("main_window"));
        this->resize(329, 331);
        QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
        sizePolicy.setHorizontalStretch(0);
        sizePolicy.setVerticalStretch(0);
        sizePolicy.setHeightForWidth(this->sizePolicy().hasHeightForWidth());
        this->setSizePolicy(sizePolicy);
        this->setLayoutDirection(Qt::LeftToRight);
        this->setAutoFillBackground(false);
        main_widget_ = new QWidget(this);
        main_widget_->setObjectName(QStringLiteral("main_widget"));
        sizePolicy.setHeightForWidth(main_widget_->sizePolicy().hasHeightForWidth());
        main_widget_->setSizePolicy(sizePolicy);
        vertical_layout_ = new QVBoxLayout(main_widget_);
        vertical_layout_->setSpacing(0);
        vertical_layout_->setObjectName(QStringLiteral("verticalLayout_9"));
        vertical_layout_->setSizeConstraint(QLayout::SetDefaultConstraint);
        vertical_layout_->setContentsMargins(0, 0, 0, 0);
        title_widget_ = new QWidget(main_widget_);
        title_widget_->setObjectName(QStringLiteral("title_widget"));
        QSizePolicy sizePolicy1(QSizePolicy::Preferred, QSizePolicy::Fixed);
        sizePolicy1.setHorizontalStretch(0);
        sizePolicy1.setVerticalStretch(0);
        sizePolicy1.setHeightForWidth(title_widget_->sizePolicy().hasHeightForWidth());
        title_widget_->setSizePolicy(sizePolicy1);
        title_widget_->setProperty("TitleWidget", QVariant(true));
        horizontal_layout_ = new QHBoxLayout(title_widget_);
        horizontal_layout_->setSpacing(0);
        horizontal_layout_->setObjectName(QStringLiteral("horizontalLayout"));
        horizontal_layout_->setContentsMargins(0, 0, 0, 0);
        logo_ = new QPushButton(title_widget_);
        logo_->setObjectName(QStringLiteral("logo"));
        QSizePolicy sizePolicy2(QSizePolicy::Fixed, QSizePolicy::Fixed);
        sizePolicy2.setHorizontalStretch(0);
        sizePolicy2.setVerticalStretch(0);
        sizePolicy2.setHeightForWidth(logo_->sizePolicy().hasHeightForWidth());
        logo_->setSizePolicy(sizePolicy2);
        logo_->setProperty("WindowIcon", QVariant(true));
        horizontal_layout_->addWidget(logo_);
        title_ = new QLabel(title_widget_);
        title_->setObjectName(QStringLiteral("title"));
        title_->setProperty("Title", QVariant(true));
        horizontal_layout_->addWidget(title_);
        horizontal_spacer_ = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
        horizontal_layout_->addItem(horizontal_spacer_);
        hide_button_ = new QPushButton(title_widget_);
        hide_button_->setObjectName(QStringLiteral("hide_button"));
        hide_button_->setProperty("HideButton", QVariant(true));
        horizontal_layout_->addWidget(hide_button_);
        maximize_button_ = new QPushButton(title_widget_);
        maximize_button_->setObjectName(QStringLiteral("maximize_button"));
        sizePolicy2.setHeightForWidth(maximize_button_->sizePolicy().hasHeightForWidth());
        maximize_button_->setSizePolicy(sizePolicy2);
        maximize_button_->setProperty("MaximizeButton", QVariant(true));
        horizontal_layout_->addWidget(maximize_button_);
        close_button_ = new QPushButton(title_widget_);
        close_button_->setObjectName(QStringLiteral("close_button"));
        sizePolicy2.setHeightForWidth(close_button_->sizePolicy().hasHeightForWidth());
        close_button_->setSizePolicy(sizePolicy2);
        close_button_->setProperty("CloseButton", QVariant(true));
        horizontal_layout_->addWidget(close_button_);
        vertical_layout_->addWidget(title_widget_);
        stacked_widget_ = new BackgroundWidget(main_widget_, "");
        stacked_widget_->setObjectName(QStringLiteral("stacked_widget"));

        QPixmap p(":/resources/main_window/pat_100.png");
        setBackgroundPixmap(p, true);

        //Utils::InterConnector::instance().setMainWindow(this);
        get_qt_theme_settings()->setOrLoadDefaultTheme();
        vertical_layout_->addWidget(stacked_widget_);
        this->setCentralWidget(main_widget_);

        logo_->setText(QString());
        hide_button_->setText(QString());
        maximize_button_->setText(QString());
        close_button_->setText(QString());

        stacked_widget_->setCurrentIndex(-1);
        QMetaObject::connectSlotsByName(this);

        if (!get_gui_settings()->get_value(settings_keep_logged_in, true))// || !get_gui_settings()->contains_value(settings_keep_logged_in))
        {
            showLoginPage();
        }
        else
        {
            showMainPage();
        }

		title_widget_->installEventFilter(event_filter_);
		title_->setText("ICQ");
		title_->setAttribute(Qt::WA_TransparentForMouseEvents);
		logo_->setAttribute(Qt::WA_TransparentForMouseEvents);

		setWindowTitle("ICQ");
#ifdef _WIN32
        setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint | Qt::WindowMinimizeButtonHint);
        fake_parent_window_ = Utils::create_fake_parent_window();
#else
        title_widget_->hide();
#endif

		title_->setMouseTracking(true);

		connect(hide_button_, SIGNAL(clicked()), this, SLOT(minimize()), Qt::QueuedConnection);
		connect(maximize_button_, SIGNAL(clicked()), this, SLOT(maximize()), Qt::QueuedConnection);
		connect(close_button_, SIGNAL(clicked()), this, SLOT(hideWindow()), Qt::QueuedConnection);

		hide_button_->setCursor(Qt::PointingHandCursor);
		maximize_button_->setCursor(Qt::PointingHandCursor);
		close_button_->setCursor(Qt::PointingHandCursor);

		connect(event_filter_, SIGNAL(doubleClick()), this, SLOT(maximize()), Qt::QueuedConnection);
		connect(event_filter_, SIGNAL(moveRequest(QPoint)), this, SLOT(moveRequest(QPoint)), Qt::QueuedConnection);

        connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipResetComplete()), this, SLOT(onVoipResetComplete()), Qt::QueuedConnection);

		connect(Ui::GetDispatcher(), SIGNAL(needLogin()), this, SLOT(showLoginPage()), Qt::DirectConnection);
		connect(&Utils::InterConnector::instance(), SIGNAL(showIconInTaskbar(bool)), this, SLOT(showIconInTaskbar(bool)), Qt::QueuedConnection);

        connect(this, SIGNAL(needActivate()), this, SLOT(activate()), Qt::QueuedConnection);

        connect(get_gui_settings(), SIGNAL(changed(QString)), this, SLOT(guiSettingsChanged(QString)), Qt::QueuedConnection);

		QFont f = QApplication::font();
		f.setStyleStrategy(QFont::PreferAntialias);
		QApplication::setFont(f);

        if (platform::is_windows())
        {
            int shadowWidth = get_gui_settings()->get_shadow_width();
            QBrush b = stacked_widget_->palette().background();
            QMatrix m;
            m.translate(shadowWidth, title_widget_->height() + shadowWidth);
            b.setMatrix(m);
            Shadow_ = new ShadowWindow(b, shadowWidth);
            QPoint pos = mapToGlobal(QPoint(rect().x(), rect().y()));
            Shadow_->move(pos.x(), pos.y());
            Shadow_->resize(rect().width(), rect().height());
            Shadow_->setActive(true);
            Shadow_->show();
        }

        initSettings();
#ifdef _WIN32
        DragAcceptFiles((HWND)winId(), TRUE);
#endif //_WIN32

        if (!get_gui_settings()->get_value<bool>(settings_show_in_taskbar, true))
            hide_taskbar_icon();

#ifdef __APPLE__
        mac_support_->enableMacUpdater();
        mac_support_->enableMacPreview(this->winId());
#endif

	}
Example #28
0
void Widget::initUI()
{
    this->setFixedSize(900, 600);//设定尺寸
    this->setWindowTitle(tr("Chaos"));//设定标题
    this->setWindowFlags(Qt::FramelessWindowHint);
    this->setAttribute(Qt::WA_QuitOnClose,true);
    this->setWindowIcon(QIcon(":/mainico"));

    //创建托盘
    QSystemTrayIcon *system_tray = new QSystemTrayIcon();
    system_tray ->setIcon(QIcon(":/mainico"));
    system_tray->setToolTip("chaos");

    //创建托盘菜单
    QMenu *contexmenu=new QMenu(this);           //注意右键菜单的父对象,在窗口销毁后要把菜单也销毁掉
    QAction *shut=new QAction("quit",this);
    shut->setIcon(QIcon(":/close.ico"));
    //菜单中动作
    contexmenu->addAction(shut);
    system_tray->setContextMenu(contexmenu);
    //显示托盘
    system_tray->show();
    connect(shut,SIGNAL(triggered()),this,SLOT(closeWindow()));//右击退出程序
    connect(system_tray,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(showWindow(QSystemTrayIcon::ActivationReason)));


    //背景图片
    QPixmap pixmap = QPixmap(":/bc.jpg").scaled(this->size());
    QPalette palette(this->palette());
    palette.setBrush(QPalette::Background, QBrush(pixmap));
    this->setPalette(palette);

    //播放按钮
    btn1=new QPushButton(this);
    btn1->setText("playvideo");
    btn1->move(700,50);
    btn1->setObjectName("mainbtn");
    connect(btn1, SIGNAL(clicked()),
               this, SLOT(playVideo()));//建造一个button 并初始化click事件

    //关闭按钮
    btn2=new QPushButton(this);
    btn2->setText("close");
    btn2->move(btn1->x(),btn1->y()+50);
    btn2->setObjectName("mainbtn");
    connect(btn2, SIGNAL(clicked()),
               this, SLOT(closeWindow()));//建造一个button 并初始化click事件
    //最小化到托盘
    btn3=new QPushButton(this);
    btn3->setText("minimize");
    btn3->move(btn2->x(),btn2->y()+50);
    btn3->setObjectName("mainbtn");
    connect(btn3, SIGNAL(clicked()),
               this, SLOT(hideWindow()));//建造一个button 并初始化click事件


    bar1=new QProgressBar(this);
    bar1->setObjectName("mybar");
    bar1->move(this->x()+100,this->height()-100);
    bar1->setValue(50);


    list1=new QListView(this);
    list1->move(50,100);
    list1->setObjectName("mylist");
    QStringList user;
    user += "first";
    user +="second";
    QStringListModel *model = new QStringListModel(user);
    list1->setModel(model);        //useList是个QListView
    user += "third";
    model->setStringList(user);


    vdo=new videowidget();//实例化弹出窗口
}
 bool GameSettings::onApply()
 {
     hideWindow();
     return true;
 }
 bool GameSettings::onCancel()
 {
     hideWindow();
     return true;
 }