Settings default filename is now "config.ini"
On Mac OS X and ubuntu, configuration file is saved in ~/.find_object Added Mac OS X packaging (DragNDrop) git-svn-id: http://find-object.googlecode.com/svn/trunk/find_object@16 620bd6b2-0a58-f614-fd9a-1bd335dccda9
This commit is contained in:
+33
-10
@@ -29,8 +29,6 @@ QT4_WRAP_CPP(moc_srcs ${headers_ui})
|
||||
### Qt Gui stuff end###
|
||||
|
||||
|
||||
|
||||
|
||||
SET(SRC_FILES
|
||||
./MainWindow.cpp
|
||||
./AddObjectDialog.cpp
|
||||
@@ -63,15 +61,24 @@ SET(LIBRARIES
|
||||
INCLUDE_DIRECTORIES(${INCLUDE_DIRS})
|
||||
|
||||
# create an executable file
|
||||
ADD_EXECUTABLE(find_object WIN32 ${SRC_FILES})
|
||||
IF(APPLE AND BUILD_AS_BUNDLE)
|
||||
ADD_EXECUTABLE(find_object MACOSX_BUNDLE ${SRC_FILES})
|
||||
ELSE()
|
||||
ADD_EXECUTABLE(find_object WIN32 ${SRC_FILES})
|
||||
ENDIF()
|
||||
# Linking with Qt libraries
|
||||
TARGET_LINK_LIBRARIES(find_object ${LIBRARIES})
|
||||
|
||||
IF(WIN32)
|
||||
IF(APPLE AND BUILD_AS_BUNDLE)
|
||||
SET_TARGET_PROPERTIES(find_object PROPERTIES
|
||||
OUTPUT_NAME ${CMAKE_BUNDLE_NAME})
|
||||
ELSEIF(WIN32)
|
||||
SET_TARGET_PROPERTIES(find_object PROPERTIES
|
||||
OUTPUT_NAME ${PROJECT_NAME})
|
||||
ENDIF(WIN32)
|
||||
|
||||
ELSE()
|
||||
SET_TARGET_PROPERTIES(find_object PROPERTIES
|
||||
OUTPUT_NAME ${PROJECT_PREFIX})
|
||||
ENDIF()
|
||||
|
||||
#---------------------------
|
||||
# Installation stuff
|
||||
@@ -79,12 +86,25 @@ ENDIF(WIN32)
|
||||
INSTALL(TARGETS find_object
|
||||
RUNTIME DESTINATION bin COMPONENT runtime
|
||||
BUNDLE DESTINATION "${CMAKE_BUNDLE_LOCATION}" COMPONENT runtime)
|
||||
|
||||
|
||||
#---------------------------
|
||||
# Dependencies packaging
|
||||
#---------------------------
|
||||
IF(APPLE AND BUILD_AS_BUNDLE)
|
||||
INSTALL(CODE "execute_process(COMMAND ln -s \"../MacOS/${CMAKE_BUNDLE_NAME}\" ${PROJECT_NAME}
|
||||
WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin)")
|
||||
ENDIF(APPLE AND BUILD_AS_BUNDLE)
|
||||
|
||||
SET(APPS "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin/${PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX}")
|
||||
IF(WIN32)
|
||||
IF((APPLE AND BUILD_AS_BUNDLE) OR WIN32)
|
||||
SET(plugin_dest_dir bin)
|
||||
SET(qtconf_dest_dir bin)
|
||||
|
||||
IF(APPLE)
|
||||
SET(plugin_dest_dir MacOS)
|
||||
SET(qtconf_dest_dir Resources)
|
||||
SET(APPS "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/MacOS/${CMAKE_BUNDLE_NAME}")
|
||||
ENDIF(APPLE)
|
||||
|
||||
# Install needed Qt plugins by copying directories from the qt installation
|
||||
# One can cull what gets copied by using 'REGEX "..." EXCLUDE'
|
||||
# Exclude debug libraries
|
||||
@@ -97,6 +117,9 @@ IF(WIN32)
|
||||
# install a qt.conf file
|
||||
# this inserts some cmake code into the install script to write the file
|
||||
SET(QT_CONF_FILE [Paths]\nPlugins=plugins)
|
||||
IF(APPLE)
|
||||
SET(QT_CONF_FILE [Paths]\nPlugins=MacOS/plugins)
|
||||
ENDIF(APPLE)
|
||||
INSTALL(CODE "
|
||||
file(WRITE \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"${QT_CONF_FILE}\")
|
||||
" COMPONENT runtime)
|
||||
@@ -115,5 +138,5 @@ IF(WIN32)
|
||||
include(\"BundleUtilities\")
|
||||
fixup_bundle(\"${APPS}\" \"\${QTPLUGINS}\" \"${DIRS}\")
|
||||
" COMPONENT runtime)
|
||||
ENDIF(WIN32)
|
||||
ENDIF((APPLE AND BUILD_AS_BUNDLE) OR WIN32)
|
||||
|
||||
|
||||
+12
-2
@@ -32,7 +32,12 @@ MainWindow::MainWindow(QWidget * parent) :
|
||||
connect(&cameraTimer_, SIGNAL(timeout()), this, SLOT(update()));
|
||||
|
||||
QByteArray geometry;
|
||||
#ifdef WIN32
|
||||
//TODO Maybe use the Documents and Settings
|
||||
Settings::loadSettings(Settings::iniDefaultFileName, &geometry);
|
||||
#else
|
||||
Settings::loadSettings(QString("%1/.%2/%3").arg(QDir::homePath()).arg(PROJECT_PREFIX).arg(Settings::iniDefaultFileName), &geometry);
|
||||
#endif
|
||||
this->restoreGeometry(geometry);
|
||||
|
||||
ui_->toolBox->setupUi();
|
||||
@@ -73,13 +78,18 @@ MainWindow::~MainWindow()
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent * event)
|
||||
{
|
||||
#ifdef WIN32
|
||||
//TODO Maybe use the Documents and Settings
|
||||
Settings::saveSettings(Settings::iniDefaultFileName, this->saveGeometry());
|
||||
#else
|
||||
Settings::saveSettings(QString("%1/.%2/%3").arg(QDir::homePath()).arg(PROJECT_PREFIX).arg(Settings::iniDefaultFileName), this->saveGeometry());
|
||||
#endif
|
||||
QMainWindow::closeEvent(event);
|
||||
}
|
||||
|
||||
void MainWindow::loadObjects()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Load objects..."), "", "*.obj");
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Load objects..."), QDir::homePath(), "*.obj");
|
||||
if(!fileName.isEmpty())
|
||||
{
|
||||
QFile file(fileName);
|
||||
@@ -113,7 +123,7 @@ void MainWindow::loadObjects()
|
||||
}
|
||||
void MainWindow::saveObjects()
|
||||
{
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save objects..."), Settings::currentDetectorType()+Settings::currentDescriptorType()+QString("%1.obj").arg(objects_.size()), "*.obj");
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save objects..."), (QDir::homePath() + "/") +Settings::currentDetectorType()+Settings::currentDescriptorType()+QString("%1.obj").arg(objects_.size()), "*.obj");
|
||||
if(!fileName.isEmpty())
|
||||
{
|
||||
if(!fileName.endsWith(".obj"))
|
||||
|
||||
+8
-1
@@ -381,10 +381,17 @@ void Object::contextMenuEvent(QContextMenuEvent * event)
|
||||
if(action == _saveImage)
|
||||
{
|
||||
QString text;
|
||||
if(_savedFileName.isEmpty())
|
||||
{
|
||||
#ifndef WIN32
|
||||
_savedFileName = QDir::homePath();
|
||||
#endif
|
||||
_savedFileName+="/figure.png";
|
||||
}
|
||||
text = QFileDialog::getSaveFileName(this, tr("Save figure to ..."), _savedFileName, "*.png *.xpm *.jpg *.pdf");
|
||||
if(!text.isEmpty())
|
||||
{
|
||||
if(!text.endsWith(".png") && !text.endsWith(".png") && !text.endsWith(".png") && !text.endsWith(".png"))
|
||||
if(!text.endsWith(".png") && !text.endsWith(".xpm") && !text.endsWith(".jpg") && !text.endsWith(".pdf"))
|
||||
{
|
||||
text.append(".png");//default
|
||||
}
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ ParametersMap Settings::defaultParameters_;
|
||||
ParametersMap Settings::parameters_;
|
||||
ParametersType Settings::parametersType_;
|
||||
Settings Settings::dummyInit_;
|
||||
const char * Settings::iniDefaultFileName = "./" PROJECT_NAME ".ini";
|
||||
const char * Settings::iniDefaultFileName = "config.ini";
|
||||
|
||||
void Settings::loadSettings(const QString & fileName, QByteArray * windowGeometry)
|
||||
{
|
||||
|
||||
+1
-1
@@ -116,7 +116,7 @@ class Settings
|
||||
public:
|
||||
virtual ~Settings(){}
|
||||
|
||||
static const char * iniDefaultFileName; // "./" PROJECT_NAME ".ini"
|
||||
static const char * iniDefaultFileName; // "config.ini"
|
||||
|
||||
static void loadSettings(const QString & fileName = iniDefaultFileName, QByteArray * windowGeometry = 0);
|
||||
static void saveSettings(const QString & fileName = iniDefaultFileName, const QByteArray & windowGeometry = QByteArray());
|
||||
|
||||
Reference in New Issue
Block a user