comparison widgets/PluginPathConfigurator.cpp @ 1288:4683b6ffb76a plugin-path-config

Grey-out meaningless buttons
author Chris Cannam
date Tue, 15 May 2018 15:25:04 +0100
parents 2dd7f764c3a6
children ed04d3666d33
comparison
equal deleted inserted replaced
1287:2dd7f764c3a6 1288:4683b6ffb76a
14 14
15 #include "PluginPathConfigurator.h" 15 #include "PluginPathConfigurator.h"
16 16
17 #include <QPushButton> 17 #include <QPushButton>
18 #include <QListWidget> 18 #include <QListWidget>
19 #include <QGridLayout>
19 #include <QLabel> 20 #include <QLabel>
20 21
21 #include "IconLoader.h" 22 #include "IconLoader.h"
22 #include "WidgetScale.h" 23 #include "WidgetScale.h"
23 24
36 37
37 m_list = new QListWidget; 38 m_list = new QListWidget;
38 m_layout->addWidget(m_list, row, 0, 1, 2); 39 m_layout->addWidget(m_list, row, 0, 1, 2);
39 m_layout->setRowStretch(row, 10); 40 m_layout->setRowStretch(row, 10);
40 m_layout->setColumnStretch(0, 10); 41 m_layout->setColumnStretch(0, 10);
42 connect(m_list, SIGNAL(currentRowChanged(int)),
43 this, SLOT(currentLocationChanged(int)));
41 ++row; 44 ++row;
42 45
43 QHBoxLayout *buttons = new QHBoxLayout; 46 QHBoxLayout *buttons = new QHBoxLayout;
44 47
45 QPushButton *down = new QPushButton; 48 m_down = new QPushButton;
46 down->setIcon(IconLoader().load("down")); 49 m_down->setIcon(IconLoader().load("down"));
47 down->setToolTip(tr("Move the selected location down in the list")); 50 m_down->setToolTip(tr("Move the selected location later in the list"));
48 down->setFixedSize(WidgetScale::scaleQSize(QSize(16, 16))); 51 m_down->setFixedSize(WidgetScale::scaleQSize(QSize(16, 16)));
49 connect(down, SIGNAL(clicked()), this, SLOT(downClicked())); 52 connect(m_down, SIGNAL(clicked()), this, SLOT(downClicked()));
50 buttons->addWidget(down); 53 buttons->addWidget(m_down);
51 54
52 QPushButton *up = new QPushButton; 55 m_up = new QPushButton;
53 up->setIcon(IconLoader().load("up")); 56 m_up->setIcon(IconLoader().load("up"));
54 up->setToolTip(tr("Move the selected location up in the list")); 57 m_up->setToolTip(tr("Move the selected location earlier in the list"));
55 up->setFixedSize(WidgetScale::scaleQSize(QSize(16, 16))); 58 m_up->setFixedSize(WidgetScale::scaleQSize(QSize(16, 16)));
56 connect(up, SIGNAL(clicked()), this, SLOT(upClicked())); 59 connect(m_up, SIGNAL(clicked()), this, SLOT(upClicked()));
57 buttons->addWidget(up); 60 buttons->addWidget(m_up);
58 61
59 QPushButton *del = new QPushButton; 62 m_delete = new QPushButton;
60 del->setIcon(IconLoader().load("datadelete")); 63 m_delete->setIcon(IconLoader().load("datadelete"));
61 del->setToolTip(tr("Remove the selected location from the list")); 64 m_delete->setToolTip(tr("Remove the selected location from the list"));
62 del->setFixedSize(WidgetScale::scaleQSize(QSize(16, 16))); 65 m_delete->setFixedSize(WidgetScale::scaleQSize(QSize(16, 16)));
63 connect(del, SIGNAL(clicked()), this, SLOT(deleteClicked())); 66 connect(m_delete, SIGNAL(clicked()), this, SLOT(deleteClicked()));
64 buttons->addWidget(del); 67 buttons->addWidget(m_delete);
65 68
66 m_layout->addLayout(buttons, row, 1); 69 m_layout->addLayout(buttons, row, 1);
67 ++row; 70 ++row;
68 } 71 }
69 72
89 } 92 }
90 93
91 if (makeCurrent >= 0 && makeCurrent < m_path.size()) { 94 if (makeCurrent >= 0 && makeCurrent < m_path.size()) {
92 m_list->setCurrentRow(makeCurrent); 95 m_list->setCurrentRow(makeCurrent);
93 } 96 }
97 }
98
99 void
100 PluginPathConfigurator::currentLocationChanged(int i)
101 {
102 m_up->setEnabled(i > 0);
103 m_down->setEnabled(i + 1 < m_path.size());
104 m_delete->setEnabled(i < m_path.size());
94 } 105 }
95 106
96 void 107 void
97 PluginPathConfigurator::upClicked() 108 PluginPathConfigurator::upClicked()
98 { 109 {