forked from openkylin/qt5-ukui-platformtheme
快速访问路径转为实际路径后再跳转
This commit is contained in:
parent
ffc0e1c634
commit
9c7c27974c
|
@ -93,9 +93,13 @@ KyNativeFileDialog::KyNativeFileDialog(QWidget *parent)
|
|||
|
||||
connect(mKyFileDialogUi->m_sider, &FileDialogSideBar::goToUriRequest, this, [this](const QString &uri, bool addToHistory, bool forceUpdate){
|
||||
pDebug << "goToUri0000";
|
||||
// if(m_searchMode)
|
||||
// searchButtonClicked();
|
||||
goToUri(uri, addToHistory, forceUpdate);
|
||||
if (uri.startsWith("favorite://")) {
|
||||
QString u = Peony::FileUtils::getTargetUri(uri);
|
||||
goToUri(u, addToHistory, forceUpdate);
|
||||
|
||||
}
|
||||
else
|
||||
goToUri(uri, addToHistory, forceUpdate);
|
||||
});
|
||||
|
||||
connect(getCurrentPage(), &Peony::DirectoryViewContainer::directoryChanged, this, &KyNativeFileDialog::updateWindowState);
|
||||
|
@ -615,6 +619,7 @@ void KyNativeFileDialog::goToUri(const QString &uri, bool addToHistory, bool for
|
|||
{
|
||||
isInitialGoToUriNum = false;
|
||||
getCurrentPage()->stopLoading();
|
||||
pDebug << "gotouri123123:" << uri << addToHistory << forceUpdate;
|
||||
if(uri.startsWith("search:///search_uris="))
|
||||
getCurrentPage()->goToUri(uri, addToHistory, forceUpdate);
|
||||
else
|
||||
|
|
|
@ -12,6 +12,7 @@ class MenuToolButton : public QToolButton
|
|||
Q_OBJECT
|
||||
public:
|
||||
explicit MenuToolButton(QWidget *parent = nullptr);
|
||||
~MenuToolButton(){}
|
||||
|
||||
Q_SIGNALS:
|
||||
|
||||
|
@ -28,6 +29,7 @@ class ToolButtonStyle : public QProxyStyle
|
|||
static ToolButtonStyle *getStyle();
|
||||
|
||||
ToolButtonStyle() {}
|
||||
~ToolButtonStyle() {}
|
||||
|
||||
int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const override;
|
||||
|
||||
|
|
|
@ -40,6 +40,12 @@ FileDialogPathBar::FileDialogPathBar(QWidget *parent) : QWidget(parent)//Peony::
|
|||
}
|
||||
}
|
||||
|
||||
FileDialogPathBar::~FileDialogPathBar()
|
||||
{
|
||||
m_pathBar->deleteLater();
|
||||
m_pathBar = nullptr;
|
||||
}
|
||||
|
||||
void FileDialogPathBar::updatePath(const QString &uri)
|
||||
{
|
||||
pDebug << "m_pathBar........ updatePath:" << uri << Peony::FileUtils::getEncodedUri(uri);
|
||||
|
|
|
@ -11,6 +11,7 @@ class FileDialogPathBar : public QWidget//public QLineEdit//
|
|||
Q_OBJECT
|
||||
public:
|
||||
explicit FileDialogPathBar(QWidget *parent = nullptr);
|
||||
~FileDialogPathBar();
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
Peony::AdvancedLocationBar *getPathBar();
|
||||
|
||||
|
|
|
@ -94,17 +94,17 @@ FileDialogSideBar::FileDialogSideBar(QWidget *parent) : QTreeView(parent)
|
|||
auto delegate = new SideBarItemDelegate(this);
|
||||
setItemDelegate(delegate);
|
||||
|
||||
auto model = new Peony::SideBarModel(this);
|
||||
auto proxyModel = new Peony::SideBarProxyFilterSortModel(this);
|
||||
proxyModel->setSourceModel(model);
|
||||
setModel(proxyModel);
|
||||
m_model = new Peony::SideBarModel(this);
|
||||
m_proxyModel = new Peony::SideBarProxyFilterSortModel(this);
|
||||
m_proxyModel->setSourceModel(m_model);
|
||||
setModel(m_proxyModel);
|
||||
|
||||
Peony::VolumeManager *volumeManager = Peony::VolumeManager::getInstance();
|
||||
connect(volumeManager,&Peony::VolumeManager::volumeAdded,this,[=](const std::shared_ptr<Peony::Volume> &volume){
|
||||
proxyModel->invalidate();//display DVD device in real time.
|
||||
m_proxyModel->invalidate();//display DVD device in real time.
|
||||
});
|
||||
connect(volumeManager,&Peony::VolumeManager::volumeRemoved,this,[=](const std::shared_ptr<Peony::Volume> &volume){
|
||||
proxyModel->invalidate();//The drive does not display when the DVD device is removed.
|
||||
m_proxyModel->invalidate();//The drive does not display when the DVD device is removed.
|
||||
//pDebug << "volumeRemoved:" <<QToolTip::text();
|
||||
//fix abnormal pull out usb device tips not hide issue, link to bug#81190
|
||||
if (QToolTip::isVisible()) {
|
||||
|
@ -112,17 +112,17 @@ FileDialogSideBar::FileDialogSideBar(QWidget *parent) : QTreeView(parent)
|
|||
}
|
||||
});
|
||||
connect(volumeManager,&Peony::VolumeManager::driveDisconnected,this,[=](const std::shared_ptr<Peony::Drive> &drive){
|
||||
proxyModel->invalidate();//Multiple udisk eject display problem
|
||||
m_proxyModel->invalidate();//Multiple udisk eject display problem
|
||||
});
|
||||
connect(volumeManager,&Peony::VolumeManager::mountAdded,this,[=](const std::shared_ptr<Peony::Mount> &mount){
|
||||
proxyModel->invalidate();//display udisk in real time after format it.
|
||||
m_proxyModel->invalidate();//display udisk in real time after format it.
|
||||
});
|
||||
|
||||
|
||||
connect(this, &FileDialogSideBar::clicked, this, [=](const QModelIndex &index){
|
||||
switch (index.column()) {
|
||||
case 0: {
|
||||
auto item = proxyModel->itemFromIndex(index);
|
||||
auto item = m_proxyModel->itemFromIndex(index);
|
||||
|
||||
if (! item)
|
||||
break;
|
||||
|
@ -142,9 +142,9 @@ FileDialogSideBar::FileDialogSideBar(QWidget *parent) : QTreeView(parent)
|
|||
break;
|
||||
}
|
||||
case 1: {
|
||||
auto item = proxyModel->itemFromIndex(index);
|
||||
auto item = m_proxyModel->itemFromIndex(index);
|
||||
if (item->isMounted() || item->isEjectable()||item->isStopable()) {
|
||||
auto leftIndex = proxyModel->index(index.row(), 0, index.parent());
|
||||
auto leftIndex = m_proxyModel->index(index.row(), 0, index.parent());
|
||||
this->collapse(leftIndex);
|
||||
item->ejectOrUnmount();
|
||||
} else {
|
||||
|
@ -167,18 +167,18 @@ FileDialogSideBar::FileDialogSideBar(QWidget *parent) : QTreeView(parent)
|
|||
});
|
||||
|
||||
connect(this, &FileDialogSideBar::expanded, this, [=](const QModelIndex &index){
|
||||
auto item = proxyModel->itemFromIndex(index);
|
||||
auto item = m_proxyModel->itemFromIndex(index);
|
||||
item->findChildrenAsync();
|
||||
});
|
||||
|
||||
connect(this, &FileDialogSideBar::collapsed, this, [=](const QModelIndex &index){
|
||||
auto item = proxyModel->itemFromIndex(index);
|
||||
auto item = m_proxyModel->itemFromIndex(index);
|
||||
item->clearChildren();
|
||||
});
|
||||
|
||||
connect(this, &QTreeView::customContextMenuRequested, this, [=](const QPoint &pos){
|
||||
auto index = indexAt(pos);
|
||||
auto item = proxyModel->itemFromIndex(index);
|
||||
auto item = m_proxyModel->itemFromIndex(index);
|
||||
if (item) {
|
||||
if (item->type() != Peony::SideBarAbstractItem::SeparatorItem) {
|
||||
Peony::SideBarMenu menu(item, nullptr);
|
||||
|
@ -219,6 +219,14 @@ FileDialogSideBar::FileDialogSideBar(QWidget *parent) : QTreeView(parent)
|
|||
// setColumnHidden(1, true);
|
||||
}
|
||||
|
||||
FileDialogSideBar::~FileDialogSideBar()
|
||||
{
|
||||
m_proxyModel->deleteLater();
|
||||
m_proxyModel = nullptr;
|
||||
m_model->deleteLater();
|
||||
m_model = nullptr;
|
||||
}
|
||||
|
||||
void FileDialogSideBar::tableModeChanged(bool isTableMode)
|
||||
{
|
||||
pDebug << "tableModeChanged........";
|
||||
|
|
|
@ -12,12 +12,14 @@
|
|||
#include <PeonySideBarProxyModel>
|
||||
#include <QComboBox>
|
||||
#include <QSize>
|
||||
#include <PeonySideBarModel>
|
||||
|
||||
class FileDialogComboBox : public QComboBox
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FileDialogComboBox(QWidget *parent = nullptr);
|
||||
~FileDialogComboBox(){}
|
||||
QSize minimumSizeHint() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
|
@ -38,6 +40,7 @@ class FileDialogSideBar : public QTreeView
|
|||
Q_OBJECT
|
||||
public:
|
||||
explicit FileDialogSideBar(QWidget *parent = nullptr);
|
||||
~FileDialogSideBar();
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
|
@ -45,6 +48,10 @@ public Q_SLOTS:
|
|||
void menuRequest(const QPoint &pos);
|
||||
void tableModeChanged(bool isTableMode);
|
||||
|
||||
private:
|
||||
Peony::SideBarProxyFilterSortModel *m_proxyModel = nullptr;
|
||||
Peony::SideBarModel *m_model = nullptr;
|
||||
|
||||
Q_SIGNALS:
|
||||
void goToUriRequest(const QString &uri, bool addToHistory = true, bool forceUpdate = false);
|
||||
|
||||
|
@ -55,6 +62,7 @@ class SideBarItemDelegate : public QStyledItemDelegate
|
|||
{
|
||||
friend class FileDialogSideBar;
|
||||
explicit SideBarItemDelegate(QObject *parent = nullptr);
|
||||
~SideBarItemDelegate(){}
|
||||
|
||||
// QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
|
@ -66,6 +74,7 @@ class SideBarStyle : public QProxyStyle
|
|||
public:
|
||||
explicit SideBarStyle();
|
||||
static SideBarStyle* getStyle();
|
||||
~SideBarStyle(){}
|
||||
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const override;
|
||||
void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const override;
|
||||
};
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "ui_kyfiledialog.h"
|
||||
#include <QFileDialog>
|
||||
#include "kyfiledialog.h"
|
||||
|
||||
#include "debug.h"
|
||||
//Ui_KyFileDialog::Ui_KyFileDialog(QDialog *parent)
|
||||
//{
|
||||
// setupUi(parent);
|
||||
|
@ -138,7 +138,7 @@ void Ui_KyFileDialog::initLineEditLayout(QDialog *mKyFileDialog)
|
|||
sizePolicy2.setHeightForWidth(m_fileNameLabel->sizePolicy().hasHeightForWidth());
|
||||
m_fileNameLabel->setSizePolicy(sizePolicy2);
|
||||
m_fileNameLabel->setMinimumSize(QSize(0, 0));
|
||||
qDebug() << "3333333333333333333";
|
||||
pDebug << "3333333333333333333";
|
||||
|
||||
m_fileNameEdit = new QLineEdit(mKyFileDialog);
|
||||
m_fileNameEdit->setObjectName("fileNameEdit");
|
||||
|
@ -147,7 +147,7 @@ void Ui_KyFileDialog::initLineEditLayout(QDialog *mKyFileDialog)
|
|||
sizePolicy3.setVerticalStretch(0);
|
||||
sizePolicy3.setHeightForWidth(m_fileNameEdit->sizePolicy().hasHeightForWidth());
|
||||
m_fileNameEdit->setSizePolicy(sizePolicy3);
|
||||
qDebug() << "44444444444444444";
|
||||
pDebug << "44444444444444444";
|
||||
|
||||
m_fileTypeCombo = new FileDialogComboBox();
|
||||
QSizePolicy sizePolicy4(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
|
@ -185,7 +185,7 @@ void Ui_KyFileDialog::intiBtnLayout(QDialog *mKyFileDialog)
|
|||
m_acceptButton->setObjectName(QString::fromUtf8("acceptButton"));
|
||||
m_rejectButton->setObjectName(QString::fromUtf8("rejectButton"));
|
||||
|
||||
qDebug() << "6666666666666666";
|
||||
pDebug << "6666666666666666";
|
||||
}
|
||||
|
||||
void Ui_KyFileDialog::setupUi(QDialog *mKyFileDialog)
|
||||
|
|
Loading…
Reference in New Issue