MCPcopy Create free account
hub / github.com/davy7125/polyphone / DirectorySortMenu

Method DirectorySortMenu

sources/directory/directorysortmenu.cpp:31–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29#include <QMouseEvent>
30
31DirectorySortMenu::DirectorySortMenu(QWidget *parent) :
32 QWidget(parent),
33 ui(new Ui::DirectorySortMenu)
34{
35 ui->setupUi(this);
36
37 // Style
38 _textColor = ContextManager::theme()->getColor(ThemeManager::HIGHLIGHTED_BACKGROUND).name();
39 _backgroundColor = ContextManager::theme()->getColor(ThemeManager::HIGHLIGHTED_TEXT).name();
40 _hoveredBackgroundColor = ContextManager::theme()->getColor(ThemeManager::HIGHLIGHTED_TEXT, ThemeManager::HOVERED).name();
41 ui->labelSort->setPixmap(ContextManager::theme()->getColoredSvg(":/icons/sort.svg", QSize(16, 16), ThemeManager::HIGHLIGHTED_BACKGROUND));
42 this->setStyle(false);
43
44 // Icon
45 _checkIcon.addPixmap(ContextManager::theme()->getColoredSvg(":/icons/check.svg", QSize(24, 24), ThemeManager::LIST_TEXT), QIcon::Normal);
46 _checkIcon.addPixmap(ContextManager::theme()->getColoredSvg(":/icons/check.svg", QSize(24, 24), ThemeManager::HIGHLIGHTED_TEXT), QIcon::Active);
47
48 // Add a menu to the button
49 int currentSort = ContextManager::configuration()->getValue(ConfManager::SECTION_DISPLAY, "directory_browser_sort", 0).toInt();
50 if (currentSort < 0 || currentSort > 3)
51 currentSort = 0;
52 QMenu * menu = new QMenu(this);
53 connect(menu, SIGNAL(aboutToHide()), this, SLOT(onMenuClosed()));
54 menu->setStyleSheet(ContextManager::theme()->getMenuTheme());
55 QAction * action = menu->addAction(tr("Name (A→Z)"));
56 if (currentSort == 0)
57 {
58 action->setIcon(_checkIcon);
59 ui->pushButton->setText(action->text());
60 }
61 connect(action, SIGNAL(triggered()), this, SLOT(element1Clicked()));
62 action = menu->addAction(tr("Newest first"));
63 if (currentSort == 1)
64 {
65 action->setIcon(_checkIcon);
66 ui->pushButton->setText(action->text());
67 }
68 connect(action, SIGNAL(triggered()), this, SLOT(element2Clicked()));
69 action = menu->addAction(tr("Largest first"));
70 if (currentSort == 2)
71 {
72 action->setIcon(_checkIcon);
73 ui->pushButton->setText(action->text());
74 }
75 connect(action, SIGNAL(triggered()), this, SLOT(element3Clicked()));
76 action = menu->addAction(tr("Smallest first"));
77 if (currentSort == 3)
78 {
79 action->setIcon(_checkIcon);
80 ui->pushButton->setText(action->text());
81 }
82 connect(action, SIGNAL(triggered()), this, SLOT(element4Clicked()));
83 ui->pushButton->setMenu(menu);
84}
85
86DirectorySortMenu::~DirectorySortMenu()
87{

Callers

nothing calls this directly

Calls 7

setStyleMethod · 0.95
getColoredSvgMethod · 0.80
toIntMethod · 0.80
getMenuThemeMethod · 0.80
setTextMethod · 0.80
getColorMethod · 0.45
getValueMethod · 0.45

Tested by

no test coverage detected