mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
context menu using options button on libraries
This commit is contained in:
parent
338eac7d55
commit
350afa3240
@ -26,6 +26,7 @@ YACReaderLibraryItemWidget::YACReaderLibraryItemWidget(QString n/*ame*/, QString
|
||||
options->setFixedWidth(18);
|
||||
options->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Minimum);
|
||||
options->setStyleSheet("QToolButton {border:none;}");
|
||||
connect(options,SIGNAL(pressed()),this,SIGNAL(showOptions()));
|
||||
/*up = new QToolButton(this);
|
||||
up->setIcon(QIcon(":/images/libraryUp.png"));
|
||||
up->setHidden(true);
|
||||
|
@ -19,6 +19,7 @@ public:
|
||||
|
||||
signals:
|
||||
void selected(QString,QString);
|
||||
void showOptions();
|
||||
public slots:
|
||||
void showUpDownButtons(bool show);
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "yacreader_library_item_widget.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QMouseEvent>
|
||||
#include <QMenu>
|
||||
|
||||
YACReaderLibraryListWidget::YACReaderLibraryListWidget(QWidget *parent) :
|
||||
QWidget(parent),currentLibraryIndex(0)
|
||||
@ -19,6 +20,7 @@ void YACReaderLibraryListWidget::addItem(QString name, QString path)
|
||||
QVBoxLayout * mainLayout = dynamic_cast<QVBoxLayout *>(layout());
|
||||
|
||||
YACReaderLibraryItemWidget * library = new YACReaderLibraryItemWidget(name,path,this);
|
||||
connect(library,SIGNAL(showOptions()),this,SLOT(showContextMenu()));
|
||||
librariesList.append(library);
|
||||
|
||||
connect(library,SIGNAL(selected(QString,QString)),this,SIGNAL(librarySelected(QString,QString)));
|
||||
@ -82,7 +84,6 @@ void YACReaderLibraryListWidget::mousePressEvent ( QMouseEvent * event )
|
||||
//deselectAllBut(item);
|
||||
setCurrentIndex(item);
|
||||
emit currentIndexChanged(librariesList.at(item)->name);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -94,4 +95,10 @@ void YACReaderLibraryListWidget::deselectAllBut(int index)
|
||||
if(i!=index)
|
||||
librariesList.at(i)->deselect();
|
||||
}
|
||||
}
|
||||
|
||||
void YACReaderLibraryListWidget::showContextMenu()
|
||||
{
|
||||
YACReaderLibraryItemWidget * itemWidget = librariesList.at(currentLibraryIndex);
|
||||
QMenu::exec(actions(),itemWidget->mapToGlobal(QPoint(itemWidget->width()-8,itemWidget->height()/2)));
|
||||
}
|
@ -22,6 +22,7 @@ public slots:
|
||||
void addItem(QString name, QString path);
|
||||
int currentIndex();
|
||||
void removeItem(int index);
|
||||
void showContextMenu();
|
||||
protected:
|
||||
void mousePressEvent ( QMouseEvent * event );
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user