Table layout for notifications

This commit is contained in:
Jordan Sherer 2019-10-09 22:13:42 -04:00
parent 581d40010f
commit fe31f54b97
2 changed files with 84 additions and 50 deletions

View File

@ -1365,6 +1365,7 @@ Configuration::impl::impl (Configuration * self, QDir const& temp_directory,
// setup notifications table view
//
QMap<QString, QString> notifyRows = {
{"notify_start", "JS8Call Start"},
{"notify_cq", "CQ Message Received"},
{"notify_hb", "HB Message Received"},
{"notify_directed", "Directed Message Received"},
@ -1375,51 +1376,84 @@ Configuration::impl::impl (Configuration * self, QDir const& temp_directory,
int i = 0;
auto table = ui_->notifications_table_widget;
auto header = table->horizontalHeader();
header->setStretchLastSection(false);
header->setSectionResizeMode(0, QHeaderView::ResizeToContents);
header->setSectionResizeMode(1, QHeaderView::ResizeToContents);
header->setSectionResizeMode(2, QHeaderView::Stretch);
header->setSectionResizeMode(3, QHeaderView::ResizeToContents);
foreach(QString key, notifyRows.keys()){
QCheckBox *vcb;
auto w1 = centeredCheckBox(this, &vcb);
if(vcb){
vcb->setChecked(true);
bool enabled = false;
QString path = "";
QCheckBox *enabledCheckbox;
auto enabledWidget = centeredCheckBox(this, &enabledCheckbox);
enabledWidget->setMinimumWidth(100);
if(enabledCheckbox){
enabledCheckbox->setChecked(enabled);
}
QCheckBox *acb;
auto w2 = centeredCheckBox(this, &acb);
if(acb){
acb->setChecked(true);
}
auto expandingPolicy = QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
expandingPolicy.setHorizontalStretch(1);
QWidget *w3 = new QWidget(this);
QHBoxLayout *l3 = new QHBoxLayout(w3);
l3->setContentsMargins(9,1,1,1);
w3->setLayout(l3);
QLabel *pathLabel = new QLabel(this);
pathLabel->setText(path);
pathLabel->setSizePolicy(expandingPolicy);
QLabel *sflb = new QLabel(this);
sflb->setText("/tmp/file.wav");
l3->addWidget(sflb);
auto minimumPolicy = QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
minimumPolicy.setHorizontalStretch(0);
QPushButton *sfpb1 = new QPushButton(this);
sfpb1->setText("Select");
l3->addWidget(sfpb1);
QWidget *buttonWidget = new QWidget(this);
buttonWidget->setSizePolicy(minimumPolicy);
QPushButton *sfpb3 = new QPushButton(this);
sfpb3->setText("Clear");
l3->addWidget(sfpb3);
QHBoxLayout *buttonLayout = new QHBoxLayout(buttonWidget);
buttonLayout->setStretch(0, 0);
buttonLayout->setStretch(1, 0);
buttonLayout->setContentsMargins(9,1,1,1);
buttonWidget->setLayout(buttonLayout);
QPushButton *selectFilePushButton = new QPushButton(this);
selectFilePushButton->setSizePolicy(minimumPolicy);
selectFilePushButton->setText("Select");
buttonLayout->addWidget(selectFilePushButton);
//
connect(selectFilePushButton, &QPushButton::pressed, this, [this, pathLabel](){
auto dir = QStandardPaths::standardLocations(QStandardPaths::MusicLocation);
auto path = QFileDialog::getOpenFileName(this, "Audio Notification", dir.first(), "Wave Files (*.wav);;All files (*.*)");
if(!path.isEmpty()){
pathLabel->setText(path);
}
});
QPushButton *clearPushButton = new QPushButton(this);
clearPushButton->setSizePolicy(minimumPolicy);
clearPushButton->setText("Clear");
buttonLayout->addWidget(clearPushButton);
connect(clearPushButton, &QPushButton::pressed, this, [this, pathLabel, enabledCheckbox](){
pathLabel->clear();
enabledCheckbox->setChecked(false);
});
// row config
int col = 0;
table->insertRow(i);
auto labelItem = new QTableWidgetItem(notifyRows.value(key));
table->setItem(i, 0, labelItem);
table->setCellWidget(i, 1, w1);
table->setCellWidget(i, 2, w2);
table->setCellWidget(i, 3, w3);
//
auto eventLabelItem = new QTableWidgetItem(notifyRows.value(key));
table->setItem(i, col++, eventLabelItem);
table->setCellWidget(i, col++, enabledWidget);
table->setCellWidget(i, col++, pathLabel);
table->setCellWidget(i, col++, buttonWidget);
i++;
}
table->resizeColumnToContents(0);
table->resizeColumnToContents(1);
table->resizeColumnToContents(2);
for(int i = 0, len = table->columnCount(); i < len; i++){
table->resizeColumnToContents(i);
}
//
// setup stations table model & view

View File

@ -278,7 +278,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>724</width>
<width>615</width>
<height>508</height>
</rect>
</property>
@ -793,8 +793,8 @@ text message.</string>
<rect>
<x>0</x>
<y>0</y>
<width>738</width>
<height>453</height>
<width>616</width>
<height>331</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_16">
@ -1517,7 +1517,7 @@ a few, particularly some Kenwood rigs, require it).</string>
<rect>
<x>0</x>
<y>0</y>
<width>718</width>
<width>494</width>
<height>490</height>
</rect>
</property>
@ -1921,8 +1921,8 @@ this setting allows you to select which audio input will be used
<rect>
<x>0</x>
<y>0</y>
<width>760</width>
<height>502</height>
<width>266</width>
<height>420</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_29">
@ -2305,7 +2305,7 @@ both here.</string>
<rect>
<x>0</x>
<y>0</y>
<width>746</width>
<width>562</width>
<height>663</height>
</rect>
</property>
@ -2800,8 +2800,8 @@ for assessing propagation and system performance.</string>
<rect>
<x>0</x>
<y>0</y>
<width>760</width>
<height>502</height>
<width>487</width>
<height>341</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_31">
@ -3166,7 +3166,7 @@ QListView::item:hover {
<enum>QAbstractItemView::NoSelection</enum>
</property>
<property name="showGrid">
<bool>true</bool>
<bool>false</bool>
</property>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>125</number>
@ -3184,12 +3184,7 @@ QListView::item:hover {
</column>
<column>
<property name="text">
<string>Visual Alert?</string>
</property>
</column>
<column>
<property name="text">
<string>Audio Alert?</string>
<string>Enabled</string>
</property>
</column>
<column>
@ -3197,6 +3192,11 @@ QListView::item:hover {
<string>Sound File</string>
</property>
</column>
<column>
<property name="text">
<string/>
</property>
</column>
</widget>
</item>
</layout>
@ -3270,8 +3270,8 @@ QListView::item:hover {
<rect>
<x>0</x>
<y>0</y>
<width>724</width>
<height>418</height>
<width>274</width>
<height>690</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_14">