void Widget::onIconClick(QSystemTrayIcon::ActivationReason reason) { switch (reason) { case QSystemTrayIcon::Trigger: { if (isHidden()) { show(); activateWindow(); if (wasMaximized) showMaximized(); else showNormal(); } else if (isMinimized()) { forceShow(); activateWindow(); if (wasMaximized) showMaximized(); else showNormal(); } else { wasMaximized = isMaximized(); if (Settings::getInstance().getMinimizeToTray()) hide(); else showMinimized(); } break; } case QSystemTrayIcon::MiddleClick: wasMaximized = isMaximized(); if (Settings::getInstance().getMinimizeToTray()) hide(); else showMinimized(); break; case QSystemTrayIcon::Unknown: if (isHidden()) forceShow(); break; default: break; } }
void FileBrowserDialog::createTitleBar() { header_ = new QWidget; header_->setObjectName("mHeader"); QHBoxLayout *layout = new QHBoxLayout; layout->setContentsMargins(1, 1, 1, 1); layout->setSpacing(0); header_->setLayout(layout); QSpacerItem *spacer1 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); layout->addSpacerItem(spacer1); brand_label_ = new QLabel(windowTitle()); brand_label_->setObjectName("mBrand"); layout->addWidget(brand_label_); QSpacerItem *spacer2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); layout->addSpacerItem(spacer2); minimize_button_ = new QPushButton; minimize_button_->setObjectName("mMinimizeBtn"); minimize_button_->setToolTip(tr("Minimize")); minimize_button_->setIcon(awesome->icon(icon_minus, QColor("#808081"))); layout->addWidget(minimize_button_); connect(minimize_button_, SIGNAL(clicked()), this, SLOT(showMinimized())); close_button_ = new QPushButton; close_button_->setObjectName("mCloseBtn"); close_button_->setToolTip(tr("Close")); close_button_->setIcon(awesome->icon(icon_remove, QColor("#808081"))); layout->addWidget(close_button_); connect(close_button_, SIGNAL(clicked()), this, SLOT(close())); header_->installEventFilter(this); }
void ControllerWindow::doMinimize() { if (isMinimized()) showNormal(); else showMinimized(); }
PreviewWindow::PreviewWindow(QWidget *parent) : QWidget(parent) { textEdit = new QTextEdit; textEdit->setReadOnly(true); textEdit->setLineWrapMode(QTextEdit::NoWrap); closeButton = new QPushButton(tr("&Close")); connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); showNormalButton = new QPushButton(tr("Show normal")); connect(showNormalButton, SIGNAL(clicked()), this, SLOT(showNormal())); showMinimizedButton = new QPushButton(tr("Show minimized")); connect(showMinimizedButton, SIGNAL(clicked()), this, SLOT(showMinimized())); showMaximizedButton = new QPushButton(tr("Show maximized")); connect(showMaximizedButton, SIGNAL(clicked()), this, SLOT(showMaximized())); showFullScreenButton = new QPushButton(tr("Show fullscreen")); connect(showFullScreenButton, SIGNAL(clicked()), this, SLOT(showFullScreen())); QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(textEdit); layout->addWidget(showNormalButton); layout->addWidget(showMinimizedButton); layout->addWidget(showMaximizedButton); layout->addWidget(showFullScreenButton); layout->addWidget(closeButton); setLayout(layout); setWindowTitle(tr("Preview <QWidget>")); }
void CMainWindow::RestorePosition() { l2max::CVariant windowX; l2max::CVariant windowY; l2max::CVariant windowWidth; l2max::CVariant windowHeight; l2max::CVariant isMaximized; l2max::CVariant isMinimized; CAppContext::GetInstance()->MainRegistry().Read( V_MAINWND_X, windowX ); CAppContext::GetInstance()->MainRegistry().Read( V_MAINWND_Y, windowY ); CAppContext::GetInstance()->MainRegistry().Read( V_MAINWND_WIDTH, windowWidth ); CAppContext::GetInstance()->MainRegistry().Read( V_MAINWND_HEIGHT, windowHeight ); CAppContext::GetInstance()->MainRegistry().Read( V_MAINWND_ISMAXI, isMaximized ); CAppContext::GetInstance()->MainRegistry().Read( V_MAINWND_ISMINI, isMinimized ); if( windowX.toInt() != -1 && windowY.toInt() != -1 ) { move( windowX.toInt(), windowY.toInt() ); } if( windowWidth.toInt() != -1 && windowHeight.toInt() != -1 ) { resize( windowWidth.toInt(), windowHeight.toInt() ); } if( isMaximized.toInt() ) { showMaximized(); } else if( isMinimized.toInt() ) { showMinimized(); } }
void UIMachineWindowSeamless::prepareMiniToolbar() { /* Get machine: */ CMachine m = machine(); /* Make sure mini-toolbar is necessary: */ bool fIsActive = m.GetExtraData(GUI_ShowMiniToolBar) != "no"; if (!fIsActive) return; /* Get the mini-toolbar alignment: */ bool fIsAtTop = m.GetExtraData(GUI_MiniToolBarAlignment) == "top"; /* Get the mini-toolbar auto-hide feature availability: */ bool fIsAutoHide = m.GetExtraData(GUI_MiniToolBarAutoHide) != "off"; /* Create mini-toolbar: */ m_pMiniToolBar = new UIRuntimeMiniToolBar(this, fIsAtTop ? Qt::AlignTop : Qt::AlignBottom, IntegrationMode_External, fIsAutoHide); m_pMiniToolBar->show(); QList<QMenu*> menus; QList<QAction*> actions = uisession()->newMenu()->actions(); for (int i=0; i < actions.size(); ++i) menus << actions.at(i)->menu(); m_pMiniToolBar->addMenus(menus); connect(m_pMiniToolBar, SIGNAL(sigMinimizeAction()), this, SLOT(showMinimized())); connect(m_pMiniToolBar, SIGNAL(sigExitAction()), gActionPool->action(UIActionIndexRuntime_Toggle_Seamless), SLOT(trigger())); connect(m_pMiniToolBar, SIGNAL(sigCloseAction()), gActionPool->action(UIActionIndexRuntime_Simple_Close), SLOT(trigger())); }
ICMainWindow::ICMainWindow(ICServer *theServer, QWidget *parent) : QMainWindow(parent), server(theServer), questionDialog(new ICNewQuestionDialog(this)), onCanvas(false) { setupUi(this); setWindowIcon(QIcon(":/images/icimage.png")); //this->setAttribute(Qt::WA_TranslucentBackground, true); setWindowFlags(Qt::FramelessWindowHint); //questionDialog->setWindowOpacity(0.8); questionDialog->setWindowFlags(questionDialog->windowFlags() | Qt::FramelessWindowHint); connect(exitButton, SIGNAL(clicked()), this, SLOT(close())); connect(minimizeButton, SIGNAL(clicked()), this, SLOT(showMinimized())); connect(understandButton, SIGNAL(clicked()), this, SLOT(understand())); connect(questionButton, SIGNAL(clicked()), this, SLOT(question())); connect(stopButton, SIGNAL(clicked()), this, SLOT(stop())); connect(server, SIGNAL(newAnswerArrived(QString)), this, SLOT(newAnswerArrived(QString))); connect(server, SIGNAL(connectionClosed()), this, SLOT(connectionClosed())); connect(questionDialog, SIGNAL(newQuestion(int,int)), this, SLOT(newQuestionReady(int,int))); sidLabel->setText(server->getIdentifier()); countLabel->setText("0/0"); }
void UIMachineWindowFullscreen::prepareMiniToolBar() { /* Get current machine: */ CMachine machine = session().GetConsole().GetMachine(); /* Check if mini tool-bar should present: */ bool fIsActive = machine.GetExtraData(VBoxDefs::GUI_ShowMiniToolBar) != "no"; if (fIsActive) { /* Get the mini tool-bar alignment: */ bool fIsAtTop = machine.GetExtraData(VBoxDefs::GUI_MiniToolBarAlignment) == "top"; /* Get the mini tool-bar auto-hide feature availability: */ bool fIsAutoHide = machine.GetExtraData(VBoxDefs::GUI_MiniToolBarAutoHide) != "off"; m_pMiniToolBar = new VBoxMiniToolBar(centralWidget(), fIsAtTop ? VBoxMiniToolBar::AlignTop : VBoxMiniToolBar::AlignBottom, true, fIsAutoHide); m_pMiniToolBar->updateDisplay(true, true); QList<QMenu*> menus; QList<QAction*> actions = uisession()->newMenu()->actions(); for (int i=0; i < actions.size(); ++i) menus << actions.at(i)->menu(); *m_pMiniToolBar << menus; connect(m_pMiniToolBar, SIGNAL(minimizeAction()), this, SLOT(showMinimized())); connect(m_pMiniToolBar, SIGNAL(exitAction()), gActionPool->action(UIActionIndexRuntime_Toggle_Fullscreen), SLOT(trigger())); connect(m_pMiniToolBar, SIGNAL(closeAction()), gActionPool->action(UIActionIndexRuntime_Simple_Close), SLOT(trigger())); } }
void KviWindow::minimize() { if(mdiParent()) mdiParent()->minimize(); else showMinimized(); }
void CameraWidget::closeEvent(QCloseEvent* event) { //--- We will not allow user to close camera windows event->ignore(); //--- We will minimize it showMinimized(); }
void MainWindow::closeEvent(QCloseEvent *event) { qDebug() << "Close event"; if (isVisible()) { #ifdef Q_OS_MAC showMinimized(); #else // Save the window geometry and position QSettings settings("Entomologist"); settings.setValue("window-geometry", saveGeometry()); settings.setValue("entomologist-state", saveState()); if (!settings.value("minimize-warning", false).toBool()) { QMessageBox box; box.setText("Entomologist will be minimized to your system tray."); box.exec(); settings.setValue("minimize-warning", true); } hide(); #endif event->ignore(); } else { qDebug() << "Accepting close event"; event->accept(); } }
QMenu* AbstractPart::createContextMenu() const { QMenu * menu = AbstractAspect::createContextMenu(); Q_ASSERT(menu); const QStyle *widget_style = d_mdi_window->style(); QAction *action_temp; if(d_mdi_window->windowState() & (Qt::WindowMinimized | Qt::WindowMaximized)) { action_temp = menu->addAction(tr("&Restore"), d_mdi_window, SLOT(showNormal())); action_temp->setIcon(widget_style->standardIcon(QStyle::SP_TitleBarNormalButton)); } if(!(d_mdi_window->windowState() & Qt::WindowMinimized)) { action_temp = menu->addAction(tr("Mi&nimize"), d_mdi_window, SLOT(showMinimized())); action_temp->setIcon(widget_style->standardIcon(QStyle::SP_TitleBarMinButton)); } if(!(d_mdi_window->windowState() & Qt::WindowMaximized)) { action_temp = menu->addAction(tr("Ma&ximize"), d_mdi_window, SLOT(showMaximized())); action_temp->setIcon(widget_style->standardIcon(QStyle::SP_TitleBarMaxButton)); } return menu; }
void NormalWindow::showMinimizedTabPage() { if (isWindow() && !isVisible()) showMinimized(); else emit tabPageShowMinimized(); }
void MainWin::restoreStateFromSettings(UiSettings &s) { _normalSize = s.value("MainWinSize", size()).toSize(); _normalPos = s.value("MainWinPos", pos()).toPoint(); bool maximized = s.value("MainWinMaximized", false).toBool(); #ifndef HAVE_KDE restoreGeometry(s.value("MainWinGeometry").toByteArray()); if(maximized) { // restoreGeometry() fails if the windows was maximized, so we resize and position explicitly resize(_normalSize); move(_normalPos); } restoreState(s.value("MainWinState").toByteArray()); #else move(_normalPos); #endif if(s.value("MainWinHidden").toBool() && QtUi::haveSystemTray()) QtUi::hideMainWidget(); else if(s.value("MainWinMinimized").toBool()) showMinimized(); else if(maximized) showMaximized(); else show(); }
void toToolWidget::importData(std::map<QString, QString> &data, const QString &prefix) { QWidget *par = parentWidget(); if (!par) par = this; if (data[prefix + ":State"] == QString::fromLatin1("Maximized")) { par->showMaximized(); showMaximized(); } else if (data[prefix + ":State"] == QString::fromLatin1("Minimized")) { par->showMinimized(); showMinimized(); } else { par->showNormal(); par->setGeometry(data[prefix + ":X"].toInt(), data[prefix + ":Y"].toInt(), data[prefix + ":Width"].toInt(), data[prefix + ":Height"].toInt()); } }
void KviMdiChild::minimize() { if(isVisible()) showMinimized(); else setWindowState((windowState() & Qt::WindowMinimized) & ~Qt::WindowMaximized); }
void UIMachineWindowFullscreen::prepareMiniToolbar() { /* Make sure mini-toolbar is not restricted: */ if (!gEDataManager->miniToolbarEnabled(vboxGlobal().managedVMUuid())) return; /* Create mini-toolbar: */ m_pMiniToolBar = new UIMiniToolBar(this, GeometryType_Full, gEDataManager->miniToolbarAlignment(vboxGlobal().managedVMUuid()), gEDataManager->autoHideMiniToolbar(vboxGlobal().managedVMUuid())); AssertPtrReturnVoid(m_pMiniToolBar); { /* Configure mini-toolbar: */ m_pMiniToolBar->addMenus(actionPool()->menus()); connect(m_pMiniToolBar, SIGNAL(sigMinimizeAction()), this, SLOT(showMinimized()), Qt::QueuedConnection); connect(m_pMiniToolBar, SIGNAL(sigExitAction()), actionPool()->action(UIActionIndexRT_M_View_T_Fullscreen), SLOT(trigger())); connect(m_pMiniToolBar, SIGNAL(sigCloseAction()), actionPool()->action(UIActionIndex_M_Application_S_Close), SLOT(trigger())); connect(m_pMiniToolBar, SIGNAL(sigNotifyAboutWindowActivationStolen()), this, SLOT(sltRevokeWindowActivation()), Qt::QueuedConnection); # ifdef Q_WS_X11 // WORKAROUND: // Due to Unity bug we want native full-screen flag to be set // for mini-toolbar _before_ trying to show it in full-screen mode. // That significantly improves of chances to have required geometry. if (vboxGlobal().typeOfWindowManager() == X11WMType_Compiz) vboxGlobal().setFullScreenFlag(m_pMiniToolBar); # endif /* Q_WS_X11 */ } }
void MainWindow::setupTrayIcon() { QAction *actionMinimize = new QAction(this); actionMinimize->setText(tr("Minimize")); connect(actionMinimize, SIGNAL(triggered()), this, SLOT(showMinimized())); QAction *actionRestore = new QAction(this); actionRestore->setText(tr("Restore")); connect(actionRestore, SIGNAL(triggered()), this, SLOT(showNormal())); QAction *actionQuit = new QAction(this); actionQuit->setText("Quit"); QAction *actionLogout = new QAction(this); actionLogout->setText("Logout"); connect(actionLogout, SIGNAL(triggered()), this, SLOT(changeUserPass())); m_trayIconMenu = new QMenu(this); m_trayIconMenu->addAction(actionMinimize); m_trayIconMenu->addAction(actionRestore); m_trayIconMenu->addSeparator(); m_trayIconMenu->addAction(actionLogout); m_trayIconMenu->addAction(actionQuit); m_trayIcon = new QSystemTrayIcon(this); m_trayIcon->setIcon(QIcon(":/qtwidget_icon.ico")); m_trayIcon->setContextMenu(m_trayIconMenu); m_trayIcon->show(); connect(m_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason))); connect(actionQuit, SIGNAL(triggered()), qApp, SLOT(quit())); }
void frmMain::InitStyle() { QPropertyAnimation *animation = new QPropertyAnimation(this, "windowOpacity"); animation->setDuration(1000); animation->setStartValue(0); animation->setEndValue(1); animation->start(); this->max = false; this->location = this->geometry(); this->setProperty("Form", true); this->setProperty("CanMove", true); this->setWindowTitle(ui->lab_Title->text()); this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint); IconHelper::Instance()->SetIcoMain(ui->lab_Ico, 40); IconHelper::Instance()->SetIcoMin(ui->btnMenu_Min); IconHelper::Instance()->SetIcoNormal(ui->btnMenu_Max); IconHelper::Instance()->SetIcoClose(ui->btnMenu_Close); connect(ui->btnMenu_Min, SIGNAL(clicked()), this, SLOT(showMinimized())); connect(ui->btnMenu_Close, SIGNAL(clicked()), this, SLOT(closeWidget())); connect(ui->btnExit, SIGNAL(clicked()),this, SLOT(closeWidget())); ui->widget_title->installEventFilter(this); ui->btnMenu_Max->click(); }
void UIMachineWindowFullscreen::prepareMiniToolbar() { /* Make sure mini-toolbar is not restricted: */ if (!gEDataManager->miniToolbarEnabled(vboxGlobal().managedVMUuid())) return; /* Create mini-toolbar: */ m_pMiniToolBar = new UIMiniToolBar(this, GeometryType_Full, gEDataManager->miniToolbarAlignment(vboxGlobal().managedVMUuid()), gEDataManager->autoHideMiniToolbar(vboxGlobal().managedVMUuid())); AssertPtrReturnVoid(m_pMiniToolBar); { /* Configure mini-toolbar: */ m_pMiniToolBar->addMenus(actionPool()->menus()); connect(m_pMiniToolBar, SIGNAL(sigMinimizeAction()), this, SLOT(showMinimized()), Qt::QueuedConnection); connect(m_pMiniToolBar, SIGNAL(sigExitAction()), actionPool()->action(UIActionIndexRT_M_View_T_Fullscreen), SLOT(trigger())); connect(m_pMiniToolBar, SIGNAL(sigCloseAction()), actionPool()->action(UIActionIndex_M_Application_S_Close), SLOT(trigger())); connect(m_pMiniToolBar, SIGNAL(sigNotifyAboutWindowActivationStolen()), this, SLOT(sltRevokeWindowActivation()), Qt::QueuedConnection); } }
void UIMachineWindowSeamless::prepareMiniToolbar() { /* Get machine: */ CMachine m = machine(); /* Make sure mini-toolbar is necessary: */ bool fIsActive = m.GetExtraData(GUI_ShowMiniToolBar) != "no"; if (!fIsActive) return; /* Get the mini-toolbar alignment: */ bool fIsAtTop = m.GetExtraData(GUI_MiniToolBarAlignment) == "top"; /* Get the mini-toolbar auto-hide feature availability: */ bool fIsAutoHide = m.GetExtraData(GUI_MiniToolBarAutoHide) != "off"; m_pMiniToolBar = new VBoxMiniToolBar(centralWidget(), fIsAtTop ? VBoxMiniToolBar::AlignTop : VBoxMiniToolBar::AlignBottom, true, fIsAutoHide); m_pMiniToolBar->setSeamlessMode(true); m_pMiniToolBar->updateDisplay(true, true); QList<QMenu*> menus; QList<QAction*> actions = uisession()->newMenu()->actions(); for (int i=0; i < actions.size(); ++i) menus << actions.at(i)->menu(); *m_pMiniToolBar << menus; connect(m_pMiniToolBar, SIGNAL(minimizeAction()), this, SLOT(showMinimized())); connect(m_pMiniToolBar, SIGNAL(exitAction()), gActionPool->action(UIActionIndexRuntime_Toggle_Seamless), SLOT(trigger())); connect(m_pMiniToolBar, SIGNAL(closeAction()), gActionPool->action(UIActionIndexRuntime_Simple_Close), SLOT(trigger())); connect(m_pMiniToolBar, SIGNAL(geometryUpdated()), this, SLOT(sltUpdateMiniToolBarMask())); }
TitleGroupBox::TitleGroupBox(QWidget *parent) : QGroupBox(parent) ,rotateAngle(0) ,angleOffset(30) ,timer_rotateStart(60) ,timer_rotatePause(2000) { setTitleUi(); //设计头部 setting = new Setting(this); //创建 “设置” 对话框 theme = new Theme(this); //创建 “主题” 对话框 tbn_closeWindow ->installEventFilter(this); //安装事件过滤器 tbn_miniWindow ->installEventFilter(this); //安装事件过滤器 tbn_setting ->installEventFilter(this); //安装事件过滤器 tbn_theme ->installEventFilter(this); //安装事件过滤器 connect(tbn_miniWindow, SIGNAL(clicked()), parent, SLOT(showMinimized())); //最小化窗口 connect(tbn_closeWindow, SIGNAL(clicked()), parent, SLOT(close())); //关闭窗口 connect(tbn_setting, SIGNAL(clicked()), this, SLOT(settingClicked())); connect(tbn_theme, SIGNAL(clicked()), this, SLOT(themeClicked())); connect(tbn_simple, SIGNAL(clicked()), this, SLOT(showMiniWindow())); //Why???? connect(theme, SIGNAL(themeClick(int)), this, SIGNAL(themeNumClick(int))); // connect(theme, SIGNAL(settingDataChanged(QString, QString)), this, SIGNAL(settingDataChanged(QString, QString))); setMouseTracking(true); }
int main(int argc, char* argv[ ]) { QApplication app(argc, argv); QPushButton button("State Machine"); QPushButton quitButton("Quit"); QPushButton interruptButton("interrupt"); QStateMachine machine; QState *s1 = new QState(&machine); QState *s11 = new QState(s1); QState *s12 = new QState(s1); QState *s13 = new QState(s1); s1->setInitialState(s11); s11->assignProperty(&button, "geometry", QRect(100, 100, 100, 50)); s12->assignProperty(&button, "geometry", QRect(300, 100, 100, 50)); s13->assignProperty(&button, "geometry", QRect(200, 200, 100, 50)); QSignalTransition *transition1 = s11->addTransition(&button, SIGNAL(clicked()), s12); QSignalTransition *transition2 = s12->addTransition(&button, SIGNAL(clicked()), s13); QSignalTransition *transition3 = s13->addTransition(&button, SIGNAL(clicked()), s11); QPropertyAnimation *animation = new QPropertyAnimation(&button, "geometry"); transition1->addAnimation(animation); transition2->addAnimation(animation); transition3->addAnimation(animation); QObject::connect(s13, SIGNAL(entered()), &button, SLOT(showMinimized())); QFinalState *s2 = new QFinalState(&machine); s1->addTransition(&quitButton, SIGNAL(clicked()), s2); QObject::connect(&machine, SIGNAL(finished()), qApp, SLOT(quit())); QHistoryState *s1h = new QHistoryState(s1); QState *s3 = new QState(&machine); QMessageBox mbox; mbox.addButton(QMessageBox::Ok); mbox.setText("Interrupted!"); mbox.setIcon(QMessageBox::Information); QObject::connect(s3, SIGNAL(entered()), &mbox, SLOT(exec())); s3->addTransition(s1h); s1->addTransition(&interruptButton, SIGNAL(clicked()), s3); machine.setInitialState(s1); machine.start(); button.show(); quitButton.move(300, 300); quitButton.show(); interruptButton.show(); return app.exec(); }
void ChatWindow::showMinimizedTabPage() { assignTabPage(); if (isWindow() && !isVisible()) showMinimized(); else emit tabPageShowMinimized(); }
TitleBar::TitleBar(QWidget *parent) :_parent(parent), _hastext(false), _hasicon(false), _draging(false), _start(0, 0), _background("#00A0B4"), _width(36), _radius(4.0), _Title(""), _close(_width), _minimize(_width), _maxmimize(_width) { setFixedHeight(_width); setAttribute(Qt::WA_StaticContents); connect(&_close, SIGNAL(clicked()), parent, SLOT(close())); connect(&_maxmimize, SIGNAL(clicked()), this, SLOT(changeState())); connect(&_minimize, SIGNAL(clicked()), parent, SLOT(showMinimized())); }
void KonvergoWindow::focusOutEvent(QFocusEvent * ev) { #ifdef Q_OS_WIN32 // Do this to workaround DWM compositor bugs with fullscreened OpenGL applications. // The compositor will not properly redraw anything when focusing other windows. if (visibility() == QWindow::FullScreen && SettingsComponent::Get().value(SETTINGS_SECTION_MAIN, "minimizeOnDefocus").toBool()) showMinimized(); #endif }
void MainWindow::iconActivated(QSystemTrayIcon::ActivationReason reason) { if (reason == QSystemTrayIcon::DoubleClick) { if (windowState() != Qt::WindowMinimized && windowState() != Qt::WindowMinimized + Qt::WindowMaximized) showMinimized(); else { showNormal(); QApplication::setActiveWindow(this); } } }
MusicWindow::MusicWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MusicWindow) { ui->setupUi(this); playNum = 1; last_PlayNum = 0; search_Last = 0; player = new QMediaPlayer; lyric = new MyLyric(this); playMode = "order"; ui->volumeSlider->setValue(player->volume()); thread = new Thread(this); //线程实例化 //窗口初始化 setElement_BackGround(); //检测音乐播放进度,同时调整播放滑块 connect(player, SIGNAL(positionChanged(qint64)), this, SLOT(updateTime(qint64))); connect(player, SIGNAL(durationChanged(qint64)), this, SLOT(setPlayRange(qint64))); connect(player, SIGNAL(positionChanged(qint64)), this, SLOT(setPlayPosition(qint64))); connect(player, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(lyric_Sync(QMediaPlayer::State))); //调整播放进程 connect(ui->timeSlider, SIGNAL(sliderMoved(int)), this, SLOT(setSliderPosition())); connect(ui->volumeSlider, SIGNAL(sliderMoved(int)), this, SLOT(adjustVolume())); connect(ui->browserHideButton, SIGNAL(clicked()), this, SLOT(browserSet())); connect(ui->setApearenceButton, SIGNAL(clicked()), this, SLOT(setApearence())); connect(ui->addButton, SIGNAL(clicked()), this, SLOT(load_again())); connect(ui->lyricButton, SIGNAL(clicked()), this, SLOT(show_Hide_Lyric())); connect(ui->nextButton, SIGNAL(clicked()), this, SLOT(nextSong())); connect(ui->lastButton, SIGNAL(clicked()), this, SLOT(lastSong())); connect(ui->playButton, SIGNAL(clicked()), this, SLOT(playEvent())); connect(ui->listWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(doubleClickedPlay(QListWidgetItem *))); connect(ui->quitButton, SIGNAL(clicked()), this, SLOT(warning())); connect(ui->markButton, SIGNAL(clicked()), this, SLOT(markSong())); connect(ui->setApearenceButton, SIGNAL(clicked()), this, SLOT(setApearence())); connect(ui->muteButton, SIGNAL(clicked()), this, SLOT(set_Mute())); connect(ui->storeButton, SIGNAL(clicked()), this, SLOT(store_Show())); connect(ui->favoriteButton, SIGNAL(clicked()), this, SLOT(favoriteSongs_Show())); connect(ui->browserButton, SIGNAL(clicked()), this, SLOT(browser_Show())); connect(ui->loginButton, SIGNAL(clicked()), this, SLOT(user_login())); connect(ui->downloadButton, SIGNAL(clicked()), this, SLOT(download_File())); connect(ui->modeButton, SIGNAL(clicked()), this, SLOT(playMode_Change())); connect(ui->smallButton, SIGNAL(clicked()), this, SLOT(showMinimized())); connect(ui->searchEdit, SIGNAL(textChanged(QString)), this, SLOT(songs_Search(QString))); //子线程 connect(thread, SIGNAL(upgrade_Signal(int, QStringList, QStringList, QFileInfoList)), this, SLOT(upgradeData(int, QStringList, QStringList, QFileInfoList)), Qt::DirectConnection ); //载入音乐 musicLoad(); Sleep(1000); }
void ATMainWindow_c::hideWindow() { if ( m_bMinimizeToTray ) { hide(); } else { showMinimized(); } }
void FramelessDlg::InitTitleBar() { QVBoxLayout* layout = qobject_cast<QVBoxLayout*>(this->layout()); m_closeBtn = new QToolButton(this); QToolButton* minBtn = new QToolButton(this); QToolButton* menuBtn = new QToolButton(this); m_subTitle = new QLabel(this); m_subTitle->setAlignment(Qt::AlignRight | Qt::AlignVCenter); m_closeBtn->setObjectName("closeBtn"); minBtn->setObjectName("minBtn"); menuBtn->setObjectName("menuBtn"); m_subTitle->setObjectName("subTitle"); menuBtn->setPopupMode(QToolButton::InstantPopup); m_menu = new QMenu(this); menuBtn->setMenu(m_menu); m_closeBtn->setFixedSize(27, 22); minBtn->setFixedSize(27, 22); menuBtn->setFixedSize(27, 22); m_subTitle->setFixedSize(400, 25); connect(m_closeBtn, SIGNAL(clicked()), this, SLOT(reject())); connect(m_closeBtn, SIGNAL(clicked()), this, SLOT(close())); connect(minBtn, SIGNAL(clicked()), this, SLOT(showMinimized())); QFrame* tb = new QFrame(this); tb->setObjectName("titleBar"); QHBoxLayout* tbLayout = new QHBoxLayout; m_title = new QLabel(this); m_title->setObjectName("label_title"); m_title->setFixedSize(300, 25); tbLayout->addWidget(m_title); tbLayout->addSpacerItem(new QSpacerItem(20, 40, QSizePolicy::Expanding, QSizePolicy::Fixed)); if ( m_flag & SUB_TITLE ) tbLayout->addWidget(m_subTitle); if ( m_flag & MENU_BUTTON ) tbLayout->addWidget(menuBtn); if ( m_flag & MIN_BUTTON ) tbLayout->addWidget(minBtn); if ( m_flag & CLOSE_BUTTON ) tbLayout->addWidget(m_closeBtn); tb->setLayout(tbLayout); layout->addWidget(tb); }