Changeset View
Changeset View
Standalone View
Standalone View
treeview.cpp
Show All 35 Lines | |||||
36 | #include <QtDBus> | 36 | #include <QtDBus> | ||
37 | #include <QSignalMapper> | 37 | #include <QSignalMapper> | ||
38 | 38 | | |||
39 | #include <QAction> | 39 | #include <QAction> | ||
40 | #include <KActionCollection> | 40 | #include <KActionCollection> | ||
41 | #include <KBuildSycocaProgressDialog> | 41 | #include <KBuildSycocaProgressDialog> | ||
42 | #include "kmenuedit_debug.h" | 42 | #include "kmenuedit_debug.h" | ||
43 | #include <KDesktopFile> | 43 | #include <KDesktopFile> | ||
44 | #include <KGlobal> | | |||
45 | #include <KIconLoader> | 44 | #include <KIconLoader> | ||
46 | #include <KInputDialog> | 45 | #include <KInputDialog> | ||
47 | #include <KLocalizedString> | 46 | #include <KLocalizedString> | ||
48 | #include <KMessageBox> | 47 | #include <KMessageBox> | ||
49 | #include <KService> | 48 | #include <KService> | ||
50 | #include <KServiceGroup> | 49 | #include <KServiceGroup> | ||
51 | #include <KConfig> | 50 | #include <KConfig> | ||
52 | #include <KConfigGroup> | 51 | #include <KConfigGroup> | ||
53 | #include <KStandardDirs> | | |||
54 | #include <kio/netaccess.h> | | |||
55 | #include <KUrlMimeData> | 52 | #include <KUrlMimeData> | ||
56 | #include <KUrl> | 53 | #include <KUrl> | ||
57 | #include <KStringHandler> | 54 | #include <KStringHandler> | ||
55 | #include <QStandardPaths> | ||||
58 | 56 | | |||
59 | #include "menufile.h" | 57 | #include "menufile.h" | ||
60 | #include "menuinfo.h" | 58 | #include "menuinfo.h" | ||
61 | 59 | | |||
62 | #define MOVE_FOLDER 'M' | 60 | #define MOVE_FOLDER 'M' | ||
63 | #define COPY_FOLDER 'C' | 61 | #define COPY_FOLDER 'C' | ||
64 | #define MOVE_FILE 'm' | 62 | #define MOVE_FILE 'm' | ||
65 | #define COPY_FILE 'c' | 63 | #define COPY_FILE 'c' | ||
▲ Show 20 Lines • Show All 214 Lines • ▼ Show 20 Line(s) | 236 | { | |||
280 | // connect moving up/down actions | 278 | // connect moving up/down actions | ||
281 | connect(m_ac->action(MOVE_UP_ACTION_NAME), &QAction::triggered, this, &TreeView::moveUpItem); | 279 | connect(m_ac->action(MOVE_UP_ACTION_NAME), &QAction::triggered, this, &TreeView::moveUpItem); | ||
282 | connect(m_ac->action(MOVE_DOWN_ACTION_NAME), &QAction::triggered, this, &TreeView::moveDownItem); | 280 | connect(m_ac->action(MOVE_DOWN_ACTION_NAME), &QAction::triggered, this, &TreeView::moveDownItem); | ||
283 | 281 | | |||
284 | // listen for selection | 282 | // listen for selection | ||
285 | connect(this, &QTreeWidget::currentItemChanged, | 283 | connect(this, &QTreeWidget::currentItemChanged, | ||
286 | this, &TreeView::itemSelected); | 284 | this, &TreeView::itemSelected); | ||
287 | 285 | | |||
288 | m_menuFile = new MenuFile(KStandardDirs::locateLocal("xdgconf-menu", QStringLiteral("applications-kmenuedit.menu"))); | 286 | m_menuFile = new MenuFile(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QLatin1String("/menus/") + QStringLiteral("applications-kmenuedit.menu")); | ||
289 | m_rootFolder = new MenuFolderInfo; | 287 | m_rootFolder = new MenuFolderInfo; | ||
290 | m_separator = new MenuSeparatorInfo; | 288 | m_separator = new MenuSeparatorInfo; | ||
291 | } | 289 | } | ||
292 | 290 | | |||
293 | TreeView::~TreeView() | 291 | TreeView::~TreeView() | ||
294 | { | 292 | { | ||
295 | cleanupClipboard(); | 293 | cleanupClipboard(); | ||
296 | delete m_rootFolder; | 294 | delete m_rootFolder; | ||
▲ Show 20 Lines • Show All 464 Lines • ▼ Show 20 Line(s) | 752 | { | |||
761 | { | 759 | { | ||
762 | if (i == 1) { | 760 | if (i == 1) { | ||
763 | result = base + QStringLiteral(".directory"); | 761 | result = base + QStringLiteral(".directory"); | ||
764 | } else { | 762 | } else { | ||
765 | result = base + QStringLiteral("-%1.directory").arg(i); | 763 | result = base + QStringLiteral("-%1.directory").arg(i); | ||
766 | } | 764 | } | ||
767 | 765 | | |||
768 | if (!excludeList->contains(result)) { | 766 | if (!excludeList->contains(result)) { | ||
769 | if (KStandardDirs::locate("xdgdata-dirs", result).isEmpty()) { | 767 | if (QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("desktop-directories/") + result).isEmpty()) { | ||
770 | break; | 768 | break; | ||
771 | } | 769 | } | ||
772 | } | 770 | } | ||
773 | i++; | 771 | i++; | ||
774 | } | 772 | } | ||
775 | excludeList->append(result); | 773 | excludeList->append(result); | ||
776 | result = KStandardDirs::locateLocal("xdgdata-dirs", result); | 774 | result = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/desktop-directories/") + result; | ||
777 | return result; | 775 | return result; | ||
778 | } | 776 | } | ||
779 | 777 | | |||
780 | bool TreeView::dropMimeData(QTreeWidgetItem *item, int index, const QMimeData *data, Qt::DropAction action) | 778 | bool TreeView::dropMimeData(QTreeWidgetItem *item, int index, const QMimeData *data, Qt::DropAction action) | ||
781 | { | 779 | { | ||
782 | // get destination folder | 780 | // get destination folder | ||
783 | TreeItem *titem = item ? dynamic_cast<TreeItem *>(item) : nullptr; | 781 | TreeItem *titem = item ? dynamic_cast<TreeItem *>(item) : nullptr; | ||
784 | if (item && !titem) { | 782 | if (item && !titem) { | ||
▲ Show 20 Lines • Show All 982 Lines • ▼ Show 20 Line(s) | 1764 | { | |||
1767 | service = m_rootFolder->findServiceShortcut(cut); | 1765 | service = m_rootFolder->findServiceShortcut(cut); | ||
1768 | } | 1766 | } | ||
1769 | 1767 | | |||
1770 | void TreeView::restoreMenuSystem() | 1768 | void TreeView::restoreMenuSystem() | ||
1771 | { | 1769 | { | ||
1772 | if (KMessageBox::warningYesNo(this, i18n("Do you want to restore the system menu? Warning: This will remove all custom menus.")) == KMessageBox::No) { | 1770 | if (KMessageBox::warningYesNo(this, i18n("Do you want to restore the system menu? Warning: This will remove all custom menus.")) == KMessageBox::No) { | ||
1773 | return; | 1771 | return; | ||
1774 | } | 1772 | } | ||
1775 | QString kmenueditfile = KStandardDirs::locateLocal("xdgconf-menu", QStringLiteral("applications-kmenuedit.menu")); | 1773 | const QString kmenueditfile = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QLatin1String("/menus/applications-kmenuedit.menu"); | ||
1776 | if (QFile::exists(kmenueditfile)) { | 1774 | if (QFile::exists(kmenueditfile)) { | ||
1777 | if (!QFile::remove(kmenueditfile)) { | 1775 | if (!QFile::remove(kmenueditfile)) { | ||
1778 | qCWarning(KMENUEDIT_LOG)<<"Could not delete "<<kmenueditfile; | 1776 | qCWarning(KMENUEDIT_LOG)<<"Could not delete "<<kmenueditfile; | ||
1779 | } | 1777 | } | ||
1780 | } | 1778 | } | ||
1781 | 1779 | | |||
1782 | QString xdgdir = KGlobal::dirs()->KStandardDirs::localxdgdatadir(); | 1780 | const QString xdgappsdir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/applications"); | ||
1783 | if (!KIO::NetAccess::del(QUrl::fromLocalFile(xdgdir + QStringLiteral("/applications")), this)) { | 1781 | if (QFileInfo(xdgappsdir).isDir()) { | ||
1784 | qCWarning(KMENUEDIT_LOG)<<"Could not delete dir :"<<(xdgdir+ QStringLiteral("/applications")); | 1782 | if (!QDir(xdgappsdir).removeRecursively()) { | ||
1783 | qCWarning(KMENUEDIT_LOG)<<"Could not delete dir :" << xdgappsdir; | ||||
1784 | } | ||||
1785 | } | ||||
1786 | const QString xdgdesktopdir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/desktop-directories"); | ||||
1787 | if (QFileInfo(xdgdesktopdir).isDir()) { | ||||
1788 | if (!QDir(xdgdesktopdir).removeRecursively()) { | ||||
1789 | qCWarning(KMENUEDIT_LOG)<<"Could not delete dir :" << xdgdesktopdir; | ||||
1785 | } | 1790 | } | ||
1786 | if (!KIO::NetAccess::del(QUrl::fromLocalFile(xdgdir + QStringLiteral("/desktop-directories")), this)) { | | |||
1787 | qCWarning(KMENUEDIT_LOG)<<"Could not delete dir :"<<(xdgdir + QStringLiteral("/desktop-directories")); | | |||
1788 | } | 1791 | } | ||
1789 | 1792 | | |||
1790 | KBuildSycocaProgressDialog::rebuildKSycoca(this); | 1793 | KBuildSycocaProgressDialog::rebuildKSycoca(this); | ||
1791 | clear(); | 1794 | clear(); | ||
1792 | cleanupClipboard(); | 1795 | cleanupClipboard(); | ||
1793 | delete m_rootFolder; | 1796 | delete m_rootFolder; | ||
1794 | delete m_separator; | 1797 | delete m_separator; | ||
1795 | 1798 | | |||
▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines |