Skip to content
Permalink
Browse files

Remove need for specifying the web browser. QDesktopServices are used…

… instead.

Drag and drop implementation.



git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8163 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
gsherman
gsherman committed Feb 16, 2008
1 parent 44a8b7e commit 19b2c1158653f75d866ba0bdd61ba0fe9758f5d7
Showing with 47 additions and 168 deletions.
  1. +43 −41 src/app/qgisapp.cpp
  2. +4 −0 src/app/qgisapp.h
  3. +0 −23 src/app/qgsoptions.cpp
  4. +0 −1 src/app/qgsoptions.h
  5. +0 −103 src/ui/qgsoptionsbase.ui
@@ -31,6 +31,7 @@
#include <QClipboard>
#include <QColor>
#include <QCursor>
#include <QDesktopServices>
#include <QDesktopWidget>
#include <QDialog>
#include <QDir>
@@ -401,6 +402,10 @@ static void customSrsValidation_(QgsSpatialRefSys* srs)
mSplash->showMessage(tr("QGIS Ready!"), Qt::AlignHCenter | Qt::AlignBottom);

mMapTipsVisible = false;

// setup drag drop
setAcceptDrops(true);

mFullScreenMode = false;
showNormal();
qApp->processEvents();
@@ -439,6 +444,43 @@ QgisApp::~QgisApp()
QgsApplication::exitQgis();
}

void QgisApp::dragEnterEvent(QDragEnterEvent *event)
{
if (event->mimeData()->hasUrls())
{
event->acceptProposedAction();
}
}

void QgisApp::dropEvent(QDropEvent *event)
{
// get the file list
QList<QUrl>::iterator i;
QList<QUrl>urls = event->mimeData()->urls();
for (i = urls.begin(); i != urls.end(); i++)
{
QUrl mUrl = *i;
// seems that some drag and drop operations include an empty url
// so we test for length to make sure we have something
if( mUrl.path().length() > 0)
{
// check to see if we are opening a project file
QFileInfo fi(mUrl.path());
if( fi.completeSuffix() == "qgs" )
{
QgsDebugMsg("Opening project " + mUrl.path());
}
else
{
QgsDebugMsg("Adding " + mUrl.path() + " to the map canvas");
openLayer(mUrl.path());
}
}
}
event->acceptProposedAction();
}


// restore any application settings stored in QSettings
void QgisApp::readSettings()
{
@@ -4259,47 +4301,7 @@ void QgisApp::openURL(QString url, bool useQgisDocDirectory)
status = 0; //avoid compiler warning
CFRelease(urlRef);
#else
// find a browser
QSettings settings;
QString browser = settings.readEntry("/qgis/browser");
if (browser.length() == 0)
{
// ask user for browser and use it
bool ok;
QString myHeading = tr("QGIS Browser Selection");
QString myMessage = tr("Enter the name of a web browser to use (eg. konqueror).\n");
myMessage += tr("Enter the full path if the browser is not in your PATH.\n");
myMessage += tr("You can change this option later by selecting Options from the Settings menu (Help Browser tab).");
QString text = QInputDialog::getText(myHeading,
myMessage,
QLineEdit::Normal,
QString::null, &ok, this);
if (ok && !text.isEmpty())
{
// user entered something and pressed OK
browser = text;
// save the setting
settings.writeEntry("/qgis/browser", browser);
}
else
{
browser = "";
}

}
if (browser.length() > 0)
{
// find the installed location of the help files
// open index.html using browser
//XXX for debug on win32 QMessageBox::information(this,"Help opening...", browser + " - " + url);
QProcess *helpProcess = new QProcess(this);
QStringList myArgs;
myArgs << url;
helpProcess->start(browser,myArgs);
}
/* mHelpViewer = new QgsHelpViewer(this,"helpviewer",false);
mHelpViewer->showContent(QgsApplication::prefixPath() +"/share/doc","index.html");
mHelpViewer->show(); */
QDesktopServices::openUrl(url);
#endif
}

@@ -145,6 +145,10 @@ class QgisApp : public QMainWindow, public Ui::QgisAppBase
//! Returns a pointer to the internal clipboard
QgsClipboard * clipboard();

void dragEnterEvent(QDragEnterEvent *);

void dropEvent(QDropEvent *);

//private slots:
public slots:
//! About QGis
@@ -53,8 +53,6 @@ QgsOptions::QgsOptions(QWidget *parent, Qt::WFlags fl) :
qparent = parent;
// read the current browser and set it
QSettings settings;
QString browser = settings.readEntry("/qgis/browser");
cmbBrowser->setCurrentText(browser);
#ifdef QGISDEBUG
std::cout << "Standard Identify radius setting: " << QGis::DEFAULT_IDENTIFY_RADIUS << std::endl;
#endif
@@ -223,7 +221,6 @@ QString QgsOptions::theme()
void QgsOptions::saveOptions()
{
QSettings settings;
settings.writeEntry("/qgis/browser", cmbBrowser->currentText());
settings.writeEntry("/Map/identifyRadius", spinBoxIdentifyValue->value());
settings.writeEntry("/qgis/hideSplash",cbxHideSplash->isChecked());
settings.writeEntry("/qgis/new_layers_visible",chkAddedVisibility->isChecked());
@@ -300,26 +297,6 @@ void QgsOptions::saveOptions()
}


void QgsOptions::on_btnFindBrowser_clicked()
{
QString filter;
#ifdef WIN32
filter = "Applications (*.exe)";
#else
filter = "All Files (*)";
#endif
QString browser = QFileDialog::getOpenFileName(
this,
"Choose a browser",
"./",
filter );
if(browser.length() > 0)
{
cmbBrowser->setCurrentText(browser);
}
}


void QgsOptions::on_pbnSelectProjection_clicked()
{
QSettings settings;
@@ -49,7 +49,6 @@ class QgsOptions :public QDialog, private Ui::QgsOptionsBase
public slots:
//! Slot called when user chooses to change the project wide projection.
void on_pbnSelectProjection_clicked();
void on_btnFindBrowser_clicked();
void on_chkAntiAliasing_stateChanged();
void on_chkUseQPixmap_stateChanged();
void saveOptions();
@@ -1021,107 +1021,6 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tabHelpBrowser" >
<attribute name="title" >
<string>Help &amp;Browser</string>
</attribute>
<layout class="QGridLayout" >
<property name="margin" >
<number>11</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="2" column="0" colspan="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="3" >
<widget class="QLabel" name="textLabel1_2" >
<property name="text" >
<string>&lt;b>Note:&lt;/b> The browser must be in your PATH or you can specify the full path above</string>
</property>
<property name="wordWrap" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="QPushButton" name="btnFindBrowser" >
<property name="maximumSize" >
<size>
<width>60</width>
<height>32767</height>
</size>
</property>
<property name="text" >
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QComboBox" name="cmbBrowser" >
<property name="editable" >
<bool>true</bool>
</property>
<item>
<property name="text" >
<string>epiphany</string>
</property>
</item>
<item>
<property name="text" >
<string>firefox</string>
</property>
</item>
<item>
<property name="text" >
<string>mozilla-firefox</string>
</property>
</item>
<item>
<property name="text" >
<string>galeon</string>
</property>
</item>
<item>
<property name="text" >
<string>konqueror</string>
</property>
</item>
<item>
<property name="text" >
<string>mozilla</string>
</property>
</item>
<item>
<property name="text" >
<string>opera</string>
</property>
</item>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="textLabel1" >
<property name="text" >
<string>Open help documents with</string>
</property>
<property name="buddy" >
<cstring>cmbBrowser</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
@@ -1136,7 +1035,6 @@
</customwidgets>
<tabstops>
<tabstop>tabWidget</tabstop>
<tabstop>btnFindBrowser</tabstop>
<tabstop>cbxHideSplash</tabstop>
<tabstop>cmbTheme</tabstop>
<tabstop>pbnSelectionColour</tabstop>
@@ -1150,7 +1048,6 @@
<tabstop>radUseGlobalProjection</tabstop>
<tabstop>txtGlobalWKT</tabstop>
<tabstop>pbnSelectProjection</tabstop>
<tabstop>cmbBrowser</tabstop>
</tabstops>
<resources/>
<connections/>

0 comments on commit 19b2c11

Please sign in to comment.
You can’t perform that action at this time.