marble_part.cpp 75 KB
Newer Older
Tobias Koenig's avatar
Tobias Koenig committed
1
//
2
// This file is part of the Marble Virtual Globe.
Tobias Koenig's avatar
Tobias Koenig committed
3
4
5
6
7
//
// This program is free software licensed under the GNU LGPL. You can
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
8
9
// Copyright 2007      Tobias Koenig  <tokoe@kde.org>
// Copyright 2008      Inge Wallin    <inge@lysator.liu.se>
10
// Copyright 2009      Jens-Michael Hoffmann <jensmh@gmx.de>
Bastian Holst's avatar
Bastian Holst committed
11
// Copyright 2010      Harshit Jain   <hjain.itbhu@gmail.com>
Tobias Koenig's avatar
Tobias Koenig committed
12
13
//

14
15
16
17
// Own
#include "marble_part.h"

// Qt
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <QDir>
#include <QPointer>
#include <QStringList>
#include <QTimer>
#include <QClipboard>
#include <QLabel>
#include <QFontMetrics>
#include <QPrinter>
#include <QPrintDialog>
#include <QProgressBar>
#include <QStandardItemModel>
#include <QShortcut>
#include <QNetworkProxy>
Dennis Nienhüser's avatar
Dennis Nienhüser committed
31
32
33
34
35
36
#include <QLabel>
#include <QDomDocument>
#include <QDomNodeList>
#include <QFileDialog>
#include <QMenu>
#include <QStatusBar>
Tobias Koenig's avatar
Tobias Koenig committed
37

38
// KDE
39
#include <kaboutdata.h>
Tobias Koenig's avatar
Tobias Koenig committed
40
#include <kactioncollection.h>
Torsten Rahn's avatar
Torsten Rahn committed
41
#include <kconfigdialog.h>
Dennis Nienhüser's avatar
Dennis Nienhüser committed
42
#include <klocalizedstring.h>
Tobias Koenig's avatar
Tobias Koenig committed
43
#include <kmessagebox.h>
44
#include <kpluginfactory.h>
Tobias Koenig's avatar
Tobias Koenig committed
45
46
#include <kparts/statusbarextension.h>
#include <kstandardaction.h>
47
#include <ktoggleaction.h>
Tobias Koenig's avatar
Tobias Koenig committed
48
#include <ktogglefullscreenaction.h>
Dennis Nienhüser's avatar
Dennis Nienhüser committed
49
50
#include <kns3/knewstuffaction.h>
#include <kns3/uploaddialog.h>
Tobias Koenig's avatar
Tobias Koenig committed
51

52
53
54
// Marble library classes
#include "AbstractFloatItem.h"
#include "AbstractDataPlugin.h"
55
#include "EditBookmarkDialog.h"
56
#include "BookmarkManager.h"
57
#include "BookmarkManagerDialog.h"
58
#include "CurrentLocationWidget.h"
59
#include "DialogConfigurationInterface.h"
60
#include "DownloadRegionDialog.h"
61
#include "GeoDataCoordinates.h"
62
#include "GeoDataFolder.h"
63
#include "GeoDataLatLonAltBox.h"
64
65
#include "GeoDataLookAt.h"
#include "GeoDataPlacemark.h"
66
#include "HttpDownloadManager.h"
67
#include "MarbleDirs.h"
68
#include "MarbleDebug.h"
Torsten Rahn's avatar
Torsten Rahn committed
69
#include "MarbleLocale.h"
70
#include "MarbleModel.h"
71
#include "MarblePluginSettingsWidget.h"
Utku Aydın's avatar
Utku Aydın committed
72
#include "MapWizard.h"
73
#include "NewBookmarkFolderDialog.h"
74
#include "RenderPluginModel.h"
75
76
77
#include "routing/RoutingManager.h"
#include "routing/RoutingProfilesModel.h"
#include "routing/RoutingProfilesWidget.h"
78
#include "routing/RouteRequest.h"
79
#include "SunControlWidget.h"
Bastian Holst's avatar
Bastian Holst committed
80
#include "TimeControlWidget.h"
81
82
#include "TileCoordsPyramid.h"
#include "ViewportParams.h"
Bastian Holst's avatar
Bastian Holst committed
83
#include "MarbleClock.h"
84
#include "ParseRunnerPlugin.h"
85
86
87
#include "PositionTracking.h"
#include "PositionProviderPlugin.h"
#include "PluginManager.h"
Dennis Nienhüser's avatar
Dennis Nienhüser committed
88
#include "SearchInputWidget.h"
89
#include "MarbleWidgetInputHandler.h"
90
#include "Planet.h"
91
#include "MapThemeDownloadDialog.h"
92
#include "cloudsync/BookmarkSyncManager.h"
93
#include "MovieCaptureDialog.h"
94
#include "cloudsync/RouteSyncManager.h"
95
96
97
98

// Marble non-library classes
#include "ControlView.h"
#include "settings.h"
Tobias Koenig's avatar
Tobias Koenig committed
99

100
101
using namespace Marble;

102
#include "ui_MarbleCacheSettingsWidget.h"
103
104
105
106
#include "ui_MarbleViewSettingsWidget.h"
#include "ui_MarbleNavigationSettingsWidget.h"
#include "ui_MarbleTimeSettingsWidget.h"

107
108
109
namespace Marble
{

Torsten Rahn's avatar
Torsten Rahn committed
110
111
namespace
{
Pino Toscano's avatar
Pino Toscano committed
112
    const char* POSITION_STRING = I18N_NOOP( "Position: %1" );
Torsten Rahn's avatar
Torsten Rahn committed
113
    const char* DISTANCE_STRING = I18N_NOOP( "Altitude: %1" );
114
    const char* TILEZOOMLEVEL_STRING = I18N_NOOP( "Tile Zoom Level: %1" );
115
    const char* DATETIME_STRING = I18N_NOOP( "Time: %1" );
Torsten Rahn's avatar
Torsten Rahn committed
116
117
}

118
119
K_PLUGIN_FACTORY(MarblePartFactory, registerPlugin<MarblePart>();)
K_EXPORT_PLUGIN(MarblePartFactory("marble"))
Tobias Koenig's avatar
Tobias Koenig committed
120

121
MarblePart::MarblePart( QWidget *parentWidget, QObject *parent, const QVariantList &arguments )
122
  : KParts::ReadOnlyPart( parent ),
Torsten Rahn's avatar
   
Torsten Rahn committed
123
    m_sunControlDialog( 0 ),
Bastian Holst's avatar
Bastian Holst committed
124
    m_timeControlDialog( 0 ),
125
    m_downloadRegionDialog( 0 ),
126
    m_movieCaptureDialog( 0 ),
127
    m_externalMapEditorAction( 0 ),
128
129
    m_recordMovieAction( 0 ),
    m_stopRecordingAction( 0 ),
Andrei Duma's avatar
Andrei Duma committed
130
    m_recentFilesAction( 0 ),
Torsten Rahn's avatar
Torsten Rahn committed
131
    m_configDialog( 0 ),
132
133
    m_position( i18n( NOT_AVAILABLE ) ),
    m_tileZoomLevel( i18n( NOT_AVAILABLE ) ),
134
    m_positionLabel( 0 ),
Torsten Rahn's avatar
   
Torsten Rahn committed
135
    m_distanceLabel( 0 )
Tobias Koenig's avatar
Tobias Koenig committed
136
{
137
    // only set marble data path when a path was given
138
139
    if ( arguments.count() != 0 && !arguments.first().toString().isEmpty() )
        MarbleDirs::setMarbleDataPath( arguments.first().toString() );
140

141
142
143
144
    // Setting measure system to provide nice standards for all unit questions.
    // This has to happen before any initialization so plugins (for example) can
    // use it during initialization.
    MarbleLocale *marbleLocale = MarbleGlobal::getInstance()->locale();
Dennis Nienhüser's avatar
Dennis Nienhüser committed
145
146
147
148
149
150
151
152
153
154
155
    // KF5 TODO: Read Connecting Calls to Catalogs" in ki18n programmer's guide
    //           and enable translations
    //     KLocale *kLocale = KGlobal::locale();
//     if ( kLocale->measureSystem() == KLocale::Metric ) {
//         marbleLocale->setMeasurementSystem( QLocale::MetricSystem );
//     }
//     else {
//         marbleLocale->setMeasurementSystem( QLocale::ImperialSystem );
//     }

    marbleLocale->setMeasurementSystem( MarbleLocale::ImperialSystem );
156
157
    migrateNewstuffConfigFiles();

158
159
160
161
162
    m_externalEditorMapping[0] = "";
    m_externalEditorMapping[1] = "potlatch";
    m_externalEditorMapping[2] = "josm";
    m_externalEditorMapping[3] = "merkaartor";

163
    m_controlView = new ControlView( parentWidget );
Tobias Koenig's avatar
Tobias Koenig committed
164
165
166
167

    setWidget( m_controlView );

    setupActions();
Torsten Rahn's avatar
Torsten Rahn committed
168

Tobias Koenig's avatar
Tobias Koenig committed
169
    setXMLFile( "marble_part.rc" );
170

Tobias Koenig's avatar
Tobias Koenig committed
171
    m_statusBarExtension = new KParts::StatusBarExtension( this );
Torsten Rahn's avatar
Torsten Rahn committed
172
    m_statusBarExtension->statusBar()->setUpdatesEnabled( false );
Tobias Koenig's avatar
Tobias Koenig committed
173

174
    // Load bookmark file. If it does not exist, a default one will be used.
175
    m_controlView->marbleModel()->bookmarkManager()->loadFile( "bookmarks/bookmarks.kml" );
176

Bastian Holst's avatar
Bastian Holst committed
177
    initializeCustomTimezone();
178
179
180
181

    setupStatusBar();
    readSettings();
    m_statusBarExtension->statusBar()->setUpdatesEnabled( true );
182

183
184
185
186
187
188
189
190
191
192
193
194
195
196
    // Show startup location
    switch ( MarbleSettings::onStartup() ) {
    case LastLocationVisited: {
            GeoDataLookAt target;
            target.setLongitude( MarbleSettings::quitLongitude() );
            target.setLatitude( MarbleSettings::quitLatitude() );
            target.setRange( MarbleSettings::quitRange() );
            m_controlView->marbleWidget()->flyTo( target, Instant );
        }
        break;
    case ShowHomeLocation:
        m_controlView->marbleWidget()->goHome( Instant );
        break;
    }
Utku Aydın's avatar
Utku Aydın committed
197

198
199
    connect( m_controlView, SIGNAL(showUploadDialog()), this, SLOT(showUploadNewStuffDialog()) );
    connect( m_controlView, SIGNAL(showMapWizard()), this, SLOT(showMapWizard()) );
200
    connect( m_controlView, SIGNAL(mapThemeDeleted()), this, SLOT(fallBackToDefaultTheme()) );
Tobias Koenig's avatar
Tobias Koenig committed
201
202
203
204
205
}

MarblePart::~MarblePart()
{
    writeSettings();
Torsten Rahn's avatar
Torsten Rahn committed
206
207

    // Check whether this delete is really needed.
Torsten Rahn's avatar
Torsten Rahn committed
208
    delete m_configDialog;
Tobias Koenig's avatar
Tobias Koenig committed
209
210
211
212
213
214
215
216
217
}

ControlView* MarblePart::controlView() const
{
    return m_controlView;
}

KAboutData *MarblePart::createAboutData()
{
Dennis Nienhüser's avatar
Dennis Nienhüser committed
218
219
220
221
222
    return new KAboutData( QString( I18N_NOOP( "marble_part" ) ),
                           QString( "Marble" ),
                           ControlView::applicationVersion(),
                           i18n( "A Virtual Globe" ),
                           KAboutLicense::LGPL_V2 );
Tobias Koenig's avatar
Tobias Koenig committed
223
224
}

Dennis Nienhüser's avatar
Dennis Nienhüser committed
225
bool MarblePart::openUrl( const QUrl &url )
Tobias Koenig's avatar
Tobias Koenig committed
226
{
Andrei Duma's avatar
Andrei Duma committed
227
228
229
230
231
232
    QFileInfo fileInfo( url.toLocalFile() );
    if ( fileInfo.isReadable() ) {
        m_controlView->marbleModel()->addGeoDataFile( url.toLocalFile() );
        m_recentFilesAction->addUrl( url );
        return true;
    }
Inge Wallin's avatar
Inge Wallin committed
233

Andrei Duma's avatar
Andrei Duma committed
234
    KMessageBox::error( widget(),
235
236
        i18n( "Sorry, unable to open '%1'. The file is not accessible." ).arg( fileInfo.fileName() ),
        i18n( "File not accessible" ) );
Andrei Duma's avatar
Andrei Duma committed
237
    return false;
Tobias Koenig's avatar
Tobias Koenig committed
238
239
240
241
}

bool MarblePart::openFile()
{
242
243
244
245
246
247
248
249
250
251
252
    const PluginManager *const pluginManager = m_controlView->marbleModel()->pluginManager();

    QStringList allFileExtensions;
    QStringList filters;
    foreach ( const ParseRunnerPlugin *plugin, pluginManager->parsingRunnerPlugins() ) {
        if ( plugin->nameId() == "Cache" )
            continue;

        const QStringList fileExtensions = plugin->fileExtensions().replaceInStrings( QRegExp( "^" ), "*." );
        const QString filter = QString( "%1|%2" ).arg( fileExtensions.join( " " ) ).arg( plugin->fileFormatDescription() );
        filters << filter;
Ander Pijoan's avatar
Ander Pijoan committed
253

254
255
256
257
258
259
260
261
        allFileExtensions << fileExtensions;
    }

    allFileExtensions.sort();
    const QString allFileTypes = QString( "%1|%2" ).arg( allFileExtensions.join( " " ) ).arg( i18n( "All Supported Files" ) );

    filters.sort();
    filters.prepend( allFileTypes );
262
    const QString filter = filters.join( ";;" );
263

Dennis Nienhüser's avatar
Dennis Nienhüser committed
264
265
    QStringList fileNames = QFileDialog::getOpenFileNames( widget(), i18n("Open File"),
                                                           m_lastFileOpenPath, filter );
266
267
268

    if ( !fileNames.isEmpty() ) {
        const QString firstFile = fileNames.first();
Dennis Nienhüser's avatar
Dennis Nienhüser committed
269
        m_lastFileOpenPath = QFileInfo( firstFile ).absolutePath();
270
271
    }

272
    foreach( const QString &fileName, fileNames ) {
273
        openUrl( QUrl::fromLocalFile(fileName) );
Tobias Koenig's avatar
Tobias Koenig committed
274
275
276
277
278
279
280
    }

    return true;
}

void MarblePart::exportMapScreenShot()
{
Dennis Nienhüser's avatar
Dennis Nienhüser committed
281
282
    QString  fileName = QFileDialog::getSaveFileName( widget(), i18n("Export Map"), QDir::homePath(),
                                                      i18n( "Images *.jpg *.png" ) );
Tobias Koenig's avatar
Tobias Koenig committed
283
284

    if ( !fileName.isEmpty() ) {
Torsten Rahn's avatar
   
Torsten Rahn committed
285
        // Take the case into account where no file format is indicated
Jens-Michael Hoffmann's avatar
Jens-Michael Hoffmann committed
286
        const char * format = 0;
Kevin Krammer's avatar
Kevin Krammer committed
287
288
        if ( !fileName.endsWith(QLatin1String( "png" ), Qt::CaseInsensitive)
           && !fileName.endsWith(QLatin1String( "jpg" ), Qt::CaseInsensitive) )
Torsten Rahn's avatar
   
Torsten Rahn committed
289
        {
Jens-Michael Hoffmann's avatar
Jens-Michael Hoffmann committed
290
            format = "JPG";
Torsten Rahn's avatar
   
Torsten Rahn committed
291
292
        }

Tobias Koenig's avatar
Tobias Koenig committed
293
        QPixmap mapPixmap = m_controlView->mapScreenShot();
Torsten Rahn's avatar
   
Torsten Rahn committed
294
        bool  success = mapPixmap.save( fileName, format );
Tobias Koenig's avatar
Tobias Koenig committed
295
296
297
298
299
300
301
302
        if ( !success ) {
            KMessageBox::error( widget(), i18nc( "Application name", "Marble" ),
                                i18n( "An error occurred while trying to save the file.\n" ),
                                KMessageBox::Notify );
        }
    }
}

303
304
305
void MarblePart::setShowBookmarks( bool show )
{
    m_controlView->marbleModel()->bookmarkManager()->setShowBookmarks( show );
Tobias Koenig's avatar
Tobias Koenig committed
306

307
308
    m_toggleBookmarkDisplayAction->setChecked( show ); // Sync state with the GUI
}
Tobias Koenig's avatar
Tobias Koenig committed
309

310
311
312
313
314
315
316
void MarblePart::setShowClouds( bool isChecked )
{
    m_controlView->marbleWidget()->setShowClouds( isChecked );

    m_showCloudsAction->setChecked( isChecked ); // Sync state with the GUI
}

317
318
319
320
321
322
323
324
325
326
void MarblePart::showPositionLabel( bool isChecked )
{
    m_positionLabel->setVisible( isChecked );
}

void MarblePart::showAltitudeLabel( bool isChecked )
{
    m_distanceLabel->setVisible( isChecked );
}

327
328
329
330
331
void MarblePart::showTileZoomLevelLabel( bool isChecked )
{
    m_tileZoomLevelLabel->setVisible( isChecked );
}

Bastian Holst's avatar
Bastian Holst committed
332
333
334
335
336
void MarblePart::showDateTimeLabel( bool isChecked )
{
    m_clockLabel->setVisible( isChecked );
}

337
338
void MarblePart::showDownloadProgressBar( bool isChecked )
{
339
340
341
    MarbleSettings::setShowDownloadProgressBar( isChecked );
    // Change visibility only if there is a download happening
    m_downloadProgressBar->setVisible( isChecked && m_downloadProgressBar->value() >= 0 );
342
343
}

Tobias Koenig's avatar
Tobias Koenig committed
344
345
void MarblePart::showFullScreen( bool isChecked )
{
Dennis Nienhüser's avatar
Dennis Nienhüser committed
346
347
    if ( QApplication::activeWindow() )
        KToggleFullScreenAction::setFullScreen( QApplication::activeWindow(), isChecked );
Tobias Koenig's avatar
Tobias Koenig committed
348
349
350
351
352
353
354
355
356
357
358
359

    m_fullScreenAct->setChecked( isChecked ); // Sync state with the GUI
}

void MarblePart::showStatusBar( bool isChecked )
{
    if ( !m_statusBarExtension->statusBar() )
        return;

    m_statusBarExtension->statusBar()->setVisible( isChecked );
}

360
void MarblePart::controlSun()
361
{
362
    if ( !m_sunControlDialog ) {
363
        m_sunControlDialog = new SunControlWidget( m_controlView->marbleWidget(), m_controlView );
364
365
366
367
368
369
370
371
        connect( m_sunControlDialog, SIGNAL(showSun(bool)),
                 this,               SLOT (showSun(bool)) );
        connect( m_sunControlDialog, SIGNAL(showSun(bool)),
                 m_showShadow,               SLOT (setChecked(bool)) );
        connect( m_sunControlDialog,    SIGNAL(isLockedToSubSolarPoint(bool)),
                 m_lockToSubSolarPoint, SLOT (setChecked(bool)) );
        connect( m_sunControlDialog,         SIGNAL(isSubSolarPointIconVisible(bool)),
                 m_setSubSolarPointIconVisible, SLOT (setChecked(bool)) );
372
    }
373
374
375
376
377
378

    m_sunControlDialog->show();
    m_sunControlDialog->raise();
    m_sunControlDialog->activateWindow();
}

Bastian Holst's avatar
Bastian Holst committed
379
380
void MarblePart::controlTime()
{
Bernhard Beschow's avatar
Bernhard Beschow committed
381
    if ( !m_timeControlDialog )
Bastian Holst's avatar
Bastian Holst committed
382
    {
383
        m_timeControlDialog = new TimeControlWidget( m_controlView->marbleModel()->clock() );
Bastian Holst's avatar
Bastian Holst committed
384
385
386
387
388
389
    }
    m_timeControlDialog->show();
    m_timeControlDialog->raise();
    m_timeControlDialog->activateWindow();
}

390

391
392
void MarblePart::showSun( bool active )
{
393
    m_controlView->marbleWidget()->setShowSunShading( active );
Bastian Holst's avatar
Bastian Holst committed
394
395
396
    m_sunControlDialog->setSunShading( active );
}

Mohammed Nafees's avatar
Mohammed Nafees committed
397
void MarblePart::lockToSubSolarPoint( bool lock )
Bastian Holst's avatar
Bastian Holst committed
398
{
Mohammed Nafees's avatar
Mohammed Nafees committed
399
400
401
402
403
404
    m_controlView->marbleWidget()->setLockToSubSolarPoint( lock );
}

void MarblePart::setSubSolarPointIconVisible( bool show )
{
    m_controlView->marbleWidget()->setSubSolarPointIconVisible( show );
405
406
}

Torsten Rahn's avatar
Torsten Rahn committed
407
408
void MarblePart::workOffline( bool offline )
{
409
    m_controlView->setWorkOffline( offline );
410
411
    m_newStuffAction->setEnabled( !offline );
    m_downloadRegionAction->setEnabled( !offline );
Torsten Rahn's avatar
Torsten Rahn committed
412
413
}

Tobias Koenig's avatar
Tobias Koenig committed
414
415
416
void MarblePart::copyMap()
{
    QPixmap      mapPixmap = m_controlView->mapScreenShot();
Dennis Nienhüser's avatar
Dennis Nienhüser committed
417
    QClipboard  *clipboard = QApplication::clipboard();
Tobias Koenig's avatar
Tobias Koenig committed
418
419
420
421

    clipboard->setPixmap( mapPixmap );
}

422
423
void MarblePart::copyCoordinates()
{
424
425
    qreal lon = m_controlView->marbleWidget()->centerLongitude();
    qreal lat = m_controlView->marbleWidget()->centerLatitude();
426

427
    QString  positionString = GeoDataCoordinates( lon, lat, 0.0, GeoDataCoordinates::Degree ).toString();
428
429
430
431
432
    QClipboard  *clipboard = QApplication::clipboard();

    clipboard->setText( positionString );
}

Tobias Koenig's avatar
Tobias Koenig committed
433
void MarblePart::readSettings()
434
{
Dennis Nienhüser's avatar
Dennis Nienhüser committed
435
    qDebug() << "Start: MarblePart::readSettings()";
436

437
    // Set home position
438
439
440
    m_controlView->marbleModel()->setHome( MarbleSettings::homeLongitude(),
                                           MarbleSettings::homeLatitude(),
                                           MarbleSettings::homeZoom() );
441

442
    // Map theme and projection
443
444
445
446
447
    QString mapTheme = MarbleSettings::mapTheme();
    if ( mapTheme.isEmpty() ) {
        mapTheme = m_controlView->defaultMapThemeId();
    }
    m_controlView->marbleWidget()->setMapThemeId( mapTheme );
448
    m_controlView->marbleWidget()->setProjection( (Projection) MarbleSettings::projection() );
Torsten Rahn's avatar
   
Torsten Rahn committed
449

450
451
    m_controlView->marbleWidget()->setShowClouds( MarbleSettings::showClouds() );
    m_showCloudsAction->setChecked( MarbleSettings::showClouds() );
Torsten Rahn's avatar
Torsten Rahn committed
452
453
454
455

    workOffline( MarbleSettings::workOffline() );
    m_workOfflineAction->setChecked( MarbleSettings::workOffline() );

456
457
    m_lockFloatItemsAct->setChecked(MarbleSettings::lockFloatItemPositions());
    lockFloatItemPosition(MarbleSettings::lockFloatItemPositions());
Bernhard Beschow's avatar
Bernhard Beschow committed
458

459
460
    setShowBookmarks( MarbleSettings::showBookmarks() );

Torsten Rahn's avatar
   
Torsten Rahn committed
461
    // Sun
462
    m_controlView->marbleWidget()->setShowSunShading( MarbleSettings::showSun() );
Bastian Holst's avatar
Bastian Holst committed
463
    m_showShadow->setChecked( MarbleSettings::showSun() );
464
    m_controlView->marbleWidget()->setShowCityLights( MarbleSettings::showCitylights() );
Mohammed Nafees's avatar
Mohammed Nafees committed
465
466
467
468
    m_controlView->marbleWidget()->setSubSolarPointIconVisible( MarbleSettings::subSolarPointIconVisible() );
    m_controlView->marbleWidget()->setLockToSubSolarPoint( MarbleSettings::lockToSubSolarPoint() );
    m_setSubSolarPointIconVisible->setChecked( MarbleSettings::subSolarPointIconVisible() );
    m_lockToSubSolarPoint->setChecked( MarbleSettings::lockToSubSolarPoint() );
469

470
    // View
471
    m_initialGraphicsSystem = (GraphicsSystem) MarbleSettings::graphicsSystem();
472
473
    m_previousGraphicsSystem = m_initialGraphicsSystem;

Dennis Nienhüser's avatar
Dennis Nienhüser committed
474
    m_lastFileOpenPath = MarbleSettings::lastFileOpenDir();
475

476
477
478
    // Tracking settings
    readTrackingSettings();

479
480
481
482
483
    // Load previous route settings
    m_controlView->marbleModel()->routingManager()->readSettings();
    bool const startupWarning = MarbleSettings::showGuidanceModeStartupWarning();
    m_controlView->marbleModel()->routingManager()->setShowGuidanceModeStartupWarning( startupWarning );

Dennis Nienhüser's avatar
Dennis Nienhüser committed
484
    KSharedConfig::Ptr sharedConfig = KSharedConfig::openConfig();
485
    if ( sharedConfig->hasGroup( "Routing Profiles" ) ) {
Dennis Nienhüser's avatar
Dennis Nienhüser committed
486
        QList<RoutingProfile> profiles;
487
488
489
490
        KConfigGroup profilesGroup = sharedConfig->group( "Routing Profiles" );
        int numProfiles = profilesGroup.readEntry( "Num", 0 );
        for ( int i = 0; i < numProfiles; ++i ) {
            KConfigGroup profileGroup = profilesGroup.group( QString( "Profile %0" ).arg(i) );
491
            QString name = profileGroup.readEntry( "Name", i18n( "Unnamed" ) );
Dennis Nienhüser's avatar
Dennis Nienhüser committed
492
            RoutingProfile profile( name );
493
494
            foreach ( const QString& pluginName, profileGroup.groupList() ) {
                KConfigGroup pluginGroup = profileGroup.group( pluginName );
Dennis Nienhüser's avatar
Dennis Nienhüser committed
495
                profile.pluginSettings().insert( pluginName, QHash<QString, QVariant>() );
496
497
                foreach ( const QString& key, pluginGroup.keyList() ) {
                    if ( key != "Enabled" ) {
Dennis Nienhüser's avatar
Dennis Nienhüser committed
498
                        profile.pluginSettings()[ pluginName ].insert( key, pluginGroup.readEntry( key ) );
499
500
501
502
503
                    }
                }
            }
            profiles << profile;
        }
504
        m_controlView->marbleModel()->routingManager()->profilesModel()->setProfiles( profiles );
505
    } else {
506
        m_controlView->marbleModel()->routingManager()->profilesModel()->loadDefaultProfiles();
507
    }
508
509
510
511
512
    int const profileIndex = MarbleSettings::currentRoutingProfile();
    if ( profileIndex >= 0 && profileIndex < m_controlView->marbleModel()->routingManager()->profilesModel()->rowCount() ) {
        RoutingProfile profile = m_controlView->marbleModel()->routingManager()->profilesModel()->profiles().at( profileIndex );
        m_controlView->marbleModel()->routingManager()->routeRequest()->setRoutingProfile( profile );
    }
513

514
515
    PositionTracking *const tracking = m_controlView->marbleModel()->positionTracking();
    tracking->readSettings();
516
517
    QString positionProvider = MarbleSettings::activePositionTrackingPlugin();
    if ( !positionProvider.isEmpty() ) {
518
        const PluginManager* pluginManager = m_controlView->marbleModel()->pluginManager();
519
        foreach( const PositionProviderPlugin* plugin, pluginManager->positionProviderPlugins() ) {
520
            if ( plugin->nameId() == positionProvider ) {
521
522
                PositionProviderPlugin* instance = plugin->newInstance();
                tracking->setPositionProviderPlugin( instance );
523
524
525
526
527
                break;
            }
        }
    }

528
529
    readStatusBarSettings();

530
    updateSettings();
Bastian Holst's avatar
Bastian Holst committed
531
532
533
534

    // Time
    if( MarbleSettings::systemTime() == true  )
    {
535
        /* nothing to do */
Bastian Holst's avatar
Bastian Holst committed
536
537
538
    }
    else if( MarbleSettings::lastSessionTime() == true )
    {
539
540
        m_controlView->marbleModel()->setClockDateTime( MarbleSettings::dateTime() );
        m_controlView->marbleModel()->setClockSpeed( MarbleSettings::speedSlider() );
Bastian Holst's avatar
Bastian Holst committed
541
542
    }

Bastian Holst's avatar
Bastian Holst committed
543
    readPluginSettings();
544

545
    m_controlView->setExternalMapEditor( m_externalEditorMapping[MarbleSettings::externalMapEditor()] );
546

Dennis Nienhüser's avatar
Dennis Nienhüser committed
547
    CloudSyncManager* cloudSyncManager = m_controlView->cloudSyncManager();
548
549
550
    cloudSyncManager->setOwncloudCredentials( MarbleSettings::owncloudServer(),
                                              MarbleSettings::owncloudUsername(),
                                              MarbleSettings::owncloudPassword());
551
552
553
    cloudSyncManager->setSyncEnabled( MarbleSettings::enableSync() );
    cloudSyncManager->routeSyncManager()->setRouteSyncEnabled( MarbleSettings::syncRoutes() );
    cloudSyncManager->bookmarkSyncManager()->setBookmarkSyncEnabled( MarbleSettings::syncBookmarks() );
Tobias Koenig's avatar
Tobias Koenig committed
554
555
}

556
557
void MarblePart::readTrackingSettings()
{
558
    if( MarbleSettings::autoCenter() || MarbleSettings::recenterMode() ) {
559
        CurrentLocationWidget *trackingWidget = m_controlView->currentLocationWidget();
560
561
562
563
564
565
566
        if( trackingWidget ) {
            trackingWidget->setRecenterMode( MarbleSettings::recenterMode() );
            trackingWidget->setAutoZoom( MarbleSettings::autoZoom() );
            trackingWidget->setTrackVisible( MarbleSettings::trackVisible() );
            trackingWidget->setLastOpenPath( MarbleSettings::lastTrackOpenPath() );
            trackingWidget->setLastSavePath( MarbleSettings::lastTrackSavePath() );
        }
567
568
569
    }
}

570
571
572
573
574
575
576
577
578
579
void MarblePart::readStatusBarSettings()
{
    const bool showPos = MarbleSettings::showPositionLabel();
    m_showPositionAction->setChecked( showPos );
    showPositionLabel( showPos );

    const bool showAlt = MarbleSettings::showAltitudeLabel();
    m_showAltitudeAction->setChecked( showAlt );
    showAltitudeLabel( showAlt );

580
581
582
583
    const bool showTileZoom = MarbleSettings::showTileZoomLevelLabel();
    m_showTileZoomLevelAction->setChecked( showTileZoom );
    showTileZoomLevelLabel( showTileZoom );

Bastian Holst's avatar
Bastian Holst committed
584
585
586
587
    const bool showDateTime = MarbleSettings::showDateTimeLabel();
    m_showDateTimeAction->setChecked( showDateTime );
    showDateTimeLabel( showDateTime );

588
589
590
    const bool showProgress = MarbleSettings::showDownloadProgressBar();
    m_showDownloadProgressAction->setChecked( showProgress );
    showDownloadProgressBar( showProgress );
591
592
}

Tobias Koenig's avatar
Tobias Koenig committed
593
594
void MarblePart::writeSettings()
{
595
    // Get the 'quit' values from the widget and store them in the settings.
596
597
598
    qreal  quitLon = m_controlView->marbleWidget()->lookAt().longitude();
    qreal  quitLat = m_controlView->marbleWidget()->lookAt().latitude();
    qreal  quitRange = m_controlView->marbleWidget()->lookAt().range();
599
600
601

    MarbleSettings::setQuitLongitude( quitLon );
    MarbleSettings::setQuitLatitude( quitLat );
602
    MarbleSettings::setQuitRange( quitRange );
603

604
    // Get the 'home' values from the widget and store them in the settings.
605
606
    qreal  homeLon = 0;
    qreal  homeLat = 0;
607
608
    int     homeZoom = 0;

609
    m_controlView->marbleModel()->home( homeLon, homeLat, homeZoom );
Tobias Koenig's avatar
Tobias Koenig committed
610
611
612
    MarbleSettings::setHomeLongitude( homeLon );
    MarbleSettings::setHomeLatitude( homeLat );
    MarbleSettings::setHomeZoom( homeZoom );
613

Torsten Rahn's avatar
Torsten Rahn committed
614
615
616
617
618
619
    // Set default font
    MarbleSettings::setMapFont( m_controlView->marbleWidget()->defaultFont() );

    // Get whether animations to the target are enabled
    MarbleSettings::setAnimateTargetVoyage( m_controlView->marbleWidget()->animationsEnabled() );

620
    // Map theme and projection
Torsten Rahn's avatar
Torsten Rahn committed
621
    MarbleSettings::setMapTheme( m_controlView->marbleWidget()->mapThemeId() );
622
623
    MarbleSettings::setProjection( m_controlView->marbleWidget()->projection() );

624
    MarbleSettings::setShowClouds( m_controlView->marbleWidget()->showClouds() );
Torsten Rahn's avatar
Torsten Rahn committed
625
626

    MarbleSettings::setWorkOffline( m_workOfflineAction->isChecked() );
627

628
    MarbleSettings::setStillQuality( m_controlView->marbleWidget()->mapQuality( Still ) );
629
    MarbleSettings::setAnimationQuality( m_controlView->marbleWidget()->
630
                                         mapQuality( Animation ) );
631

632
633
    MarbleSettings::setShowBookmarks( m_controlView->marbleModel()->bookmarkManager()->showBookmarks() );

634
    // FIXME: Hopefully Qt will have a getter for this one in the future ...
635
    GraphicsSystem graphicsSystem = (GraphicsSystem) MarbleSettings::graphicsSystem();
636
637
    MarbleSettings::setGraphicsSystem( graphicsSystem );

Dennis Nienhüser's avatar
Dennis Nienhüser committed
638
    MarbleSettings::setLastFileOpenDir( m_lastFileOpenPath );
639

640
    MarbleSettings::setDistanceUnit( MarbleGlobal::getInstance()->locale()->measurementSystem() );
Torsten Rahn's avatar
Torsten Rahn committed
641
642
    MarbleSettings::setAngleUnit( m_controlView->marbleWidget()->defaultAngleUnit() );

Torsten Rahn's avatar
   
Torsten Rahn committed
643
    // Sun
644
645
    MarbleSettings::setShowSun( m_controlView->marbleWidget()->showSunShading() );
    MarbleSettings::setShowCitylights( m_controlView->marbleWidget()->showCityLights() );
Mohammed Nafees's avatar
Mohammed Nafees committed
646
647
    MarbleSettings::setLockToSubSolarPoint( m_controlView->marbleWidget()->isLockedToSubSolarPoint() );
    MarbleSettings::setSubSolarPointIconVisible( m_controlView->marbleWidget()->isSubSolarPointIconVisible() );
Torsten Rahn's avatar
   
Torsten Rahn committed
648

649
650
    // Tracking
    CurrentLocationWidget *trackingWidget = m_controlView->currentLocationWidget();
651
    if( trackingWidget )
652
653
654
655
656
657
658
659
    {
        MarbleSettings::setRecenterMode( trackingWidget->recenterMode() );
        MarbleSettings::setAutoZoom( trackingWidget->autoZoom() );
        MarbleSettings::setTrackVisible( trackingWidget->trackVisible() );
        MarbleSettings::setLastTrackOpenPath( trackingWidget->lastOpenPath() );
        MarbleSettings::setLastTrackSavePath( trackingWidget->lastSavePath() );
    }

660
    // Caches
661
662
    MarbleSettings::setVolatileTileCacheLimit( m_controlView->marbleWidget()->
                                               volatileTileCacheLimit() / 1024 );
663
    MarbleSettings::setPersistentTileCacheLimit( m_controlView->marbleModel()->
664
                                                 persistentTileCacheLimit() / 1024 );
Bernhard Beschow's avatar
Bernhard Beschow committed
665

Bastian Holst's avatar
Bastian Holst committed
666
    // Time
667
668
    MarbleSettings::setDateTime( m_controlView->marbleModel()->clockDateTime() );
    MarbleSettings::setSpeedSlider( m_controlView->marbleModel()->clockSpeed() );
Bastian Holst's avatar
Bastian Holst committed
669

Bastian Holst's avatar
Bastian Holst committed
670
    // Plugins
671
672
    writePluginSettings();

673
    QString positionProvider;
674
    PositionTracking* tracking = m_controlView->marbleModel()->positionTracking();
675
    tracking->writeSettings();
676
    if ( tracking->positionProviderPlugin() ) {
677
678
679
680
        positionProvider = tracking->positionProviderPlugin()->nameId();
    }
    MarbleSettings::setActivePositionTrackingPlugin( positionProvider );

681
682
    MarbleSettings::setLockFloatItemPositions( m_lockFloatItemsAct->isChecked() );

683
684
    writeStatusBarSettings();

Andrei Duma's avatar
Andrei Duma committed
685
    // Store recent files
Dennis Nienhüser's avatar
Dennis Nienhüser committed
686
    KSharedConfig::Ptr sharedConfig = KSharedConfig::openConfig();
Andrei Duma's avatar
Andrei Duma committed
687
688
    m_recentFilesAction->saveEntries( sharedConfig->group( "RecentFiles" ) );

689
    // Store current route settings
690
691
692
    RoutingManager *routingManager = m_controlView->marbleWidget()->model()->routingManager();
    routingManager->writeSettings();
    bool const startupWarning = routingManager->showGuidanceModeStartupWarning();
693
    MarbleSettings::setShowGuidanceModeStartupWarning( startupWarning );
694
695
696
    QList<RoutingProfile>  profiles = routingManager->profilesModel()->profiles();
    RoutingProfile const profile = routingManager->routeRequest()->routingProfile();
    MarbleSettings::setCurrentRoutingProfile( profiles.indexOf( profile ) );
697

698
699
700
    QList<QString> const editors = m_externalEditorMapping.values();
    MarbleSettings::setExternalMapEditor( editors.indexOf( m_controlView->externalMapEditor() ) );

701
702
    applyPluginState();

Dennis Nienhüser's avatar
Dennis Nienhüser committed
703
    MarbleSettings::self()->save();
Tobias Koenig's avatar
Tobias Koenig committed
704
705
}

706
707
708
709
void MarblePart::writeStatusBarSettings()
{
    MarbleSettings::setShowPositionLabel( m_showPositionAction->isChecked() );
    MarbleSettings::setShowAltitudeLabel( m_showAltitudeAction->isChecked() );
710
    MarbleSettings::setShowTileZoomLevelLabel( m_showTileZoomLevelAction->isChecked() );
Bastian Holst's avatar
Bastian Holst committed
711
    MarbleSettings::setShowDateTimeLabel( m_showDateTimeAction->isChecked() );
712
713
714
    MarbleSettings::setShowDownloadProgressBar( m_showDownloadProgressAction->isChecked() );
}

Tobias Koenig's avatar
Tobias Koenig committed
715
716
void MarblePart::setupActions()
{
Andrei Duma's avatar
Andrei Duma committed
717
    // Action: Recent Files
Dennis Nienhüser's avatar
Dennis Nienhüser committed
718
    m_recentFilesAction = KStandardAction::openRecent( this, SLOT(openUrl(QUrl)),
Andrei Duma's avatar
Andrei Duma committed
719
                                                       actionCollection() );
Dennis Nienhüser's avatar
Dennis Nienhüser committed
720
    KSharedConfig::Ptr sharedConfig = KSharedConfig::openConfig();
Andrei Duma's avatar
Andrei Duma committed
721
722
    m_recentFilesAction->loadEntries( sharedConfig->group( "RecentFiles" ) );

723
    // Action: Download Region
Dennis Nienhüser's avatar
Dennis Nienhüser committed
724
    m_downloadRegionAction = new QAction( this );
725
726
727
    m_downloadRegionAction->setText( i18nc( "Action for downloading an entire region of a map",
                                            "Download Region..." ));
    actionCollection()->addAction( "file_download_region", m_downloadRegionAction );
728
    connect( m_downloadRegionAction, SIGNAL(triggered()), SLOT(showDownloadRegionDialog()));
729

Tobias Koenig's avatar
Tobias Koenig committed
730
    // Action: Print Map
731
    m_printMapAction = KStandardAction::print( this, SLOT(printMapScreenShot()),
732
                                               actionCollection() );
Tobias Koenig's avatar
Tobias Koenig committed
733

734
    m_printPreviewAction = KStandardAction::printPreview( m_controlView, SLOT(printPreview()),
735
                                               actionCollection() );
736

Tobias Koenig's avatar
Tobias Koenig committed
737
    // Action: Export Map
Dennis Nienhüser's avatar
Dennis Nienhüser committed
738
    m_exportMapAction = new QAction( this );
Tobias Koenig's avatar
Tobias Koenig committed
739
    actionCollection()->addAction( "exportMap", m_exportMapAction );
740
    m_exportMapAction->setText( i18nc( "Action for saving the map to a file", "&Export Map..." ) );
Dennis Nienhüser's avatar
Dennis Nienhüser committed
741
742
    m_exportMapAction->setIcon( QIcon::fromTheme( "document-save-as" ) );
    actionCollection()->setDefaultShortcut( m_exportMapAction, Qt::CTRL + Qt::Key_S );
743
744
    connect( m_exportMapAction, SIGNAL(triggered(bool)),
             this,              SLOT(exportMapScreenShot()) );
Tobias Koenig's avatar
Tobias Koenig committed
745

746
    // Action: Work Offline
Dennis Nienhüser's avatar
Dennis Nienhüser committed
747
    m_workOfflineAction = new QAction( this );
Torsten Rahn's avatar
Torsten Rahn committed
748
    actionCollection()->addAction( "workOffline", m_workOfflineAction );
749
    m_workOfflineAction->setText( i18nc( "Action for toggling offline mode", "&Work Offline" ) );
Dennis Nienhüser's avatar
Dennis Nienhüser committed
750
    m_workOfflineAction->setIcon( QIcon::fromTheme( "user-offline" ) );
751
752
    m_workOfflineAction->setCheckable( true );
    m_workOfflineAction->setChecked( false );
753
754
    connect( m_workOfflineAction, SIGNAL(triggered(bool)),
             this,                SLOT(workOffline(bool)) );
755

Tobias Koenig's avatar
Tobias Koenig committed
756
    // Action: Copy Map to the Clipboard
757
    m_copyMapAction = KStandardAction::copy( this, SLOT(copyMap()),
Bernhard Beschow's avatar
Bernhard Beschow committed
758
                                             actionCollection() );
759
    m_copyMapAction->setText( i18nc( "Action for copying the map to the clipboard", "&Copy Map" ) );
760

761
    // Action: Copy Coordinates string
Dennis Nienhüser's avatar
Dennis Nienhüser committed
762
    m_copyCoordinatesAction = new QAction( this );
763
    actionCollection()->addAction( "edit_copy_coordinates",
Bernhard Beschow's avatar
Bernhard Beschow committed
764
                                   m_copyCoordinatesAction );
765
766
    m_copyCoordinatesAction->setText( i18nc( "Action for copying the coordinates to the clipboard",
                                             "C&opy Coordinates" ) );
Dennis Nienhüser's avatar
Dennis Nienhüser committed
767
    m_copyCoordinatesAction->setIcon( QIcon( ":/icons/copy-coordinates.png" ) );
768
769
    connect( m_copyCoordinatesAction, SIGNAL(triggered(bool)),
             this,                    SLOT(copyCoordinates()) );
770

Tobias Koenig's avatar
Tobias Koenig committed
771
    // Action: Open a Gpx or a Kml File
772
    m_openAct = KStandardAction::open( this, SLOT(openFile()),
Bernhard Beschow's avatar
Bernhard Beschow committed
773
                                       actionCollection() );
774
    m_openAct->setText( i18nc( "Action for opening a file", "&Open..." ) );
Tobias Koenig's avatar
Tobias Koenig committed
775
776

    // Standard actions.  So far only Quit.
Dennis Nienhüser's avatar
Dennis Nienhüser committed
777
    KStandardAction::quit( qApp, SLOT(closeAllWindows()),
Bernhard Beschow's avatar
Bernhard Beschow committed
778
                           actionCollection() );
Tobias Koenig's avatar
Tobias Koenig committed
779

780
    // Action: Get hot new stuff
781
782
783
    m_newStuffAction = KNS3::standardAction( i18nc( "Action for downloading maps (GHNS)",
                                                    "Download Maps..."),
                                             this,
784
                                             SLOT(showNewStuffDialog()),
785
                                             actionCollection(), "new_stuff" );
786
    m_newStuffAction->setStatusTip( i18nc( "Status tip", "Download new maps"));
Dennis Nienhüser's avatar
Dennis Nienhüser committed
787
    actionCollection()->setDefaultShortcut( m_newStuffAction, Qt::CTRL + Qt::Key_N );
788

789
    // Action: Create a New Map
Dennis Nienhüser's avatar
Dennis Nienhüser committed
790
    m_mapWizardAct = new QAction( i18nc( "Action for creating new maps",
791
792
                                         "&Create a New Map..." ),
                                  this );
Dennis Nienhüser's avatar
Dennis Nienhüser committed
793
    m_mapWizardAct->setIcon( QIcon( ":/icons/create-new-map.png" ) );
794
795
796
    actionCollection()->addAction( "createMap", m_mapWizardAct );
    m_mapWizardAct->setStatusTip( i18nc( "Status tip",
                                         "A wizard guides you through the creation of your own map theme." ) );
797
    connect( m_mapWizardAct, SIGNAL(triggered()), SLOT(showMapWizard()) );
798

799
    KStandardAction::showStatusbar( this, SLOT(showStatusBar(bool)),
Bernhard Beschow's avatar
Bernhard Beschow committed
800
                                    actionCollection() );
Tobias Koenig's avatar
Tobias Koenig committed
801

802
    m_fullScreenAct = KStandardAction::fullScreen( 0, 0, widget(),
Bernhard Beschow's avatar
Bernhard Beschow committed
803
                                                   actionCollection() );
804
805
    connect( m_fullScreenAct, SIGNAL(triggered(bool)),
             this,            SLOT(showFullScreen(bool)) );
Tobias Koenig's avatar
Tobias Koenig committed
806

807
    // Action: Show Crosshairs option
808
809
    QList<RenderPlugin *> pluginList = m_controlView->marbleWidget()->renderPlugins();
    QList<RenderPlugin *>::const_iterator i = pluginList.constBegin();
Jens-Michael Hoffmann's avatar
Jens-Michael Hoffmann committed
810
811
    QList<RenderPlugin *>::const_iterator const end = pluginList.constEnd();
    for (; i != end; ++i ) {
812
813
814
815
816
        if ( (*i)->nameId() == "crosshairs" ) {
            actionCollection()->addAction( "show_crosshairs", (*i)->action() );
        }
    }

817
    // Action: Show Clouds option
Dennis Nienhüser's avatar
Dennis Nienhüser committed
818
    m_showCloudsAction = new QAction( this );
819
820
821
    actionCollection()->addAction( "show_clouds", m_showCloudsAction );
    m_showCloudsAction->setCheckable( true );
    m_showCloudsAction->setChecked( true );
Dennis Nienhüser's avatar
Dennis Nienhüser committed
822
    m_showCloudsAction->setIcon( QIcon( ":/icons/clouds.png" ) );
823
    m_showCloudsAction->setText( i18nc( "Action for toggling clouds", "&Clouds" ) );
824
825
    connect( m_showCloudsAction, SIGNAL(triggered(bool)),
             this,               SLOT(setShowClouds(bool)) );
826

827
    // Action: Show Sunshade options
Dennis Nienhüser's avatar
Dennis Nienhüser committed
828
    m_controlSunAction = new QAction( this );
829
    actionCollection()->addAction( "control_sun", m_controlSunAction );
830
    m_controlSunAction->setText( i18nc( "Action for sun control dialog", "S&un Control..." ) );
831
832
    connect( m_controlSunAction, SIGNAL(triggered(bool)),
             this,               SLOT(controlSun()) );
833

834
    KStandardAction::redisplay( m_controlView->marbleWidget(), SLOT(reloadMap()), actionCollection() );
835

Bastian Holst's avatar
Bastian Holst committed
836
    // Action: Show Time options
Dennis Nienhüser's avatar
Dennis Nienhüser committed
837
    m_controlTimeAction = new QAction( this );
Bastian Holst's avatar
Bastian Holst committed
838
    actionCollection()->addAction( "control_time", m_controlTimeAction );
Dennis Nienhüser's avatar
Dennis Nienhüser committed
839
    m_controlTimeAction->setIcon( QIcon( ":/icons/clock.png" ) );
Bastian Holst's avatar
Bastian Holst committed
840
    m_controlTimeAction->setText( i18nc( "Action for time control dialog", "&Time Control..." ) );
841
842
    connect( m_controlTimeAction, SIGNAL(triggered(bool)),
         this,               SLOT(controlTime()) );
Bastian Holst's avatar
Bastian Holst committed
843

844
    // Action: Lock float items
Dennis Nienhüser's avatar
Dennis Nienhüser committed
845
    m_lockFloatItemsAct = new QAction ( this );
846
    actionCollection()->addAction( "options_lock_floatitems",
Bernhard Beschow's avatar
Bernhard Beschow committed
847
                                   m_lockFloatItemsAct );
848
849
    m_lockFloatItemsAct->setText( i18nc( "Action for locking float items on the map",
                                         "Lock Position" ) );
Dennis Nienhüser's avatar
Dennis Nienhüser committed
850
    m_lockFloatItemsAct->setIcon( QIcon( ":/icons/unlock.png" ) );
851
852
    m_lockFloatItemsAct->setCheckable( true );
    m_lockFloatItemsAct->setChecked( false );
853
854
    connect( m_lockFloatItemsAct, SIGNAL(triggered(bool)),
             this,                SLOT(lockFloatItemPosition(bool)) );
855

856
    KStandardAction::preferences( this, SLOT(editSettings()),
Bernhard Beschow's avatar
Bernhard Beschow committed
857
                                  actionCollection() );
858

Bastian Holst's avatar
Bastian Holst committed
859