JKQtExtras
a library of useful Qt widgets and tools
JKQTERecentFilesMenu Class Reference

a special QMenu that allows to manage a list of recently loaded files More...

#include <jkqterecentfilesmenu.h>

Inheritance diagram for JKQTERecentFilesMenu:
Collaboration diagram for JKQTERecentFilesMenu:

Public Slots

void setMenuEnabled (bool enabled)
 

Signals

void openRecentFile (const QString &filename)
 emitted when the user clicks one of the recent files in the menu. More...
 

Public Member Functions

 JKQTERecentFilesMenu (QWidget *parent=0)
 
void addRecentFile (const QString &filename)
 add a new file to the list of recent files More...
 
void clearRecentFiles ()
 clear all recent files More...
 
bool doesShowIcons () const
 show icons next to the recent files More...
 
int maxRecentFilesCount () const
 returns the max. number of files in the list More...
 
void readSettings (QSettings &settings, QString prefix=QString(""))
 read the list of recent files from a QSettings object. More...
 
void setAlwaysEnabled (bool enabled)
 
void setDefaultIcon (const QIcon &defaultIcon)
 set the default icon More...
 
void setIconForExtension (const QString &extension, const QIcon &icon)
 register an icon for a given filetype this overrides the display of system icons More...
 
void setMaxRecentFilesCount (int num)
 set the max. number of files in the list More...
 
void setShowIcons (bool enabled)
 show icons next to the recent files More...
 
void setUseSystemFileIcons (bool use)
 use file icons from system More...
 
void storeSettings (QSettings &settings, QString prefix=QString(""))
 save the list of recent files into a QSettings object. More...
 

Protected Slots

void intOpenRecentFile ()
 
void updateActions ()
 

Protected Member Functions

QIcon iconForFile (const QFileInfo &fileinfo)
 
QString strippedName (const QString &fullFileName)
 

Protected Attributes

bool alwaysDisabled
 
QFileIconProvider iconProvider
 
QList< QAction * > m_actions
 
bool m_alwaysEnabled
 
QIcon m_defaultIcon
 
QMap< QString, QIcon > m_fileIcons
 
QStringList m_files
 
bool m_icons
 
bool m_useSystemFileIcons
 

Detailed Description

a special QMenu that allows to manage a list of recently loaded files

Usage example:

// add recent files menu to existing menu bar
ui->menubar->addMenu(menuRecent);
// set max. number of entires
menuRecent->setMaxRecentFilesCount(10);
// add some file
menuRecent->addRecentFile(QApplication::instance()->applicationFilePath());

Constructor & Destructor Documentation

◆ JKQTERecentFilesMenu()

JKQTERecentFilesMenu::JKQTERecentFilesMenu ( QWidget *  parent = 0)
explicit

Member Function Documentation

◆ addRecentFile()

void JKQTERecentFilesMenu::addRecentFile ( const QString &  filename)

add a new file to the list of recent files

◆ clearRecentFiles()

void JKQTERecentFilesMenu::clearRecentFiles ( )

clear all recent files

◆ doesShowIcons()

bool JKQTERecentFilesMenu::doesShowIcons ( ) const

show icons next to the recent files

◆ iconForFile()

QIcon JKQTERecentFilesMenu::iconForFile ( const QFileInfo &  fileinfo)
protected

◆ intOpenRecentFile

void JKQTERecentFilesMenu::intOpenRecentFile ( )
protectedslot

◆ maxRecentFilesCount()

int JKQTERecentFilesMenu::maxRecentFilesCount ( ) const

returns the max. number of files in the list

◆ openRecentFile

void JKQTERecentFilesMenu::openRecentFile ( const QString &  filename)
signal

emitted when the user clicks one of the recent files in the menu.

◆ readSettings()

void JKQTERecentFilesMenu::readSettings ( QSettings &  settings,
QString  prefix = QString("") 
)

read the list of recent files from a QSettings object.

The settings are saved under the key [prefix] + "recentfilelist"

◆ setAlwaysEnabled()

void JKQTERecentFilesMenu::setAlwaysEnabled ( bool  enabled)

◆ setDefaultIcon()

void JKQTERecentFilesMenu::setDefaultIcon ( const QIcon &  defaultIcon)

set the default icon

◆ setIconForExtension()

void JKQTERecentFilesMenu::setIconForExtension ( const QString &  extension,
const QIcon &  icon 
)

register an icon for a given filetype this overrides the display of system icons

◆ setMaxRecentFilesCount()

void JKQTERecentFilesMenu::setMaxRecentFilesCount ( int  num)

set the max. number of files in the list

◆ setMenuEnabled

void JKQTERecentFilesMenu::setMenuEnabled ( bool  enabled)
slot

◆ setShowIcons()

void JKQTERecentFilesMenu::setShowIcons ( bool  enabled)

show icons next to the recent files

◆ setUseSystemFileIcons()

void JKQTERecentFilesMenu::setUseSystemFileIcons ( bool  use)

use file icons from system

◆ storeSettings()

void JKQTERecentFilesMenu::storeSettings ( QSettings &  settings,
QString  prefix = QString("") 
)

save the list of recent files into a QSettings object.

The settings are saved under the key [prefix] + "recentfilelist"

◆ strippedName()

QString JKQTERecentFilesMenu::strippedName ( const QString &  fullFileName)
protected

◆ updateActions

void JKQTERecentFilesMenu::updateActions ( )
protectedslot

Member Data Documentation

◆ alwaysDisabled

bool JKQTERecentFilesMenu::alwaysDisabled
protected

◆ iconProvider

QFileIconProvider JKQTERecentFilesMenu::iconProvider
protected

◆ m_actions

QList<QAction*> JKQTERecentFilesMenu::m_actions
protected

◆ m_alwaysEnabled

bool JKQTERecentFilesMenu::m_alwaysEnabled
protected

◆ m_defaultIcon

QIcon JKQTERecentFilesMenu::m_defaultIcon
protected

◆ m_fileIcons

QMap<QString, QIcon> JKQTERecentFilesMenu::m_fileIcons
protected

◆ m_files

QStringList JKQTERecentFilesMenu::m_files
protected

◆ m_icons

bool JKQTERecentFilesMenu::m_icons
protected

◆ m_useSystemFileIcons

bool JKQTERecentFilesMenu::m_useSystemFileIcons
protected

The documentation for this class was generated from the following file:
JKQTERecentFilesMenu::setMaxRecentFilesCount
void setMaxRecentFilesCount(int num)
set the max. number of files in the list
JKQTERecentFilesMenu::JKQTERecentFilesMenu
JKQTERecentFilesMenu(QWidget *parent=0)
JKQTERecentFilesMenu::addRecentFile
void addRecentFile(const QString &filename)
add a new file to the list of recent files
JKQTERecentFilesMenu
a special QMenu that allows to manage a list of recently loaded files
Definition: jkqterecentfilesmenu.h:37