Skip to content

Commit 1f24f80

Browse files
committed
code adjustment
1 parent b187b78 commit 1f24f80

File tree

4 files changed

+91
-77
lines changed

4 files changed

+91
-77
lines changed

Mergin/project_limit_hit_dialog.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,35 @@
66

77
ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), "ui", "ui_project_limit_hit_dialog.ui")
88

9+
910
class ProjectLimitHitDialog(QDialog):
1011
def __init__(self, e, parent=None):
1112
QDialog.__init__(self, parent)
1213
self.ui = uic.loadUi(ui_file, self)
13-
14-
quota = e.server_response.get('projects_quota', 'N/A')
15-
plan = e.server_response.get('plan', 'N/A')
16-
self.planQuota_label.setText(str(quota))
17-
self.planName_label.setText(str(plan))
18-
14+
15+
self.server_response = e.server_response
16+
self.setDialogStyle()
17+
1918
self.cancel_btn.clicked.connect(self.reject)
2019
self.upgrade_plan_btn.clicked.connect(self.open_upgrade_link)
21-
20+
21+
def setDialogStyle(self):
22+
quota = self.server_response.get("projects_quota", "N/A")
23+
quota_text = f"{quota}/{quota}"
24+
25+
self.plan_quota_progress_bar.setFormat(quota_text)
26+
self.plan_quota_progress_bar.setStyleSheet(
27+
"""
28+
QProgressBar {
29+
border: none;
30+
text-align: center;
31+
}
32+
QProgressBar::chunk {
33+
background-color: rgb(0, 76, 69);
34+
}
35+
"""
36+
)
37+
2238
def open_upgrade_link(self):
2339
QDesktopServices.openUrl(QUrl("https://www.merginmaps.com/pricing"))
24-
self.accept()
40+
self.accept()

Mergin/projects_manager.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from .project_status_dialog import ProjectStatusDialog
3232
from .project_limit_hit_dialog import ProjectLimitHitDialog
3333

34+
3435
class MerginProjectsManager(object):
3536
"""Class for managing Mergin Maps projects in QGIS."""
3637

Mergin/ui/ui_project_limit_hit_dialog.ui

Lines changed: 63 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>332</width>
10-
<height>278</height>
9+
<width>352</width>
10+
<height>224</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
1414
<string>Project limit hit</string>
1515
</property>
16-
<layout class="QVBoxLayout" name="verticalLayout">
17-
<item>
16+
<layout class="QGridLayout" name="gridLayout">
17+
<item row="0" column="0">
1818
<widget class="QLabel" name="label">
1919
<property name="sizePolicy">
2020
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
@@ -30,7 +30,7 @@
3030
</font>
3131
</property>
3232
<property name="text">
33-
<string>You have reached the maximum limit of active monthly contributors for your subscription.</string>
33+
<string>You've reached the maximum number of active monthly contributors for your current subscription.</string>
3434
</property>
3535
<property name="textFormat">
3636
<enum>Qt::AutoText</enum>
@@ -43,80 +43,41 @@
4343
</property>
4444
</widget>
4545
</item>
46-
<item>
47-
<widget class="QLabel" name="label_2">
48-
<property name="text">
49-
<string>Upgrade your subscription or wait until next month
50-
for refresh of slots.</string>
46+
<item row="3" column="0">
47+
<widget class="QProgressBar" name="plan_quota_progress_bar">
48+
<property name="enabled">
49+
<bool>true</bool>
5150
</property>
52-
<property name="alignment">
53-
<set>Qt::AlignCenter</set>
51+
<property name="sizePolicy">
52+
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
53+
<horstretch>0</horstretch>
54+
<verstretch>0</verstretch>
55+
</sizepolicy>
5456
</property>
55-
</widget>
56-
</item>
57-
<item>
58-
<spacer name="verticalSpacer">
59-
<property name="orientation">
60-
<enum>Qt::Vertical</enum>
57+
<property name="minimumSize">
58+
<size>
59+
<width>0</width>
60+
<height>15</height>
61+
</size>
6162
</property>
62-
<property name="sizeHint" stdset="0">
63+
<property name="maximumSize">
6364
<size>
64-
<width>20</width>
65-
<height>40</height>
65+
<width>16777215</width>
66+
<height>16777215</height>
67+
</size>
68+
</property>
69+
<property name="baseSize">
70+
<size>
71+
<width>0</width>
72+
<height>15</height>
6673
</size>
6774
</property>
68-
</spacer>
69-
</item>
70-
<item>
71-
<layout class="QHBoxLayout" name="horizontalLayout">
72-
<item>
73-
<widget class="QLabel" name="label_3">
74-
<property name="text">
75-
<string>Used</string>
76-
</property>
77-
</widget>
78-
</item>
79-
<item>
80-
<widget class="QLabel" name="planQuota_label">
81-
<property name="text">
82-
<string/>
83-
</property>
84-
<property name="alignment">
85-
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
86-
</property>
87-
</widget>
88-
</item>
89-
</layout>
90-
</item>
91-
<item>
92-
<widget class="QProgressBar" name="plan_quota_progress_bar">
9375
<property name="value">
9476
<number>100</number>
9577
</property>
9678
</widget>
9779
</item>
98-
<item>
99-
<layout class="QHBoxLayout" name="horizontalLayout_2">
100-
<item>
101-
<widget class="QLabel" name="label_6">
102-
<property name="text">
103-
<string>Plan</string>
104-
</property>
105-
</widget>
106-
</item>
107-
<item>
108-
<widget class="QLabel" name="planName_label">
109-
<property name="text">
110-
<string/>
111-
</property>
112-
<property name="alignment">
113-
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
114-
</property>
115-
</widget>
116-
</item>
117-
</layout>
118-
</item>
119-
<item>
80+
<item row="5" column="0">
12081
<layout class="QHBoxLayout" name="horizontalLayout_3">
12182
<item>
12283
<widget class="QPushButton" name="cancel_btn">
@@ -133,8 +94,11 @@ for refresh of slots.</string>
13394
</item>
13495
<item>
13596
<widget class="QPushButton" name="upgrade_plan_btn">
97+
<property name="enabled">
98+
<bool>true</bool>
99+
</property>
136100
<property name="sizePolicy">
137-
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
101+
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
138102
<horstretch>0</horstretch>
139103
<verstretch>0</verstretch>
140104
</sizepolicy>
@@ -151,12 +115,42 @@ for refresh of slots.</string>
151115
<height>16777215</height>
152116
</size>
153117
</property>
118+
<property name="font">
119+
<font>
120+
<kerning>true</kerning>
121+
</font>
122+
</property>
154123
<property name="text">
155124
<string>Upgrade</string>
156125
</property>
157126
<property name="default">
158127
<bool>true</bool>
159128
</property>
129+
<property name="flat">
130+
<bool>false</bool>
131+
</property>
132+
</widget>
133+
</item>
134+
</layout>
135+
</item>
136+
<item row="1" column="0">
137+
<widget class="QLabel" name="label_2">
138+
<property name="text">
139+
<string>Upgrade your subscription or wait until next month
140+
for the limit to reset.</string>
141+
</property>
142+
<property name="alignment">
143+
<set>Qt::AlignCenter</set>
144+
</property>
145+
</widget>
146+
</item>
147+
<item row="2" column="0">
148+
<layout class="QHBoxLayout" name="horizontalLayout">
149+
<item>
150+
<widget class="QLabel" name="label_3">
151+
<property name="text">
152+
<string>Used</string>
153+
</property>
160154
</widget>
161155
</item>
162156
</layout>

scripts/format_py.bash

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
cd "$(dirname "$0")"
3+
black -l 120 ../Mergin

0 commit comments

Comments
 (0)