@@ -1530,13 +1530,6 @@ QAction *MainWindow::addTrayAction(Actions::Id id)
1530
1530
return act;
1531
1531
}
1532
1532
1533
- void MainWindow::updateTabIcon (const QString &newName, const QString &oldName)
1534
- {
1535
- const QString icon = getIconNameForTabName (oldName);
1536
- if ( !icon.isEmpty () )
1537
- setIconNameForTabName (newName, icon);
1538
- }
1539
-
1540
1533
template <typename Receiver, typename ReturnType>
1541
1534
QAction *MainWindow::addItemAction (Actions::Id id, Receiver *receiver, ReturnType (Receiver::* slot)())
1542
1535
{
@@ -3134,24 +3127,25 @@ void MainWindow::doSaveTabPositions(AppConfig *appConfig)
3134
3127
3135
3128
void MainWindow::tabsMoved (const QString &oldPrefix, const QString &newPrefix)
3136
3129
{
3137
- const QStringList tabs = ui->tabWidget ->tabs ();
3138
- Q_ASSERT ( oldPrefix == newPrefix || !tabs .contains (oldPrefix) );
3139
- Q_ASSERT ( !tabs .contains (QString ()) );
3130
+ const QStringList newTabNames = ui->tabWidget ->tabs ();
3131
+ Q_ASSERT ( oldPrefix == newPrefix || !newTabNames .contains (oldPrefix) );
3132
+ Q_ASSERT ( !newTabNames .contains (QString ()) );
3140
3133
3141
- const QString prefix = oldPrefix + ' /' ;
3134
+ AppConfig appConfig;
3135
+ Tabs tabs;
3142
3136
3143
3137
// Rename tabs if needed.
3144
- for (int i = 0 ; i < tabs.size (); ++i) {
3138
+ for (int i = 0 ; i < newTabNames.size (); ++i) {
3139
+ const QString &newTabName = newTabNames[i];
3145
3140
auto placeholder = getPlaceholder (i);
3146
3141
const QString oldTabName = placeholder->tabName ();
3147
-
3148
- if ( (oldTabName == oldPrefix || oldTabName.startsWith (prefix)) && newPrefix != oldPrefix) {
3149
- const QString newName = newPrefix + oldTabName.mid (oldPrefix.size ());
3150
- setTabName (placeholder, newName);
3151
- }
3142
+ if (newTabName != oldTabName)
3143
+ updateTabName (placeholder, newTabName, &appConfig, &tabs);
3152
3144
}
3153
3145
3154
- saveTabPositions ();
3146
+ const QStringList tabNames = ui->tabWidget ->tabs ();
3147
+ tabs.save (&appConfig.settings (), tabNames);
3148
+ appConfig.setOption (Config::tabs::name (), tabNames);
3155
3149
}
3156
3150
3157
3151
void MainWindow::tabBarMenuRequested (QPoint pos, int tab)
@@ -3480,31 +3474,34 @@ void MainWindow::onItemDoubleClicked()
3480
3474
activateCurrentItem ();
3481
3475
}
3482
3476
3483
- bool MainWindow::setTabName (ClipboardBrowserPlaceholder *placeholder, const QString &newName)
3477
+ bool MainWindow::updateTabName (
3478
+ ClipboardBrowserPlaceholder *placeholder,
3479
+ const QString &newName,
3480
+ AppConfig *appConfig,
3481
+ Tabs *tabs)
3484
3482
{
3485
3483
const QString oldName = placeholder->tabName ();
3486
3484
if ( !placeholder->setTabName (newName) )
3487
3485
return false ;
3488
3486
3489
- updateTabIcon (newName, oldName);
3490
- const int tabIndex = findTabIndex (oldName);
3491
- Q_ASSERT (tabIndex != -1 );
3492
- ui->tabWidget ->setTabName (tabIndex, newName);
3493
-
3494
- Tabs tabs;
3495
- TabProperties tabProperties = tabs.tabProperties (oldName);
3487
+ TabProperties tabProperties = tabs->tabProperties (oldName);
3496
3488
tabProperties.name = newName;
3497
- tabs.setTabProperties (tabProperties);
3498
- Settings settings;
3499
- const QStringList tabNames = ui->tabWidget ->tabs ();
3500
- tabs.save (&settings, tabNames);
3501
- settings.setValue (" Options/tabs" , tabNames);
3502
-
3503
- if (oldName == m_options.clipboardTab )
3504
- settings.setValue (" Options/clipboard_tab" , newName);
3489
+ tabs->setTabProperties (tabProperties);
3490
+
3491
+ if (oldName == m_options.clipboardTab ) {
3492
+ m_options.clipboardTab = newName;
3493
+ appConfig->setOption (Config::clipboard_tab::name (), newName);
3494
+ // Restart clipboard monitoring to apply new clipboard tab configuration.
3495
+ if (!m_clipboardStoringDisabled) {
3496
+ emit disableClipboardStoring (true );
3497
+ emit disableClipboardStoring (false );
3498
+ }
3499
+ }
3505
3500
3506
- if (oldName == m_options.trayTabName )
3507
- settings.setValue (" Options/tray_tab" , newName);
3501
+ if (oldName == m_options.trayTabName ) {
3502
+ m_options.trayTabName = newName;
3503
+ appConfig->setOption (Config::tray_tab::name (), newName);
3504
+ }
3508
3505
3509
3506
return true ;
3510
3507
}
@@ -4211,8 +4208,19 @@ void MainWindow::renameTab(const QString &name, int tabIndex)
4211
4208
return ;
4212
4209
4213
4210
auto placeholder = getPlaceholder (tabIndex);
4214
- if (placeholder)
4215
- setTabName (placeholder, name);
4211
+ if (!placeholder)
4212
+ return ;
4213
+
4214
+ AppConfig appConfig;
4215
+ Tabs tabs;
4216
+ if ( !updateTabName (placeholder, name, &appConfig, &tabs) )
4217
+ return ;
4218
+
4219
+ ui->tabWidget ->setTabName (tabIndex, name);
4220
+
4221
+ const QStringList tabNames = ui->tabWidget ->tabs ();
4222
+ tabs.save (&appConfig.settings (), tabNames);
4223
+ appConfig.setOption (Config::tabs::name (), tabNames);
4216
4224
}
4217
4225
4218
4226
void MainWindow::removeTabGroup (const QString &name)
0 commit comments