mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-06-03 21:21:25 +00:00
Changed resource selector so you click the resource name to find it instead of having a separate find button
This commit is contained in:
parent
096ef45bac
commit
2348b8514f
@ -16,7 +16,9 @@ CResourceSelector::CResourceSelector(QWidget *pParent /*= 0*/)
|
|||||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
|
||||||
// Set up UI
|
// Set up UI
|
||||||
mpResNameLabel = new QLabel(this);
|
mpResNameButton = new QPushButton(this);
|
||||||
|
mpResNameButton->setFlat(true);
|
||||||
|
mpResNameButton->setStyleSheet("text-align:left; font-size:10pt; margin:0px; padding-left:2px");
|
||||||
|
|
||||||
mpSetButton = new QPushButton(this);
|
mpSetButton = new QPushButton(this);
|
||||||
mpSetButton->setToolTip("Use selected asset in Resource Browser");
|
mpSetButton->setToolTip("Use selected asset in Resource Browser");
|
||||||
@ -24,12 +26,6 @@ CResourceSelector::CResourceSelector(QWidget *pParent /*= 0*/)
|
|||||||
mpSetButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
mpSetButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
mpSetButton->setFixedSize(16, 16);
|
mpSetButton->setFixedSize(16, 16);
|
||||||
|
|
||||||
mpFindButton = new QPushButton(this);
|
|
||||||
mpFindButton->setToolTip("Find in Resource Browser");
|
|
||||||
mpFindButton->setIcon(QIcon(":/icons/Search_16px.png"));
|
|
||||||
mpFindButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
||||||
mpFindButton->setFixedSize(16, 16);
|
|
||||||
|
|
||||||
mpClearButton = new QPushButton(this);
|
mpClearButton = new QPushButton(this);
|
||||||
mpClearButton->setToolTip("Clear");
|
mpClearButton->setToolTip("Clear");
|
||||||
mpClearButton->setIcon(QIcon(":/icons/X_16px.png"));
|
mpClearButton->setIcon(QIcon(":/icons/X_16px.png"));
|
||||||
@ -38,10 +34,9 @@ CResourceSelector::CResourceSelector(QWidget *pParent /*= 0*/)
|
|||||||
|
|
||||||
mpFrameLayout = new QHBoxLayout(this);
|
mpFrameLayout = new QHBoxLayout(this);
|
||||||
mpFrameLayout->setSpacing(2);
|
mpFrameLayout->setSpacing(2);
|
||||||
mpFrameLayout->setContentsMargins(3, 0, 0, 0);
|
mpFrameLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
mpFrameLayout->addWidget(mpResNameLabel);
|
mpFrameLayout->addWidget(mpResNameButton);
|
||||||
mpFrameLayout->addWidget(mpSetButton);
|
mpFrameLayout->addWidget(mpSetButton);
|
||||||
mpFrameLayout->addWidget(mpFindButton);
|
|
||||||
mpFrameLayout->addWidget(mpClearButton);
|
mpFrameLayout->addWidget(mpClearButton);
|
||||||
mpFrame = new QFrame(this);
|
mpFrame = new QFrame(this);
|
||||||
mpFrame->setBackgroundRole(QPalette::AlternateBase);
|
mpFrame->setBackgroundRole(QPalette::AlternateBase);
|
||||||
@ -53,15 +48,10 @@ CResourceSelector::CResourceSelector(QWidget *pParent /*= 0*/)
|
|||||||
mpLayout->setContentsMargins(0, 0, 0, 0);
|
mpLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
setLayout(mpLayout);
|
setLayout(mpLayout);
|
||||||
|
|
||||||
// Font
|
|
||||||
QFont Font = font();
|
|
||||||
Font.setPointSize(10);
|
|
||||||
setFont(Font);
|
|
||||||
|
|
||||||
// UI Connections
|
// UI Connections
|
||||||
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(CreateContextMenu(QPoint)));
|
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(CreateContextMenu(QPoint)));
|
||||||
|
connect(mpResNameButton, SIGNAL(clicked()), this, SLOT(Find()));
|
||||||
connect(mpSetButton, SIGNAL(clicked()), this, SLOT(Set()));
|
connect(mpSetButton, SIGNAL(clicked()), this, SLOT(Set()));
|
||||||
connect(mpFindButton, SIGNAL(clicked()), this, SLOT(Find()));
|
|
||||||
connect(mpClearButton, SIGNAL(clicked()), this, SLOT(Clear()));
|
connect(mpClearButton, SIGNAL(clicked()), this, SLOT(Clear()));
|
||||||
|
|
||||||
// Set up context menu
|
// Set up context menu
|
||||||
@ -95,9 +85,8 @@ void CResourceSelector::UpdateUI()
|
|||||||
bool HasResource = mpResEntry != nullptr;
|
bool HasResource = mpResEntry != nullptr;
|
||||||
|
|
||||||
// Update main UI
|
// Update main UI
|
||||||
mpResNameLabel->setText(HasResource ? TO_QSTRING(mpResEntry->Name()) + "." + TO_QSTRING(mpResEntry->CookedExtension().ToString()) : "");
|
mpResNameButton->setText(HasResource ? TO_QSTRING(mpResEntry->Name()) + "." + TO_QSTRING(mpResEntry->CookedExtension().ToString()) : "");
|
||||||
mpResNameLabel->setToolTip(HasResource ? TO_QSTRING(mpResEntry->CookedAssetPath(true)) : "");
|
mpResNameButton->setToolTip(HasResource ? TO_QSTRING(mpResEntry->CookedAssetPath(true)) : "");
|
||||||
mpFindButton->setEnabled(HasResource);
|
|
||||||
mpClearButton->setEnabled(HasResource);
|
mpClearButton->setEnabled(HasResource);
|
||||||
|
|
||||||
// Update context menu
|
// Update context menu
|
||||||
@ -151,7 +140,7 @@ void CResourceSelector::EditAsset()
|
|||||||
|
|
||||||
void CResourceSelector::CopyName()
|
void CResourceSelector::CopyName()
|
||||||
{
|
{
|
||||||
gpEdApp->clipboard()->setText(mpResNameLabel->text());
|
gpEdApp->clipboard()->setText(mpResNameButton->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CResourceSelector::CopyPath()
|
void CResourceSelector::CopyPath()
|
||||||
@ -174,10 +163,13 @@ void CResourceSelector::Set()
|
|||||||
|
|
||||||
void CResourceSelector::Find()
|
void CResourceSelector::Find()
|
||||||
{
|
{
|
||||||
CResourceBrowser *pBrowser = gpEdApp->ResourceBrowser();
|
if (mpResEntry)
|
||||||
pBrowser->SelectResource(mpResEntry);
|
{
|
||||||
pBrowser->show();
|
CResourceBrowser *pBrowser = gpEdApp->ResourceBrowser();
|
||||||
pBrowser->raise();
|
pBrowser->SelectResource(mpResEntry);
|
||||||
|
pBrowser->show();
|
||||||
|
pBrowser->raise();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CResourceSelector::Clear()
|
void CResourceSelector::Clear()
|
||||||
|
@ -18,9 +18,8 @@ class CResourceSelector : public QWidget
|
|||||||
QVBoxLayout *mpLayout;
|
QVBoxLayout *mpLayout;
|
||||||
QHBoxLayout *mpFrameLayout;
|
QHBoxLayout *mpFrameLayout;
|
||||||
QFrame *mpFrame;
|
QFrame *mpFrame;
|
||||||
QLabel *mpResNameLabel;
|
QPushButton *mpResNameButton;
|
||||||
QPushButton *mpSetButton;
|
QPushButton *mpSetButton;
|
||||||
QPushButton *mpFindButton;
|
|
||||||
QPushButton *mpClearButton;
|
QPushButton *mpClearButton;
|
||||||
|
|
||||||
// Context Menu
|
// Context Menu
|
||||||
|
Loading…
x
Reference in New Issue
Block a user