diff --git a/vlsisapd/src/configuration/src/CMakeLists.txt b/vlsisapd/src/configuration/src/CMakeLists.txt index f9e01320..7fca3224 100644 --- a/vlsisapd/src/configuration/src/CMakeLists.txt +++ b/vlsisapd/src/configuration/src/CMakeLists.txt @@ -6,7 +6,8 @@ ${LIBXML2_INCLUDE_DIR} ) - set ( mocIncludes vlsisapd/configuration/ConfigurationWidget.h + set ( mocIncludes vlsisapd/configuration/FilePathEdit.h + vlsisapd/configuration/ConfigurationWidget.h vlsisapd/configuration/ParameterWidget.h vlsisapd/configuration/ConfTabWidget.h vlsisapd/configuration/ConfEditorWidget.h @@ -18,6 +19,7 @@ set ( cpps Parameter.cpp LayoutDescription.cpp Configuration.cpp + FilePathEdit.cpp ParameterWidget.cpp ConfTabWidget.cpp ConfigurationWidget.cpp @@ -26,8 +28,9 @@ set ( editorcpp ConfEditorMain.cpp ) qt4_wrap_cpp ( mocCpps ${mocIncludes} ) + qt4_add_resources ( RCC_SRCS Configuration.qrc ) - add_library ( configuration ${cpps} ${mocCpps} ) + add_library ( configuration ${cpps} ${mocCpps} ${RCC_SRCS} ) target_link_libraries ( configuration ${QT_LIBRARIES} ${PYTHON_LIBRARIES} ${LIBXML2_LIBRARIES} diff --git a/vlsisapd/src/configuration/src/ConfEditorMain.cpp b/vlsisapd/src/configuration/src/ConfEditorMain.cpp index c0e6976b..ca923dc6 100644 --- a/vlsisapd/src/configuration/src/ConfEditorMain.cpp +++ b/vlsisapd/src/configuration/src/ConfEditorMain.cpp @@ -48,11 +48,15 @@ int main ( int argc, char* argv[] ) int returnCode = 0; try { + bool disableGtkStyle; + boptions::options_description options ("Command line arguments & options"); options.add_options() - ( "help,h", "Print this help." ) - ( "conf,c", boptions::value() - , "The path of the configuration file." ); + ( "help,h" , "Print this help." ) + ( "disable-gtkstyle", boptions::bool_switch(&disableGtkStyle)->default_value(false) + , "Run the detailed router (Kite).") + ( "conf,c" , boptions::value() + , "The path of the configuration file." ); boptions::variables_map arguments; boptions::store ( boptions::parse_command_line(argc,argv,options), arguments ); @@ -65,7 +69,7 @@ int main ( int argc, char* argv[] ) auto_ptr qa ( new QApplication(argc,argv) ); #if (QT_VERSION >= QT_VERSION_CHECK(4,5,0)) and not defined (__APPLE__) - qa->setStyle ( new QGtkStyle() ); + if ( not disableGtkStyle ) qa->setStyle ( new QGtkStyle() ); #endif bfs::path::default_name_check ( bfs::portable_posix_name ); diff --git a/vlsisapd/src/configuration/src/ConfEditorWidget.cpp b/vlsisapd/src/configuration/src/ConfEditorWidget.cpp index d7e2acf1..a5c19815 100644 --- a/vlsisapd/src/configuration/src/ConfEditorWidget.cpp +++ b/vlsisapd/src/configuration/src/ConfEditorWidget.cpp @@ -39,7 +39,7 @@ namespace Cfg { ConfEditorWidget::ConfEditorWidget ( QWidget* parent ) : QMainWindow (parent) - , _configurationWidget (Configuration::get()->buildWidget(ConfigurationWidget::StandAlone)) + , _configurationWidget (Configuration::get()->buildWidget(ConfigurationWidget::Embedded)) , _fileMenu (NULL) , _saveAction (NULL) , _quitAction (NULL) @@ -90,7 +90,8 @@ namespace Cfg { cout << "Saving configuration file: <" << dotConfigFile << ">."<< endl; - Configuration::get()->writeToStream ( file, Configuration::DriveValues|Configuration::DriveLayout ); + Configuration::get()->writeToStream ( file, 0 ); + //Configuration::get()->writeToStream ( file, Configuration::DriveValues|Configuration::DriveLayout ); file.close (); } diff --git a/vlsisapd/src/configuration/src/Configuration.cpp b/vlsisapd/src/configuration/src/Configuration.cpp index 432c902a..629f6162 100644 --- a/vlsisapd/src/configuration/src/Configuration.cpp +++ b/vlsisapd/src/configuration/src/Configuration.cpp @@ -273,12 +273,14 @@ namespace { { if ( xmlTextReaderNodeType(_reader) == XML_READER_TYPE_END_ELEMENT ) return; - string attrId = _getAttributeValue("id"); - string attrType = _getAttributeValue("type"); - string attrLabel = _getAttributeValue("label"); - string attrColumn = _getAttributeValue("column"); - string attrSpan = _getAttributeValue("span"); - string attrSpinBox = _getAttributeValue("spinbox"); + string attrId = _getAttributeValue("id"); + string attrType = _getAttributeValue("type"); + string attrLabel = _getAttributeValue("label"); + string attrColumn = _getAttributeValue("column"); + string attrSpan = _getAttributeValue("span"); + string attrSpinBox = _getAttributeValue("spinbox"); + string attrFileName = _getAttributeValue("filename"); + string attrPathName = _getAttributeValue("pathname"); if ( attrId.empty() and attrType.empty() ) { cerr << "[ERROR] In tag, neither \"id\" nor \"type\" attribute." << endl; @@ -309,7 +311,9 @@ namespace { } int flags = 0; - if ( attrSpinBox == "true" ) flags |= ParameterWidget::UseSpinBox; + if ( attrSpinBox == "true" ) flags |= ParameterWidget::UseSpinBox; + if ( attrFileName == "true" ) flags |= ParameterWidget::IsFileName; + if ( attrPathName == "true" ) flags |= ParameterWidget::IsPathName; _configuration->getLayout().getBackTab()->addWidget ( WidgetDescription::parameter(attrId,attrLabel,column,span,flags) ); } diff --git a/vlsisapd/src/configuration/src/Configuration.qrc b/vlsisapd/src/configuration/src/Configuration.qrc new file mode 100644 index 00000000..b487bc43 --- /dev/null +++ b/vlsisapd/src/configuration/src/Configuration.qrc @@ -0,0 +1,5 @@ + + + images/choose.png + + diff --git a/vlsisapd/src/configuration/src/FilePathEdit.cpp b/vlsisapd/src/configuration/src/FilePathEdit.cpp new file mode 100644 index 00000000..33c6b435 --- /dev/null +++ b/vlsisapd/src/configuration/src/FilePathEdit.cpp @@ -0,0 +1,73 @@ + +// -*- C++ -*- +// +// This file is part of the VSLSI Stand-Alone Software. +// Copyright (c) UPMC/LIP6 2010-2010, All Rights Reserved +// +// =================================================================== +// +// $Id$ +// +// x-----------------------------------------------------------------x +// | | +// | C O R I O L I S | +// | C o n f i g u r a t i o n D a t a - B a s e | +// | | +// | Author : Damien Dupuis | +// | E-mail : Damien.Dupuis@soc.lip6.fr | +// | =============================================================== | +// | C++ Module : "./FilePathEdit.h" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x + + +#include +#include +#include +#include + +#include "vlsisapd/configuration/FilePathEdit.h" + + +namespace Cfg { + + + FilePathEdit::FilePathEdit ( Type type, std::string filter, QWidget* parent ) + : QLineEdit(parent) + , _type (type) + , _filter (filter) + { + _chooseButton = new QToolButton(this); + QPixmap pixmap(":/images/choose.png"); + _chooseButton->setIcon(QIcon(pixmap)); + _chooseButton->setIconSize(pixmap.size()); + _chooseButton->setCursor(Qt::ArrowCursor); + _chooseButton->setStyleSheet("QToolButton { border: none; padding: 0px; }"); + _chooseButton->setToolTip(tr( (type&Filename)?"Choose file ...":"Choose directory ..." )); + connect(_chooseButton, SIGNAL(clicked()), this, SLOT(updateLineEdit())); + setStyleSheet(QString("QLineEdit { padding-right: %1px; } ").arg(_chooseButton->sizeHint().width() + 1)); + } + + + void FilePathEdit::resizeEvent(QResizeEvent *) + { + QSize sz = _chooseButton->sizeHint(); + int l, t, r, b; + getContentsMargins(&l, &t, &r, &b); + _chooseButton->move(rect().right() - r - sz.width(), (rect().bottom() + 2 - sz.height())/2); + } + + + void FilePathEdit::updateLineEdit() + { + if (_type == FilePathEdit::Filename) { + setText(QFileDialog::getOpenFileName(this, tr("Choose file"), "", tr(_filter.c_str()))); + } else { + setText(QFileDialog::getExistingDirectory(this, tr("Choose directory"), "", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks)); + } + } + + +} // End of Cfg namespace. diff --git a/vlsisapd/src/configuration/src/LayoutDescription.cpp b/vlsisapd/src/configuration/src/LayoutDescription.cpp index b0ffc533..4898cf56 100644 --- a/vlsisapd/src/configuration/src/LayoutDescription.cpp +++ b/vlsisapd/src/configuration/src/LayoutDescription.cpp @@ -154,6 +154,8 @@ namespace Cfg { if ( widget->getSpan() != 1 ) out << " span=\"" << widget->getSpan() << "\""; if ( widget->getFlags() & ParameterWidget::UseSpinBox ) out << " spinbox=\"true\""; + if ( widget->getFlags() & ParameterWidget::IsFileName ) out << " filename=\"true\""; + if ( widget->getFlags() & ParameterWidget::IsPathName ) out << " pathname=\"true\""; break; } diff --git a/vlsisapd/src/configuration/src/ParameterWidget.cpp b/vlsisapd/src/configuration/src/ParameterWidget.cpp index 597231d8..80d5a604 100644 --- a/vlsisapd/src/configuration/src/ParameterWidget.cpp +++ b/vlsisapd/src/configuration/src/ParameterWidget.cpp @@ -32,6 +32,7 @@ #include #include #include "vlsisapd/configuration/Parameter.h" +#include "vlsisapd/configuration/FilePathEdit.h" #include "vlsisapd/configuration/ParameterWidget.h" #include "vlsisapd/configuration/ConfigurationWidget.h" @@ -62,7 +63,11 @@ namespace Cfg { break; case Parameter::String: { - QLineEdit* lineEdit = new QLineEdit(); + QLineEdit* lineEdit = NULL; + if ( hasFlags(IsFileName) ) lineEdit = new FilePathEdit ( FilePathEdit::Filename ); + else if ( hasFlags(IsPathName) ) lineEdit = new FilePathEdit ( FilePathEdit::Pathname ); + else lineEdit = new QLineEdit(); + lineEdit->setSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Fixed ); lineEdit->setMinimumWidth ( 375 ); lineEdit->setText ( QString("%1").arg(_parameter->asString().c_str()) ); diff --git a/vlsisapd/src/configuration/src/images/choose.png b/vlsisapd/src/configuration/src/images/choose.png new file mode 100644 index 00000000..ed5fc860 Binary files /dev/null and b/vlsisapd/src/configuration/src/images/choose.png differ diff --git a/vlsisapd/src/configuration/src/vlsisapd/configuration/FilePathEdit.h b/vlsisapd/src/configuration/src/vlsisapd/configuration/FilePathEdit.h new file mode 100644 index 00000000..c6c540d6 --- /dev/null +++ b/vlsisapd/src/configuration/src/vlsisapd/configuration/FilePathEdit.h @@ -0,0 +1,57 @@ + +// -*- C++ -*- +// +// This file is part of the VSLSI Stand-Alone Software. +// Copyright (c) UPMC/LIP6 2010-2010, All Rights Reserved +// +// =================================================================== +// +// $Id$ +// +// x-----------------------------------------------------------------x +// | | +// | C O R I O L I S | +// | C o n f i g u r a t i o n D a t a - B a s e | +// | | +// | Author : Damien Dupuis | +// | E-mail : Damien.Dupuis@soc.lip6.fr | +// | =============================================================== | +// | C++ Header : "./vlsisapd/configuration/FilePathEdit.h" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x + + +#ifndef __CFG_FILE_LINE_EDIT__ +#define __CFG_FILE_LINE_EDIT__ + +#include +#include +class QToolButton; + + +namespace Cfg { + + + class FilePathEdit : public QLineEdit + { + Q_OBJECT; + public: + enum Type { Filename=0x1, Pathname=0x2 }; + public: + FilePathEdit ( Type type=Filename, std::string filter="", QWidget* parent=NULL ); + protected: + void resizeEvent ( QResizeEvent* ); + private slots: + void updateLineEdit (); + private: + QToolButton* _chooseButton; + Type _type; + std::string _filter; + }; + + +} // End of Cfg namespace. + +#endif // __CFG_FILE_LINE_EDIT__ diff --git a/vlsisapd/src/configuration/src/vlsisapd/configuration/ParameterWidget.h b/vlsisapd/src/configuration/src/vlsisapd/configuration/ParameterWidget.h index 3f2514bf..8e90344a 100644 --- a/vlsisapd/src/configuration/src/vlsisapd/configuration/ParameterWidget.h +++ b/vlsisapd/src/configuration/src/vlsisapd/configuration/ParameterWidget.h @@ -44,7 +44,7 @@ namespace Cfg { class ParameterWidget : public QObject { Q_OBJECT; public: - enum Flags { UseSpinBox=0x1 }; + enum Flags { UseSpinBox=0x1, IsFileName=0x2, IsPathName=0x4 }; public: ParameterWidget ( QObject* parent, Parameter*, const std::string& label, int flags ); inline Parameter* getParameter ();