Skip to content

Commit

Permalink
Renaming tabs updates configuration (clipboard_tab, tray_tab)
Browse files Browse the repository at this point in the history
If the clipboard tab is renamed, clipboard will be still stored in the
renamed tab.
  • Loading branch information
hluk committed Jul 10, 2021
1 parent d16c64f commit 1e60402
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/gui/mainwindow.cpp
Expand Up @@ -3876,10 +3876,23 @@ void MainWindow::renameTab(const QString &name, int tabIndex)

auto placeholder = getPlaceholder(tabIndex);
if (placeholder) {
updateTabIcon(name, placeholder->tabName());
const QString oldName = placeholder->tabName();
if ( placeholder->setTabName(name) ) {
updateTabIcon(name, oldName);
ui->tabWidget->setTabName(tabIndex, name);
saveTabPositions();

QStringList optionsAndValues;
if (oldName == m_options.clipboardTab) {
optionsAndValues.append(QStringLiteral("clipboard_tab"));
optionsAndValues.append(name);
}
if (oldName == m_options.trayTabName) {
optionsAndValues.append(QStringLiteral("tray_tab"));
optionsAndValues.append(name);
}
if ( !optionsAndValues.isEmpty() )
config(optionsAndValues);
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions src/tests/tests.cpp
Expand Up @@ -2632,6 +2632,24 @@ void Tests::renameTab()
QVERIFY( !hasTab(tab2) );
}

void Tests::renameClipboardTab()
{
const QString newClipboardTabName = clipboardTabName + QStringLiteral("2");
RUN("config" << "tray_tab" << clipboardTabName, clipboardTabName + QStringLiteral("\n"));

RUN("renametab" << clipboardTabName << newClipboardTabName, "");
RUN("tab", newClipboardTabName + "\n");
RUN("config" << "clipboard_tab", newClipboardTabName + QStringLiteral("\n"));
RUN("config" << "tray_tab", newClipboardTabName + QStringLiteral("\n"));

TEST( m_test->setClipboard("test1") );
WAIT_ON_OUTPUT("tab" << newClipboardTabName << "read" << "0", "test1");
RUN("tab", newClipboardTabName + "\n");

WAIT_ON_OUTPUT("read" << "0", "test1");
RUN("tab", newClipboardTabName + "\n");
}

void Tests::importExportTab()
{
const QString tab = testTab(1);
Expand Down
1 change: 1 addition & 0 deletions src/tests/tests.h
Expand Up @@ -189,6 +189,7 @@ private slots:
void action();
void insertRemoveItems();
void renameTab();
void renameClipboardTab();
void importExportTab();

void removeAllFoundItems();
Expand Down

0 comments on commit 1e60402

Please sign in to comment.