Qt: Moved the signal-setup to the .ui-files, UI tweaks

develop
tastytea 2018-10-14 04:29:11 +02:00
parent 60df552d8e
commit 5dbf23b018
No known key found for this signature in database
GPG Key ID: CFC39497F1B26E07
5 changed files with 187 additions and 25 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.6)
project (whyblocked
VERSION 0.7.5
VERSION 0.7.6
LANGUAGES CXX
)

View File

@ -27,17 +27,7 @@ MainWindow::MainWindow(QMainWindow *parent) : QMainWindow(parent)
_model = new QStandardItemModel;
tableview->setModel(_model);
tableview->setSelectionBehavior(QAbstractItemView::SelectRows);
populate_tableview();
connect(action_add, &QAction::triggered, this, &MainWindow::add);
connect(action_remove, &QAction::triggered, this, &MainWindow::remove);
connect(action_reload, &QAction::triggered, this, &MainWindow::populate_tableview);
connect(action_about, &QAction::triggered, this, &MainWindow::about);
connect(action_quit, &QAction::triggered, this, &MainWindow::close);
connect(tableview, &QTableView::clicked, this, &MainWindow::show_details);
connect(tableview, &QTableView::activated, this, &MainWindow::show_details);
}
void MainWindow::populate_tableview()
@ -57,7 +47,7 @@ void MainWindow::populate_tableview()
_model->setHeaderData(0, Qt::Horizontal, tr("User/Instance"));
_model->setHeaderData(1, Qt::Horizontal, tr("Blocked/Silenced?"));
_model->setHeaderData(2, Qt::Horizontal, tr("Reason"));
tableview->horizontalHeader()->resizeSection(0, 300);
tableview->horizontalHeader()->resizeSection(0, 250);
statusBar()->showMessage(tr("Database loaded."));
}
@ -152,9 +142,6 @@ DialogAdd::DialogAdd(QMainWindow *parent)
, _parent(static_cast<MainWindow*>(parent))
{
setupUi(this);
connect(button_receipt_add, &QPushButton::clicked, this, &DialogAdd::add_receipt);
connect(button_receipt_remove, &QPushButton::clicked, this, &DialogAdd::remove_receipt);
}
const dialogdata DialogAdd::get_data()

View File

@ -41,7 +41,6 @@ public:
void add_row(const QString &user, const int &blocked, const QString &reason);
private:
void populate_tableview();
const string urls_to_hyperlinks(const string &text);
QStandardItemModel *_model;
@ -51,6 +50,7 @@ private slots:
void remove();
void about();
void show_details(QModelIndex index);
void populate_tableview();
};
@ -63,6 +63,7 @@ public:
private:
const dialogdata get_data();
MainWindow *_parent;
private slots:

View File

@ -26,8 +26,23 @@
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="showGrid">
<bool>false</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<attribute name="horizontalHeaderVisible">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>100</number>
<number>125</number>
</attribute>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>true</bool>
@ -35,6 +50,9 @@
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
<item>
@ -176,5 +194,125 @@
</action>
</widget>
<resources/>
<connections/>
<connections>
<connection>
<sender>action_about</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
<slot>about()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>299</x>
<y>299</y>
</hint>
</hints>
</connection>
<connection>
<sender>action_add</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
<slot>add()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>299</x>
<y>299</y>
</hint>
</hints>
</connection>
<connection>
<sender>action_quit</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>299</x>
<y>299</y>
</hint>
</hints>
</connection>
<connection>
<sender>action_reload</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
<slot>populate_tableview()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>299</x>
<y>299</y>
</hint>
</hints>
</connection>
<connection>
<sender>action_remove</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
<slot>remove()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>299</x>
<y>299</y>
</hint>
</hints>
</connection>
<connection>
<sender>tableview</sender>
<signal>activated(QModelIndex)</signal>
<receiver>MainWindow</receiver>
<slot>show_details(QModelIndex)</slot>
<hints>
<hint type="sourcelabel">
<x>182</x>
<y>390</y>
</hint>
<hint type="destinationlabel">
<x>203</x>
<y>551</y>
</hint>
</hints>
</connection>
<connection>
<sender>tableview</sender>
<signal>clicked(QModelIndex)</signal>
<receiver>MainWindow</receiver>
<slot>show_details(QModelIndex)</slot>
<hints>
<hint type="sourcelabel">
<x>387</x>
<y>408</y>
</hint>
<hint type="destinationlabel">
<x>412</x>
<y>551</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>add()</slot>
<slot>remove()</slot>
<slot>populate_tableview()</slot>
<slot>about()</slot>
<slot>show_details(QModelIndex)</slot>
</slots>
</ui>

View File

@ -186,12 +186,12 @@
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>227</x>
<y>256</y>
<x>324</x>
<y>268</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>169</y>
<x>331</x>
<y>226</y>
</hint>
</hints>
</connection>
@ -202,14 +202,50 @@
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>290</x>
<x>255</x>
<y>262</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>169</y>
<x>265</x>
<y>224</y>
</hint>
</hints>
</connection>
<connection>
<sender>button_receipt_add</sender>
<signal>clicked()</signal>
<receiver>DialogAdd</receiver>
<slot>add_receipt()</slot>
<hints>
<hint type="sourcelabel">
<x>41</x>
<y>207</y>
</hint>
<hint type="destinationlabel">
<x>115</x>
<y>156</y>
</hint>
</hints>
</connection>
<connection>
<sender>button_receipt_remove</sender>
<signal>clicked()</signal>
<receiver>DialogAdd</receiver>
<slot>remove_receipt()</slot>
<hints>
<hint type="sourcelabel">
<x>95</x>
<y>245</y>
</hint>
<hint type="destinationlabel">
<x>135</x>
<y>190</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>add_receipt()</slot>
<slot>remove_receipt()</slot>
</slots>
</ui>