diff options
Diffstat (limited to 'krusader/BookMan/krbookmarkbutton.cpp')
-rw-r--r-- | krusader/BookMan/krbookmarkbutton.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/krusader/BookMan/krbookmarkbutton.cpp b/krusader/BookMan/krbookmarkbutton.cpp new file mode 100644 index 0000000..08d13a5 --- /dev/null +++ b/krusader/BookMan/krbookmarkbutton.cpp @@ -0,0 +1,38 @@ +#include "krbookmarkbutton.h" +#include "krbookmarkhandler.h" +#include "../krusader.h" +#include <qpixmap.h> +#include <kiconloader.h> +#include <kaction.h> +#include <klocale.h> +#include <kpopupmenu.h> +#include <kdebug.h> + +KrBookmarkButton::KrBookmarkButton(QWidget *parent): QToolButton(parent) { + QPixmap icon = krLoader->loadIcon("bookmark", KIcon::Toolbar, 16); + setFixedSize(icon.width() + 4, icon.height() + 4); + setPixmap(icon); + setTextLabel(i18n("BookMan II"), true); + setPopupDelay(10); // 0.01 seconds press + setAcceptDrops(false); + + acmBookmarks = new KActionMenu(i18n("Bookmarks"), "bookmark", 0, 0); + acmBookmarks->setDelayed(false); + acmBookmarks->popupMenu()->setKeyboardShortcutsEnabled(true); + acmBookmarks->popupMenu()->setKeyboardShortcutsExecute(true); + + setPopup(acmBookmarks->popupMenu()); + connect(this, SIGNAL(pressed()), this, SLOT(populate())); + populate(); +} + +void KrBookmarkButton::populate() { + krBookMan->populate(static_cast<KPopupMenu*>(popup())); +} + +void KrBookmarkButton::openPopup() { + populate(); + popup()->exec(mapToGlobal(QPoint(0, height()))); +} + +#include "krbookmarkbutton.moc" |