diff --git a/GUI/coregui/Models/JobModel.cpp b/GUI/coregui/Models/JobModel.cpp index 39085a04f93d791eea4382fea6ce26ebe2c8c2f5..ef3d78a88f85930b878f9cb4abe50f7af4c0f3cd 100644 --- a/GUI/coregui/Models/JobModel.cpp +++ b/GUI/coregui/Models/JobModel.cpp @@ -42,7 +42,7 @@ TH2D *JobModel::getHistogram() return mp_cached_histogram; } const OutputData<double> *output = mp_simulation->getOutputData(); - if (output->getNdimensions() !=2) { + if (output->getRank() !=2) { return 0; } std::vector<size_t> axis_sizes; @@ -50,7 +50,7 @@ TH2D *JobModel::getHistogram() std::vector<std::vector<double> > binvectors; // we assume variable bin size and prepare [nbins+1] array of left edges of each bin plus right edge of the last bin - for(size_t i_axis=0; i_axis<output->getNdimensions(); ++i_axis) { + for(size_t i_axis=0; i_axis<output->getRank(); ++i_axis) { const IAxis *axis = output->getAxis(i_axis); if( !axis ) return 0; double dx(0); diff --git a/GUI/coregui/Views/Components/SampleEditor/SampleFactory.h b/GUI/coregui/Views/Components/SampleEditor/SampleFactory.h index 864aa36023153062cf930e96ea844797f64c8038..704260f5fe5eb8a5d7f03a58c0ae7897ade159fd 100644 --- a/GUI/coregui/Views/Components/SampleEditor/SampleFactory.h +++ b/GUI/coregui/Views/Components/SampleEditor/SampleFactory.h @@ -21,30 +21,30 @@ class SampleIsGISAXS9_Rotated : public MultiLayer public: SampleIsGISAXS9_Rotated() { - const double angle_around_z = 45.*Units::degree; - complex_t n_air(1.0, 0.0); - complex_t n_substrate(1.0-6e-6, 2e-8); - complex_t n_particle(1.0-6e-4, 2e-8); - const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air); - const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate); - Layer air_layer; - air_layer.setMaterial(p_air_material); - Layer substrate_layer; - substrate_layer.setMaterial(p_substrate_material); +// const double angle_around_z = 45.*Units::degree; +// complex_t n_air(1.0, 0.0); +// complex_t n_substrate(1.0-6e-6, 2e-8); +// complex_t n_particle(1.0-6e-4, 2e-8); +// const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air); +// const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate); +// Layer air_layer; +// air_layer.setMaterial(p_air_material); +// Layer substrate_layer; +// substrate_layer.setMaterial(p_substrate_material); - Particle *pyramid = new Particle(n_particle, new FormFactorPyramid(5*Units::nanometer, 5*Units::nanometer, Units::deg2rad(54.73)) ); +// Particle *pyramid = new Particle(n_particle, new FormFactorPyramid(5*Units::nanometer, 5*Units::nanometer, Units::deg2rad(54.73)) ); - Geometry::Transform3D *transform = new Geometry::RotateZ3D(angle_around_z); +// Geometry::Transform3D *transform = new Geometry::RotateZ3D(angle_around_z); - ParticleDecoration particle_decoration; +// ParticleDecoration particle_decoration; - particle_decoration.addParticle(pyramid, transform); - particle_decoration.addInterferenceFunction(new InterferenceFunctionNone()); +// particle_decoration.addParticle(pyramid, transform); +// particle_decoration.addInterferenceFunction(new InterferenceFunctionNone()); - LayerDecorator air_layer_decorator(air_layer, particle_decoration); +// LayerDecorator air_layer_decorator(air_layer, particle_decoration); - addLayer(air_layer_decorator); - addLayer(substrate_layer); +// addLayer(air_layer_decorator); +// addLayer(substrate_layer); } virtual ~SampleIsGISAXS9_Rotated(){} diff --git a/GUI/coregui/Views/InstrumentView.cpp b/GUI/coregui/Views/InstrumentView.cpp index c8f5d5faa40184a62941f342c037c10997f5c595..2953080de5d9e4e1257379e2fd95fe4e2263db47 100644 --- a/GUI/coregui/Views/InstrumentView.cpp +++ b/GUI/coregui/Views/InstrumentView.cpp @@ -2,7 +2,7 @@ #include "SimulationDataModel.h" #include "Units.h" -#include "ExperimentConstants.h" +//#include "ExperimentConstants.h" #include <boost/lexical_cast.hpp> diff --git a/GUI/coregui/coregui.pro b/GUI/coregui/coregui.pro index b8623ce010a6b0a988e8ba0e8cdd24199fbe40d2..2e8d3fad6be1104c4c17434111beafd8981828a2 100644 --- a/GUI/coregui/coregui.pro +++ b/GUI/coregui/coregui.pro @@ -57,7 +57,7 @@ HEADERS += \ INCLUDEPATH += $$PWD/mainwindow $$PWD/utils $$PWD/Views $$PWD/Models # visual style "Manhattan" -LIBS += $$PWD/../../lib/libqt-manhattan-style.so +LIBS += $$PWD/../../lib/libManhattanStyle.so INCLUDEPATH += $$PWD/../externals/qt-manhattan-style ## ROOT libraries integration diff --git a/GUI/externals/qt-manhattan-style/CMakeLists.txt b/GUI/externals/qt-manhattan-style/CMakeLists.txt index 983f1b0e3245845bfdef76dbe3927b0843b7ed5e..46b29b0b609fb603806cb187b0d106852a54ea2e 100644 --- a/GUI/externals/qt-manhattan-style/CMakeLists.txt +++ b/GUI/externals/qt-manhattan-style/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.9) project(qt-manhattan-style) @@ -53,15 +53,12 @@ set(UI_FILES ) # Qt5 -find_package(Qt5Widgets) -include_directories(${Qt5Widgets_INCLUDE_DIRS}) -add_definitions(${Qt5Widgets_DEFINITIONS}) -set(CMAKE_POSITION_INDEPENDENT_CODE ON) +set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) +find_package(Qt5Widgets) # Run uic on ui files qt5_wrap_ui(UI_HDRS ${UI_FILES}) -include_directories(${CMAKE_CURRENT_BINARY_DIR}) # UI headers are generated in the binary directory # this command will generate rules that will run rcc on all files from RCS # in result RC_SRCS variable will contain paths to files produced by rcc @@ -77,3 +74,5 @@ add_library(${PROJECT_NAME} SHARED ${SRCS} ${UI_HDRS} ${RC_SRCS}) # Link the target to its dependencies # The Qt5Widgets_LIBRARIES variable also includes QtGui and QtCore target_link_libraries(${PROJECT_NAME} ${Qt5Widgets_LIBRARIES}) + +qt5_use_modules(${PROJECT_NAME} Widgets) diff --git a/GUI/externals/qt-manhattan-style/extensions/simpleprogressbar.cpp b/GUI/externals/qt-manhattan-style/extensions/simpleprogressbar.cpp index b4e31d23d7c64a4168f77954c3fd50644fad346b..158121d57278db3fc6e36f793ef99f60094ca46f 100644 --- a/GUI/externals/qt-manhattan-style/extensions/simpleprogressbar.cpp +++ b/GUI/externals/qt-manhattan-style/extensions/simpleprogressbar.cpp @@ -27,6 +27,8 @@ SimpleProgressBar::~SimpleProgressBar() void SimpleProgressBar::reset() { m_value = m_minimum; + m_finished = false; + m_error = false; update(); } diff --git a/GUI/externals/qt-manhattan-style/extensions/tabwidget.cpp b/GUI/externals/qt-manhattan-style/extensions/tabwidget.cpp index e96a0daa7fb43cf7f99d54dd57d3ef5503c95030..6c868e73908669c5ac5186f619dbe5849c1a927a 100644 --- a/GUI/externals/qt-manhattan-style/extensions/tabwidget.cpp +++ b/GUI/externals/qt-manhattan-style/extensions/tabwidget.cpp @@ -37,7 +37,7 @@ TabWidget::TabWidget(QWidget *parent) : m_drawFrame(false) { QVBoxLayout *layout = new QVBoxLayout; - layout->setContentsMargins(0, minimumSizeHint().height(), 0, 0); + layout->setContentsMargins(0, TAB_HEIGHT + CONTENT_HEIGHT_MARGIN + 1, 0, 0); m_stack = new QStackedWidget; layout->addWidget(m_stack); setLayout(layout); @@ -78,11 +78,6 @@ void TabWidget::setFrameVisible(bool visible) } } -QSize TabWidget::minimumSizeHint() const -{ - return QSize(0, TAB_HEIGHT + CONTENT_HEIGHT_MARGIN + 1); -} - void TabWidget::addTab(const QString &name, QWidget *widget) { Q_ASSERT(widget); @@ -134,6 +129,11 @@ int TabWidget::tabCount() const return m_tabs.size(); } +QString TabWidget::tabText(int index) const +{ + return m_tabs.value(index).name; +} + /// Converts a position to the tab that is undeneath /// If HitArea is tab, then the second part of the pair /// is the tab number diff --git a/GUI/externals/qt-manhattan-style/extensions/tabwidget.h b/GUI/externals/qt-manhattan-style/extensions/tabwidget.h index 59e6811625c3bb8b6c355d620e6ec53e50330563..72dd8a0b21c2eeae74d3c68de384f55892926ddc 100644 --- a/GUI/externals/qt-manhattan-style/extensions/tabwidget.h +++ b/GUI/externals/qt-manhattan-style/extensions/tabwidget.h @@ -25,6 +25,7 @@ public: void insertTab(int index, const QString &name, QWidget *widget); void removeTab(int index); int tabCount() const; + QString tabText(int index) const; int currentIndex() const; void setCurrentIndex(int index); @@ -36,7 +37,6 @@ protected: void paintEvent(QPaintEvent *event); void mousePressEvent(QMouseEvent *event); bool event(QEvent *event); - QSize minimumSizeHint() const; private: struct Tab { diff --git a/GUI/externals/qt-manhattan-style/extensions/threelevelsitempicker.cpp b/GUI/externals/qt-manhattan-style/extensions/threelevelsitempicker.cpp index a24793d88b146c10c6638c8183c037f6eff07991..41ca19b63f47a56c07d76b7859a51229a5097d63 100644 --- a/GUI/externals/qt-manhattan-style/extensions/threelevelsitempicker.cpp +++ b/GUI/externals/qt-manhattan-style/extensions/threelevelsitempicker.cpp @@ -11,6 +11,7 @@ #include <QLabel> #include <QTimer> + namespace { @@ -80,15 +81,16 @@ ThreeLevelsItemPicker::ThreeLevelsItemPicker(const QString& level1Title, // List widgets m_level1Items = new ListWidget; - m_level1Items->setMaxCount(3); + m_level1Items->setMaxCount(5); m_level1Items->addItems(m_level2ItemsFromlevel1.keys()); connect(m_level1Items, SIGNAL(currentTextChanged(QString)), this, SLOT(setLevel1(QString))); m_level2Items = new ListWidget; - m_level2Items->setMaxCount(m_level2ItemsFromlevel1.count()); + m_level2Items->setMaxCount(5); connect(m_level2Items, SIGNAL(currentTextChanged(QString)), this, SLOT(setLevel2(QString))); m_level3Items = new ListWidget; - m_level3Items->setMaxCount(m_level3ItemsFromLevel2.count()); + m_level3Items->setMaxCount(5); connect(m_level3Items, SIGNAL(currentTextChanged(QString)), this, SLOT(setLevel3(QString))); + connect(m_level3Items, SIGNAL(itemReselected()), this, SLOT(hide())); QGridLayout *grid = new QGridLayout(this); grid->setMargin(0); @@ -142,6 +144,13 @@ void ThreeLevelsItemPicker::setVisible(bool visible) m_triggerAction->setChecked(visible); } +void ThreeLevelsItemPicker::setMaxVisibleItemCount(int count) +{ + m_level1Items->setMaxCount(count); + m_level2Items->setMaxCount(count); + m_level3Items->setMaxCount(count); +} + QString ThreeLevelsItemPicker::level1() const { QListWidgetItem* item = m_level1Items->currentItem(); @@ -160,6 +169,45 @@ QString ThreeLevelsItemPicker::level3() const return item ? item->text() : QString(); } +namespace +{ + +QListWidgetItem* find(const ListWidget* list, const QString& name) +{ + for (int row = 0; row < list->count(); ++row) + { + QListWidgetItem* item = list->item(row); + if (item->text() == name) + return item; + } + + //return nullptr; + return NULL; +} + +} // Anonymous namespace + +void ThreeLevelsItemPicker::setLevel1Item(const QString& name) +{ + QListWidgetItem* item = ::find(m_level1Items, name); + if (item) + m_level1Items->setCurrentItem(item); +} + +void ThreeLevelsItemPicker::setLevel2Item(const QString& name) +{ + QListWidgetItem* item = ::find(m_level2Items, name); + if (item) + m_level2Items->setCurrentItem(item); +} + +void ThreeLevelsItemPicker::setLevel3Item(const QString& name) +{ + QListWidgetItem* item = ::find(m_level3Items, name); + if (item) + m_level3Items->setCurrentItem(item); +} + void ThreeLevelsItemPicker::setLevel1(const QString& name) { m_level2Items->clear(); @@ -180,11 +228,15 @@ void ThreeLevelsItemPicker::setLevel3(const QString& name) m_triggerAction->setProperty("heading", name); QListWidgetItem* item = m_level2Items->currentItem(); m_triggerAction->setProperty("subtitle", item ? item->text() : ""); - QTimer::singleShot(200, this, SLOT(hide())); - + smoothHide(); emit itemChanged(); } +void ThreeLevelsItemPicker::smoothHide() +{ + QTimer::singleShot(200, this, SLOT(hide())); +} + // This is a workaround for the problem that Windows // will let the mouse events through when you click // outside a popup to close it. This causes the popup @@ -280,10 +332,14 @@ ListWidget::ListWidget(QWidget *parent) setFocusPolicy(Qt::WheelFocus); setItemDelegate(new TargetSelectorDelegate(this)); setAttribute(Qt::WA_MacShowFocusRect, false); - setStyleSheet(QString::fromLatin1("QListWidget { background: #464646; border-style: none; }")); setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); -} + // Style + QFile file(":/extensions/qss/threelevelsitempicker-listwidget.qss"); + file.open(QFile::ReadOnly); + QString styleSheet = QLatin1String(file.readAll()); + setStyleSheet(styleSheet); +} QSize ListWidget::sizeHint() const { @@ -317,3 +373,13 @@ void ListWidget::setMaxCount(int maxCount) m_maxCount = maxCount; updateGeometry(); } + +void ListWidget::mouseReleaseEvent(QMouseEvent* event) +{ + QListWidgetItem* item = currentItem(); + QListWidget::mouseReleaseEvent(event); + if (item == currentItem()) + { + emit itemReselected(); + } +} diff --git a/GUI/externals/qt-manhattan-style/extensions/threelevelsitempicker.h b/GUI/externals/qt-manhattan-style/extensions/threelevelsitempicker.h index 1a9bc90822def0f1f4030468423cb9e22508014c..e51344cda9812e0b4c25bd8f5ab923498b321e95 100644 --- a/GUI/externals/qt-manhattan-style/extensions/threelevelsitempicker.h +++ b/GUI/externals/qt-manhattan-style/extensions/threelevelsitempicker.h @@ -13,12 +13,20 @@ namespace Manhattan { class ListWidget : public QListWidget { Q_OBJECT + public: ListWidget(QWidget *parent = 0); QSize sizeHint() const; void keyPressEvent(QKeyEvent *event); void keyReleaseEvent(QKeyEvent *event); void setMaxCount(int maxCount); + +signals: + void itemReselected(); + +protected: + void mouseReleaseEvent(QMouseEvent* event); + private: int m_maxCount; }; @@ -38,11 +46,16 @@ public: inline QAction* triggerAction() const { return m_triggerAction; } void setVisible(bool visible); + void setMaxVisibleItemCount(int count); QString level1() const; QString level2() const; QString level3() const; + void setLevel1Item(const QString& name); + void setLevel2Item(const QString& name); + void setLevel3Item(const QString& name); + signals: void itemChanged(); @@ -50,6 +63,7 @@ private slots: void setLevel1(const QString& name); void setLevel2(const QString& name); void setLevel3(const QString& name); + void smoothHide(); private: void mousePressEvent(QMouseEvent *); diff --git a/GUI/externals/qt-manhattan-style/fancytabwidget.cpp b/GUI/externals/qt-manhattan-style/fancytabwidget.cpp index 4f9f922dcb2067fbea601a4bcca9f85e99edd6e9..6187d0520e3171f5b5522925858d7f2c51aeb644 100644 --- a/GUI/externals/qt-manhattan-style/fancytabwidget.cpp +++ b/GUI/externals/qt-manhattan-style/fancytabwidget.cpp @@ -110,7 +110,6 @@ QSize FancyTabBar::tabSizeHint(bool minimum) const if (width > maxLabelwidth) maxLabelwidth = width; } -// int iconHeight = minimum ? 0 : 32; int iconHeight = minimum ? 0 : 48; return QSize(qMax(width, maxLabelwidth + 4), iconHeight + spacing + fm.height()); } @@ -401,7 +400,6 @@ FancyTabWidget::FancyTabWidget(QWidget *parent) QVBoxLayout *topCornerWidgetLayout = new QVBoxLayout; topCornerWidgetLayout->setSpacing(0); topCornerWidgetLayout->setMargin(0); - topCornerWidgetLayout->addStretch(); m_topCornerWidgetContainer->setLayout(topCornerWidgetLayout); selectionLayout->addWidget(m_topCornerWidgetContainer, 0); @@ -417,7 +415,6 @@ FancyTabWidget::FancyTabWidget(QWidget *parent) QVBoxLayout *bottomCornerWidgetLayout = new QVBoxLayout; bottomCornerWidgetLayout->setSpacing(0); bottomCornerWidgetLayout->setMargin(0); - bottomCornerWidgetLayout->addStretch(); m_bottomCornerWidgetContainer->setLayout(bottomCornerWidgetLayout); selectionLayout->addWidget(m_bottomCornerWidgetContainer, 0); @@ -445,11 +442,13 @@ void FancyTabWidget::setSelectionWidgetHidden(bool hidden) { m_selectionWidget->setHidden(hidden); } +//void FancyTabWidget::insertTab(int index, QWidget *tab, const QIcon &icon) void FancyTabWidget::insertTab(int index, QWidget *tab, const QIcon &icon, const QString &label) { +// QString label("XXX"); m_modesStack->insertWidget(index, tab); m_tabBar->insertTab(index, icon, label); - setTabEnabled(index,true); + setTabEnabled(index, true); } void FancyTabWidget::removeTab(int index) diff --git a/GUI/externals/qt-manhattan-style/fancytabwidget.h b/GUI/externals/qt-manhattan-style/fancytabwidget.h index 4301a91b7a3e2b4903a0ddc426c0c3240cfbf200..cc1388cc99c0e2b3d022e52be3aadd1020bdcdc4 100644 --- a/GUI/externals/qt-manhattan-style/fancytabwidget.h +++ b/GUI/externals/qt-manhattan-style/fancytabwidget.h @@ -144,6 +144,7 @@ class QTMANHATTANSTYLESHARED_EXPORT FancyTabWidget : public QWidget public: FancyTabWidget(QWidget *parent = 0); +// void insertTab(int index, QWidget *tab, const QIcon &icon); void insertTab(int index, QWidget *tab, const QIcon &icon, const QString &label); void removeTab(int index); void removeTabs(); diff --git a/GUI/externals/qt-manhattan-style/module.cpp b/GUI/externals/qt-manhattan-style/module.cpp new file mode 100644 index 0000000000000000000000000000000000000000..deb77f89b5e3cf1ba22f70e326bdc2963b382b45 --- /dev/null +++ b/GUI/externals/qt-manhattan-style/module.cpp @@ -0,0 +1,54 @@ +#include <boost/python.hpp> +using namespace boost::python; + +#include "fancytabwidget.h" +#include "manhattanstyle.h" +#include "stylehelper.h" + +#include <iostream> + + +void export_sip(); +void export_QString(); + +BOOST_PYTHON_MODULE(libManhattanStyle) +{ + + try { import("PyQt4.QtCore"); } catch(...) {} // needed for toPyQt(...) + try { import("PyQt4.QtGui"); } catch(...) {} // needed for toPyQt(...) + try { import("PyQt4.QtOpenGL"); } catch(...) {} // needed for toPyQt(...) + + export_sip(); + export_QString(); + +// class_<QObject, QObject*, boost::noncopyable>("QObject", no_init) +// ; + +// class_<QWidget, bases<QObject>, QWidget*, boost::noncopyable>("QWidget") +// ; + +// class_<Manhattan::FancyTabWidget, bases<QWidget>, Manhattan::FancyTabWidget*, boost::noncopyable>("FancyTabWidget") +// .def("insertTab",&Manhattan::FancyTabWidget::insertTab) +// ; + + + class_<Manhattan::FancyTabWidget, boost::noncopyable, std::auto_ptr<Manhattan::FancyTabWidget> >("FancyTabWidget") + .def("insertTab",&Manhattan::FancyTabWidget::insertTab) + ; + + // class_<Manhattan::FancyTabWidget, bases<QWidget>, Manhattan::FancyTabWidget*, boost::noncopyable>("FancyTabWidget") + class_<ManhattanStyle, ManhattanStyle*, boost::noncopyable >("ManhattanStyle", init<QString>()) + //class_<ManhattanStyle, boost::noncopyable, std::auto_ptr<ManhattanStyle> >("ManhattanStyle", init<QString>()) + ; + + class_< Manhattan::Utils::StyleHelper, Manhattan::Utils::StyleHelper*, boost::noncopyable >( "StyleHelper" ) + .def("setBaseColor",&Manhattan::Utils::StyleHelper::setBaseColor).staticmethod( "setBaseColor" ) + ; +// .staticmethod( "setBaseColor" ); +// .def( +// "setBaseColor" +// , (void (*)( const QColor &))( &Manhattan::Utils::StyleHelper::setBaseColor ) +// , ( arg("color") ) ) +// .staticmethod( "setBaseColor" ); + +} diff --git a/GUI/externals/qt-manhattan-style/module2.cpp b/GUI/externals/qt-manhattan-style/module2.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0d86c94547da1822eab9eaa12d0979cf88c7f4d8 --- /dev/null +++ b/GUI/externals/qt-manhattan-style/module2.cpp @@ -0,0 +1,100 @@ +#include <boost/python.hpp> +using namespace boost::python; + +#include <QObject> +#include <QWidget> +#include <QColor> +#include <QIcon> + +#include "fancytabwidget.h" +#include "manhattanstyle.h" +#include "stylehelper.h" + +#include <iostream> + + +//void export_sip(); +//void export_QString(); + +long int unwrap(QObject* ptr) { +return reinterpret_cast<long int>(ptr); +} + +template <typename T> +T* wrap(long int ptr) { +return reinterpret_cast<T*>(ptr); +} + + +BOOST_PYTHON_MODULE(libManhattanStyle) +{ + + try { import("PyQt4.QtCore"); } catch(...) {} // needed for toPyQt(...) + try { import("PyQt4.QtGui"); } catch(...) {} // needed for toPyQt(...) + try { import("PyQt4.QtOpenGL"); } catch(...) {} // needed for toPyQt(...) + + + class_<QObject, QObject*, boost::noncopyable>("QObject", no_init) + .def("unwrap", unwrap) + .def("wrap", make_function( wrap<QObject>, return_value_policy<return_by_value>() )) + .staticmethod("wrap"); + + class_<QWidget, bases<QObject>, QWidget*, boost::noncopyable>("QWidget") + .def("wrap", make_function( wrap<QWidget>, return_value_policy<return_by_value>() )) + .staticmethod("wrap"); + + class_<QColor, QColor*, boost::noncopyable>("QColor") + .def("wrap", make_function( wrap<QColor>, return_value_policy<return_by_value>() )) + .staticmethod("wrap"); + + class_<QString, QString*, boost::noncopyable>("QString") + .def("wrap", make_function( wrap<QString>, return_value_policy<return_by_value>() )) + .staticmethod("wrap"); + + class_<QIcon, QIcon*, boost::noncopyable>("QIcon") + .def("wrap", make_function( wrap<QIcon>, return_value_policy<return_by_value>() )) + .staticmethod("wrap"); + + class_<QProxyStyle, QProxyStyle*, boost::noncopyable>("QProxyStyle") + .def("wrap", make_function( wrap<QProxyStyle>, return_value_policy<return_by_value>() )) + .staticmethod("wrap"); + + +// export_sip(); +// export_QString(); + + +// class_<QObject, QObject*, boost::noncopyable>("QObject", no_init) +// ; + +// class_<QWidget, bases<QObject>, QWidget*, boost::noncopyable>("QWidget") +// ; + + class_<Manhattan::FancyTabWidget, bases<QWidget>, Manhattan::FancyTabWidget*, boost::noncopyable>("FancyTabWidget") + .def("insertTab",&Manhattan::FancyTabWidget::insertTab) + ; + + + class_<ManhattanStyle, bases<QProxyStyle>, ManhattanStyle*, boost::noncopyable >("ManhattanStyle", init<QString>()) + ; + + +// class_<Manhattan::FancyTabWidget, boost::noncopyable, std::auto_ptr<Manhattan::FancyTabWidget> >("FancyTabWidget") +// .def("insertTab",&Manhattan::FancyTabWidget::insertTab) +// ; + +// // class_<Manhattan::FancyTabWidget, bases<QWidget>, Manhattan::FancyTabWidget*, boost::noncopyable>("FancyTabWidget") +// class_<ManhattanStyle, ManhattanStyle*, boost::noncopyable >("ManhattanStyle", init<QString>()) +// //class_<ManhattanStyle, boost::noncopyable, std::auto_ptr<ManhattanStyle> >("ManhattanStyle", init<QString>()) +// ; + + class_< Manhattan::Utils::StyleHelper >( "StyleHelper" ) + .def("setBaseColor",&Manhattan::Utils::StyleHelper::setBaseColor) + .staticmethod( "setBaseColor" ); +//// .def( +//// "setBaseColor" +//// , (void (*)( const QColor &))( &Manhattan::Utils::StyleHelper::setBaseColor ) +//// , ( arg("color") ) ) +//// .staticmethod( "setBaseColor" ); + +} diff --git a/GUI/externals/qt-manhattan-style/module_qstring.cpp b/GUI/externals/qt-manhattan-style/module_qstring.cpp new file mode 100644 index 0000000000000000000000000000000000000000..efd1be60a518d0d54ae8a900661095e29bc1de97 --- /dev/null +++ b/GUI/externals/qt-manhattan-style/module_qstring.cpp @@ -0,0 +1,103 @@ +#include <Python.h> +#include <boost/python.hpp> + +#include <QString> + +using namespace boost::python; + +struct QString_to_python_str +{ + + // FIXME: handle this using boost::python::str + static PyObject* convert(QString const &str) + { +#if defined ( Py_UNICODE_WIDE ) + PyObject *obj = PyUnicode_FromUnicode( 0, str.length() ); + if (!obj) + throw_error_already_set(); + + Py_UNICODE *pyu = PyUnicode_AS_UNICODE( obj ); + + for (int i = 0; i < str.length(); ++i) + *pyu++ = (str.at(i)).unicode(); + + return obj; +#else + return PyUnicode_FromWideChar( (const wchar_t*) str.unicode(), str.length() ); +#endif + } +}; + +struct QString_from_python_str +{ + QString_from_python_str() + { + converter::registry::push_back( &convertible, &construct, type_id<QString>() ); + } + + static void* convertible(PyObject *obj_ptr) + { + if (PyUnicode_Check(obj_ptr)) + return obj_ptr; + if (PyString_Check(obj_ptr)) + return obj_ptr; + + return 0; + } + + static void construct(PyObject *obj_ptr, converter::rvalue_from_python_stage1_data *data) + { + if (PyUnicode_Check(obj_ptr)) { + void *storage = ((converter::rvalue_from_python_storage<QString> *) data)->storage.bytes; + PY_UNICODE_TYPE *ucode = PyUnicode_AS_UNICODE(obj_ptr); + int len = PyUnicode_GET_SIZE(obj_ptr); +#if defined(Py_UNICODE_WIDE) + QString* out = new(storage) QString; + for ( int i = 0; i < len; ++i ) + out->append( (uint)ucode[i] ); +#else + new(storage) QString( (const QChar *)ucode, len ); +#endif + data->convertible = storage; + } else if ( PyString_Check( obj_ptr ) ) { + const char *value = PyString_AsString(obj_ptr); + if(!value) + throw_error_already_set(); + + void *storage = ((converter::rvalue_from_python_storage<QString> *) data)->storage.bytes; + new(storage) QString(QByteArray(value, PyString_Size(obj_ptr))); + data->convertible = storage; + } + } + +}; + +/* +class QStringTest +{ + public: + QString getString() const + { + return m_str; + } + void setString(const QString &str) + { + m_str = str; + } + private: + QString m_str; +}; +*/ + +void export_QString() +{ + to_python_converter<QString, QString_to_python_str>(); + QString_from_python_str(); + + /* + class_<QStringTest>("QStringTest") + .def("getString", &QStringTest::getString) + .def("setString", &QStringTest::setString) + ; + */ +} diff --git a/GUI/externals/qt-manhattan-style/module_sip.cpp b/GUI/externals/qt-manhattan-style/module_sip.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8286be8a3f7a2ffc1651d90be46dffee686ac8a5 --- /dev/null +++ b/GUI/externals/qt-manhattan-style/module_sip.cpp @@ -0,0 +1,397 @@ +#include <boost/python.hpp> +#include <boost/tuple/tuple.hpp> + +#include <sip.h> +#include <iostream> +#include <QWidget> +#include <QObject> +#include <QAction> +#include <QIcon> +#include <QString> +#include <QColor> + +#include "manhattanstyle.h" +#include "fancytabwidget.h" + +using namespace boost::python; + +/** + * Initialize the SIP API + */ +const sipAPIDef *sip_API = 0; + +bool init_sip_api() +{ + // import the sip module + object sip_module = import("sip"); + if (!sip_module.ptr()) { + std::cout << "Could not import sip python module." << std::endl; + return false; + } + + // get the dictionary + dict sip_dict = extract<dict>(sip_module.attr("__dict__")); + if (!sip_dict.ptr()) { + std::cout << "Could not find the __dict__ attribute in the sip python module." << std::endl; + return false; + } + + // get the _C_API object from the dictionary + object sip_capi_obj = sip_dict.get("_C_API"); + if (!sip_capi_obj.ptr()) { + std::cout << "Could not find the _C_API entry in the sip python module dictionary." << std::endl; + return false; + } + +#ifdef SIP_USE_PYCAPSULE + if (!PyCapsule_IsValid(sip_capi_obj.ptr(), "sip._C_API")) { +#else + if (!PyCObject_Check(sip_capi_obj.ptr())) { +#endif + std::cout << "The _C_API object in the sip python module is invalid." << std::endl; + return false; + } + +#ifdef SIP_USE_PYCAPSULE + sip_API = + reinterpret_cast<const sipAPIDef*>(PyCapsule_GetPointer(sip_capi_obj.ptr(), + "sip._C_API")); +#else + sip_API = + reinterpret_cast<const sipAPIDef*>(PyCObject_AsVoidPtr(sip_capi_obj.ptr())); +#endif + return true; +} + +/** + * MetaData helper templates. While this information is available + * (QObject::metaObject) for objects derived from QObject, not + * all classes are derived from it. To make all classes work with + * the same templates we do it this way. + * + */ + +// these are used by the toPyQt function, +template <typename T> struct MetaData; + +// used by toPyQt(...) +template <> struct MetaData<Manhattan::FancyTabWidget> { static const char* className() { return "QWidget";} }; +template <> struct MetaData<ManhattanStyle> { static const char* className() { return "QStyle";} }; + +template <> struct MetaData<QObject> { static const char* className() { return "QObject";} }; +template <> struct MetaData<QWidget> { static const char* className() { return "QWidget";} }; +template <> struct MetaData<QIcon> { static const char* className() { return "QIcon";} }; +template <> struct MetaData<QColor> { static const char* className() { return "QColor";} }; +template <> struct MetaData<QAction> { static const char* className() { return "QAction";} }; +//template <> struct MetaData<QString> { static const char* className() { return "QString";} }; + + +/** + * QWidget* <--> PyQt object + * QAction* <--> PyQt object + * ... + */ +template <typename T> +struct QClass_converters +{ + + struct QClass_to_PyQt + { + static PyObject* convert(const T& object) + { +#if SIP_API_MAJOR_NR >=4 + const sipTypeDef *type = sip_API->api_find_type(MetaData<T>::className()); +#else + sipWrapperType *type = sip_API->api_find_class(MetaData<T>::className()); +#endif + if (!type) + return incref(Py_None); + +#if SIP_API_MAJOR_NR >=4 + PyObject *sip_obj = sip_API->api_convert_from_type((void*)(&object), type, 0); +#else + PyObject *sip_obj = sip_API->api_convert_from_instance((void*)(&object), type, 0); +#endif + if (!sip_obj) + return incref(Py_None); + + return incref(sip_obj); + } + + static PyObject* convert(T* object) + { + if (!object) + return incref(Py_None); + +#if SIP_API_MAJOR_NR >=4 + const sipTypeDef *type = sip_API->api_find_type(MetaData<T>::className()); +#else + sipWrapperType *type = sip_API->api_find_class(MetaData<T>::className()); +#endif + if (!type) + return incref(Py_None); + +#if SIP_API_MAJOR_NR >=4 + PyObject *sip_obj = sip_API->api_convert_from_type(object, type, 0); +#else + PyObject *sip_obj = sip_API->api_convert_from_instance(object, type, 0); +#endif + if (!sip_obj) + return incref(Py_None); + + return incref(sip_obj); + } + + static PyObject* convert(const T* object) + { + return convert((T*)object); + } + + }; + + static void* QClass_from_PyQt(PyObject *obj_ptr) + { +#if SIP_API_MAJOR_NR >=4 + std::cout << "XXX 1.1" << std::endl; + if (!PyObject_TypeCheck(obj_ptr, sip_API->api_wrapper_type)) { +#else + std::cout << "XXX 1.2" << std::endl; + if (!sip_API->api_wrapper_check(obj_ptr)) { +#endif + std::cout << "Error - already set in QClass_from_PyQt.." << std::endl; + //throw_error_already_set(); + } + + // transfer ownership from python to C++ +#if SIP_API_MAJOR_NR >=4 + sip_API->api_transfer_to(obj_ptr, 0); +#else + sip_API->api_transfer(obj_ptr, 1); +#endif + + // reinterpret to sipWrapper +#if SIP_API_MAJOR_NR >= 4 + sipSimpleWrapper *wrapper = reinterpret_cast<sipSimpleWrapper*>(obj_ptr); +#else + sipWrapper *wrapper = reinterpret_cast<sipWrapper*>(obj_ptr); +#endif + +#if (SIP_API_MAJOR_NR == 8 && SIP_API_MINOR_NR >= 1) || SIP_API_MAJOR_NR > 8 + return sip_API->api_get_address(wrapper); +#elif SIP_API_MAJOR_NR == 8 + return wrapper->data; +#else + return wrapper->u.cppPtr; +#endif + } + + QClass_converters() + { + // example: PyQt object --> C++ pointer + converter::registry::insert( &QClass_from_PyQt, type_id<T>() ); + // example: const QColor* -> PyQt object + to_python_converter<const T*, QClass_to_PyQt>(); + // example: QUndoCommand* Extension::performAction(...) --> PyQt object + to_python_converter<T*, QClass_to_PyQt>(); + // example: QColor GLWidget::background() --> PyQt object + to_python_converter<T, QClass_to_PyQt>(); + } + +}; + +/** + * Special case QList<QAction*> --> PyQt object + */ + struct QList_QAction_to_python_list_PyQt + { + typedef QList<QAction*>::const_iterator iter; + + static PyObject* convert(const QList<QAction*> &qList) + { + #if SIP_API_MAJOR_NR >=4 + const sipTypeDef *type = sip_API->api_find_type("QAction"); + #else + sipWrapperType *type = sip_API->api_find_class("QAction"); + #endif + if (!type) + return incref(Py_None); + + boost::python::list pyList; + + foreach (QAction *action, qList) { + #if SIP_API_MAJOR_NR >=4 + PyObject *sip_obj = sip_API->api_convert_from_type(action, type, 0); + #else + PyObject *sip_obj = sip_API->api_convert_from_instance(action, type, 0); + #endif + if (!sip_obj) + continue; + boost::python::object real_obj = object(handle<>(sip_obj)); + pyList.append(real_obj); + } + + return boost::python::incref(pyList.ptr()); + } + }; + + struct QList_QAction_from_python_list_PyQt + { + QList_QAction_from_python_list_PyQt() + { + converter::registry::push_back( &convertible, &construct, type_id< QList<QAction*> >() ); + } + + static void* convertible(PyObject *obj_ptr) + { + + //is this a tuple type? + if (PyTuple_Check(obj_ptr)) { + //check the tuple elements... - convert to a boost::tuple object + boost::python::tuple t( handle<>(borrowed(obj_ptr)) ); + + //how many elements are there? + int n = PyTuple_Size(obj_ptr); + + //can they all be converted to type 'T'? + for (int i=0; i<n; ++i) { + if (!boost::python::extract<QAction*>(t[i]).check()) + return 0; + } + + //the tuple is ok! + return obj_ptr; + } + //is this a list type? + else if (PyList_Check(obj_ptr)) { + //check that all of the list elements can be converted to the right type + boost::python::list l( handle<>(borrowed(obj_ptr)) ); + + //how many elements are there? + int n = PyList_Size(obj_ptr); + + //return obj_ptr; + + //can all of the elements be converted to type 'T'? + for (int i=0; i<n; ++i) { + if (!boost::python::extract<QAction*>(l[i]).check()) + return 0; + } + + //the list is ok! + return obj_ptr; + } + + //could not recognise the type... + return 0; + } + + static void construct(PyObject *obj_ptr, converter::rvalue_from_python_stage1_data *data) + { + if (PyTuple_Check(obj_ptr)) { + //convert the PyObject to a boost::python::object + boost::python::tuple t( handle<>(borrowed(obj_ptr)) ); + + //locate the storage space for the result + void* storage = ((converter::rvalue_from_python_storage< QList<QAction*> >*)data)->storage.bytes; + + //create the T container + new (storage) QList<QAction*>(); + + QList<QAction*> *container = static_cast< QList<QAction*>* >(storage); + + //add all of the elements from the tuple - get the number of elements in the tuple + int n = PyTuple_Size(obj_ptr); + + for (int i=0; i<n; ++i) { + QAction *action = boost::python::extract<QAction*>(t[i]); + container->append( action ); + } + + data->convertible = storage; + } + else if (PyList_Check(obj_ptr)) { + //convert the PyObject to a boost::python::object + boost::python::list l( handle<>(borrowed(obj_ptr)) ); + + //locate the storage space for the result + void* storage = ((converter::rvalue_from_python_storage< QList<QAction*> >*)data)->storage.bytes; + + //create the T container + new (storage) QList<QAction*>(); + + QList<QAction*> *container = static_cast< QList<QAction*>* >(storage); + + //add all of the elements from the tuple - get the number of elements in the tuple + int n = PyList_Size(obj_ptr); + + for (int i=0; i<n; ++i) { + QAction *action = boost::python::extract<QAction*>(l[i]); + container->append( action ); + } + + data->convertible = storage; + } + } + + }; + + +/** + * The toPyQt implementation + */ +template <typename T> +PyObject* toPyQt(T *obj) +{ + if (!obj) { + std::cout << "toPyQt: null pointer object"; + return incref(Py_None); + } + +#if SIP_API_MAJOR_NR >=4 + const sipTypeDef *type = sip_API->api_find_type(MetaData<T>::className()); +#else + sipWrapperType *type = sip_API->api_find_class(MetaData<T>::className()); +#endif + if (!type) { + std::cout << "toPyQt: could not determine type"; + return incref(Py_None); + } + +#if SIP_API_MAJOR_NR >=4 + PyObject *sip_obj = sip_API->api_convert_from_type(obj, type, 0); +#else + PyObject *sip_obj = sip_API->api_convert_from_instance(obj, type, 0); +#endif + if (!sip_obj) { + return incref(Py_None); + std::cout << "toPyQt: could not convert"; + } + + return incref(sip_obj); +} + +void export_sip() +{ + if (!init_sip_api()) { + std::cout << "Could not initialize SIP API !" << std::endl; + return; + } + + // toPyQt functions + def("toPyQt", &toPyQt<Manhattan::FancyTabWidget>); + def("toPyQt", &toPyQt<ManhattanStyle>); + + // QClass* <--> PyQt objects + QClass_converters<QColor>(); + QClass_converters<QObject>(); + QClass_converters<QWidget>(); // from python + QClass_converters<QAction>(); // from/to python + QClass_converters<QIcon>(); + //QClass_converters<QString>(); + //QClass_converters<QColor>(); + + + // special case + to_python_converter<QList<QAction*>, QList_QAction_to_python_list_PyQt>(); + QList_QAction_from_python_list_PyQt(); +} diff --git a/GUI/externals/qt-manhattan-style/qt-manhattan-style.pro b/GUI/externals/qt-manhattan-style/qt-manhattan-style.pro index 8f789a3566fe87997f4fb500c5eca4bfb28082d2..c81e4ebdc945811119a7b0c7354837324367a908 100644 --- a/GUI/externals/qt-manhattan-style/qt-manhattan-style.pro +++ b/GUI/externals/qt-manhattan-style/qt-manhattan-style.pro @@ -1,5 +1,5 @@ # Application visual style as in qt-creator, taken from https://github.com/tegesoft/qt-manhattan -TARGET = qt-manhattan-style +TARGET = ManhattanStyle TEMPLATE = lib QT += core gui @@ -36,7 +36,11 @@ SOURCES += \ doubletabwidget.cpp \ extensions/simpleprogressbar.cpp \ extensions/tabwidget.cpp \ - extensions/threelevelsitempicker.cpp + extensions/threelevelsitempicker.cpp \ + #module2.cpp + module.cpp \ + module_sip.cpp \ + module_qstring.cpp HEADERS +=\ stylehelper.h \ @@ -80,6 +84,20 @@ OTHER_FILES += \ CMakeLists.txt +#pythonvers=$$system("python -c 'import sys; sys.stdout.write(sys.version[:3])'") +#pythonsysincdir=$$system("python -c 'import sys; sys.stdout.write(sys.prefix + \"/include/python\" + sys.version[:3])'") +#pythonsyslibdir=$$system("python -c 'import sys; sys.stdout.write(sys.prefix + \"/lib\" )'") +#INCLUDEPATH += $$pythonsysincdir +#LIBS += -lboost_python -L$$pythonsyslibdir -lpython$$pythonvers + +# ----------------------------------------------------------------------------- +# general project settings +# ----------------------------------------------------------------------------- + +CONFIG += BORNAGAIN_PYTHON +include($$PWD/../../../shared.pri) +INCLUDEPATH -= /opt/local/include + # ----------------------------------------------------------------------------- # Installing library into dedicated directory at the end of compilation # ----------------------------------------------------------------------------- @@ -87,3 +105,4 @@ target.path = $$PWD/../../../lib INSTALLS += target QMAKE_DISTCLEAN += $$target.path/$(TARGET) QMAKE_POST_LINK = (make install) + diff --git a/GUI/externals/qt-manhattan-style/resources/resources.qrc b/GUI/externals/qt-manhattan-style/resources/resources.qrc index f6050eeedcf29866bae6f5be6ac29228420e9928..1c216e94513c0843d721660de008657afc34ea16 100644 --- a/GUI/externals/qt-manhattan-style/resources/resources.qrc +++ b/GUI/externals/qt-manhattan-style/resources/resources.qrc @@ -9,4 +9,16 @@ <file>rightselection.png</file> <file>targetpanel_bottom.png</file> </qresource> + <qresource prefix="/extensions/images"> + <file>scrollbar-vertical-up-highlight.png</file> + <file>scrollbar-vertical-background.png</file> + <file>scrollbar-vertical-down.png</file> + <file>scrollbar-vertical-down-highlight.png</file> + <file>scrollbar-vertical-slider.png</file> + <file>scrollbar-vertical-slider-highlight.png</file> + <file>scrollbar-vertical-up.png</file> + </qresource> + <qresource prefix="/extensions/qss"> + <file>threelevelsitempicker-listwidget.qss</file> + </qresource> </RCC> diff --git a/GUI/externals/qt-manhattan-style/resources/scrollbar-vertical-background.png b/GUI/externals/qt-manhattan-style/resources/scrollbar-vertical-background.png new file mode 100644 index 0000000000000000000000000000000000000000..42a9b86c7b446bfeaef151440086f8d223a27ced Binary files /dev/null and b/GUI/externals/qt-manhattan-style/resources/scrollbar-vertical-background.png differ diff --git a/GUI/externals/qt-manhattan-style/resources/scrollbar-vertical-down-highlight.png b/GUI/externals/qt-manhattan-style/resources/scrollbar-vertical-down-highlight.png new file mode 100644 index 0000000000000000000000000000000000000000..e4bf7b40251fb16c28d73af51abe4b7538388159 Binary files /dev/null and b/GUI/externals/qt-manhattan-style/resources/scrollbar-vertical-down-highlight.png differ diff --git a/GUI/externals/qt-manhattan-style/resources/scrollbar-vertical-down.png b/GUI/externals/qt-manhattan-style/resources/scrollbar-vertical-down.png new file mode 100644 index 0000000000000000000000000000000000000000..5f91b598bbbb837a159893833fb2c992fe9870a5 Binary files /dev/null and b/GUI/externals/qt-manhattan-style/resources/scrollbar-vertical-down.png differ diff --git a/GUI/externals/qt-manhattan-style/resources/scrollbar-vertical-slider-highlight.png b/GUI/externals/qt-manhattan-style/resources/scrollbar-vertical-slider-highlight.png new file mode 100644 index 0000000000000000000000000000000000000000..96cba68f5d92eb162e8b7222016148153e4f1a60 Binary files /dev/null and b/GUI/externals/qt-manhattan-style/resources/scrollbar-vertical-slider-highlight.png differ diff --git a/GUI/externals/qt-manhattan-style/resources/scrollbar-vertical-slider.png b/GUI/externals/qt-manhattan-style/resources/scrollbar-vertical-slider.png new file mode 100644 index 0000000000000000000000000000000000000000..e3b100f2645132b129bb411b2c84be16498b2d9b Binary files /dev/null and b/GUI/externals/qt-manhattan-style/resources/scrollbar-vertical-slider.png differ diff --git a/GUI/externals/qt-manhattan-style/resources/scrollbar-vertical-up-highlight.png b/GUI/externals/qt-manhattan-style/resources/scrollbar-vertical-up-highlight.png new file mode 100644 index 0000000000000000000000000000000000000000..73851f6002960a014023d63943b51eb1e2b664a8 Binary files /dev/null and b/GUI/externals/qt-manhattan-style/resources/scrollbar-vertical-up-highlight.png differ diff --git a/GUI/externals/qt-manhattan-style/resources/scrollbar-vertical-up.png b/GUI/externals/qt-manhattan-style/resources/scrollbar-vertical-up.png new file mode 100644 index 0000000000000000000000000000000000000000..3638898f2fe8fb4f05e263b96dc25e718efc0a0e Binary files /dev/null and b/GUI/externals/qt-manhattan-style/resources/scrollbar-vertical-up.png differ diff --git a/GUI/externals/qt-manhattan-style/resources/threelevelsitempicker-listwidget.qss b/GUI/externals/qt-manhattan-style/resources/threelevelsitempicker-listwidget.qss new file mode 100644 index 0000000000000000000000000000000000000000..52a99b447a9ffb7481252eaae5979a1fdd5d2327 --- /dev/null +++ b/GUI/externals/qt-manhattan-style/resources/threelevelsitempicker-listwidget.qss @@ -0,0 +1,48 @@ +QListWidget { + background: #464646; + border-style: none; +} + +QScrollBar:vertical { + margin: 17px 0 17px 0; + border-image: url(:extensions/images/scrollbar-vertical-background.png) 10 0 10 0 stretch stretch; +} + +QScrollBar::handle:vertical { + border-width: 1px; + border-image: url(:extensions/images/scrollbar-vertical-slider.png) 2 1 2 1 stretch stretch; + min-height: 20px; +} + +QScrollBar::handle:vertical:hover { + border-image: url(:extensions/images/scrollbar-vertical-slider-highlight.png) 2 1 2 1 stretch stretch; + min-height: 20px; +} + +QScrollBar::add-line:vertical { + border-image: url(:extensions/images/scrollbar-vertical-down.png); + height: 16px; + subcontrol-origin: margin; +} + +QScrollBar::add-line:vertical:hover { + border-image: url(:extensions/images/scrollbar-vertical-down-highlight.png); + height: 16px; + subcontrol-origin: margin; +} + +QScrollBar::sub-line:vertical { + border-image: url(:extensions/images/scrollbar-vertical-up.png); + height: 16px; + subcontrol-origin: margin; +} + +QScrollBar::sub-line:vertical:hover { + border-image: url(:extensions/images/scrollbar-vertical-up-highlight.png); + height: 16px; + subcontrol-origin: margin; +} + +QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { + background: none; +} diff --git a/GUI/pygui/application.py b/GUI/pygui/application.py new file mode 100644 index 0000000000000000000000000000000000000000..c80e31a277a07af726538ec51ada725dc3729745 --- /dev/null +++ b/GUI/pygui/application.py @@ -0,0 +1,16 @@ +import sys +import os +from PyQt4.QtGui import QApplication, QMainWindow + +from mainwindow.MainWindow import MainWindow + + +def main(): + a = QApplication(sys.argv) + w = MainWindow() + w.show() + return a.exec_() + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/GUI/pygui/mainwindow/MainWindow.py b/GUI/pygui/mainwindow/MainWindow.py new file mode 100644 index 0000000000000000000000000000000000000000..4ffcc560bda483b0ded90c065c04b2d171ed4d5f --- /dev/null +++ b/GUI/pygui/mainwindow/MainWindow.py @@ -0,0 +1,57 @@ +import sys +import os +import sip + +from PyQt4.QtCore import ( + Qt, QObject, QString +) + +from PyQt4.QtGui import ( + QApplication, qApp, QMainWindow, QWidget, QIcon, QColor, QStyle +) + +sys.path.append(os.path.abspath("../../lib")) +sys.path.append(os.path.abspath("..")) + + +def toPyQt(object, type): + ptr = object.unwrap() + return sip.wrapinstance(ptr, type) + +def fromPyQt(object, type): + ptr = sip.unwrapinstance(object) + return type.wrap(ptr) + + +import libManhattanStyle as lms +from views.WelcomeView import WelcomeView + +class MainWindow(QMainWindow): + def __init__(self, parent=None): + QMainWindow.__init__(self, parent) + + baseName = QApplication.style().objectName() + + manhattan_style = lms.ManhattanStyle( str(baseName) ) + #manhattan_style = lms.ManhattanStyle( sip.unwrapinstance(baseName) ) + #manhattan_style = lms.ManhattanStyle( fromPyQt(baseName, lms.QString) ) + + #lms.StyleHelper.setBaseColor( fromPyQt(QColor(0x086FA1), lms.QColor) ) + + k = QColor(Qt.red) + lms.StyleHelper.setBaseColor(k ) + qApp.setStyle( lms.toPyQt(manhattan_style) ) + + + self.__tabWidget = lms.FancyTabWidget() + self.__welcomeView = WelcomeView() + #self.__welcomeView = QWidget() + + self.__tabWidget.insertTab(0, self.__welcomeView, QIcon(":/images/mode_welcome.png"), "Welcome" ) + #self.__tabWidget.insertTab(0, fromPyQt(self.__welcomeView, lms.QWidget), fromPyQt(QIcon(":/images/mode_welcome.png"), lms.QIcon), fromPyQt(QString("Welcome"), lms.QString )) + + self.setCentralWidget( lms.toPyQt(self.__tabWidget) ) + #self.setCentralWidget( toPyQt(self.__tabWidget, QWidget) ) + + + diff --git a/GUI/pygui/mainwindow/__init__.py b/GUI/pygui/mainwindow/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..d0c49d273161286a070480bfabc024435430267f --- /dev/null +++ b/GUI/pygui/mainwindow/__init__.py @@ -0,0 +1 @@ +__author__ = 'pospelov' diff --git a/GUI/pygui/views/WelcomeView.py b/GUI/pygui/views/WelcomeView.py new file mode 100644 index 0000000000000000000000000000000000000000..7a71f68cd1536b9bf0aa51b0e9c5b6c4497f54cb --- /dev/null +++ b/GUI/pygui/views/WelcomeView.py @@ -0,0 +1,12 @@ +from PyQt4.QtCore import ( + QObject, +) + +from PyQt4.QtGui import ( + QMainWindow, QWidget, +) + + +class WelcomeView(QWidget): + def __init__(self, parent = None): + QWidget.__init__(self, parent) diff --git a/GUI/pygui/views/__init__.py b/GUI/pygui/views/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..d0c49d273161286a070480bfabc024435430267f --- /dev/null +++ b/GUI/pygui/views/__init__.py @@ -0,0 +1 @@ +__author__ = 'pospelov'