void MyWebView::initEvents() { // 委托页面所有连接在当前视图中打开 myPage->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); connect(myPage, SIGNAL(linkClicked(QUrl)), this, SLOT(onOpenUrl(QUrl))); // 对所有事件添加信号槽 connect(myFrame, SIGNAL(loadFinished(bool)), this, SLOT(onLoadFinished(bool))); connect(myFrame, SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(onJavaScriptWindowObjectCleared())); connect(myFrame, SIGNAL(initialLayoutCompleted()), this, SLOT(onInitialLayoutCompleted())); connect(myFrame, SIGNAL(pageChanged()), this, SLOT(onPageChanged())); connect(myFrame, SIGNAL(contentsSizeChanged(const QSize)), this, SLOT(onContentsSizeChanged(const QSize))); connect(myFrame, SIGNAL(iconChanged()), this, SLOT(onIconChanged())); connect(myFrame, SIGNAL(loadStarted()), this, SLOT(onLoadStarted())); connect(myFrame, SIGNAL(titleChanged(const QString)), this, SLOT(onTitleChanged(const QString))); connect(myFrame, SIGNAL(urlChanged(const QUrl)), this, SLOT(onUrlChanged(const QUrl))); connect(myPage, SIGNAL(loadProgress(int)), this, SLOT(onLoadProgress(int))); connect(myPage, SIGNAL(repaintRequested(const QRect)), this, SLOT(onRepaintRequested(const QRect))); connect(myPage, SIGNAL(geometryChangeRequested(const QRect)), this, SLOT(onGeometryChangeRequested(const QRect))); connect(newManager, SIGNAL(requestFinished(QString)), this, SLOT(onRequestFinished(QString))); connect(newManager, SIGNAL(requestStart(QString)), this, SLOT(onRequestStart(QString))); };
//--------------------------------------------------------- // Implementations //--------------------------------------------------------- //------------------------------------- MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), m_ui(new Ui::MainWindow), m_lblSongInfo(NULL) { m_ui->setupUi(this); m_ui->dockWidgetLyrics->setWindowTitle(tr("Lyrics")); #ifdef Q_OS_WIN32 if(QSysInfo::WindowsVersion == QSysInfo::WV_WINDOWS10) setStyleSheet("QToolBar { background-color: white;};"); #endif setupActions(); setupTrayIcon(); setupDockMenu(); setupToolbar(); connectSlots(); restoreGeometryAndState(); m_ui->stackedWidget->setCurrentIndex(PAGE_HOME); onPageChanged(PAGE_HOME); qApp->setWindowIcon(Icons::mellowPlayer()); setWindowIcon(Icons::mellowPlayer()); // Setup controllers new UpdateController(this); new PlayerController(this); new StreamingServicesController(this); new NotificationsController(this); new HotkeysController(this); new MPRIS2Controller(this); new LyricsController(this); }