/**************************************************************************** ** ** Copyright (C) 2015 ** ** This file is generated by the Magus toolkit ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ****************************************************************************/ // Include #include <QHBoxLayout> #include <QVBoxLayout> #include <QMessageBox> #include <QDir> #include <QImageReader> #include "tool_simple_texturewidget.h" namespace Magus { //****************************************************************************/ QtSimpleTextureWidget::QtSimpleTextureWidget(QWidget* parent) : QWidget(parent) { setWindowTitle(QString("Texture selection")); mNameTexture = QString(""); mBaseNameTexture = QString(""); mTextureSize = QSize(128, 128); mOriginIsFile = true; QHBoxLayout* mainLayout = new QHBoxLayout; QVBoxLayout* textureSelectionLayout = new QVBoxLayout; // Define selection widget (QListView) mSelectionList = new QListView(this); mSelectionList->setViewMode(QListView::IconMode); mSelectionList->setIconSize(mTextureSize); mSelectionList->setSpacing(0); mSelectionList->setMovement(QListView::Snap); mSelectionList->setFlow(QListView::LeftToRight); mSelectionList->setWrapping(true); mSelectionList->setDragEnabled(true); mSelectionList->setAcceptDrops(false); mSelectionList->setDropIndicatorShown(false); mSelectionList->setMouseTracking(true); mSelectionModel = new QtSimpleTextureModel(); mSelectionList->setModel(mSelectionModel); connect(mSelectionList, SIGNAL(clicked(QModelIndex)), this, SLOT(handleSelected(QModelIndex))); connect(mSelectionList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(handleDoubleClicked(QModelIndex))); connect(mSelectionList, SIGNAL(entered(QModelIndex)), this, SLOT(mouseOver(QModelIndex))); // Layout textureSelectionLayout->addWidget(mSelectionList); mainLayout->addLayout(textureSelectionLayout); setLayout(mainLayout); }
DataBaseTab::DataBaseTab(QWidget * parent) : QTableView(parent) { DatabaseModel *model = new DatabaseModel(this); this->setModel(model); this->verticalHeader()->hide(); this->setSelectionBehavior(QAbstractItemView::SelectRows); connect(this, SIGNAL(doubleClicked(QModelIndex)), SLOT(handleDoubleClicked(QModelIndex))); }
/**************************************************************************** ** ** Copyright (C) 2015 ** ** This file is generated by the Magus toolkit ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ****************************************************************************/ // Include #include <QHBoxLayout> #include <QVBoxLayout> #include <QMessageBox> #include <QDir> #include <QImageReader> #include <QListWidgetItem> #include <QProcess> #include "magus_core.h" #include "tool_extended_texturewidget.h" namespace Magus { //****************************************************************************/ QtTextureAndText::QtTextureAndText(const QPixmap& pixmap, const QString& name, const QString& baseName, const QSize& size, QWidget* parent) : QWidget(parent) { setContentsMargins(-8, -8, -8, -8); QHBoxLayout* mainLayout = new QHBoxLayout; QVBoxLayout* sphereAndNameLayout = new QVBoxLayout; mName = name; mBaseName = baseName; mSphereWidget = new QtGLSphereWidget(this); mSphereWidget->setPixmap(pixmap, name, baseName); mBaseNameEdit = new QLineEdit; mBaseNameEdit->setText(mBaseName); mBaseNameEdit->setEnabled(false); connect(mSphereWidget, SIGNAL(selected(QString,QString)), this, SLOT(handleSelected(QString,QString))); connect(mSphereWidget, SIGNAL(doubleClicked(QString,QString)), this, SLOT(handleDoubleClicked(QString,QString))); setMouseTracking(true); // Layout sphereAndNameLayout->addWidget(mSphereWidget, 1000); sphereAndNameLayout->addWidget(mBaseNameEdit, 1); mainLayout->addLayout(sphereAndNameLayout); setLayout(mainLayout); setMinimumSize(size); setMaximumSize(size); } //****************************************************************************/ QtTextureAndText::~QtTextureAndText(void) { } //****************************************************************************/ void QtTextureAndText::handleSelected(const QString& name, const QString& baseName) { emit selected(name, baseName); } //****************************************************************************/ void QtTextureAndText::handleDoubleClicked(const QString& name, const QString& baseName) { emit doubleClicked(name, baseName); } //****************************************************************************/ //****************************************************************************/ //****************************************************************************/ QtExtendedTextureListWidget::QtExtendedTextureListWidget(QWidget* parent) : QListWidget(parent) { setMouseTracking(true); setAcceptDrops(true); setDropIndicatorShown(true); } //****************************************************************************/ QtExtendedTextureListWidget::~QtExtendedTextureListWidget(void) { } //****************************************************************************/ void QtExtendedTextureListWidget::keyPressEvent(QKeyEvent* event) { switch (event->key()) { case Qt::Key_Delete: { if (count() > 0) { QListWidgetItem* item = currentItem(); if (item) { QWidget* widget = itemWidget(item); if (widget) { int r = row(item); QtTextureAndText* textureAndText = static_cast<QtTextureAndText*>(widget); QString name = textureAndText->mName; QString baseName = textureAndText->mBaseName; removeItemWidget(item); takeItem(r); emit assetDeleted(name, baseName); } } } } break; } event->accept(); } //****************************************************************************/ void QtExtendedTextureListWidget::dropEvent(QDropEvent* event) { const QMimeData *mimeData = event->mimeData(); if (mimeData->hasUrls()) { QList<QUrl> urlList = mimeData->urls(); for (int i = 0; i < urlList.size(); ++i) { QString baseName = urlList.at(i).fileName(); if (isTypeBasedOnExtension(baseName, MAGUS_SUPPORTED_IMAGE_FORMATS, MAGUS_SUPPORTED_IMAGE_FORMATS_LENGTH)) { QString name = urlList.at(i).path(); stripLeadingSlashes(name); emit textureFileDropped(name, baseName); } } } event->acceptProposedAction(); } //****************************************************************************/ void QtExtendedTextureListWidget::dragEnterEvent(QDragEnterEvent *event) { event->acceptProposedAction(); } //****************************************************************************/ void QtExtendedTextureListWidget::dragMoveEvent(QDragMoveEvent *event) { event->acceptProposedAction(); } //****************************************************************************/ //****************************************************************************/ //****************************************************************************/ QtExtendedTextureWidget::QtExtendedTextureWidget(QWidget* parent) : QWidget(parent) { setWindowTitle(QString("Texture selection")); mNameTexture = QString(""); mBaseNameTexture = QString(""); mSystemCommandEditAsset = QString(""); mTextureSize = QSize(128, 128); mOriginIsFile = true; QHBoxLayout* mainLayout = new QHBoxLayout; QVBoxLayout* textureSelectionLayout = new QVBoxLayout; // Define selection widget (QListWidget) mSelectionList = new QtExtendedTextureListWidget(this); mSelectionList->setViewMode(QListView::ListMode); mSelectionList->setSpacing(0); mSelectionList->setMovement(QListView::Snap); mSelectionList->setFlow(QListView::LeftToRight); mSelectionList->setWrapping(true); mSelectionList->setWordWrap(true); connect(mSelectionList, SIGNAL(textureFileDropped(QString,QString)), this, SLOT(handleTextureFileDropped(QString,QString))); connect(mSelectionList, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(handleSelected(QListWidgetItem*))); connect(mSelectionList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(handleDoubleClicked(QListWidgetItem*))); connect(mSelectionList, SIGNAL(itemEntered(QListWidgetItem*)), this, SLOT(handleMouseOver(QListWidgetItem*))); connect(mSelectionList, SIGNAL(assetDeleted(QString,QString)), this, SLOT(handleAssetDeleted(QString,QString))); // Layout textureSelectionLayout->addWidget(mSelectionList); mainLayout->addLayout(textureSelectionLayout); setLayout(mainLayout); } //****************************************************************************/ QtExtendedTextureWidget::~QtExtendedTextureWidget(void) { } //****************************************************************************/ void QtExtendedTextureWidget::addTexture(const QPixmap& pixmap, const QString& name, const QString& baseName) { QtTextureAndText* textureAndText = new QtTextureAndText(pixmap, name, baseName, mTextureSize, this); QListWidgetItem* item = new QListWidgetItem(); item->setSizeHint(mTextureSize); // Must be present, otherwise the widget is not shown mSelectionList->addItem(item); mSelectionList->setItemWidget(item, textureAndText); // Needed to do this on a detailed (item) level when the texture itself is selected or double clicked connect(textureAndText, SIGNAL(selected(QString,QString)), this, SLOT(handleSelected(QString,QString))); connect(textureAndText, SIGNAL(doubleClicked(QString,QString)), this, SLOT(handleDoubleClicked(QString,QString))); }
UimStandaloneToolbar::UimStandaloneToolbar( QWidget *parent, const char *name ) : QHBox( parent, name, Qt::WStyle_NoBorder | Qt::WX11BypassWM ) { uim_init(); adjustSize(); UimToolbarDraggingHandler *h = new UimToolbarDraggingHandler( this ); h->adjustSize(); h->show(); QObject::connect( h, SIGNAL( handleDoubleClicked() ), this, SLOT( slotToolbarDoubleClicked() ) ); toolbar = new QUimHelperToolbar( this ); toolbar->adjustSize(); toolbar->show(); QObject::connect( toolbar, SIGNAL( toolbarResized() ), this, SLOT( slotToolbarResized() ) ); toolbar->setMargin(TOOLBAR_MARGIN_SIZE); // Move int panelHeight = 64; // FIXME! int screenwidth = QApplication::desktop() ->screenGeometry().width(); int screenheight = QApplication::desktop() ->screenGeometry().height(); QPoint p( screenwidth - width() - panelHeight, screenheight - height() - panelHeight ); move( p ); // Enable Dragging Feature QObject::connect( h, SIGNAL( moveTo( const QPoint & ) ), this, SLOT( move( const QPoint & ) ) ); // Quit QObject::connect( toolbar, SIGNAL( quitToolbar() ), qApp, SLOT( quit() ) ); show(); }
void UimToolbarDraggingHandler::mouseDoubleClickEvent( QMouseEvent * /* e */ ) { isDragging = false; emit handleDoubleClicked(); }