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 // add all screens
const auto SCREENS = picker.screens(); const auto SCREENS = picker.screens();
constexpr int BUTTON_WIDTH = 441; constexpr int BUTTON_WIDTH = 430;
constexpr int BUTTON_HEIGHT = 41; constexpr int BUTTON_HEIGHT = 40;
constexpr int BUTTON_PAD = 4; constexpr int BUTTON_PAD = 4;
for (int i = 0; i < SCREENS.size(); ++i) { 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()) + ", " 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.y()) + " (" + std::to_string(GEOMETRY.width()) + "x"
+ std::to_string(GEOMETRY.height()) + ") (") + SCREENS[i]->name().toStdString() + ")"); + 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); 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); button->resize(BUTTON_WIDTH, BUTTON_HEIGHT);
QObject::connect(button, &QPushButton::clicked, [=] () { QObject::connect(button, &QPushButton::clicked, [=] () {
std::string ID = button->text().toStdString(); std::string ID = button->text().toStdString();
@ -133,8 +140,14 @@ int main(int argc, char *argv[]) {
QString text = QString::fromStdString(window.clazz + ": " + window.name); 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); 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); button->resize(BUTTON_WIDTH, BUTTON_HEIGHT);
mainPickerPtr->windowIDs[button] = window.id; mainPickerPtr->windowIDs[button] = window.id;
@ -156,8 +169,8 @@ int main(int argc, char *argv[]) {
QString text = "Select region..."; QString text = "Select region...";
QPushButton* button = new QPushButton(text, (QWidget*)REGION_OBJECT); QPushButton* button = new QPushButton(text, (QWidget*)REGION_OBJECT);
button->move(79, 80); button->move(60, 80);
button->resize(321, 41); button->resize(330, 40);
QObject::connect(button, &QPushButton::clicked, [=] () { QObject::connect(button, &QPushButton::clicked, [=] () {
auto REGION = execAndGet("slurp -f \"%o %x %y %w %h\""); auto REGION = execAndGet("slurp -f \"%o %x %y %w %h\"");
REGION = REGION.substr(0, REGION.length() - 1); REGION = REGION.substr(0, REGION.length() - 1);

View file

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