Skip to content
Snippets Groups Projects
Commit 07d9e11b authored by stefan's avatar stefan
Browse files

info_widget, added context menu

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2602 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent 301f66ba
No related branches found
No related tags found
No related merge requests found
modules/gui/share/icons/delete_icon.png

769 B | W: | H:

modules/gui/share/icons/delete_icon.png

687 B | W: | H:

modules/gui/share/icons/delete_icon.png
modules/gui/share/icons/delete_icon.png
modules/gui/share/icons/delete_icon.png
modules/gui/share/icons/delete_icon.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -19,9 +19,10 @@
/*
Author: Stefan Scheuber
*/
#include <QApplication>
#include <QDir>
#include <QMenu>
#include <QVBoxLayout>
#include <QApplication>
#include <ost/platform.hh>
......@@ -30,7 +31,8 @@
#include "info_widget.hh"
namespace ost { namespace gui {
namespace ost {
namespace gui {
class InfoWidgetFactory: public WidgetFactory {
public:
......@@ -45,7 +47,9 @@ public:
OST_REGISTER_WIDGET(InfoWidget, InfoWidgetFactory);
InfoWidget::InfoWidget(QWidget* parent) : Widget(NULL, parent), model_(new QStandardItemModel(this)), view_(new QListView(this)) {
InfoWidget::InfoWidget(QWidget* parent) :
Widget(NULL, parent), model_(new QStandardItemModel(this)), view_(
new QListView(this)) {
QVBoxLayout* layout = new QVBoxLayout(this);
layout->setMargin(0);
layout->setSpacing(0);
......@@ -54,9 +58,12 @@ InfoWidget::InfoWidget(QWidget* parent) : Widget(NULL, parent), model_(new QStan
view_->setModel(model_);
view_->setSelectionBehavior(QAbstractItemView::SelectRows);
view_->setDragEnabled(true);
view_->setContextMenuPolicy(Qt::CustomContextMenu);
layout->addWidget(view_);
connect(view_, SIGNAL(customContextMenuRequested(const QPoint&)), this,
SLOT(ContextMenuRequested(const QPoint&)));
QDir icon_path(GetSharedDataPath().c_str());
icon_path.cd("gui");
......@@ -64,7 +71,8 @@ InfoWidget::InfoWidget(QWidget* parent) : Widget(NULL, parent), model_(new QStan
QAction* clear_action = new QAction(this);
clear_action->setToolTip("Clear info panel");
clear_action->setIcon(QIcon(icon_path.absolutePath()+QDir::separator()+QString("delete_icon.png")));
clear_action->setIcon(QIcon(icon_path.absolutePath() + QDir::separator()
+ QString("delete_icon.png")));
connect(clear_action, SIGNAL(triggered(bool)), this, SLOT(Clear()));
this->actions_.append(clear_action);
}
......@@ -92,8 +100,7 @@ void InfoWidget::LogMessage(const QString& message, QIcon icon){
this->model_->appendRow(item);
}
QPixmap InfoWidget::GetIcon(QMessageBox::Icon icon, QWidget* widget)
{
QPixmap InfoWidget::GetIcon(QMessageBox::Icon icon, QWidget* widget) {
QStyle *style = widget ? widget->style() : QApplication::style();
int icon_size = style->pixelMetric(QStyle::PM_MessageBoxIconSize, 0, widget);
QIcon tmp_icon;
......@@ -134,6 +141,20 @@ ActionList InfoWidget::GetActions(){
return this->actions_;
}
void InfoWidget::ContextMenuRequested(const QPoint& pos) {
QAction* remove_selected_action = new QAction("Remove", this);
remove_selected_action->setToolTip("Remove this item");
connect(remove_selected_action, SIGNAL(triggered(bool)), this,
SLOT(RemoveSelected()));
QMenu* menu = new QMenu();
menu->addAction(remove_selected_action);
if (menu->actions().size() > 0) {
menu->popup(view_->viewport()->mapToGlobal(pos));
}
}
InfoWidget::~InfoWidget() {
}
......
......
......@@ -59,6 +59,9 @@ public slots:
void RemoveSelected();
void Update();
private slots:
void ContextMenuRequested(const QPoint& pos);
private:
QPixmap GetIcon(QMessageBox::Icon icon, QWidget* widget);
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment