NewFolderDialog::NewFolderDialog( QWidget* parent, KMFolder *folder )
  : KDialog( parent ),
    mFormatComboBox( 0 ), mContentsComboBox( 0 ),
    mNamespacesComboBox( 0 ), mFolder( folder )
{
  setCaption( i18n( "New Folder" ) );
  setButtons( Ok | Cancel );
  setModal( false );
  setObjectName( "new_folder_dialog" );
  setAttribute( Qt::WA_DeleteOnClose );
  if ( mFolder ) {
    setCaption( i18n( "New Subfolder of %1", mFolder->prettyUrl() ) );
  }
  connect( this, SIGNAL(okClicked()), SLOT(slotOk()) );
  QWidget *privateLayoutWidget = new QWidget( this );
  privateLayoutWidget->setObjectName( "mTopLevelLayout" );
  privateLayoutWidget->setGeometry( QRect( 10, 10, 260, 80 ) );
  setMainWidget( privateLayoutWidget );
  mTopLevelLayout = new QVBoxLayout( privateLayoutWidget );
  mTopLevelLayout->setObjectName( "mTopLevelLayout" );
  mTopLevelLayout->setSpacing( spacingHint() );
  mTopLevelLayout->setMargin( 0 );

  mNameHBox = new QHBoxLayout();
  mNameHBox->setSpacing( 6 );
  mNameHBox->setMargin( 0 );
  mNameHBox->setObjectName( "mNameHBox" );

  mNameLabel = new QLabel( privateLayoutWidget );
  mNameLabel->setObjectName( "mNameLabel" );
  mNameLabel->setText( i18nc( "@label:textbox Name of the new folder.", "&Name:" ) );
  mNameHBox->addWidget( mNameLabel );

  mNameLineEdit = new KLineEdit( privateLayoutWidget );
  mNameLineEdit->setObjectName( "mNameLineEdit" );
  mNameLineEdit->setClearButtonShown( true );
  mNameLabel->setBuddy( mNameLineEdit );
  mNameLineEdit->setWhatsThis( i18n( "Enter a name for the new folder." ) );
  mNameLineEdit->setFocus();
  mNameHBox->addWidget( mNameLineEdit );
  mTopLevelLayout->addLayout( mNameHBox );
  connect( mNameLineEdit, SIGNAL( textChanged ( const QString & ) ), this, SLOT( slotFolderNameChanged( const QString & ) ) );

  if ( !mFolder ||
      ( mFolder->folderType() != KMFolderTypeImap &&
        mFolder->folderType() != KMFolderTypeCachedImap ) ) {
    mFormatHBox = new QHBoxLayout();
    mFormatHBox->setSpacing( 6 );
    mFormatHBox->setMargin( 0 );
    mFormatHBox->setObjectName( "mFormatHBox" );
    mMailboxFormatLabel = new QLabel( privateLayoutWidget );
    mMailboxFormatLabel->setObjectName( "mMailboxFormatLabel" );
    mMailboxFormatLabel->setText( i18n( "Mailbox &format:" ) );
    mFormatHBox->addWidget( mMailboxFormatLabel );

    mFormatComboBox = new KComboBox( privateLayoutWidget );
    mFormatComboBox->setEditable( false );
    mFormatComboBox->setObjectName( "mFormatComboBox" );
    mMailboxFormatLabel->setBuddy( mFormatComboBox );
    mFormatComboBox->setWhatsThis( i18n( "Select whether you want to store the messages in this folder as one file per  message (maildir) or as one big file (mbox). KMail uses maildir by default and this only needs to be changed in rare circumstances. If you are unsure, leave this option as-is." ) );

    mFormatComboBox->insertItem(0,"mbox");
    mFormatComboBox->insertItem(1,"maildir");
    // does the below make any sense?
    //  mFormatComboBox->insertItem(2, "search");
    {
      KSharedConfig::Ptr config = KMKernel::config();
      KConfigGroup group(config, "General");
      int type = group.readEntry("default-mailbox-format", 1 );
      if ( type < 0 || type > 1 ) type = 1;
      mFormatComboBox->setCurrentIndex( type );
    }
    mFormatHBox->addWidget( mFormatComboBox );
    mTopLevelLayout->addLayout( mFormatHBox );
  }

  // --- contents -----
  if ( kmkernel->iCalIface().isEnabled() &&
       mFolder && mFolder->folderType() != KMFolderTypeImap ) {
    mContentsHBox = new QHBoxLayout();
    mContentsHBox->setSpacing( 6 );
    mContentsHBox->setMargin( 0 );
    mContentsHBox->setObjectName( "mContentsHBox" );

    mContentsLabel = new QLabel( privateLayoutWidget );
    mContentsLabel->setObjectName( "mContentsLabel" );
    mContentsLabel->setText( i18n( "Folder &contains:" ) );
    mContentsHBox->addWidget( mContentsLabel );

    mContentsComboBox = new KComboBox(  privateLayoutWidget );
    mContentsComboBox->setEditable( false );
    mContentsComboBox->setObjectName( "mContentsComboBox" );
    mContentsLabel->setBuddy( mContentsComboBox );
    mContentsComboBox->setWhatsThis( i18n( "Select whether you want the new folder to be used for mail storage of for storage of groupware items such as tasks or notes. The default is mail. If you are unsure, leave this option as-is." ) );
    mContentsComboBox->addItem( i18nc( "type of folder content", "Mail" ) );
    mContentsComboBox->addItem( i18nc( "type of folder content", "Calendar" ) );
    mContentsComboBox->addItem( i18nc( "type of folder content", "Contacts" ) );
    mContentsComboBox->addItem( i18nc( "type of folder content", "Notes" ) );
    mContentsComboBox->addItem( i18nc( "type of folder content", "Tasks" ) );
    mContentsComboBox->addItem( i18nc( "type of folder content", "Journal" ) );
    if ( mFolder ) // inherit contents type from papa
      mContentsComboBox->setCurrentIndex( mFolder->storage()->contentsType() );
    mContentsHBox->addWidget( mContentsComboBox );
    mTopLevelLayout->addLayout( mContentsHBox );
  }

  if ( mFolder &&
      ( mFolder->folderType() == KMFolderTypeImap ||
        mFolder->folderType() == KMFolderTypeCachedImap ) ) {
    bool rootFolder = false;
    QStringList namespaces;
    if ( mFolder->folderType() == KMFolderTypeImap ) {
      ImapAccountBase* ai = static_cast<KMFolderImap*>(mFolder->storage())->account();
      if ( mFolder->storage() == ai->rootFolder() ) {
        rootFolder = true;
        namespaces = ai->namespaces()[ImapAccountBase::PersonalNS];
      }
    }
    if ( mFolder->folderType() == KMFolderTypeCachedImap ) {
      ImapAccountBase* ai = static_cast<KMFolderCachedImap*>(mFolder->storage())->account();
      if ( ai && mFolder->storage() == ai->rootFolder() ) {
        rootFolder = true;
        namespaces = ai->namespaces()[ImapAccountBase::PersonalNS];
      }
    }
    if ( rootFolder && namespaces.count() > 1 ) {
      mNamespacesHBox = new QHBoxLayout();
      mNamespacesHBox->setSpacing( 6 );
      mNamespacesHBox->setMargin( 0 );
      mNamespacesHBox->setObjectName( "mNamespaceHBox" );

      mNamespacesLabel = new QLabel( privateLayoutWidget );
      mNamespacesLabel->setObjectName( "mNamespacesLabel" );
      mNamespacesLabel->setText( i18n( "Namespace for &folder:" ) );
      mNamespacesHBox->addWidget( mNamespacesLabel );

      mNamespacesComboBox = new KComboBox( privateLayoutWidget );
      mNamespacesComboBox->setEditable( false );
      mNamespacesComboBox->setObjectName( "mNamespacesComboBox" );
      mNamespacesLabel->setBuddy( mNamespacesComboBox );
      mNamespacesComboBox->setWhatsThis( i18n( "Select the personal namespace the folder should be created in." ) );
      mNamespacesComboBox->addItems( namespaces );
      mNamespacesHBox->addWidget( mNamespacesComboBox );
      mTopLevelLayout->addLayout( mNamespacesHBox );
    } else {
      mNamespacesComboBox = 0;
    }
  }

  resize( QSize(282, 108).expandedTo(minimumSizeHint()) );
  setAttribute(Qt::WA_WState_Polished);
  slotFolderNameChanged( mNameLineEdit->text());
}
OSItemSelectorButtons::OSItemSelectorButtons(QWidget * parent)
    : QWidget(parent)
{
    this->setObjectName("OSItemSelectorButtons");
    this->setStyleSheet("QWidget#OSItemSelectorButtons { background: #E6E6E6; border-top: 1px solid black; }");

    m_vLayout = new QVBoxLayout();
    m_vLayout->setContentsMargins(0,0,0,0);
    m_vLayout->setSpacing(0);
    this->setLayout(m_vLayout);

    // drop zone

    QHBoxLayout * dropZoneLayout = new QHBoxLayout();
    dropZoneLayout->setContentsMargins(10,10,10,10);

    m_dropZoneController = new AlwaysEmptyDropZoneVectorController();
    m_dropZone = new OSDropZone(m_dropZoneController);
    m_dropZone->setMaxItems(1);
    dropZoneLayout->addWidget(m_dropZone);

    m_vLayout->addLayout(dropZoneLayout);

    connect(m_dropZone, &OSDropZone::itemDropped, this, &OSItemSelectorButtons::itemDropped);

    // buttons
    QWidget * buttonBox = new QWidget();
    buttonBox->setObjectName("ButtonBox");
    buttonBox->setStyleSheet("QWidget#ButtonBox { background: #808080; border-top: 1px solid black; }");
    m_vLayout->addWidget(buttonBox);

    QHBoxLayout * buttonLayout = new QHBoxLayout();
    buttonLayout->setContentsMargins(10,10,10,10);
    buttonLayout->setSpacing(5);
    buttonBox->setLayout(buttonLayout);

    m_addButton = new QPushButton();
    m_addButton->setFlat(true);
    m_addButton->setObjectName("AddButton");
    m_addButton->setToolTip("Add new object");
    m_addButton->setFixedSize(24,24);
    buttonLayout->addWidget(m_addButton);

    connect(m_addButton, &QPushButton::clicked, this, &OSItemSelectorButtons::addClicked);

    m_copyButton = new QPushButton();
    m_copyButton->setEnabled(false);
    m_copyButton->setFlat(true);
    m_copyButton->setObjectName("CopyButton");
    m_copyButton->setToolTip("Copy selected object");
    m_copyButton->setFixedSize(24,24);
    buttonLayout->addWidget(m_copyButton);

    connect(m_copyButton, &QPushButton::clicked, this, &OSItemSelectorButtons::copyClicked);

    m_removeButton = new QPushButton();
    m_removeButton->setEnabled(false);
    m_removeButton->setFlat(true);
    m_removeButton->setObjectName("DeleteButton");
    m_removeButton->setToolTip("Remove selected objects");
    m_removeButton->setFixedSize(24,24);
    buttonLayout->addWidget(m_removeButton);

    connect(m_removeButton, &QPushButton::clicked, this, &OSItemSelectorButtons::removeClicked);

    buttonLayout->addStretch();

    m_purgeButton = new QPushButton();
    m_purgeButton->setFlat(true);
    m_purgeButton->setObjectName("PurgeButton");
    m_purgeButton->setToolTip("Purge unused objects");
    m_purgeButton->setFixedSize(24,24);
    buttonLayout->addWidget(m_purgeButton);

    connect(m_purgeButton, &QPushButton::clicked, this, &OSItemSelectorButtons::purgeClicked);

    //m_openBclDlgButton = new QPushButton(this);
    //m_openBclDlgButton->setObjectName("OpenBclDlgButton");
    //m_openBclDlgButton->setText("Online BCL");
    //m_openBclDlgButton->hide();
    //m_vLayout->addWidget(m_openBclDlgButton);
    //
    //connect(m_openBclDlgButton, &QPushButton::clicked, this, &OSItemSelectorButtons::downloadComponentsClicked);
}
Example #3
0
/*!
    \internal
*/
QWidget *QFormBuilder::createWidget(const QString &widgetName, QWidget *parentWidget, const QString &name)
{
    if (widgetName.isEmpty()) {
        //: Empty class name passed to widget factory method
        qWarning() << QCoreApplication::translate("QFormBuilder", "An empty class name was passed on to %1 (object name: '%2').").arg(QString::fromUtf8(Q_FUNC_INFO), name);
        return 0;
    }

    QWidget *w = 0;

#ifndef QT_NO_TABWIDGET
    if (qobject_cast<QTabWidget*>(parentWidget))
        parentWidget = 0;
#endif
#ifndef QT_NO_STACKEDWIDGET
    if (qobject_cast<QStackedWidget*>(parentWidget))
        parentWidget = 0;
#endif
#ifndef QT_NO_TOOLBOX
    if (qobject_cast<QToolBox*>(parentWidget))
        parentWidget = 0;
#endif

    // ### special-casing for Line (QFrame) -- fix for 4.2
    do {
        if (widgetName == QFormBuilderStrings::instance().lineClass) {
            w = new QFrame(parentWidget);
            static_cast<QFrame*>(w)->setFrameStyle(QFrame::HLine | QFrame::Sunken);
            break;
        }
        const QByteArray widgetNameBA = widgetName.toUtf8();
        const char *widgetNameC = widgetNameBA.constData();
        if (w) { // symmetry for macro
        }

#define DECLARE_LAYOUT(L, C)
#define DECLARE_COMPAT_WIDGET(W, C)
#define DECLARE_WIDGET(W, C) else if (!qstrcmp(widgetNameC, #W)) { Q_ASSERT(w == 0); w = new W(parentWidget); }
#define DECLARE_WIDGET_1(W, C) else if (!qstrcmp(widgetNameC, #W)) { Q_ASSERT(w == 0); w = new W(0, parentWidget); }

#include "widgets.table"

#undef DECLARE_COMPAT_WIDGET
#undef DECLARE_LAYOUT
#undef DECLARE_WIDGET
#undef DECLARE_WIDGET_1

        if (w)
            break;

        // try with a registered custom widget
        QDesignerCustomWidgetInterface *factory = m_customWidgets.value(widgetName);
        if (factory != 0)
            w = factory->createWidget(parentWidget);
    } while(false);

    QFormBuilderExtra *fb = QFormBuilderExtra::instance(this);
    if (w == 0) { // Attempt to instantiate base class of promoted/custom widgets
        const QString baseClassName = fb->customWidgetBaseClass(widgetName);
        if (!baseClassName.isEmpty()) {
            qWarning() << QCoreApplication::translate("QFormBuilder", "QFormBuilder was unable to create a custom widget of the class '%1'; defaulting to base class '%2'.").arg(widgetName, baseClassName);
            return createWidget(baseClassName, parentWidget, name);
        }
    }

    if (w == 0) { // nothing to do
        qWarning() << QCoreApplication::translate("QFormBuilder", "QFormBuilder was unable to create a widget of the class '%1'.").arg(widgetName);
        return 0;
    }

    w->setObjectName(name);

    if (qobject_cast<QDialog *>(w))
        w->setParent(parentWidget);

    return w;
}
Example #4
0
ItemLibraryWidget::ItemLibraryWidget(QWidget *parent) :
    QFrame(parent),
    m_iconProvider(m_resIconSize),
    m_itemIconSize(24, 24),
    m_resIconSize(24, 24),
    m_itemsView(new QQuickView()),
    m_resourcesView(new Internal::ItemLibraryTreeView(this)),
    m_filterFlag(QtBasic),
    m_itemLibraryId(-1)
{
    Internal::registerQmlTypes();

    setWindowTitle(tr("Library", "Title of library view"));

    /* create Items view and its model */
    m_itemsView->setResizeMode(QQuickView::SizeRootObjectToView);
    m_itemsView->engine()->setOutputWarningsToStandardError(debug);
    m_itemLibraryModel = new Internal::ItemLibraryModel(this);
    m_itemLibraryModel->setItemIconSize(m_itemIconSize);

    QQmlContext *rootContext = m_itemsView->rootContext();
    rootContext->setContextProperty(QLatin1String("itemLibraryModel"), m_itemLibraryModel.data());
    rootContext->setContextProperty(QLatin1String("itemLibraryIconWidth"), m_itemIconSize.width());
    rootContext->setContextProperty(QLatin1String("itemLibraryIconHeight"), m_itemIconSize.height());

    QColor highlightColor = palette().highlight().color();
    if (0.5*highlightColor.saturationF()+0.75-highlightColor.valueF() < 0)
        highlightColor.setHsvF(highlightColor.hsvHueF(),0.1 + highlightColor.saturationF()*2.0, highlightColor.valueF());
    m_itemsView->rootContext()->setContextProperty(QLatin1String("highlightColor"), highlightColor);

    // loading the qml has to come after all needed context properties are set
    m_itemsView->setSource(QUrl("qrc:/ItemLibrary/qml/ItemsView.qml"));

    QQuickItem *rootItem = qobject_cast<QQuickItem*>(m_itemsView->rootObject());
    connect(rootItem, SIGNAL(itemSelected(int)), this, SLOT(showItemInfo(int)));
    connect(rootItem, SIGNAL(itemDragged(int)), this, SLOT(startDragAndDropDelayed(int)));
    connect(this, SIGNAL(scrollItemsView(QVariant)), rootItem, SLOT(scrollView(QVariant)));
    connect(this, SIGNAL(resetItemsView()), rootItem, SLOT(resetView()));

    /* create Resources view and its model */
    m_resourcesFileSystemModel = new QFileSystemModel(this);
    m_resourcesFileSystemModel->setIconProvider(&m_iconProvider);
    m_resourcesView->setModel(m_resourcesFileSystemModel.data());
    m_resourcesView->setIconSize(m_resIconSize);

    /* create image provider for loading item icons */
    m_itemsView->engine()->addImageProvider(QLatin1String("qmldesigner_itemlibrary"), new Internal::ItemLibraryImageProvider);

    /* other widgets */
    QTabBar *tabBar = new QTabBar(this);
    tabBar->addTab(tr("QML Types", "Title of library QML types view"));
    tabBar->addTab(tr("Resources", "Title of library resources view"));
    tabBar->addTab(tr("Imports", "Title of library imports view"));
    tabBar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    connect(tabBar, SIGNAL(currentChanged(int)), this, SLOT(setCurrentIndexOfStackedWidget(int)));
    connect(tabBar, SIGNAL(currentChanged(int)), this, SLOT(updateSearch()));

    m_filterLineEdit = new Utils::FilterLineEdit(this);
    m_filterLineEdit->setObjectName(QLatin1String("itemLibrarySearchInput"));
    m_filterLineEdit->setPlaceholderText(tr("<Filter>", "Library search input hint text"));
    m_filterLineEdit->setDragEnabled(false);
    m_filterLineEdit->setMinimumWidth(75);
    m_filterLineEdit->setTextMargins(0, 0, 20, 0);
    QWidget *lineEditFrame = new QWidget(this);
    lineEditFrame->setObjectName(QLatin1String("itemLibrarySearchInputFrame"));
    QGridLayout *lineEditLayout = new QGridLayout(lineEditFrame);
    lineEditLayout->setMargin(2);
    lineEditLayout->setSpacing(0);
    lineEditLayout->addItem(new QSpacerItem(5, 3, QSizePolicy::Fixed, QSizePolicy::Fixed), 0, 0, 1, 3);
    lineEditLayout->addItem(new QSpacerItem(5, 5, QSizePolicy::Fixed, QSizePolicy::Fixed), 1, 0);
    lineEditLayout->addWidget(m_filterLineEdit.data(), 1, 1, 1, 1);
    lineEditLayout->addItem(new QSpacerItem(5, 5, QSizePolicy::Fixed, QSizePolicy::Fixed), 1, 2);
    connect(m_filterLineEdit.data(), SIGNAL(filterChanged(QString)), this, SLOT(setSearchFilter(QString)));

    QWidget *container = createWindowContainer(m_itemsView.data());
    m_stackedWidget = new QStackedWidget(this);
    m_stackedWidget->addWidget(container);
    m_stackedWidget->addWidget(m_resourcesView.data());

    QWidget *spacer = new QWidget(this);
    spacer->setObjectName(QLatin1String("itemLibrarySearchInputSpacer"));
    spacer->setFixedHeight(4);

    QGridLayout *layout = new QGridLayout(this);
    layout->setContentsMargins(0, 0, 0, 0);
    layout->setSpacing(0);
    layout->addWidget(tabBar, 0, 0, 1, 1);
    layout->addWidget(spacer, 1, 0);
    layout->addWidget(lineEditFrame, 2, 0, 1, 1);
    layout->addWidget(m_stackedWidget.data(), 3, 0, 1, 1);

    setResourcePath(QDir::currentPath());
    setSearchFilter(QString());

    /* style sheets */
    setStyleSheet(QLatin1String(Utils::FileReader::fetchQrc(":/qmldesigner/stylesheet.css")));
    m_resourcesView->setStyleSheet(QLatin1String(Utils::FileReader::fetchQrc(":/qmldesigner/scrollbar.css")));
}
Example #5
0
QWidget* MenuItem::rowWidget(CamcopsApp& app) const
{
    QWidget* row = new QWidget();
    QHBoxLayout* rowlayout = new QHBoxLayout();
    row->setLayout(rowlayout);

    if (m_p_task) {
        // --------------------------------------------------------------------
        // Task instance
        // --------------------------------------------------------------------
        // Stretch: http://stackoverflow.com/questions/14561516/qt-qhboxlayout-percentage-size

        bool complete = m_p_task->isComplete();
        const bool& threecols = m_task_shows_taskname;

        // Taskname
        if (m_task_shows_taskname) {
            QLabel* taskname = new LabelWordWrapWide(m_p_task->shortname());
            taskname->setObjectName(complete
                                    ? "task_item_taskname_complete"
                                    : "task_item_taskname_incomplete");
            QSizePolicy spTaskname(QSizePolicy::Preferred,
                                   QSizePolicy::Preferred);
            spTaskname.setHorizontalStretch(STRETCH_3COL_TASKNAME);
            taskname->setSizePolicy(spTaskname);
            rowlayout->addWidget(taskname);
        }
        // Timestamp
        QLabel* timestamp = new LabelWordWrapWide(
            m_p_task->whenCreated().toString(DateTime::SHORT_DATETIME_FORMAT));
        timestamp->setObjectName(complete ? "task_item_timestamp_complete"
                                          : "task_item_timestamp_incomplete");
        QSizePolicy spTimestamp(QSizePolicy::Preferred,
                                QSizePolicy::Preferred);
        spTimestamp.setHorizontalStretch(threecols ? STRETCH_3COL_TIMESTAMP
                                                   : STRETCH_2COL_TIMESTAMP);
        timestamp->setSizePolicy(spTimestamp);
        rowlayout->addWidget(timestamp);
        // Summary
        QLabel* summary = new LabelWordWrapWide(
                    m_p_task->summaryWithCompleteSuffix());
        summary->setObjectName(complete ? "task_item_summary_complete"
                                        : "task_item_summary_incomplete");
        QSizePolicy spSummary(QSizePolicy::Preferred, QSizePolicy::Preferred);
        spSummary.setHorizontalStretch(threecols ? STRETCH_3COL_SUMMARY
                                                 : STRETCH_2COL_SUMMARY);
        summary->setSizePolicy(spSummary);
        rowlayout->addWidget(summary);
    } else {
        // --------------------------------------------------------------------
        // Conventional menu item
        // --------------------------------------------------------------------

        // Icon
        if (!m_label_only) {  // Labels go full-left
            if (!m_icon.isEmpty()) {
                QLabel* icon = UiFunc::iconWidget(m_icon, row);
                rowlayout->addWidget(icon);
            } else if (m_chain) {
                QLabel* icon = UiFunc::iconWidget(
                    UiFunc::iconFilename(UiConst::ICON_CHAIN), row);
                rowlayout->addWidget(icon);
            } else {
                rowlayout->addWidget(UiFunc::blankIcon(row));
            }
        }

        // Title/subtitle
        QVBoxLayout* textlayout = new QVBoxLayout();

        QLabel* title = new LabelWordWrapWide(m_title);
        title->setObjectName("menu_item_title");
        textlayout->addWidget(title);
        if (!m_subtitle.isEmpty()) {
            QLabel* subtitle = new LabelWordWrapWide(m_subtitle);
            subtitle->setObjectName("menu_item_subtitle");
            textlayout->addWidget(subtitle);
        }
        rowlayout->addLayout(textlayout);
        rowlayout->addStretch();

        // Arrow on right
        if (m_arrow_on_right) {
            QLabel* iconLabel = UiFunc::iconWidget(
                UiFunc::iconFilename(UiConst::ICON_HASCHILD),
                nullptr, false);
            rowlayout->addWidget(iconLabel);
        }

        // Background colour, via stylesheets
        if (m_label_only) {
            row->setObjectName("label_only");
        } else if (!m_implemented) {
            row->setObjectName("not_implemented");
        } else if (m_unsupported) {
            row->setObjectName("unsupported");
        } else if (m_not_if_locked && app.locked()) {
            row->setObjectName("locked");
        } else if (m_needs_privilege && !app.privileged()) {
            row->setObjectName("needs_privilege");
        }
        // ... but not for locked/needs privilege, as otherwise we'd need
        // to refresh the whole menu? Well, we could try it.
        // On Linux desktop, it's extremely fast.
    }

    // Size policy
    QSizePolicy size_policy(QSizePolicy::MinimumExpanding,  // horizontal
                            QSizePolicy::Fixed);  // vertical
    row->setSizePolicy(size_policy);

    return row;
}
BackstageOSF::BackstageOSF(QWidget *parent) : BackstagePage(parent)
{
	QGridLayout *layout = new QGridLayout(this);
	layout->setSpacing(0);
	layout->setContentsMargins(0, 0, 0, 0);
	setLayout(layout);

	QWidget *topRow = new QWidget(this);
	layout->addWidget(topRow);

	QGridLayout *topRowLayout = new QGridLayout();
	topRowLayout->setContentsMargins(0, 6, 12, 0);
	topRow->setLayout(topRowLayout);

	QLabel *label = new QLabel("Open Science Framework", topRow);
	QSizePolicy sp = label->sizePolicy();
	sp.setHorizontalStretch(1);
	label->setSizePolicy(sp);
	label->setContentsMargins(12, 12, 12, 1);
	topRowLayout->addWidget(label, 0, 0);

	_nameButton = new QToolButton(topRow);
	_nameButton->hide();
	topRowLayout->addWidget(_nameButton, 0, 1);

	connect(_nameButton, SIGNAL(clicked(bool)), this, SLOT(nameClicked()));

	QWidget *buttonsWidget = new QWidget(this);
	buttonsWidget->setContentsMargins(0, 0, 0, 0);
	layout->addWidget(buttonsWidget);

	QGridLayout *buttonsWidgetLayout = new QGridLayout(buttonsWidget);
	buttonsWidgetLayout->setContentsMargins(0, 0, 12, 0);
	buttonsWidget->setLayout(buttonsWidgetLayout);

	_breadCrumbs = new BreadCrumbs(buttonsWidget);
	buttonsWidgetLayout->addWidget(_breadCrumbs, 0, 0);

	_newFolderButton = new QToolButton(buttonsWidget);
	_newFolderButton->setText("New Folder");
	_newFolderButton->hide();
	buttonsWidgetLayout->addWidget(_newFolderButton, 0, 2);

	_fileNameContainer = new QWidget(this);
	_fileNameContainer->hide();
	_fileNameContainer->setObjectName("browseContainer");
	layout->addWidget(_fileNameContainer);

	QHBoxLayout *saveLayout = new QHBoxLayout(_fileNameContainer);
	_fileNameContainer->setLayout(saveLayout);

	_fileNameTextBox = new QLineEdit(_fileNameContainer);
	QSizePolicy policy = _fileNameTextBox->sizePolicy();
	policy.setHorizontalStretch(1);
	_fileNameTextBox->setSizePolicy(policy);
	_fileNameTextBox->setEnabled(false);

	saveLayout->addWidget(_fileNameTextBox);

	_saveButton = new QPushButton(_fileNameContainer);
	_saveButton->setText("Save");
	_saveButton->setEnabled(false);
	saveLayout->addWidget(_saveButton, 0, Qt::AlignRight);

	QWidget *line;

	line = new QWidget(this);
	line->setFixedHeight(1);
	line->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
	line->setStyleSheet("QWidget { background-color: #A3A4A5 ; }");
	layout->addWidget(line);

	_model = new FSBMOSF();

	connect(_model, SIGNAL(authenticationSuccess()), this, SLOT(updateUserDetails()));
	connect(_model, SIGNAL(authenticationClear()), this, SLOT(updateUserDetails()));

	_fsBrowser = new FSBrowser(this);
	_fsBrowser->setViewType(FSBrowser::ListView);
	_fsBrowser->setFSModel(_model);
	layout->addWidget(_fsBrowser);

	_breadCrumbs->setModel(_model);
	_breadCrumbs->setEnabled(false);

	connect(_fsBrowser, SIGNAL(entryOpened(QString)), this, SLOT(notifyDataSetOpened(QString)));
	connect(_fsBrowser, SIGNAL(entrySelected(QString)), this, SLOT(notifyDataSetSelected(QString)));

	connect(_saveButton, SIGNAL(clicked()), this, SLOT(saveClicked()));
	connect(_newFolderButton, SIGNAL(clicked(bool)), this, SLOT(newFolderClicked()));

	line = new QWidget(this);
	line->setFixedWidth(1);
	line->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
	line->setStyleSheet("QWidget { background-color: #A3A4A5 ; }");
	layout->addWidget(line, 0, 1, 6, 1);

	QWidget *about = new QWidget(this);
	about->setObjectName("aboutOSF");
	about->setStyleSheet("#aboutOSF { border-top: 1px solid #A3A4A5 ; }");
	layout->addWidget(about);

	QHBoxLayout *aboutLayout = new QHBoxLayout(about);
	aboutLayout->setSpacing(12);
	about->setLayout(aboutLayout);

	HyperlinkLabel *aboutOSF = new HyperlinkLabel(about);
	aboutOSF->setText("<a href='https://osf.io/getting-started/'>About the OSF</a>");

	HyperlinkLabel *registerOSF = new HyperlinkLabel(about);
	registerOSF->setText("<a href='https://osf.io/'>Register</a>");

	aboutLayout->addWidget(aboutOSF);
	aboutLayout->addWidget(registerOSF);
	aboutLayout->addStretch(1);
}
Example #7
0
QWidget *PoitemTableDelegate::createEditor(QWidget *parent,
					   const QStyleOptionViewItem &/*style*/,
					   const QModelIndex &index) const
{
  const QAbstractItemModel *model = index.model();
  QWidget *editor = 0;

  switch (index.column())
  {
    case ITEM_NUMBER_COL:
    {
      ItemLineEdit *item = new ItemLineEdit(parent);
      item->setType(ItemLineEdit::cGeneralPurchased | ItemLineEdit::cGeneralManufactured | ItemLineEdit::cActive);
      item->setDefaultType(ItemLineEdit::cGeneralPurchased | ItemLineEdit::cActive);
      if ((qobject_cast<const PoitemTableModel*>(model))->_vendrestrictpurch)
      {
	int vendid = (qobject_cast<const PoitemTableModel*>(model))->_vendid;
	// TODO: put queries in ItemLineEdit, trigger them with a setVendId()
        item->setQuery( QString("SELECT DISTINCT item_id, item_number, item_descrip1, item_descrip2,"
				"                uom_name, item_type, item_config "
				"FROM item, itemsite, itemsrc, uom  "
				"WHERE ( (itemsite_item_id=item_id)"
				" AND (itemsrc_item_id=item_id)"
                                " AND (item_inv_uom_id=uom_id)"
				" AND (itemsite_active)"
				" AND (item_active)"
				" AND (itemsrc_active)"
				" AND (itemsrc_vend_id=%1) ) "
				"ORDER BY item_number;" )
                         .arg(vendid) );
        item->setValidationQuery( QString("SELECT DISTINCT item_id, item_number, item_descrip1, item_descrip2,"
					  "                uom_name, item_type, item_config "
					  "FROM item, itemsite, itemsrc, uom  "
					  "WHERE ( (itemsite_item_id=item_id)"
					  " AND (itemsrc_item_id=item_id)"
                                          " AND (item_inv_uom_id=uom_id)"
					  " AND (itemsite_active)"
					  " AND (item_active)"
					  " AND (itemsrc_active)"
					  " AND (itemsrc_vend_id=%1) "
					  " AND (itemsite_item_id=:item_id) ) "
					  "ORDER BY item_number;" )
				   .arg(vendid) );
      }

      editor = item;
      break;
    }

    case WAREHOUS_CODE_COL:
    {
      int itemid = model->data(model->index(index.row(), ITEM_ID_COL)).toInt();
      if (itemid <= 0)	// probably non-inventory item so don't pick a whs
	break;

      WComboBox *whs = new WComboBox(parent);
      whs->setType(WComboBox::Supply);
      whs->findItemsites(itemid);
      editor = whs;
      break;
    }

    case POITEM_VEND_ITEM_NUMBER_COL:
    {
      editor = new XLineEdit(parent);
      editor->setObjectName("poitem_vend_item_number");
      break;
    }

    case POITEM_QTY_ORDERED_COL:
    {
      XLineEdit *qty = new XLineEdit(parent);
      qty->setValidator(omfgThis->qtyVal());
      editor = qty;
      break;
    }
    
    case POITEM_UNITPRICE_COL:
    case POITEM_FREIGHT_COL:
    {
      XLineEdit *price = new XLineEdit(parent);
      price->setValidator(omfgThis->priceVal());
      editor = price;
      break;
    }

    case POITEM_DUEDATE_COL:
    {
      XDateEdit *duedate = new XDateEdit(parent);
      duedate->setFocusPolicy(Qt::StrongFocus);
      editor = duedate;
      editor->setObjectName("poitem_duedate");
      break;
    }

#ifdef QE_NONINVENTORY
    case EXPCAT_CODE_COL:
    {
      ExpenseLineEdit *expcat = new ExpenseLineEdit(parent);
      editor = expcat;
      break;
    }
#endif

    default:
    {
      editor = 0;
      break;
    }
  }

  if (editor)
  {
#ifdef Q_WS_MAC
    // compensate for many custom widgets making themselves smaller on OS X
    QFont f = editor->font();
    f.setPointSize(f.pointSize() + 2);
    editor->setFont(f);
#endif
    editor->installEventFilter(const_cast<PoitemTableDelegate*>(this));
    if (DEBUG)
      qDebug("createEditor: editor has focus policy %d", editor->focusPolicy());
  }
  return editor;
}
Example #8
0
//-----------------------------------------------------------------------------
void DebugScriptWindow::setupUI()
{
  // Testing setting up the UI programatically, as opposed to using QTCreator
  // and its generated XML.

  QWidget* dockWidgetContents = new QWidget();
  dockWidgetContents->setObjectName(QString::fromUtf8("DebugWindowContents"));
  this->setWidget(dockWidgetContents);

  mMainLayout = new QVBoxLayout(dockWidgetContents);
  mMainLayout->setSpacing(6);
  mMainLayout->setContentsMargins(9, 9, 9, 9);
  mMainLayout->setObjectName(QString::fromUtf8("verticalLayout"));

  // Script debug implementation.
  {
    QWidget* scriptTabContents = new QWidget();
    mMainLayout->addWidget(scriptTabContents);

    QHBoxLayout* scriptLayout = new QHBoxLayout(scriptTabContents);
    scriptTabContents->setLayout(scriptLayout);

    // Output / one line interaction
    {
      QWidget* outputContents = new QWidget();
      scriptLayout->addWidget(outputContents);

      QVBoxLayout* outputLayout = new QVBoxLayout();
      outputContents->setLayout(outputLayout);

      mListWidget = new QListWidget();
      outputLayout->addWidget(mListWidget);

      // Lower line edit and label.
      {
        QWidget* cont = new QWidget();
        cont->setMinimumHeight(0);
        outputLayout->addWidget(cont);

        QHBoxLayout* hboxLayout = new QHBoxLayout();
        cont->setLayout(hboxLayout);

        QLabel* lbl = new QLabel();
        lbl->setText(QString::fromUtf8("Command: "));
        lbl->setMinimumSize(QSize(0, 0));
        hboxLayout->addWidget(lbl);

        mScriptOneLineEdit = new QLineEdit();
        hboxLayout->addWidget(mScriptOneLineEdit);
        QObject::connect(mScriptOneLineEdit, SIGNAL(returnPressed()), this,
                         SLOT(oneLineEditOnReturnPressed()));
        QObject::connect(mScriptOneLineEdit, SIGNAL(textEdited(const QString&)),
                         this, SLOT(oneLineEditOnEdited(const QString&)));
      }
    }

    // Script interaction.
    {
      QWidget* editContents = new QWidget();
      scriptLayout->addWidget(editContents);

      QVBoxLayout* editLayout = new QVBoxLayout();
      editContents->setLayout(editLayout);

      mScriptTextEdit = new QTextEdit();
      QFont font("Monospace");
      font.setStyleHint(QFont::TypeWriter);
      mScriptTextEdit->setCurrentFont(font);
      editLayout->addWidget(mScriptTextEdit);

      // Combo box combined with execute button.
      {
        QWidget* comboExecContents = new QWidget();
        comboExecContents->setMinimumHeight(0);
        editLayout->addWidget(comboExecContents);

        QHBoxLayout* comboExecLayout = new QHBoxLayout();
        comboExecContents->setLayout(comboExecLayout);

        QLabel* lbl = new QLabel();
        lbl->setText(QString::fromUtf8("Examples: "));
        comboExecLayout->addWidget(lbl);

        mScriptExamplesBox = new QComboBox();
        comboExecLayout->addWidget(mScriptExamplesBox);
        QString emptyExample = QString::fromUtf8(" ");

        mScriptExamplesBox->addItem(QString::fromUtf8(" "),
                                    QVariant(emptyExample));

        QString regressionTesting = QString::fromUtf8(
            "-- Please modify the variables below to point to valid paths.\n"
            "local homeDir = os.getenv('HOME')\n"
            "regress_scriptDir = homeDir .. '/sci/imagevis3d/Tuvok/LuaScripting"
            "/Regression/iv3d'\n"
            "regress_c60Dir = homeDir .. '/sci/datasets/c60.uvf'\n"
            "regress_outputDir = homeDir .. '/sci/datasets/output'\n"
            "luaVerboseMode(true)\n\n"
            "-- Todo: Switch to LuaFileSystem -- cross platform\n"
            "for fname in dir(regress_scriptDir) do\n"
            "  if fname ~= '.' and fname ~= '..' then\n"
            "    -- Ignore vim swap files\n"
            "    ext = fname:match('.(%a*)$'):lower()\n"
            "    if ext ~= 'swp' then\n"
            "      print('Running \\'' .. fname .. '\\'')\n"
            "      dofile(regress_scriptDir .. '/' .. fname)\n"
            "    end\n"
            "  end\n"
            "end\n\n"
            "luaVerboseMode(false)\n");
        mScriptExamplesBox->addItem(QString::fromUtf8("Regression Testing"),
                                    QVariant(regressionTesting));

        QString autoScreenCap = QString::fromUtf8(
            "-- This script will only run on a Posix compliant OS.\n"
            "-- Opens the dataset given by 'filename' and begins taking screen captures.\n"
            "-- You can manually transform the dataset while the script is running.\n"
            "-- Expect horrible things to happen if you close the render window while\n"
            "-- the script is running.\n"
            "local homeDir = os.getenv('HOME')\n"
            "local filename = homeDir .. '/sci/datasets/c60.uvf'\n"
            "local outputDir = homeDir .. '/sci/datasets/output/images'\n"
            "local numScreenCaps = 128\n\n"
            "print('Animate and capture script')\n"
            "print('Results will be output to: ' .. outputDir)\n"
            "os.execute('mkdir -p ' .. outputDir)\n\n"
            "-- data = Render window to animate.\n"
            "-- numFrames = Number of frames to capture during the animation.\n"
            "function doAnim (data, numFrames)\n"
            "  local datasetPath = data.getDataset().fullpath()\n"
            "  local baseName = os.capture('basename ' .. datasetPath .. ' .uvf', false)\n"
            "  print('Using basename: ' .. baseName)\n"
            "  t = 0.0\n"
            "  dt = 2.0 * math.pi / numFrames\n"
            "  for i=1,numFrames do\n"
            "    t = t + dt\n"
            "    print('Capturing screen ' .. i)\n"
            "    data.screenCapture(outputDir .. '/' .. baseName .. '_' .. i .. '.png', false)\n"
            "    -- Dirty hack to get the UI to update.\n"
            "    iv3d.processUI()\n"
            "  end\n"
            "end\n\n"
            "print('Loading data')\n"
            "data = iv3d.renderer.new(filename)\n"
            "print('Performing screen captures')\n"
            "data.setRendererTarget(1)\n"
            "doAnim(data, numScreenCaps)\n"
            "data.setRendererTarget(0)\n");
        mScriptExamplesBox->addItem(QString::fromUtf8("Auto Screen Cap"),
                                    QVariant(autoScreenCap));


        QString exampleMath = QString::fromUtf8(
            "print('-- Binary Operators --')\n"
            "print(5 + 79)\n"
            "print('Basic binary operators: ' .. (3 * 5 - 2) / 5 + 1 )\n"
            "print('Exponentiation: ' .. 3 ^ 5)\n"
            "a = 17; b = 5;\n"
            "print('Modulo: ' .. a % b)\n"
            "print('-- Relational Operators --')\n"
            "print('Is it equal?: ' .. tostring(a%b == a-math.floor(a/b)*b))\n"
            "print('a less than b?: ' .. tostring(a < b))\n"
            "print('a greater than b?: ' .. tostring(a > b))\n");
        mScriptExamplesBox->addItem(QString::fromUtf8("Basic Math"),
                                    QVariant(exampleMath));
        QString exampleLightOnAll = QString::fromUtf8(
            "for i in ...;\n"
            "...\n"
            "...\n"
            "...\n"
            "..");
        mScriptExamplesBox->addItem(QString::fromUtf8("Turn On All Lighting"),
                                    QVariant(exampleLightOnAll));
        QString rotate360AndScreenCap = QString::fromUtf8(
            "for i in ...;\n"
            "...\n"
            "...\n"
            "...\n"
            "..");
        mScriptExamplesBox->addItem(QString::fromUtf8("Rotate 360 and Screen "
                                                      "Cap"),
                                    QVariant(rotate360AndScreenCap));
        QObject::connect(mScriptExamplesBox, SIGNAL(currentIndexChanged(int)),
                         this, SLOT(exampComboIndexChanged(int)));

        QSpacerItem* spacer = new QSpacerItem(40, 10,
                                              QSizePolicy::Expanding,
                                              QSizePolicy::Preferred);
        comboExecLayout->addSpacerItem(spacer);

        mExecButton = new QPushButton();
        mExecButton->setMinimumSize(QSize(0, 23));  // Required, if not, button
        // is shifted downwards beyond its layout control.
        mExecButton->setText(QString::fromUtf8("Execute Script"));
        comboExecLayout->addWidget(mExecButton);
        QObject::connect(mExecButton, SIGNAL(clicked()), this,
                         SLOT(execClicked()));
      }
    }
  }
  connect(mScriptTextEdit, SIGNAL(textChanged()), this, SLOT(fixFont()));
}
QWidget *DynamicConnectionPageWindow::createDynamicWidget(WidgetType widgetType, DynamicWidgetInfo *widgetInfo) const
{
    QWidget *widget = 0;
    QString value = getValue(widgetInfo->attributes.value("value"));

    switch(widgetType){
    case Label:
    {
        QLabel *label = new QLabel(value);
        label->setFrameShape(QFrame::StyledPanel);
        label->setFrameShadow(QFrame::Sunken);
        label->setTextInteractionFlags(Qt::TextSelectableByMouse|Qt::TextSelectableByKeyboard);
        widget = label;
        break;
    }
    case CheckBox:
    {
        QCheckBox *checkBox = new QCheckBox();
        checkBox->setChecked(value == "true");
        widget = checkBox;
        break;
    }
    case ComboBox:
    {
        QComboBox *comboBox = new QComboBox();
        QDomNodeList childNodes = widgetInfo->childNodes;
        for(int i=0; i<childNodes.size(); ++i){
            QDomNode e = childNodes.at(i);
            Q_ASSERT(e.nodeName() == "option");
            comboBox->addItem(e.attributes().namedItem("text").toAttr().value());
        }
        if(!value.isEmpty()){
            comboBox->setCurrentIndex(value.toInt());
        }

        widget = comboBox;
        break;
    }
    case RadioButton:
    {
        RadioButtonGroup *radioButtonGroup = new RadioButtonGroup(widgetInfo->attributes.value("caption").isEmpty() ? Qt::Horizontal : Qt::Vertical);
        QDomNodeList childNodes = widgetInfo->childNodes;
        for(int i=0; i<childNodes.size(); ++i){
            QDomNode e = childNodes.at(i);
            Q_ASSERT(e.nodeName() == "option");
            QString text = e.attributes().namedItem("text").toAttr().value();
            QRadioButton *radio = new QRadioButton(text);
            radioButtonGroup->addRadioButton(radio);
        }

        if(!value.isEmpty()){
            radioButtonGroup->checkRadio(value.toInt());
        }

        widget = radioButtonGroup;
        break;
    }
    default:
        Q_ASSERT(false);
        return 0;
        break;
    }

    QString widgetName = widgetInfo->attributes.value("name");
    widget->setObjectName(widgetName);

    return widget;
}
void model_import_dlg::create_mesh_tab(QTabWidget * parent, size_t index, render::lod lod)
{
	QWidget * tab = new QWidget(parent);
	tab->setObjectName("meshTab");

	auto & geometry = conv.get(index).geometry.at(lod);
	auto & material = conv.get(index).materials.at(lod);

	QGroupBox * geometry_box = new QGroupBox(tab);
	geometry_box->setGeometry(10, 10, 561, 115);
	geometry_box->setTitle("Geometry");

	QLabel * vertices = new QLabel(geometry_box);
	vertices->setGeometry(20, 20, 200, 20);
	vertices->setText("Vertices: " + QString::number(geometry.vertex_count));

	QLabel * faces = new QLabel(geometry_box);
	faces->setGeometry(20, 40, 200, 20);
	faces->setText("Faces: " + QString::number(geometry.index_count / 3));

	QLabel * indices = new QLabel(geometry_box);
	indices->setGeometry(20, 60, 200, 20);
	indices->setText("Indices: " + QString::number(geometry.index_count));

	QLabel * layout = new QLabel(geometry_box);
	layout->setGeometry(20, 80, 200, 20);
	layout->setText("Layout: " + QString::fromStdString(render::vertex::str(geometry.vertex_type)));

	QGroupBox * material_box = new QGroupBox(tab);
	material_box->setGeometry(10, 130, 561, 400);
	material_box->setTitle("Material");

	QGroupBox * colors_box = new QGroupBox(material_box);
	colors_box->setGeometry(15, 20, 455, 134);
	colors_box->setTitle("Colors");

	QTableWidget * colorsTable = new QTableWidget(colors_box);
	colorsTable->setGeometry(15, 25, 237, 92);
	colorsTable->setObjectName("colorsTable");
	colorsTable->setRowCount(3);
	colorsTable->setColumnCount(3);
	colorsTable->setFrameShape(QFrame::NoFrame);
	colorsTable->setShowGrid(false);
	colorsTable->setSelectionBehavior(QAbstractItemView::SelectionBehavior::SelectRows);
	colorsTable->setEditTriggers(QAbstractItemView::DoubleClicked);
	colorsTable->horizontalHeader()->setDefaultSectionSize(60);
	colorsTable->verticalHeader()->setDefaultSectionSize(23);
	colorsTable->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection);

	QStringList color_types;
	color_types.append("Ambient");
	color_types.append("Diffuse");
	color_types.append("Specular");

	QStringList color_channels;
	color_channels.append("R");
	color_channels.append("G");
	color_channels.append("B");

	colorsTable->setVerticalHeaderLabels(color_types);
	colorsTable->setHorizontalHeaderLabels(color_channels);

	colorsTable->setItem(0, 0, new QTableWidgetItem(QString::number(rgb_to_byte(material.ambient.x))));
	colorsTable->setItem(0, 1, new QTableWidgetItem(QString::number(rgb_to_byte(material.ambient.y))));
	colorsTable->setItem(0, 2, new QTableWidgetItem(QString::number(rgb_to_byte(material.ambient.z))));
	colorsTable->setItem(1, 0, new QTableWidgetItem(QString::number(rgb_to_byte(material.diffuse.x))));
	colorsTable->setItem(1, 1, new QTableWidgetItem(QString::number(rgb_to_byte(material.diffuse.y))));
	colorsTable->setItem(1, 2, new QTableWidgetItem(QString::number(rgb_to_byte(material.diffuse.z))));
	colorsTable->setItem(2, 0, new QTableWidgetItem(QString::number(rgb_to_byte(material.specular.x))));
	colorsTable->setItem(2, 1, new QTableWidgetItem(QString::number(rgb_to_byte(material.specular.y))));
	colorsTable->setItem(2, 2, new QTableWidgetItem(QString::number(rgb_to_byte(material.specular.z))));

	QPushButton * colorPick = new QPushButton(colors_box);
	colorPick->setGeometry(290, 24, 75, 23);
	colorPick->setObjectName("colorPick");
	colorPick->setText("Pick");

	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 3; j++)
			colorsTable->item(i, j)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);

	QObject::connect(colorsTable, SIGNAL(itemSelectionChanged()), this, SLOT(on_color_table_changed()));
	QObject::connect(colorPick, SIGNAL(pressed()), this, SLOT(on_color_pick()));

	QLabel * spec_power = new QLabel(colors_box);
	spec_power->setGeometry(290, 89, 80, 23);
	spec_power->setText("Specular power: ");

	QDoubleSpinBox * spec_power_box = new QDoubleSpinBox(colors_box);
	spec_power_box->setObjectName("specularSpinBox");
	spec_power_box->setDecimals(2);
	spec_power_box->setSingleStep(0.05);
	spec_power_box->setFrame(false);
	spec_power_box->setGeometry(390, 89, 50, 23);
	spec_power_box->setValue(material.specular_power);

	QGroupBox * textures_box = new QGroupBox(material_box);
	textures_box->setGeometry(15, 159, 531, 225);
	textures_box->setTitle("Textures");

	QTableWidget * texturesTable = new QTableWidget(textures_box);
	texturesTable->setObjectName("texturesTable");
	texturesTable->setGeometry(15, 25, 500, 150);
	texturesTable->setRowCount(material.textures.size());
	texturesTable->setColumnCount(2);
	texturesTable->setFrameShape(QFrame::NoFrame);
	texturesTable->setShowGrid(false);
	texturesTable->setSelectionBehavior(QAbstractItemView::SelectionBehavior::SelectRows);
	texturesTable->setEditTriggers(QAbstractItemView::DoubleClicked);
	texturesTable->horizontalHeader()->setDefaultSectionSize(60);
	texturesTable->verticalHeader()->setDefaultSectionSize(23);
	texturesTable->verticalHeader()->setVisible(false);

	QStringList texture_headers;
	texture_headers.append("File");
	texture_headers.append("Type");
	texturesTable->setHorizontalHeaderLabels(texture_headers);

	int i = 0;
	assimp::texture_type_map texture_map;

	for (auto texture : material.textures)
	{
		texturesTable->setItem(i, 0, new QTableWidgetItem(QString::fromStdString(texture.second.texture_path.generic_string())));
		texturesTable->setItem(i, 1, new QTableWidgetItem(QString::fromStdString(texture_map.get(texture.first))));
		texturesTable->setColumnWidth(0, 350);
		texturesTable->setColumnWidth(1, 150);

		i++;
	}

	for (i = 0; i < texturesTable->rowCount(); i++)
	for (int j = 0; j < texturesTable->columnCount(); j++)
		texturesTable->item(i, j)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);

	QPushButton * add_texture = new QPushButton(textures_box);
	add_texture->setGeometry(15, 185, 75, 23);
	add_texture->setText("Add");

	QPushButton * edit_texture = new QPushButton(textures_box);
	edit_texture->setGeometry(100, 185, 75, 23);
	edit_texture->setObjectName("textureEditButton");
	edit_texture->setText("Edit");
	edit_texture->setEnabled(false);

	QPushButton * delete_texture = new QPushButton(textures_box);
	delete_texture->setGeometry(185, 185, 75, 23);
	delete_texture->setObjectName("textureDeleteButton");
	delete_texture->setText("Delete");
	delete_texture->setEnabled(false);

	QObject::connect(texturesTable, SIGNAL(itemSelectionChanged()), this, SLOT(on_texture_table_changed()));
	QObject::connect(add_texture, SIGNAL(pressed()), this, SLOT(on_texture_add()));
	QObject::connect(edit_texture, SIGNAL(pressed()), this, SLOT(on_texture_edit()));
	QObject::connect(delete_texture, SIGNAL(pressed()), this, SLOT(on_texture_delete()));

	QString title = "Mesh " + QString::number(index);
	parent->addTab(tab, title);
}
KexiCSVExportWizard::KexiCSVExportWizard(const KexiCSVExport::Options& options,
        QWidget * parent)
        : K3Wizard(parent)
        , m_options(options)
// , m_mode(mode)
// , m_itemId(itemId)
        , m_fileSavePage(0)
        , m_defaultsBtn(0)
        , m_importExportGroup(KGlobal::config()->group("ImportExport"))
        , m_rowCount(-1)
        , m_rowCountDetermined(false)
        , m_cancelled(false)
{
    if (m_options.mode == KexiCSVExport::Clipboard) {
        finishButton()->setText(i18n("Copy"));
        backButton()->hide();
    } else {
        finishButton()->setText(i18n("Export"));
    }
    helpButton()->hide();

    QString infoLblFromText;
    KexiGUIMessageHandler msgh(this);
    m_tableOrQuery = new KexiDB::TableOrQuerySchema(
        KexiMainWindowIface::global()->project()->dbConnection(), m_options.itemId);
    if (m_tableOrQuery->table()) {
        if (m_options.mode == KexiCSVExport::Clipboard) {
            setWindowTitle(i18n("Copy Data From Table to Clipboard"));
            infoLblFromText = i18n("Copying data from table:");
        } else {
            setWindowTitle(i18n("Export Data From Table to CSV File"));
            infoLblFromText = i18n("Exporting data from table:");
        }
    } else if (m_tableOrQuery->query()) {
        if (m_options.mode == KexiCSVExport::Clipboard) {
            setWindowTitle(i18n("Copy Data From Query to Clipboard"));
            infoLblFromText = i18n("Copying data from table:");
        } else {
            setWindowTitle(i18n("Export Data From Query to CSV File"));
            infoLblFromText = i18n("Exporting data from query:");
        }
    } else {
        msgh.showErrorMessage(KexiMainWindowIface::global()->project()->dbConnection(),
                              i18n("Could not open data for exporting."));
        m_cancelled = true;
        return;
    }
    // OK, source data found.

    // Setup pages

    // 1. File Save Page
    if (m_options.mode == KexiCSVExport::File) {
        m_fileSavePage = new KexiStartupFileWidget(
            KUrl("kfiledialog:///CSVImportExport"), //startDir
            KexiStartupFileWidget::Custom | KexiStartupFileWidget::SavingFileBasedDB,
            this);
        m_fileSavePage->setObjectName("m_fileSavePage");
        m_fileSavePage->setMinimumHeight(kapp->desktop()->availableGeometry().height() / 2);
        m_fileSavePage->setAdditionalFilters(csvMimeTypes().toSet());
        m_fileSavePage->setDefaultExtension("csv");
        m_fileSavePage->setLocationText(
            KexiUtils::stringToFileName(m_tableOrQuery->captionOrName()));
        connect(m_fileSavePage, SIGNAL(rejected()), this, SLOT(reject()));
        addPage(m_fileSavePage, i18n("Enter Name of File You Want to Save Data To"));
    }

    // 2. Export options
    m_exportOptionsPage = new QWidget(this);
    m_exportOptionsPage->setObjectName("m_exportOptionsPage");
    QGridLayout *exportOptionsLyr = new QGridLayout(m_exportOptionsPage);
    exportOptionsLyr->setObjectName("exportOptionsLyr");
    m_infoLblFrom = new KexiCSVInfoLabel(infoLblFromText, m_exportOptionsPage);
    KexiPart::Info *partInfo = Kexi::partManager().infoForClass(
            QString("org.kexi-project.%1").arg(m_tableOrQuery->table() ? "table" : "query"));
    if (partInfo)
        m_infoLblFrom->setIcon(partInfo->itemIcon());
    m_infoLblFrom->separator()->hide();
    exportOptionsLyr->addWidget(m_infoLblFrom, 0, 0, 0, 2);

    m_infoLblTo = new KexiCSVInfoLabel(
        (m_options.mode == KexiCSVExport::File) ? i18n("To CSV file:") : i18n("To clipboard:"),
        m_exportOptionsPage
    );
    if (m_options.mode == KexiCSVExport::Clipboard)
        m_infoLblTo->setIcon("edit-paste");
    exportOptionsLyr->addWidget(m_infoLblTo, 1, 0, 1, 3);

    m_showOptionsButton = new KPushButton(KGuiItem(i18n("Show Options >>"), "configure"),
                                          m_exportOptionsPage);
    connect(m_showOptionsButton, SIGNAL(clicked()), this, SLOT(slotShowOptionsButtonClicked()));
    exportOptionsLyr->addWidget(m_showOptionsButton, 2, 2, 0, 0);
    m_showOptionsButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

    // -<options section>
    m_exportOptionsSection = new Q3GroupBox(1, Qt::Vertical, i18n("Options"), m_exportOptionsPage);
    m_exportOptionsSection->setObjectName("m_exportOptionsSection");
    m_exportOptionsSection->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    exportOptionsLyr->addWidget(m_exportOptionsSection, 3, 3, 0, 1);
    QWidget *exportOptionsSectionWidget
    = new QWidget(m_exportOptionsSection);
    exportOptionsSectionWidget->setObjectName("exportOptionsSectionWidget");
    QGridLayout *exportOptionsSectionLyr = new QGridLayout(exportOptionsSectionWidget);
    exportOptionsLyr->setObjectName("exportOptionsLyr");

    // -delimiter
    m_delimiterWidget = new KexiCSVDelimiterWidget(false, //!lineEditOnBottom
            exportOptionsSectionWidget);
    m_delimiterWidget->setDelimiter(defaultDelimiter());
    exportOptionsSectionLyr->addWidget(m_delimiterWidget, 0, 1);
    QLabel *delimiterLabel = new QLabel(i18n("Delimiter:"), exportOptionsSectionWidget);
    delimiterLabel->setBuddy(m_delimiterWidget);
    exportOptionsSectionLyr->addWidget(delimiterLabel, 0, 0);

    // -text quote
    QWidget *textQuoteWidget = new QWidget(exportOptionsSectionWidget);
    QHBoxLayout *textQuoteLyr = new QHBoxLayout(textQuoteWidget);
    exportOptionsSectionLyr->addWidget(textQuoteWidget, 1, 1);
    m_textQuote = new KexiCSVTextQuoteComboBox(textQuoteWidget);
    m_textQuote->setTextQuote(defaultTextQuote());
    textQuoteLyr->addWidget(m_textQuote);
    textQuoteLyr->addStretch(0);
    QLabel *textQuoteLabel = new QLabel(i18n("Text quote:"), exportOptionsSectionWidget);
    textQuoteLabel->setBuddy(m_textQuote);
    exportOptionsSectionLyr->addWidget(textQuoteLabel, 1, 0);

    // - character encoding
    m_characterEncodingCombo = new KexiCharacterEncodingComboBox(exportOptionsSectionWidget);
    m_characterEncodingCombo->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    exportOptionsSectionLyr->addWidget(m_characterEncodingCombo, 2, 1);
    QLabel *characterEncodingLabel = new QLabel(i18n("Text encoding:"), exportOptionsSectionWidget);
    characterEncodingLabel->setBuddy(m_characterEncodingCombo);
    exportOptionsSectionLyr->addWidget(characterEncodingLabel, 2, 0);

    // - checkboxes
    m_addColumnNamesCheckBox = new QCheckBox(i18n("Add column names as the first row"),
            exportOptionsSectionWidget);
    m_addColumnNamesCheckBox->setChecked(true);
    exportOptionsSectionLyr->addWidget(m_addColumnNamesCheckBox, 3, 1);
//! @todo 1.1: for copying use "Always use above options for copying" string
    m_alwaysUseCheckBox = new QCheckBox(i18n("Always use above options for exporting"),
                                        m_exportOptionsPage);
    exportOptionsLyr->addWidget(m_alwaysUseCheckBox, 4, 4, 0, 1);
// exportOptionsSectionLyr->addWidget( m_alwaysUseCheckBox, 4, 1 );
    m_exportOptionsSection->hide();
    m_alwaysUseCheckBox->hide();
    // -</options section>

// exportOptionsLyr->setColumnStretch(3, 1);
    exportOptionsLyr->addItem(
        new QSpacerItem(0, 0, QSizePolicy::Preferred, QSizePolicy::MinimumExpanding), 5, 0, 1, 2);

// addPage(m_exportOptionsPage, i18n("Set Export Options"));
    addPage(m_exportOptionsPage,
            m_options.mode == KexiCSVExport::Clipboard ? i18n("Copying") : i18n("Exporting"));
    setFinishEnabled(m_exportOptionsPage, true);

    // load settings
    if (m_options.mode != KexiCSVExport::Clipboard
            && readBoolEntry("ShowOptionsInCSVExportDialog", false)) {
        show();
        slotShowOptionsButtonClicked();
    }
    if (readBoolEntry("StoreOptionsForCSVExportDialog", false)) {
        // load defaults:
        m_alwaysUseCheckBox->setChecked(true);
        QString s = readEntry("DefaultDelimiterForExportingCSVFiles", defaultDelimiter());
        if (!s.isEmpty())
            m_delimiterWidget->setDelimiter(s);
        s = readEntry("DefaultTextQuoteForExportingCSVFiles", defaultTextQuote());
        m_textQuote->setTextQuote(s); //will be invaliudated here, so not a problem
        s = readEntry("DefaultEncodingForExportingCSVFiles");
        if (!s.isEmpty())
            m_characterEncodingCombo->setSelectedEncoding(s);
        m_addColumnNamesCheckBox->setChecked(
            readBoolEntry("AddColumnNamesForExportingCSVFiles", true));
    }

    updateGeometry();

    // -keep widths equal on page #2:
    int width = qMax(m_infoLblFrom->leftLabel()->sizeHint().width(),
                     m_infoLblTo->leftLabel()->sizeHint().width());
    m_infoLblFrom->leftLabel()->setFixedWidth(width);
    m_infoLblTo->leftLabel()->setFixedWidth(width);
}
Example #12
0
void interface::CreateWidgets(){
    QString name, type, title, wight, image, id, act;

    xmlItem childItem;
    xmlItem md          = xml.find(xml_root,md_metadata);
    xmlItem ifTabs      = xml.find(xml_root,md_tabs);
    xmlItem itActions   = xml.find(xml_root,md_actions);

    currentTab = 0;
    int idTab = 0;
    int idVal = 0;
    while (!ifTabs.isNull()){
        name = xml.attr(ifTabs,mda_name);
        type = xml.attr(ifTabs,mda_type);
        title = xml.attr(ifTabs,mda_title);

        QGridLayout *l = new QGridLayout(this);
        QTabWidget *root = new QTabWidget;

        l->addWidget(root);
        connect(root,SIGNAL(currentChanged(int)),this,SLOT(on_clicked_tab(int)));
        //—оздаем вкладки разделов
        childItem = xml.find(ifTabs,md_tab);

        while (!childItem.isNull()){
            name = xml.attr(childItem,mda_name);
            type = xml.attr(childItem,mda_type);
            title = xml.attr(childItem,mda_title);
            image = xml.attr(childItem,mda_image);
            QWidget *Tab = UIload.createWidget(type,root,name);
            Tab->setObjectName(name);
            QIcon ic(":/"+image);
            root->setIconSize(QSize(50,50));
            root->addTab(Tab,ic,title);

            QHBoxLayout *vb = new QHBoxLayout(Tab);

            QStackedWidget *stWidget = new QStackedWidget();
            listWindow.insert(idTab,stWidget);
            idTab++;
            //idVal = 0;

            // —оздаем левое меню
            xmlItem childrenItem = xml.find(childItem,md_left_menu,0);
            while (!childrenItem.isNull() && childrenItem.nodeName() == md_left_menu){
                name = xml.attr(childrenItem,mda_name);
                type = xml.attr(childrenItem,mda_type);
                title = xml.attr(childrenItem,mda_title);
                wight = xml.attr(childrenItem,mda_width);

                iisTaskPanel *tskPanel = new iisTaskPanel(Tab);
                if (!wight.isEmpty())
                    tskPanel->setMinimumWidth(wight.toInt());

                vb->addWidget(tskPanel,0);
                vb->setAlignment(tskPanel,Qt::AlignLeft);
                // √руппы меню
                tskPanel->layout()->setAlignment(Qt::AlignTop);
                xmlItem xmlGr = xml.find(childrenItem,md_group);
                while (!xmlGr.isNull()){
                    name = xml.attr(xmlGr,mda_name);
                    type = xml.attr(xmlGr,mda_type);
                    title = xml.attr(xmlGr,mda_title);


                    //QGroupBox *Gr = new QGroupBox(name,prev);
                    iisTaskBox *Gr = new iisTaskBox(title);
                    tskPanel->addWidget(Gr);
                    Gr->setObjectName(name);

                    //Ёлементы меню
                    xmlItem xmlValue = xml.find(xmlGr,md_value);
                    while (!xmlValue.isNull()){
                        name    = xml.attr(xmlValue,mda_name);
                        id      = xml.attr(xmlValue,mda_id);
                        title   = xml.attr(xmlValue,mda_title);
                        act     = xml.sText(xmlValue,md_comaction);

                        iisIconLabel *val = new iisIconLabel(title);
                        val->setObjectName(name);
                        connect(val,SIGNAL(clicked()),this,SLOT(on_clicked_item()));
                        Gr->addIconLabel(val);
                        list.insert(val,idVal);

                        xmlItem iact = xml.findId(itActions,"",act);
                        xmlItem iObj, iFrm;
                        if (!iact.isNull()){
                            QString idObj = xml.sText(iact,md_objectid);
                            xmlItem tmp =  xml.firstChild(md);
                            while (!tmp.isNull()){
                                iObj = xml.findId(tmp,"",idObj);
                                tmp = xml.nextSibling(tmp);
                                if (!iObj.isNull()) break;
                            }
                        }
                        if (!iObj.isNull()){
                            QString idFrm = xml.sText(iact,md_formid);
                            iObj = xml.find(iObj,md_forms);
                            iFrm = xml.findId(iObj,"",idFrm);
                            // —оздаем форму
                            QWidget *form =eng->OpenForm(iFrm);
                            if (form){
                                stWidget->insertWidget(idVal,form);
                                idVal++;
                            }
                        }

                        xmlValue = xml.nextSibling(xmlValue);
                    }

                    xmlGr = xml.nextSibling(xmlGr);
                }
                childrenItem = xml.nextSibling(childrenItem);
            }


            // ѕрава¤ панель
            childrenItem = xml.find(childItem,md_panel);
            while (!childrenItem.isNull()){
                name = xml.attr(childrenItem,mda_name);
                type = xml.attr(childrenItem,mda_type);
                title = xml.attr(childrenItem,mda_title);
                wight = xml.attr(childrenItem,mda_width);
                if (!wight.isEmpty())
                    stWidget->setMinimumWidth(wight.toInt());
                stWidget->setObjectName(name);
                stWidget->setFrameStyle(1);
                stWidget->setFrameShadow(QFrame::Raised);
                vb->addWidget(stWidget,2);

                childrenItem = xml.nextSibling(childrenItem);
            }
            childItem = xml.nextSibling(childItem);
        }
        ifTabs = xml.nextSibling(ifTabs);
    }

}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
QWidget* PdmUiDefaultObjectEditor::createWidget(QWidget* parent)
{
    QWidget* widget = new QWidget(parent);
    widget->setObjectName("ObjectEditor");
    return widget;
}
Example #14
0
QLayout * PageRoomsList::bodyLayoutDefinition()
{
    // TODO move stylesheet stuff into css/qt.css

    QVBoxLayout * pageLayout = new QVBoxLayout();
    pageLayout->setSpacing(0);

    QGridLayout * topLayout = new QGridLayout();
    topLayout->setSpacing(0);
    pageLayout->addLayout(topLayout, 0);

    // State button

    QPushButton * btnState = new QPushButton(tr("Room state"));
    btnState->setStyleSheet("QPushButton { background-color: #F6CB1C; border-color: #F6CB1C; color: #130F2A; padding: 1px 3px 3px 3px; margin: 0px; border-bottom: none; border-radius: 0px; border-top-left-radius: 10px; } QPushButton:hover { background-color: #FFEB3C; border-color: #F6CB1C; color: #000000 } QPushButton:pressed { background-color: #FFEB3C; border-color: #F6CB1C; color: #000000; }");
    btnState->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);

    // State menu

    QMenu * stateMenu = new QMenu(btnState);
    showGamesInLobby = new QAction(QAction::tr("Show games in lobby"), stateMenu);
    showGamesInLobby->setCheckable(true);
    showGamesInLobby->setChecked(true);
    showGamesInProgress = new QAction(QAction::tr("Show games in-progress"), stateMenu);
    showGamesInProgress->setCheckable(true);
    showGamesInProgress->setChecked(true);
    showPassword = new QAction(QAction::tr("Show password protected"), stateMenu);
    showPassword->setCheckable(true);
    showPassword->setChecked(true);
    showJoinRestricted = new QAction(QAction::tr("Show join restricted"), stateMenu);
    showJoinRestricted->setCheckable(true);
    showJoinRestricted->setChecked(true);
    stateMenu->addAction(showGamesInLobby);
    stateMenu->addAction(showGamesInProgress);
    stateMenu->addAction(showPassword);
    stateMenu->addAction(showJoinRestricted);
    btnState->setMenu(stateMenu);

    // Help/prompt message at top
    QLabel * lblDesc = new QLabel(tr("Search for a room:"));
    lblDesc->setObjectName("lblDesc");
    lblDesc->setStyleSheet("#lblDesc { color: #130F2A; background: #F6CB1C; border: solid 4px #F6CB1C; padding: 5px 10px 3px 6px;}");
    lblDesc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    lblDesc->setFixedHeight(24);
    lblDesc->setMinimumWidth(0);

    // Search text box
    QWidget * searchContainer = new QWidget();
    searchContainer->setFixedHeight(24);
    searchContainer->setObjectName("searchContainer");
    searchContainer->setStyleSheet("#searchContainer { background: #F6CB1C; border-top-right-radius: 10px; padding: 3px; }");
    searchContainer->setFixedWidth(200);
    searchText = new LineEditCursor(searchContainer);
    searchText->setFixedWidth(200);
    searchText->setMaxLength(60);
    searchText->setFixedHeight(22);
    searchText->setStyleSheet("LineEditCursor { border-width: 0px; border-radius: 6px; margin-top: 3px; margin-right: 3px; padding-left: 4px; padding-bottom: 2px; background-color: rgb(23, 11, 54); } LineEditCursor:hover, LineEditCursor:focus { background-color: rgb(13, 5, 68); }");

    // Corner widget
    QLabel * corner = new QLabel();
    corner->setPixmap(QPixmap(QString::fromUtf8(":/res/inverse-corner-bl.png")));
    corner->setFixedSize(10, 10);

    const QIcon& lp = QIcon(":/res/new.png");
    //QSize sz = lp.actualSize(QSize(65535, 65535));
    BtnCreate = new QPushButton();
    BtnCreate->setText(tr("Create room"));
    BtnCreate->setIcon(lp);
    BtnCreate->setStyleSheet("padding: 4px 8px; margin-bottom: 6px;");

    BtnJoin = new QPushButton(tr("Join room"));
    BtnJoin->setStyleSheet("padding: 4px 8px; margin-bottom: 6px; margin-left: 6px;");
    BtnJoin->setEnabled(false);

    // Add widgets to top layout
    topLayout->addWidget(btnState, 1, 0);
    topLayout->addWidget(lblDesc, 1, 1);
    topLayout->addWidget(searchContainer, 1, 2);
    topLayout->addWidget(corner, 1, 3, Qt::AlignBottom);
    topLayout->addWidget(BtnCreate, 0, 5, 2, 1);
    topLayout->addWidget(BtnJoin, 0, 6, 2, 1);

    // Top layout stretch
    topLayout->setRowStretch(0, 1);
    topLayout->setRowStretch(1, 0);
    topLayout->setColumnStretch(4, 1);

    // Rooms list and chat with splitter
    m_splitter = new QSplitter();
    m_splitter->setChildrenCollapsible(false);
    pageLayout->addWidget(m_splitter, 100);

    // Room list
    QWidget * roomsListWidget = new QWidget(this);
    m_splitter->setOrientation(Qt::Vertical);
    m_splitter->addWidget(roomsListWidget);

    QVBoxLayout * roomsLayout = new QVBoxLayout(roomsListWidget);
    roomsLayout->setMargin(0);

    roomsList = new RoomTableView(this);
    roomsList->setSelectionBehavior(QAbstractItemView::SelectRows);
    roomsList->verticalHeader()->setVisible(false);
    roomsList->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
    roomsList->setAlternatingRowColors(true);
    roomsList->setShowGrid(false);
    roomsList->setSelectionMode(QAbstractItemView::SingleSelection);
    roomsList->setStyleSheet("QTableView { border-top-left-radius: 0px; }");
    roomsList->setFocusPolicy(Qt::NoFocus);
    roomsLayout->addWidget(roomsList, 200);

    // Lobby chat

    chatWidget = new HWChatWidget(this, false);
    m_splitter->addWidget(chatWidget);

    return pageLayout;
}
Example #15
0
void setup::setCurrentIndex(XTreeWidgetItem* item)
{
  QString uiName = item->data(0, Xt::RawRole).toString();
  QString label = "<span style=\" font-size:14pt; font-weight:600;\">%1</span></p></body></html>";

  if (_itemMap.contains(uiName) && _itemMap.value(uiName).index >= 0)
  {
    _stack->setCurrentIndex(_itemMap.value(uiName).index);
    _stackLit->setText(label.arg(item->text(0)));
    return;
  }
  else if (_itemMap.contains(uiName) && !item->isDisabled())
  {
    // First look for a class...
    QWidget *w = xtGetScreen(uiName, this);

    if (w)
      _itemMap[uiName].implementation = w;
    else
    {
      // No class, so look for an extension
      XSqlQuery screenq;
      screenq.prepare("SELECT * "
                      "  FROM uiform "
                      " WHERE((uiform_name=:uiform_name)"
                      "   AND (uiform_enabled))"
                      " ORDER BY uiform_order DESC"
                      " LIMIT 1;");
      screenq.bindValue(":uiform_name", uiName);
      screenq.exec();
      if (screenq.first())
      {     
        QUiLoader loader;
        QByteArray ba = screenq.value("uiform_source").toByteArray();
        QBuffer uiFile(&ba);
        if (!uiFile.open(QIODevice::ReadOnly))
          QMessageBox::critical(0, tr("Could not load UI"),
                                tr("<p>There was an error loading the UI Form "
                                   "from the database."));
        w = loader.load(&uiFile);
        w->setObjectName(uiName);
        uiFile.close();

        // Load scripts if applicable
        XSqlQuery scriptq;
        scriptq.prepare("SELECT script_source, script_order"
                        "  FROM script"
                        " WHERE((script_name=:script_name)"
                        "   AND (script_enabled))"
                        " ORDER BY script_order;");
        scriptq.bindValue(":script_name", uiName);
        scriptq.exec();

        QScriptEngine* engine = new QScriptEngine();
        if (_preferences->boolean("EnableScriptDebug"))
        {
          QScriptEngineDebugger* debugger = new QScriptEngineDebugger(this);
          debugger->attachTo(engine);
        }
        omfgThis->loadScriptGlobals(engine);
        QScriptValue mywindow = engine->newQObject(w);
        engine->globalObject().setProperty("mywindow", mywindow);

        while(scriptq.next())
        {
          QString script = scriptHandleIncludes(scriptq.value("script_source").toString());
          QScriptValue result = engine->evaluate(script, uiName);
          if (engine->hasUncaughtException())
          {
            int line = engine->uncaughtExceptionLineNumber();
            qDebug() << "uncaught exception at line" << line << ":" << result.toString();
          }
        }
        _itemMap[uiName].implementation = engine;
      }
    }

    if (w)
    {
      // Hide buttons out of context here
      QWidget* close = w->findChild<QWidget*>("_close");
      if (close)
        close->hide();
      QWidget* buttons = w->findChild<QDialogButtonBox*>();
      if (buttons)
        buttons->hide();

      //Set mode if applicable
      int mode = _itemMap.value(uiName).mode;
      if (mode && w->inherits("XDialog"))
      {
        XWidget* x = dynamic_cast<XWidget*>(w);
        ParameterList params;
        if (mode == cEdit)
          params.append("mode", "edit");
        else if (mode == cView)
          params.append("mode", "view");
        if (x)
          x->set(params);
      }

      int idx = _stack->count();
      _itemMap[uiName].index = idx;
      _stack->addWidget(w);
      _stack->setCurrentIndex(idx);

      _stackLit->setText(label.arg(item->text(0)));
      return;
    }
  }

  // Nothing here so try the next one
  XTreeWidgetItem* next = dynamic_cast<XTreeWidgetItem*>(_tree->itemBelow(item));
  if (next)
    setCurrentIndex(next);
}
Example #16
0
QWidget* WidgetStyle::createWidget(const QString& name)
{
    if(name == "CheckBox")
    {
        QCheckBox* box = new QCheckBox("CheckBox");
        box->setObjectName("CheckBox");
        return setLayoutWidget({ box }, { 100, 30 });
    }
    else if(name == "ComboBox")
    {
        QComboBox* box = new QComboBox;
        box->addItem("Item1");
        box->addItem("Item3");
        box->addItem("Item3");
        box->setObjectName("ComboBox");
        return setLayoutWidget({ box }, { 70, 30 });
    }
    else if(name == "DateEdit")
    {
        QDateEdit* date = new QDateEdit;
        date->setObjectName("DateEdit");
        return setLayoutWidget({ date }, { 110, 40 });
    }
    else if(name == "DateTimeEdit")
    {
        QDateTimeEdit* date = new QDateTimeEdit;
        date->setObjectName("DateTimeEdit");
        return setLayoutWidget({ date }, { 160, 30 });
    }
    else if(name == "Dialog")
    {
        QDialog* dialog = new QDialog;
        dialog->setObjectName("Dialog");
        return setLayoutWidget({ dialog }, { 160, 110 });
    }
    else if(name == "DockWidget") //?
    {
        QDockWidget* widget = new QDockWidget;
        widget->setObjectName("DockWidget");
        widget->resize(61, 22);
        return widget;
    }
    else if(name == "DoubleSpinBox")
    {
        QDoubleSpinBox* box = new QDoubleSpinBox;
        box->setObjectName("DoubleSpinBox");
        return setLayoutWidget({ box }, { 90, 40 });
    }
    else if(name == "Frame") //??
    {
        QFrame* frame = new QFrame;
        frame->setObjectName("Frame");
        frame->resize(150, 100);
        return frame;
    }
    else if(name == "GroupBox")
    {
        QGroupBox* box = new QGroupBox("GroupBox");
        box->setObjectName("GroupBox");
        return setLayoutWidget({ box }, { 160, 110 });
    }
    else if(name == "Label")
    {
        QLabel* label = new QLabel("Label");
        label->setObjectName("Label");
        return setLayoutWidget({ label }, { 40, 20});
    }
    else if(name == "LineEdit")
    {
        QLineEdit* line = new QLineEdit;
        line->setObjectName("LineEdit");
        return setLayoutWidget({ line }, { 30, 30 });
    }
    else if(name == "ListView") //??
    {
        QListView* view = new QListView;
        view->setObjectName("ListView");
        view->resize(71, 71);
        return view;
    }
    else if(name == "ListWidget")
    {
        QListWidget* list = new QListWidget;
        list->setObjectName("ListWidget");
        for(int i = 0; i < 20; i++)
            list->addItem(QString("Item %1").arg(i));
        return setLayoutWidget({ list }, { 80, 80 });
    }
    else if(name == "MainWindow")
    {
        QMainWindow* window = new QMainWindow;
        window->setObjectName("MainWindow");
        return setLayoutWidget({ window }, { 160, 110 });
    }
    else if(name == "Menu")
    {
        QMenu* parentMenu = new QMenu;
        parentMenu->setObjectName("Menu");
        parentMenu->addMenu("Menu1");
        QMenu* menu1 = parentMenu->addMenu("Menu2");
        menu1->addMenu("Menu1");
        menu1->addMenu("Menu2");
        parentMenu->addSeparator();
        parentMenu->addMenu("Menu3");
        return setLayoutWidget({ parentMenu }, { 160, 110 });
    }
    else if(name == "MenuBar")
    {
        QMenuBar* bar = new QMenuBar;
        bar->setObjectName("QMenuBar");
        QMenu* menu1 = bar->addMenu("MenuBar1");
        menu1->addMenu("Menu1");
        menu1->addSeparator();
        menu1->addMenu("Menu2");
        QMenu* menu2 = bar->addMenu("MenuBar2");
        menu2->addMenu("Menu1");
        menu2->addSeparator();
        menu2->addMenu("Menu2");
        QMenu* menu3 = bar->addMenu("MenuBar3");
        menu3->addMenu("Menu1");
        menu3->addSeparator();
        menu3->addMenu("Menu2");
        return setLayoutWidget({ bar }, { 280, 60 });
    }
    else if(name == "ProgressBar")
    {
        QProgressBar* bar = new QProgressBar;
        bar->setObjectName("ProgressBar");
        bar->setRange(0, 100);
        bar->setValue(0);

        QTimer* timer = new QTimer(bar);
        this->connect(timer, &QTimer::timeout, this, [bar]()
        {
            if(bar->value() == 100)
                bar->setValue(0);
            else
                bar->setValue(bar->value() + 1);
        });
        timer->start(100);
        return setLayoutWidget({ bar }, { 110, 30 });
    }
    else if(name == "PushButton")
    {
        QPushButton* button = new QPushButton("PushButton");
        button->setObjectName("PushButton");
        return setLayoutWidget({ button }, { 125, 30 });
    }
    else if(name == "RadioButton")
    {
        QRadioButton* button = new QRadioButton("RadioButton");
        button->setObjectName("RadioButton");
        return setLayoutWidget({ button }, { 125, 30 });
    }
    else if(name == "ScrollBar")
    {
        QScrollBar* barH = new QScrollBar(Qt::Horizontal);
        QScrollBar* barV = new QScrollBar(Qt::Vertical);
        barH->setObjectName("ScrollBarH");
        barV->setObjectName("ScrollBarV");
        return setLayoutWidget({ barH, barV }, { 200, 100 });
    }
    else if(name == "Slider")
    {
        QSlider* sliderH = new QSlider(Qt::Horizontal);
        QSlider* sliderV = new QSlider(Qt::Vertical);
        sliderH->setObjectName("SliderH");
        sliderV->setObjectName("SliderV");
        return setLayoutWidget({ sliderH, sliderV }, { 200, 100 });
    }
    else if(name == "SpinBox")
    {
        QSpinBox* spinBox = new QSpinBox;
        spinBox->setObjectName("SpinBox");
        return setLayoutWidget({ spinBox }, { 60, 35 });
    }
    else if(name == "Splitter")
    {
        QSplitter* splitterV = new QSplitter(Qt::Vertical);
        QSplitter* splitterH = new QSplitter(Qt::Horizontal);
        splitterV->setObjectName("SplitterV");
        splitterH->setObjectName("SplitterH");
        splitterV->addWidget(new QPushButton("PushButton1"));
        splitterV->addWidget(new QPushButton("PushButton2"));
        splitterH->addWidget(splitterV);
        splitterH->addWidget(new QPushButton("PushButton3"));
        return setLayoutWidget({ splitterH }, { 250, 110 });
    }
    else if(name == "TabWidget")
    {
        QTabWidget* tab = new QTabWidget;
        tab->addTab(new QWidget, "Widget1");
        tab->addTab(new QWidget, "Widget2");
        tab->addTab(new QWidget, "Widget3");
        tab->setObjectName("TabWidget");
        return setLayoutWidget({ tab }, { 210, 110 });
    }
    else if(name == "TableView") //?
    {
        QTableView* view = new QTableView;
        view->setObjectName("TableView");
        view->resize(200, 100);
        return view;
    }
    else if(name == "TableWidget")
    {
        const int n = 100;
        QStringList list = { "one", "two", "three" };
        QTableWidget* table = new QTableWidget(n, n);
        table->setObjectName("TableWidget");
        table->setHorizontalHeaderLabels(list);
        table->setVerticalHeaderLabels(list);
        for(int i = 0; i < n; i++)
            for(int j = 0; j < n; j++)
                table->setItem(i, j, new QTableWidgetItem(QString("%1, %2").arg(i).arg(j)));
        return setLayoutWidget({ table }, { 210, 110 });
    }
    else if(name == "TextEdit")
    {
        QTextEdit* text = new QTextEdit;
        text->setObjectName("TextEdit");
        return setLayoutWidget({ text }, { 80, 80 });
    }
    else if(name == "TimeEdit")
    {
        QTimeEdit* time = new QTimeEdit;
        time->setObjectName("TimeEdit");
        return setLayoutWidget({ time }, { 80, 80 });
    }
    else if(name == "ToolButton")
    {
        QToolButton* button = new QToolButton;
        button->setText("ToolButton");
        button->setObjectName("ToolButton");
        return setLayoutWidget({ button }, { 95, 25 });
    }
    else if(name == "ToolBox")
    {
        QToolBox* box = new QToolBox;
        box->addItem(new QWidget, "Widget1");
        box->addItem(new QWidget, "Widget2");
        box->addItem(new QWidget, "Widget3");
        box->setObjectName("ToolBox");
        return setLayoutWidget({ box }, { 110, 180 });
    }
    else if(name == "TreeView") //?
    {
        QTreeView* tree = new QTreeView;
        tree->setObjectName("TreeView");
        tree->resize(200, 100);
        return tree;
    }
    else if(name == "TreeWidget")
    {
        QTreeWidget* tree = new QTreeWidget;
        tree->setObjectName("TreeWidget");
        tree->setHeaderLabels({ "Folders", "Used Space" });
        QTreeWidgetItem* item = new QTreeWidgetItem(tree);
        item->setText(0, "Local Disk");
        for(int i = 1; i < 20; i++)
        {
            QTreeWidgetItem* dir = new QTreeWidgetItem(item);
            dir->setText(0, "Directory" + QString::number(i));
            dir->setText(1, QString::number(i) + "MB");
        }
        tree->setItemExpanded(item, true);
        return setLayoutWidget({ tree }, { 210, 110 });
    }
    else if(name == "Widget")
    {
        QWidget* widget = new QWidget;
        widget->setObjectName("Widget");
        return setLayoutWidget({ widget }, { 210, 110 });
    }
    return nullptr;
}
Example #17
0
    void setupUi(QMainWindow *Detection)
    {
        if (Detection->objectName().isEmpty())
            Detection->setObjectName(QString::fromUtf8("Detection"));
        Detection->resize(729, 480);
        actionE_xit = new QAction(Detection);
        actionE_xit->setObjectName(QString::fromUtf8("actionE_xit"));
        action_Load_Map = new QAction(Detection);
        action_Load_Map->setObjectName(QString::fromUtf8("action_Load_Map"));
        action_Connect = new QAction(Detection);
        action_Connect->setObjectName(QString::fromUtf8("action_Connect"));
        action_Disconnect = new QAction(Detection);
        action_Disconnect->setObjectName(QString::fromUtf8("action_Disconnect"));
        centralWidget = new QWidget(Detection);
        centralWidget->setObjectName(QString::fromUtf8("centralWidget"));
        gridLayoutWidget = new QWidget(centralWidget);
        gridLayoutWidget->setObjectName(QString::fromUtf8("gridLayoutWidget"));
        gridLayoutWidget->setGeometry(QRect(0, 0, 721, 421));
        gridLayout = new QGridLayout(gridLayoutWidget);
        gridLayout->setSpacing(6);
        gridLayout->setContentsMargins(11, 11, 11, 11);
        gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
        gridLayout->setSizeConstraint(QLayout::SetNoConstraint);
        gridLayout->setVerticalSpacing(5);
        gridLayout->setContentsMargins(0, 0, 0, 0);
        ugvFeedLabel = new QLabel(gridLayoutWidget);
        ugvFeedLabel->setObjectName(QString::fromUtf8("ugvFeedLabel"));
        QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
        sizePolicy.setHorizontalStretch(0);
        sizePolicy.setVerticalStretch(0);
        sizePolicy.setHeightForWidth(ugvFeedLabel->sizePolicy().hasHeightForWidth());
        ugvFeedLabel->setSizePolicy(sizePolicy);

        gridLayout->addWidget(ugvFeedLabel, 1, 2, 1, 1);

        connectionButton = new QCommandLinkButton(gridLayoutWidget);
        connectionButton->setObjectName(QString::fromUtf8("connectionButton"));

        gridLayout->addWidget(connectionButton, 0, 2, 1, 1);

        uavFeedLabel = new QLabel(gridLayoutWidget);
        uavFeedLabel->setObjectName(QString::fromUtf8("uavFeedLabel"));
        sizePolicy.setHeightForWidth(uavFeedLabel->sizePolicy().hasHeightForWidth());
        uavFeedLabel->setSizePolicy(sizePolicy);
        uavFeedLabel->setMaximumSize(QSize(16777215, 16777215));

        gridLayout->addWidget(uavFeedLabel, 1, 0, 1, 1);

        ugvMapLabel = new QLabel(gridLayoutWidget);
        ugvMapLabel->setObjectName(QString::fromUtf8("ugvMapLabel"));
        QSizePolicy sizePolicy1(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding);
        sizePolicy1.setHorizontalStretch(0);
        sizePolicy1.setVerticalStretch(0);
        sizePolicy1.setHeightForWidth(ugvMapLabel->sizePolicy().hasHeightForWidth());
        ugvMapLabel->setSizePolicy(sizePolicy1);

        gridLayout->addWidget(ugvMapLabel, 1, 3, 1, 1);

        horizontalLayout_4 = new QHBoxLayout();
        horizontalLayout_4->setSpacing(6);
        horizontalLayout_4->setObjectName(QString::fromUtf8("horizontalLayout_4"));
        label_2 = new QLabel(gridLayoutWidget);
        label_2->setObjectName(QString::fromUtf8("label_2"));

        horizontalLayout_4->addWidget(label_2);

        uavTakeoffLandButton = new QPushButton(gridLayoutWidget);
        uavTakeoffLandButton->setObjectName(QString::fromUtf8("uavTakeoffLandButton"));

        horizontalLayout_4->addWidget(uavTakeoffLandButton);


        gridLayout->addLayout(horizontalLayout_4, 2, 0, 1, 1);

        horizontalLayout_2 = new QHBoxLayout();
        horizontalLayout_2->setSpacing(6);
        horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout_2"));
        label = new QLabel(gridLayoutWidget);
        label->setObjectName(QString::fromUtf8("label"));

        horizontalLayout_2->addWidget(label);

        ugvSpeedLCD = new QLCDNumber(gridLayoutWidget);
        ugvSpeedLCD->setObjectName(QString::fromUtf8("ugvSpeedLCD"));
        ugvSpeedLCD->setFrameShape(QFrame::Box);

        horizontalLayout_2->addWidget(ugvSpeedLCD);


        gridLayout->addLayout(horizontalLayout_2, 4, 2, 1, 1);

        horizontalLayout_6 = new QHBoxLayout();
        horizontalLayout_6->setSpacing(6);
        horizontalLayout_6->setObjectName(QString::fromUtf8("horizontalLayout_6"));
        label_3 = new QLabel(gridLayoutWidget);
        label_3->setObjectName(QString::fromUtf8("label_3"));

        horizontalLayout_6->addWidget(label_3);

        ugvSpeakerButton = new QPushButton(gridLayoutWidget);
        ugvSpeakerButton->setObjectName(QString::fromUtf8("ugvSpeakerButton"));

        horizontalLayout_6->addWidget(ugvSpeakerButton);


        gridLayout->addLayout(horizontalLayout_6, 2, 2, 1, 1);

        verticalLayout = new QVBoxLayout();
        verticalLayout->setSpacing(6);
        verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
        label_4 = new QLabel(gridLayoutWidget);
        label_4->setObjectName(QString::fromUtf8("label_4"));
        label_4->setAlignment(Qt::AlignCenter);

        verticalLayout->addWidget(label_4);

        sauverStatus = new QTextBrowser(gridLayoutWidget);
        sauverStatus->setObjectName(QString::fromUtf8("sauverStatus"));
        sauverStatus->setEnabled(true);
        QSizePolicy sizePolicy2(QSizePolicy::Minimum, QSizePolicy::Minimum);
        sizePolicy2.setHorizontalStretch(0);
        sizePolicy2.setVerticalStretch(0);
        sizePolicy2.setHeightForWidth(sauverStatus->sizePolicy().hasHeightForWidth());
        sauverStatus->setSizePolicy(sizePolicy2);
        sauverStatus->setMaximumSize(QSize(777215, 215));

        verticalLayout->addWidget(sauverStatus);


        gridLayout->addLayout(verticalLayout, 4, 3, 1, 1);

        label_5 = new QLabel(gridLayoutWidget);
        label_5->setObjectName(QString::fromUtf8("label_5"));

        gridLayout->addWidget(label_5, 0, 0, 1, 1);

        Detection->setCentralWidget(centralWidget);
        menuBar = new QMenuBar(Detection);
        menuBar->setObjectName(QString::fromUtf8("menuBar"));
        menuBar->setGeometry(QRect(0, 0, 729, 23));
        menuFile = new QMenu(menuBar);
        menuFile->setObjectName(QString::fromUtf8("menuFile"));
        menu_Tools = new QMenu(menuBar);
        menu_Tools->setObjectName(QString::fromUtf8("menu_Tools"));
        menu_Help = new QMenu(menuBar);
        menu_Help->setObjectName(QString::fromUtf8("menu_Help"));
        Detection->setMenuBar(menuBar);
        mainToolBar = new QToolBar(Detection);
        mainToolBar->setObjectName(QString::fromUtf8("mainToolBar"));
        Detection->addToolBar(Qt::TopToolBarArea, mainToolBar);
        statusBar = new QStatusBar(Detection);
        statusBar->setObjectName(QString::fromUtf8("statusBar"));
        Detection->setStatusBar(statusBar);

        menuBar->addAction(menuFile->menuAction());
        menuBar->addAction(menu_Tools->menuAction());
        menuBar->addAction(menu_Help->menuAction());
        menuFile->addAction(action_Load_Map);
        menuFile->addAction(action_Disconnect);
        menuFile->addAction(actionE_xit);
        menu_Tools->addAction(action_Connect);

        retranslateUi(Detection);
        QObject::connect(actionE_xit, SIGNAL(activated()), Detection, SLOT(close()));
        QObject::connect(action_Connect, SIGNAL(activated()), connectionButton, SLOT(click()));

        QMetaObject::connectSlotsByName(Detection);
    } // setupUi
Example #18
0
QWidget *ToitemTableDelegate::createEditor(QWidget *parent,
					   const QStyleOptionViewItem &/*style*/,
					   const QModelIndex &index) const
{
  const ToitemTableModel *model = (ToitemTableModel*)(index.model());
  QWidget *editor = 0;

  switch (index.column())
  {
    case ITEM_NUMBER_COL:
    {
      ItemLineEdit *item = new ItemLineEdit(parent);
      item->setType(ItemLineEdit::cActive);
      item->addExtraClause(QString("(item_id IN ("
				    "  SELECT itemsite_item_id"
				    "  FROM itemsite"
				    "  WHERE itemsite_warehous_id=%1))")
				    .arg(model->srcWhsId()));

      editor = item;
      break;
    }

    case TOITEM_QTY_ORDERED_COL:
    {
      QLineEdit *qty = new QLineEdit(parent);
      qty->setValidator(omfgThis->qtyVal());
      editor = qty;
      break;
    }
    
    case TOITEM_FREIGHT_COL:
    {
      QLineEdit *price = new QLineEdit(parent);
      price->setValidator(omfgThis->priceVal());
      editor = price;
      break;
    }

    case TOITEM_DUEDATE_COL:
    {
      DLineEdit *duedate = new DLineEdit(parent);
      editor = duedate;
      editor->setObjectName("toitem_duedate");
      break;
    }

#ifdef QE_PROJECT
    case PRJ_NUMBER_COL:
    {
      ProjectLineEdit *prj = new ProjectLineEdit(parent);
      prj->setType(ProjectLineEdit::PurchaseOrder);
      editor = prj;
      editor->setObjectName("prj_number");
      break;
    }
#endif

    default:
    {
      editor = 0;
      break;
    }
  }

  if (editor)
  {
#ifdef Q_WS_MAC
    // compensate for many custom widgets making themselves smaller on OS X
    QFont f = editor->font();
    f.setPointSize(f.pointSize() + 2);
    editor->setFont(f);
#endif
    editor->installEventFilter(const_cast<ToitemTableDelegate*>(this));
  }
  return editor;
}
Example #19
0
//--------------------------------------------------------------------------------------------
void MReadiness::Init()
{
//===####  I: Left (Ekranoplan):  ####===

  QGraphicsScene* PSceneEkranoplan = new QGraphicsScene(this);
  PSceneEkranoplan->addPixmap(QPixmap(":/lun2.png"));
//  PSceneEkranoplan->addPixmap(QPixmap(":/Ekranoplan.png"));
  PViewEkranoplan = new QGraphicsView(PSceneEkranoplan, this);

  for(int i = 0; i < GetPMainWnd()->GetPListTestRectsReadinessChannels()->count(); i++)
  {
    ListTestRectItems << PSceneEkranoplan->addRect((*GetPMainWnd()->GetPListTestRectsReadinessChannels())[i], QPen(), QBrush());
  }

  NRPoint = 5;
  MRPoints = new qreal[NRPoint];

  qreal rPoint1 = 0.5;  qreal rPoint2 = 1.0;
  qreal dRPoint = (rPoint2-rPoint1)/(NRPoint-1);

  for(int i = 0; i < NRPoint-1; i++) { MRPoints[i] = rPoint1 + i*dRPoint; }
  MRPoints[NRPoint-1] = rPoint2;

  Alpha1 = 100;   Alpha2 = 200;   DIncrementAlpha = 5;
  DAlpha = (Alpha2-Alpha1)/(NRPoint-1);
  MAlphas = new int[NRPoint];
  MkAlphas = new int[NRPoint];


//===####  II: 1) Right (Channels):  ####===

  QSplitter* pSplitterReadiness = new QSplitter(Qt::Vertical, this);

  QList<int> list;  list << 150 << 200;    setSizes(list);   list.clear();


//===  1) ReadinessTest:

  QScrollArea* pScrollAreaTest = new QScrollArea(pSplitterReadiness);
  pScrollAreaTest->setWidgetResizable(true);

  QWidget* pScrollAreaTestContents = new QWidget(pSplitterReadiness);
  pScrollAreaTestContents->setObjectName(QStringLiteral("ScrollAreaTestContents"));

  QRect rect = FillReadinessTest(pScrollAreaTestContents);
  pScrollAreaTestContents->setMinimumSize(rect.right() + 3,rect.bottom() + 3);

  pScrollAreaTest->setWidget(pScrollAreaTestContents);


//===  2) ReadinessStart:

  QScrollArea* pScrollAreaStart = new QScrollArea(pSplitterReadiness);
  pScrollAreaStart->setGeometry(QRect(40, 70, 611, 111));
  pScrollAreaStart->setWidgetResizable(true);

  QWidget* pScrollAreaStartContents = new QWidget(pSplitterReadiness);
  rect = FillReadinessStart(pScrollAreaStartContents);

  pScrollAreaStartContents->setMinimumSize(rect.right()+3,rect.bottom()+3);
  pScrollAreaStart->setWidget(pScrollAreaStartContents);

  list << 800 << 200;   pSplitterReadiness->setSizes(list);  list.clear();
}
ItemLibraryWidget::ItemLibraryWidget(QWidget *parent) :
    QFrame(parent),
    m_itemIconSize(24, 24),
    m_resIconSize(24, 24),
    m_iconProvider(m_resIconSize),
    m_itemsView(new QQuickView()),
    m_resourcesView(new ItemLibraryTreeView(this)),
    m_filterFlag(QtBasic)
{
    ItemLibraryModel::registerQmlTypes();

    setWindowTitle(tr("Library", "Title of library view"));

    /* create Items view and its model */
    m_itemsView->setResizeMode(QQuickView::SizeRootObjectToView);
    m_itemLibraryModel = new ItemLibraryModel(this);

    QQmlContext *rootContext = m_itemsView->rootContext();
    rootContext->setContextProperty(QStringLiteral("itemLibraryModel"), m_itemLibraryModel.data());
    rootContext->setContextProperty(QStringLiteral("itemLibraryIconWidth"), m_itemIconSize.width());
    rootContext->setContextProperty(QStringLiteral("itemLibraryIconHeight"), m_itemIconSize.height());
    rootContext->setContextProperty(QStringLiteral("rootView"), this);

    m_itemsView->rootContext()->setContextProperty(QStringLiteral("highlightColor"), Utils::StyleHelper::notTooBrightHighlightColor());

    /* create Resources view and its model */
    m_resourcesFileSystemModel = new QFileSystemModel(this);
    m_resourcesFileSystemModel->setIconProvider(&m_iconProvider);
    m_resourcesView->setModel(m_resourcesFileSystemModel.data());
    m_resourcesView->setIconSize(m_resIconSize);

    /* create image provider for loading item icons */
    m_itemsView->engine()->addImageProvider(QStringLiteral("qmldesigner_itemlibrary"), new Internal::ItemLibraryImageProvider);

    /* other widgets */
    QTabBar *tabBar = new QTabBar(this);
    tabBar->addTab(tr("QML Types", "Title of library QML types view"));
    tabBar->addTab(tr("Resources", "Title of library resources view"));
    tabBar->addTab(tr("Imports", "Title of library imports view"));
    tabBar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    connect(tabBar, SIGNAL(currentChanged(int)), this, SLOT(setCurrentIndexOfStackedWidget(int)));
    connect(tabBar, SIGNAL(currentChanged(int)), this, SLOT(updateSearch()));

    m_filterLineEdit = new Utils::FancyLineEdit(this);
    m_filterLineEdit->setObjectName(QStringLiteral("itemLibrarySearchInput"));
    m_filterLineEdit->setPlaceholderText(tr("<Filter>", "Library search input hint text"));
    m_filterLineEdit->setDragEnabled(false);
    m_filterLineEdit->setMinimumWidth(75);
    m_filterLineEdit->setTextMargins(0, 0, 20, 0);
    m_filterLineEdit->setFiltering(true);
    QWidget *lineEditFrame = new QWidget(this);
    lineEditFrame->setObjectName(QStringLiteral("itemLibrarySearchInputFrame"));
    QGridLayout *lineEditLayout = new QGridLayout(lineEditFrame);
    lineEditLayout->setMargin(2);
    lineEditLayout->setSpacing(0);
    lineEditLayout->addItem(new QSpacerItem(5, 3, QSizePolicy::Fixed, QSizePolicy::Fixed), 0, 0, 1, 3);
    lineEditLayout->addItem(new QSpacerItem(5, 5, QSizePolicy::Fixed, QSizePolicy::Fixed), 1, 0);
    lineEditLayout->addWidget(m_filterLineEdit.data(), 1, 1, 1, 1);
    lineEditLayout->addItem(new QSpacerItem(5, 5, QSizePolicy::Fixed, QSizePolicy::Fixed), 1, 2);
    connect(m_filterLineEdit.data(), SIGNAL(filterChanged(QString)), this, SLOT(setSearchFilter(QString)));

    QWidget *container = createWindowContainer(m_itemsView.data());
    m_stackedWidget = new QStackedWidget(this);
    m_stackedWidget->addWidget(container);
    m_stackedWidget->addWidget(m_resourcesView.data());

    QWidget *spacer = new QWidget(this);
    spacer->setObjectName(QStringLiteral("itemLibrarySearchInputSpacer"));
    spacer->setFixedHeight(4);

    QGridLayout *layout = new QGridLayout(this);
    layout->setContentsMargins(0, 0, 0, 0);
    layout->setSpacing(0);
    layout->addWidget(tabBar, 0, 0, 1, 1);
    layout->addWidget(spacer, 1, 0);
    layout->addWidget(lineEditFrame, 2, 0, 1, 1);
    layout->addWidget(m_stackedWidget.data(), 3, 0, 1, 1);

    setResourcePath(QDir::currentPath());
    setSearchFilter(QString());

    /* style sheets */
    setStyleSheet(QString::fromUtf8(Utils::FileReader::fetchQrc(":/qmldesigner/stylesheet.css")));
    m_resourcesView->setStyleSheet(QString::fromUtf8(Utils::FileReader::fetchQrc(":/qmldesigner/scrollbar.css")));

    m_qmlSourceUpdateShortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_F5), this);
    connect(m_qmlSourceUpdateShortcut, SIGNAL(activated()), this, SLOT(reloadQmlSource()));

    // init the first load of the QML UI elements
    reloadQmlSource();
}
NotificationWidget::NotificationWidget(QList<int> idFeedList,
                                       QList<int> cntNewNewsList,
                                       QList<int> idColorList,
                                       QStringList colorList,
                                       QWidget *parentWidget,
                                       QWidget *parent)
  : QWidget(parent)
  , idFeedList_(idFeedList)
  , cntAllNews_(0)
  , cntReadNews_(0)
{
  Qt::WindowFlags flags;
#ifdef Q_OS_MAC
  flags = Qt::FramelessWindowHint | Qt::SplashScreen | Qt::X11BypassWindowManagerHint | Qt::WindowStaysOnTopHint;
#else
  flags = Qt::FramelessWindowHint | Qt::Tool | Qt::X11BypassWindowManagerHint | Qt::WindowStaysOnTopHint;
#endif
  setWindowFlags(flags);

  setAttribute(Qt::WA_TranslucentBackground);
  setFocusPolicy(Qt::NoFocus);
  setAttribute(Qt::WA_AlwaysShowToolTips);

  int numberItems;
  int widthList;
  QString fontFamily;
  int fontSize;
  QString textColor;
  QString backgroundColor;
  QString linkColor;
  bool showTitlesFeedsNotify;
  bool showIconFeedNotify;
  bool showButtonMarkAllNotify;
  bool showButtonMarkReadNotify;
  bool showButtonExBrowserNotify;
  bool showButtonDeleteNotify;

  if (idFeedList.count()) {
    screen_ = mainApp->mainWindow()->screenNotify_;
    position_ = mainApp->mainWindow()->positionNotify_;
    transparency_ = mainApp->mainWindow()->transparencyNotify_;
    timeShowNews_ = mainApp->mainWindow()->timeShowNewsNotify_;
    numberItems = mainApp->mainWindow()->countShowNewsNotify_;
    widthList = mainApp->mainWindow()->widthTitleNewsNotify_;
    fontFamily = mainApp->mainWindow()->notificationFontFamily_;
    fontSize = mainApp->mainWindow()->notificationFontSize_;
    textColor = mainApp->mainWindow()->notifierTextColor_;
    backgroundColor = mainApp->mainWindow()->notifierBackgroundColor_;
    linkColor = mainApp->mainWindow()->linkColor_;

    showTitlesFeedsNotify = mainApp->mainWindow()->showTitlesFeedsNotify_;
    showIconFeedNotify = mainApp->mainWindow()->showIconFeedNotify_;
    showButtonMarkAllNotify = mainApp->mainWindow()->showButtonMarkAllNotify_;
    showButtonMarkReadNotify = mainApp->mainWindow()->showButtonMarkReadNotify_;
    showButtonExBrowserNotify = mainApp->mainWindow()->showButtonExBrowserNotify_;
    showButtonDeleteNotify = mainApp->mainWindow()->showButtonDeleteNotify_;
  } else {
    OptionsDialog *options = qobject_cast<OptionsDialog*>(parentWidget);
    screen_ = options->screenNotify_->currentIndex()-1;
    position_ = options->positionNotify_->currentIndex();
    transparency_ = options->transparencyNotify_->value();
    timeShowNews_ = options->timeShowNewsNotify_->value();
    numberItems = options->countShowNewsNotify_->value();
    widthList = options->widthTitleNewsNotify_->value();
    fontFamily = options->fontsTree_->topLevelItem(4)->text(2).section(", ", 0, 0);
    fontSize = options->fontsTree_->topLevelItem(4)->text(2).section(", ", 1).toInt();
    textColor = options->colorsTree_->topLevelItem(21)->text(1);
    backgroundColor = options->colorsTree_->topLevelItem(22)->text(1);
    linkColor = options->colorsTree_->topLevelItem(6)->text(1);

    showTitlesFeedsNotify = options->showTitlesFeedsNotify_->isChecked();
    showIconFeedNotify = options->showIconFeedNotify_->isChecked();
    showButtonMarkAllNotify = options->showButtonMarkAllNotify_->isChecked();
    showButtonMarkReadNotify = options->showButtonMarkReadNotify_->isChecked();
    showButtonExBrowserNotify = options->showButtonExBrowserNotify_->isChecked();
    showButtonDeleteNotify = options->showButtonDeleteNotify_->isChecked();

    for (int i = 0; i < 10; i++) {
      cntNewNewsList << 9;
    }
  }

  if (screen_ == -1) {
    screen_ = QApplication::desktop()->screenNumber(mainApp->mainWindow());
  }

  int transparency = 255*(100-transparency_)/100;
  QColor color(backgroundColor);
  int redColor = color.red()-20;
  if (redColor < 0) redColor = 0;
  int greenColor = color.green()-20;
  if (greenColor < 0) greenColor = 0;
  int blueColor = color.blue()-20;
  if (blueColor < 0) blueColor = 0;

  iconTitle_ = new QLabel(this);
  iconTitle_->setPixmap(QPixmap(":/images/quiterss16"));
  textTitle_ = new QLabel(this);

  closeButton_ = new QToolButton(this);
  closeButton_->setToolTip(tr("Close"));
  closeButton_->setStyleSheet(
        "QToolButton { border: none; padding: 0px; "
        "image: url(:/images/close); }"
        "QToolButton:hover {"
        "image: url(:/images/closeHover); }");

  QHBoxLayout *titleLayout = new QHBoxLayout();
  titleLayout->setMargin(4);
  titleLayout->setSpacing(5);
  titleLayout->addWidget(iconTitle_);
  titleLayout->addWidget(textTitle_, 1);
  titleLayout->addWidget(closeButton_);

  QWidget *titlePanel_ = new QWidget(this);
  titlePanel_->setCursor(Qt::PointingHandCursor);
  titlePanel_->setObjectName("titleNotification");
  titlePanel_->setLayout(titleLayout);
  titlePanel_->installEventFilter(this);
  titlePanel_->setStyleSheet(QString("#titleNotification { background: rgba(%1, %2, %3, %4); }").
                             arg(redColor).arg(greenColor).
                             arg(blueColor).arg(transparency));

  numPage_ = new QLabel(this);

  ToolButton *markAllReadButton_ = new ToolButton(this);
  markAllReadButton_->setToolTip(tr("Mark All News Read"));
  markAllReadButton_->setIcon(QIcon(":/images/markReadAll"));
  markAllReadButton_->setAutoRaise(true);
  prevButton_ = new ToolButton(this);
  prevButton_->setIcon(QIcon(":/images/moveLeft"));
  prevButton_->setToolTip(tr("Previous Page"));
  prevButton_->setEnabled(false);
  prevButton_->setAutoRaise(true);
  nextButton_ = new ToolButton(this);
  nextButton_->setIcon(QIcon(":/images/moveRight"));
  nextButton_->setToolTip(tr("Next Page"));
  nextButton_->setAutoRaise(true);

  QHBoxLayout *bottomLayout = new QHBoxLayout();
  bottomLayout->setMargin(2);
  bottomLayout->setSpacing(1);
  bottomLayout->addSpacing(3);
  bottomLayout->addWidget(numPage_);
  bottomLayout->addStretch(1);
  if (showButtonMarkAllNotify) {
    bottomLayout->addWidget(markAllReadButton_);
    bottomLayout->addSpacing(5);
  }
  bottomLayout->addWidget(prevButton_);
  bottomLayout->addWidget(nextButton_);
  bottomLayout->addSpacing(3);

  QWidget *bottomPanel_ = new QWidget(this);
  bottomPanel_->setObjectName("bottomNotification");
  bottomPanel_->setLayout(bottomLayout);
  bottomPanel_->setStyleSheet(QString("#bottomNotification { background: rgba(%1, %2, %3, %4); }").
                              arg(redColor).arg(greenColor).
                              arg(blueColor).arg(transparency));

  stackedWidget_ = new QStackedWidget(this);

  QVBoxLayout *mainLayout = new QVBoxLayout();
  mainLayout->setMargin(1);
  mainLayout->setSpacing(0);
  mainLayout->addWidget(titlePanel_);
  mainLayout->addWidget(stackedWidget_);
  mainLayout->addWidget(bottomPanel_);

  QWidget *mainWidget = new QWidget(this);
  mainWidget->setObjectName("notificationWidget");
  mainWidget->setLayout(mainLayout);
  mainWidget->setMouseTracking(true);
  mainWidget->setStyleSheet(QString("#notificationWidget { background: rgba(%1, %2, %3, %4); }").
                            arg(color.red()).arg(color.green()).
                            arg(color.blue()).arg(transparency));

  QVBoxLayout *layout = new QVBoxLayout();
  layout->setMargin(0);
  layout->addWidget(mainWidget);

  setLayout(layout);

  foreach (int cntNews, cntNewNewsList) {
    cntAllNews_ = cntAllNews_ + cntNews;
  }
Example #22
0
/**
 * @brief MainWindow::addMedium fügt ein Medium in die Datenbank und ins UI ein
 * @param mType Typ des Mediums
 * @param mName Titel des Mediums
 * @param mID ID des Mediums, falls verfügbar (wenn leer, dann wird eine eigene erstellt)
 * @return ID des eingefügten Mediums
 */
int MainWindow::addMedium(MType mType, QString mName, QString detail, int mID){
    QString mTypeString;
    QString mEntry;
    Medium *medium;
    QString detailType;
    /// Unterscheidung zwischen Medien Typ: erstellt verschieden Klassen und füllt die Zusatzinformationen
    switch (mType){
    case book:
        mTypeString="Buch";
        medium = new Book(mName);
        ((Book*)medium)->setAuthor(detail);
        detailType="Autor: ";
        break;
    case cd:
        mTypeString="CD";
        medium = new CD(mName);
        ((CD*)medium)->setInterpret(detail);
        detailType="Interpret: ";
        break;
    case dvd:
        mTypeString="DVD";
        medium = new DVD(mName);
        ((DVD*)medium)->setDirector(detail);
        detailType="Regisseur: ";
        break;
    default:
        mTypeString="-";
        medium = new Medium(mName);
    }
    if (detail.isEmpty()){
        detail = "-";
        detailType = "";
    }
    /// Medium in Datenbank erfassen (Fehler, falls ID bereits existiert)
    if (mID == -1){
        lendlib->addMediumToList(medium);
    } else {
        if (!lendlib->addMediumToList(medium, mID)){
            otherErr = true;
            errString = "Medium konnte nicht mit vorgegebener ID eingegeben werden.";
            checkError();
        }
    }

    mEntry = QString::number(medium->getID());

    /// UI-Elemente erstellen
    QWidget *newMedium = new QWidget;
    QHBoxLayout *newMediumLayout = new QHBoxLayout(newMedium);
    QPushButton *delB = new QPushButton("Löschen");
    QLabel *type = new QLabel(mTypeString);
    QLabel *title = new QLabel(mName);
    QLabel *lendee = new QLabel("");
    QPushButton *retlendB = new QPushButton("Ausleihen");

    /// UI-Eigenschaften anpassen
    newMedium->setObjectName(mEntry);
    newMedium->setToolTip("Typ: "+mTypeString+"\nTitel: "+mName+"\n"+detailType+detail);
    delB->setObjectName("del"+mEntry);
    delB->setToolTip("Lösche Medium "+mEntry+": "+mName);
    type->setObjectName("type"+mEntry);
    title->setObjectName("title"+mEntry);
    lendee->setObjectName("lendee"+mEntry);
    retlendB->setObjectName("retlend"+mEntry);
    retlendB->setToolTip("Leihe Medium "+mEntry+" aus: "+mName);

    newMedium->layout()->setMargin(0);
    newMedium->setStyleSheet("border-bottom: 1px solid #DEE2CF");
    delB->setStyleSheet("background: #DEE2CF;");
    delB->setMinimumWidth(60);
    delB->setMaximumWidth(60);
    delB->setMinimumHeight(25);
    delB->setMaximumHeight(25);
    connect(delB, SIGNAL (released()), this, SLOT (deleteMediumButton()));
    retlendB->setStyleSheet("background: #DEE2CF;");
    retlendB->setMinimumWidth(100);
    retlendB->setMaximumWidth(100);
    retlendB->setMinimumHeight(25);
    retlendB->setMaximumHeight(25);
    connect(retlendB, SIGNAL (released()), this, SLOT (retlendMediumButton()));
    type->setMinimumWidth(60);
    type->setMaximumWidth(60);
    lendee->setMinimumWidth(100);
    lendee->setMaximumWidth(100);

    newMediumLayout->addWidget(delB);
    newMediumLayout->addWidget(type);
    newMediumLayout->addWidget(title);
    newMediumLayout->addWidget(lendee);
    newMediumLayout->addWidget(retlendB);
    qobject_cast<QVBoxLayout*>(ui->allMediaScroll->layout())->insertWidget(getInsertPosition(mName),newMedium);

    ui->allMediaScroll->layout()->removeItem(ui->mediaSpacer);
    ui->allMediaScroll->layout()->addItem(ui->mediaSpacer);
    return medium->getID();
}
Example #23
0
//--------------------------------------------------------------------------------------------
void MReadiness::Init()
{
//===####  I: Left (Ekranoplan):  ####===

  QGraphicsScene* PSceneEkranoplan = new QGraphicsScene(this);//PMainSplitter);  //    scene.addText("Hello, world!");
  PSceneEkranoplan->addPixmap(QPixmap(":/Ekranoplan.png"));
    //scene.setSceneRect(0,0, 100,100);

  QGraphicsView* PViewEkranoplan = new QGraphicsView(PSceneEkranoplan, this);
    //view.setBaseSize(200,500);
//  PMainSplitter->addWidget(PViewEkranoplan);
//++  addWidget(PViewEkranoplan);


//int ind = psplitter->indexOf(&view);
//QString s;  s.sprintf("ind = %d", ind);
//QMessageBox msgBox;  msgBox.setText(s);  msgBox.exec();

    //psplitter->handle(0)->setFixedWidth(100);
    //psplitter->handle(0)->setMaximumWidth(100);
    //psplitter->setHandleWidth(50);
    //psplitter->resize(1200,500);


//  InitReadiness(this, pSplitter);

//    scene.addEllipse(QRectF(180,360, 40,40),QPen(),QBrush(QColor(255,0,0,255)));
    int xc = 200;  int yc = 380;  int rc = 25;
    QRadialGradient radialGradTestSpot(QPointF(xc, yc), rc);
//    radialGradTestSpot.setColorAt(0, Qt::red);
    radialGradTestSpot.setColorAt(0, QColor(255, 0, 0, 155)); // 255
//    radialGrad.setColorAt(0.5, Qt::blue);
//    radialGradTestSpot.setColorAt(1, Qt::green);
    radialGradTestSpot.setColorAt(1, QColor(0, 255, 0, 155));

//radialGradTestSpot.setColorAt(0, QColor(20, 255, 180, 255)); // 255
//radialGradTestSpot.setColorAt(0.6, QColor(180, 255, 180, 155)); // 255
//radialGradTestSpot.setColorAt(1, QColor(220, 0, 0, 100)); // 255

     QGraphicsEllipseItem* PTestSpot = PSceneEkranoplan->addEllipse(QRectF(xc-rc,yc-rc, 2*rc,2*rc),QPen(Qt::NoPen),QBrush(radialGradTestSpot));



//===####  II: 1) Right (Channels):  ####===

  QSplitter* pSplitterReadiness = new QSplitter(Qt::Vertical, this);//pSplitter);
//++  addWidget(pSplitterReadiness);

  QList<int> list;  list << 150 << 200;    setSizes(list);   list.clear();


//===  1) ReadinessTest:

//    scrollArea = new QScrollArea(centralWidget);
  QScrollArea* pScrollAreaTest = new QScrollArea(pSplitterReadiness);//this);
//  pScrollAreaTest->setObjectName(QStringLiteral("ScrollAreaTest"));
//+  pScrollAreaTest->setGeometry(QRect(40, 70, 611, 111));
  pScrollAreaTest->setWidgetResizable(true);
//pScrollAreaTest->setBaseSize(30,40);
//addWidget(pScrollAreaTest);

  QWidget* pScrollAreaTestContents = new QWidget(pSplitterReadiness);//this);
  pScrollAreaTestContents->setObjectName(QStringLiteral("ScrollAreaTestContents"));
//+  pScrollAreaTestContents->setGeometry(QRect(0, 0, 609, 109));
//pScrollAreaTestContents->setBaseSize(30,40);
//  pScrollAreaTestContents->setMinimumSize(609,109);

//pScrollAreaTest->setWidget(pScrollAreaTestContents);
//pScrollAreaTestContents->setParent(pScrollAreaTest);

//  pScrollAreaTestContents->setMinimumSize(609,109);
  QRect rect = FillReadinessTest(pScrollAreaTestContents);
  pScrollAreaTestContents->setMinimumSize(rect.right()+3,rect.bottom()+3);

//pScrollAreaTest->adjustSize();
//pScrollAreaTest->setMinimumWidth(100);
//pScrollAreaTest->setMaximumWidth(200);
//pScrollAreaTestContents->setMinimumWidth(600);
//pScrollAreaTestContents->setMaximumWidth(200);
  pScrollAreaTest->setWidget(pScrollAreaTestContents);


//===  2) ReadinessStart:

  QScrollArea* pScrollAreaStart = new QScrollArea(pSplitterReadiness);//this);
//  pScrollAreaStart->setObjectName(QStringLiteral("ScrollAreaStart"));
  pScrollAreaStart->setGeometry(QRect(40, 70, 611, 111));
  pScrollAreaStart->setWidgetResizable(true);
//addWidget(pScrollAreaStart);

  QWidget* pScrollAreaStartContents = new QWidget(pSplitterReadiness);//this);
//  pScrollAreaStartContents->setObjectName(QStringLiteral("ScrollAreaStartContents"));
//  pScrollAreaStartContents->setGeometry(QRect(0, 0, 609, 109));
//  pScrollAreaStartContents->setMinimumSize(609,109);

  rect = FillReadinessStart(pScrollAreaStartContents);
  pScrollAreaStartContents->setMinimumSize(rect.right()+3,rect.bottom()+3);
  pScrollAreaStart->setWidget(pScrollAreaStartContents);

//===

//  pSplitterReadiness->addWidget(pScrollAreaTest);
//  pSplitterReadiness->addWidget(pScrollAreaStart);
//  list << 700 << 200;    pSplitterReadiness->setSizes(list);

//++  pSplitterReadiness->addWidget(pScrollAreaTest);
//++  pSplitterReadiness->addWidget(pScrollAreaStart);
  list << 800 << 200;   pSplitterReadiness->setSizes(list);  list.clear();

//pScrollAreaTest->setWidget(listview);
//pScrollAreaTest->setWidget(treeview);
//pScrollAreaTest->setWidget(textedit);
//     MTestChannel* pTestCannel = new MTestChannel;


//=================
//=================
/*
//  QSerialPort* pSerialPort = new QSerialPort(this);
  QString sp;
  foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts()) {
    sp += QObject::tr("Port: ") + info.portName() + "\n"
        + QObject::tr("Location: ") + info.systemLocation() + "\n"
        + QObject::tr("Description: ") + info.description() + "\n"
        + QObject::tr("Manufacturer: ") + info.manufacturer() + "\n"
        + QObject::tr("Vendor Identifier: ") + (info.hasVendorIdentifier() ? QString::number(info.vendorIdentifier(), 16) : QString()) + "\n"
        + QObject::tr("Product Identifier: ") + (info.hasProductIdentifier() ? QString::number(info.productIdentifier(), 16) : QString()) + "\n"
        + QObject::tr("Busy: ") + (info.isBusy() ? QObject::tr("Yes") : QObject::tr("No")) + "\n";
  }
QMessageBox msgBox;  msgBox.setText(sp);  msgBox.exec();
*/

/*++++
//=================

//  QSerialPort* pSerialPort = new QSerialPort(this);
//  QString sp;

QSlider* pSlider = new QSlider(pScrollAreaTest);
//pSlider->setObjectName(QStringLiteral("verticalSlider"));
pSlider->setOrientation(Qt::Vertical);
pSlider->setGeometry(QRect(600, 120, 16, 160));
pSlider->setMinimum(0);
pSlider->setMaximum(255);
pSlider->setSingleStep(1);
pSlider->setPageStep(25);
pSlider->setValue(0);
pSlider->setTickPosition(QSlider::TicksAbove);


QString portName("COM3");
PPort = new QSerialPort(this);
PPort->setPortName(portName);
if(PPort->open(QIODevice::WriteOnly))  {
  PPort->setBaudRate(QSerialPort::Baud9600);
  PPort->setDataBits(QSerialPort::Data8);
  PPort->setParity(QSerialPort::NoParity);
  PPort->setStopBits(QSerialPort::OneStop);
  PPort->setFlowControl(QSerialPort::NoFlowControl);

  QMessageBox msgBox;  msgBox.setText("Port \""+portName+"\" is open");  msgBox.exec();
}
else {
  QMessageBox msgBox;  msgBox.setText("Port \""+portName+"\" is not open");  msgBox.exec();
}

connect(pSlider, SIGNAL(valueChanged(int)), this, SLOT(SlotArduino_ControlLED(int)));
connect(PPort, SIGNAL(error(QSerialPort::SerialPortError)), this, SLOT(SlotPortError(QSerialPort::SerialPortError)));
//=================
*/
}
Example #24
0
/*!
  Setup our basic widget layout, ready for the pages
*/
void VkOptionsDialog::setupLayout()
{
   // ------------------------------------------------------------
   // top layout
   QVBoxLayout* vLayout = new QVBoxLayout( this );
   vLayout->setObjectName( QString::fromUtf8( "vlayout" ) );
   
   // ------------------------------------------------------------
   // parent widget for the contents + pages
   QWidget* hLayoutWidget = new QWidget( this );
   hLayoutWidget->setObjectName( QString::fromUtf8( "hLayoutWidget" ) );
   vLayout->addWidget( hLayoutWidget );
   
   // ------------------------------------------------------------
   // contents + pages layout
   QHBoxLayout* hLayout = new QHBoxLayout( hLayoutWidget );
   hLayout->setObjectName( QString::fromUtf8( "hLayout" ) );
   hLayout->setContentsMargins( 0, 0, 0, 0 );
   
   // ------------------------------------------------------------
   // The contents list
   // Note: give this its maximum width once filled with items
   contentsListWidget = new QListWidget( hLayoutWidget );
   contentsListWidget->setObjectName( QString::fromUtf8( "contentsListWidget" ) );
   contentsListWidget->setEditTriggers( QAbstractItemView::NoEditTriggers );
   contentsListWidget->setSortingEnabled( false );
   QSizePolicy sizePolicyContents( QSizePolicy::Maximum, QSizePolicy::Expanding );
   contentsListWidget->setSizePolicy( sizePolicyContents );
   contentsListWidget->setSelectionMode( QAbstractItemView::SingleSelection );
   hLayout->addWidget( contentsListWidget );
   
   optionPages = new QStackedWidget( hLayoutWidget );
   optionPages->setObjectName( QString::fromUtf8( "optionPages" ) );
   optionPages->setFrameShape( QFrame::StyledPanel );
   optionPages->setFrameShadow( QFrame::Raised );
   hLayout->addWidget( optionPages );
   
   
   // ------------------------------------------------------------
   // parent widget for the buttons
   QWidget* hButtonWidget = new QWidget( this );
   hButtonWidget->setObjectName( QString::fromUtf8( "hButtonWidget" ) );
   vLayout->addWidget( hButtonWidget );
   
   // ------------------------------------------------------------
   // options button box
   QHBoxLayout* hLayoutButtons = new QHBoxLayout( hButtonWidget );
   hLayoutButtons->setObjectName( QString::fromUtf8( "hLayoutButtons" ) );
   hLayoutButtons->setMargin(0);
   
   updateDefaultsButton = new QPushButton( QPixmap( ":/vk_icons/icons/filesave.png" ),
                                     "Save As Project Default" );
   hLayoutButtons->addWidget( updateDefaultsButton );
   hLayoutButtons->addStretch( 1 );
   
   optionsButtonBox = new QDialogButtonBox( hButtonWidget );
   optionsButtonBox->setObjectName( QString::fromUtf8( "optionsButtonBox" ) );
   optionsButtonBox->setOrientation( Qt::Horizontal );
   optionsButtonBox->setStandardButtons( QDialogButtonBox::Apply |
                                         QDialogButtonBox::Cancel |
                                         QDialogButtonBox::Ok );
   hLayoutButtons->addWidget( optionsButtonBox );
   
   // ------------------------------------------------------------
   // signals / slots
   connect( contentsListWidget, SIGNAL( itemSelectionChanged() ),
            this,                 SLOT( showPage() ) );

   QPushButton* applyButton  = optionsButtonBox->button( QDialogButtonBox::Apply );
   QPushButton* cancelButton = optionsButtonBox->button( QDialogButtonBox::Cancel );
   QPushButton* okButton     = optionsButtonBox->button( QDialogButtonBox::Ok );
   connect( applyButton,      SIGNAL( released() ), this, SLOT( apply()  ) ); // Apply
   connect( optionsButtonBox, SIGNAL( rejected() ), this, SLOT( reject() ) ); // Cancel
   connect( optionsButtonBox, SIGNAL( accepted() ), this, SLOT( accept() ) ); // Ok
   connect( updateDefaultsButton, SIGNAL( released() ), this, SLOT( overwriteDefaultConfig() ) );

   // ------------------------------------------------------------
   // setup default state
   applyButton->setEnabled( false );
   cancelButton->setEnabled( true );
   okButton->setDefault( true );
}
Example #25
0
QWidget * Q3EditorFactory::createEditor(QWidget * parent, const QVariant & v)
{
    QWidget * w = 0;
    switch(v.type()){
        case QVariant::Invalid:
            w = 0;
            break;
        case QVariant::Bool:
            w = new QComboBox(parent, "qt_editor_bool");
            ((QComboBox *) w)->insertItem(QLatin1String("False"));
            ((QComboBox *) w)->insertItem(QLatin1String("True"));
            break;
        case QVariant::UInt:
            w = new QSpinBox(0, 999999, 1, parent, "qt_editor_spinbox");
            break;
        case QVariant::Int:
            w = new QSpinBox(-999999, 999999, 1, parent, "qt_editor_int");
            break;
        case QVariant::String:
        case QVariant::Double:
            w = new QLineEdit(parent, "qt_editor_double");
            ((QLineEdit*)w)->setFrame(false);
            break;
        case QVariant::Date: {
            QDateTimeEdit *edit = new QDateTimeEdit(parent);
            edit->setDisplayFormat(QLatin1String("yyyy/MM/dd"));
            edit->setObjectName(QLatin1String("qt_editor_date"));
            w = edit; }
            break;
        case QVariant::Time: {
            QDateTimeEdit *edit = new QDateTimeEdit(parent);
            edit->setDisplayFormat(QLatin1String("hh:mm"));
            edit->setObjectName(QLatin1String("qt_editor_time"));
            w = edit; }
            break;
        case QVariant::DateTime:
            w = new QDateTimeEdit(parent);
            w->setObjectName(QLatin1String("qt_editor_datetime"));
            break;
#ifndef QT_NO_LABEL
        case QVariant::Pixmap:
            w = new QLabel(parent, QLatin1String("qt_editor_pixmap"));
            break;
#endif
        case QVariant::Palette:
        case QVariant::Color:
        case QVariant::Font:
        case QVariant::Brush:
        case QVariant::Bitmap:
        case QVariant::Cursor:
        case QVariant::Map:
        case QVariant::StringList:
        case QVariant::Rect:
        case QVariant::Size:
        case QVariant::IconSet:
        case QVariant::Point:
        case QVariant::PointArray:
        case QVariant::Region:
        case QVariant::SizePolicy:
        case QVariant::ByteArray:
        default:
            w = new QWidget(parent, "qt_editor_default");
            break;
    }
    return w;
}
Example #26
0
void NoteItem::initControls()
{
    QString rowId, title = tr("Untitled"), tag = tr("Untagged"), created;
    if(m_noteId > 0) {
        m_q->Sql(QString("select rowid,title,content,tag,create_time,gid,status from notes where rowid=%1").arg(m_noteId).toUtf8());
        m_q->FetchRow();
        rowId = QString::fromUtf8((char*)m_q->GetColumnCString(0));
        title = QString::fromUtf8((char*)m_q->GetColumnCString(1));
        m_content = QString::fromUtf8((char*)m_q->GetColumnCString(2));
        tag = QString::fromUtf8((char*)m_q->GetColumnCString(3));
        created = QString::fromUtf8((char*)m_q->GetColumnCString(4));
        m_gid = m_q->GetColumnInt(5);
        m_status = m_q->GetColumnInt(6);
        m_rich = Qt::mightBeRichText(m_content);
        m_totalLine = m_content.count('\n');;
    }

    if(m_readOnly) {
        m_title = new QLabel(this);
        m_title->setObjectName(QString::fromUtf8("title"));
        m_title->setWordWrap(true);
        m_title->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
        m_title->setText("<h2>"+Qt::escape(title)+"</h2><table width='100%'><tr><td align='left' width='40%'>"+tag+"</td><td align='center' width='20%'>"+rowId+"</td><td align='right' width='40%'>"+created+"</td></tr></table>");

        m_verticalLayout->addWidget(m_title);

        QWidget* contentWidget;
        if(m_rich) {
            TextBrowser* textBrowser = new TextBrowser(this);
            textBrowser->setOpenExternalLinks(true);
            textBrowser->setHtml(m_content);
            textBrowser->setStyleSheet("#contentWidget { background:url(:/html.png)}");
            if(MainWindow::s_query.length())
                textBrowser->find(MainWindow::s_query);

            contentWidget = textBrowser;
            contentWidget->setObjectName(QString::fromUtf8("contentWidget"));
            m_verticalLayout->addWidget(contentWidget);
            loadResource();
        }
        else {
            PlainTextBrowser* plainTextEdit = new PlainTextBrowser(this);
            plainTextEdit->setPlainText(m_content);
            plainTextEdit->setReadOnly(m_readOnly);
            plainTextEdit->setStyleSheet("#contentWidget { background:url(:/text.png)}");
            if(MainWindow::s_query.length())
                plainTextEdit->find(MainWindow::s_query);

            contentWidget = plainTextEdit;
            contentWidget->setObjectName(QString::fromUtf8("contentWidget"));
            m_verticalLayout->addWidget(contentWidget);
        }
        contentWidget->setFont(MainWindow::s_font);
        contentWidget->installEventFilter(this);
    }
    else {
        QFont font;
        font.setPointSize(12);
        font.setBold(true);

        m_titleEdit = new QLineEdit(this);
        m_titleEdit->setObjectName(QString::fromUtf8("titleEdit"));
        m_titleEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
        m_titleEdit->setFont(font);
        m_titleEdit->setText(title);
        m_verticalLayout->addWidget(m_titleEdit);

        if(m_rich) {
            m_webView = new QWebView(this);
            m_webView->page()->setNetworkAccessManager(&s_urlBasedRenderer);

            QFile file(":/editor.html");
            file.open(QIODevice::ReadOnly);
            QString html = file.readAll();
            html = html.replace(QRegExp("CONTENT_PLACEHOLDER"),m_content);
            m_webView->setHtml(html);
            m_webView->page()->mainFrame()->addToJavaScriptWindowObject("localFile", new LocalFileDialog(this));
            m_verticalLayout->addWidget(m_webView);
        }
        else {
            m_titleEdit->setToolTip(QApplication::translate("MainWindow", "Leave this unchanged to choose title automatically.", 0, QApplication::UnicodeUTF8));
            m_textEdit = new QPlainTextEdit(this);
            m_textEdit->setFont(MainWindow::s_font);
            m_textEdit->setPlainText(m_content);
            m_verticalLayout->addWidget(m_textEdit);
        }

        m_tagEdit = new QLineEdit(this);
        m_tagEdit->setObjectName(QString::fromUtf8("tagEdit"));
        m_tagEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
        m_tagEdit->setFont(font);
        m_tagEdit->setText(tag);
        m_verticalLayout->addWidget(m_tagEdit);

        m_tagEdit->setCompleter(&(MainWindow::s_tagCompleter));
    }
}
DiagnosticCodeSelector::DiagnosticCodeSelector(
        const QString& stylesheet,
        QSharedPointer<DiagnosticCodeSet> codeset,
        QModelIndex selected,
        QWidget* parent) :
    OpenableWidget(parent),
    m_codeset(codeset),
    m_treeview(nullptr),
    m_flatview(nullptr),
    m_lineedit(nullptr),
    m_heading_tree(nullptr),
    m_heading_search(nullptr),
    m_search_button(nullptr),
    m_tree_button(nullptr),
    m_selection_model(nullptr),
    m_flat_proxy_model(nullptr),
    m_diag_filter_model(nullptr),
    m_proxy_selection_model(nullptr),
    m_searching(false)
{
    Q_ASSERT(m_codeset);

    setStyleSheet(stylesheet);

    // ========================================================================
    // Header
    // ========================================================================

    // ------------------------------------------------------------------------
    // Main row
    // ------------------------------------------------------------------------

    Qt::Alignment button_align = Qt::AlignHCenter | Qt::AlignTop;

    // Cancel button
    QAbstractButton* cancel = new ImageButton(UiConst::CBS_CANCEL);
    connect(cancel, &QAbstractButton::clicked,
            this, &DiagnosticCodeSelector::finished);

    // Title
    LabelWordWrapWide* title_label = new LabelWordWrapWide(m_codeset->title());
    title_label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    title_label->setObjectName("title");

    m_search_button = new ImageButton(UiConst::CBS_ZOOM);  // *** ICON: remove "+" from centre of magnifying glass
    connect(m_search_button.data(), &QAbstractButton::clicked,
            this, &DiagnosticCodeSelector::goToSearch);

    m_tree_button = new ImageButton(UiConst::CBS_CHOOSE_PAGE);  // *** ICON: tree view
    connect(m_tree_button.data(), &QAbstractButton::clicked,
            this, &DiagnosticCodeSelector::goToTree);

    QHBoxLayout* header_toprowlayout = new QHBoxLayout();
    header_toprowlayout->addWidget(cancel, 0, button_align);
    header_toprowlayout->addWidget(title_label);  // default alignment fills whole cell
    header_toprowlayout->addWidget(m_search_button, 0, button_align);
    header_toprowlayout->addWidget(m_tree_button, 0, button_align);

    // ------------------------------------------------------------------------
    // Horizontal line
    // ------------------------------------------------------------------------
    HorizontalLine* horizline = new HorizontalLine(UiConst::HEADER_HLINE_WIDTH);
    horizline->setObjectName("header_horizontal_line");

    // ------------------------------------------------------------------------
    // Header assembly
    // ------------------------------------------------------------------------
    QVBoxLayout* header_mainlayout = new QVBoxLayout();
    header_mainlayout->addLayout(header_toprowlayout);
    header_mainlayout->addWidget(horizline);

    // ========================================================================
    // Selection model
    // ========================================================================

    m_selection_model = QSharedPointer<QItemSelectionModel>(
                new QItemSelectionModel(m_codeset.data()));
    connect(m_selection_model.data(), &QItemSelectionModel::selectionChanged,
            this, &DiagnosticCodeSelector::selectionChanged);
    m_selection_model->select(selected, QItemSelectionModel::ClearAndSelect);

    // ========================================================================
    // Tree view
    // ========================================================================

    m_heading_tree = new QLabel(tr("Explore as tree:"));
    m_heading_tree->setObjectName("heading");

    m_treeview = new QTreeView();
    m_treeview->setModel(m_codeset.data());
    m_treeview->setSelectionModel(m_selection_model.data());
    if (m_treeview->header()) {
        m_treeview->header()->close();
    }
    m_treeview->setWordWrap(true);
    m_treeview->setColumnHidden(DiagnosticCode::COLUMN_CODE, true);
    m_treeview->setColumnHidden(DiagnosticCode::COLUMN_DESCRIPTION, true);
    m_treeview->setColumnHidden(DiagnosticCode::COLUMN_FULLNAME, false);
    m_treeview->setSortingEnabled(false);
    m_treeview->scrollTo(selected);

    // ========================================================================
    // Search box
    // ========================================================================

    m_lineedit = new QLineEdit();
    connect(m_lineedit, &QLineEdit::textEdited,
            this, &DiagnosticCodeSelector::searchTextEdited);

    // ========================================================================
    // Proxy models: (1) flatten (2) filter
    // ========================================================================
    // http://doc.qt.io/qt-5/qsortfilterproxymodel.html#details

    m_flat_proxy_model = QSharedPointer<FlatProxyModel>(
                new FlatProxyModel());
    m_flat_proxy_model->setSourceModel(m_codeset.data());

    m_diag_filter_model = QSharedPointer<DiagnosisSortFilterModel>(
                new DiagnosisSortFilterModel());
    m_diag_filter_model->setSourceModel(m_flat_proxy_model.data());
    m_diag_filter_model->setSortCaseSensitivity(Qt::CaseInsensitive);
    m_diag_filter_model->sort(DiagnosticCode::COLUMN_CODE, Qt::AscendingOrder);
    m_diag_filter_model->setFilterCaseSensitivity(Qt::CaseInsensitive);
    m_diag_filter_model->setFilterKeyColumn(DiagnosticCode::COLUMN_DESCRIPTION);

    // ========================================================================
    // Selection model for proxy model
    // ========================================================================

    m_proxy_selection_model = QSharedPointer<QItemSelectionModel>(
                new QItemSelectionModel(m_diag_filter_model.data()));
   connect(m_proxy_selection_model.data(), &QItemSelectionModel::selectionChanged,
           this, &DiagnosticCodeSelector::proxySelectionChanged);
   QModelIndex proxy_selected = proxyFromSource(selected);
   m_proxy_selection_model->select(proxy_selected,
                                   QItemSelectionModel::ClearAndSelect);

    // ========================================================================
    // List view, for search
    // ========================================================================
    // We want to show all depths, not just the root nodes, and QListView
    // doesn't by default.
    // - You can make a QTreeView look like this:
    //   http://stackoverflow.com/questions/21564976
    //   ... but users can collapse/expand (and it collapses by itself) and
    //   is not ideal.
    // - The alternative is a proxy model that flattens properly for us (see
    //   same link). We'll do that, and use a real QListView.

    m_heading_search = new QLabel(tr("Search diagnoses:"));
    m_heading_search->setObjectName("heading");

    m_flatview = new QListView();
    m_flatview->setModel(m_diag_filter_model.data());
    m_flatview->setSelectionModel(m_proxy_selection_model.data());
    m_flatview->setWordWrap(true);
    m_flatview->scrollTo(proxy_selected);

    // ========================================================================
    // Final assembly (with "this" as main widget)
    // ========================================================================

    setSearchAppearance();

    QVBoxLayout* mainlayout = new QVBoxLayout();
    mainlayout->addLayout(header_mainlayout);
    mainlayout->addWidget(m_heading_tree);
    mainlayout->addWidget(m_treeview);
    mainlayout->addWidget(m_heading_search);
    mainlayout->addWidget(m_lineedit);
    mainlayout->addWidget(m_flatview);

    QWidget* topwidget = new QWidget();
    topwidget->setObjectName("menu_window_background");
    topwidget->setLayout(mainlayout);

    QVBoxLayout* toplayout = new QVBoxLayout();
    toplayout->setContentsMargins(UiConst::NO_MARGINS);
    toplayout->addWidget(topwidget);

    setLayout(toplayout);
}
medViewContainer::medViewContainer(medViewContainerSplitter *parent): QFrame(parent),
    d(new medViewContainerPrivate)
{
    d->parent = parent;

    d->uuid = QUuid::createUuid();
    medViewContainerManager::instance()->registerNewContainer(this);

    d->view = NULL;
    d->viewToolbar = NULL;

    d->defaultWidget = new QWidget;
    d->defaultWidget->setObjectName("defaultWidget");
    QLabel *defaultLabel = new QLabel(tr("Drag'n drop series here from the left panel or"));
    QPushButton *openButton= new QPushButton(tr("open a file from your system"));
    QVBoxLayout *defaultLayout = new QVBoxLayout(d->defaultWidget);
    defaultLayout->addWidget(defaultLabel);
    defaultLayout->addWidget(openButton);
    connect(openButton, SIGNAL(clicked()), this, SLOT(openFromSystem()));

    d->menuButton = new QPushButton(this);
    d->menuButton->setIcon(QIcon(":/pixmaps/tools.png"));
    d->menuButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    d->menuButton->setToolTip(tr("Tools"));

    d->toolBarMenu = new QMenu(this);
    connect(d->menuButton, SIGNAL(clicked()), this, SLOT(popupMenu()));


    d->openAction = new QAction(tr("Open"), d->toolBarMenu);
    d->openAction->setIcon(QIcon(":/pixmaps/open.png"));
    d->openAction->setToolTip(tr("Open a file from your system"));
    d->openAction->setIconVisibleInMenu(true);
    connect(d->openAction, SIGNAL(triggered()), this, SLOT(openFromSystem()));

    d->closeContainerButton = new QPushButton(this);
    d->closeContainerButton->setIcon(QIcon(":/pixmaps/closebutton.png"));
    d->closeContainerButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    d->closeContainerButton->setToolTip(tr("Close"));
    d->closeContainerButton->setFocusPolicy(Qt::NoFocus);

    d->vSplitAction = new QAction(tr("V split"), d->toolBarMenu);
    d->vSplitAction->setIcon(QIcon(":/pixmaps/splitbutton_vertical.png"));
    d->vSplitAction->setToolTip(tr("Split vertically"));
    d->vSplitAction->setIconVisibleInMenu(true);
    connect(d->vSplitAction, SIGNAL(triggered()), this, SIGNAL(vSplitRequest()));

    d->hSplitAction = new QAction(tr("H split"), d->toolBarMenu);
    d->hSplitAction->setIcon(QIcon(":/pixmaps/splitbutton_horizontal.png"));
    d->hSplitAction->setToolTip(tr("Split horizontally"));
    d->hSplitAction->setIconVisibleInMenu(true);
    connect(d->hSplitAction, SIGNAL(triggered()), this, SIGNAL(hSplitRequest()));

    // make it a parameter to get synch between state of the container and the maximized button.
    d->maximizedAction = new QAction(tr("Maximized"), d->toolBarMenu);
    d->maximizedAction->setToolTip("Toggle maximized / unmaximized");
    d->maximizedAction->setCheckable(true);
    QIcon maximizedIcon(":/icons/maximize.svg");
    maximizedIcon.addFile(":/icons/un_maximize.svg",
                        QSize(16,16),
                        QIcon::Normal,
                        QIcon::On);

    d->maximizedAction->setIcon(maximizedIcon);
    d->maximizedAction->setIconVisibleInMenu(true);
    d->maximized = false;
    connect(d->maximizedAction, SIGNAL(triggered()), this, SLOT(toggleMaximized()));
    d->maximizedAction->setEnabled(false);

    d->toolBarMenu = new QMenu(this);
    d->toolBarMenu->addActions(QList<QAction*>() << d->openAction);
    d->toolBarMenu->addSeparator();
    d->toolBarMenu->addActions(QList<QAction*>() << d->vSplitAction << d->hSplitAction);
    d->toolBarMenu->addSeparator();
    d->toolBarMenu->addActions(QList<QAction*>() << d->maximizedAction);

    d->poolIndicator = new medPoolIndicator;

    QWidget* toolBar = new QWidget(this);
    toolBar->setObjectName("containerToolBar");
    toolBar->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
    d->toolBarLayout = new QHBoxLayout(toolBar);
    d->toolBarLayout->setContentsMargins(0, 0, 0, 0);
    d->toolBarLayout->setSpacing(2);

    QWidget *viewToolbarContainer = new QWidget(this);
    viewToolbarContainer->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    d->viewToolbarContainerLayout = new QHBoxLayout(viewToolbarContainer);
    d->viewToolbarContainerLayout->setContentsMargins(2, 0, 2, 0);
    d->viewToolbarContainerLayout->setSpacing(2);

    QWidget *containerToolbar = new QWidget(this);
    containerToolbar->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
    QHBoxLayout *containerToolbarLayout  = new QHBoxLayout(containerToolbar);
    containerToolbarLayout->setContentsMargins(2, 0, 2, 0);
    containerToolbarLayout->setSpacing(2);
    containerToolbarLayout->addWidget(d->poolIndicator);
    containerToolbarLayout->addWidget(d->menuButton);
    containerToolbarLayout->addWidget(d->closeContainerButton);

    d->toolBarLayout->addWidget(viewToolbarContainer);
    d->toolBarLayout->addWidget(containerToolbar,0,Qt::AlignRight);

    d->mainLayout = new QGridLayout(this);
    d->mainLayout->setContentsMargins(0, 0, 0, 0);
    d->mainLayout->setSpacing(0);
    d->mainLayout->addWidget(toolBar, 0, 0, Qt::AlignTop);
    d->mainLayout->addWidget(d->defaultWidget, 0, 0, 0, 0, Qt::AlignCenter);

    this->setAcceptDrops(true);
    this->setUserSplittable(true);
    this->setClosingMode(medViewContainer::CLOSE_CONTAINER);
    this->setMultiLayered(true);
    this->setFocusPolicy(Qt::ClickFocus);
    this->setMouseTracking(true);
    this->setUserOpenable(true);

    d->selected = false;
    this->setSelected(false);

    d->defaultStyleSheet = this->styleSheet();
}
medLinkMenu::medLinkMenu(QWidget * parent) : QPushButton(parent), d(new medLinkMenuPrivate)
{
    this->setIcon(QIcon(":icons/link.svg"));

    d->popupWidget = new QWidget(this);
    d->popupWidget->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint );
    d->popupWidget->setContentsMargins(0,0,4,4);
    d->popupWidget->setObjectName("popupWidget");

    d->subPopupWidget = new QWidget(this);
    d->subPopupWidget->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint );
    d->subPopupWidget->setContentsMargins(0,0,4,4);
    d->subPopupWidget->setObjectName("subPopupWidget");

    d->popupWidget->setAttribute(Qt::WA_TranslucentBackground);
    d->subPopupWidget->setAttribute(Qt::WA_TranslucentBackground);

#ifdef Q_OS_LINUX
    QGraphicsDropShadowEffect *shadowEffect1 = new QGraphicsDropShadowEffect(this);
    shadowEffect1->setOffset(2);
    shadowEffect1->setBlurRadius(8);
    shadowEffect1->setColor(QColor(33, 33, 33, 200));

    QGraphicsDropShadowEffect *shadowEffect2 = new QGraphicsDropShadowEffect(this);
    shadowEffect2->setOffset(2);
    shadowEffect2->setBlurRadius(8);
    shadowEffect2->setColor(QColor(33, 33, 33, 200));

    d->popupWidget->setGraphicsEffect(shadowEffect1);
    d->subPopupWidget->setGraphicsEffect(shadowEffect2);
#endif

    d->groupList = new medListWidget;
    d->groupList->setMouseTracking(true);
    d->groupList->setAlternatingRowColors(true);

    d->paramList = new medListWidget;
    d->paramList->setMouseTracking(true);
    d->paramList->setAlternatingRowColors(true);

    d->newGroupitem = new QListWidgetItem("Add new Group...");
    d->groupList->addItem(d->newGroupitem);
    d->newGroupEdit = new QLineEdit("Add new Group...");
    d->groupList->setItemWidget(d->newGroupitem, d->newGroupEdit);

    d->saveAsPresetButton = new QPushButton("Save as preset");

    d->presetList = new medListWidget;
    d->presetList->setMouseTracking(true);
    d->presetList->setAlternatingRowColors(true);
    d->presetList->hide();

    QVBoxLayout *popUpLayout = new QVBoxLayout(d->popupWidget);
    popUpLayout->setContentsMargins(0,0,0,0);
    popUpLayout->addWidget(d->groupList);

    connect(this, SIGNAL(clicked()), this, SLOT(showPopup()));
    connect(d->newGroupEdit, SIGNAL(returnPressed()), this, SLOT(createNewGroup()));
    connect(d->groupList, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(selectGroup(QListWidgetItem*)));
    connect(d->paramList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(selectParam(QListWidgetItem*)));
    connect(d->groupList, SIGNAL(itemEntered(QListWidgetItem*)), this, SLOT(showSubMenu(QListWidgetItem*)));
    connect(d->paramList, SIGNAL(itemEntered(QListWidgetItem*)), this, SLOT(highlightItem(QListWidgetItem*)));
    connect(d->paramList, SIGNAL(itemPressed(QListWidgetItem*)), this, SLOT(selectItem(QListWidgetItem*)));
    connect(d->saveAsPresetButton, SIGNAL(clicked()), this, SLOT(saveAsPreset()));
    connect(d->presetList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(applyPreset(QListWidgetItem*)));
    connect(d->presetList, SIGNAL(itemEntered(QListWidgetItem*)), this, SLOT(highlightItem(QListWidgetItem*)));
    connect(d->presetList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(editPreset(QListWidgetItem*)));
    connect(d->presetList, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(selectItem(QListWidgetItem*)));


    QWidget *internalSubPopWidget = new QWidget;
    internalSubPopWidget->setObjectName("internalSubPopWidget");
    QVBoxLayout *layout = new QVBoxLayout(d->subPopupWidget);
    layout->setContentsMargins(0,0,0,0);
    layout->setSpacing(0);
    layout->addWidget(internalSubPopWidget);

    QVBoxLayout *subPopUpLayout = new QVBoxLayout(internalSubPopWidget);
    subPopUpLayout->setContentsMargins(3,3,3,3);
    subPopUpLayout->setSpacing(3);
    subPopUpLayout->addWidget(d->paramList);
    subPopUpLayout->addWidget(d->saveAsPresetButton);
    subPopUpLayout->addWidget(d->presetList);

    d->groupList->installEventFilter(this);
    d->paramList->installEventFilter(this);
    d->newGroupEdit->installEventFilter(this);
    d->saveAsPresetButton->installEventFilter(this);
    d->presetList->installEventFilter(this);
    if(qApp->activeWindow())
      qApp->activeWindow()->installEventFilter(this);
}
//virtual
void MTAccountDetails::refresh(QString strID, QString strName)
{
//  qDebug() << "MTAccountDetails::refresh";

    if (!strID.isEmpty() && (NULL != ui))
    {
        m_qstrID = strID;
        // -------------------------------------
        QString qstrAmount = MTHome::shortAcctBalance(strID);

        QWidget * pHeaderWidget  = MTEditDetails::CreateDetailHeaderWidget(m_Type, strID, strName, qstrAmount, "", ":/icons/icons/vault.png", false);

        pHeaderWidget->setObjectName(QString("DetailHeader")); // So the stylesheet doesn't get applied to all its sub-widgets.

        if (m_pHeaderWidget)
        {
            ui->verticalLayout->removeWidget(m_pHeaderWidget);

            m_pHeaderWidget->setParent(NULL);
            m_pHeaderWidget->disconnect();
            m_pHeaderWidget->deleteLater();

            m_pHeaderWidget = NULL;
        }
        ui->verticalLayout->insertWidget(0, pHeaderWidget);
        m_pHeaderWidget = pHeaderWidget;
        // ----------------------------------
//      ui->lineEditID  ->setText(strID);
        ui->lineEditName->setText(strName);
        // ----------------------------------
        std::string str_server_id = OTAPI_Wrap::It()->GetAccountWallet_ServerID   (strID.toStdString());
        std::string str_asset_id  = OTAPI_Wrap::It()->GetAccountWallet_AssetTypeID(strID.toStdString());
        std::string str_nym_id    = OTAPI_Wrap::It()->GetAccountWallet_NymID      (strID.toStdString());
        // ----------------------------------
        QString qstr_server_id    = QString::fromStdString(str_server_id);
        QString qstr_asset_id     = QString::fromStdString(str_asset_id);
        QString qstr_nym_id       = QString::fromStdString(str_nym_id);
        // ----------------------------------
        QString qstr_server_name  = QString::fromStdString(OTAPI_Wrap::It()->GetServer_Name   (str_server_id));
        QString qstr_asset_name   = QString::fromStdString(OTAPI_Wrap::It()->GetAssetType_Name(str_asset_id));
        QString qstr_nym_name     = QString::fromStdString(OTAPI_Wrap::It()->GetNym_Name      (str_nym_id));
        // ----------------------------------
        // MAIN TAB
        //
        if (!strID.isEmpty())
        {
            ui->lineEditServer->setText(qstr_server_name);
            ui->lineEditAsset ->setText(qstr_asset_name);
            ui->lineEditNym   ->setText(qstr_nym_name);
        }
        // -----------------------------------
        // TAB: "CASH PURSE"
        //
        if (m_pCashPurse)
            m_pCashPurse->refresh(strID, strName);
        // -----------------------------------------------------------------------
        FavorLeftSideForIDs();
        // -----------------------------------------------------------------------
        QString qstr_default_acct_id = Moneychanger::It()->get_default_account_id();

        if (strID == qstr_default_acct_id)
            ui->pushButtonMakeDefault->setEnabled(false);
        else
            ui->pushButtonMakeDefault->setEnabled(true);
    }
}