Skip to content

Commit

Permalink
Moved some options logic out of qgisapp into qgsoptions
Browse files Browse the repository at this point in the history
Added a checkbox for anti-aliasing (not wired in yet)
Got rid of path calcs in favour of qgsapplication::foo()



git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@4660 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Jan 12, 2006
1 parent 1d3416d commit d0f1190
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 34 deletions.
15 changes: 0 additions & 15 deletions src/gui/qgisapp.cpp
Expand Up @@ -4551,29 +4551,14 @@ void QgisApp::socketReadyRead()
void QgisApp::options()
{
QgsOptions *optionsDialog = new QgsOptions(this);

// add the themes to the combo box on the option dialog
QDir themeDir(mAppDir + "/share/qgis/themes");
themeDir.setFilter(QDir::Dirs);
QStringList dirs = themeDir.entryList("*");
for(int i=0; i < dirs.count(); i++)
{
if(dirs[i] != "." && dirs[i] != "..")
{
optionsDialog->addTheme(dirs[i]);
}
}
optionsDialog->setCurrentTheme();
if(optionsDialog->exec())
{
// set the theme if it changed
setTheme(optionsDialog->theme());
setupToolbarPopups(optionsDialog->theme());

// set the visible flag for new layers
mAddedLayersHidden = optionsDialog->newVisible();
}

}

void QgisApp::helpContents()
Expand Down
31 changes: 18 additions & 13 deletions src/gui/qgsoptions.cpp
Expand Up @@ -16,6 +16,7 @@
* *
***************************************************************************/
/* $Id$ */
#include "qgsapplication.h"
#include "qgsoptions.h"
#include "qgis.h"
#include "qgisapp.h"
Expand Down Expand Up @@ -82,10 +83,22 @@ QgsOptions::QgsOptions(QWidget *parent, const char *name, bool modal) :
txtGlobalWKT->setText(myProjString);

// populate combo box with ellipsoids
mQGisSettingsDir = QDir::homeDirPath () + "/.qgis/";
getEllipsoidList();
QString myEllipsoidId = settings.readEntry("/qgis/measure/ellipsoid", "WGS84");
cmbEllipsoid->setCurrentText(getEllipsoidName(myEllipsoidId));
// add the themes to the combo box on the option dialog
QDir myThemeDir(QgsApplication::themePath());
myThemeDir.setFilter(QDir::Dirs);
QStringList myDirList = myThemeDir.entryList("*");
for(int i=0; i < myDirList.count(); i++)
{
if(myDirList[i] != "." && myDirList[i] != "..")
{
cmbTheme->insertItem(myDirList[i]);
}
}
// set the theme combo
cmbTheme->setCurrentText(settings.readEntry("/Themes","default"));
}

//! Destructor
Expand All @@ -110,6 +123,7 @@ void QgsOptions::saveOptions()
settings.writeEntry("/Map/identifyRadius", spinBoxIdentifyValue->value());
settings.writeEntry("/qgis/hideSplash",cbxHideSplash->isChecked());
settings.writeEntry("/qgis/new_layers_visible",!chkAddedVisibility->isChecked());
settings.writeEntry("/qgis/enable_anti_aliasing",chkAntiAliasing->isChecked());
if(cmbTheme->currentText().length() == 0)
{
settings.writeEntry("/Themes", "default");
Expand Down Expand Up @@ -150,18 +164,9 @@ void QgsOptions::on_cbxHideSplash_toggled( bool )

}

void QgsOptions::addTheme(QString item)
{
cmbTheme->insertItem(item);
}



void QgsOptions::setCurrentTheme()
{
QSettings settings;
cmbTheme->setCurrentText(settings.readEntry("/Themes","default"));
}

void QgsOptions::on_btnFindBrowser_clicked()
{
Expand Down Expand Up @@ -228,7 +233,7 @@ void QgsOptions::getEllipsoidList()
sqlite3_stmt *myPreparedStatement;
int myResult;
//check the db is available
myResult = sqlite3_open(QString(mQGisSettingsDir+"qgis.db").latin1(), &myDatabase);
myResult = sqlite3_open(QString(QgsApplication::srsDbFilePath()+"qgis.db").latin1(), &myDatabase);
if(myResult)
{
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
Expand Down Expand Up @@ -261,7 +266,7 @@ QString QgsOptions::getEllipsoidAcronym(QString theEllipsoidName)
int myResult;
QString myName;
//check the db is available
myResult = sqlite3_open(QString(mQGisSettingsDir+"qgis.db").latin1(), &myDatabase);
myResult = sqlite3_open(QString(QgsApplication::srsDbFilePath()+"qgis.db").latin1(), &myDatabase);
if(myResult)
{
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
Expand Down Expand Up @@ -293,7 +298,7 @@ QString QgsOptions::getEllipsoidName(QString theEllipsoidAcronym)
int myResult;
QString myName;
//check the db is available
myResult = sqlite3_open(QString(mQGisSettingsDir+"qgis.db").latin1(), &myDatabase);
myResult = sqlite3_open((QgsApplication::srsDbFilePath()+"qgis.db").latin1(), &myDatabase);
if(myResult)
{
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
Expand Down
9 changes: 3 additions & 6 deletions src/gui/qgsoptions.h
Expand Up @@ -43,16 +43,14 @@ class QgsOptions :public QDialog, private Ui::QgsOptionsBase
QString theme();

public slots:
//! Slot to change the theme this is handled when the user
// activates or highlights a theme name in the drop-down list
void themeChanged(const QString &);
//! Slot called when user chooses to change the project wide projection.
void on_pbnSelectProjection_clicked();
void on_btnFindBrowser_clicked();
void setCurrentTheme();
void addTheme(QString item);
void on_cbxHideSplash_toggled( bool );
void saveOptions();
//! Slot to change the theme this is handled when the user
// activates or highlights a theme name in the drop-down list
void themeChanged(const QString &);

/**
* Return the desired state of newly added layers. If a layer
Expand All @@ -66,7 +64,6 @@ class QgsOptions :public QDialog, private Ui::QgsOptionsBase

QString getEllipsoidAcronym(QString theEllipsoidName);
QString getEllipsoidName(QString theEllipsoidAcronym);
QString mQGisSettingsDir;

private:
//! Pointer to our parent
Expand Down
2 changes: 2 additions & 0 deletions src/legend/qgslegend.cpp
Expand Up @@ -71,6 +71,8 @@ QgsLegend::QgsLegend(QgisApp* app, QWidget * parent, const char *name)
setHeaderLabels(myList);
//added by Tim to hide the header - header is unneccessary
header()->setHidden(1);
setRootIsDecorated(true);

}


Expand Down
22 changes: 22 additions & 0 deletions src/ui/qgsoptionsbase.ui
Expand Up @@ -213,6 +213,28 @@
<number>6</number>
</property>
<item row="2" column="0" >
<widget class="QGroupBox" name="groupBox_8" >
<property name="title" >
<string>Anti-aliasing</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="0" >
<widget class="QCheckBox" name="chkAntiAliasing" >
<property name="text" >
<string>Make lines appear less jagged at the expense of some drawing performance</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
Expand Down

0 comments on commit d0f1190

Please sign in to comment.