screengrabber/src/mainview.cpp
changeset 15 e11368ed4880
child 17 4f2773374eff
equal deleted inserted replaced
11:4df3a095718c 15:e11368ed4880
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 #include <hbview.h>
       
    19 #include <hbmainwindow.h>
       
    20 #include <hbapplication.h>
       
    21 #include <hblabel.h>
       
    22 #include <hbmenu.h>
       
    23 #include <hbaction.h>
       
    24 #include <hbtextedit.h>
       
    25 #include <hbmessagebox.h>
       
    26 #include <qgraphicslinearlayout.h>
       
    27 #include "enginewrapper.h"
       
    28 #include "settingsView.h"
       
    29 #include "mainview.h"
       
    30 #include "notifications.h"
       
    31 #include "hbtoolbar.h"
       
    32 
       
    33 // ---------------------------------------------------------------------------
       
    34 
       
    35 MainView::MainView(HbMainWindow &mainWindow, EngineWrapper &engineWrapper):
       
    36     mMainWindow(mainWindow),
       
    37     mSettingsView(0),
       
    38     mEngineWrapper(engineWrapper)
       
    39 {
       
    40 }
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 
       
    44 MainView::~MainView()
       
    45 {
       
    46 }
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 
       
    50 void MainView::init(HbApplication &app)
       
    51 {
       
    52     this->setTitle("Screen Grabber");
       
    53     createMenu(app);
       
    54     createInfoText();
       
    55     createToolbar();
       
    56 
       
    57 }
       
    58 
       
    59 void MainView::createMenu(HbApplication& app)
       
    60 {
       
    61     
       
    62     HbMenu* menu = this->menu();
       
    63    
       
    64     if (menu != NULL) {
       
    65     
       
    66         actionSendToBg = menu->addAction("Send to background");
       
    67         connect(actionSendToBg, SIGNAL( triggered() ), this, SLOT( sendToBackground() ) );
       
    68         
       
    69         actionSettings = menu->addAction("Settings");
       
    70         connect(actionSettings, SIGNAL( triggered() ), this, SLOT( showSettings() ) );
       
    71     
       
    72         actionAbout = menu->addAction("About");
       
    73         connect(actionAbout, SIGNAL( triggered() ), this, SLOT( showAboutPopup() ) );
       
    74     
       
    75         actionExit = menu->addAction("Exit");
       
    76         connect(actionExit, SIGNAL(triggered()), this, SLOT( my_quit() ) );
       
    77 
       
    78 		HbAction *mDefaultNavigationAction = new HbAction(Hb::QuitNaviAction, this);
       
    79 		connect(mDefaultNavigationAction,SIGNAL(triggered()), this, SLOT(my_quit()));
       
    80 		setNavigationAction(mDefaultNavigationAction);
       
    81         
       
    82     	//setNavigationAction(actionExit);
       
    83     }
       
    84 }
       
    85 
       
    86 
       
    87 
       
    88 void MainView::my_quit()
       
    89     {
       
    90 	HbLabel label(" Exit Screen grabber confirm");
       
    91 	if (HbMessageBox::question("Do you really want to exit the Screen Grabber application?","yes","no",&label))
       
    92 		qApp->quit();   
       
    93     }
       
    94 
       
    95 // ---------------------------------------------------------------------------
       
    96 
       
    97 void MainView::createInfoText()
       
    98 {
       
    99     QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical, this);
       
   100     if (layout != NULL) {
       
   101         HbTextEdit* edit = new HbTextEdit(this);
       
   102         if(edit != NULL) {
       
   103             edit->setPlainText("Please use the settings screen to define the "
       
   104                                "capture mode and any other related settings "
       
   105                                "such as capture hotkey and saving format. "
       
   106                                "Using the PNG format for screen shots is "
       
   107                                "recommended, since it is compressed but "
       
   108                                "lossless. The captures can be managed with "
       
   109                                "the Media Gallery application.\n\nYou may "
       
   110                                "start taking screenshots or capturing video "
       
   111                                "now. Please press the Applications key to go back "
       
   112                                "to the Application menu or send this application "
       
   113                                "to the background via the Options menu. To be "
       
   114                                "able to take screenshots or capture video, this "
       
   115                                "application needs to stay running in the "
       
   116                                "background.");
       
   117             edit->setReadOnly(true);
       
   118             //TODO edit->setCursorHidden(true);
       
   119             //TODO edit->setAttribute(Qt::WA_InputMethodEnabled, false);
       
   120             layout->addItem(edit);
       
   121             layout->setContentsMargins(5, 5, 5, 5);
       
   122             this->setLayout(layout);
       
   123         }
       
   124         
       
   125     }
       
   126     
       
   127 }
       
   128 
       
   129 // ---------------------------------------------------------------------------
       
   130 
       
   131 void MainView::showSettings()
       
   132 {
       
   133     mEngineWrapper.EnableRcpOfFoc(ETrue);
       
   134 	mEngineWrapper.LoadSettings();	
       
   135 	mSettingsView->loadSettings();
       
   136 	mMainWindow.setCurrentView(mSettingsView);
       
   137 }
       
   138 
       
   139 // ---------------------------------------------------------------------------
       
   140 
       
   141 void MainView::createToolbar()
       
   142 {
       
   143     HbToolBar *toolbar = new HbToolBar(this); // main view takes the ownership
       
   144     toolbar->addAction(actionSettings);
       
   145     toolbar->addAction(actionSendToBg);
       
   146     setToolBar(toolbar);
       
   147 }
       
   148 
       
   149 // ---------------------------------------------------------------------------
       
   150 
       
   151 void MainView::showAboutPopup()
       
   152 {
       
   153     Notifications::about();
       
   154 }
       
   155 
       
   156 // ---------------------------------------------------------------------------
       
   157 
       
   158 void MainView::sendToBackground()
       
   159     {
       
   160     mEngineWrapper.sendUIToBackground();
       
   161     }
       
   162 
       
   163