Skip to content
Permalink
Browse files

Fix for ticket #611 (add a "don't show this again toggle" to the snap

vertex warning dialog box)
Also includes a small re-organisation of the QgsMessageViewer class


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7668 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m
g_j_m committed Nov 27, 2007
1 parent 3d601d7 commit a34087c959b47ba3ec282b86d08ff98108b2a993
@@ -776,9 +776,10 @@ void QgsComposer::on_mActionExportAsSVG_activated(void)
// QT 4 QPicture does not support export to SVG, so we're still using Q3Picture.
// When QGIS moves to Qt 4.3, we can use QSvgGenerator instead.

QString myQSettingsLabel = "/UI/displaySVGWarning";
QSettings myQSettings;

bool displaySVGWarning = myQSettings.value("/UI/displaySVGWarning", true).toBool();
bool displaySVGWarning = myQSettings.value(myQSettingsLabel, true).toBool();

if (displaySVGWarning)
{
@@ -787,6 +788,7 @@ void QgsComposer::on_mActionExportAsSVG_activated(void)
m->setCheckBoxText(tr("Don't show this message again"));
m->setCheckBoxState(Qt::Unchecked);
m->setCheckBoxVisible(true);
m->setCheckBoxQSettingsLabel(myQSettingsLabel);
m->setMessageAsHtml(tr("<p>The SVG export function in Qgis has several "
"problems due to bugs and deficiencies in the "
"Qt4 svg code. Of note, text does not "
@@ -799,17 +801,6 @@ void QgsComposer::on_mActionExportAsSVG_activated(void)
"satisfactory."
"</p>"));
m->exec();

if (m->checkBoxState() == Qt::Checked)
{
myQSettings.setValue("/UI/displaySVGWarning", false); //turn off the warning next time
}
else
{
myQSettings.setValue("/UI/displaySVGWarning", true);
}
//delete m; // this causes a segfault

}
QString myLastUsedFile = myQSettings.readEntry("/UI/lastSaveAsSvgFile","qgis.svg");
QFileInfo file(myLastUsedFile);
@@ -24,10 +24,11 @@
#include "qgsmaptopixel.h"
#include "qgsproject.h"
#include "qgscursors.h"
#include "qgsmessageviewer.h"
#include <QMessageBox>
#include <QPixmap>
#include <QCursor>

#include <QSettings>

QgsMapToolVertexEdit::QgsMapToolVertexEdit(QgsMapCanvas* canvas, enum Tool tool)
: QgsMapTool(canvas), mTool(tool), mRubberBandIndex1(-1), mRubberBandIndex2(-1), mRubberBand(0)
@@ -128,8 +129,7 @@ void QgsMapToolVertexEdit::canvasPressEvent(QMouseEvent * e)
//Find nearest segment of the selected line, move that node to the mouse location
if (!snapSegmentWithContext(layerPoint))
{
QMessageBox::warning(0, QObject::tr("Error"),
QObject::tr("Could not snap segment. Have you set the tolerance in Settings > Project Properties > General?"));
displaySnapToleranceWarning();
return;
}

@@ -170,17 +170,15 @@ void QgsMapToolVertexEdit::canvasPressEvent(QMouseEvent * e)
{
if(!snapVertexWithContext(snapPoint))
{
QMessageBox::warning(0, QObject::tr("Error"),
QObject::tr("Could not snap segment. Have you set the tolerance in Settings > Project Properties > General?"));
displaySnapToleranceWarning();
return;
}
}
else //snap to segment and take the closest vertex in case of line/multiline/polygon/multipolygon layers
{
if (!snapSegmentWithContext(snapPoint))
{
QMessageBox::warning(0, QObject::tr("Error"),
QObject::tr("Could not snap segment. Have you set the tolerance in Settings > Project Properties > General?"));
displaySnapToleranceWarning();
return;
}

@@ -258,6 +256,28 @@ double QgsMapToolVertexEdit::tolerance()
return QgsProject::instance()->readDoubleEntry("Digitizing","/Tolerance",0);
}

void QgsMapToolVertexEdit::displaySnapToleranceWarning()
{
QSettings myQSettings;
QString myQSettingsLabel = "/UI/displaySnapWarning";
bool displaySnapWarning = myQSettings.value(myQSettingsLabel, true).toBool();

if (displaySnapWarning)
{
QgsMessageViewer* m = new QgsMessageViewer(0);
m->setWindowTitle(tr("Snap tolerance"));
m->setCheckBoxText(tr("Don't show this message again"));
m->setCheckBoxVisible(true);
m->setCheckBoxQSettingsLabel(myQSettingsLabel);
m->setMessageAsHtml("<p>" +
tr("Could not snap segment.") +
"</p><p>" +
tr("Have you set the tolerance in "
"Settings > Project Properties > General?") +
"</p>");
m->exec();
}
}

bool QgsMapToolVertexEdit::snapSegmentWithContext(QgsPoint& point)
{
@@ -65,6 +65,9 @@ class QgsMapToolVertexEdit : public QgsMapTool

//! current vertex edit tool
enum Tool mTool;

//! Displays a warning about the snap tolerance settings
void displaySnapToleranceWarning();

/**Searches the closest point within the project tolerance and setx mSnappedAtFeatureId and mSnappedAtVertex*/
bool snapVertexWithContext(QgsPoint& point);
@@ -27,6 +27,7 @@ qgsencodingfiledialog.h
qgslayerprojectionselector.h
qgsmapcanvas.h
qgsmapoverviewcanvas.h
qgsmessageviewer.h
qgsmaptoolemitpoint.h
qgsprojectionselector.h
)
@@ -17,7 +17,7 @@
/* $Id$ */

#include "qgsmessageviewer.h"

#include <QSettings>

QgsMessageViewer::QgsMessageViewer(QWidget *parent, Qt::WFlags fl)
: QDialog(parent, fl)
@@ -28,6 +28,8 @@ QgsMessageViewer::QgsMessageViewer(QWidget *parent, Qt::WFlags fl)
// Default state for the checkbox
setCheckBoxVisible(false);
setCheckBoxState(Qt::Unchecked);

mCheckBoxQSettingsLabel = "";
}

QgsMessageViewer::~QgsMessageViewer()
@@ -86,7 +88,20 @@ void QgsMessageViewer::setCheckBoxState(Qt::CheckState state)
checkBox->setCheckState(state);
}

Qt::CheckState QgsMessageViewer::checkBoxState()
void QgsMessageViewer::setCheckBoxQSettingsLabel(QString label)
{
mCheckBoxQSettingsLabel = label;
}


void QgsMessageViewer::on_checkBox_toggled(bool toggled)
{
return checkBox->checkState();
if (!mCheckBoxQSettingsLabel.isEmpty())
{
QSettings settings;
if (checkBox->checkState() == Qt::Checked)
settings.setValue(mCheckBoxQSettingsLabel, false);
else
settings.setValue(mCheckBoxQSettingsLabel, true);
}
}
@@ -22,8 +22,11 @@
#include <qgisgui.h>
#include "qgsmessageoutput.h"

#include <QString>

class GUI_EXPORT QgsMessageViewer: public QDialog, public QgsMessageOutput, private Ui::QgsMessageViewer
{
Q_OBJECT
public:
QgsMessageViewer(QWidget *parent = 0, Qt::WFlags fl = QgisGui::ModalDialogFlags);
~QgsMessageViewer();
@@ -51,8 +54,16 @@ class GUI_EXPORT QgsMessageViewer: public QDialog, public QgsMessageOutput, priv
void setCheckBoxVisible(bool visible);
// Sets the check state
void setCheckBoxState(Qt::CheckState state);
// The state of the checkbox
Qt::CheckState checkBoxState();
// Specifies a QSettings tag to store/retrieve the checkbox
// state to/from. Use an empty QString to disable this feature.
void setCheckBoxQSettingsLabel(QString label);

private slots:
void on_checkBox_toggled(bool);


private:
QString mCheckBoxQSettingsLabel;
};

#endif

0 comments on commit a34087c

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