Example #1
0
void CMainWindow::CreateMenu()
{
   ///////////////////////////////////////////////////////////////////////////////////////////////
   _menuBarManager->ShowMenu( CMenuBarManager::mMainPreferences, _menuSessionId );
   _menuBarManager->ShowMenu( CMenuBarManager::mMainExit, _menuSessionId );

   _menuBarManager->Connect( CMenuBarManager::mMainPreferences, this, SLOT( OnPreferences() ) );
   _menuBarManager->Connect( CMenuBarManager::mMainExit, this, SLOT( close() ) );

   ///////////////////////////////////////////////////////////////////////////////////////////////
   _menuBarManager->ShowMenu( CMenuBarManager::mHelpAbout, _menuSessionId );

   _menuBarManager->Connect( CMenuBarManager::mHelpAbout, this, SLOT( OnAbout() ) );
}
Example #2
0
bool MainWindow::winEvent(MSG * msg, long * result)
{
  if (msg->message == WM_SYSCOMMAND)
  {
    switch (msg->wParam)
    {
    case IDM_PREFERENCES_DIALOG:
      OnPreferences();
      *result = 0;
      return true;
    case IDM_ABOUT_DIALOG:
      OnAbout();
      *result = 0;
      return true;
    }
  }
  return false;
}
Example #3
0
MainWindow::MainWindow() : m_locationService(CreateDesktopLocationService(*this))
{
#ifndef USE_DRAPE
  m_pDrawWidget = new DrawWidget(this);
  setCentralWidget(m_pDrawWidget);
#else
  m_pDrawWidget = new DrapeSurface();
  QSurfaceFormat format = m_pDrawWidget->requestedFormat();
  format.setDepthBufferSize(16);
  m_pDrawWidget->setFormat(format);
  QWidget * w = QWidget::createWindowContainer(m_pDrawWidget, this);
  w->setMouseTracking(true);
  setCentralWidget(w);
#endif // USE_DRAPE

  shared_ptr<location::State> locState = m_pDrawWidget->GetFramework().GetLocationState();
  locState->AddStateModeListener([this] (location::State::Mode mode)
                                 {
                                    LocationStateModeChanged(mode);
                                 });

  CreateNavigationBar();
  CreateSearchBarAndPanel();

  setWindowTitle(tr("MAPS.ME"));
  setWindowIcon(QIcon(":/ui/logo.png"));

#ifndef OMIM_OS_WINDOWS
  QMenu * helpMenu = new QMenu(tr("Help"), this);
  menuBar()->addMenu(helpMenu);
  helpMenu->addAction(tr("About"), this, SLOT(OnAbout()));
  helpMenu->addAction(tr("Preferences"), this, SLOT(OnPreferences()));
#else
  {
    // create items in the system menu
    HMENU menu = ::GetSystemMenu((HWND)winId(), FALSE);
    MENUITEMINFOA item;
    item.cbSize = sizeof(MENUITEMINFOA);
    item.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STRING;
    item.fType = MFT_STRING;
    item.wID = IDM_PREFERENCES_DIALOG;
    QByteArray const prefsStr = tr("Preferences...").toLocal8Bit();
    item.dwTypeData = const_cast<char *>(prefsStr.data());
    item.cch = prefsStr.size();
    ::InsertMenuItemA(menu, ::GetMenuItemCount(menu) - 1, TRUE, &item);
    item.wID = IDM_ABOUT_DIALOG;
    QByteArray const aboutStr = tr("About MAPS.ME...").toLocal8Bit();
    item.dwTypeData = const_cast<char *>(aboutStr.data());
    item.cch = aboutStr.size();
    ::InsertMenuItemA(menu, ::GetMenuItemCount(menu) - 1, TRUE, &item);
    item.fType = MFT_SEPARATOR;
    ::InsertMenuItemA(menu, ::GetMenuItemCount(menu) - 1, TRUE, &item);
  }
#endif

  LoadState();

#ifndef NO_DOWNLOADER
  // Show intro dialog if necessary
  bool bShow = true;
  (void)Settings::Get("ShowWelcome", bShow);

  if (bShow)
  {
    bool bShowUpdateDialog = true;

    string text;
    try
    {
      ReaderPtr<Reader> reader = GetPlatform().GetReader("welcome.html");
      reader.ReadAsString(text);
    }
    catch (...)
    {}

    if (!text.empty())
    {
      InfoDialog welcomeDlg(tr("Welcome to MAPS.ME!"), text.c_str(),
                            this, QStringList(tr("Download Maps")));
      if (welcomeDlg.exec() == QDialog::Rejected)
        bShowUpdateDialog = false;
    }
    Settings::Set("ShowWelcome", false);

    if (bShowUpdateDialog)
      ShowUpdateDialog();
  }
#endif // NO_DOWNLOADER

#ifndef USE_DRAPE
  m_pDrawWidget->UpdateAfterSettingsChanged();
#endif // USE_DRAPE
  locState->InvalidatePosition();
}