mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
added support for checkable items in nstoolbar //TODO find a better UI desing?
This commit is contained in:
parent
d03fc902a1
commit
1ae1f04eb7
@ -29,6 +29,23 @@ signals:
|
||||
void filterChanged(YACReader::SearchModifiers, QString);
|
||||
};
|
||||
|
||||
class MacToolBarItemWrapper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MacToolBarItemWrapper(QAction * action, QMacToolBarItem * toolbaritem);
|
||||
|
||||
public slots:
|
||||
void actionToggled(bool toogled);
|
||||
|
||||
private:
|
||||
QAction * action;
|
||||
QMacToolBarItem * toolbaritem;
|
||||
|
||||
void updateIcon(bool checked);
|
||||
};
|
||||
|
||||
|
||||
class YACReaderMacOSXToolbar : public QMacToolBar
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -190,8 +190,12 @@ void YACReaderMacOSXToolbar::addAction(QAction *action)
|
||||
if(action->data().toString() == TOGGLE_COMICS_VIEW_ACTION_YL)
|
||||
viewSelector = toolBarItem;
|
||||
connect(toolBarItem,SIGNAL(activated()),action, SIGNAL(triggered()));
|
||||
|
||||
NSToolbarItem * nativeItem = toolBarItem->nativeToolBarItem();
|
||||
actions.insert(QString::fromNSString(nativeItem.itemIdentifier),action);
|
||||
|
||||
MacToolBarItemWrapper * wrapper = new MacToolBarItemWrapper(action,toolBarItem);
|
||||
//wrapper->actionToogled(true);
|
||||
}
|
||||
|
||||
void YACReaderMacOSXToolbar::addDropDownItem(const QList<QAction *> &actions, const QAction *defaultAction)
|
||||
@ -325,3 +329,37 @@ void YACReaderMacOSXSearchLineEdit::setEnabled(bool enabled)
|
||||
{
|
||||
[((NSTextField *)nstextfield) setEnabled:enabled];
|
||||
}
|
||||
|
||||
|
||||
MacToolBarItemWrapper::MacToolBarItemWrapper(QAction *action, QMacToolBarItem *toolbaritem)
|
||||
:action(action),toolbaritem(toolbaritem)
|
||||
{
|
||||
if(action->isCheckable())
|
||||
{
|
||||
connect(action,SIGNAL(toggled(bool)),this,SLOT(actionToggled(bool)));
|
||||
connect(toolbaritem,SIGNAL(activated()), action, SLOT(toggle()));
|
||||
updateIcon(action->isChecked());
|
||||
}
|
||||
}
|
||||
|
||||
void MacToolBarItemWrapper::actionToggled(bool toogled)
|
||||
{
|
||||
updateIcon(toogled);
|
||||
}
|
||||
|
||||
void MacToolBarItemWrapper::updateIcon(bool enabled)
|
||||
{
|
||||
if(enabled)
|
||||
{
|
||||
QIcon icon = action->icon();
|
||||
QPixmap tempPixmap = icon.pixmap(QSize(24,24));
|
||||
QPainter painter;
|
||||
painter.begin(&tempPixmap);
|
||||
painter.fillRect(QRect(3,22,18,2),QColor("#EBBE00"));
|
||||
painter.end();
|
||||
|
||||
toolbaritem->setIcon(QIcon(tempPixmap));
|
||||
}
|
||||
else
|
||||
toolbaritem->setIcon(action->icon());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user