2023-10-08 15:46:08 +08:00
|
|
|
/*
|
|
|
|
* KWin Style UKUI
|
|
|
|
*
|
|
|
|
* Copyright (C) 2023, KylinSoft Co., Ltd.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Authors: Jing Tan <tanjing@kylinos.cn>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2022-10-20 14:35:01 +08:00
|
|
|
#include "debug.h"
|
|
|
|
|
|
|
|
#include "pathbar.h"
|
|
|
|
#include <PeonyPathCompleter>
|
|
|
|
#include <PeonyPathBarModel>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QObject>
|
2022-11-28 20:37:53 +08:00
|
|
|
#include <QDBusInterface>
|
|
|
|
#include <QDBusMessage>
|
|
|
|
#include <peony-qt/file-utils.h>
|
2022-10-20 14:35:01 +08:00
|
|
|
#include "debug.h"
|
2023-12-11 15:20:27 +08:00
|
|
|
#include "settings/ukui-style-settings.h"
|
2023-08-25 11:24:16 +08:00
|
|
|
using namespace UKUIFileDialog;
|
2022-10-20 14:35:01 +08:00
|
|
|
|
|
|
|
FileDialogPathBar::FileDialogPathBar(QWidget *parent) : QWidget(parent)//Peony::AdvancedLocationBar(parent)//QLineEdit(parent)//
|
|
|
|
{
|
|
|
|
setAttribute(Qt::WA_TranslucentBackground);
|
2022-11-28 20:37:53 +08:00
|
|
|
setContentsMargins(0,0,0,0);
|
2022-10-20 14:35:01 +08:00
|
|
|
m_pathBar = new Peony::AdvancedLocationBar(this);
|
2022-11-28 20:37:53 +08:00
|
|
|
|
|
|
|
QDBusInterface *interFace = new QDBusInterface(SERVICE, PATH, INTERFACE, QDBusConnection::sessionBus());
|
|
|
|
if(interFace->isValid()){
|
|
|
|
connect(interFace, SIGNAL(mode_change_signal(bool)), this, SLOT(updateTableModel(bool)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QDBusMessage message = QDBusMessage::createMethodCall("com.kylin.statusmanager.interface",
|
|
|
|
"/",
|
|
|
|
"com.kylin.statusmanager.interface",
|
|
|
|
"get_current_tabletmode");
|
|
|
|
QDBusMessage ret = QDBusConnection::sessionBus().call(message);
|
|
|
|
if (ret.type() != QDBusMessage::ReplyMessage)
|
|
|
|
{
|
|
|
|
//从返回参数获取返回值
|
|
|
|
pDebug << "complex type failed!";
|
|
|
|
updateTableModel(false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
updateTableModel(ret.arguments()[0].value<bool>());
|
|
|
|
}
|
2022-10-20 14:35:01 +08:00
|
|
|
}
|
|
|
|
|
2023-08-25 11:24:16 +08:00
|
|
|
FileDialogPathBar::~FileDialogPathBar()
|
|
|
|
{
|
|
|
|
m_pathBar->deleteLater();
|
|
|
|
m_pathBar = nullptr;
|
|
|
|
}
|
|
|
|
|
2022-10-20 14:35:01 +08:00
|
|
|
void FileDialogPathBar::updatePath(const QString &uri)
|
|
|
|
{
|
2022-11-28 20:37:53 +08:00
|
|
|
pDebug << "m_pathBar........ updatePath:" << uri << Peony::FileUtils::getEncodedUri(uri);
|
|
|
|
m_pathBar->updateLocation(Peony::FileUtils::urlEncode(uri));
|
2022-10-20 14:35:01 +08:00
|
|
|
// setText(uri);
|
|
|
|
// clearFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FileDialogPathBar::resizeEvent(QResizeEvent *e)
|
|
|
|
{
|
|
|
|
m_pathBar->setFixedWidth(this->width());
|
|
|
|
m_pathBar->setGeometry(0, (this->height() - m_pathBar->height()) / 2, this->width(), m_pathBar->height());
|
|
|
|
}
|
|
|
|
|
|
|
|
Peony::AdvancedLocationBar *FileDialogPathBar::getPathBar()
|
|
|
|
{
|
|
|
|
return m_pathBar;
|
|
|
|
}
|
2022-11-28 20:37:53 +08:00
|
|
|
|
|
|
|
void FileDialogPathBar::updateTableModel(bool isTable)
|
|
|
|
{
|
|
|
|
pDebug << "updateTableModel...." << isTable;
|
|
|
|
// m_pathBar->updateTabletModeValue(isTable);
|
|
|
|
if(isTable){
|
|
|
|
m_pathBar->setFixedHeight(48);
|
|
|
|
this->setFixedHeight(48);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
m_pathBar->setFixedHeight(36);
|
|
|
|
this->setFixedHeight(36);
|
|
|
|
}
|
|
|
|
pDebug << "m_pathBar height1111:" << m_pathBar->height() << this->height();
|
|
|
|
}
|