Skip to content

Commit

Permalink
Remove need for specifying the web browser. QDesktopServices are used…
Browse files Browse the repository at this point in the history
… instead.

Drag and drop implementation.



git-svn-id: http://svn.osgeo.org/qgis/trunk@8163 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
gsherman committed Feb 16, 2008
1 parent de8c103 commit 369915a
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 168 deletions.
84 changes: 43 additions & 41 deletions src/app/qgisapp.cpp
Expand Up @@ -31,6 +31,7 @@
#include <QClipboard>
#include <QColor>
#include <QCursor>
#include <QDesktopServices>
#include <QDesktopWidget>
#include <QDialog>
#include <QDir>
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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()
{
Expand Down Expand Up @@ -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
}

Expand Down
4 changes: 4 additions & 0 deletions src/app/qgisapp.h
Expand Up @@ -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
Expand Down
23 changes: 0 additions & 23 deletions src/app/qgsoptions.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/app/qgsoptions.h
Expand Up @@ -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();
Expand Down
103 changes: 0 additions & 103 deletions src/ui/qgsoptionsbase.ui
Expand Up @@ -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>
Expand All @@ -1136,7 +1035,6 @@
</customwidgets>
<tabstops>
<tabstop>tabWidget</tabstop>
<tabstop>btnFindBrowser</tabstop>
<tabstop>cbxHideSplash</tabstop>
<tabstop>cmbTheme</tabstop>
<tabstop>pbnSelectionColour</tabstop>
Expand All @@ -1150,7 +1048,6 @@
<tabstop>radUseGlobalProjection</tabstop>
<tabstop>txtGlobalWKT</tabstop>
<tabstop>pbnSelectProjection</tabstop>
<tabstop>cmbBrowser</tabstop>
</tabstops>
<resources/>
<connections/>
Expand Down

0 comments on commit 369915a

Please sign in to comment.