50
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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: Handles command related to mediaeditors in fullscreen
|
|
15 |
* for image Rotate, Crop & Set as Wallpaper
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
#include <glxcommandfactory.h>
|
52
|
22 |
|
|
23 |
|
|
24 |
#ifdef FF_IMAGE_EDITOR
|
|
25 |
#include <photoeditor_highway.hrh>
|
|
26 |
#endif //FF_IMAGE_EDITOR
|
|
27 |
|
50
|
28 |
#include "glxcommandhandlereditimage.h"
|
|
29 |
#include <glxcommandhandlers.hrh>
|
|
30 |
#include <glxmodelparm.h>
|
|
31 |
#include <glxmediamodel.h>
|
|
32 |
#include <XQServiceRequest.h>
|
|
33 |
#include <XQAiwRequest.h>
|
|
34 |
|
54
|
35 |
GlxCommandHandlerEditImage::GlxCommandHandlerEditImage() :
|
|
36 |
mReq(NULL), mMediaModel(NULL)
|
50
|
37 |
{
|
|
38 |
//Nothing to do here
|
|
39 |
}
|
|
40 |
|
|
41 |
GlxCommandHandlerEditImage::~GlxCommandHandlerEditImage()
|
|
42 |
{
|
|
43 |
delete mReq;
|
|
44 |
mReq = NULL;
|
54
|
45 |
clearMediaModel();
|
50
|
46 |
}
|
|
47 |
|
54
|
48 |
void GlxCommandHandlerEditImage::executeCommand(int commandId,
|
|
49 |
int collectionId, QList<QModelIndex> /*indexList*/)
|
50
|
50 |
{
|
|
51 |
const QString service = QLatin1String("PhotoEditor");
|
|
52 |
const QString interface = QLatin1String("com.nokia.symbian.imageeditor");
|
|
53 |
const QString operation = QLatin1String("view(QString,int)");
|
|
54 |
|
|
55 |
//Connect to service provider
|
|
56 |
if(mReq == NULL)
|
|
57 |
{
|
|
58 |
mReq = mAppmgr.create(service, interface, operation, true);
|
|
59 |
mReq->setEmbedded(true);
|
54
|
60 |
mReq->setSynchronous(false);
|
50
|
61 |
}
|
|
62 |
|
|
63 |
if(mReq == NULL)
|
|
64 |
{
|
|
65 |
return;
|
54
|
66 |
}
|
|
67 |
|
|
68 |
connect(mReq, SIGNAL(requestOk(const QVariant&)), this, SLOT(handleOk(const QVariant&)));
|
|
69 |
connect(mReq, SIGNAL(requestError(int,const QString&)), this, SLOT(handleError(int,const QString&)));
|
|
70 |
|
|
71 |
GlxModelParm modelParm(collectionId, 0);
|
|
72 |
clearMediaModel();
|
|
73 |
mMediaModel = new GlxMediaModel(modelParm);
|
|
74 |
if (!mMediaModel)
|
|
75 |
{
|
|
76 |
return;
|
50
|
77 |
}
|
|
78 |
|
54
|
79 |
connect( mMediaModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SLOT( storeItems( QModelIndex, int, int ) ) );
|
|
80 |
|
50
|
81 |
//Get the file path for the item selected
|
54
|
82 |
QString imagePath = (mMediaModel->data(
|
|
83 |
mMediaModel->index(mMediaModel->data(mMediaModel->index(0, 0),
|
|
84 |
GlxFocusIndexRole).value<int> (), 0), GlxUriRole)).value<
|
|
85 |
QString> ();
|
|
86 |
//delete mediaModel;
|
|
87 |
|
50
|
88 |
QList<QVariant> args;
|
|
89 |
args << imagePath;
|
52
|
90 |
#ifdef FF_IMAGE_EDITOR
|
54
|
91 |
if(EGlxCmdSetWallpaper == commandId)
|
|
92 |
{
|
|
93 |
args << EEditorHighwayWallpaperCrop;
|
|
94 |
}
|
|
95 |
else if(EGlxCmdRotateImgCrop == commandId)
|
50
|
96 |
{
|
|
97 |
args << EEditorHighwayFreeCrop;
|
|
98 |
}
|
|
99 |
else if(EGlxCmdRotateImgCW == commandId)
|
|
100 |
{
|
|
101 |
args << EEditorHighwayRotateCW;
|
|
102 |
}
|
|
103 |
else // if(EGlxCmdRotateImgCCW == aCommandId)
|
54
|
104 |
|
50
|
105 |
{
|
|
106 |
args << EEditorHighwayRotateCCW;
|
|
107 |
}
|
|
108 |
mReq->setArguments(args);
|
52
|
109 |
#endif //FF_IMAGE_EDITOR
|
50
|
110 |
// Send the request
|
|
111 |
bool res = mReq->send();
|
54
|
112 |
if (!res)
|
50
|
113 |
{
|
54
|
114 |
// Request failed.
|
50
|
115 |
}
|
|
116 |
}
|
|
117 |
|
54
|
118 |
void GlxCommandHandlerEditImage::doHandleUserAction(GlxMediaModel* /*model*/,
|
|
119 |
QList<QModelIndex> /*indexList*/) const
|
|
120 |
{
|
|
121 |
//Dummy, to keepup with compiler error
|
|
122 |
}
|
|
123 |
|
|
124 |
void GlxCommandHandlerEditImage::handleOk(const QVariant& result)
|
|
125 |
{
|
|
126 |
//Nothing to do for - Needs further implementation to refine setting
|
|
127 |
//default image in fullscreen view
|
|
128 |
}
|
|
129 |
|
|
130 |
void GlxCommandHandlerEditImage::handleError(int errorCode,
|
|
131 |
const QString& errorMessage)
|
50
|
132 |
{
|
54
|
133 |
clearMediaModel();
|
50
|
134 |
}
|
54
|
135 |
|
|
136 |
void GlxCommandHandlerEditImage::storeItems(const QModelIndex &parent,
|
|
137 |
int aStartRow, int aEndRow)
|
|
138 |
{
|
|
139 |
//This implementation assumes that we will be getting only one new
|
|
140 |
//image creation notification. Needs refined implementation
|
|
141 |
if (mMediaModel)
|
|
142 |
{
|
|
143 |
QModelIndex modelIndex = mMediaModel->index(aStartRow, 0);
|
|
144 |
mMediaModel->setData(modelIndex, modelIndex.row(), GlxFocusIndexRole);
|
|
145 |
}
|
|
146 |
}
|
|
147 |
|
|
148 |
void GlxCommandHandlerEditImage::clearMediaModel()
|
|
149 |
{
|
|
150 |
if (mMediaModel)
|
|
151 |
{
|
|
152 |
disconnect(mMediaModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(storeItems(QModelIndex,int,int)));
|
|
153 |
delete mMediaModel;
|
|
154 |
mMediaModel = NULL;
|
|
155 |
}
|
|
156 |
}
|