Ejemplo n.º 1
0
FeaturedArtistsWebView::FeaturedArtistsWebView(QWidget* parent,
                                               QString libraryPath,
                                               QString remoteURL,
                                               SongDownloader* downloader)
                       : QWebView(parent),
                         LibraryView() {
    m_sLibraryPath = libraryPath;
    m_sRemoteURL = remoteURL;
    m_sLocalErrorURL = "about:qt";
    m_bOfflineMode = false;
    m_pSongDownloader = downloader;

    QWidget::setContextMenuPolicy(Qt::PreventContextMenu);

    //Allow us to catch if opening the HTML file on promo.mixxx.org
    //fails, and display a local copy instead.
    connect(this, SIGNAL(loadFinished(bool)),
            this, SLOT(handleLoadFinished(bool)));

    //Load the promo tracks webpage
    QWebView::load(QUrl(m_sRemoteURL));

    //Let us manually handle links that are clicked via the linkClicked()
    //signal...
    QWebPage* page = QWebView::page();
    page->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);

    connect(this, SIGNAL(linkClicked(const QUrl&)),
            this, SLOT(handleClickedLink(const QUrl&)));

    QTimer* loadingTimer = new QTimer(this);
    connect(loadingTimer, SIGNAL(timeout()),
            this, SLOT(checkWebpageLoadingProgress()));
    loadingTimer->start(LOAD_TIMEOUT);
}
Ejemplo n.º 2
0
HelpForm::HelpForm(QWidget *parent) :
    QMainWindow(parent,Qt::FramelessWindowHint),webview(new QMyWebView)
{
    setupUi(this);
    setCentralWidget(webview);
    QWebPage *page = webview->page();
    page->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
    page->setContentEditable(FALSE);
    webview->setContextMenuPolicy(Qt::NoContextMenu);
    connect(page,SIGNAL(linkClicked(QUrl)),SLOT(loadUrl(QUrl)));
    connect(action_back,SIGNAL(triggered()),webview,SLOT(back()));
    connect(action_forward,SIGNAL(triggered()),webview,SLOT(forward()));
    connect(action_refresh,SIGNAL(triggered()),webview,SLOT(reload()));
}
Ejemplo n.º 3
0
void MainWindow::init(bool is_development) {
    //qApp->installEventFilter(this);
  
    setWindowTitle(settings->value("window_title").toString());

    if (settings->value("minified_state").toString() == "true") {
        setWindowState(Qt::WindowMinimized);
    }

    this->setMinimumWidth(430);
    this->setMinimumHeight(430);

    webView = new QWebView(this);
    if (settings->value("context_menu").toString() == "false") {
        webView->setContextMenuPolicy(Qt::NoContextMenu);
    }
    this->setCentralWidget(webView);

    m_network_manager = new QNetworkAccessManager(this);

    QWebPage *webPage = webView->page();
    webPage->setNetworkAccessManager(m_network_manager);
    webPage->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
    connect(webPage, &QWebPage::linkClicked, this, &MainWindow::onLinkClicked);
    connect(webPage->mainFrame(), &QWebFrame::javaScriptWindowObjectCleared, this, &MainWindow::attachJsApi);

    webView->show();

    bootstrap(is_development);

    // restore saved window geometry from .ini file
    QVariant size = settings->value("main_window_geometry");
    if ( size.isNull() ) {
        this->setGeometry(QRect(500, 100, 700, 500));
    } else {
        this->setGeometry(size.toRect());
    }

    // restore saved zoom factor from .ini file
    qreal z = settings->value("zoom_factor").toReal();
    if ( z ) webView->page()->mainFrame()->setZoomFactor(z);

    m_jsApi = new JsApi(this);

    optionsDialog = new OptionsDialog(this);
    optionsDialog->m_version = m_version;
    connect(optionsDialog, SIGNAL(accepting()), m_jsApi, SLOT(onOptionsDialogAccepted()));

    QShortcut *zoomin = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Plus), this);
    connect(zoomin, &QShortcut::activated, this, &MainWindow::onZoomIn);

    QShortcut *zoomout = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Minus), this);
    connect(zoomout, &QShortcut::activated, this, &MainWindow::onZoomOut);

    QShortcut *shutdown = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this);
    connect(shutdown, &QShortcut::activated, m_jsApi, &JsApi::shutdown);

    QWebSettings::setObjectCacheCapacities(0, 0, 0);

    if (settings->value("webinspector").toString() == "true") {
        QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);

        QWebInspector *inspector;
        inspector = new QWebInspector();
        inspector->setPage(webView->page());
        inspector->setGeometry(QRect(500, 10, 1000, 700));
        inspector->show();
    }

    QIcon icon = QIcon(application_path + "/" + APPNAME + ".png");
    m_trayIcon = new QSystemTrayIcon(this);
    m_trayIcon->setIcon(icon);
    m_trayIcon->show();
    connect(m_trayIcon, &QSystemTrayIcon::messageClicked, m_jsApi, &JsApi::onTrayMessageClicked);
    connect(m_trayIcon, &QSystemTrayIcon::activated, m_jsApi, &JsApi::onTrayIconActivated);
}
Ejemplo n.º 4
0
CWizDocumentView::CWizDocumentView(CWizExplorerApp& app, QWidget* parent)
    : INoteView(parent)
    , m_app(app)
    , m_dbMgr(app.databaseManager())
    , m_userSettings(app.userSettings())
    #ifdef USEWEBENGINE
    , m_web(new CWizDocumentWebEngine(app, this))
    , m_comments(new QWebEngineView(this))
    #else
    , m_web(new CWizDocumentWebView(app, this))
    , m_commentWidget(new CWizLocalProgressWebView(app.mainWindow()))
    #endif
    , m_title(new TitleBar(app, this))
    , m_passwordView(new CWizUserCipherForm(app, this))
    , m_viewMode(app.userSettings().noteViewMode())
    , m_transitionView(new CWizDocumentTransitionView(this))
    , m_bLocked(false)
    , m_bEditingMode(false)
    , m_noteLoaded(false)
    , m_editStatusSyncThread(new CWizDocumentEditStatusSyncThread(this))
    //, m_editStatusCheckThread(new CWizDocumentStatusCheckThread(this))
    , m_editStatus(0)
    , m_sizeHint(QSize(200, 1))
{
    m_title->setEditor(m_web);

    QVBoxLayout* layoutDoc = new QVBoxLayout();
    layoutDoc->setContentsMargins(0, 0, 0, 0);
    layoutDoc->setSpacing(0);

    m_docView = new QWidget(this);
    m_docView->setLayout(layoutDoc);

    m_tab = new QStackedWidget(this);
    //
    m_passwordView->setGeometry(this->geometry());
    connect(m_passwordView, SIGNAL(cipherCheckRequest()), SLOT(onCipherCheckRequest()));
    //
    m_msgWidget = new QWidget(this);
    QVBoxLayout* layoutMsg = new QVBoxLayout();
    m_msgWidget->setLayout(layoutMsg);
    m_msgLabel = new QLabel(m_msgWidget);
    m_msgLabel->setAlignment(Qt::AlignCenter);
    m_msgLabel->setWordWrap(true);
    layoutMsg->addWidget(m_msgLabel);
    //
    m_tab->addWidget(m_docView);
    m_tab->addWidget(m_passwordView);
    m_tab->addWidget(m_msgWidget);
    m_tab->setCurrentWidget(m_docView);    

    m_web->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    m_comments = m_commentWidget->web();
    QWebPage *commentPage = new QWebPage(m_comments);
    commentPage->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
    m_comments->setPage(commentPage);
    m_comments->history()->setMaximumItemCount(0);
    m_comments->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
    m_comments->settings()->globalSettings()->setAttribute(QWebSettings::LocalStorageEnabled, true);
    m_comments->settings()->globalSettings()->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, true);
    m_comments->page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
    m_comments->setAcceptDrops(false);
    connect(m_comments, SIGNAL(loadFinished(bool)), m_title, SLOT(onCommentPageLoaded(bool)));
    connect(m_comments, SIGNAL(linkClicked(QUrl)), m_web, SLOT(onEditorLinkClicked(QUrl)));
    connect(m_comments->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()),
            SLOT(on_comment_populateJavaScriptWindowObject()));
    connect(m_commentWidget, SIGNAL(widgetStatusChanged()), SLOT(on_commentWidget_statusChanged()));

    m_commentWidget->hide();

    QWidget* wgtEditor = new QWidget(m_docView);
    QVBoxLayout* layoutEditor = new QVBoxLayout(wgtEditor);
    layoutEditor->setSpacing(0);
    layoutEditor->setContentsMargins(0, 5, 0, 0);
    layoutEditor->addWidget(m_title);
    layoutEditor->addWidget(m_web);
    layoutEditor->setStretchFactor(m_title, 0);
    layoutEditor->setStretchFactor(m_web, 1);

    m_splitter = new CWizSplitter(this);
    m_splitter->addWidget(wgtEditor);
    m_splitter->addWidget(m_commentWidget);
    m_splitter->setOrientation(Qt::Horizontal);

    layoutDoc->addWidget(m_splitter);
//    layoutDoc->setStretchFactor(m_title, 0);
//    layoutDoc->setStretchFactor(m_splitter, 1);

#ifdef USEWEBENGINE
    QLineEdit *commandLine = new QLineEdit(this);
    layoutDoc->addWidget(commandLine);
    connect(commandLine, SIGNAL(returnPressed()), SLOT(on_command_request()));
#endif

    QVBoxLayout* layoutMain = new QVBoxLayout(this);
    layoutMain->setContentsMargins(0, 0, 0, 0);
    setLayout(layoutMain);
    layoutMain->addWidget(m_tab);

    //
    layoutMain->addWidget(m_transitionView);
    m_transitionView->hide();

    MainWindow* mainWindow = qobject_cast<MainWindow *>(m_app.mainWindow());
    m_downloaderHost = mainWindow->downloaderHost();
    connect(m_downloaderHost, SIGNAL(downloadDone(const WIZOBJECTDATA&, bool)),
            SLOT(on_download_finished(const WIZOBJECTDATA&, bool)));

    connect(&m_dbMgr, SIGNAL(documentModified(const WIZDOCUMENTDATA&, const WIZDOCUMENTDATA&)), \
            SLOT(on_document_modified(const WIZDOCUMENTDATA&, const WIZDOCUMENTDATA&)));

    connect(&m_dbMgr, SIGNAL(documentDataModified(const WIZDOCUMENTDATA&)),
            SLOT(on_document_data_modified(const WIZDOCUMENTDATA&)));

    connect(&m_dbMgr, SIGNAL(attachmentCreated(const WIZDOCUMENTATTACHMENTDATA&)), \
            SLOT(on_attachment_created(const WIZDOCUMENTATTACHMENTDATA&)));

    connect(&m_dbMgr, SIGNAL(attachmentDeleted(const WIZDOCUMENTATTACHMENTDATA&)), \
            SLOT(on_attachment_deleted(const WIZDOCUMENTATTACHMENTDATA&)));

    connect(&m_dbMgr, SIGNAL(documentUploaded(QString,QString)), \
            m_editStatusSyncThread, SLOT(documentUploaded(QString,QString)));

    connect(Core::ICore::instance(), SIGNAL(viewNoteRequested(Core::INoteView*,const WIZDOCUMENTDATA&)),
            SLOT(onViewNoteRequested(Core::INoteView*,const WIZDOCUMENTDATA&)));

    connect(Core::ICore::instance(), SIGNAL(viewNoteLoaded(Core::INoteView*,WIZDOCUMENTDATA,bool)),
            SLOT(onViewNoteLoaded(Core::INoteView*,const WIZDOCUMENTDATA&,bool)));

    connect(Core::ICore::instance(), SIGNAL(closeNoteRequested(Core::INoteView*)),
            SLOT(onCloseNoteRequested(Core::INoteView*)));

    connect(m_web, SIGNAL(focusIn()), SLOT(on_webView_focus_changed()));

    connect(m_title, SIGNAL(notifyBar_link_clicked(QString)), SLOT(on_notifyBar_link_clicked(QString)));
    connect(m_title, SIGNAL(loadComment_request(QString)), SLOT(on_loadComment_request(QString)), Qt::QueuedConnection);

//    connect(m_editStatusCheckThread, SIGNAL(checkFinished(QString,QStringList)),
//            SLOT(on_checkEditStatus_finished(QString,QStringList)));
//    connect(m_editStatusCheckThread, SIGNAL(checkDocumentChangedFinished(QString,bool)),
//            SLOT(on_checkDocumentChanged_finished(QString,bool)));
//    connect(m_editStatusCheckThread, SIGNAL(checkTimeOut(QString)),
//            SLOT(on_checkEditStatus_timeout(QString)));

    //
    m_editStatusSyncThread->start(QThread::IdlePriority);
//    m_editStatusCheckThread->start(QThread::IdlePriority);

    m_editStatusChecker = new CWizDocumentStatusChecker();
    connect(this, SIGNAL(checkDocumentEditStatusRequest(QString,QString)), m_editStatusChecker,
            SLOT(checkEditStatus(QString,QString)));
    connect(this, SIGNAL(stopCheckDocumentEditStatusRequest(QString,QString)),
            m_editStatusChecker, SLOT(stopCheckStatus(QString,QString)));
    connect(m_editStatusChecker, SIGNAL(checkEditStatusFinished(QString,bool)), \
            SLOT(on_checkEditStatus_finished(QString,bool)));
    connect(m_editStatusChecker, SIGNAL(checkTimeOut(QString)), \
            SLOT(on_checkEditStatus_timeout(QString)));
    connect(m_editStatusChecker, SIGNAL(documentEditingByOthers(QString,QStringList)), \
            SLOT(on_documentEditingByOthers(QString,QStringList)));
    connect(m_editStatusChecker, SIGNAL(checkDocumentChangedFinished(QString,bool)), \
            SLOT(on_checkDocumentChanged_finished(QString,bool)));

    QThread* checkThread = new QThread(this);
    connect(checkThread, SIGNAL(started()), m_editStatusChecker, SLOT(initialise()));
    connect(checkThread, SIGNAL(finished()), m_editStatusChecker, SLOT(clearTimers()));
    m_editStatusChecker->moveToThread(checkThread);
    checkThread->start();
}
Ejemplo n.º 5
0
void QWebPageProto::setLinkDelegationPolicy(QWebPage::LinkDelegationPolicy policy)
{
  QWebPage *item = qscriptvalue_cast<QWebPage*>(thisObject());
  if (item)
    item->setLinkDelegationPolicy(policy);
}