Commit af51e0ff authored by Jekyll Wu's avatar Jekyll Wu
Browse files

Refacotr tab format related UI components into RenameTabWidget

This make EditProfileDialog and RenameTabsDialog reuse the same
widget, instead of duplicating each other in its own code or .ui file.
RenameTabsDialog is now just a simple container of RenameTabWidget
parent 01d97f9e
......@@ -89,6 +89,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/tests/CTestCustom.cmake)
ProfileWriter.cpp
Pty.cpp
RenameTabsDialog.cpp
RenameTabWidget.cpp
Screen.cpp
ScreenWindow.cpp
Session.cpp
......@@ -139,6 +140,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/tests/CTestCustom.cmake)
KeyBindingEditor.ui
ManageProfilesDialog.ui
RenameTabsDialog.ui
RenameTabWidget.ui
HistorySizeWidget.ui
settings/GeneralSettings.ui
settings/TabBarSettings.ui
......
......@@ -319,40 +319,23 @@ void EditProfileDialog::showEnvironmentEditor()
void EditProfileDialog::setupTabsPage(const Profile::Ptr profile)
{
// tab title format
_ui->tabTitleEdit->setClearButtonShown(true);
_ui->remoteTabTitleEdit->setClearButtonShown(true);
_ui->tabTitleEdit->setText(profile->localTabTitleFormat());
_ui->remoteTabTitleEdit->setText(profile->remoteTabTitleFormat());
_ui->renameTabWidget->setTabTitleText(profile->localTabTitleFormat());
_ui->renameTabWidget->setRemoteTabTitleText(profile->remoteTabTitleFormat());
connect(_ui->renameTabWidget, SIGNAL(tabTitleFormatChanged(QString)), this,
SLOT(tabTitleFormatChanged(QString)));
connect(_ui->renameTabWidget, SIGNAL(remoteTabTitleFormatChanged(QString)), this,
SLOT(remoteTabTitleFormatChanged(QString)));
// tab monitoring
const int silenceSeconds = profile->silenceSeconds();
_ui->silenceSecondsSpinner->setValue(silenceSeconds);
_ui->silenceSecondsSpinner->setSuffix(ki18ncp("Unit of time", " second", " seconds"));
connect(_ui->tabTitleEdit, SIGNAL(textChanged(QString)), this,
SLOT(tabTitleFormatChanged(QString)));
connect(_ui->remoteTabTitleEdit, SIGNAL(textChanged(QString)), this,
SLOT(remoteTabTitleFormatChanged(QString)));
connect(_ui->silenceSecondsSpinner, SIGNAL(valueChanged(int)),
this, SLOT(silenceSecondsChanged(int)));
_ui->tabTitleFormatButton->setContext(Session::LocalTabTitle);
connect(_ui->tabTitleFormatButton, SIGNAL(dynamicElementSelected(QString)),
this, SLOT(insertTabTitleText(QString)));
_ui->remoteTabTitleFormatButton->setContext(Session::RemoteTabTitle);
connect(_ui->remoteTabTitleFormatButton, SIGNAL(dynamicElementSelected(QString)),
this, SLOT(insertRemoteTabTitleText(QString)));
}
void EditProfileDialog::insertTabTitleText(const QString& text)
{
_ui->tabTitleEdit->insert(text);
}
void EditProfileDialog::insertRemoteTabTitleText(const QString& text)
{
_ui->remoteTabTitleEdit->insert(text);
}
void EditProfileDialog::saveGeometryOnExit(bool value)
{
updateTempProfileProperty(Profile::SaveGeometryOnExit, value);
......
......@@ -113,9 +113,6 @@ private slots:
void tabTitleFormatChanged(const QString& text);
void remoteTabTitleFormatChanged(const QString& text);
void insertTabTitleText(const QString& text);
void insertRemoteTabTitleText(const QString& text);
void showTerminalSizeHint(bool);
void saveGeometryOnExit(bool);
void showEnvironmentEditor();
......
......@@ -267,44 +267,7 @@
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Tab title format:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KLineEdit" name="tabTitleEdit">
<property name="toolTip">
<string>Normal tab title format</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="Konsole::TabTitleFormatButton" name="tabTitleFormatButton"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Remote tab title format:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="KLineEdit" name="remoteTabTitleEdit">
<property name="toolTip">
<string>Tab title format used when a remote command (e.g. connection to another computer via SSH) is being executed</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="Konsole::TabTitleFormatButton" name="remoteTabTitleFormatButton"/>
<widget class="Konsole::RenameTabWidget" name="renameTabWidget"/>
</item>
</layout>
</widget>
......@@ -1109,9 +1072,9 @@
<container>1</container>
</customwidget>
<customwidget>
<class>Konsole::TabTitleFormatButton</class>
<extends>QPushButton</extends>
<header>TabTitleFormatButton.h</header>
<class>Konsole::RenameTabWidget</class>
<extends>QWidget</extends>
<header>RenameTabWidget.h</header>
</customwidget>
<customwidget>
<class>Konsole::HistorySizeWidget</class>
......
/*
Copyright 2010 by Kurt Hindenburg <kurt.hindenburg@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
*/
// Own
#include "RenameTabWidget.h"
// Konsole
#include "ui_RenameTabWidget.h"
using Konsole::RenameTabWidget;
RenameTabWidget::RenameTabWidget(QWidget* parent)
: QWidget(parent)
{
_ui = new Ui::RenameTabWidget();
_ui->setupUi(this);
_ui->tabTitleEdit->setClearButtonShown(true);
_ui->remoteTabTitleEdit->setClearButtonShown(true);
connect(_ui->tabTitleEdit, SIGNAL(textChanged(QString)), this,
SIGNAL(tabTitleFormatChanged(QString)));
connect(_ui->remoteTabTitleEdit, SIGNAL(textChanged(QString)), this,
SIGNAL(remoteTabTitleFormatChanged(QString)));
_ui->tabTitleFormatButton->setContext(Session::LocalTabTitle);
connect(_ui->tabTitleFormatButton, SIGNAL(dynamicElementSelected(QString)),
this, SLOT(insertTabTitleText(QString)));
_ui->remoteTabTitleFormatButton->setContext(Session::RemoteTabTitle);
connect(_ui->remoteTabTitleFormatButton, SIGNAL(dynamicElementSelected(QString)),
this, SLOT(insertRemoteTabTitleText(QString)));
}
RenameTabWidget::~RenameTabWidget()
{
delete _ui;
}
void RenameTabWidget::focusTabTitleText()
{
_ui->tabTitleEdit->setFocus();
}
void RenameTabWidget::focusRemoteTabTitleText()
{
_ui->remoteTabTitleEdit->setFocus();
}
void RenameTabWidget::setTabTitleText(const QString& text)
{
_ui->tabTitleEdit->setText(text);
}
void RenameTabWidget::setRemoteTabTitleText(const QString& text)
{
_ui->remoteTabTitleEdit->setText(text);
}
QString RenameTabWidget::tabTitleText() const
{
return(_ui->tabTitleEdit->text());
}
QString RenameTabWidget::remoteTabTitleText() const
{
return(_ui->remoteTabTitleEdit->text());
}
void RenameTabWidget::insertTabTitleText(const QString& text)
{
_ui->tabTitleEdit->insert(text);
}
void RenameTabWidget::insertRemoteTabTitleText(const QString& text)
{
_ui->remoteTabTitleEdit->insert(text);
}
/*
Copyright 2010 by Kurt Hindenburg <kurt.hindenburg@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
*/
#ifndef RENAMETABWIDGET_H
#define RENAMETABWIDGET_H
// Qt
#include <QtGui/QWidget>
namespace Ui
{
class RenameTabWidget;
}
namespace Konsole
{
class RenameTabWidget : public QWidget
{
Q_OBJECT
public:
explicit RenameTabWidget(QWidget* parent = 0);
~RenameTabWidget();
QString tabTitleText() const;
QString remoteTabTitleText() const;
void setTabTitleText(const QString&);
void setRemoteTabTitleText(const QString&);
void focusTabTitleText();
void focusRemoteTabTitleText();
signals:
void tabTitleFormatChanged(const QString&);
void remoteTabTitleFormatChanged(const QString&);
public slots:
void insertTabTitleText(const QString& text);
void insertRemoteTabTitleText(const QString& text);
private:
Ui::RenameTabWidget* _ui;
};
}
#endif
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>RenameTabWidget</class>
<widget class="QWidget" name="RenameTabWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>325</width>
<height>110</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_5">
<property name="title">
<string/>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Tab title format:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KLineEdit" name="tabTitleEdit">
<property name="toolTip">
<string>Normal tab title format</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="Konsole::TabTitleFormatButton" name="tabTitleFormatButton"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Remote tab title format:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="KLineEdit" name="remoteTabTitleEdit">
<property name="toolTip">
<string>Tab title format used when a remote command (e.g. connection to another computer via SSH) is being executed</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="Konsole::TabTitleFormatButton" name="remoteTabTitleFormatButton"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KLineEdit</class>
<extends>QLineEdit</extends>
<header>klineedit.h</header>
</customwidget>
<customwidget>
<class>Konsole::TabTitleFormatButton</class>
<extends>QPushButton</extends>
<header>TabTitleFormatButton.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
......@@ -35,17 +35,6 @@ RenameTabsDialog::RenameTabsDialog(QWidget* parent)
_ui = new Ui::RenameTabsDialog();
_ui->setupUi(mainWidget());
_ui->tabTitleEdit->setClearButtonShown(true);
_ui->remoteTabTitleEdit->setClearButtonShown(true);
_ui->tabTitleFormatButton->setContext(Session::LocalTabTitle);
connect(_ui->tabTitleFormatButton, SIGNAL(dynamicElementSelected(QString)),
this, SLOT(insertTabTitleText(QString)));
_ui->remoteTabTitleFormatButton->setContext(Session::RemoteTabTitle);
connect(_ui->remoteTabTitleFormatButton, SIGNAL(dynamicElementSelected(QString)),
this, SLOT(insertRemoteTabTitleText(QString)));
}
RenameTabsDialog::~RenameTabsDialog()
......@@ -55,41 +44,41 @@ RenameTabsDialog::~RenameTabsDialog()
void RenameTabsDialog::focusTabTitleText()
{
_ui->tabTitleEdit->setFocus();
_ui->renameTabWidget->focusTabTitleText();
}
void RenameTabsDialog::focusRemoteTabTitleText()
{
_ui->remoteTabTitleEdit->setFocus();
_ui->renameTabWidget->focusRemoteTabTitleText();
}
void RenameTabsDialog::setTabTitleText(const QString& text)
{
_ui->tabTitleEdit->setText(text);
_ui->renameTabWidget->setTabTitleText(text);
}
void RenameTabsDialog::setRemoteTabTitleText(const QString& text)
{
_ui->remoteTabTitleEdit->setText(text);
_ui->renameTabWidget->setRemoteTabTitleText(text);
}
QString RenameTabsDialog::tabTitleText() const
{
return(_ui->tabTitleEdit->text());
return _ui->renameTabWidget->tabTitleText();
}
QString RenameTabsDialog::remoteTabTitleText() const
{
return(_ui->remoteTabTitleEdit->text());
return _ui->renameTabWidget->remoteTabTitleText();
}
void RenameTabsDialog::insertTabTitleText(const QString& text)
{
_ui->tabTitleEdit->insert(text);
_ui->renameTabWidget->insertTabTitleText(text);
}
void RenameTabsDialog::insertRemoteTabTitleText(const QString& text)
{
_ui->remoteTabTitleEdit->insert(text);
_ui->renameTabWidget->insertRemoteTabTitleText(text);
}
......@@ -12,69 +12,15 @@
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_5">
<property name="title">
<string/>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Tab title format:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KLineEdit" name="tabTitleEdit">
<property name="toolTip">
<string>Normal tab title format</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="Konsole::TabTitleFormatButton" name="tabTitleFormatButton"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Remote tab title format:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="KLineEdit" name="remoteTabTitleEdit">
<property name="toolTip">
<string>Tab title format used when a remote command (e.g. connection to another computer via SSH) is being executed</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="Konsole::TabTitleFormatButton" name="remoteTabTitleFormatButton"/>
</item>
</layout>
</widget>
<widget class="Konsole::RenameTabWidget" name="renameTabWidget"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KLineEdit</class>
<extends>QLineEdit</extends>
<header>klineedit.h</header>
</customwidget>
<customwidget>
<class>Konsole::TabTitleFormatButton</class>
<extends>QPushButton</extends>
<header>TabTitleFormatButton.h</header>
<class>Konsole::RenameTabWidget</class>
<extends>QWidget</extends>
<header>RenameTabWidget.h</header>
</customwidget>
</customwidgets>
<resources/>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment