forked from openkylin/ukui-panel
!37 *Feat:任务栏拖拽交互
Merge pull request !37 from zhangyinjie/dev_dragapplications
This commit is contained in:
commit
225d1f17af
|
@ -43,19 +43,21 @@ bool PinToTaskbar::RemoveFromTaskbar(const QString &desktop)
|
|||
|
||||
bool PinToTaskbar::CheckIfExist(const QString &desktop)
|
||||
{
|
||||
QString fixdDesktop;
|
||||
//兼容处理,传入desktop路径和文件名都可以匹配
|
||||
QString desktopName;
|
||||
if(desktop.contains("/")) {
|
||||
desktopName = desktop.section('/', -1, -1);
|
||||
} else
|
||||
desktopName = desktop;
|
||||
QString fixdDesktopName;
|
||||
const auto apps = getTaskbarFixedList();
|
||||
|
||||
for (const QMap<QString, QVariant> &app : apps) {
|
||||
fixdDesktop = app.value("desktop", "").toString();
|
||||
|
||||
if (fixdDesktop.contains(desktop)) {
|
||||
fixdDesktopName = app.value("desktop", "").toString().section('/', -1, -1);
|
||||
if (fixdDesktopName.contains(desktopName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
QList<QMap<QString, QVariant> > PinToTaskbar::getTaskbarFixedList()
|
||||
|
|
|
@ -213,11 +213,11 @@ UKUITaskBar::UKUITaskBar(IUKUIPanelPlugin *plugin, QWidget *parent) :
|
|||
************************************************/
|
||||
UKUITaskBar::~UKUITaskBar()
|
||||
{
|
||||
for (auto it = m_vBtn.begin(); it != m_vBtn.end();) {
|
||||
for (auto it = m_vQuickLaunchBtn.begin(); it != m_vQuickLaunchBtn.end();) {
|
||||
(*it)->deleteLater();
|
||||
m_vBtn.erase(it);
|
||||
m_vQuickLaunchBtn.erase(it);
|
||||
}
|
||||
m_vBtn.clear();
|
||||
m_vQuickLaunchBtn.clear();
|
||||
}
|
||||
|
||||
void UKUITaskBar::initMaskUI()
|
||||
|
@ -291,7 +291,7 @@ void UKUITaskBar::onDesktopChanged()
|
|||
(*i)->onDesktopChanged();
|
||||
if ((*i)->m_existSameQckBtn) {
|
||||
UKUITaskGroup* btn = (*i)->getOwnQckBtn();
|
||||
if (m_vBtn.contains(btn))
|
||||
if (m_vQuickLaunchBtn.contains(btn))
|
||||
btn->setVisible((*i)->isHidden());
|
||||
}
|
||||
}
|
||||
|
@ -306,9 +306,9 @@ void UKUITaskBar::readPanelConfig(bool isTabletMode)
|
|||
|
||||
void UKUITaskBar::refreshQuickLaunch()
|
||||
{
|
||||
for (auto it = m_vBtn.begin(); it != m_vBtn.end();) {
|
||||
for (auto it = m_vQuickLaunchBtn.begin(); it != m_vQuickLaunchBtn.end();) {
|
||||
(*it)->deleteLater();
|
||||
m_vBtn.erase(it);
|
||||
m_vQuickLaunchBtn.erase(it);
|
||||
}
|
||||
|
||||
QString desktop;
|
||||
|
@ -356,14 +356,14 @@ QList<QMap<QString, QVariant> > UKUITaskBar::copyQuicklaunchConfig()
|
|||
|
||||
void UKUITaskBar::addButtonForQuicklanch(QList<QMap<QString, QVariant> > apps)
|
||||
{
|
||||
for (auto it = m_vBtn.begin(); it != m_vBtn.end();) {
|
||||
UKUITaskGroup * quicklaunch = m_vBtn.value(m_vBtn.indexOf(*it));
|
||||
for (auto it = m_vQuickLaunchBtn.begin(); it != m_vQuickLaunchBtn.end();) {
|
||||
UKUITaskGroup * quicklaunch = m_vQuickLaunchBtn.value(m_vQuickLaunchBtn.indexOf(*it));
|
||||
if(quicklaunch->m_existSameQckBtn == true) {
|
||||
it++;
|
||||
continue;
|
||||
}
|
||||
(*it)->deleteLater();
|
||||
m_vBtn.erase(it);
|
||||
m_vQuickLaunchBtn.erase(it);
|
||||
}
|
||||
|
||||
for (const QMap<QString, QVariant> &app : apps) {
|
||||
|
@ -480,21 +480,48 @@ QString UKUITaskBar::isComputerOrTrash(QString urlName) {
|
|||
return urlName;
|
||||
}
|
||||
|
||||
bool UKUITaskBar::pubCheckIfExist(QString name) {
|
||||
|
||||
for (int i = 0; i < m_vBtn.size(); i++) {
|
||||
QString cmpName;
|
||||
//bxq cmpName = (!m_vBtn.value(i)->m_fileName.isEmpty() ? m_vBtn.value(i)->m_fileName :
|
||||
// (!m_vBtn.value(i)->file.isEmpty() ? m_vBtn.value(i)->file :
|
||||
// (!m_vBtn.value(i)->name.isEmpty() ? m_vBtn.value(i)->name : m_vBtn.value(i)->exec)));
|
||||
cmpName = m_vBtn.value(i)->m_fileName;
|
||||
if (cmpName.isEmpty()) return false;
|
||||
if (cmpName.compare(name) == 0) return true;
|
||||
bool UKUITaskBar::isQuickLaunchBtn(QString desktopName)
|
||||
{
|
||||
for(int i=0; i<m_vQuickLaunchBtn.size(); i++) {
|
||||
QString btnDesktopPath = m_vQuickLaunchBtn.at(i)->m_fileName;
|
||||
QString btnDesktopName = btnDesktopPath.section('/', -1, -1);
|
||||
if (btnDesktopName.isEmpty())
|
||||
return false;
|
||||
if (btnDesktopName.compare(desktopName) == 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UKUITaskBar::CheckIfExist(QString arg)
|
||||
bool UKUITaskBar::isKnownWindows(QString desktopName)
|
||||
{
|
||||
QMap<WId, UKUITaskGroup*>::iterator iter = m_knownWindows.begin();
|
||||
for(iter; iter!=m_knownWindows.end(); iter++) {
|
||||
QString btnDesktopPath = iter.value()->m_fileName;
|
||||
QString btnDesktopName = btnDesktopPath.section('/', -1, -1);
|
||||
if (btnDesktopName.isEmpty())
|
||||
return false;
|
||||
if (btnDesktopName.compare(desktopName) == 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QString UKUITaskBar::getKnownWindowsDesktopPath(QString desktopName)
|
||||
{
|
||||
QMap<WId, UKUITaskGroup*>::iterator iter = m_knownWindows.begin();
|
||||
for(iter; iter!=m_knownWindows.end(); iter++) {
|
||||
QString btnDesktopPath = iter.value()->m_fileName;
|
||||
QString btnDesktopName = btnDesktopPath.section('/', -1, -1);
|
||||
if (btnDesktopName.isEmpty())
|
||||
return QString();
|
||||
if (btnDesktopName.compare(desktopName) == 0)
|
||||
return btnDesktopPath;
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool UKUITaskBar::checkIfExist(QString arg)
|
||||
{
|
||||
if(countOfButtons() > 0)
|
||||
{
|
||||
|
@ -511,50 +538,43 @@ bool UKUITaskBar::CheckIfExist(QString arg)
|
|||
|
||||
void UKUITaskBar::dropEvent(QDropEvent *e)
|
||||
{
|
||||
qDebug()<<"<<<<<<<<<<<<<<<< taskbar dropevent";
|
||||
const auto urls = e->mimeData()->urls().toSet();
|
||||
for (const QUrl &url : urls)
|
||||
{
|
||||
XdgDesktopFile xdg;
|
||||
QString urlName(url.isLocalFile() ? url.toLocalFile() : url.url());
|
||||
QFileInfo ur(urlName);
|
||||
QString fileName("/usr/share/applications/");
|
||||
qDebug()<<"<<<<<<<<<<< taskbar filename before"<<fileName;
|
||||
qDebug()<<"<<<<<<<<<<< taskbar desktop"<<urlName.section('/', -1, -1);
|
||||
fileName.append(urlName.section('/', -1, -1));
|
||||
//fileName = isComputerOrTrash(urlName);
|
||||
urlName = isComputerOrTrash(urlName);
|
||||
qDebug()<<"<<<<<<<<<<< taskbar filename after"<<fileName;
|
||||
qDebug()<<"<<<<<<<<<<< taskbar urlname"<<urlName;
|
||||
const QSet<QUrl> dragDesktopUrls = e->mimeData()->urls().toSet();
|
||||
//支持拖拽多个图标。对链表遍历,逐个处理
|
||||
for (const QUrl &url : dragDesktopUrls) {
|
||||
bool isHandle = false;
|
||||
//解析dragDesktopUrl 获取 Desktop文件名
|
||||
QString dragDesktopPath(url.isLocalFile() ? url.toLocalFile() : url.url());
|
||||
QString dragDesktopName = dragDesktopPath.section('/', -1, -1);
|
||||
|
||||
if (CheckIfExist(urlName)) return;
|
||||
if (CheckIfExist(fileName)) return;
|
||||
if (isDesktopFile(urlName)) {
|
||||
if (ur.isSymLink()){
|
||||
if (xdg.load(urlName) && xdg.isSuitable()) {
|
||||
if (CheckIfExist(xdg.fileName())) return;
|
||||
addButton(new QuickLaunchAction(&xdg, this));
|
||||
}
|
||||
} else {
|
||||
if (xdg.load(fileName) && xdg.isSuitable()) {
|
||||
if (CheckIfExist(urlName)) return;
|
||||
addButton(new QuickLaunchAction(&xdg, this));
|
||||
// A- 按钮已固定,不作处理
|
||||
QString btnDesktopPath;
|
||||
QString btnDesktopName;
|
||||
for(int i=0; i<m_vQuickLaunchBtn.size(); i++) {
|
||||
//解析desktop名
|
||||
btnDesktopPath = m_vQuickLaunchBtn.at(i)->m_fileName;
|
||||
btnDesktopName = btnDesktopPath.section('/', -1, -1);
|
||||
if(btnDesktopName == dragDesktopName) {
|
||||
isHandle = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// B- 按钮已打开,未固定,做固定按钮操作
|
||||
if(isHandle == false) {
|
||||
QMap<WId, UKUITaskGroup*>::iterator iter = m_knownWindows.begin();
|
||||
for(iter; iter!=m_knownWindows.end(); iter++) {
|
||||
btnDesktopPath = iter.value()->m_fileName;
|
||||
btnDesktopName = btnDesktopPath.section('/', -1, -1);
|
||||
if(btnDesktopName == dragDesktopName) {
|
||||
addToTaskbar(iter.value()->m_fileName);
|
||||
realign();
|
||||
isHandle = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// } else if (ur.exists() && ur.isExecutable() && !ur.isDir() || ur.isSymLink()) {
|
||||
// if (ur.size() <= 153600)
|
||||
// xdg.load(urlName);
|
||||
// addButton(new QuickLaunchAction(urlName, this));
|
||||
// } else if (ur.exists()) {
|
||||
// if (ur.size() <= 153600)
|
||||
// xdg.load(urlName);
|
||||
// addButton(new QuickLaunchAction(urlName, this));
|
||||
// //taskbar->pubAddButton(new QuickLaunchAction(urlName, urlName, "", this));
|
||||
} else {
|
||||
qWarning() << "XdgDesktopFile" << urlName << "is not valid";
|
||||
QMessageBox::information(this, tr("Drop Error"),
|
||||
tr("File/URL '%1' cannot be embedded into QuickLaunch for now").arg(urlName)
|
||||
);
|
||||
}
|
||||
// C- taskbar中没有该按钮, 创建新按钮,固定按钮
|
||||
if(isHandle == false) {
|
||||
addToTaskbar(dragDesktopPath);
|
||||
}
|
||||
}
|
||||
saveSettings();
|
||||
|
@ -571,8 +591,8 @@ void UKUITaskBar::dragEnterEvent(QDragEnterEvent* event)
|
|||
fileName.append(urlName.section('/', -1, -1));
|
||||
fileName = isComputerOrTrash(urlName);
|
||||
urlName = isComputerOrTrash(urlName);
|
||||
if (CheckIfExist(urlName)) return;
|
||||
if (CheckIfExist(fileName)) return;
|
||||
if (checkIfExist(urlName)) return;
|
||||
if (checkIfExist(fileName)) return;
|
||||
if (!isDesktopFile(urlName)) return;
|
||||
|
||||
}
|
||||
|
@ -684,9 +704,9 @@ void UKUITaskBar::groupBecomeEmptySlot()
|
|||
++i;
|
||||
}
|
||||
}
|
||||
for (auto it = m_vBtn.begin(); it!=m_vBtn.end(); ++it) {
|
||||
for (auto it = m_vQuickLaunchBtn.begin(); it!=m_vQuickLaunchBtn.end(); ++it) {
|
||||
UKUITaskGroup *pQuickBtn = *it;
|
||||
if(pQuickBtn->m_fileName == group->m_fileName
|
||||
if(pQuickBtn->m_desktopName == group->m_desktopName
|
||||
&&(m_layout->indexOf(pQuickBtn) >= 0 )) {
|
||||
pQuickBtn->setHidden(false);
|
||||
m_layout->moveItem(m_layout->indexOf(pQuickBtn), m_layout->indexOf(group));
|
||||
|
@ -716,7 +736,6 @@ void UKUITaskBar::addWindow(WId window)
|
|||
(*i_group)->onWindowRemoved(window);
|
||||
}
|
||||
}
|
||||
|
||||
/*check if window belongs to some existing group
|
||||
* 安卓兼容应用的组名为kydroid-display-window
|
||||
* 需要将安卓兼容目录的分组特性关闭
|
||||
|
@ -732,6 +751,7 @@ void UKUITaskBar::addWindow(WId window)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!group) {
|
||||
group = new UKUITaskGroup(group_id, window, this);
|
||||
connect(group, SIGNAL(groupBecomeEmpty(QString)), this, SLOT(groupBecomeEmptySlot()));
|
||||
|
@ -743,9 +763,9 @@ void UKUITaskBar::addWindow(WId window)
|
|||
connect(group, &UKUITaskButton::dragging, this, [this] (QObject * dragSource, QPoint const & pos) {
|
||||
switchButtons(qobject_cast<UKUITaskGroup *>(sender()), qobject_cast<UKUITaskGroup *>(dragSource));//, pos);
|
||||
});
|
||||
for (auto it = m_vBtn.begin(); it!=m_vBtn.end(); ++it) {
|
||||
for (auto it = m_vQuickLaunchBtn.begin(); it!=m_vQuickLaunchBtn.end(); ++it) {
|
||||
UKUITaskGroup *pQuickBtn = *it;
|
||||
if(pQuickBtn->m_fileName == group->m_fileName
|
||||
if(pQuickBtn->m_desktopName == group->m_desktopName
|
||||
&&(m_layout->indexOf(pQuickBtn) >= 0 )) {
|
||||
m_layout->addWidget(group);
|
||||
m_layout->moveItem(m_layout->indexOf(group), m_layout->indexOf(pQuickBtn));
|
||||
|
@ -977,8 +997,8 @@ void UKUITaskBar::realign()
|
|||
UKUITaskGroup *group = it.value();
|
||||
group->setIconSize(QSize(iconsize,iconsize));
|
||||
}
|
||||
for (int i = 0; i < m_vBtn.size(); i++) {
|
||||
UKUITaskGroup * quicklaunch = m_vBtn.value(i);
|
||||
for (int i = 0; i < m_vQuickLaunchBtn.size(); i++) {
|
||||
UKUITaskGroup * quicklaunch = m_vQuickLaunchBtn.value(i);
|
||||
quicklaunch->setIconSize(QSize(iconsize, iconsize));
|
||||
}
|
||||
m_layout->setCellFixedSize(btnSize);
|
||||
|
@ -1085,14 +1105,14 @@ void UKUITaskBar::addButton(QuickLaunchAction* action)
|
|||
*/
|
||||
for (auto it = m_knownWindows.begin(); it!=m_knownWindows.end(); ++it) {
|
||||
UKUITaskGroup *group = *it;
|
||||
if(btn->m_fileName == group->m_fileName
|
||||
if(btn->m_desktopName == group->m_desktopName
|
||||
&&(m_layout->indexOf(group) >= 0)) {
|
||||
m_layout->addWidget(btn);
|
||||
m_layout->moveItem(m_layout->indexOf(btn), m_layout->indexOf(group));
|
||||
isNeedAddNewWidget = false;
|
||||
group->m_existSameQckBtn = true;
|
||||
btn->m_existSameQckBtn = true;
|
||||
m_vBtn.push_back(btn);
|
||||
m_vQuickLaunchBtn.push_back(btn);
|
||||
group->setQckLchBtn(btn);
|
||||
btn->setHidden(group->isVisible());
|
||||
break;
|
||||
|
@ -1101,7 +1121,7 @@ void UKUITaskBar::addButton(QuickLaunchAction* action)
|
|||
if (isNeedAddNewWidget) {
|
||||
m_layout->addWidget(btn);
|
||||
btn->setIconSize(QSize(m_plugin->panel()->iconSize(),m_plugin->panel()->iconSize()));
|
||||
m_vBtn.push_back(btn);
|
||||
m_vQuickLaunchBtn.push_back(btn);
|
||||
m_layout->moveItem(m_layout->indexOf(btn), countOfButtons() - 1);
|
||||
}
|
||||
connect(btn, &UKUITaskButton::dragging, this, [this] (QObject * dragSource, QPoint const & pos) {
|
||||
|
@ -1134,12 +1154,12 @@ bool UKUITaskBar::checkButton(QuickLaunchAction* action)
|
|||
bool checkresult;
|
||||
UKUITaskGroup* btn = new UKUITaskGroup(action, m_plugin, this);
|
||||
int i = 0;
|
||||
int counts = m_vBtn.size();
|
||||
if (m_vBtn.size()>0) {
|
||||
int counts = m_vQuickLaunchBtn.size();
|
||||
if (m_vQuickLaunchBtn.size()>0) {
|
||||
while (i != counts) {
|
||||
UKUITaskGroup *b = m_vBtn.value(i);
|
||||
UKUITaskGroup *b = m_vQuickLaunchBtn.value(i);
|
||||
qDebug()<<"m_layout->itemAt("<<i<<") ";
|
||||
if(b->m_fileName == btn->m_fileName) {
|
||||
if(b->m_desktopName == btn->m_desktopName) {
|
||||
checkresult=true;
|
||||
break;
|
||||
} else {
|
||||
|
@ -1164,13 +1184,13 @@ void UKUITaskBar::removeButton(QuickLaunchAction* action)
|
|||
if (!btn) {
|
||||
return;
|
||||
}
|
||||
while (i < m_vBtn.size()) {
|
||||
UKUITaskGroup *tmp = m_vBtn.value(i);
|
||||
if (QString::compare(btn->m_fileName, tmp->m_fileName) == 0) {
|
||||
doInitGroupButton(tmp->m_fileName);
|
||||
while (i < m_vQuickLaunchBtn.size()) {
|
||||
UKUITaskGroup *tmp = m_vQuickLaunchBtn.value(i);
|
||||
if (QString::compare(btn->m_desktopName, tmp->m_desktopName) == 0) {
|
||||
doInitGroupButton(tmp->m_desktopName);
|
||||
tmp->deleteLater();
|
||||
m_layout->removeWidget(tmp);
|
||||
m_vBtn.remove(i);
|
||||
m_vQuickLaunchBtn.remove(i);
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
|
@ -1183,13 +1203,13 @@ void UKUITaskBar::removeButton(QuickLaunchAction* action)
|
|||
void UKUITaskBar::removeButton(QString file)
|
||||
{
|
||||
int i = 0;
|
||||
while (i < m_vBtn.size()) {
|
||||
UKUITaskGroup *tmp = m_vBtn.value(i);
|
||||
if (QString::compare(file, tmp->m_fileName) == 0) {
|
||||
doInitGroupButton(tmp->m_fileName);
|
||||
while (i < m_vQuickLaunchBtn.size()) {
|
||||
UKUITaskGroup *tmp = m_vQuickLaunchBtn.value(i);
|
||||
if (QString::compare(file, tmp->m_desktopName) == 0) {
|
||||
doInitGroupButton(tmp->m_desktopName);
|
||||
tmp->deleteLater();
|
||||
m_layout->removeWidget(tmp);
|
||||
m_vBtn.remove(i);
|
||||
m_vQuickLaunchBtn.remove(i);
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
|
@ -1210,11 +1230,11 @@ void UKUITaskBar::WindowAddtoTaskBar(QString arg)
|
|||
|
||||
void UKUITaskBar::WindowRemovefromTaskBar(QString arg)
|
||||
{
|
||||
for (auto it = m_vBtn.begin(); it!=m_vBtn.end(); ++it) {
|
||||
for (auto it = m_vQuickLaunchBtn.begin(); it!=m_vQuickLaunchBtn.end(); ++it) {
|
||||
UKUITaskGroup *pQuickBtn = *it;
|
||||
if(pQuickBtn->m_fileName == arg && (m_layout->indexOf(pQuickBtn) >= 0 )) {
|
||||
doInitGroupButton(pQuickBtn->m_fileName);
|
||||
m_vBtn.removeOne(pQuickBtn);
|
||||
if(pQuickBtn->m_desktopName == arg && (m_layout->indexOf(pQuickBtn) >= 0 )) {
|
||||
doInitGroupButton(pQuickBtn->m_desktopName);
|
||||
m_vQuickLaunchBtn.removeOne(pQuickBtn);
|
||||
pQuickBtn->deleteLater();
|
||||
m_layout->removeWidget(pQuickBtn);
|
||||
saveSettings();
|
||||
|
@ -1253,7 +1273,6 @@ void UKUITaskBar::addToTaskbar(QString arg)
|
|||
{
|
||||
const auto url=QUrl(arg);
|
||||
QString fileName(url.isLocalFile() ? url.toLocalFile() : url.url());
|
||||
qDebug()<<"<<<<<<<<<<< taskbar addToTaskbar filename"<<fileName;
|
||||
QFileInfo fi(fileName);
|
||||
XdgDesktopFile xdg;
|
||||
if (xdg.load(fileName)) {
|
||||
|
@ -1284,7 +1303,7 @@ void UKUITaskBar::doInitGroupButton(QString sname)
|
|||
for(auto it= m_knownWindows.begin(); it != m_knownWindows.end();it++) {
|
||||
UKUITaskGroup *group = it.value();
|
||||
if (group->m_existSameQckBtn) {
|
||||
if (sname == group->m_fileName) {
|
||||
if (sname == group->m_desktopName) {
|
||||
group->m_existSameQckBtn = false;
|
||||
group->setQckLchBtn(NULL);
|
||||
break;
|
||||
|
@ -1299,18 +1318,18 @@ void UKUITaskBar::buttonDeleted()
|
|||
if (!btn) {
|
||||
return;
|
||||
}
|
||||
for (auto it = m_vBtn.begin(); it != m_vBtn.end(); it++) {
|
||||
for (auto it = m_vQuickLaunchBtn.begin(); it != m_vQuickLaunchBtn.end(); it++) {
|
||||
if (*it == btn) {
|
||||
for (auto it= m_knownWindows.begin(); it != m_knownWindows.end(); it++) {
|
||||
UKUITaskGroup *group = it.value();
|
||||
if (group->m_existSameQckBtn) {
|
||||
if (btn->m_fileName == group->m_fileName) {
|
||||
if (btn->m_desktopName == group->m_desktopName) {
|
||||
group->m_existSameQckBtn = false;
|
||||
group->setQckLchBtn(NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
m_vBtn.erase(it);
|
||||
m_vQuickLaunchBtn.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1332,7 +1351,7 @@ void UKUITaskBar::saveSettings()
|
|||
int size = m_layout->count();
|
||||
for (int j = 0; j < size; ++j) {
|
||||
UKUITaskGroup *b = qobject_cast<UKUITaskGroup*>(m_layout->itemAt(j)->widget());
|
||||
if (!(m_vBtn.contains(b) || m_knownWindows.contains(m_knownWindows.key(b)))) {
|
||||
if (!(m_vQuickLaunchBtn.contains(b) || m_knownWindows.contains(m_knownWindows.key(b)))) {
|
||||
continue;
|
||||
}
|
||||
if (!b->m_statFlag && b->m_existSameQckBtn) {
|
||||
|
@ -1448,11 +1467,12 @@ void UKUITaskBar::addWindow_wl(QString iconName, QString caption, WId window)
|
|||
}
|
||||
}
|
||||
});
|
||||
QString groupDesktopName = "/usr/share/applications/" + group_id + ".desktop";
|
||||
QString groupDesktopPath = "/usr/share/applications/" + group_id + ".desktop";
|
||||
QString groupDesktopName = groupDesktopPath.section('/', -1, -1);
|
||||
bool isNeedAddNewWidget = true;
|
||||
for (auto it = m_vBtn.begin(); it!=m_vBtn.end(); ++it) {
|
||||
for (auto it = m_vQuickLaunchBtn.begin(); it!=m_vQuickLaunchBtn.end(); ++it) {
|
||||
UKUITaskGroup *pQuickBtn = *it;
|
||||
if(pQuickBtn->m_fileName == groupDesktopName
|
||||
if(pQuickBtn->m_desktopName == groupDesktopName
|
||||
&&(m_layout->indexOf(pQuickBtn) >= 0 )) {
|
||||
m_layout->addWidget(group);
|
||||
m_layout->moveItem(m_layout->indexOf(group), m_layout->indexOf(pQuickBtn));
|
||||
|
@ -1463,7 +1483,8 @@ void UKUITaskBar::addWindow_wl(QString iconName, QString caption, WId window)
|
|||
group->wl_widgetUpdateTitle(caption);
|
||||
group->setToolButtonsStyle(m_buttonStyle);
|
||||
group->setQckLchBtn(pQuickBtn);
|
||||
group->m_fileName = groupDesktopName;
|
||||
group->m_fileName = groupDesktopPath;
|
||||
group->m_desktopName = groupDesktopName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,10 +112,13 @@ public:
|
|||
inline IUKUIPanelPlugin * plugin() const { return m_plugin; }
|
||||
inline UKUITaskBarIcon* fetchIcon()const{return m_taskbarIcon;}
|
||||
void pubAddButton(QuickLaunchAction* action) { addButton(action); }
|
||||
void pubAddToTaskbar(QString desktopPath) { addToTaskbar(desktopPath); }
|
||||
void pubSaveSettings() { saveSettings(); }
|
||||
QString isComputerOrTrash(QString urlName);
|
||||
bool pubCheckIfExist(QString name);
|
||||
bool CheckIfExist(QString arg);
|
||||
bool isQuickLaunchBtn(QString name);
|
||||
bool isKnownWindows(QString desktopName);
|
||||
QString getKnownWindowsDesktopPath(QString desktopName);
|
||||
bool checkIfExist(QString desktopName);
|
||||
bool isDesktopFile(QString urlName);
|
||||
|
||||
///quicklaunch func
|
||||
|
@ -202,7 +205,7 @@ private:
|
|||
TaskStatus m_taskStatus;
|
||||
|
||||
/// quicklaunch parameter
|
||||
QVector<UKUITaskGroup*> m_vBtn;
|
||||
QVector<UKUITaskGroup*> m_vQuickLaunchBtn; //快速启动按钮列表 QuickLaunch
|
||||
QGSettings *m_settings;
|
||||
|
||||
QWidget *m_tmpWidget;
|
||||
|
@ -214,7 +217,7 @@ private:
|
|||
void setMaskPostion();
|
||||
|
||||
private:
|
||||
QMap<WId, UKUITaskGroup*> m_knownWindows; //!< Ids of known windows (mapping to buttons/groups)
|
||||
QMap<WId, UKUITaskGroup*> m_knownWindows; //!< Ids of known windows (mapping to buttons/groups) 未固定的按钮
|
||||
QList <WId> m_swid;
|
||||
UKUi::GridLayout *m_layout;
|
||||
|
||||
|
|
|
@ -101,6 +101,7 @@ public:
|
|||
|
||||
QHash<QString,QString> settingsMap();
|
||||
QString m_fileName;
|
||||
QString m_desktopName;
|
||||
|
||||
void toDoModifyQuicklaunchMenuAction(bool direction) { modifyQuicklaunchMenuAction(direction);}
|
||||
|
||||
|
|
|
@ -101,6 +101,7 @@ UKUITaskGroup::UKUITaskGroup(QuickLaunchAction * act, IUKUIPanelPlugin * plugin,
|
|||
setIconSize(QSize(m_plugin->panel()->iconSize(), m_plugin->panel()->iconSize()));
|
||||
|
||||
m_fileName=act->m_settingsMap["desktop"];
|
||||
m_desktopName = m_fileName.section('/', -1, -1);
|
||||
this->setStyle(new CustomStyle());
|
||||
}
|
||||
|
||||
|
@ -193,6 +194,7 @@ void UKUITaskGroup::initDesktopFileName(int window) {
|
|||
QString processExeName = reply.value();
|
||||
if (!processExeName.isEmpty()) {
|
||||
m_fileName = processExeName;
|
||||
m_desktopName = m_fileName.section('/', -1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -749,51 +751,37 @@ void UKUITaskGroup::mouseMoveEvent(QMouseEvent* event)
|
|||
|
||||
void UKUITaskGroup::dropEvent(QDropEvent *event)
|
||||
{
|
||||
const auto urls = event->mimeData()->urls().toSet();
|
||||
qDebug()<<">>>>>>>>> urls:"<<urls;
|
||||
for (const QUrl &url : urls)
|
||||
{
|
||||
XdgDesktopFile xdg;
|
||||
QString urlName(url.isLocalFile() ? url.toLocalFile() : url.url());
|
||||
qDebug()<<"~~~~~~~~~~~~~~~~ urlname"<<urlName;
|
||||
QFileInfo ur(urlName);
|
||||
QString fileName("/usr/share/applications/");
|
||||
const QSet<QUrl> dragDesktopUrls = event->mimeData()->urls().toSet();
|
||||
//支持拖拽多个图标。对链表遍历,逐个处理
|
||||
for (const QUrl &url : dragDesktopUrls) {
|
||||
bool isHandle = false;
|
||||
//解析dragDesktopUrl 获取 Desktop文件名
|
||||
QString dragDesktopPath(url.isLocalFile() ? url.toLocalFile() : url.url());
|
||||
QString dragDesktopName = dragDesktopPath.section('/', -1, -1);
|
||||
|
||||
fileName.append(urlName.section('/', -1, -1));
|
||||
qDebug()<<">>>>>>>>>>>>>>> fileName:"<<fileName;
|
||||
fileName = m_parent->isComputerOrTrash(urlName);
|
||||
urlName = m_parent->isComputerOrTrash(urlName);
|
||||
|
||||
if (m_parent->pubCheckIfExist(urlName)) return;
|
||||
if (m_parent->pubCheckIfExist(fileName)) return;
|
||||
if (m_parent->isDesktopFile(urlName)) {
|
||||
if (ur.isSymLink()){
|
||||
if (xdg.load(urlName) && xdg.isSuitable()) {
|
||||
if (m_parent->pubCheckIfExist(xdg.fileName())) return;
|
||||
m_parent->pubAddButton(new QuickLaunchAction(&xdg, this));
|
||||
}
|
||||
} else {
|
||||
if (xdg.load(fileName) && xdg.isSuitable()) {
|
||||
if (m_parent->pubCheckIfExist(urlName)) return;
|
||||
m_parent->pubAddButton(new QuickLaunchAction(&xdg, this));
|
||||
// A- 按钮已固定,不作处理
|
||||
if(m_parent->isQuickLaunchBtn(dragDesktopName)) {
|
||||
isHandle = true;
|
||||
break;
|
||||
}
|
||||
// B- 按钮已打开,未固定,做固定按钮操作
|
||||
if(isHandle == false) {
|
||||
if(m_parent->isKnownWindows(dragDesktopName)) {
|
||||
QString desktopPath = m_parent->getKnownWindowsDesktopPath(dragDesktopName);
|
||||
if(!desktopPath.isEmpty()) {
|
||||
m_parent->pubAddToTaskbar(desktopPath);
|
||||
m_parent->realign();
|
||||
isHandle = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//bxq } else if (ur.exists() && ur.isExecutable() && !ur.isDir() || ur.isSymLink()) {
|
||||
// if (ur.size() <= 153600)
|
||||
// xdg.load(urlName);
|
||||
// taskbar->pubAddButton(new QuickLaunchAction(urlName, this));
|
||||
// } else if (ur.exists()) {
|
||||
// if (ur.size() <= 153600)
|
||||
// xdg.load(urlName);
|
||||
// taskbar->pubAddButton(new QuickLaunchAction(urlName, this));
|
||||
// //taskbar->pubAddButton(new QuickLaunchAction(urlName, urlName, "", this));
|
||||
} else {
|
||||
qWarning() << "XdgDesktopFile" << urlName << "is not valid";
|
||||
QMessageBox::information(this, tr("Drop Error"),
|
||||
tr("File/URL '%1' cannot be embedded into QuickLaunch for now").arg(urlName)
|
||||
);
|
||||
}
|
||||
// C- taskbar中没有该按钮, 创建新按钮,固定按钮
|
||||
if(isHandle == false) {
|
||||
m_parent->pubAddToTaskbar(dragDesktopPath);
|
||||
}
|
||||
}
|
||||
|
||||
m_parent->pubSaveSettings();
|
||||
emit t_saveSettings();
|
||||
UKUITaskButton::dropEvent(event);
|
||||
|
|
Loading…
Reference in New Issue