void FramelessWindow::mouseReleaseEvent(QMouseEvent *event) {
  Q_UNUSED(event);
  if (isMaximized()) {
    return;
  }

  m_bMousePressed = false;
  bool bSwitchBackCursorNeeded =
      m_bDragTop || m_bDragLeft || m_bDragRight || m_bDragBottom;
  m_bDragTop = false;
  m_bDragLeft = false;
  m_bDragRight = false;
  m_bDragBottom = false;
  if (bSwitchBackCursorNeeded) {
    setCursor(Qt::ArrowCursor);
  }
}
ZLQtApplicationWindow::~ZLQtApplicationWindow() {
	if (isFullscreen()) {
		myWindowStateOption.setValue(FULLSCREEN);
	} else if (isMaximized()) {
		myWindowStateOption.setValue(MAXIMIZED);
	} else {
		myWindowStateOption.setValue(NORMAL);
		if (x() != -1) {
			myXOption.setValue(x());
		}
		if (y() != -1) {
			myYOption.setValue(y());
		}
		myWidthOption.setValue(width());
		myHeightOption.setValue(height());
	}
}
Beispiel #3
0
void MainWindowPlugin::decreaseWidth()
{
    if (isMaximized() || isFullScreen())
        return;

    if (!canDecreaseWindowWidth())
        return;

    QSize stepSize = getZoomStepSize();
    QSize minSize = PLUGIN_WINDOW_MIN_SIZE;
    const int newWidth = qMax(width() - stepSize.width(), minSize.width());
    const int newHeight = height(); // keep same height;

    resize(newWidth, newHeight);

    getMainController()->resizePluginEditor(newWidth, newHeight);
}
Beispiel #4
0
void MainWindowPlugin::increaseWidth()
{
    if (isMaximized() || isFullScreen())
        return;

    if (!canIncreaseWindowWidth())
        return;

    QSize stepSize = getZoomStepSize();
    QSize maxSize = getMaxWindowSize();
    const int newWidth = qMin(width() + stepSize.width(), maxSize.width());
    const int newHeight = height(); // changing just the width

    resize(newWidth, newHeight);

    getMainController()->resizePluginEditor(newWidth, newHeight);
}
Beispiel #5
0
// For Qt4, see changeEvent method for Qt5
void KviMainWindow::hideEvent(QHideEvent * e)
{
#ifndef COMPILE_ON_MAC
	if(KVI_OPTION_BOOL(KviOption_boolMinimizeInTray) && e->spontaneous())
	{
		if(!trayIcon())
		{
			executeInternalCommand(KVI_INTERNALCOMMAND_TRAYICON_SHOW);
		}
		if(trayIcon())
		{
			KVI_OPTION_BOOL(KviOption_boolFrameIsMaximized) = isMaximized();
			QTimer::singleShot(0, this, SLOT(hide()));
		}
		return;
	}
#endif
}
Beispiel #6
0
void MainWindow::showRightColumn(object_ptr<TWidget> widget) {
	auto wasWidth = width();
	auto wasRightWidth = _rightColumn ? _rightColumn->width() : 0;
	_rightColumn = std::move(widget);
	if (_rightColumn) {
		_rightColumn->setParent(this);
		_rightColumn->show();
		_rightColumn->setFocus();
	} else if (App::wnd()) {
		App::wnd()->setInnerFocus();
	}
	auto nowRightWidth = _rightColumn ? _rightColumn->width() : 0;
	setMinimumWidth(st::windowMinWidth + nowRightWidth);
	if (!isMaximized()) {
		tryToExtendWidthBy(wasWidth + nowRightWidth - wasRightWidth - width());
	} else {
		updateControlsGeometry();
	}
}
Beispiel #7
0
void OSMDIChildWnd::detachMDI() {
  if (detached) return;
  detached = 1;
  if(m_parent) {
    OSMDIClientWnd * realparent = m_parent->getMDIClient();
    if ( realparent )
      realparent->unregisterRootWndChild(this);
    m_parent->updateMDIControlButtons(isMaximized());
  }
  m_oldparent = m_parent;
  setMDIParent(NULL);
  reparent(NULL);
#ifdef DETACHABLE
  HMENU sysm = GetSystemMenu(getOsWindowHandle(), FALSE);
  UINT currentID = MDICHILD_SYSMENU_DETACH;
  ModifyMenu(sysm,MDICHILD_SYSMENU_DETACH,MF_STRING,(UINT_PTR)currentID,"Attach to main window");
#endif
  //if (getMenu()) SetMenu(gethWnd(), getMenu()); fucko
}
void KisGmicWidget::maximizeSlot()
{
    QPushButton * maximizeButton = qobject_cast<QPushButton *>(sender());
    if (!maximizeButton)
    {
        return;
    }
    if (isMaximized())
    {
        // restore clicked
        showNormal();
        maximizeButton->setText(maximizeStr);
    }
    else
    {
        showMaximized();
        maximizeButton->setText(i18n("Restore"));
    }
}
void ApplicationWindow::toggleVisibility(QSystemTrayIcon::ActivationReason e)
{
    if(e == QSystemTrayIcon::Trigger || e == QSystemTrayIcon::DoubleClick){
        if(isHidden()){
            show();
            if(isMinimized()){
                if(isMaximized()){
                    showMaximized();
                }else{
                    showNormal();
                }
            }
            raise();
            activateWindow();
        }else{
            hide();
        }
    }
}
Beispiel #10
0
void MainWindow::SaveSettings()
{
    //Force toolbar checkbox value to be updated
    AboutToShowViewMenu();

    mSettings->setValue(SETTINGS_WINDOW_WIDTH, size().width());
    mSettings->setValue(SETTINGS_WINDOW_HEIGHT, size().height());
    mSettings->setValue(SETTINGS_WINDOW_MAXIMIZED, isMaximized());

    mSettings->setValue(SETTINGS_SHOW_STYLE, mUI.mActionShowStyle->isChecked());
    mSettings->setValue(SETTINGS_SHOW_ERRORS, mUI.mActionShowErrors->isChecked());
    mSettings->setValue(SETTINGS_TOOLBARS_MAIN_SHOW, mUI.mToolBarMain->isVisible());
    mSettings->setValue(SETTINGS_TOOLBARS_VIEW_SHOW, mUI.mToolBarView->isVisible());

    mApplications->SaveSettings(mSettings);

    mSettings->setValue(SETTINGS_LANGUAGE, mTranslation->GetCurrentLanguage());
    mUI.mResults->SaveSettings();
}
Beispiel #11
0
void SeparateWindow::toggleFullscreen()
{
  QSettings settings;
  if (isFullScreen())
  {
    // Show the window normal or maximized (depending on how it was shown before)
    if (showNormalMaximized)
      showMaximized();
    else
      showNormal();
  }
  else
  {
    // Save if the window is currently maximized
    showNormalMaximized = isMaximized();

    showFullScreen();
  }
}
void Axon200Commander::Panel::doSave( Settings::Object::State &s ) const {
	if (isMaximized())
		s.saveInteger("Maximized", 1);
	else if (isMinimized())
		s.saveInteger("Minimized", 1);

	QPoint pos = parentWidget()->pos();
	s.saveInteger("X", pos.x());
	s.saveInteger("Y", pos.y());
	s.saveInteger("W", width());
	s.saveInteger("H", height());

    s.saveInteger("Input Channel", mainUI->inputChannelSpinBox->value() );
    s.saveInteger("Output Channel", mainUI->outputChannelSpinBox->value() );
    s.saveInteger("Gain", mainUI->gainComboBox->currentItem() );
    s.saveInteger("Headstage Config", mainUI->configComboBox->currentItem() );
    s.saveInteger("Mode", mainUI->ampModeButtonGroup->selectedId() );
    s.saveInteger("Auto Mode", mainUI->autoModeButton->isOn() );
}
Beispiel #13
0
void ATMainWindow_c::writeSettings()
{
	int bMax = isMaximized();

	QSettings settings( g_strIniFile, QSettings::IniFormat);
	if ( !bMax )
	{
		settings.setValue( "pos", pos() );
		settings.setValue( "size", size() );
	}
	settings.setValue( "maximized", bMax );
	settings.setValue( "qtstyle", m_strStyle );
	settings.setValue( "hotkey_mod1", m_strHotkeyMod1 );
	settings.setValue( "hotkey_mod2", m_strHotkeyMod2 );
	settings.setValue( "hotkey_key", m_strHotkeyKey );
	settings.setValue( "hotkey_enabled", m_bHotkeyEnabled );
	settings.setValue( "minimize_to_tray", m_bMinimizeToTray );

	settings.sync();
}
void ContractManagerView::loadWorkSpace()
{
    //qDebug() << "ContractManagerView::loadWorkSpace()";

    wsSettings->beginGroup("contractmanager");
    restoreGeometry(wsSettings->value( "geometry", saveGeometry() ).toByteArray());

    move(wsSettings->value( "pos", pos() ).toPoint());
    resize(wsSettings->value( "size", size()).toSize());
    if ( wsSettings->value( "maximized", isMaximized() ).toBool() )
    {
        showMaximized();
    }
    wsSettings->endGroup();

    //qDebug() << "pos():" << pos();
    //qDebug() << "FrameGeo:" << this->frameGeometry();



}
Beispiel #15
0
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMdiSubWindow::moveEvent(QMoveEvent* moveEvent)
{
    if (!isMaximized())
    {
        m_normalWindowGeometry = frameGeometry();
    }
    
    if (!m_blockTilingChanges)
    {
        if (window() == RiaApplication::instance()->mainWindow())
        {
            RiaApplication::instance()->mainWindow()->storeSubWindowTiling(false);
        }
        else if (window() == RiaApplication::instance()->mainPlotWindow())
        {
            RiaApplication::instance()->mainPlotWindow()->storeSubWindowTiling(false);
        }
    }

    QMdiSubWindow::moveEvent(moveEvent);
}
Beispiel #16
0
void NodeEditorWindows::writeSettings()
{
    QSettings settings("GPStudio", "gpnode");

    // MainWindow position/size/maximized
    settings.beginGroup("MainWindow");
    settings.setValue("size", normalGeometry().size());
    settings.setValue("pos", normalGeometry().topLeft());
    settings.setValue("maximized", isMaximized());
    settings.endGroup();

    // old projects write
    settings.beginWriteArray("projects");
    for (int i = 0; i < _oldProjects.size() && i < MaxOldProject; ++i)
    {
        settings.setArrayIndex(i);
        QString path = _oldProjects[i];
        settings.setValue("path", path);
    }
    settings.endArray();
}
Beispiel #17
0
//wczytuje ustawienia z pliku
void MainWindow::wczytajUstawienia()
{
    //utworzenie odwołania do ustawień systemowych (nazwa firmy, nazwa programu)
    QSettings ustawSystemowe("MD", "Poziom tuszu");

    //grupa ustawień mainwindow
    ustawSystemowe.beginGroup("mainwindow");

    //poszczególne opcje do wczytania z ustawień systemowych
    restoreGeometry(ustawSystemowe.value("geometria", saveGeometry()).toByteArray());
    restoreState(ustawSystemowe.value("stan", saveState()).toByteArray());
    move(ustawSystemowe.value("pozycja", pos()).toPoint());
    resize(ustawSystemowe.value("rozmiar", size()).toSize());

    //w przypadku maksymalizacji okna
    if (ustawSystemowe.value("maksymalizacja", isMaximized()).toBool())
        showMaximized();

    //koniec grupy mainwindow
    ustawSystemowe.endGroup();
}
Beispiel #18
0
	void MainWindow::resizeEvent(QResizeEvent* event)
	{
        if (isMaximized())
        {
            get_gui_settings()->set_value(settings_window_maximized, true);
        }
        else
        {
            QRect rc = Ui::get_gui_settings()->get_value(settings_main_window_rect, QRect());
            rc.setWidth(event->size().width());
            rc.setHeight(event->size().height());

            get_gui_settings()->set_value(settings_main_window_rect, rc);
            get_gui_settings()->set_value(settings_window_maximized, false);
        }
        // TODO : limit call this stats
        // GetDispatcher()->post_stats_to_core(core::stats::stats_event_names::main_window_resize);

#ifdef __APPLE__
        mac_support_->updateMainMenu();
#endif
	}
Beispiel #19
0
void MainWindow::writeSettings() {
    QSettings settings;
    settings.setValue("mainwindow/maximized", isMaximized());
    settings.setValue("mainwindow/geometry", saveGeometry());
    settings.setValue("mainwindow/state", saveState());
    writeDockSettings(lyricsDock_, "lyrics", lyricsDockEnabled_);
    writeDockSettings(console_, "console", consoleEnabled_);

    settings.setValue("mainwindow/cursorFollowsPlayback", cursorFollowsPlayback_);

    settings.setValue("mainwindow/saveTabs", saveTabs_);
    if (saveTabs_) {
        QList<QVariant> names;
        QList<QVariant> data;
        for (int i = 0; i < playlistTabs->count(); ++i) {
            names.append(playlistTabs->tabText(i));
            PlaylistTab *tab = dynamic_cast<PlaylistTab *>(playlistTabs->widget(i));
            if (tab->isEditable()) {
                QByteArray tabData;
                tab->serialize(tabData);
                data.append(tabData);
            } else
                data.append(QVariant::Invalid);
        }
        settings.setValue("mainwindow/tabsNames", QVariant(names));
        settings.setValue("mainwindow/tabsData", QVariant(data));
    }

    int position = -1;
    int lastTab = -1;
    auto lastPlayed = player_.getLastPlayed();
    if (lastPlayed.first && lastPlayed.second.isValid()) {
        auto playlistTab = playlistModels_.left.at(lastPlayed.first);
        position = playlistTab->getUnfilteredPosition(lastPlayed.second);
        lastTab = playlistTabs->indexOf(playlistTab);
    }
    settings.setValue("mainwindow/lastPlayingTab", lastTab);
    settings.setValue("mainwindow/lastPlayingPosition", position);
}
Beispiel #20
0
void PgxConsoleMainWindow::closeEvent(QCloseEvent *event)
{
    //Clean-up only when there is no active thread.
    //However, this will cause a memory leak when the
    //TableView is closed when the thread is busy.
    //Proper solution is to create a Thread class
    //and cancel that before we clean-up. We cannot do
    //this now because we are using QFuture (per Qt docs).
    emit pgxconsoleClosing();

    QSettings settings("pgXplorer", "pgXplorer");
    if(isMaximized()) {
        settings.setValue("pgxconsole_maximized", true);
        showNormal();
    }
    else
        settings.setValue("pgxconsole_maximized", false);
    settings.setValue("pgxconsole_pos", pos());
    settings.setValue("pgxconsole_size", size());

    QMainWindow::closeEvent(event);
}
Beispiel #21
0
void MainWindow::SaveSettings() const
{
    // Window/dialog sizes
    mSettings->setValue(SETTINGS_WINDOW_WIDTH, size().width());
    mSettings->setValue(SETTINGS_WINDOW_HEIGHT, size().height());
    mSettings->setValue(SETTINGS_WINDOW_MAXIMIZED, isMaximized());

    // Show * states
    mSettings->setValue(SETTINGS_SHOW_STYLE, mUI.mActionShowStyle->isChecked());
    mSettings->setValue(SETTINGS_SHOW_ERRORS, mUI.mActionShowErrors->isChecked());
    mSettings->setValue(SETTINGS_SHOW_WARNINGS, mUI.mActionShowWarnings->isChecked());
    mSettings->setValue(SETTINGS_SHOW_PORTABILITY, mUI.mActionShowPortability->isChecked());
    mSettings->setValue(SETTINGS_SHOW_PERFORMANCE, mUI.mActionShowPerformance->isChecked());
    mSettings->setValue(SETTINGS_SHOW_INFORMATION, mUI.mActionShowInformation->isChecked());

    mSettings->setValue(SETTINGS_STD_CPP03, mUI.mActionCpp03->isChecked());
    mSettings->setValue(SETTINGS_STD_CPP11, mUI.mActionCpp11->isChecked());
    mSettings->setValue(SETTINGS_STD_C89, mUI.mActionC89->isChecked());
    mSettings->setValue(SETTINGS_STD_C99, mUI.mActionC99->isChecked());
    mSettings->setValue(SETTINGS_STD_C11, mUI.mActionC11->isChecked());
    mSettings->setValue(SETTINGS_STD_POSIX, mUI.mActionPosix->isChecked());

    // Main window settings
    mSettings->setValue(SETTINGS_TOOLBARS_MAIN_SHOW, mUI.mToolBarMain->isVisible());
    mSettings->setValue(SETTINGS_TOOLBARS_VIEW_SHOW, mUI.mToolBarView->isVisible());
    mSettings->setValue(SETTINGS_TOOLBARS_FILTER_SHOW, mUI.mToolBarFilter->isVisible());

    if (mUI.mActionEnforceCpp->isChecked())
        mSettings->setValue(SETTINGS_ENFORCED_LANGUAGE, Settings::CPP);
    else if (mUI.mActionEnforceC->isChecked())
        mSettings->setValue(SETTINGS_ENFORCED_LANGUAGE, Settings::C);
    else
        mSettings->setValue(SETTINGS_ENFORCED_LANGUAGE, Settings::None);

    mApplications->SaveSettings();

    mSettings->setValue(SETTINGS_LANGUAGE, mTranslation->GetCurrentLanguage());
    mUI.mResults->SaveSettings(mSettings);
}
void FramelessWindow::mousePressEvent(QMouseEvent *event) {
  if (isMaximized()) {
    return;
  }

  m_bMousePressed = true;
  m_StartGeometry = this->geometry();

  QPoint globalMousePos = mapToGlobal(QPoint(event->x(), event->y()));

  if (leftBorderHit(globalMousePos) && topBorderHit(globalMousePos)) {
    m_bDragTop = true;
    m_bDragLeft = true;
    setCursor(Qt::SizeFDiagCursor);
  } else if (rightBorderHit(globalMousePos) && topBorderHit(globalMousePos)) {
    m_bDragRight = true;
    m_bDragTop = true;
    setCursor(Qt::SizeBDiagCursor);
  } else if (leftBorderHit(globalMousePos) && bottomBorderHit(globalMousePos)) {
    m_bDragLeft = true;
    m_bDragBottom = true;
    setCursor(Qt::SizeBDiagCursor);
  } else {
    if (topBorderHit(globalMousePos)) {
      m_bDragTop = true;
      setCursor(Qt::SizeVerCursor);
    } else if (leftBorderHit(globalMousePos)) {
      m_bDragLeft = true;
      setCursor(Qt::SizeHorCursor);
    } else if (rightBorderHit(globalMousePos)) {
      m_bDragRight = true;
      setCursor(Qt::SizeHorCursor);
    } else if (bottomBorderHit(globalMousePos)) {
      m_bDragBottom = true;
      setCursor(Qt::SizeVerCursor);
    }
  }
}
ZLQtApplicationWindow::~ZLQtApplicationWindow() {
	if (isFullscreen()) {
		myWindowStateOption.setValue(FULLSCREEN);
	} else if (isMaximized()) {
		myWindowStateOption.setValue(MAXIMIZED);
	} else {
		myWindowStateOption.setValue(NORMAL);
		QPoint position = pos();
		if (position.x() != -1) {
			myXOption.setValue(position.x());
		}
		if (position.y() != -1) {
			myYOption.setValue(position.y());
		}
		myWidthOption.setValue(width());
		myHeightOption.setValue(height());
	}
	for (std::map<const ZLToolbar::Item*,QAction*>::iterator it = myActions.begin(); it != myActions.end(); ++it) {
		if (it->second != 0) {
			delete it->second;
		}
	}
}
Beispiel #24
0
void Ide::closeEvent(QCloseEvent *e)
{
    QMessageBox mb(QMessageBox::Question, Qrc::text("dialog.quit.title"), Qrc::text("dialog.quit.message"));
    mb.addButton(QMessageBox::Yes);
    mb.addButton(QMessageBox::No);
    mb.setWindowIcon(Qrc::icon("dialog_quit"));
    if (QMessageBox::Yes == mb.exec())
    {
        auto p = Preferences::get();
        bool m = isMaximized();
        p->setWindowMaximized(m);
        if (!m)
        {
            p->setWindowSize(size());
        }
        p->setDocksState(saveState());
        p->save();
    }
    else
    {
        e->ignore();
    }
}
Beispiel #25
0
void KviMdiChild::restore()
{
	if(isMinimized())
	{
		// we don't use showNormal here because it seems to enforce the previous window geometry:
		// since we were minimized in a shaded form, this creates ugly effects (like bug #823)
		setWindowState(windowState() & ~Qt::WindowMinimized);
		show();
		return;
	}

	if(isMaximized())
	{
		setWindowState(windowState() & ~Qt::WindowMaximized);
		showNormal();
		return;
	}

	if(!isVisible())
	{
		show();
		return;
	}
}
Beispiel #26
0
void MainWindow::on_actionFullscreen_triggered(bool checked)
{
	// "fullscreen" checked
    if (checked == true)
    {
		m_bMaximized = isMaximized();
		showFullScreen();
    }
	else
	{
		// case: if it was maximized before fullscreen,
		// return to maximized..
		if (m_bMaximized == true)
		{
			showMaximized();
		}
		else
		{
			showNormal();
		}
	}

	DoImageSize();
}
Beispiel #27
0
void CCommonWidget::resizeEvent (QResizeEvent* event)
{
	if(isMaximized())
	{
		if(m_pMaxButton)
			m_pMaxButton->hide();
		if(m_pRestoreButton)
			m_pRestoreButton->show();
		MakeRoundCorner();
	}
	else if(isMinimized())
	{

	}
	else
	{
		if(m_pRestoreButton)
			m_pRestoreButton->hide();
		if(m_pMaxButton)
			m_pMaxButton->show();
		MakeRoundCorner();
	}
	
}
Beispiel #28
0
Widget::Widget(QWidget *parent)
    : QMainWindow(parent),
      ui(new Ui::MainWindow),
      activeChatroomWidget{nullptr}
{
    ui->setupUi(this);

    ui->statusbar->hide();
    ui->menubar->hide();

    //restore window state
    restoreGeometry(Settings::getInstance().getWindowGeometry());
    restoreState(Settings::getInstance().getWindowState());
    ui->mainSplitter->restoreState(Settings::getInstance().getSplitterState());

    if (Settings::getInstance().getUseNativeDecoration())
    {
        ui->titleBar->hide();
        this->layout()->setContentsMargins(0, 0, 0, 0);

        ui->friendList->setObjectName("friendList");
        ui->friendList->setStyleSheet(Style::get(":ui/friendList/friendList.css"));
    }
    else
    {
        this->setObjectName("activeWindow");
        this->setStyleSheet(Style::get(":ui/window/window.css"));
        ui->statusPanel->setStyleSheet(QString(""));
        ui->friendList->setStyleSheet(QString(""));

        ui->friendList->setObjectName("friendList");
        ui->friendList->setStyleSheet(Style::get(":ui/friendList/friendList.css"));

        ui->tbMenu->setIcon(QIcon(":ui/window/applicationIcon.png"));
        ui->pbMin->setObjectName("minimizeButton");
        ui->pbMax->setObjectName("maximizeButton");
        ui->pbClose->setObjectName("closeButton");

        setWindowFlags(Qt::CustomizeWindowHint);
        setWindowFlags(Qt::FramelessWindowHint);

        addAction(ui->actionClose);

        connect(ui->pbMin, SIGNAL(clicked()), this, SLOT(minimizeBtnClicked()));
        connect(ui->pbMax, SIGNAL(clicked()), this, SLOT(maximizeBtnClicked()));
        connect(ui->pbClose, SIGNAL(clicked()), this, SLOT(close()));

        m_titleMode = FullTitle;
        moveWidget = false;
        inResizeZone = false;
        allowToResize = false;
        resizeVerSup = false;
        resizeHorEsq = false;
        resizeDiagSupEsq = false;
        resizeDiagSupDer = false;

        if (isMaximized())
        {
            showMaximized();
            ui->pbMax->setObjectName("restoreButton");
        }
    }

    isWindowMinimized = 0;

    ui->mainContent->setLayout(new QVBoxLayout());
    ui->mainHead->setLayout(new QVBoxLayout());
    ui->mainHead->layout()->setMargin(0);
    ui->mainHead->layout()->setSpacing(0);

    contactListWidget = new FriendListWidget();
    ui->friendList->setWidget(contactListWidget);
    ui->friendList->setLayoutDirection(Qt::RightToLeft);

    ui->nameLabel->setEditable(true);
    ui->statusLabel->setEditable(true);

    // delay setting username and message until Core inits
    //ui->nameLabel->setText(core->getUsername());
    ui->nameLabel->setStyleSheet("QLabel { color : white; font-size: 11pt; font-weight:bold;}");
    //ui->statusLabel->setText(core->getStatusMessage());
    ui->statusLabel->setStyleSheet("QLabel { color : white; font-size: 8pt;}");

    ui->statusButton->setStyleSheet(Style::get(":/ui/statusButton/statusButton.css"));

    QMenu *statusButtonMenu = new QMenu(ui->statusButton);
    QAction* setStatusOnline = statusButtonMenu->addAction(Widget::tr("Online","Button to set your status to 'Online'"));
    setStatusOnline->setIcon(QIcon(":ui/statusButton/dot_online.png"));
    QAction* setStatusAway = statusButtonMenu->addAction(Widget::tr("Away","Button to set your status to 'Away'"));
    setStatusAway->setIcon(QIcon(":ui/statusButton/dot_idle.png"));
    QAction* setStatusBusy = statusButtonMenu->addAction(Widget::tr("Busy","Button to set your status to 'Busy'"));
    setStatusBusy->setIcon(QIcon(":ui/statusButton/dot_busy.png"));
    ui->statusButton->setMenu(statusButtonMenu);

    ui->titleBar->setMouseTracking(true);
    ui->LTitle->setMouseTracking(true);
    ui->tbMenu->setMouseTracking(true);
    ui->pbMin->setMouseTracking(true);
    ui->pbMax->setMouseTracking(true);
    ui->pbClose->setMouseTracking(true);
    ui->statusHead->setMouseTracking(true);

    //ui->friendList->viewport()->installEventFilter(this);

    // disable proportional scaling
    ui->mainSplitter->setStretchFactor(0,0);
    ui->mainSplitter->setStretchFactor(1,1);

    ui->statusButton->setObjectName("offline");
    ui->statusButton->style()->polish(ui->statusButton);

    camera = new Camera;
    settingsDialog = new SettingsDialog(this);

    // Disable some widgets until we're connected to the DHT
    ui->statusButton->setEnabled(false);

    qRegisterMetaType<Status>("Status");
    qRegisterMetaType<vpx_image>("vpx_image");
    qRegisterMetaType<uint8_t>("uint8_t");
    qRegisterMetaType<int32_t>("int32_t");
    qRegisterMetaType<int64_t>("int64_t");
    qRegisterMetaType<ToxFile>("ToxFile");
    qRegisterMetaType<ToxFile::FileDirection>("ToxFile::FileDirection");

    coreThread = new QThread(this);
    core = new Core(camera, coreThread);
    core->moveToThread(coreThread);
    connect(coreThread, &QThread::started, core, &Core::start);

    connect(core, &Core::connected, this, &Widget::onConnected);
    connect(core, &Core::disconnected, this, &Widget::onDisconnected);
    connect(core, &Core::failedToStart, this, &Widget::onFailedToStartCore);
    connect(core, &Core::statusSet, this, &Widget::onStatusSet);
    connect(core, &Core::usernameSet, this, &Widget::setUsername);
    connect(core, &Core::statusMessageSet, this, &Widget::setStatusMessage);
    connect(core, SIGNAL(fileDownloadFinished(const QString&)), &filesForm, SLOT(onFileDownloadComplete(const QString&)));
    connect(core, SIGNAL(fileUploadFinished(const QString&)), &filesForm, SLOT(onFileUploadComplete(const QString&)));
    connect(core, &Core::friendAdded, this, &Widget::addFriend);
    connect(core, &Core::failedToAddFriend, this, &Widget::addFriendFailed);
    connect(core, &Core::friendStatusChanged, this, &Widget::onFriendStatusChanged);
    connect(core, &Core::friendUsernameChanged, this, &Widget::onFriendUsernameChanged);
    connect(core, &Core::friendStatusChanged, this, &Widget::onFriendStatusChanged);
    connect(core, &Core::friendStatusMessageChanged, this, &Widget::onFriendStatusMessageChanged);
    connect(core, &Core::friendUsernameLoaded, this, &Widget::onFriendUsernameLoaded);
    connect(core, &Core::friendStatusMessageLoaded, this, &Widget::onFriendStatusMessageLoaded);
    connect(core, &Core::friendRequestReceived, this, &Widget::onFriendRequestReceived);
    connect(core, &Core::friendMessageReceived, this, &Widget::onFriendMessageReceived);
    connect(core, &Core::groupInviteReceived, this, &Widget::onGroupInviteReceived);
    connect(core, &Core::groupMessageReceived, this, &Widget::onGroupMessageReceived);
    connect(core, &Core::groupNamelistChanged, this, &Widget::onGroupNamelistChanged);
    connect(core, &Core::emptyGroupCreated, this, &Widget::onEmptyGroupCreated);

    connect(this, &Widget::statusSet, core, &Core::setStatus);
    connect(this, &Widget::friendRequested, core, &Core::requestFriendship);
    connect(this, &Widget::friendRequestAccepted, core, &Core::acceptFriendRequest);

    connect(ui->addButton, SIGNAL(clicked()), this, SLOT(onAddClicked()));
    connect(ui->groupButton, SIGNAL(clicked()), this, SLOT(onGroupClicked()));
    connect(ui->transferButton, SIGNAL(clicked()), this, SLOT(onTransferClicked()));
    connect(ui->settingsButton, SIGNAL(clicked()), this, SLOT(onSettingsClicked()));
    connect(ui->nameLabel, SIGNAL(textChanged(QString,QString)), this, SLOT(onUsernameChanged(QString,QString)));
    connect(ui->statusLabel, SIGNAL(textChanged(QString,QString)), this, SLOT(onStatusMessageChanged(QString,QString)));
    connect(setStatusOnline, SIGNAL(triggered()), this, SLOT(setStatusOnline()));
    connect(setStatusAway, SIGNAL(triggered()), this, SLOT(setStatusAway()));
    connect(setStatusBusy, SIGNAL(triggered()), this, SLOT(setStatusBusy()));
    connect(&friendForm, SIGNAL(friendRequested(QString,QString)), this, SIGNAL(friendRequested(QString,QString)));

    coreThread->start();

    friendForm.show(*ui);
}
Beispiel #29
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;
	}
void MdiWindow::storeState()
{
	m_wasMaximized = isMaximized();
}