platform/shared/qt/rhodes/impl/MainWindowImpl.cpp in rhodes-6.2.0 vs platform/shared/qt/rhodes/impl/MainWindowImpl.cpp in rhodes-7.1.17
- old
+ new
@@ -31,10 +31,11 @@
#include "common/RhoFilePath.h"
#include "rubyext/NativeToolbarExt.h"
#include "json/JSONIterator.h"
#include "MainWindowImpl.h"
//#undef null
+#ifndef RHODES_VERSION_LIBRARY
#include <QString>
#ifndef OS_SAILFISH
#if QT_VERSION >= 0x050000
#include <QtWidgets/QAction>
#else
@@ -42,51 +43,64 @@
#endif
#endif
#include <QHash>
#include "../mainwindowinterface.h"
+
IMPLEMENT_LOGCLASS(CMainWindow,"MainWindow");
+#endif
using namespace rho;
using namespace rho::common;
using namespace rho::json;
extern "C" void rho_geoimpl_turngpsoff();
+#ifndef RHODES_VERSION_LIBRARY
int CMainWindow::m_screenWidth;
int CMainWindow::m_screenHeight;
bool CMainWindow::mainWindowClosed = false;
+#endif
-CMainWindow::CMainWindow(): QObject(), m_started(true), qtMainWindow(NULL)
+CMainWindow::CMainWindow()
+#ifndef RHODES_VERSION_LIBRARY
+ : QObject(), m_started(true), qtMainWindow(NULL)
+#endif
{
+#ifndef RHODES_VERSION_LIBRARY
//int argc = 0;
QCoreApplication::setOrganizationName("Rhomobile");
#ifndef RHODES_EMULATOR
QCoreApplication::setApplicationName(RHODESAPP().getAppName().c_str());
#else
QCoreApplication::setApplicationName("RhoSimulator");
#endif
+#endif //RHODES_VERSION_LIBRARY
//qtApplication = (void*)new QApplication(argc, 0);
}
CMainWindow::~CMainWindow()
{
+#ifndef RHODES_VERSION_LIBRARY
if (qtMainWindow) delete (QtMainWindow*)qtMainWindow;
//if (qtApplication) delete (QApplication*)qtApplication;
+#endif
}
CMainWindow* CMainWindow::getInstance(void)
{
static CMainWindow* instance = new CMainWindow();
return instance;
}
void CMainWindow::updateSizeProperties(int width, int height)
{
+#ifndef RHODES_VERSION_LIBRARY
m_screenWidth = width;
m_screenHeight = height;
+#endif
}
void CMainWindow::logEvent(const ::std::string& message)
{
LOG(INFO) + message;
@@ -95,21 +109,24 @@
void CMainWindow::onWebViewUrlChanged(const ::std::string& url)
{
RHODESAPP().keepLastVisitedUrl(url);
}
+#ifndef RHODES_VERSION_LIBRARY
bool CMainWindow::Initialize(const wchar_t* title)
{
bool ok = init(this, title);
#ifndef OS_SAILFISH
rho_rhodesapp_callUiCreatedCallback();
#endif
return ok;
}
+#endif
void CMainWindow::createCustomMenu(void)
{
+#ifndef RHODES_VERSION_LIBRARY
RHODESAPP().getAppMenu().copyMenuItems(m_arAppMenuItems);
#ifdef ENABLE_DYNAMIC_RHOBUNDLE
String strIndexPage = CFilePath::join(RHODESAPP().getStartUrl(),"index"RHO_ERB_EXT);
if ( RHODESAPP().getCurrentUrl().compare(RHODESAPP().getStartUrl()) == 0 ||
RHODESAPP().getCurrentUrl().compare(strIndexPage) == 0 )
@@ -126,14 +143,16 @@
#else
menuAddAction((oItem.m_strLink == "close" ? "Exit" : oItem.m_strLabel.c_str()), i, oItem.m_isEnable);
#endif
}
}
+#endif//RHODES_VERSION_LIBRARY
}
void CMainWindow::onCustomMenuItemCommand(int nItemPos)
{
+#ifndef RHODES_VERSION_LIBRARY
if ( nItemPos < 0 || nItemPos >= (int)m_arAppMenuItems.size() )
return;
CAppMenuItem& oMenuItem = m_arAppMenuItems.elementAt(nItemPos);
if ( oMenuItem.m_strLink == "reload_rhobundle" )
@@ -147,12 +166,21 @@
#endif
return;
}
oMenuItem.processCommand();
+#endif
}
+void CMainWindow::onWindowClose(void)
+{
+#ifndef RHODES_VERSION_LIBRARY
+ mainWindowClosed = true;
+#endif
+}
+
+#ifndef RHODES_VERSION_LIBRARY
void CMainWindow::minimizeWindow(void)
{
#ifndef OS_SAILFISH //TODO: FIX
((QtMainWindow*)qtMainWindow)->showMinimized();
#endif
@@ -178,16 +206,11 @@
void CMainWindow::DestroyUi(void)
{
rho_rhodesapp_callUiDestroyedCallback();
}
-void CMainWindow::onWindowClose(void)
-{
- mainWindowClosed = true;
-}
-
// **************************************************************************
//
// proxy methods:
//
// **************************************************************************
@@ -664,19 +687,20 @@
void CMainWindow::menuAddAction(const char* label, int item, bool enabled)
{
((QtMainWindow*)qtMainWindow)->menuAddAction(QString(label), item, enabled);
}
-
+#endif
// Handlers
void CMainWindow::onActivate(int active)
{
rho_rhodesapp_callAppActiveCallback(active);
if (!active)
rho_geoimpl_turngpsoff();
}
+#ifndef RHODES_VERSION_LIBRARY
// Commands
void CMainWindow::exitCommand()
{
emit doExitCommand();
}
@@ -823,13 +847,18 @@
void CMainWindow::createCustomMenuSlot(void)
{
createCustomMenu();
}
+#endif
extern "C" void rho_os_impl_performOnUiThread(rho::common::IRhoRunnable* pTask)
{
+#ifndef RHODES_VERSION_LIBRARY
CMainWindow::getInstance()->executeRunnable(pTask);
+#else
+ pTask->runObject();
+#endif
}
#if defined(RHODES_QT_PLATFORM) && defined(OS_MACOSX)
extern "C" void rho_qt_sys_minimize()
{