Changeset View
Changeset View
Standalone View
Standalone View
krusader/BookMan/krbookmarkhandler.cpp
Show All 17 Lines | |||||
18 | * You should have received a copy of the GNU General Public License * | 18 | * You should have received a copy of the GNU General Public License * | ||
19 | * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * | 19 | * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * | ||
20 | *****************************************************************************/ | 20 | *****************************************************************************/ | ||
21 | 21 | | |||
22 | #include "krbookmarkhandler.h" | 22 | #include "krbookmarkhandler.h" | ||
23 | #include "kraddbookmarkdlg.h" | 23 | #include "kraddbookmarkdlg.h" | ||
24 | 24 | | |||
25 | #include "../krglobal.h" | 25 | #include "../krglobal.h" | ||
26 | #include "../icon.h" | ||||
26 | #include "../krslots.h" | 27 | #include "../krslots.h" | ||
27 | #include "../kractions.h" | 28 | #include "../kractions.h" | ||
28 | #include "../krmainwindow.h" | 29 | #include "../krmainwindow.h" | ||
29 | #include "../Dialogs/popularurls.h" | 30 | #include "../Dialogs/popularurls.h" | ||
30 | #include "../FileSystem/filesystem.h" | 31 | #include "../FileSystem/filesystem.h" | ||
31 | #include "../Panel/krpanel.h" | 32 | #include "../Panel/krpanel.h" | ||
32 | #include "../Panel/listpanelactions.h" | 33 | #include "../Panel/listpanelactions.h" | ||
33 | 34 | | |||
34 | // QtCore | 35 | // QtCore | ||
35 | #include <QTextStream> | 36 | #include <QTextStream> | ||
36 | #include <QFile> | 37 | #include <QFile> | ||
37 | #include <QEvent> | 38 | #include <QEvent> | ||
38 | #include <QStandardPaths> | 39 | #include <QStandardPaths> | ||
39 | #include <QDebug> | 40 | #include <QDebug> | ||
40 | #include <QTimer> | 41 | #include <QTimer> | ||
41 | // QtGui | 42 | // QtGui | ||
42 | #include <QMouseEvent> | 43 | #include <QMouseEvent> | ||
43 | #include <QCursor> | 44 | #include <QCursor> | ||
44 | 45 | | |||
45 | #include <KConfigCore/KSharedConfig> | 46 | #include <KConfigCore/KSharedConfig> | ||
46 | #include <KI18n/KLocalizedString> | 47 | #include <KI18n/KLocalizedString> | ||
47 | #include <KIconThemes/KIconLoader> | | |||
48 | #include <KWidgetsAddons/KMessageBox> | 48 | #include <KWidgetsAddons/KMessageBox> | ||
49 | #include <KXmlGui/KActionCollection> | 49 | #include <KXmlGui/KActionCollection> | ||
50 | #include <KBookmarks/KBookmarkManager> | 50 | #include <KBookmarks/KBookmarkManager> | ||
51 | 51 | | |||
52 | #define SPECIAL_BOOKMARKS true | 52 | #define SPECIAL_BOOKMARKS true | ||
53 | 53 | | |||
54 | // ------------------------ for internal use | 54 | // ------------------------ for internal use | ||
55 | #define BOOKMARKS_FILE "krusader/krbookmarks.xml" | 55 | #define BOOKMARKS_FILE "krusader/krbookmarks.xml" | ||
▲ Show 20 Lines • Show All 329 Lines • ▼ Show 20 Line(s) | 379 | { | |||
385 | // run the loop twice, in order to put the folders on top. stupid but easy :-) | 385 | // run the loop twice, in order to put the folders on top. stupid but easy :-) | ||
386 | // note: this code drops the separators put there by the user | 386 | // note: this code drops the separators put there by the user | ||
387 | QListIterator<KrBookmark *> it(parent->children()); | 387 | QListIterator<KrBookmark *> it(parent->children()); | ||
388 | while (it.hasNext()) { | 388 | while (it.hasNext()) { | ||
389 | KrBookmark *bm = it.next(); | 389 | KrBookmark *bm = it.next(); | ||
390 | 390 | | |||
391 | if (!bm->isFolder()) continue; | 391 | if (!bm->isFolder()) continue; | ||
392 | QMenu *newMenu = new QMenu(menu); | 392 | QMenu *newMenu = new QMenu(menu); | ||
393 | newMenu->setIcon(QIcon(krLoader->loadIcon(bm->iconName(), KIconLoader::Small))); | 393 | newMenu->setIcon(Icon(bm->iconName())); | ||
394 | newMenu->setTitle(bm->text()); | 394 | newMenu->setTitle(bm->text()); | ||
395 | QAction *menuAction = menu->addMenu(newMenu); | 395 | QAction *menuAction = menu->addMenu(newMenu); | ||
396 | QVariant v; | 396 | QVariant v; | ||
397 | v.setValue<KrBookmark *>(bm); | 397 | v.setValue<KrBookmark *>(bm); | ||
398 | menuAction->setData(v); | 398 | menuAction->setData(v); | ||
399 | 399 | | |||
400 | buildMenu(bm, newMenu, depth + 1); | 400 | buildMenu(bm, newMenu, depth + 1); | ||
401 | } | 401 | } | ||
Show All 19 Lines | 415 | if (depth == 0) { | |||
421 | bool hasJumpback = group.readEntry("BM Jumpback", true); | 421 | bool hasJumpback = group.readEntry("BM Jumpback", true); | ||
422 | 422 | | |||
423 | if (hasPopularURLs) { | 423 | if (hasPopularURLs) { | ||
424 | menu->addSeparator(); | 424 | menu->addSeparator(); | ||
425 | 425 | | |||
426 | // add the popular links submenu | 426 | // add the popular links submenu | ||
427 | QMenu *newMenu = new QMenu(menu); | 427 | QMenu *newMenu = new QMenu(menu); | ||
428 | newMenu->setTitle(i18n("Popular URLs")); | 428 | newMenu->setTitle(i18n("Popular URLs")); | ||
429 | newMenu->setIcon(QIcon(krLoader->loadIcon("folder-bookmark", KIconLoader::Small))); | 429 | newMenu->setIcon(Icon("folder-bookmark")); | ||
430 | QAction *bmfAct = menu->addMenu(newMenu); | 430 | QAction *bmfAct = menu->addMenu(newMenu); | ||
431 | _specialBookmarks.append(bmfAct); | 431 | _specialBookmarks.append(bmfAct); | ||
432 | // add the top 15 urls | 432 | // add the top 15 urls | ||
433 | #define MAX 15 | 433 | #define MAX 15 | ||
434 | QList<QUrl> list = _mainWindow->popularUrls()->getMostPopularUrls(MAX); | 434 | QList<QUrl> list = _mainWindow->popularUrls()->getMostPopularUrls(MAX); | ||
435 | QList<QUrl>::Iterator it; | 435 | QList<QUrl>::Iterator it; | ||
436 | for (it = list.begin(); it != list.end(); ++it) { | 436 | for (it = list.begin(); it != list.end(); ++it) { | ||
437 | QString name; | 437 | QString name; | ||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | 483 | if (hasJumpback) { | |||
506 | addJumpBackAction(true); | 506 | addJumpBackAction(true); | ||
507 | addJumpBackAction(false); | 507 | addJumpBackAction(false); | ||
508 | } | 508 | } | ||
509 | } | 509 | } | ||
510 | 510 | | |||
511 | menu->addSeparator(); | 511 | menu->addSeparator(); | ||
512 | menu->addAction(KrActions::actAddBookmark); | 512 | menu->addAction(KrActions::actAddBookmark); | ||
513 | _specialBookmarks.append(KrActions::actAddBookmark); | 513 | _specialBookmarks.append(KrActions::actAddBookmark); | ||
514 | QAction *bmAct = menu->addAction(krLoader->loadIcon("bookmarks", KIconLoader::Small), | 514 | QAction *bmAct = menu->addAction(Icon("bookmarks"), | ||
515 | i18n("Manage Bookmarks"), manager, SLOT(slotEditBookmarks())); | 515 | i18n("Manage Bookmarks"), manager, SLOT(slotEditBookmarks())); | ||
516 | _specialBookmarks.append(bmAct); | 516 | _specialBookmarks.append(bmAct); | ||
517 | 517 | | |||
518 | // make sure the menu is connected to us | 518 | // make sure the menu is connected to us | ||
519 | disconnect(menu, SIGNAL(triggered(QAction*)), 0, 0); | 519 | disconnect(menu, SIGNAL(triggered(QAction*)), 0, 0); | ||
520 | } | 520 | } | ||
521 | 521 | | |||
522 | menu->installEventFilter(this); | 522 | menu->installEventFilter(this); | ||
▲ Show 20 Lines • Show All 299 Lines • ▼ Show 20 Line(s) | |||||
822 | #define DELETE_ID 100202 | 822 | #define DELETE_ID 100202 | ||
823 | 823 | | |||
824 | void KrBookmarkHandler::rightClicked(QMenu *menu, KrBookmark * bm) | 824 | void KrBookmarkHandler::rightClicked(QMenu *menu, KrBookmark * bm) | ||
825 | { | 825 | { | ||
826 | QMenu popup(_mainBookmarkPopup); | 826 | QMenu popup(_mainBookmarkPopup); | ||
827 | QAction * act; | 827 | QAction * act; | ||
828 | 828 | | |||
829 | if (!bm->isFolder()) { | 829 | if (!bm->isFolder()) { | ||
830 | act = popup.addAction(krLoader->loadIcon("document-open", KIconLoader::Panel), i18n("Open")); | 830 | act = popup.addAction(Icon("document-open"), i18n("Open")); | ||
831 | act->setData(QVariant(OPEN_ID)); | 831 | act->setData(QVariant(OPEN_ID)); | ||
832 | act = popup.addAction(krLoader->loadIcon("tab-new", KIconLoader::Panel), i18n("Open in a new tab")); | 832 | act = popup.addAction(Icon("tab-new"), i18n("Open in a new tab")); | ||
833 | act->setData(QVariant(OPEN_NEW_TAB_ID)); | 833 | act->setData(QVariant(OPEN_NEW_TAB_ID)); | ||
834 | popup.addSeparator(); | 834 | popup.addSeparator(); | ||
835 | } | 835 | } | ||
836 | act = popup.addAction(krLoader->loadIcon("edit-delete", KIconLoader::Panel), i18n("Delete")); | 836 | act = popup.addAction(Icon("edit-delete"), i18n("Delete")); | ||
837 | act->setData(QVariant(DELETE_ID)); | 837 | act->setData(QVariant(DELETE_ID)); | ||
838 | 838 | | |||
839 | connect(menu, SIGNAL(highlighted(int)), &popup, SLOT(close())); | 839 | connect(menu, SIGNAL(highlighted(int)), &popup, SLOT(close())); | ||
840 | connect(menu, SIGNAL(activated(int)), &popup, SLOT(close())); | 840 | connect(menu, SIGNAL(activated(int)), &popup, SLOT(close())); | ||
841 | 841 | | |||
842 | int result = -1; | 842 | int result = -1; | ||
843 | QAction *res = popup.exec(QCursor::pos()); | 843 | QAction *res = popup.exec(QCursor::pos()); | ||
844 | if (res && res->data().canConvert<int> ()) | 844 | if (res && res->data().canConvert<int> ()) | ||
Show All 33 Lines |