void MainWindow::changeEvent ( QEvent * event ){ if(event->type() == QEvent::WindowStateChange){ switch (windowState ()) { case Qt::WindowNoState: ui.actionShowMaximized->setEnabled(true); ui.actionShowFullScreen->setEnabled(true); ui.actionShowMinimized->setEnabled(true); ui.actionShowNormal->setEnabled(false); break; case Qt::WindowMinimized: ui.actionShowMaximized->setEnabled(true); ui.actionShowFullScreen->setEnabled(true); ui.actionShowMinimized->setEnabled(false); ui.actionShowNormal->setEnabled(true); break; case Qt::WindowMaximized: ui.actionShowMaximized->setEnabled(false); ui.actionShowFullScreen->setEnabled(true); ui.actionShowMinimized->setEnabled(true); ui.actionShowNormal->setEnabled(true); break; case Qt::WindowFullScreen: ui.actionShowMaximized->setEnabled(false); ui.actionShowFullScreen->setEnabled(false); ui.actionShowMinimized->setEnabled(true); ui.actionShowNormal->setEnabled(true); break; default: //TODO: Other State break; } event->accept(); } event->ignore(); }
void MainWindow::changeEvent(QEvent* event) { if (event->type() == QEvent::WindowStateChange) { QWindowStateChangeEvent* stateChangeEvent = static_cast<QWindowStateChangeEvent*>(event); if ((stateChangeEvent->oldState() == Qt::WindowNoState || stateChangeEvent->oldState() == Qt::WindowMaximized) && (windowState() & Qt::WindowMinimized) == Qt::WindowMinimized) { emit windowShown(false); emit windowMinimizedChanged(true); } else { emit windowShown(true); if ((stateChangeEvent->oldState() & Qt::WindowMinimized) == Qt::WindowMinimized) { emit windowMinimizedChanged(false); } } } else if (event->type() == QEvent::ActivationChange) { if (isActiveWindow()) { emit windowShown(true); } else { emit windowShown(false); } } QMainWindow::changeEvent(event); }
void MainWindow::changeEvent(QEvent* event) { if (event->type() == QEvent::WindowStateChange) { QWindowStateChangeEvent* stateChangeEvent = static_cast<QWindowStateChangeEvent*>(event); if ((stateChangeEvent->oldState() == Qt::WindowNoState || stateChangeEvent->oldState() == Qt::WindowMaximized) && windowState() == Qt::WindowMinimized) { emit windowShown(false); } else { emit windowShown(true); } if (isFullScreen() != Menu::getInstance()->isOptionChecked(MenuOption::Fullscreen)) { Menu::getInstance()->setIsOptionChecked(MenuOption::Fullscreen, isFullScreen()); } } else if (event->type() == QEvent::ActivationChange) { if (isActiveWindow()) { emit windowShown(true); } else { emit windowShown(false); } } QMainWindow::changeEvent(event); }
void MainWindow::setupSignalsSlots() { //signal-slot: //connect(_thread,SIGNAL(updateUI(QStringList)),this,SLOT(updateClients(QStringList)),Qt::QueuedConnection); qRegisterMetaType<QVector<Device*> >("QVector<Device*>"); connect(m_restoreAction, &QAction::triggered, this, [this](){ setMainWindowVisibility(isHidden() || windowState() == Qt::WindowMinimized || (qApp->applicationState() == Qt::ApplicationInactive)); }); connect(m_quitAction, &QAction::triggered, this, &MainWindow::close); connect(m_controlWifi,&QAction::triggered,this,&MainWindow::on_pushButton_clicked); connect(m_restartWifi,&QAction::triggered,this,[this](){ ui->pushButton->setText("Restaring..."); m_wifi->restartWifi(); ui->pushButton->setText("STOP"); }); connect(m_wthread,SIGNAL(clientAdd(QVector<Device *>)),this,SLOT(updateNewClients(QVector<Device*>)),Qt::QueuedConnection); connect(m_wthread,SIGNAL(clientLeave(QVector<Device *>)),this,SLOT(updateLeaveClients(QVector<Device*>)),Qt::QueuedConnection); connect(m_wthread,SIGNAL(clientUpdate(QVector<Device*>)),this,SLOT(updateDevicesList(QVector<Device*>)),Qt::QueuedConnection); }
bool Window::eventFilter(QObject *obj, QEvent *evt) { if (obj == App::app() && (evt->type() == QEvent::ApplicationActivate)) { QTimer::singleShot(1, this, SLOT(checkHistoryActivation())); } else if (obj == App::app() && (evt->type() == QEvent::FileOpen)) { QString url = static_cast<QFileOpenEvent*>(evt)->url().toEncoded(); if (!url.trimmed().midRef(0, 5).compare(qsl("tg://"), Qt::CaseInsensitive)) { cSetStartUrl(url); if (!cStartUrl().isEmpty() && App::main() && App::self()) { App::main()->openLocalUrl(cStartUrl()); cSetStartUrl(QString()); } } activate(); } else if (obj == this && evt->type() == QEvent::WindowStateChange) { Qt::WindowState state = (windowState() & Qt::WindowMinimized) ? Qt::WindowMinimized : ((windowState() & Qt::WindowMaximized) ? Qt::WindowMaximized : ((windowState() & Qt::WindowFullScreen) ? Qt::WindowFullScreen : Qt::WindowNoState)); psStateChanged(state); if (App::main()) { App::main()->mainStateChanged(state); } } else if (obj == this && (evt->type() == QEvent::Move || evt->type() == QEvent::Resize)) { psUpdatedPosition(); } return PsMainWindow::eventFilter(obj, evt); }
void bc_editor_app::changeEvent(QEvent* p_event) { if (p_event->type() == QEvent::WindowStateChange) { QWindowStateChangeEvent* l_window_state_event = static_cast<QWindowStateChangeEvent*>(p_event); m_d3d_widget->window_state_change_event(l_window_state_event, windowState()); } if (p_event->type() == QEvent::ActivationChange) { if (isActiveWindow()) { QFocusEvent l_focus_event(QEvent::FocusIn); focusInEvent(&l_focus_event); } else { QFocusEvent l_focus_event(QEvent::FocusOut); focusOutEvent(&l_focus_event); } } QWidget::changeEvent(p_event); }
KomposeFullscreenWidget::KomposeFullscreenWidget( int displayType, KomposeLayout *l ) : AbstractViewWidget( 0, l ) { // if ( QT_VERSION < 0x030300 ) /* use showMaximized instead of setWindowState to make it compile on qt 3.1 or whatever */ // showMaximized(); // KWin::setState( winId(), NET::KeepAbove ); // Set Desktop background as our background setBackgroundMode( Qt::FixedPixmap ); // setBackgroundPixmap(*(KomposeGlobal::self()->getDesktopBgPixmap())); rootpix = new KRootPixmap (this); rootpix->start(); m_menu = KomposeGlobal::self()->getViewMenu(); initView(); // Alternate showFullscreen setWindowState(windowState() | WindowFullScreen); if (KomposeSettings::self()->viewScreen() == -1) setGeometry( KGlobalSettings::desktopGeometry( this ) ); else { QDesktopWidget deskwidget; QRect deskRect = deskwidget.screenGeometry(KomposeSettings::self()->viewScreen()); setGeometry(deskRect); kdDebug() << deskRect << endl; } if (!isTopLevel()) QApplication::sendPostedEvents(this, QEvent::ShowFullScreen); setActiveWindow(); KWin::setOnAllDesktops( winId(), true ); }
void CustomWindow::resetPlatformWindow( QSurfaceFormat fmt ) { // qDebug() << "=====================" << __PRETTY_FUNCTION__ << "====================="; // Show the window if hidden if( !isVisible() ) { show(); } Qt::WindowState savedWindowState = windowState(); #if defined( Q_OS_WIN ) // Force into windowed mode to get proper position and size setWindowState( Qt::WindowNoState ); #elif defined( Q_OS_MACX ) // Force into windowed mode to get proper position and size // Don't do this if we're already fullscreen on OS X, it'll happen automatically if( !( savedWindowState & Qt::WindowFullScreen ) ) { setWindowState( Qt::WindowNoState ); } #endif QPoint savedPosition = position(); QSize savedSize = size(); #if defined( Q_OS_WIN ) // Destroy the window and force the context to be reloaded destroy(); #elif defined( Q_OS_MACX ) // Hide the window and force the QSG to reset it and its context hide(); #endif releaseResources(); setFormat( fmt ); show(); setPosition( savedPosition ); resize( savedSize ); #if defined( Q_OS_WIN ) setWindowState( savedWindowState ); #elif defined( Q_OS_MACX ) // On OS X, if fullscreen wait for animation to finish before going back // If you try to go to fullscreen during the animation, the system makes a denied sound and doesn't do anything // FIXME: What if the user tweaks their animation to be slower? // FIXME: This approach sucks either way if( savedWindowState & Qt::WindowFullScreen ) { QTimer::singleShot( 750, this, SLOT( showFullScreen() ) ); } #endif // qDebug() << "=========================================================="; }
void LasercakeGLWidget::toggle_fullscreen(bool fullscreen) { if(fullscreen) { setWindowState(windowState() | Qt::WindowFullScreen); } else { setWindowState(windowState() & ~Qt::WindowFullScreen); } }
void UIMachineWindowNormal::loadSettings() { /* Call to base-class: */ UIMachineWindow::loadSettings(); /* Get machine: */ CMachine m = machine(); /* Load extra-data settings: */ { /* Load window position settings: */ QString strPositionAddress = m_uScreenId == 0 ? QString("%1").arg(GUI_LastNormalWindowPosition) : QString("%1%2").arg(GUI_LastNormalWindowPosition).arg(m_uScreenId); QStringList strPositionSettings = m.GetExtraDataStringList(strPositionAddress); bool ok = !strPositionSettings.isEmpty(), max = false; int x = 0, y = 0, w = 0, h = 0; if (ok && strPositionSettings.size() > 0) x = strPositionSettings[0].toInt(&ok); else ok = false; if (ok && strPositionSettings.size() > 1) y = strPositionSettings[1].toInt(&ok); else ok = false; if (ok && strPositionSettings.size() > 2) w = strPositionSettings[2].toInt(&ok); else ok = false; if (ok && strPositionSettings.size() > 3) h = strPositionSettings[3].toInt(&ok); else ok = false; if (ok && strPositionSettings.size() > 4) max = strPositionSettings[4] == GUI_LastWindowState_Max; QRect ar = ok ? QApplication::desktop()->availableGeometry(QPoint(x, y)) : QApplication::desktop()->availableGeometry(this); /* If previous parameters were read correctly: */ if (ok) { /* If previous machine state is SAVED: */ if (m.GetState() == KMachineState_Saved) { /* Restore window size and position: */ m_normalGeometry = QRect(x, y, w, h); setGeometry(m_normalGeometry); } /* If previous machine state was not SAVED: */ else { /* Restore only window position: */ m_normalGeometry = QRect(x, y, width(), height()); setGeometry(m_normalGeometry); if (machineView()) machineView()->normalizeGeometry(false); } /* Maximize if needed: */ if (max) setWindowState(windowState() | Qt::WindowMaximized); } else { /* Normalize view early to the optimal size: */ if (machineView()) machineView()->normalizeGeometry(true); /* Move newly created window to the screen center: */ m_normalGeometry = geometry(); m_normalGeometry.moveCenter(ar.center()); setGeometry(m_normalGeometry); } /* Normalize view to the optimal size: */ if (machineView()) #ifdef Q_WS_X11 QTimer::singleShot(0, machineView(), SLOT(sltNormalizeGeometry())); #else /* Q_WS_X11 */ machineView()->normalizeGeometry(true); #endif } /* Load availability settings: */ { /* USB Stuff: */ const CUSBController &usbController = m.GetUSBController(); if ( usbController.isNull() || !usbController.GetEnabled() || !usbController.GetProxyAvailable()) { /* Hide USB menu: */ indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)->setHidden(true); } else { /* Toggle USB LED: */ indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)->setState( usbController.GetEnabled() ? KDeviceActivity_Idle : KDeviceActivity_Null); } } /* Load global settings: */ { VBoxGlobalSettings settings = vboxGlobal().settings(); menuBar()->setHidden(settings.isFeatureActive("noMenuBar")); statusBar()->setHidden(settings.isFeatureActive("noStatusBar")); if (statusBar()->isHidden()) m_pIdleTimer->stop(); } }
void LasercakeGLWidget::toggle_fullscreen() { setWindowState(windowState() ^ Qt::WindowFullScreen); }
// Get whether fullscreen is activated or not bool StelMainWindow::getFullScreen() const { return windowState().testFlag(Qt::WindowFullScreen); }
/** * Intercepte l'événement de fermeture pour contrôler que tous les onglets ont * été enregistrés. Montre une fenêtre de dialogue le cas échéant. */ void MainWindow::closeEvent(QCloseEvent *event) { /// nombre d'onglets à fermer int saved = 0; /// pour des raisons pratiques, stocke le dernier onglet non enregistré int n = 0; // vérifie s'il y a 0, 1 ou plus onglets non enregistrés for(int i = 0; i < tabWidget->count() && saved < 2; i++) { if(!((AbstractTabWidget*)(tabWidget->widget(i)))->isSaved()) { n = i; saved++; } } if(saved == 0) { // tous les onglets sont prêts à être fermés event->accept(); } else if(saved == 1) { // un seul onglet n'est pas enregistré if(((AbstractTabWidget*) tabWidget->widget(n))->confirmClose()) { event->accept(); } else { event->ignore(); return; } } else { // plus d'un onglet n'est pas enregistré // demande de confirmation de confirmation int ret = QMessageBox::warning(this, tr("Unsaved files"), tr("Some files are not saved. Are you sure to want to quit ?"), QMessageBox::SaveAll | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::SaveAll ); switch(ret) { case QMessageBox::SaveAll: // on sauvegarde tout for(int i=0; i<tabWidget->count(); i++) { ((AbstractTabWidget*) tabWidget->widget(i))->save(); } break; case QMessageBox::Discard: // on ignore : rien à faire, les onglets seront détruits à la fermeture break; default: // on annule event->ignore(); return; } } // sauvegarde des préférences de la fenêtre QSettings s; s.beginGroup("mainwindow"); if(windowState().testFlag(Qt::WindowMaximized)) { // fenêtre maximisée s.setValue("maximized", true); s.remove("size"); s.remove("position"); } else { // fenêtre non maximisée : on stocke position + taille s.setValue("size", size()); s.setValue("position", pos()); s.remove("maximized"); } // tooltips activés ou non s.setValue("tooltips", tooltipButton->isChecked()); // où se situe le dock de connexion s.setValue("maindock_area", dockWidgetArea(dockWidget)); s.setValue("maindock_size", dockWidget->size()); s.endGroup(); // fichiers récents s.beginWriteArray("recentfiles", recentFiles.size()); for(int i=0; i<recentFiles.size(); i++) { s.setArrayIndex(i); s.setValue("entry", recentFiles[i]); } s.endArray(); // on prend le soin de fermer toutes les connexions DbManager::closeAll(); event->accept(); }
void UIMachineWindowNormal::loadSettings() { /* Call to base-class: */ UIMachineWindow::loadSettings(); /* Load GUI customizations: */ { #ifndef VBOX_WS_MAC /* Update menu-bar visibility: */ menuBar()->setVisible(actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_T_Visibility)->isChecked()); #endif /* !VBOX_WS_MAC */ /* Update status-bar visibility: */ statusBar()->setVisible(actionPool()->action(UIActionIndexRT_M_View_M_StatusBar_T_Visibility)->isChecked()); m_pIndicatorsPool->setAutoUpdateIndicatorStates(statusBar()->isVisible() && uisession()->isRunning()); } /* Load window geometry: */ { /* Load extra-data: */ QRect geo = gEDataManager->machineWindowGeometry(machineLogic()->visualStateType(), m_uScreenId, vboxGlobal().managedVMUuid()); /* If we do have proper geometry: */ if (!geo.isNull()) { /* If previous machine-state was SAVED: */ if (machine().GetState() == KMachineState_Saved) { /* Restore window geometry: */ m_normalGeometry = geo; VBoxGlobal::setTopLevelGeometry(this, m_normalGeometry); } /* If previous machine-state was NOT SAVED: */ else { /* Restore only window position: */ m_normalGeometry = QRect(geo.x(), geo.y(), width(), height()); VBoxGlobal::setTopLevelGeometry(this, m_normalGeometry); /* And normalize to the optimal-size: */ normalizeGeometry(false /* adjust position */); } /* Maximize (if necessary): */ if (gEDataManager->machineWindowShouldBeMaximized(machineLogic()->visualStateType(), m_uScreenId, vboxGlobal().managedVMUuid())) setWindowState(windowState() | Qt::WindowMaximized); } /* If we do NOT have proper geometry: */ else { /* Get available geometry, for screen with (x,y) coords if possible: */ QRect availableGeo = !geo.isNull() ? gpDesktop->availableGeometry(QPoint(geo.x(), geo.y())) : gpDesktop->availableGeometry(this); /* Normalize to the optimal size: */ normalizeGeometry(true /* adjust position */); /* Move newly created window to the screen-center: */ m_normalGeometry = geometry(); m_normalGeometry.moveCenter(availableGeo.center()); VBoxGlobal::setTopLevelGeometry(this, m_normalGeometry); } /* Normalize to the optimal size: */ #ifdef VBOX_WS_X11 QTimer::singleShot(0, this, SLOT(sltNormalizeGeometry())); #else /* !VBOX_WS_X11 */ normalizeGeometry(true /* adjust position */); #endif /* !VBOX_WS_X11 */ } }
void lemon::setupActions() { KStandardAction::quit(this, SLOT(salir()), actionCollection()); //KStandardAction::quit(qApp, SLOT(quit()), actionCollection()); KStandardAction::preferences(this, SLOT(optionsPreferences()), actionCollection()); //Our actions QAction* loginAction = actionCollection()->addAction( "login" ); loginAction->setText(i18n("Login")); loginAction->setIcon(KIcon("office-address-book")); //identity loginAction->setShortcut(Qt::CTRL+Qt::Key_L); connect(loginAction, SIGNAL(triggered(bool)),m_view, SLOT(login())); QAction *corteCajaAction = actionCollection()->addAction("balance"); corteCajaAction->setText(i18nc("Account balance", "Balance")); corteCajaAction->setIcon(KIcon("lemon-balance")); corteCajaAction->setShortcut(Qt::CTRL+Qt::Key_B); connect(corteCajaAction, SIGNAL(triggered(bool)), m_view, SLOT(doCorteDeCaja())); QAction* enterCodeAction = actionCollection()->addAction( "enterCode" ); enterCodeAction->setText(i18n("Enter Code")); enterCodeAction->setIcon(KIcon("lemon-tag")); enterCodeAction->setShortcut(Qt::Key_F2); connect(enterCodeAction, SIGNAL(triggered(bool)),m_view, SLOT(showEnterCodeWidget())); QAction* searchItemAction = actionCollection()->addAction( "searchItem" ); searchItemAction->setText(i18n("Search Item")); searchItemAction->setIcon(KIcon("edit-find")); searchItemAction->setShortcut(Qt::Key_F3); connect(searchItemAction, SIGNAL(triggered(bool)),m_view, SLOT(showSearchItemWidget())); QAction* delSelectedItemAction = actionCollection()->addAction( "deleteSelectedItem" ); delSelectedItemAction->setText(i18n("Delete Selected Item")); delSelectedItemAction->setIcon(KIcon("lemon-boxcancel")); delSelectedItemAction->setShortcut(QKeySequence::ZoomOut); //Qt::Key_Delete Qt::Key_Control+Qt::Key_Delete QKeySequence::Cut QKeySequence::ZoomOut connect(delSelectedItemAction, SIGNAL(triggered(bool)),m_view, SLOT(deleteSelectedItem())); // ERROR: I dont know why, in my computer, instead of CTRL-Delete, the key assigned is Shift-( // The same for other non-working shortcuts. // Some problem related to different keyboard layout : qDebug()<<"shortcut:"<<delSelectedItemAction->shortcuts(); QAction* finishTransactionAction = actionCollection()->addAction( "finishTransaction" ); finishTransactionAction->setText(i18n("Finish transaction")); finishTransactionAction->setIcon(KIcon("lemon-transaction-accept")); finishTransactionAction->setShortcut(Qt::Key_F12); connect(finishTransactionAction, SIGNAL(triggered(bool)),m_view, SLOT(finishCurrentTransaction())); QAction* cancelTransactionAction = actionCollection()->addAction( "cancelTransaction" ); cancelTransactionAction->setText(i18n("Cancel transaction")); cancelTransactionAction->setIcon(KIcon("lemon-transaction-cancel")); cancelTransactionAction->setShortcut(Qt::Key_F10); connect(cancelTransactionAction, SIGNAL(triggered(bool)),m_view, SLOT(preCancelCurrentTransaction())); QAction* cancelSellAction = actionCollection()->addAction("cancelTicket"); cancelSellAction->setText(i18n("Cancel a ticket")); cancelSellAction->setIcon(KIcon("lemon-ticket-cancel") ); cancelSellAction->setShortcut(Qt::Key_F11); connect(cancelSellAction, SIGNAL(triggered(bool)),m_view, SLOT(askForIdToCancel())); //NOTE: This action is for setting how much money is on the drawer... QAction* startOperationAction = actionCollection()->addAction( "startOperation" ); startOperationAction->setText(i18n("Start Operation")); startOperationAction->setIcon(KIcon("window-new")); startOperationAction->setShortcut(QKeySequence::New); // New Qt::Key_Control+Qt::Key_N connect(startOperationAction, SIGNAL(triggered(bool)),m_view, SLOT(_slotDoStartOperation())); QAction *payFocusAction = actionCollection()->addAction("payFocus"); payFocusAction->setText(i18n("Pay focus")); payFocusAction->setIcon(KIcon("lemon-payfocus")); payFocusAction->setShortcut(Qt::Key_F4); //Qt::Key_Alt + Qt::Key_End connect(payFocusAction, SIGNAL(triggered(bool)),m_view, SLOT(focusPayInput())); QAction *showProdGridAction = actionCollection()->addAction("showProductsGrid"); showProdGridAction->setCheckable(true); showProdGridAction->setText(i18n("Show/Hide Products Grid")); showProdGridAction->setIcon(KIcon("view-split-top-bottom")); showProdGridAction->setShortcut(QKeySequence::Print); connect(showProdGridAction, SIGNAL(toggled(bool)), m_view, SLOT(showProductsGrid(bool))); qDebug()<<"Show Grid shortcut:"<<showProdGridAction->shortcuts(); QAction *showPriceCheckerAction = actionCollection()->addAction("showPriceChecker"); showPriceCheckerAction->setText(i18n("Show Price Checker")); showPriceCheckerAction->setIcon(KIcon("lemon-price-checker")); showPriceCheckerAction->setShortcut(Qt::Key_F9); connect(showPriceCheckerAction, SIGNAL(triggered(bool)), m_view, SLOT(showPriceChecker())); QAction *reprintTicketAction = actionCollection()->addAction("reprintTicket"); reprintTicketAction->setText(i18n("Reprint ticket")); reprintTicketAction->setIcon(KIcon("lemon-print-ticket")); reprintTicketAction->setShortcut(Qt::Key_F5); connect(reprintTicketAction, SIGNAL(triggered(bool)), m_view, SLOT(showReprintTicket())); QAction *cashOutAction = actionCollection()->addAction("cashOut"); cashOutAction->setText(i18n("Cash Out")); cashOutAction->setIcon(KIcon("lemon-cashout")); cashOutAction->setShortcut(Qt::Key_F7); //F7 connect(cashOutAction, SIGNAL(triggered(bool)), m_view, SLOT(cashOut())); QAction *cashAvailableAction = actionCollection()->addAction("cashAvailable"); cashAvailableAction->setText(i18n("Cash in drawer")); cashAvailableAction->setIcon(KIcon("lemon-money")); cashAvailableAction->setShortcut(Qt::Key_F6); connect(cashAvailableAction, SIGNAL(triggered(bool)), m_view, SLOT(cashAvailable())); QAction *cashInAction = actionCollection()->addAction("cashIn"); cashInAction->setText(i18n("Cash In")); cashInAction->setIcon(KIcon("lemon-cashin")); cashInAction->setShortcut(Qt::Key_F8); //F8 connect(cashInAction, SIGNAL(triggered(bool)), m_view, SLOT(cashIn())); QAction *endOfDayAction = actionCollection()->addAction("endOfDay"); endOfDayAction->setText(i18n("End of day report")); endOfDayAction->setIcon(KIcon("go-jump-today")); endOfDayAction->setShortcut(QKeySequence::Close); connect(endOfDayAction, SIGNAL(triggered(bool)), m_view, SLOT(endOfDay())); qDebug()<<"End of day shortcut:"<<endOfDayAction->shortcuts(); QAction *soAction = actionCollection()->addAction("specialOrder"); soAction->setText(i18n("Add Special Order")); soAction->setIcon(KIcon("lemon-box")); soAction->setShortcut(Qt::Key_PageUp); connect(soAction, SIGNAL(triggered(bool)), m_view, SLOT(addSpecialOrder())); qDebug()<<"SpecialOrder shortcut:"<<soAction->shortcuts(); QAction *socAction = actionCollection()->addAction("specialOrderComplete"); socAction->setText(i18n("Complete Special Order")); socAction->setIcon(KIcon("lemon-box")); socAction->setShortcut(Qt::Key_PageDown); connect(socAction, SIGNAL(triggered(bool)), m_view, SLOT(specialOrderComplete())); qDebug()<<"SpecialOrder Complete shortcut:"<<socAction->shortcuts(); QAction *lockAction = actionCollection()->addAction("lockScreen"); lockAction->setText(i18n("Lock Screen")); lockAction->setIcon(KIcon("lemon-box")); //TODO:CREATE ICON! lockAction->setShortcut(Qt::CTRL+Qt::Key_Space); connect(lockAction, SIGNAL(triggered(bool)), m_view, SLOT(lockScreen())); qDebug()<<"LockScreen shortcut:"<<lockAction->shortcuts(); QAction *suspendSaleAction = actionCollection()->addAction("suspendSale"); suspendSaleAction->setText(i18n("Suspend Sale")); suspendSaleAction->setIcon(KIcon("lemon-suspend")); suspendSaleAction->setShortcut(Qt::CTRL+Qt::Key_Backspace); connect(suspendSaleAction, SIGNAL(triggered(bool)), m_view, SLOT( suspendSale() )); qDebug()<<"Suspend Sale shortcut:"<<suspendSaleAction->shortcuts(); QAction *soStatusAction = actionCollection()->addAction("soStatus"); soStatusAction->setText(i18n("Change Special Order Status")); soStatusAction->setIcon(KIcon("lemon-box")); //TODO:CREATE ICON! soStatusAction->setShortcut(Qt::CTRL+Qt::Key_PageUp); connect(soStatusAction, SIGNAL(triggered(bool)), m_view, SLOT( changeSOStatus() )); qDebug()<<"soStatus shortcut:"<<soStatusAction->shortcuts(); QAction *oDiscAction = actionCollection()->addAction("occasionalDiscount"); oDiscAction->setText(i18n("Change Special Order Status")); oDiscAction->setIcon(KIcon("lemon-money")); //TODO:CREATE ICON! oDiscAction->setShortcut(Qt::CTRL+Qt::Key_D); connect(oDiscAction, SIGNAL(triggered(bool)), m_view, SLOT( occasionalDiscount() )); qDebug()<<"occasionalDiscount shortcut:"<<oDiscAction->shortcuts(); QAction *resumeAction = actionCollection()->addAction("resumeSale"); resumeAction->setText(i18n("Resume Sale")); resumeAction->setIcon(KIcon("lemon-resume")); resumeAction->setShortcut(Qt::CTRL+Qt::Key_R); connect(resumeAction, SIGNAL(triggered(bool)), m_view, SLOT( resumeSale() )); qDebug()<<"resumeSale shortcut:"<<resumeAction->shortcuts(); QAction *makeReservationA = actionCollection()->addAction("makeReservation"); makeReservationA->setText(i18n("Reserve Items")); makeReservationA->setIcon(KIcon("lemon-box")); //TODO:CREATE ICON! makeReservationA->setShortcut(Qt::ALT + Qt::Key_R); // Qt::ALT is the left ALT key ( not the Alt Gr ) connect(makeReservationA, SIGNAL(triggered(bool)), m_view, SLOT( reserveItems() )); qDebug()<<"makeReservation shortcut:"<<makeReservationA->shortcuts(); QAction *resumeRAction = actionCollection()->addAction("resumeReservation"); resumeRAction->setText(i18n("Reservations")); resumeRAction->setIcon(KIcon("lemon-box")); //TODO:CREATE ICON! resumeRAction->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_R); connect(resumeRAction, SIGNAL(triggered(bool)), m_view, SLOT( resumeReservation() )); qDebug()<<"Reservations shortcut:"<<resumeRAction->shortcuts(); QAction *showCreditsAction = actionCollection()->addAction("showCredits"); showCreditsAction->setText(i18n("Show Credits")); showCreditsAction->setIcon(KIcon("lemon-credits")); showCreditsAction->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_C); connect(showCreditsAction, SIGNAL(triggered(bool)), m_view, SLOT( showCredits() )); qDebug()<<"ShowCredits shortcut:"<<showCreditsAction->shortcuts(); setupGUI(); //FIXME: SCREEN SIZE setWindowState( windowState() | Qt::WindowFullScreen ); // set //setGeometry(QApplication::desktop()->screenGeometry(this)); if (!Settings::splitterSizes().isEmpty()) m_view->setTheSplitterSizes(Settings::splitterSizes()); if (!Settings::gridSplitterSizes().isEmpty()) m_view->setTheGridSplitterSizes(Settings::gridSplitterSizes()); }
TinyMainWindow::TinyMainWindow(QWidget *parent) : BasicMainWindow(parent), ui(new Ui::TinyMainWindow) { ui->setupUi(this); setWindowFlags(Qt::Window | Qt::FramelessWindowHint); setAttribute(Qt::WA_QuitOnClose); setWindowState(windowState() | Qt::WindowFullScreen); pv->release_mouse_event = false; pv->status_label1 = new QLabel(); ui->statusBar->addWidget(pv->status_label1, 1); pv->status_label2 = new QLabel(); ui->statusBar->addWidget(pv->status_label2, 0); pv->status_label3 = new QLabel(); ui->statusBar->addWidget(pv->status_label3, 0); #if 0 //def Q_OS_WIN priv->folder_icon = QIcon(":/image/winfolder.png"); #else pv->folder_icon = QIcon(":/image/macfolder.png"); #endif { QString ss = makeStyleSheetText(); setStyleSheet(ss); } #ifdef Q_OS_MAC #else ui->action_help_about->setText(tr("&About SkyMPC")); #endif pv->menu.addAction(ui->action_help_about); pv->menu.addAction(ui->action_debug); setRepeatEnabled(false); setRandomEnabled(false); if (!start_with_shift_key) { MySettings settings; settings.beginGroup("Connection"); QString addr = settings.value("Address").toString(); int port = settings.value("Port").toInt(); QString password = settings.value("Password").toString(); settings.endGroup(); pv->host = Host(addr, port); pv->host.setPassword(password); } #if 0 pv->command_action_map["random"] = ui->action_random; pv->command_action_map["repeat"] = ui->action_repeat; pv->command_action_map["play"] = ui->action_play_always; pv->command_action_map["stop"] = ui->action_stop; pv->command_action_map["prev"] = ui->action_previous; pv->command_action_map["next"] = ui->action_next; pv->command_action_map["single"] = ui->action_single; pv->command_action_map["exit"] = ui->action_file_close; pv->command_action_map["vu"] = ui->action_volume_up; pv->command_action_map["vd"] = ui->action_volume_down; pv->command_action_map["qs1"] = ui->action_playlist_quick_save_1; pv->command_action_map["qs2"] = ui->action_playlist_quick_save_2; pv->command_action_map["ql1"] = ui->action_playlist_quick_load_1; pv->command_action_map["ql2"] = ui->action_playlist_quick_load_2; pv->command_action_map["clear"] = ui->action_playlist_clear; // priv->key_command_map[Qt::Key_P] = "play"; // priv->key_command_map[Qt::Key_S] = "stop"; #endif }
void ConnectionEditor::activateAndRaise() { setWindowState((windowState() & ~Qt::WindowMinimized) | Qt::WindowActive); }
void Main::restaura() { setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive); this->show(); this->setFocus(Qt::ShortcutFocusReason); this->show(); }
void ImageViewer::contextMenuEvent(QContextMenuEvent *event) { if (!m_flipbook) return; QAction *action; if (m_isColorModel) { event->ignore(); return; } QMenu *menu = new QMenu(this); if (m_flipbook->getPreviewedFx()) { if (!(windowState() & Qt::WindowFullScreen)) { action = menu->addAction(tr("Clone Preview")); action->setShortcut(QKeySequence( CommandManager::instance()->getKeyFromId(MI_ClonePreview))); connect(action, SIGNAL(triggered()), m_flipbook, SLOT(clonePreview())); } if (m_flipbook->isFreezed()) { action = menu->addAction(tr("Unfreeze Preview")); action->setShortcut(QKeySequence( CommandManager::instance()->getKeyFromId(MI_FreezePreview))); connect(action, SIGNAL(triggered()), m_flipbook, SLOT(unfreezePreview())); } else { action = menu->addAction(tr("Freeze Preview")); action->setShortcut(QKeySequence( CommandManager::instance()->getKeyFromId(MI_FreezePreview))); connect(action, SIGNAL(triggered()), m_flipbook, SLOT(freezePreview())); } action = menu->addAction(tr("Regenerate Preview")); action->setShortcut(QKeySequence( CommandManager::instance()->getKeyFromId(MI_RegeneratePreview))); connect(action, SIGNAL(triggered()), m_flipbook, SLOT(regenerate())); action = menu->addAction(tr("Regenerate Frame Preview")); action->setShortcut(QKeySequence( CommandManager::instance()->getKeyFromId(MI_RegenerateFramePr))); connect(action, SIGNAL(triggered()), m_flipbook, SLOT(regenerateFrame())); menu->addSeparator(); } action = menu->addAction(tr("Load / Append Images")); connect(action, SIGNAL(triggered()), m_flipbook, SLOT(loadImages())); // history of the loaded paths of flipbook action = CommandManager::instance()->getAction(MI_LoadRecentImage); menu->addAction(action); action->setParent(m_flipbook); if (m_flipbook->isSavable()) { action = menu->addAction(tr("Save Images")); connect(action, SIGNAL(triggered()), m_flipbook, SLOT(saveImages())); } menu->addSeparator(); QAction *reset = menu->addAction(tr("Reset View")); reset->setShortcut( QKeySequence(CommandManager::instance()->getKeyFromId(V_ZoomReset))); connect(reset, SIGNAL(triggered()), SLOT(resetView())); QAction *fit = menu->addAction(tr("Fit To Window")); fit->setShortcut( QKeySequence(CommandManager::instance()->getKeyFromId(V_ZoomFit))); connect(fit, SIGNAL(triggered()), SLOT(fitView())); #ifdef _WIN32 if (ImageUtils::FullScreenWidget *fsWidget = dynamic_cast<ImageUtils::FullScreenWidget *>(parentWidget())) { bool isFullScreen = (fsWidget->windowState() & Qt::WindowFullScreen) != 0; action = menu->addAction(isFullScreen ? tr("Exit Full Screen Mode") : tr("Full Screen Mode")); action->setShortcut(QKeySequence( CommandManager::instance()->getKeyFromId(V_ShowHideFullScreen))); connect(action, SIGNAL(triggered()), fsWidget, SLOT(toggleFullScreen())); } #endif bool addedSep = false; if (m_isHistogramEnable && visibleRegion().contains(event->pos() * getDevPixRatio())) { menu->addSeparator(); addedSep = true; action = menu->addAction(tr("Show Histogram")); connect(action, SIGNAL(triggered()), SLOT(showHistogram())); } if (m_visualSettings.m_doCompare) { if (!addedSep) menu->addSeparator(); action = menu->addAction(tr("Swap Compared Images")); connect(action, SIGNAL(triggered()), SLOT(swapCompared())); } menu->exec(event->globalPos()); action = CommandManager::instance()->getAction(MI_LoadRecentImage); action->setParent(0); delete menu; update(); }
void PhotoView::toggleFullscreen() { setWindowState( windowState() ^ Qt::WindowFullScreen ); }
QString configTreeView::loadINI() { QSettings settings(QApplication::applicationDirPath() + "/ananas-designer.ini", QSettings::IniFormat); QString projectName; settings.beginGroup("Options"); QString s = settings.value("m_font", m_font.toString()).toString(); m_font.fromString(s); m_tabStopWidth = settings.value("m_tabStopWidth", m_tabStopWidth).toInt(); m_cppHighlighter = settings.value("m_cppHighlighter", m_cppHighlighter).toBool(); m_automaticCompilation = settings.value("m_automaticCompilation", m_automaticCompilation).toBool(); m_lineNumbers = settings.value("m_lineNumbers", m_lineNumbers).toBool(); m_autoIndent = settings.value("m_autoIndent", m_autoIndent).toBool(); m_autoCompletion = settings.value("m_autoCompletion", m_autoCompletion).toBool(); m_autobrackets = settings.value("m_autobrackets", m_autobrackets).toBool(); // Divius: comments autoclose m_autocomments = settings.value("m_autocomments", m_autocomments).toBool(); // m_selectionBorder = settings.value("m_selectionBorder", m_selectionBorder).toBool(); m_saveBeforeBuild = settings.value("m_saveBeforeBuild", m_saveBeforeBuild).toBool(); m_restoreOnStart = settings.value("m_restoreOnStart", m_restoreOnStart).toBool(); m_promptBeforeQuit = settings.value("m_promptBeforeQuit", m_promptBeforeQuit).toBool(); m_checkEnvironmentOnStartup = settings.value("m_checkEnvironmentOnStartup", m_checkEnvironmentOnStartup).toBool(); m_autoMaskDocks = settings.value("m_autoMaskDocks", m_autoMaskDocks).toBool(); m_endLine = (EndLine)settings.value("m_endLine", m_endLine).toInt(); m_tabSpaces = settings.value("m_tabSpaces", m_tabSpaces).toBool(); m_match = settings.value("m_match", m_match).toBool(); m_highlightCurrentLine = settings.value("m_highlightCurrentLine", m_highlightCurrentLine).toBool(); m_backgroundColor = QColor(settings.value("m_backgroundColor", m_backgroundColor).toString()); m_textColor = QColor(settings.value("m_textColor", m_textColor).toString()); m_currentLineColor = QColor(settings.value("m_currentLineColor", m_currentLineColor).toString()); m_matchingColor = QColor(settings.value("m_matchingColor", m_matchingColor).toString()); m_projectsDirectory = settings.value("m_projectsDirectory", m_projectsDirectory).toString(); m_pluginsDirectory = settings.value("m_pluginsDirectory", m_pluginsDirectory).toString(); m_includeDirectory = settings.value("m_includeDirectory", m_includeDirectory).toString(); m_documentationDirectory = settings.value("m_documentationDirectory", m_documentationDirectory).toString(); m_makeOptions = settings.value("m_makeOptions", m_makeOptions).toString(); m_showTreeClasses = settings.value("m_showTreeClasses", m_showTreeClasses).toBool(); m_closeButtonInTabs = settings.value("m_closeButtonInTabs", m_closeButtonInTabs).toBool(); m_displayEditorToolbars = settings.value("m_displayEditorToolbars", m_displayEditorToolbars).toBool(); //slotUpdateOtherFileActions(); m_displayWhiteSpaces = settings.value("m_displayWhiteSpaces", m_displayWhiteSpaces).toBool(); m_rightMarginLine = settings.value("m_rightMarginLine", m_rightMarginLine).toInt(); m_wordWrap = settings.value("m_wordWrap", m_wordWrap).toBool(); m_hideFindReplace = settings.value("m_hideFindReplace", m_hideFindReplace).toInt(); m_smartClick = settings.value("m_smartClick", m_smartClick).toBool(); //if( !QDir().exists(m_includeDirectory) ) //{ // QMessageBox::warning(0, // "Ananas-designer", tr("The Qt include directory doesn't exist,\nYou can change in Options dialog."), tr("Ok") ); // // } //setCrossButton( !m_closeButtonInTabs ); m_intervalUpdatingClasses = settings.value("m_intervalUpdatingClasses", m_intervalUpdatingClasses).toInt(); if ( m_currentLineColor == Qt::black ) m_currentLineColor = QColor(); m_mibCodec = settings.value("m_mibCodec", m_mibCodec).toInt(); // m_formatPreprocessorText.setForeground( QColor(settings.value("m_formatPreprocessorText", m_formatPreprocessorText.foreground().color().name()).toString() ) ); m_formatQtText.setForeground( QColor(settings.value("m_formatQtText", m_formatQtText.foreground().color().name()).toString() ) ); m_formatSingleComments.setForeground( QColor(settings.value("m_formatSingleComments", m_formatSingleComments.foreground().color().name()).toString() ) ); m_formatMultilineComments.setForeground( QColor(settings.value("m_formatMultilineComments", m_formatMultilineComments.foreground().color().name()).toString() ) ); m_formatQuotationText.setForeground( QColor(settings.value("m_formatQuotationText", m_formatQuotationText.foreground().color().name()).toString() ) ); m_formatMethods.setForeground( QColor(settings.value("m_formatMethods", m_formatMethods.foreground().color().name()).toString() ) ); m_formatKeywords.setForeground( QColor(settings.value("m_formatKeywords", m_formatKeywords.foreground().color().name()).toString() ) ); //actionEditor_mode->setChecked( settings.value("editorMode", actionEditor_mode->isChecked()).toBool() ); settings.endGroup(); /* TODO if (!m_showTreeClasses) //ToolsOptions/General tabExplorer->setTabToolTip( 1, tr("Classes explorer is disabled, please enable it in the Options dialog") ); else tabExplorer->setTabToolTip( 1, "" ); */ //m_assistant->setdocumentationDirectory( m_documentationDirectory ); // Load shortcuts settings.beginGroup("Shortcuts"); QList<QObject*> childrens; childrens = children(); QListIterator<QObject*> iterator(childrens); while ( iterator.hasNext() ) { QObject *object = iterator.next(); QAction *action = qobject_cast<QAction*>(object); if ( (action) && (!(action->data().toString().contains( "Recent|" ))) && (!action->objectName().isEmpty()) ) { QString text = object->objectName(); if ( !text.isEmpty() ) { QString shortcut = action->shortcut(); shortcut = settings.value(text, shortcut).toString(); action->setShortcut( shortcut ); } } } settings.endGroup(); if ( m_restoreOnStart ) { settings.beginGroup("Project"); projectName = settings.value("absoluteNameProjectFile").toString(); settings.endGroup(); } // settings.beginGroup("mainwindowstate"); #ifdef Q_OS_WIN32 // Restores position, size and state for both normal and maximized/fullscreen state. Problems reported unter X11. // See Qt doc: Geometry: Restoring a Window's Geometry for details. restoreGeometry(settings.value("geometry", saveGeometry()).toByteArray()); // Window geometry and state. #else // Restores position, size and state including maximized/fullscreen. move(settings.value("pos", pos()).toPoint()); // Window position. resize(settings.value("size", size()).toSize()); // Window size. // Note: Yes, the window can be maximized and fullscreen! if (settings.value("maximized", isMaximized()).toBool()) // Window maximized. setWindowState(windowState() | Qt::WindowMaximized); if (settings.value("fullscreen", isFullScreen()).toBool()) // Window fullscreen. setWindowState(windowState() | Qt::WindowFullScreen); #endif //restoreState(settings.value("state", saveState()).toByteArray()); // Toolbar and DockWidget state. settings.endGroup(); //settings.beginGroup("editormode"); //QList<QDockWidget*> dockWidgets = findChildren<QDockWidget*>(); //foreach( QWidget *w, dockWidgets ) // toolbarStatus[w] = settings.value(w->objectName(),w->isVisible()).toBool(); //settings.endGroup(); return projectName; }
void MainWindow::showFront() { show(); setWindowState((windowState() & ~Qt::WindowMinimized) | Qt::WindowActive); show(); }
KrViewer::KrViewer(QWidget *parent) : KParts::MainWindow(parent, (Qt::WindowFlags)KDE_DEFAULT_WINDOWFLAGS), manager(this, this), tabBar(this), reservedKeys(), reservedKeyActions(), sizeX(-1), sizeY(-1) { //setWFlags(Qt::WType_TopLevel | WDestructiveClose); setXMLFile("krviewer.rc"); // kpart-related xml file setHelpMenuEnabled(false); connect(&manager, SIGNAL(activePartChanged(KParts::Part*)), this, SLOT(createGUI(KParts::Part*))); connect(&tabBar, &QTabWidget::currentChanged, this, &KrViewer::tabChanged); connect(&tabBar, SIGNAL(tabCloseRequested(int)), this, SLOT(tabCloseRequest(int))); tabBar.setDocumentMode(true); tabBar.setMovable(true); setCentralWidget(&tabBar); printAction = KStandardAction::print(this, SLOT(print()), 0); copyAction = KStandardAction::copy(this, SLOT(copy()), 0); viewerMenu = new QMenu(this); QAction *tempAction; KActionCollection *ac = actionCollection(); #define addCustomMenuAction(name, text, slot, shortcut)\ tempAction = ac->addAction(name, this, slot);\ tempAction->setText(text);\ ac->setDefaultShortcut(tempAction, shortcut);\ viewerMenu->addAction(tempAction); addCustomMenuAction("genericViewer", i18n("&Generic Viewer"), SLOT(viewGeneric()), Qt::CTRL + Qt::SHIFT + Qt::Key_G); addCustomMenuAction("textViewer", i18n("&Text Viewer"), SLOT(viewText()), Qt::CTRL + Qt::SHIFT + Qt::Key_T); addCustomMenuAction("hexViewer", i18n("&Hex Viewer"), SLOT(viewHex()), Qt::CTRL + Qt::SHIFT + Qt::Key_H); addCustomMenuAction("lister", i18n("&Lister"), SLOT(viewLister()), Qt::CTRL + Qt::SHIFT + Qt::Key_L); viewerMenu->addSeparator(); addCustomMenuAction("textEditor", i18n("Text &Editor"), SLOT(editText()), Qt::CTRL + Qt::SHIFT + Qt::Key_E); viewerMenu->addSeparator(); QList<QAction *> actList = menuBar()->actions(); bool hasPrint = false, hasCopy = false; foreach(QAction *a, actList) { if (a->shortcut().matches(printAction->shortcut()) != QKeySequence::NoMatch) hasPrint = true; if (a->shortcut().matches(copyAction->shortcut()) != QKeySequence::NoMatch) hasCopy = true; } QAction *printAct = viewerMenu->addAction(printAction->icon(), printAction->text(), this, SLOT(print())); if (hasPrint) printAct->setShortcut(printAction->shortcut()); QAction *copyAct = viewerMenu->addAction(copyAction->icon(), copyAction->text(), this, SLOT(copy())); if (hasCopy) copyAct->setShortcut(copyAction->shortcut()); viewerMenu->addSeparator(); configKeysAction = ac->addAction(KStandardAction::KeyBindings, this, SLOT(configureShortcuts())); viewerMenu->addAction(configKeysAction); viewerMenu->addSeparator(); detachAction = ac->addAction("detachTab", this, SLOT(detachTab())); detachAction->setText(i18n("&Detach Tab")); //no point in detaching only one tab.. detachAction->setEnabled(false); ac->setDefaultShortcut(detachAction, Qt::META + Qt::Key_D); viewerMenu->addAction(detachAction); quitAction = ac->addAction(KStandardAction::Quit, this, SLOT(close())); viewerMenu->addAction(quitAction); tabCloseAction = ac->addAction("closeTab", this, SLOT(tabCloseRequest())); tabCloseAction->setText(i18n("&Close Current Tab")); QList<QKeySequence> shortcuts = KStandardShortcut::close(); shortcuts.append(Qt::Key_Escape); ac->setDefaultShortcuts(tabCloseAction, shortcuts); tabNextAction = ac->addAction("nextTab", this, SLOT(nextTab())); tabNextAction->setText(i18n("&Next Tab")); ac->setDefaultShortcuts(tabNextAction, KStandardShortcut::tabNext()); tabPrevAction = ac->addAction("prevTab", this, SLOT(prevTab())); tabPrevAction->setText(i18n("&Previous Tab")); ac->setDefaultShortcuts(tabPrevAction, KStandardShortcut::tabPrev()); tabBar.setTabsClosable(true); checkModified(); KConfigGroup group(krConfig, "KrViewerWindow"); int sx = group.readEntry("Window Width", -1); int sy = group.readEntry("Window Height", -1); if (sx != -1 && sy != -1) resize(sx, sy); else resize(900, 700); if (group.readEntry("Window Maximized", false)) { setWindowState(windowState() | Qt::WindowMaximized); } // filtering out the key events menuBar() ->installEventFilter(this); }
connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject())); dialog->setLayout(layout); return dialog; } void MainWindow::open() { QStringList list = QFileDialog::getOpenFileNames(0, tr("Open files"), QDir::homePath(), PaintWorkspace::getFilenameFilter()); foreach(QString str, list) { open(str); } setWindowState(Qt::WindowActive | windowState()); } void MainWindow::save() { PaintWorkspace *wsp = getCurrentWorkspace(); if (wsp) { wsp->save(); } setWindowState(Qt::WindowActive | windowState()); } void MainWindow::saveAs()
GNSSView::GNSSView(QStringList & args) { fullScreen=true; for (int i=1;i<args.size();i++){ // skip the first if (args.at(i) == "--nofullscreen") fullScreen=false; else if (args.at(i) == "--help"){ std::cout << "gnssview " << std::endl; std::cout << "Usage: gnssview [options]" << std::endl; std::cout << std::endl; std::cout << "--help print this help" << std::endl; std::cout << "--license print this help" << std::endl; std::cout << "--nofullscreen run in a window" << std::endl; std::cout << "--version display version" << std::endl; exit(EXIT_SUCCESS); } else if (args.at(i) == "--license"){ std::cout << " gnssview - a program for displaying GNSS satellite paths" << std::endl; std::cout << std::endl; std::cout << " The MIT License (MIT)" << std::endl; std::cout << std::endl; std::cout << " Copyright (c) 2014 Michael J. Wouters" << std::endl; std::cout << std::endl; std::cout << " Permission is hereby granted, free of charge, to any person obtaining a copy" << std::endl; std::cout << " of this software and associated documentation files (the \"Software\"), to deal" << std::endl; std::cout << " in the Software without restriction, including without limitation the rights" << std::endl; std::cout << " to use, copy, modify, merge, publish, distribute, sublicense, and/or sell" << std::endl; std::cout << " copies of the Software, and to permit persons to whom the Software is" << std::endl; std::cout << " furnished to do so, subject to the following conditions:" << std::endl; std::cout << std::endl; std::cout << " The above copyright notice and this permission notice shall be included in" << std::endl; std::cout << " all copies or substantial portions of the Software." << std::endl; std::cout << std::endl; std::cout << " THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR" << std::endl; std::cout << " IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY," << std::endl; std::cout << " FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE" << std::endl; std::cout << " AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER" << std::endl; std::cout << " LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM," << std::endl; std::cout << " OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN" << std::endl; std::cout << " THE SOFTWARE." << std::endl; exit(EXIT_SUCCESS); } else if (args.at(i) == "--version"){ std::cout << "gnssview " << VERSION_INFO << std::endl; std::cout << std::endl; std::cout << "This ain't no stinkin' Perl script!" << std::endl; exit(EXIT_SUCCESS); } else{ std::cout << "gnssview: Unknown option '"<< args.at(i).toStdString() << "'" << std::endl; std::cout << "gnssview: Use --help to get a list of available command line options"<< std::endl; exit(EXIT_SUCCESS); } } setWindowTitle(tr("gnssview")); setMinimumSize(QSize(1920,1080)); if (fullScreen) setWindowState(windowState() ^ Qt::WindowFullScreen); setMouseTracking(true); // so that mouse movements wake up the display QCursor curs; curs.setShape(Qt::BlankCursor); setCursor(curs); cursor().setPos(0,0); QTime on(7,0,0); QTime off(19,0,0); powerManager=new PowerManager(on,off); powerManager->enable(false); latitude=-33.87; longitude=151.21; address=""; port=-1; // Note: readConfig needs 'view' QVBoxLayout * vb = new QVBoxLayout(this); vb->setContentsMargins(0,0,0,0); view = new GNSSViewWidget(NULL,&birds); vb->addWidget(view); QString config = app->locateResource("gnssview.xml"); if (!config.isNull()) readConfig(config); view->setLocation(latitude,longitude); createActions(); setContextMenuPolicy(Qt::CustomContextMenu); connect(this,SIGNAL(customContextMenuRequested ( const QPoint & )),this,SLOT(createContextMenu(const QPoint &))); udpSocket = new QUdpSocket(this); udpSocket->bind(port,QUdpSocket::ShareAddress); // Start of flimflummery // Newer versions of Qt support this but for the moment we'll do it the Unix way int socketfd = udpSocket->socketDescriptor(); if (socketfd != -1){ ip_mreq mreq; memset(&mreq,0,sizeof(ip_mreq)); mreq.imr_multiaddr.s_addr = inet_addr(address.toStdString().c_str()); // group addr mreq.imr_interface.s_addr = htons(INADDR_ANY); // use default //Make this a member of the Multicast Group if(setsockopt(socketfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const void *)&mreq,sizeof(mreq)) < 0){ qDebug("Failed to add to multicast group"); } // set TTL (Time To Live) unsigned int ttl = 38; // restricted to 38 hops if (setsockopt(socketfd, IPPROTO_IP, IP_MULTICAST_TTL, (const char *)&ttl, sizeof(ttl) ) < 0){ qDebug("Failed to set TTL"); } } else{ qDebug() << "Bad socket fd!"; } // End of flimflummery connect(udpSocket, SIGNAL(readyRead()),this, SLOT(readPendingDatagrams())); updateTimer = new QTimer(this); connect(updateTimer,SIGNAL(timeout()),this,SLOT(updateView())); QDateTime now = QDateTime::currentDateTime(); updateTimer->start(1000-now.time().msec()); }
void MainWindow::closeEvent(QCloseEvent *) { Config.setValue("WindowSize", size()); Config.setValue("WindowPosition", pos()); Config.setValue("WindowState", (int)windowState()); }
void MdiWindow::mouseReleaseEvent(QMouseEvent *event) { QStyleOptionTitleBar option; option.initFrom(this); option.titleBarFlags = windowFlags(); option.titleBarState = windowState(); option.subControls = QStyle::SC_All; option.activeSubControls = QStyle::SC_None; if (!isMinimized()) { option.rect.setHeight(height() - widget()->height()); } if (!isMaximized() && style()->subControlRect(QStyle::CC_TitleBar, &option, QStyle::SC_TitleBarMaxButton, this).contains(event->pos())) { setWindowFlags(Qt::SubWindow | Qt::CustomizeWindowHint | Qt::FramelessWindowHint); showMaximized(); SessionsManager::markSessionModified(); } else if (!isMinimized() && style()->subControlRect(QStyle::CC_TitleBar, &option, QStyle::SC_TitleBarMinButton, this).contains(event->pos())) { const QList<QMdiSubWindow*> subWindows = mdiArea()->subWindowList(); int activeSubWindows = 0; for (int i = 0; i < subWindows.count(); ++i) { if (!subWindows.at(i)->isMinimized()) { ++activeSubWindows; } } storeState(); setWindowFlags(Qt::SubWindow); showMinimized(); if (activeSubWindows == 1) { MainWindow *mainWindow = MainWindow::findMainWindow(mdiArea()); if (mainWindow) { mainWindow->getWindowsManager()->setActiveWindowByIndex(-1); } else { mdiArea()->setActiveSubWindow(NULL); } } else if (activeSubWindows > 1) { ActionsManager::triggerAction(ActionsManager::ActivatePreviouslyUsedTabAction, mdiArea()); } SessionsManager::markSessionModified(); } else if (isMinimized()) { restoreState(); } QMdiSubWindow::mouseReleaseEvent(event); }
//事件过滤器, 现在用于响应标题栏的鼠标事件,目的在于拖动窗口和双击窗口最大化的功能 bool WidgetMain::eventFilter(QObject *target, QEvent *event) { if(target == widgetMove || target == labelLogo || pushButtonInfor == target) { QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); switch(event->type()) { case QEvent::MouseButtonPress: { if(Qt::LeftButton == mouseEvent->button()) { //获取屏幕左上角坐标与软件左上角坐标的偏移 offset_ = mouseEvent->globalPos() - frameGeometry().topLeft(); return true; } else { return false; } break; } case QEvent::MouseMove: { if (Qt::LeftButton == mouseEvent->buttons() ) { move(mouseEvent->globalPos() - offset_); return true; } else { return false; } break; } case QEvent::MouseButtonDblClick: { if (Qt::LeftButton == mouseEvent->button() && mouseEvent->y() <= widgetMove->height()) { if(windowState() != Qt::WindowFullScreen) { this->setWindowState(Qt::WindowFullScreen); } else { this->setWindowState(Qt::WindowNoState); } return true; } else { return false; } break; } default: { //... break; } return true; } } else if(pDustbin_ == target) { if(QEvent::MouseButtonPress == event->type()) { //在这里进行删除处理 if(FOCUS_GROUP == type_) { if(!groupName_.isEmpty()) { Q_EMIT signalDeleteGroup(groupName_); clearDustbinData(); } } else if(FOCUS_LINE == type_) { if(pFlowLine_ && !startName_.isEmpty() && !endName_.isEmpty()) { pFlowLine_->deleteLine(); clearDustbinData(); } } else { qDebug() << "没有要删除的类型, 哪里赋值错了么?" << type_; } event->accept(); return true; } else { event->ignore(); return false; } } else if(widgetLeft == target) { if(QEvent::Resize == event->type() || QEvent::Show) { //这里move if(NULL != pSerialSetting_) { pSerialSetting_->move(widgetLeft->width()+5, widgetTitle->height()+3); } if(NULL != pFunctionArea_) { pFunctionArea_->move(splitter->sizes().at(0) + (widgetOption->width()-pFunctionArea_->width())/2, 31); } event->accept(); return true; } else { event->ignore(); return false; } } else if(pBackStart_ == target) { QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); if(QEvent::MouseButtonPress == mouseEvent->type()) { qDebug() << "啊被按住了~~"; pEditScene_->backStart(); event->accept(); pBackStart_->hide(); return true; } return QWidget::eventFilter(target, event); } else { return QWidget::eventFilter(target, event); } }
bool Widget::event(QEvent * e) { if( e->type() == QEvent::WindowStateChange ) { if(windowState().testFlag(Qt::WindowMinimized) == true) { isWindowMinimized = 1; } } else if (e->type() == QEvent::WindowActivate) { if (!Settings::getInstance().getUseNativeDecoration()) { this->setObjectName("activeWindow"); this->style()->polish(this); } isWindowMinimized = 0; if (activeChatroomWidget != nullptr) { activeChatroomWidget->resetEventFlags(); activeChatroomWidget->updateStatusLight(); } } else if (e->type() == QEvent::WindowDeactivate && !Settings::getInstance().getUseNativeDecoration()) { this->setObjectName("inactiveWindow"); this->style()->polish(this); } else if (e->type() == QEvent::MouseMove && !Settings::getInstance().getUseNativeDecoration()) { QMouseEvent *k = (QMouseEvent *)e; int xMouse = k->pos().x(); int yMouse = k->pos().y(); int wWidth = this->geometry().width(); int wHeight = this->geometry().height(); if (moveWidget) { inResizeZone = false; moveWindow(k); } else if (allowToResize) resizeWindow(k); else if (xMouse >= wWidth - PIXELS_TO_ACT or allowToResize) { inResizeZone = true; if (yMouse >= wHeight - PIXELS_TO_ACT) { setCursor(Qt::SizeFDiagCursor); resizeWindow(k); } else if (yMouse <= PIXELS_TO_ACT) { setCursor(Qt::SizeBDiagCursor); resizeWindow(k); } } else { inResizeZone = false; setCursor(Qt::ArrowCursor); } e->accept(); } return QWidget::event(e); }
void MainWindow::onTrayOpenQuack() { this->show(); this->setFocus(); this->setWindowState( (windowState() & ~Qt::WindowMinimized) | Qt::WindowActive); this->raise(); this->activateWindow(); }