* ./vslsisapd/src/configuration:
- New: Integrate the FilePathEdit widget, courtesy of D. Dupuis. - Bug: In ConfEditorMain, new boolean switch to allow disable of GtkStyle which make FilePathEdit to coredump (Linux feature only!).
This commit is contained in:
parent
a2d5823fce
commit
7b1fd28df0
|
@ -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}
|
||||
|
|
|
@ -48,9 +48,13 @@ 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." )
|
||||
( "disable-gtkstyle", boptions::bool_switch(&disableGtkStyle)->default_value(false)
|
||||
, "Run the detailed router (Kite).")
|
||||
( "conf,c" , boptions::value<string>()
|
||||
, "The path of the configuration file." );
|
||||
|
||||
|
@ -65,7 +69,7 @@ int main ( int argc, char* argv[] )
|
|||
|
||||
auto_ptr<QApplication> 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 );
|
||||
|
|
|
@ -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 ();
|
||||
}
|
||||
|
||||
|
|
|
@ -279,6 +279,8 @@ namespace {
|
|||
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 <widget> tag, neither \"id\" nor \"type\" attribute." << endl;
|
||||
|
@ -310,6 +312,8 @@ namespace {
|
|||
|
||||
int flags = 0;
|
||||
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) );
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource>
|
||||
<file>images/choose.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
|
@ -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 <iostream>
|
||||
#include <QToolButton>
|
||||
#include <QStyle>
|
||||
#include <QFileDialog>
|
||||
|
||||
#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.
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <QIntValidator>
|
||||
#include <QDoubleValidator>
|
||||
#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()) );
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
|
@ -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 <string>
|
||||
#include <QLineEdit>
|
||||
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__
|
|
@ -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 ();
|
||||
|
|
Loading…
Reference in New Issue