Fix some UI issues and bugs in hyprland-share-picker

This commit is contained in:
marcoilla 2023-01-22 17:32:00 +01:00
parent b03b1c2f27
commit 6f04533a45
2 changed files with 79 additions and 27 deletions

View File

@ -95,8 +95,8 @@ int main(int argc, char *argv[]) {
// add all screens
const auto SCREENS = picker.screens();
constexpr int BUTTON_WIDTH = 441;
constexpr int BUTTON_HEIGHT = 41;
constexpr int BUTTON_WIDTH = 430;
constexpr int BUTTON_HEIGHT = 40;
constexpr int BUTTON_PAD = 4;
for (int i = 0; i < SCREENS.size(); ++i) {
@ -105,8 +105,15 @@ int main(int argc, char *argv[]) {
QString text = QString::fromStdString(std::string("Screen " + std::to_string(i) + " at " + std::to_string(GEOMETRY.x()) + ", "
+ std::to_string(GEOMETRY.y()) + " (" + std::to_string(GEOMETRY.width()) + "x"
+ std::to_string(GEOMETRY.height()) + ") (") + SCREENS[i]->name().toStdString() + ")");
// resize text for graphical reason
if (text.size() > 60) {
text.resize(60);
text.append("...");
}
QPushButton* button = new QPushButton(text, (QWidget*)SCREENS_SCROLL_AREA_CONTENTS);
button->move(9, 5 + (BUTTON_HEIGHT + BUTTON_PAD) * i);
button->move(10, 5 + (BUTTON_HEIGHT + BUTTON_PAD) * i);
button->resize(BUTTON_WIDTH, BUTTON_HEIGHT);
QObject::connect(button, &QPushButton::clicked, [=] () {
std::string ID = button->text().toStdString();
@ -132,9 +139,15 @@ int main(int argc, char *argv[]) {
for (auto& window : WINDOWLIST) {
QString text = QString::fromStdString(window.clazz + ": " + window.name);
// resize text for graphical reason
if (text.size() > 60) {
text.resize(60);
text.append("...");
}
QPushButton* button = new QPushButton(text, (QWidget*)WINDOWS_SCROLL_AREA_CONTENTS);
button->move(9, 5 + (BUTTON_HEIGHT + BUTTON_PAD) * windowIterator);
button->move(10, 5 + (BUTTON_HEIGHT + BUTTON_PAD) * windowIterator);
button->resize(BUTTON_WIDTH, BUTTON_HEIGHT);
mainPickerPtr->windowIDs[button] = window.id;
@ -156,8 +169,8 @@ int main(int argc, char *argv[]) {
QString text = "Select region...";
QPushButton* button = new QPushButton(text, (QWidget*)REGION_OBJECT);
button->move(79, 80);
button->resize(321, 41);
button->move(60, 80);
button->resize(330, 40);
QObject::connect(button, &QPushButton::clicked, [=] () {
auto REGION = execAndGet("slurp -f \"%o %x %y %w %h\"");
REGION = REGION.substr(0, REGION.length() - 1);

View File

@ -42,15 +42,15 @@
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<y>5</y>
<width>500</width>
<height>290</height>
<height>285</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>500</width>
<height>290</height>
<height>285</height>
</size>
</property>
<property name="maximumSize">
@ -66,21 +66,45 @@
<enum>QTabWidget::North</enum>
</property>
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="screens">
<property name="minimumSize">
<size>
<width>450</width>
<height>200</height>
</size>
</property>
<attribute name="title">
<string>Screen</string>
</attribute>
<widget class="QScrollArea" name="scrollArea">
<property name="geometry">
<rect>
<x>9</x>
<y>9</y>
<width>461</width>
<height>241</height>
<x>0</x>
<y>0</y>
<width>450</width>
<height>200</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>450</width>
<height>200</height>
</size>
</property>
<property name="cursor" stdset="0">
<cursorShape>ArrowCursor</cursorShape>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable">
<bool>false</bool>
</property>
@ -89,14 +113,14 @@
<rect>
<x>0</x>
<y>0</y>
<width>459</width>
<height>239</height>
<width>450</width>
<height>200</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>459</width>
<height>239</height>
<width>450</width>
<height>200</height>
</size>
</property>
<property name="focusPolicy">
@ -112,12 +136,21 @@
<widget class="QScrollArea" name="scrollArea_2">
<property name="geometry">
<rect>
<x>9</x>
<y>9</y>
<width>461</width>
<height>241</height>
<x>0</x>
<y>0</y>
<width>450</width>
<height>200</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable">
<bool>false</bool>
</property>
@ -126,14 +159,14 @@
<rect>
<x>0</x>
<y>0</y>
<width>459</width>
<height>239</height>
<width>450</width>
<height>200</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>459</width>
<height>239</height>
<width>450</width>
<height>200</height>
</size>
</property>
<property name="focusPolicy">
@ -143,6 +176,12 @@
</widget>
</widget>
<widget class="QWidget" name="region">
<property name="minimumSize">
<size>
<width>450</width>
<height>210</height>
</size>
</property>
<attribute name="title">
<string>Region</string>
</attribute>