Krita Source Code Documentation
Loading...
Searching...
No Matches
KRecentFilesActionPrivate Class Reference

#include <krecentfilesaction_p.h>

Public Member Functions

void _k_urlSelected (QAction *)
 
void init ()
 
 KRecentFilesActionPrivate (KRecentFilesAction *parent)
 
void updateIcon (const QStandardItem *item)
 
virtual ~KRecentFilesActionPrivate ()
 

Public Attributes

QAction * clearAction
 
QAction * clearSeparator
 
bool m_fileIconsPopulated
 
QAction * m_noEntriesAction
 
const QStandardItemModel * m_recentFilesModel
 
QMap< QAction *, QUrl > m_urls
 
int m_visibleItemsCount
 
KRecentFilesActionq_ptr
 

Detailed Description

Definition at line 21 of file krecentfilesaction_p.h.

Constructor & Destructor Documentation

◆ KRecentFilesActionPrivate()

KRecentFilesActionPrivate::KRecentFilesActionPrivate ( KRecentFilesAction * parent)
inline

◆ ~KRecentFilesActionPrivate()

virtual KRecentFilesActionPrivate::~KRecentFilesActionPrivate ( )
inlinevirtual

Definition at line 37 of file krecentfilesaction_p.h.

38 {
39 }

Member Function Documentation

◆ _k_urlSelected()

void KRecentFilesActionPrivate::_k_urlSelected ( QAction * action)

Definition at line 140 of file krecentfilesaction.cpp.

141{
143 Q_EMIT q->urlSelected(m_urls[action]);
144}
QMap< QAction *, QUrl > m_urls
Recent files action.

References m_urls.

◆ init()

void KRecentFilesActionPrivate::init ( )

Definition at line 84 of file krecentfilesaction.cpp.

85{
87 delete q->menu();
88 q->setMenu(new QMenu());
89 q->setToolBarMode(KSelectAction::MenuMode);
90 m_noEntriesAction = q->menu()->addAction(i18n("No Entries"));
91 m_noEntriesAction->setObjectName(QLatin1String("no_entries"));
92 m_noEntriesAction->setEnabled(false);
93 clearSeparator = q->menu()->addSeparator();
94 clearSeparator->setVisible(false);
95 clearSeparator->setObjectName(QLatin1String("separator"));
96 clearAction = q->menu()->addAction(i18n("Clear List"), q, SLOT(clearActionTriggered()));
97 clearAction->setObjectName(QLatin1String("clear_action"));
98 clearAction->setVisible(false);
99 q->setEnabled(false);
100#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
101 q->connect(q, SIGNAL(triggered(QAction*)), SLOT(_k_urlSelected(QAction*)));
102#else
103 q->connect(q, SIGNAL(actionTriggered(QAction*)), SLOT(_k_urlSelected(QAction*)));
104#endif
105 QString baseStyleName = q->menu()->style()->objectName();
106 if (baseStyleName != QLatin1String("windows")) {
107 // Force Fusion theme because other themes like Breeze doesn't
108 // work well with QProxyStyle, may result in small icons.
109 baseStyleName = QStringLiteral("fusion");
110 }
111 QStyle *baseStyle = QStyleFactory::create(baseStyleName);
112 QStyle *newStyle = new KRecentFilesIconProxyStyle(baseStyle);
113 newStyle->setParent(q->menu());
114 q->menu()->setStyle(newStyle);
115
116 q->connect(q->menu(),
117 SIGNAL(aboutToShow()),
118 SLOT(menuAboutToShow()));
119
121 SIGNAL(fileAdded(const QUrl &)),
122 SLOT(fileAdded(const QUrl &)));
124 SIGNAL(fileRemoved(const QUrl &)),
125 SLOT(fileRemoved(const QUrl &)));
127 SIGNAL(listRenewed()),
128 SLOT(listRenewed()));
129
130 // We have to manually trigger the initial load because
131 // KisRecentFilesManager is initialized earlier than this.
132 q->rebuildEntries();
133}
static KisRecentFilesManager * instance()

References _k_urlSelected(), clearAction, clearSeparator, KisRecentFilesManager::instance(), and m_noEntriesAction.

◆ updateIcon()

void KRecentFilesActionPrivate::updateIcon ( const QStandardItem * item)

Definition at line 146 of file krecentfilesaction.cpp.

147{
148 if (!item) {
149 return;
150 }
151 const QUrl url = item->data().toUrl();
152 if (!url.isValid()) {
153 return;
154 }
155 QAction *action = m_urls.key(url);
156 if (!action) {
157 return;
158 }
159 const QIcon icon = item->icon();
160 if (icon.isNull()) {
161 return;
162 }
163 action->setIcon(icon);
164 action->setIconVisibleInMenu(true);
165}

References m_urls.

Member Data Documentation

◆ clearAction

QAction* KRecentFilesActionPrivate::clearAction

Definition at line 51 of file krecentfilesaction_p.h.

◆ clearSeparator

QAction* KRecentFilesActionPrivate::clearSeparator

Definition at line 50 of file krecentfilesaction_p.h.

◆ m_fileIconsPopulated

bool KRecentFilesActionPrivate::m_fileIconsPopulated

Definition at line 53 of file krecentfilesaction_p.h.

◆ m_noEntriesAction

QAction* KRecentFilesActionPrivate::m_noEntriesAction

Definition at line 49 of file krecentfilesaction_p.h.

◆ m_recentFilesModel

const QStandardItemModel* KRecentFilesActionPrivate::m_recentFilesModel

Definition at line 52 of file krecentfilesaction_p.h.

◆ m_urls

QMap<QAction *, QUrl> KRecentFilesActionPrivate::m_urls

Definition at line 48 of file krecentfilesaction_p.h.

◆ m_visibleItemsCount

int KRecentFilesActionPrivate::m_visibleItemsCount

Definition at line 47 of file krecentfilesaction_p.h.

◆ q_ptr

KRecentFilesAction* KRecentFilesActionPrivate::q_ptr

Definition at line 55 of file krecentfilesaction_p.h.


The documentation for this class was generated from the following files: