mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-21 03:35:40 -04:00
Add initial work on Qt frontend
This commit is contained in:
23
src/duckstation-qt/qtutils.cpp
Normal file
23
src/duckstation-qt/qtutils.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
#include "qtutils.h"
|
||||
#include <QtWidgets/QTableView>
|
||||
#include <algorithm>
|
||||
|
||||
namespace QtUtils {
|
||||
|
||||
void ResizeColumnsForTableView(QTableView* view, const std::initializer_list<int>& widths)
|
||||
{
|
||||
const int total_width =
|
||||
std::accumulate(widths.begin(), widths.end(), 0, [](int a, int b) { return a + std::max(b, 0); });
|
||||
|
||||
const int flex_width = std::max(view->width() - total_width - 2, 1);
|
||||
|
||||
int column_index = 0;
|
||||
for (const int spec_width : widths)
|
||||
{
|
||||
const int width = spec_width < 0 ? flex_width : spec_width;
|
||||
view->setColumnWidth(column_index, width);
|
||||
column_index++;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace QtUtils
|
Reference in New Issue
Block a user