Beispiel #1
0
LxMainWindow::LxMainWindow( QWidget* prarent /*= 0*/ )
:QWebView(prarent)
{
	_initWidget();
	this->setRenderHints(QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing);
 	QObject::connect(this, SIGNAL(linkClicked(const QUrl&)), this, SLOT(linkClickedAction(const QUrl&)));

	QNetworkAccessManager* pNetworkAccessManager = this->page()->networkAccessManager();
	LxOption* pOption = lxCoreApp->getOption();
	if (pOption && pNetworkAccessManager)
	{
		QString strCookies = pOption->getCookieFilePath();
		LxNetWorkCookies* pCookies = new LxNetWorkCookies(strCookies, this);
		pNetworkAccessManager->setCookieJar(pCookies);

		QNetworkDiskCache *diskCache = new QNetworkDiskCache(this);
		QString location = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
		//QString location = QDesktopServices::storageLocation(QDesktopServices::CacheLocation);
		diskCache->setCacheDirectory(location);
		diskCache->setMaximumCacheSize(1024);//byte
		pNetworkAccessManager->setCache(diskCache);

		pNetworkAccessManager->setNetworkAccessible(QNetworkAccessManager::Accessible);

		m_bLoadHrefInCurrent = pOption->getLoadHrefInCurrentMainDialog();

	}
	QString iconName = pOption->getSystemTrayIconName();
	QString iconPath = QCoreApplication::applicationDirPath() + "/" + iconName;
	qDebug("show path %s", qPrintable(iconPath));
	QIcon icon(iconPath);
	this->setWindowIcon(icon);
}
Beispiel #2
0
void LxCoreApplicationPrivate::showMainDialog( QUrl URL /*= ""*/ )
{
    qDebug(" LxCoreApplicationPrivate::showMainDialog()");
	
	do 
	{
		if (!m_pMainWin)
			m_pMainWin = new LxMainWindow();
		

		m_pMainWin->setUrl(URL);

		LxOption* pOption = getOption();

		if (!pOption)
			break;

		if (lxCoreApp->getDialogs())
		{
			m_pDialogs->append(QString("LomoX-Main"),m_pDialog);
		}

		new LxCoreApplication((QObject*)m_pMainWin, m_pMainWin,QString(LOMOX_API_COREAPP));
		bool bshowloading = false;
		int gifW = 0;
		int gifH = 0;
		if (pOption->getNeedShowLoadingGif())
		{
			gifW = pOption->getLoadingGifWidth();
			gifH = pOption->getLoadingGifHeight();
			if (gifW > 0 && gifH > 0)
			{
				bshowloading = true;
			}
		}
		LxDialogBase* pDialogOp = new LxDialogBase(this, m_pMainWin, "LxDialog", bshowloading, gifW, gifH);

		LxSystemTray *pSystemTray = NULL;
		if (pOption->getNeedSystemTray())
		{
			QString iconName = pOption->getSystemTrayIconName();
			QString iconPath = QCoreApplication::applicationDirPath() + "/" + iconName;
			qDebug("show path %s", iconPath.toStdString());
			QIcon icon(iconPath);
			pSystemTray = new LxSystemTray(icon, pOption->getMainTitle(), pDialogOp);
		}
		m_pMainWin->show();
		
		qDebug("LomoX.dialogs.count=%d",m_pDialogs->count().toInt());

	} while (false);
	
	
	return ;

 
}
Beispiel #3
0
bool LxMainWindow::_initWidget()
{
	setObjectName("lomoxwin");
	setAttribute(Qt::WA_DeleteOnClose);//主窗口关闭时析构

	do 
	{
		LxOption* pOption = lxCoreApp->getOption();

		if (!pOption)
			break;

		Qt::WindowFlags winType = Qt::Dialog ;

		if (pOption->getNeedShowMainNcFrame())
		{
			winType |=  Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint;
		}
		else
		{
			winType |= Qt::FramelessWindowHint;
			winType |= Qt::WindowSystemMenuHint;//不加不出现窗口 modify by KeoJam 2015-04-19
			this->setAttribute(Qt::WA_TranslucentBackground, true);
			this->setStyleSheet("#lomoxwin{background-color:transparent} QMenu{background-color:none;}");
		}

		if (pOption->getMainWindowStaysOnTopHint())
			winType |= Qt::WindowStaysOnTopHint;

		this->setWindowFlags(winType);

		QWebPage* ptrWebPage = new LxWebPage(this);
		this->setPage(ptrWebPage);//add  by KeoJam 启用自定义LxWebPage用于Permission处理
		//QPointer<QWebPage> ptrWebPage = this->page();
		QPointer<LxWebPluginFactory> ptrPlugin = new LxWebPluginFactory(ptrWebPage);
		ptrWebPage->setPluginFactory(ptrPlugin);
		//ptrWebPage->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);//LinkDelegationPolicy::DelegateAllLinks
	} while (false);


	return true;
}
Beispiel #4
0
bool LxBaseWin::_initWidget()
{
	setObjectName("lomoxchildwin");

	do
	{
		LxOption* pOption = lxCoreApp->getOption();

		if (!pOption)
			break;

		Qt::WindowFlags winType = Qt::Dialog;

		if (pOption->getNeedShowChildNcFrame())
		{
			winType |= Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint;
		}
		else
		{
			winType |= Qt::FramelessWindowHint;
			winType |= Qt::WindowSystemMenuHint;//不加不出现窗口 modify by KeoJam 2015-04-19
			this->setAttribute(Qt::WA_TranslucentBackground, true);
			this->setStyleSheet("#lomoxwin{background-color:transparent} QMenu{background-color:none;}");
		}

		if (pOption->getChildWindowStaysOnTopHint())
			winType |= Qt::WindowStaysOnTopHint;
		this->setWindowFlags(winType);
#ifdef Q_OS_WIN
		SetWindowLong((HWND)this->winId(), GWL_EXSTYLE, WS_EX_APPWINDOW);//add  by KeoJam 强制子窗口最小化显示在任务
#endif
		QWebPage* ptrWebPage = new LxWebPage(this);
		this->setPage(ptrWebPage);//add  by KeoJam 启用自定义LxWebPage用于Permission处理
		//QPointer<QWebPage> ptrWebPage = this->page();
		QPointer<LxWebPluginFactory> ptrPlugin = new LxWebPluginFactory(ptrWebPage);
		ptrWebPage->setPluginFactory(ptrPlugin);
		//ptrWebPage->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);//LinkDelegationPolicy::DelegateAllLinks
	} while (false);


	return true;
}
Beispiel #5
0
void LxCoreApplicationPrivate::runLomoxApp(int argc, char *argv[])
{
	QApplication a(argc, argv);

	QWebSettings::globalSettings()->setAttribute(QWebSettings::AutoLoadImages,true);
//#ifdef  DEBUG
	QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled,true);
//#endif

	QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled,true);
	QWebSettings::globalSettings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled,true);
	QWebSettings::globalSettings()->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled,true);
	QWebSettings::globalSettings()->setAttribute(QWebSettings::LocalStorageEnabled,true);
	QWebSettings::globalSettings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls,true);
	QWebSettings::globalSettings()->setAttribute(QWebSettings::LocalContentCanAccessFileUrls,true);

	QWebSettings::globalSettings()->setAttribute(QWebSettings::JavascriptCanOpenWindows,true);
	QWebSettings::globalSettings()->setAttribute(QWebSettings::LinksIncludedInFocusChain,true);
	QWebSettings::globalSettings()->setAttribute(QWebSettings::PrintElementBackgrounds, true);
	QWebSettings::globalSettings()->setAttribute(QWebSettings::XSSAuditingEnabled, false);
	QWebSettings::globalSettings()->setAttribute(QWebSettings::NotificationsEnabled, true);
	
	//QWebSettings::globalSettings()->setObjectCacheCapacities(0,0,0); 降低内存用的,但是速度回变低
	QString libraryPath = QCoreApplication::applicationDirPath() + QDir::separator() + QString("plugins\\");
	QStringList libraryPaths;
	libraryPaths.append(libraryPath);
	QCoreApplication::setLibraryPaths(libraryPaths);
	QString strStoragePath = QCoreApplication::applicationDirPath() + QDir::separator() + QString("Storage\\");
	QWebSettings::globalSettings()->enablePersistentStorage(strStoragePath);

	do 
	{
		QString strUrl;
		LxOption* pOtion = getOption();
		if (pOtion)
		{
			strUrl = pOtion->getStartUrl();
		}
		else
			Q_ASSERT(pOtion == nullptr);


		if (!strUrl.isEmpty())
		{
			if (-1 == strUrl.indexOf(':'))
			{
				strUrl = QString::fromLocal8Bit("http://") + strUrl;
			}
			QFileInfo qFileInfo(strUrl);
			if (qFileInfo.isAbsolute())//add by KeoJam 如果是本地文件强制加file:///
			{
				strUrl = QString::fromLocal8Bit("file:///") + strUrl;
			}

			if (!pOtion)
				break;

			QString strTitle = pOtion->getMainTitle();
			if (!strTitle.isEmpty())
				lxCoreApp->setMainDialogTitle(strTitle);
			lxCoreApp->showMainDialog(QUrl(strUrl));
		}
		else
		{
			Q_ASSERT(!strUrl.isEmpty());
			return ;
		}

	} while (false);

	a.exec();
}