mirror of
https://github.com/KDE/konsole.git
synced 2026-06-10 23:15:38 -04:00
Move ManageProfiles dialog to Configure Konsole window
Change the stand alone ManageProfiles dialog into a tab inside the Configure Konsole window. Side effect is that Konsole KParts can't open manage profiles.
This commit is contained in:
@@ -85,7 +85,6 @@ set(konsoleprivate_SRCS ${sessionadaptors_SRCS}
|
||||
KeyBindingEditor.cpp
|
||||
KeyboardTranslator.cpp
|
||||
KeyboardTranslatorManager.cpp
|
||||
ManageProfilesDialog.cpp
|
||||
ProcessInfo.cpp
|
||||
Profile.cpp
|
||||
ProfileList.cpp
|
||||
@@ -147,7 +146,6 @@ ki18n_wrap_ui(konsoleprivate_SRCS ColorSchemeEditor.ui
|
||||
CopyInputDialog.ui
|
||||
EditProfileDialog.ui
|
||||
KeyBindingEditor.ui
|
||||
ManageProfilesDialog.ui
|
||||
RenameTabDialog.ui
|
||||
RenameTabWidget.ui
|
||||
HistorySizeDialog.ui
|
||||
@@ -155,6 +153,7 @@ ki18n_wrap_ui(konsoleprivate_SRCS ColorSchemeEditor.ui
|
||||
PrintOptions.ui
|
||||
settings/FileLocationSettings.ui
|
||||
settings/GeneralSettings.ui
|
||||
settings/ProfileSettings.ui
|
||||
settings/TabBarSettings.ui)
|
||||
|
||||
add_library(konsoleprivate ${konsoleprivate_SRCS})
|
||||
@@ -174,6 +173,7 @@ set(konsole_KDEINIT_SRCS
|
||||
main.cpp
|
||||
settings/FileLocationSettings.cpp
|
||||
settings/GeneralSettings.cpp
|
||||
settings/ProfileSettings.cpp
|
||||
settings/TabBarSettings.cpp)
|
||||
|
||||
kconfig_add_kcfg_files(konsole_KDEINIT_SRCS settings/KonsoleSettings.kcfgc)
|
||||
|
||||
@@ -49,7 +49,6 @@
|
||||
#include "BookmarkHandler.h"
|
||||
#include "SessionController.h"
|
||||
#include "ProfileList.h"
|
||||
#include "ManageProfilesDialog.h"
|
||||
#include "Session.h"
|
||||
#include "ViewManager.h"
|
||||
#include "SessionManager.h"
|
||||
@@ -58,6 +57,7 @@
|
||||
#include "WindowSystemInfo.h"
|
||||
#include "settings/FileLocationSettings.h"
|
||||
#include "settings/GeneralSettings.h"
|
||||
#include "settings/ProfileSettings.h"
|
||||
#include "settings/TabBarSettings.h"
|
||||
|
||||
using namespace Konsole;
|
||||
@@ -659,23 +659,27 @@ void MainWindow::newFromProfile(Profile::Ptr profile)
|
||||
}
|
||||
void MainWindow::showManageProfilesDialog()
|
||||
{
|
||||
ManageProfilesDialog* dialog = new ManageProfilesDialog(this);
|
||||
dialog->show();
|
||||
showSettingsDialog(true);
|
||||
}
|
||||
|
||||
void MainWindow::showSettingsDialog()
|
||||
void MainWindow::showSettingsDialog(const bool showProfilePage)
|
||||
{
|
||||
if (KConfigDialog::showDialog("settings"))
|
||||
return;
|
||||
|
||||
KConfigDialog* settingsDialog = new KConfigDialog(this, "settings", KonsoleSettings::self());
|
||||
settingsDialog->setFaceType(KPageDialog::List);
|
||||
settingsDialog->setFaceType(KPageDialog::Tabbed);
|
||||
|
||||
GeneralSettings* generalSettings = new GeneralSettings(settingsDialog);
|
||||
settingsDialog->addPage(generalSettings,
|
||||
i18nc("@title Preferences page name", "General"),
|
||||
"utilities-terminal");
|
||||
|
||||
ProfileSettings* profileSettings = new ProfileSettings(settingsDialog);
|
||||
KPageWidgetItem* profilePage = settingsDialog->addPage(profileSettings,
|
||||
i18nc("@title Preferences page name", "Profiles"),
|
||||
"configure");
|
||||
|
||||
TabBarSettings* tabBarSettings = new TabBarSettings(settingsDialog);
|
||||
settingsDialog->addPage(tabBarSettings,
|
||||
i18nc("@title Preferences page name", "TabBar"),
|
||||
@@ -686,6 +690,9 @@ void MainWindow::showSettingsDialog()
|
||||
i18nc("@title Preferences page name", "File Location"),
|
||||
"configure");
|
||||
|
||||
if (showProfilePage)
|
||||
settingsDialog->setCurrentPage(profilePage);
|
||||
|
||||
settingsDialog->show();
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ private slots:
|
||||
void newWindow();
|
||||
void showManageProfilesDialog();
|
||||
void activateMenuBar();
|
||||
void showSettingsDialog();
|
||||
void showSettingsDialog(const bool showProfilePage = false);
|
||||
void showShortcutsDialog();
|
||||
void newFromProfile(Profile::Ptr profile);
|
||||
void activeViewChanged(SessionController* controller);
|
||||
|
||||
30
src/Part.cpp
30
src/Part.cpp
@@ -36,7 +36,6 @@
|
||||
// Konsole
|
||||
#include "EditProfileDialog.h"
|
||||
#include "Emulation.h"
|
||||
#include "ManageProfilesDialog.h"
|
||||
#include "Session.h"
|
||||
#include "SessionController.h"
|
||||
#include "SessionManager.h"
|
||||
@@ -55,9 +54,6 @@ Part::Part(QWidget* parentWidget , QObject* parent, const QVariantList&)
|
||||
, _pluggedController(0)
|
||||
, _manageProfilesAction(0)
|
||||
{
|
||||
// setup global actions
|
||||
createGlobalActions();
|
||||
|
||||
// create view widget
|
||||
_viewManager = new ViewManager(this, actionCollection());
|
||||
_viewManager->setNavigationMethod(ViewManager::NoNavigation);
|
||||
@@ -86,18 +82,6 @@ Part::~Part()
|
||||
ProfileManager::instance()->saveSettings();
|
||||
}
|
||||
|
||||
void Part::createGlobalActions()
|
||||
{
|
||||
_manageProfilesAction = new QAction(i18n("Manage Profiles..."), this);
|
||||
connect(_manageProfilesAction, &QAction::triggered, this, static_cast<void(Part::*)()>(&Konsole::Part::showManageProfilesDialog));
|
||||
}
|
||||
|
||||
void Part::setupActionsForSession(SessionController* controller)
|
||||
{
|
||||
KActionCollection* collection = controller->actionCollection();
|
||||
collection->addAction("manage-profiles", _manageProfilesAction);
|
||||
}
|
||||
|
||||
bool Part::openFile()
|
||||
{
|
||||
return false;
|
||||
@@ -241,7 +225,6 @@ void Part::activeViewChanged(SessionController* controller)
|
||||
|
||||
// insert new controller
|
||||
insertChildClient(controller);
|
||||
setupActionsForSession(controller);
|
||||
|
||||
connect(controller, &Konsole::SessionController::titleChanged, this, &Konsole::Part::activeViewTitleChanged);
|
||||
activeViewTitleChanged(controller);
|
||||
@@ -280,19 +263,6 @@ void Part::activeViewTitleChanged(ViewProperties* properties)
|
||||
emit setWindowCaption(properties->title());
|
||||
}
|
||||
|
||||
void Part::showManageProfilesDialog()
|
||||
{
|
||||
showManageProfilesDialog(_viewManager->widget());
|
||||
}
|
||||
|
||||
void Part::showManageProfilesDialog(QWidget* parent)
|
||||
{
|
||||
ManageProfilesDialog* dialog = new ManageProfilesDialog(parent);
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
dialog->setShortcutEditorVisible(false);
|
||||
dialog->show();
|
||||
}
|
||||
|
||||
void Part::showEditCurrentProfileDialog(QWidget* parent)
|
||||
{
|
||||
Q_ASSERT(activeSession());
|
||||
|
||||
13
src/Part.h
13
src/Part.h
@@ -90,16 +90,6 @@ public slots:
|
||||
*/
|
||||
QStringList profileNameList() const;
|
||||
|
||||
/**
|
||||
* Shows the dialog used to manage profiles in Konsole. The dialog
|
||||
* will be non-modal and will delete itself when it is closed.
|
||||
*
|
||||
* This is experimental API and not guaranteed to be present in later
|
||||
* KDE 4 releases.
|
||||
*
|
||||
* @param parent The parent widget of the new dialog.
|
||||
*/
|
||||
void showManageProfilesDialog(QWidget* parent);
|
||||
/**
|
||||
* Shows the dialog used to edit the profile used by the active session. The
|
||||
* dialog will be non-modal and will delete itself when it is closed.
|
||||
@@ -198,15 +188,12 @@ protected:
|
||||
private slots:
|
||||
void activeViewChanged(SessionController* controller);
|
||||
void activeViewTitleChanged(ViewProperties* properties);
|
||||
void showManageProfilesDialog();
|
||||
void terminalExited();
|
||||
void newTab();
|
||||
void overrideTerminalShortcut(QKeyEvent*, bool& override);
|
||||
void sessionStateChanged(int state);
|
||||
private:
|
||||
Session* activeSession() const;
|
||||
void createGlobalActions();
|
||||
void setupActionsForSession(SessionController*);
|
||||
|
||||
private:
|
||||
ViewManager* _viewManager;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
// Own
|
||||
#include "ManageProfilesDialog.h"
|
||||
#include "ProfileSettings.h"
|
||||
|
||||
// Qt
|
||||
#include <QtCore/QFileInfo>
|
||||
@@ -42,95 +42,82 @@
|
||||
#include "TerminalDisplay.h"
|
||||
#include "SessionManager.h"
|
||||
#include "SessionController.h"
|
||||
#include "ui_ManageProfilesDialog.h"
|
||||
#include "ui_ProfileSettings.h"
|
||||
|
||||
using namespace Konsole;
|
||||
|
||||
ManageProfilesDialog::ManageProfilesDialog(QWidget* aParent)
|
||||
: QDialog(aParent)
|
||||
ProfileSettings::ProfileSettings(QWidget* aParent)
|
||||
: QWidget(aParent)
|
||||
, _sessionModel(new QStandardItemModel(this))
|
||||
{
|
||||
setWindowTitle(i18nc("@title:window", "Manage Profiles"));
|
||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
|
||||
QWidget *mainWidget = new QWidget(this);
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
setLayout(mainLayout);
|
||||
mainLayout->addWidget(mainWidget);
|
||||
connect(buttonBox, &QDialogButtonBox::accepted, this, &ManageProfilesDialog::slotAccepted);
|
||||
connect(buttonBox, &QDialogButtonBox::rejected, this, &ManageProfilesDialog::reject);
|
||||
mainLayout->addWidget(buttonBox);
|
||||
|
||||
|
||||
_ui = new Ui::ManageProfilesDialog();
|
||||
_ui->setupUi(mainWidget);
|
||||
setupUi(this);
|
||||
|
||||
// hide vertical header
|
||||
_ui->sessionTable->verticalHeader()->hide();
|
||||
_ui->sessionTable->setShowGrid(false);
|
||||
sessionTable->verticalHeader()->hide();
|
||||
sessionTable->setShowGrid(false);
|
||||
|
||||
_ui->sessionTable->setItemDelegateForColumn(FavoriteStatusColumn, new FavoriteItemDelegate(this));
|
||||
_ui->sessionTable->setItemDelegateForColumn(ShortcutColumn, new ShortcutItemDelegate(this));
|
||||
_ui->sessionTable->setEditTriggers(_ui->sessionTable->editTriggers() | QAbstractItemView::SelectedClicked);
|
||||
sessionTable->setItemDelegateForColumn(FavoriteStatusColumn, new FavoriteItemDelegate(this));
|
||||
sessionTable->setItemDelegateForColumn(ShortcutColumn, new ShortcutItemDelegate(this));
|
||||
sessionTable->setEditTriggers(sessionTable->editTriggers() | QAbstractItemView::SelectedClicked);
|
||||
|
||||
// populate the table with profiles
|
||||
populateTable();
|
||||
|
||||
// listen for changes to profiles
|
||||
connect(ProfileManager::instance(), &Konsole::ProfileManager::profileAdded, this, &Konsole::ManageProfilesDialog::addItems);
|
||||
connect(ProfileManager::instance(), &Konsole::ProfileManager::profileRemoved, this, &Konsole::ManageProfilesDialog::removeItems);
|
||||
connect(ProfileManager::instance(), &Konsole::ProfileManager::profileChanged, this, &Konsole::ManageProfilesDialog::updateItems);
|
||||
connect(ProfileManager::instance() , &Konsole::ProfileManager::favoriteStatusChanged, this, &Konsole::ManageProfilesDialog::updateFavoriteStatus);
|
||||
connect(ProfileManager::instance(), &Konsole::ProfileManager::profileAdded, this, &Konsole::ProfileSettings::addItems);
|
||||
connect(ProfileManager::instance(), &Konsole::ProfileManager::profileRemoved, this, &Konsole::ProfileSettings::removeItems);
|
||||
connect(ProfileManager::instance(), &Konsole::ProfileManager::profileChanged, this, &Konsole::ProfileSettings::updateItems);
|
||||
connect(ProfileManager::instance() , &Konsole::ProfileManager::favoriteStatusChanged, this, &Konsole::ProfileSettings::updateFavoriteStatus);
|
||||
|
||||
// resize the session table to the full width of the table
|
||||
_ui->sessionTable->horizontalHeader()->setHighlightSections(false);
|
||||
_ui->sessionTable->resizeColumnsToContents();
|
||||
sessionTable->horizontalHeader()->setHighlightSections(false);
|
||||
sessionTable->resizeColumnsToContents();
|
||||
|
||||
// allow a larger width for the shortcut column to account for the
|
||||
// increased with needed by the shortcut editor compared with just
|
||||
// displaying the text of the shortcut
|
||||
_ui->sessionTable->setColumnWidth(ShortcutColumn,
|
||||
_ui->sessionTable->columnWidth(ShortcutColumn) + 100);
|
||||
sessionTable->setColumnWidth(ShortcutColumn,
|
||||
sessionTable->columnWidth(ShortcutColumn) + 100);
|
||||
|
||||
// setup buttons
|
||||
connect(_ui->newProfileButton, &QPushButton::clicked, this, &Konsole::ManageProfilesDialog::createProfile);
|
||||
connect(_ui->editProfileButton, &QPushButton::clicked, this, &Konsole::ManageProfilesDialog::editSelected);
|
||||
connect(_ui->deleteProfileButton, &QPushButton::clicked, this, &Konsole::ManageProfilesDialog::deleteSelected);
|
||||
connect(_ui->setAsDefaultButton, &QPushButton::clicked, this, &Konsole::ManageProfilesDialog::setSelectedAsDefault);
|
||||
connect(newProfileButton, &QPushButton::clicked, this, &Konsole::ProfileSettings::createProfile);
|
||||
connect(editProfileButton, &QPushButton::clicked, this, &Konsole::ProfileSettings::editSelected);
|
||||
connect(deleteProfileButton, &QPushButton::clicked, this, &Konsole::ProfileSettings::deleteSelected);
|
||||
connect(setAsDefaultButton, &QPushButton::clicked, this, &Konsole::ProfileSettings::setSelectedAsDefault);
|
||||
}
|
||||
|
||||
void ManageProfilesDialog::showEvent(QShowEvent*)
|
||||
void ProfileSettings::showEvent(QShowEvent*)
|
||||
{
|
||||
Q_ASSERT(_ui->sessionTable->model());
|
||||
Q_ASSERT(sessionTable->model());
|
||||
|
||||
// try to ensure that all the text in all the columns is visible initially.
|
||||
// FIXME: this is not a good solution, look for a more correct way to do this
|
||||
|
||||
int totalWidth = 0;
|
||||
const int columnCount = _ui->sessionTable->model()->columnCount();
|
||||
const int columnCount = sessionTable->model()->columnCount();
|
||||
|
||||
for (int i = 0 ; i < columnCount ; i++)
|
||||
totalWidth += _ui->sessionTable->columnWidth(i);
|
||||
totalWidth += sessionTable->columnWidth(i);
|
||||
|
||||
// the margin is added to account for the space taken by the resize grips
|
||||
// between the columns, this ensures that a horizontal scroll bar is not added
|
||||
// automatically
|
||||
int margin = style()->pixelMetric(QStyle::PM_HeaderGripMargin) * columnCount;
|
||||
_ui->sessionTable->setMinimumWidth(totalWidth + margin);
|
||||
_ui->sessionTable->horizontalHeader()->setStretchLastSection(true);
|
||||
sessionTable->setMinimumWidth(totalWidth + margin);
|
||||
sessionTable->horizontalHeader()->setStretchLastSection(true);
|
||||
}
|
||||
|
||||
ManageProfilesDialog::~ManageProfilesDialog()
|
||||
ProfileSettings::~ProfileSettings()
|
||||
{
|
||||
delete _ui;
|
||||
}
|
||||
|
||||
void ManageProfilesDialog::slotAccepted()
|
||||
void ProfileSettings::slotAccepted()
|
||||
{
|
||||
ProfileManager::instance()->saveSettings();
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
void ManageProfilesDialog::itemDataChanged(QStandardItem* item)
|
||||
void ProfileSettings::itemDataChanged(QStandardItem* item)
|
||||
{
|
||||
if (item->column() == ShortcutColumn) {
|
||||
QKeySequence sequence = QKeySequence::fromString(item->text());
|
||||
@@ -151,7 +138,7 @@ void ManageProfilesDialog::itemDataChanged(QStandardItem* item)
|
||||
}
|
||||
}
|
||||
|
||||
int ManageProfilesDialog::rowForProfile(const Profile::Ptr profile) const
|
||||
int ProfileSettings::rowForProfile(const Profile::Ptr profile) const
|
||||
{
|
||||
const int rowCount = _sessionModel->rowCount();
|
||||
for (int i = 0; i < rowCount; i++) {
|
||||
@@ -162,7 +149,7 @@ int ManageProfilesDialog::rowForProfile(const Profile::Ptr profile) const
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
void ManageProfilesDialog::removeItems(const Profile::Ptr profile)
|
||||
void ProfileSettings::removeItems(const Profile::Ptr profile)
|
||||
{
|
||||
int row = rowForProfile(profile);
|
||||
if (row < 0)
|
||||
@@ -170,7 +157,7 @@ void ManageProfilesDialog::removeItems(const Profile::Ptr profile)
|
||||
|
||||
_sessionModel->removeRow(row);
|
||||
}
|
||||
void ManageProfilesDialog::updateItems(const Profile::Ptr profile)
|
||||
void ProfileSettings::updateItems(const Profile::Ptr profile)
|
||||
{
|
||||
const int row = rowForProfile(profile);
|
||||
if (row < 0)
|
||||
@@ -183,7 +170,7 @@ void ManageProfilesDialog::updateItems(const Profile::Ptr profile)
|
||||
|
||||
updateItemsForProfile(profile, items);
|
||||
}
|
||||
void ManageProfilesDialog::updateItemsForProfile(const Profile::Ptr profile, QList<QStandardItem*>& items) const
|
||||
void ProfileSettings::updateItemsForProfile(const Profile::Ptr profile, QList<QStandardItem*>& items) const
|
||||
{
|
||||
// Profile Name
|
||||
items[ProfileNameColumn]->setText(profile->name());
|
||||
@@ -207,7 +194,7 @@ void ManageProfilesDialog::updateItemsForProfile(const Profile::Ptr profile, QLi
|
||||
items[ShortcutColumn]->setData(QVariant::fromValue(profile), ShortcutRole);
|
||||
items[ShortcutColumn]->setToolTip(i18nc("@info:tooltip", "Double click to change shortcut"));
|
||||
}
|
||||
void ManageProfilesDialog::addItems(const Profile::Ptr profile)
|
||||
void ProfileSettings::addItems(const Profile::Ptr profile)
|
||||
{
|
||||
if (profile->isHidden())
|
||||
return;
|
||||
@@ -219,11 +206,11 @@ void ManageProfilesDialog::addItems(const Profile::Ptr profile)
|
||||
updateItemsForProfile(profile, items);
|
||||
_sessionModel->appendRow(items);
|
||||
}
|
||||
void ManageProfilesDialog::populateTable()
|
||||
void ProfileSettings::populateTable()
|
||||
{
|
||||
Q_ASSERT(!_ui->sessionTable->model());
|
||||
Q_ASSERT(!sessionTable->model());
|
||||
|
||||
_ui->sessionTable->setModel(_sessionModel);
|
||||
sessionTable->setModel(_sessionModel);
|
||||
|
||||
_sessionModel->clear();
|
||||
// setup session table
|
||||
@@ -239,18 +226,18 @@ void ManageProfilesDialog::populateTable()
|
||||
}
|
||||
updateDefaultItem();
|
||||
|
||||
connect(_sessionModel, &QStandardItemModel::itemChanged, this, &Konsole::ManageProfilesDialog::itemDataChanged);
|
||||
connect(_sessionModel, &QStandardItemModel::itemChanged, this, &Konsole::ProfileSettings::itemDataChanged);
|
||||
|
||||
// listen for changes in the table selection and update the state of the form's buttons
|
||||
// accordingly.
|
||||
//
|
||||
// it appears that the selection model is changed when the model itself is replaced,
|
||||
// so the signals need to be reconnected each time the model is updated.
|
||||
connect(_ui->sessionTable->selectionModel(), &QItemSelectionModel::selectionChanged, this, &Konsole::ManageProfilesDialog::tableSelectionChanged);
|
||||
connect(sessionTable->selectionModel(), &QItemSelectionModel::selectionChanged, this, &Konsole::ProfileSettings::tableSelectionChanged);
|
||||
|
||||
_ui->sessionTable->selectRow(0);
|
||||
sessionTable->selectRow(0);
|
||||
}
|
||||
void ManageProfilesDialog::updateDefaultItem()
|
||||
void ProfileSettings::updateDefaultItem()
|
||||
{
|
||||
Profile::Ptr defaultProfile = ProfileManager::instance()->defaultProfile();
|
||||
|
||||
@@ -273,60 +260,60 @@ void ManageProfilesDialog::updateDefaultItem()
|
||||
}
|
||||
}
|
||||
}
|
||||
void ManageProfilesDialog::tableSelectionChanged(const QItemSelection&)
|
||||
void ProfileSettings::tableSelectionChanged(const QItemSelection&)
|
||||
{
|
||||
const int selectedRows = _ui->sessionTable->selectionModel()->selectedRows().count();
|
||||
const int selectedRows = sessionTable->selectionModel()->selectedRows().count();
|
||||
const ProfileManager* manager = ProfileManager::instance();
|
||||
const bool isNotDefault = (selectedRows > 0) && currentProfile() != manager->defaultProfile();
|
||||
const bool isDeletable = (selectedRows > 1) ||
|
||||
(selectedRows == 1 && isProfileDeletable(currentProfile()));
|
||||
|
||||
_ui->newProfileButton->setEnabled(selectedRows < 2);
|
||||
newProfileButton->setEnabled(selectedRows < 2);
|
||||
// FIXME: At some point editing 2+ profiles no longer works
|
||||
_ui->editProfileButton->setEnabled(selectedRows == 1);
|
||||
editProfileButton->setEnabled(selectedRows == 1);
|
||||
// do not allow the default session type to be removed
|
||||
_ui->deleteProfileButton->setEnabled(isDeletable && isNotDefault);
|
||||
_ui->setAsDefaultButton->setEnabled(isNotDefault && (selectedRows < 2));
|
||||
deleteProfileButton->setEnabled(isDeletable && isNotDefault);
|
||||
setAsDefaultButton->setEnabled(isNotDefault && (selectedRows < 2));
|
||||
}
|
||||
void ManageProfilesDialog::deleteSelected()
|
||||
void ProfileSettings::deleteSelected()
|
||||
{
|
||||
foreach(const Profile::Ptr & profile, selectedProfiles()) {
|
||||
if (profile != ProfileManager::instance()->defaultProfile())
|
||||
ProfileManager::instance()->deleteProfile(profile);
|
||||
}
|
||||
}
|
||||
void ManageProfilesDialog::setSelectedAsDefault()
|
||||
void ProfileSettings::setSelectedAsDefault()
|
||||
{
|
||||
ProfileManager::instance()->setDefaultProfile(currentProfile());
|
||||
// do not allow the new default session type to be removed
|
||||
_ui->deleteProfileButton->setEnabled(false);
|
||||
_ui->setAsDefaultButton->setEnabled(false);
|
||||
deleteProfileButton->setEnabled(false);
|
||||
setAsDefaultButton->setEnabled(false);
|
||||
|
||||
// update font of new default item
|
||||
updateDefaultItem();
|
||||
}
|
||||
|
||||
void ManageProfilesDialog::moveUpSelected()
|
||||
void ProfileSettings::moveUpSelected()
|
||||
{
|
||||
Q_ASSERT(_sessionModel);
|
||||
|
||||
const int rowIndex = _ui->sessionTable->currentIndex().row();
|
||||
const int rowIndex = sessionTable->currentIndex().row();
|
||||
const QList<QStandardItem*>items = _sessionModel->takeRow(rowIndex);
|
||||
_sessionModel->insertRow(rowIndex - 1, items);
|
||||
_ui->sessionTable->selectRow(rowIndex - 1);
|
||||
sessionTable->selectRow(rowIndex - 1);
|
||||
}
|
||||
|
||||
void ManageProfilesDialog::moveDownSelected()
|
||||
void ProfileSettings::moveDownSelected()
|
||||
{
|
||||
Q_ASSERT(_sessionModel);
|
||||
|
||||
const int rowIndex = _ui->sessionTable->currentIndex().row();
|
||||
const int rowIndex = sessionTable->currentIndex().row();
|
||||
const QList<QStandardItem*>items = _sessionModel->takeRow(rowIndex);
|
||||
_sessionModel->insertRow(rowIndex + 1, items);
|
||||
_ui->sessionTable->selectRow(rowIndex + 1);
|
||||
sessionTable->selectRow(rowIndex + 1);
|
||||
}
|
||||
|
||||
void ManageProfilesDialog::createProfile()
|
||||
void ProfileSettings::createProfile()
|
||||
{
|
||||
// setup a temporary profile which is a clone of the selected profile
|
||||
// or the default if no profile is selected
|
||||
@@ -357,7 +344,7 @@ void ManageProfilesDialog::createProfile()
|
||||
}
|
||||
delete dialog.data();
|
||||
}
|
||||
void ManageProfilesDialog::editSelected()
|
||||
void ProfileSettings::editSelected()
|
||||
{
|
||||
QList<Profile::Ptr> profiles(selectedProfiles());
|
||||
|
||||
@@ -387,10 +374,10 @@ void ManageProfilesDialog::editSelected()
|
||||
dialog.setProfile(Profile::Ptr(group));
|
||||
dialog.exec();
|
||||
}
|
||||
QList<Profile::Ptr> ManageProfilesDialog::selectedProfiles() const
|
||||
QList<Profile::Ptr> ProfileSettings::selectedProfiles() const
|
||||
{
|
||||
QList<Profile::Ptr> list;
|
||||
QItemSelectionModel* selection = _ui->sessionTable->selectionModel();
|
||||
QItemSelectionModel* selection = sessionTable->selectionModel();
|
||||
if (!selection)
|
||||
return list;
|
||||
|
||||
@@ -401,9 +388,9 @@ QList<Profile::Ptr> ManageProfilesDialog::selectedProfiles() const
|
||||
|
||||
return list;
|
||||
}
|
||||
Profile::Ptr ManageProfilesDialog::currentProfile() const
|
||||
Profile::Ptr ProfileSettings::currentProfile() const
|
||||
{
|
||||
QItemSelectionModel* selection = _ui->sessionTable->selectionModel();
|
||||
QItemSelectionModel* selection = sessionTable->selectionModel();
|
||||
|
||||
if (!selection || selection->selectedRows().count() != 1)
|
||||
return Profile::Ptr();
|
||||
@@ -411,7 +398,7 @@ Profile::Ptr ManageProfilesDialog::currentProfile() const
|
||||
return selection->
|
||||
selectedIndexes().first().data(ProfileKeyRole).value<Profile::Ptr>();
|
||||
}
|
||||
bool ManageProfilesDialog::isProfileDeletable(Profile::Ptr profile) const
|
||||
bool ProfileSettings::isProfileDeletable(Profile::Ptr profile) const
|
||||
{
|
||||
static const QString systemDataLocation = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation).last() + QStringLiteral("konsole/");
|
||||
|
||||
@@ -435,7 +422,7 @@ bool ManageProfilesDialog::isProfileDeletable(Profile::Ptr profile) const
|
||||
return true;
|
||||
}
|
||||
}
|
||||
void ManageProfilesDialog::updateFavoriteStatus(Profile::Ptr profile, bool favorite)
|
||||
void ProfileSettings::updateFavoriteStatus(Profile::Ptr profile, bool favorite)
|
||||
{
|
||||
Q_ASSERT(_sessionModel);
|
||||
|
||||
@@ -448,9 +435,9 @@ void ManageProfilesDialog::updateFavoriteStatus(Profile::Ptr profile, bool favor
|
||||
}
|
||||
}
|
||||
}
|
||||
void ManageProfilesDialog::setShortcutEditorVisible(bool visible)
|
||||
void ProfileSettings::setShortcutEditorVisible(bool visible)
|
||||
{
|
||||
_ui->sessionTable->setColumnHidden(ShortcutColumn, !visible);
|
||||
sessionTable->setColumnHidden(ShortcutColumn, !visible);
|
||||
}
|
||||
void StyledBackgroundPainter::drawBackground(QPainter* painter, const QStyleOptionViewItem& option,
|
||||
const QModelIndex&)
|
||||
@@ -491,7 +478,7 @@ bool FavoriteItemDelegate::editorEvent(QEvent* aEvent, QAbstractItemModel*,
|
||||
if (aEvent->type() == QEvent::MouseButtonPress ||
|
||||
aEvent->type() == QEvent::KeyPress ||
|
||||
aEvent->type() == QEvent::MouseButtonDblClick) {
|
||||
Profile::Ptr profile = index.data(ManageProfilesDialog::ProfileKeyRole).value<Profile::Ptr>();
|
||||
Profile::Ptr profile = index.data(ProfileSettings::ProfileKeyRole).value<Profile::Ptr>();
|
||||
const bool isFavorite = ProfileManager::instance()->findFavorites().contains(profile);
|
||||
|
||||
ProfileManager::instance()->setFavorite(profile, !isFavorite);
|
||||
@@ -17,8 +17,8 @@
|
||||
02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef MANAGEPROFILESDIALOG_H
|
||||
#define MANAGEPROFILESDIALOG_H
|
||||
#ifndef PROFILESETTINGS_H
|
||||
#define PROFILESETTINGS_H
|
||||
|
||||
// Qt
|
||||
#include <QStyledItemDelegate>
|
||||
@@ -29,17 +29,13 @@
|
||||
|
||||
// Konsole
|
||||
#include "Profile.h"
|
||||
#include "ui_ProfileSettings.h"
|
||||
|
||||
class QItemSelection;
|
||||
class QShowEvent;
|
||||
class QStandardItem;
|
||||
class QStandardItemModel;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ManageProfilesDialog;
|
||||
}
|
||||
|
||||
namespace Konsole
|
||||
{
|
||||
/**
|
||||
@@ -47,7 +43,7 @@ namespace Konsole
|
||||
* the user to add new profiles, and remove or edit existing
|
||||
* profile types.
|
||||
*/
|
||||
class KONSOLEPRIVATE_EXPORT ManageProfilesDialog : public QDialog
|
||||
class ProfileSettings : public QWidget, private Ui::ProfileSettings
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -56,8 +52,8 @@ class KONSOLEPRIVATE_EXPORT ManageProfilesDialog : public QDialog
|
||||
|
||||
public:
|
||||
/** Constructs a new profile type with the specified parent. */
|
||||
explicit ManageProfilesDialog(QWidget* parent = 0);
|
||||
virtual ~ManageProfilesDialog();
|
||||
explicit ProfileSettings(QWidget* parent = 0);
|
||||
virtual ~ProfileSettings();
|
||||
|
||||
/**
|
||||
* Specifies whether the shortcut editor should be show.
|
||||
@@ -108,7 +104,6 @@ private:
|
||||
void populateTable();
|
||||
int rowForProfile(const Profile::Ptr profile) const;
|
||||
|
||||
Ui::ManageProfilesDialog* _ui;
|
||||
QStandardItemModel* _sessionModel;
|
||||
|
||||
static const int ProfileNameColumn = 0;
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ManageProfilesDialog</class>
|
||||
<widget class="QWidget" name="ManageProfilesDialog">
|
||||
<class>ProfileSettings</class>
|
||||
<widget class="QWidget" name="ProfileSettings">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
Reference in New Issue
Block a user