Improve logical block spacing

Signed-off-by: Loren Eteval <loren.eteval@proton.me>
This commit is contained in:
Loren Eteval
2026-10-07 09:57:52 +08:00
parent 2afaf05210
commit 1cf79beeb8
6 changed files with 53 additions and 0 deletions
+2
View File
@@ -400,6 +400,7 @@ class DuplicateServersProgressDialog(AppQTransientDialog):
self.finishedDuplication = True
self.profileIds = []
self.accept()
def retranslate(self):
@@ -1487,6 +1488,7 @@ class ServerTableView(
"""Change metadata without replacing profiles or disturbing live runtimes."""
selected = self._selectedProfileIds()
current = self._currentProfileId()
changed = set(Storage.setUserServersFavorite(selected, favorite))
if not changed:
+4
View File
@@ -202,14 +202,17 @@ class MetricsPageAndGraphTest(unittest.TestCase):
def testGlobalRetranslationRefreshesEndpointOnceWithoutChangingHistory(self):
with isolatedSettings():
AppSettings.set('Language', 'EN')
manager = MetricsHistory()
page = MetricsPage(manager)
manager.recordSample({DOWNLOAD_SPEED_METRIC: 32})
samples = manager.rawSamples()
try:
for locale in ('RU', 'ZH', 'EN'):
AppSettings.set('Language', locale)
with mock.patch.object(
page.endpointInfoWidget,
'retranslate',
@@ -217,6 +220,7 @@ class MetricsPageAndGraphTest(unittest.TestCase):
) as translate:
Mixins.QTranslatable.retranslateAll()
self.assertEqual(translate.call_count, 1)
self.assertEqual(
page.metricsCard.downloadTitleLabel.text(), _('Download')
)
+26
View File
@@ -2116,6 +2116,7 @@ class ProfileMutationBatchTest(unittest.TestCase):
profiles[0].metadata.subscriptionManaged = True
profiles[0].metadata.subscriptionProfileKey = 'remote-key'
profiles[1].metadata.subscriptionSource = 'group-b'
table.selectAll()
metadataChanged = QSignalSpy(table.sourceModel.dataChanged)
@@ -2128,17 +2129,24 @@ class ProfileMutationBatchTest(unittest.TestCase):
if not action.isSeparator()
and action.textCompare('Add to Favorites')
)
add.trigger()
self.assertTrue(all(profile.metadata.favorite for profile in profiles))
self.assertEqual(metadataChanged.count(), 1)
add.trigger()
self.assertEqual(metadataChanged.count(), 1)
table.filterFavorites(True)
table.filterBySubscription('group-a')
table.search('profile-0000')
self.assertEqual(
table._visibleProfileIds(), [profiles[0].metadata.profileId]
)
table.selectAll()
remove = next(
action
@@ -2147,6 +2155,7 @@ class ProfileMutationBatchTest(unittest.TestCase):
and action.textCompare('Remove from Favorites')
)
remove.trigger()
self.assertEqual(table.proxyModel.rowCount(), 0)
self.assertEqual(table._selectedProfileIds(), [])
self.assertIs(Storage.UserServers()[0], profiles[0])
@@ -2155,7 +2164,9 @@ class ProfileMutationBatchTest(unittest.TestCase):
)
self.assertEqual(Storage.UserActivatedItemIndex(), 3)
controller.startReconnection.assert_not_called()
table.filterFavorites(False)
self.assertEqual(
table._visibleProfileIds(), [profiles[0].metadata.profileId]
)
@@ -2163,11 +2174,13 @@ class ProfileMutationBatchTest(unittest.TestCase):
def testSmallDuplicationPublishesOneBatchOfIndependentManualCopies(self):
with self.table(4) as (table, controller):
originals = list(Storage.UserServers())
for profile in originals:
profile.metadata.subscriptionSource = 'group-a'
profile.metadata.subscriptionManaged = True
profile.metadata.subscriptionProfileKey = profile.metadata.profileId
originals[0].metadata.favorite = True
table.sourceModel.sort(0, QtCore.Qt.DescendingOrder)
table.search('000[01]')
table.selectAll()
@@ -2238,6 +2251,7 @@ class ProfileMutationBatchTest(unittest.TestCase):
self.assertEqual(dialog.copiedCount, 3)
self.assertTrue(dialog.finishedDuplication)
self.assertEqual(dialog.profileIds, [])
originalIds = {profile.metadata.profileId for profile in originals}
copies = [
profile
@@ -2245,6 +2259,7 @@ class ProfileMutationBatchTest(unittest.TestCase):
if profile.metadata.profileId not in originalIds
and profile.itemRemark != 'newcomer'
]
self.assertEqual(
sorted(profile.itemRemark for profile in copies),
['profile-0000', 'profile-0001', 'profile-0003'],
@@ -2314,20 +2329,27 @@ class ProfileMutationBatchTest(unittest.TestCase):
table.selectAll()
table.duplicateSelectedItem()
dialog = table.findChild(DuplicateServersProgressDialog)
self.assertIsNotNone(dialog)
self.assertTrue(waitFor(lambda: dialog.copiedCount > 0))
QTest.mouseClick(dialog.cancelButton, QtCore.Qt.LeftButton)
self.assertTrue(waitFor(lambda: not isValid(dialog)))
self.assertLess(len(Storage.UserServers()), 2000)
count = len(Storage.UserServers())
table.duplicateSelectedItem()
pending = table.findChild(DuplicateServersProgressDialog)
self.assertIsNotNone(pending)
table.deleteLater()
QtCore.QCoreApplication.sendPostedEvents(
table, QtCore.QEvent.DeferredDelete
)
processQtEvents()
self.assertFalse(isValid(pending))
self.assertEqual(len(Storage.UserServers()), count)
@@ -2337,6 +2359,7 @@ class ProfileMutationBatchTest(unittest.TestCase):
table.duplicateSelectedItem()
dialog = table.findChild(DuplicateServersProgressDialog)
self.assertIsNotNone(dialog)
table.cleanup()
processQtEvents()
@@ -2346,6 +2369,7 @@ class ProfileMutationBatchTest(unittest.TestCase):
def testProgressDialogsUseSharedRetranslationWithoutLosingProgress(self):
with self.table(10) as (table, controller):
AppSettings.set('Language', 'EN')
dialogs = (
(
ImportURIsProgressDialog(('fixture',) * 10, parent=table),
@@ -2372,6 +2396,7 @@ class ProfileMutationBatchTest(unittest.TestCase):
for locale in ('RU', 'ZH', 'EN'):
AppSettings.set('Language', locale)
with ExitStack() as stack:
translations = [
stack.enter_context(
@@ -2383,6 +2408,7 @@ class ProfileMutationBatchTest(unittest.TestCase):
)
for dialog, *_fields in dialogs
]
Mixins.QTranslatable.retranslateAll()
for (dialog, title, status, counter), translated in zip(
+3
View File
@@ -102,8 +102,10 @@ class RepositoryContractTest(unittest.TestCase):
self.assertIs(repository.data()[1], profiles[0])
self.assertEqual(dict(profiles[0].connection), originalConnection)
self.assertFalse(profiles[1].metadata.favorite)
repository.sync()
restored = UserServers().data()
self.assertEqual(
[profile.metadata.profileId for profile in restored],
[profile.metadata.profileId for profile in repository.data()],
@@ -111,6 +113,7 @@ class RepositoryContractTest(unittest.TestCase):
self.assertEqual(
[profile.metadata.favorite for profile in restored], [False, True]
)
self.assertEqual(repository.setProfilesFavorite([unique], False), [unique])
def testRoutingRepositoryRoundTripPreservesUnknownDocuments(self):
+5
View File
@@ -77,15 +77,20 @@ class StyleSheetStateRenderingTest(unittest.TestCase):
try:
button.show()
processQtEvents()
point = (button.width() - 12, button.height() // 2)
unchecked = button.grab().toImage().pixelColor(*point)
button.setChecked(True)
checked = button.grab().toImage().pixelColor(*point)
self.assertNotEqual(checked, unchecked)
self.assertEqual(
checked, QColor(AppStyleSheet.Palettes[theme]['accent_soft'])
)
button.setChecked(False)
self.assertEqual(
button.grab().toImage().pixelColor(*point), unchecked
)
+13
View File
@@ -2981,6 +2981,7 @@ class DialogBehaviorTest(unittest.TestCase):
def testCustomMessageRetranslationKeepsPayloadAndUpdatesDialogControls(self):
with isolatedSettings():
AppSettings.set('Language', 'EN')
box = MBoxImportError()
box.setWindowTitle(_('Duplicate'))
box.setHeading(_('Delete'))
@@ -2992,6 +2993,7 @@ class DialogBehaviorTest(unittest.TestCase):
for locale in ('RU', 'ZH', 'EN'):
AppSettings.set('Language', locale)
Mixins.QTranslatable.retranslateAll()
self.assertEqual(box.windowTitle(), _('Duplicate'))
self.assertEqual(box.heading(), _('Delete'))
self.assertEqual(box.text(), _('Invalid data'))
@@ -3018,11 +3020,13 @@ class DialogBehaviorTest(unittest.TestCase):
try:
for locale in ('RU', 'ZH', 'EN'):
AppSettings.set('Language', locale)
with mock.patch.object(
managed, 'retranslate', wraps=managed.retranslate
) as translate:
Mixins.QTranslatable.retranslateAll()
self.assertEqual(translate.call_count, 1)
self.assertEqual(protected.text(), 'Cancel')
self.assertEqual(managed.text(), _('Save'))
self.assertEqual(plain.text(), _('Cancel'))
@@ -3033,6 +3037,7 @@ class DialogBehaviorTest(unittest.TestCase):
def testActionRetranslationLeavesManagedChildrenToTheirOwnPass(self):
with isolatedSettings():
AppSettings.set('Language', 'EN')
owner = QWidget()
menu = AppQMenu(parent=owner)
managed = AppQAction('Save', parent=menu)
@@ -3043,19 +3048,23 @@ class DialogBehaviorTest(unittest.TestCase):
try:
for locale in ('RU', 'ZH', 'EN'):
AppSettings.set('Language', locale)
with mock.patch.object(
managed, 'setText', wraps=managed.setText
) as update:
Mixins.QTranslatable.retranslateAll()
self.assertEqual(update.call_count, 1)
self.assertEqual(parent.text(), _('Server'))
self.assertEqual(managed.text(), _('Save'))
self.assertEqual(protected.text(), 'Cancel')
plain = QAction('Cancel', menu)
menu.addAction(plain)
AppSettings.set('Language', 'ZH')
Mixins.QTranslatable.retranslateAll()
self.assertEqual(plain.text(), _('Cancel'))
finally:
owner.deleteLater()
@@ -3064,6 +3073,7 @@ class DialogBehaviorTest(unittest.TestCase):
def testMessageGeometryRefreshesAfterManagedButtonTranslation(self):
with isolatedSettings():
AppSettings.set('Language', 'EN')
box = AppQMessageBox()
button = AppQPushButton(_('Copy Error'))
box.addButton(button, box.ButtonRole.ActionRole)
@@ -3075,6 +3085,7 @@ class DialogBehaviorTest(unittest.TestCase):
AppSettings.set('Language', locale)
Mixins.QTranslatable.retranslateAll()
processQtEvents()
self.assertEqual(button.text(), _('Copy Error'))
self.assertGreaterEqual(
button.width(), box._preferredButtonWidth(button)
@@ -3083,8 +3094,10 @@ class DialogBehaviorTest(unittest.TestCase):
AppSettings.set('Language', 'RU')
Mixins.QTranslatable.retranslateAll()
deleteQObject(box)
processQtEvents()
self.assertFalse(isValid(box))
finally:
if isValid(box):