File indexing completed on 2024-04-14 03:47:54
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2005-2007 Torsten Rahn <tackat@kde.org> 0004 // SPDX-FileCopyrightText: 2007 Inge Wallin <ingwa@kde.org> 0005 // 0006 0007 0008 #include "MarbleNavigator.h" 0009 0010 #include <QtAlgorithms> 0011 0012 #include "MarbleDebug.h" 0013 0014 #include "ui_MarbleNavigator.h" 0015 0016 namespace Marble 0017 { 0018 0019 class MarbleNavigatorPrivate 0020 { 0021 public: 0022 int m_minimumzoom; 0023 0024 Ui::MarbleNavigator uiWidget; 0025 }; 0026 0027 0028 MarbleNavigator::MarbleNavigator( QWidget *parent ) 0029 : QWidget( parent ), 0030 d( new MarbleNavigatorPrivate ) 0031 0032 { 0033 d->uiWidget.setupUi( this ); 0034 0035 d->m_minimumzoom = 950; 0036 0037 setFocusPolicy( Qt::NoFocus ); 0038 0039 connect( d->uiWidget.goHomeButton, SIGNAL(clicked()), 0040 this, SIGNAL(goHome()) ); 0041 connect( d->uiWidget.zoomSlider, SIGNAL(valueChanged(int)), 0042 this, SIGNAL(zoomChanged(int)) ); 0043 connect( d->uiWidget.zoomInButton, SIGNAL(clicked()), 0044 this, SIGNAL(zoomIn()) ); 0045 connect( d->uiWidget.zoomOutButton, SIGNAL(clicked()), 0046 this, SIGNAL(zoomOut()) ); 0047 0048 connect( d->uiWidget.moveLeftButton, SIGNAL(clicked()), 0049 this, SIGNAL(moveLeft()) ); 0050 connect( d->uiWidget.moveRightButton, SIGNAL(clicked()), 0051 this, SIGNAL(moveRight()) ); 0052 connect( d->uiWidget.moveUpButton, SIGNAL(clicked()), 0053 this, SIGNAL(moveUp()) ); 0054 connect( d->uiWidget.moveDownButton, SIGNAL(clicked()), 0055 this, SIGNAL (moveDown()) ); 0056 } 0057 0058 MarbleNavigator::~MarbleNavigator() 0059 { 0060 delete d; 0061 } 0062 0063 0064 int MarbleNavigator::minimumZoom() const 0065 { 0066 return d->m_minimumzoom; 0067 } 0068 0069 0070 void MarbleNavigator::changeZoom( int zoom ) 0071 { 0072 // No infinite loops here 0073 // if (zoomSlider->value() != zoom) 0074 d->uiWidget.zoomSlider->setValue( zoom ); 0075 d->uiWidget.zoomSlider->setMinimum( d->m_minimumzoom ); 0076 } 0077 0078 0079 void MarbleNavigator::resizeEvent ( QResizeEvent * ) 0080 { 0081 // m_pSpacerFrame->setSizePolicy( QSizePolicy::Preferred, 0082 // QSizePolicy::Fixed ); 0083 if ( height() < 100 ) { 0084 if ( !d->uiWidget.zoomSlider->isHidden() ) { 0085 d->uiWidget.zoomSlider->hide(); 0086 d->uiWidget.m_pSpacerFrame->setSizePolicy( QSizePolicy::Preferred, 0087 QSizePolicy::Expanding ); 0088 } 0089 } else { 0090 if ( d->uiWidget.zoomSlider->isHidden() ) { 0091 d->uiWidget.zoomSlider->show(); 0092 d->uiWidget.m_pSpacerFrame->setSizePolicy( QSizePolicy::Preferred, 0093 QSizePolicy::Fixed ); 0094 } 0095 } 0096 } 0097 0098 } 0099 0100 #include "moc_MarbleNavigator.cpp"