Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 4f71fabf authored by Robert Knight's avatar Robert Knight

More Session -> Profile renaming. Make default profile bold in 'Manage...

More Session -> Profile renaming.  Make default profile bold in 'Manage Profiles' dialog.  Show KDE directory selection dialog when clicking on initial directory edit button in profile edit dialog.

svn path=/branches/work/konsole-split-view/; revision=659341
parent 1a0b94d8
......@@ -102,7 +102,7 @@ kde4_automoc(${konsole_KDEINIT_SRCS})
kde4_add_kdeinit_executable( konsole ${konsole_KDEINIT_SRCS})
target_link_libraries(kdeinit_konsole ${KDE4_KDEPRINT_LIBS} ${QT_QTXML_LIBRARY} ${KDE4_KNOTIFYCONFIG_LIBS} )
target_link_libraries(kdeinit_konsole ${KDE4_KDEPRINT_LIBS} ${QT_QTXML_LIBRARY} ${KDE4_KNOTIFYCONFIG_LIBS} ${KDE4_KFILE_LIBS} )
# XRender library for true transparency support
if(X11_Xrender_FOUND)
......@@ -165,7 +165,7 @@ kde4_add_plugin(konsolepart WITH_PREFIX ${konsolepart_PART_SRCS})
set_target_properties(konsolepart PROPERTIES DEFINE_SYMBOL KONSOLE_PART)
target_link_libraries(konsolepart ${KDE4_KDEUI_LIBS} ${KDE4_KPARTS_LIBS} )
target_link_libraries(konsolepart ${KDE4_KDEUI_LIBS} ${KDE4_KPARTS_LIBS} ${KDE4_KFILE_LIBS} )
if(X11_XTest_LIB)
target_link_libraries(konsolepart ${X11_XTest_LIB} )
endif(X11_XTest_LIB)
......
......@@ -26,6 +26,7 @@
// KDE
#include <KFontDialog>
#include <KIcon>
#include <KDirSelectDialog>
// Konsole
#include "ColorScheme.h"
......@@ -48,14 +49,17 @@ EditProfileDialog::~EditProfileDialog()
{
delete _ui;
}
void EditProfileDialog::setSessionType(const QString& key)
void EditProfileDialog::setProfile(const QString& key)
{
_sessionTypeKey = key;
_profileKey = key;
const Profile* info = SessionManager::instance()->sessionType(key);
const Profile* info = SessionManager::instance()->profile(key);
Q_ASSERT( info );
// update caption
setCaption( QString("Edit Profile \"%1\"").arg(info->name()) );
// setup each page of the dialog
setupGeneralPage(info);
setupAppearencePage(info);
......@@ -69,6 +73,19 @@ void EditProfileDialog::setupGeneralPage(const Profile* info)
_ui->commandEdit->setText( info->command(false,false) );
_ui->initialDirEdit->setText( info->defaultWorkingDirectory() );
_ui->iconSelectButton->setIcon( KIcon(info->icon()) );
// signals and slots
connect( _ui->dirSelectButton , SIGNAL(clicked()) , this , SLOT(selectInitialDir()) );
}
void EditProfileDialog::selectInitialDir()
{
const KUrl& url = KDirSelectDialog::selectDirectory(_ui->initialDirEdit->text(),
true,
0L,
i18n("Select Initial Directory"));
if ( !url.isEmpty() )
_ui->initialDirEdit->setText(url.path());
}
void EditProfileDialog::setupAppearencePage(const Profile* info)
{
......
......@@ -58,15 +58,17 @@ public:
*
* @param key The key for the session type provided by the SessionManager instance
*/
void setSessionType(const QString& key);
void setProfile(const QString& key);
/**
* Returns a session info object representing the new or modified session
* type.
* Returns a profile instance representing the new or modified profile.
*/
Profile* newSessionInfo();
Profile* newProfile();
private slots:
// general page
void selectInitialDir();
// appearence page
void setFontSize(int pointSize);
void showFontDialog();
......@@ -87,7 +89,7 @@ private:
void applyAdvancedPage(MutableSessionInfo* info);
Ui::EditProfileDialog* _ui;
QString _sessionTypeKey;
QString _profileKey;
};
/**
......
This diff is collapsed.
......@@ -199,8 +199,8 @@ void MainWindow::setSessionList(ProfileList* list)
{
sessionListChanged(list->actions());
connect( list , SIGNAL(sessionSelected(const QString&)) , this ,
SLOT(sessionSelected(const QString&)) );
connect( list , SIGNAL(profileSelected(const QString&)) , this ,
SLOT(newFromProfile(const QString&)) );
connect( list , SIGNAL(actionsChanged(const QList<QAction*>&)) , this ,
SLOT(sessionListChanged(const QList<QAction*>&)) );
......@@ -229,7 +229,7 @@ void MainWindow::showShortcutsDialog()
KShortcutsDialog::configure( actionCollection() );
}
void MainWindow::sessionSelected(const QString& key)
void MainWindow::newFromProfile(const QString& key)
{
emit requestSession(key,_viewManager);
}
......
......@@ -101,7 +101,7 @@ class MainWindow : public KXmlGuiWindow
void showManageProfilesDialog();
void showRemoteConnectionDialog();
void showShortcutsDialog();
void sessionSelected(const QString&);
void newFromProfile(const QString&);
void activeViewChanged(SessionController* controller);
void activeViewTitleChanged(ViewProperties*);
......
......@@ -49,9 +49,9 @@ ManageProfilesDialog::ManageProfilesDialog(QWidget* parent)
// update table and listen for changes to the session types
updateTableModel();
connect( SessionManager::instance() , SIGNAL(sessionTypeAdded(const QString&)) , this,
connect( SessionManager::instance() , SIGNAL(profileAdded(const QString&)) , this,
SLOT(updateTableModel()) );
connect( SessionManager::instance() , SIGNAL(sessionTypeRemoved(const QString&)) , this,
connect( SessionManager::instance() , SIGNAL(profileRemoved(const QString&)) , this,
SLOT(updateTableModel()) );
// ensure that session names are fully visible
......@@ -79,17 +79,18 @@ void ManageProfilesDialog::updateTableModel()
_sessionModel = new QStandardItemModel(this);
_sessionModel->setHorizontalHeaderLabels( QStringList() << "Name"
<< "Show in Menu" );
QListIterator<QString> keyIter( SessionManager::instance()->availableSessionTypes() );
QListIterator<QString> keyIter( SessionManager::instance()->availableProfiles() );
while ( keyIter.hasNext() )
{
const QString& key = keyIter.next();
Profile* info = SessionManager::instance()->sessionType(key);
Profile* info = SessionManager::instance()->profile(key);
QList<QStandardItem*> itemList;
QStandardItem* item = new QStandardItem( info->name() );
item->setData(key);
const bool isFavorite = SessionManager::instance()->favorites().contains(key);
QStandardItem* favoriteItem = new QStandardItem();
......@@ -104,6 +105,7 @@ void ManageProfilesDialog::updateTableModel()
_sessionModel->appendRow(itemList);
}
updateDefaultItem();
_ui->sessionTable->setModel(_sessionModel);
// listen for changes in the table selection and update the state of the form's buttons
......@@ -123,11 +125,34 @@ void ManageProfilesDialog::updateTableModel()
tableSelectionChanged( _ui->sessionTable->selectionModel()->selection() );
}
void ManageProfilesDialog::updateDefaultItem()
{
const QString& defaultKey = SessionManager::instance()->defaultProfileKey();
for ( int i = 0 ; i < _sessionModel->rowCount() ; i++ )
{
QStandardItem* item = _sessionModel->item(i);
QFont font = item->font();
bool isDefault = ( defaultKey == item->data().value<QString>() );
if ( isDefault && !font.bold() )
{
font.setBold(true);
item->setFont(font);
}
else if ( !isDefault && font.bold() )
{
font.setBold(false);
item->setFont(font);
}
}
}
void ManageProfilesDialog::tableSelectionChanged(const QItemSelection& selection)
{
bool enable = !selection.indexes().isEmpty();
const SessionManager* manager = SessionManager::instance();
const bool isNotDefault = enable && selectedKey() != manager->defaultSessionKey();
const bool isNotDefault = enable && selectedKey() != manager->defaultProfileKey();
_ui->editSessionButton->setEnabled(enable);
// do not allow the default session type to be removed
......@@ -136,28 +161,31 @@ void ManageProfilesDialog::tableSelectionChanged(const QItemSelection& selection
}
void ManageProfilesDialog::deleteSelected()
{
Q_ASSERT( selectedKey() != SessionManager::instance()->defaultSessionKey() );
Q_ASSERT( selectedKey() != SessionManager::instance()->defaultProfileKey() );
SessionManager::instance()->deleteSessionType(selectedKey());
SessionManager::instance()->deleteProfile(selectedKey());
}
void ManageProfilesDialog::setSelectedAsDefault()
{
SessionManager::instance()->setDefaultSessionType(selectedKey());
SessionManager::instance()->setDefaultProfile(selectedKey());
// do not allow the new default session type to be removed
_ui->deleteSessionButton->setEnabled(false);
_ui->setAsDefaultButton->setEnabled(false);
_ui->setAsDefaultButton->setEnabled(false);
// update font of new default item
updateDefaultItem();
}
void ManageProfilesDialog::newType()
{
EditProfileDialog dialog(this);
// base new type off the default session type
dialog.setSessionType(QString());
dialog.setProfile(QString());
dialog.exec();
}
void ManageProfilesDialog::editSelected()
{
EditProfileDialog dialog(this);
dialog.setSessionType(selectedKey());
dialog.setProfile(selectedKey());
dialog.exec();
}
QString ManageProfilesDialog::selectedKey() const
......
......@@ -39,16 +39,16 @@ namespace Konsole
{
/**
* A dialog which lists the available types of sessions and allows
* the user to add new sessions, and remove or edit existing
* session types.
* A dialog which lists the available types of profiles and allows
* the user to add new profiles, and remove or edit existing
* profile types.
*/
class ManageProfilesDialog : public KDialog
{
Q_OBJECT
public:
/** Constructs a new session type with the specified parent. */
/** Constructs a new profile type with the specified parent. */
ManageProfilesDialog(QWidget* parent = 0);
virtual ~ManageProfilesDialog();
......@@ -62,13 +62,16 @@ private slots:
// selection changes
void tableSelectionChanged(const QItemSelection&);
// updates the session table to be in sync with the
// updates the profile table to be in sync with the
// session manager
void updateTableModel();
private:
QString selectedKey() const; // return the key associated with the currently selected
// item in the session table
// item in the profile table
void updateDefaultItem(); // updates the font of the items to match
// their default / non-default profile status
Ui::ManageProfilesDialog* _ui;
QStandardItemModel* _sessionModel;
};
......
......@@ -41,7 +41,7 @@ void ProfileList::favoriteChanged(const QString& key,bool isFavorite)
{
if ( isFavorite )
{
Profile* info = SessionManager::instance()->sessionType(key);
Profile* info = SessionManager::instance()->profile(key);
QAction* action = _group->addAction(info->name());
action->setIcon( KIcon(info->icon()) );
......@@ -66,9 +66,9 @@ void ProfileList::favoriteChanged(const QString& key,bool isFavorite)
void ProfileList::triggered(QAction* action)
{
// assert that session key is still valid
Q_ASSERT( SessionManager::instance()->sessionType( action->data().toString() ) );
Q_ASSERT( SessionManager::instance()->profile( action->data().toString() ) );
emit sessionSelected( action->data().toString() );
emit profileSelected( action->data().toString() );
}
QList<QAction*> ProfileList::actions()
......
......@@ -12,10 +12,10 @@ namespace Konsole
{
/**
* ProfileList provides a list of actions which represent types of session that a SessionManager can
* create. These actions can be plugged into a GUI
* ProfileList provides a list of actions which represent session profiles that a SessionManager
* can create a session from. These actions can be plugged into a GUI
*
* The user-data associated with each session can be passed to the createSession() method of the
* The user-data associated with each session can be passed to the createProfile() method of the
* SessionManager to create a new terminal session.
*/
class ProfileList : public QObject
......@@ -38,9 +38,9 @@ signals:
/**
* Emitted when the user selects an action from the list.
*
* @param key The session type key associated with the selected action.
* @param key The profile key associated with the selected action.
*/
void sessionSelected(const QString& key);
void profileSelected(const QString& key);
/**
* Emitted when the list of actions changes.
*/
......
......@@ -465,7 +465,7 @@ void SessionController::debugProcess()
void SessionController::editCurrentProfile()
{
EditProfileDialog dialog(_view);
dialog.setSessionType(_session->type());
dialog.setProfile(_session->type());
dialog.exec();
}
void SessionController::renameSession()
......
......@@ -243,41 +243,6 @@ QString Profile::defaultWorkingDirectory() const
return _config->readPathEntry("Cwd");
}
/*MutableSessionInfo::MutableSessionInfo(const QString& path)
: Profile(path) {}
void MutableSessionInfo::setName(const QString& name) { _name = name; }
QString MutableSessionInfo::name() const { return _name; }
void MutableSessionInfo::setCommand(const QString& command) { _command = command; }
QString MutableSessionInfo::command(bool,bool) const { return _command; }
void MutableSessionInfo::setArguments(const QStringList& arguments){ _arguments = arguments; }
QStringList MutableSessionInfo::arguments() const { return _arguments; }
void MutableSessionInfo::setTerminal(const QString& terminal) { _terminal = terminal; }
QString MutableSessionInfo::terminal() const { return _terminal; }
void MutableSessionInfo::setKeyboardSetup(const QString& keyboard) { _keyboardSetup = keyboard; }
QString MutableSessionInfo::keyboardSetup() const { return _keyboardSetup; }
void MutableSessionInfo::setColorScheme(const QString& colorScheme) { _colorScheme = colorScheme; }
QString MutableSessionInfo::colorScheme() const { return _colorScheme; }
void MutableSessionInfo::setDefaultWorkingDirectory(const QString& dir) { _defaultWorkingDirectory = dir; }
QString MutableSessionInfo::defaultWorkingDirectory() const { return _defaultWorkingDirectory; }
void MutableSessionInfo::setNewSessionText(const QString& text) { _newSessionText = text; }
QString MutableSessionInfo::newSessionText() const { return _newSessionText; }
void MutableSessionInfo::setDefaultFont(const QFont& font) { _defaultFont = font; }
QFont MutableSessionInfo::defaultFont() const { return _defaultFont ; }
void MutableSessionInfo::setIcon(const QString& icon) { _icon = icon; }
QString MutableSessionInfo::icon() const { return _icon; }
*/
SessionManager::SessionManager()
{
//locate default session
......@@ -302,14 +267,14 @@ SessionManager::SessionManager()
QString configFile = fileIter.next();
Profile* newType = new Profile(configFile);
QString sessionKey = addSessionType( newType );
QString sessionKey = addProfile( newType );
if ( QFileInfo(configFile).fileName() == defaultSessionFilename )
_defaultSessionType = sessionKey;
_defaultProfile = sessionKey;
}
Q_ASSERT( _types.count() > 0 );
Q_ASSERT( !_defaultSessionType.isEmpty() );
Q_ASSERT( !_defaultProfile.isEmpty() );
// now that the session types have been loaded,
// get the list of favorite sessions
......@@ -350,7 +315,7 @@ Session* SessionManager::createSession(QString key )
const Profile* info = 0;
if ( key.isEmpty() )
info = defaultSessionType();
info = defaultProfile();
else
info = _types[key];
......@@ -399,15 +364,15 @@ void SessionManager::sessionTerminated(Session* session)
session->deleteLater();
}
QList<QString> SessionManager::availableSessionTypes() const
QList<QString> SessionManager::availableProfiles() const
{
return _types.keys();
}
Profile* SessionManager::sessionType(const QString& key) const
Profile* SessionManager::profile(const QString& key) const
{
if ( key.isEmpty() )
return defaultSessionType();
return defaultProfile();
if ( _types.contains(key) )
return _types[key];
......@@ -415,14 +380,14 @@ Profile* SessionManager::sessionType(const QString& key) const
return 0;
}
Profile* SessionManager::defaultSessionType() const
Profile* SessionManager::defaultProfile() const
{
return _types[_defaultSessionType];
return _types[_defaultProfile];
}
QString SessionManager::defaultSessionKey() const
QString SessionManager::defaultProfileKey() const
{
return _defaultSessionType;
return _defaultProfile;
}
void SessionManager::addSetting( Setting setting, Source source, const QVariant& value)
......@@ -452,7 +417,7 @@ QVariant SessionManager::activeSetting( Setting setting ) const
return value;
}
QString SessionManager::addSessionType(Profile* type)
QString SessionManager::addProfile(Profile* type)
{
QString key;
......@@ -467,14 +432,14 @@ QString SessionManager::addSessionType(Profile* type)
_types.insert(key,type);
emit sessionTypeAdded(key);
emit profileAdded(key);
return key;
}
void SessionManager::deleteSessionType(const QString& key)
void SessionManager::deleteProfile(const QString& key)
{
Profile* type = sessionType(key);
Profile* type = profile(key);
setFavorite(key,false);
......@@ -484,18 +449,18 @@ void SessionManager::deleteSessionType(const QString& key)
delete type;
}
emit sessionTypeRemoved(key);
emit profileRemoved(key);
qWarning() << __FUNCTION__ << "TODO: Make this change persistant.";
//TODO Store this information persistantly
}
void SessionManager::setDefaultSessionType(const QString& key)
void SessionManager::setDefaultProfile(const QString& key)
{
Q_ASSERT ( _types.contains(key) );
_defaultSessionType = key;
_defaultProfile = key;
Profile* info = sessionType(key);
Profile* info = profile(key);
Q_ASSERT( QFile::exists(info->path()) );
QFileInfo fileInfo(info->path());
......@@ -535,7 +500,7 @@ void SessionManager::setFavorite(const QString& key , bool favorite)
void SessionManager::loadFavorites()
{
KSharedConfigPtr appConfig = KGlobal::config();
KConfigGroup favoriteGroup = appConfig->group("Favorite Sessions");
KConfigGroup favoriteGroup = appConfig->group("Favorite Profiles");
qDebug() << "loading favorites";
......@@ -562,7 +527,7 @@ void SessionManager::loadFavorites()
void SessionManager::saveFavorites()
{
KSharedConfigPtr appConfig = KGlobal::config();
KConfigGroup favoriteGroup = appConfig->group("Favorite Sessions");
KConfigGroup favoriteGroup = appConfig->group("Favorite Profiles");
QStringList names;
QSetIterator<QString> keyIter(_favorites);
......@@ -570,9 +535,9 @@ void SessionManager::saveFavorites()
{
const QString& key = keyIter.next();
Q_ASSERT( _types.contains(key) && sessionType(key) != 0 );
Q_ASSERT( _types.contains(key) && profile(key) != 0 );
names << sessionType(key)->name();
names << profile(key)->name();
}
favoriteGroup.writeEntry("Favorites",names);
......
......@@ -116,7 +116,7 @@ private:
* as root and whether or not the binary
* for the session is available.
*
* The availability of the session type is not determined until the
* The availability of the profile is not determined until the
* isAvailable() method is called.
*
*/
......@@ -147,7 +147,7 @@ public:
/**
* Construct a new Profile
* to provide information on a session type.
* to provide information on a profile.
*
* @p path Path to the configuration file
* for this type of session
......@@ -156,9 +156,9 @@ public:
virtual ~Profile();
/** Sets the parent session type. */
/** Sets the parent profile. */
void setParent( Profile* parent );
/** Returns the parent session type. */
/** Returns the parent profile. */
Profile* parent() const;
/** Sets the value of a property. */
virtual void setProperty( Property property , const QVariant& value );
......@@ -171,11 +171,11 @@ public:
*/
QString path() const;
/** Returns the title of the session type */
/** Returns the title of the profile */
QString name() const;
/**
* Returns the path of an icon associated
* with this session type
* with this profile
*/
QString icon() const;
/**
......@@ -259,12 +259,12 @@ private:
/**
* Creates new terminal sessions using information in configuration files.
* Information about the available session kinds can be obtained using
* availableSessionTypes(). Call createSession() to create a new session.
* availableprofiles(). Call createSession() to create a new session.
* The session will automatically notify the SessionManager when it finishes running.
*
* Session types in the manager have a concept of favorite status, which can be used
* by widgets and dialogs in the application decide which sessions to list and
* how to display them. The favorite status of a session type can be altered using
* how to display them. The favorite status of a profile can be altered using
* setFavorite() and retrieved using isFavorite()
*/
class SessionManager : public QObject
......@@ -274,7 +274,7 @@ Q_OBJECT
public:
/**
* Constructs a new session manager and loads information about the available
* session types.
* profiles.
*/
SessionManager();
virtual ~SessionManager();
......@@ -304,16 +304,16 @@ public:
};
/**
* Returns a list of keys for registered session types.
* Returns a list of keys for registered profiles.
*/
QList<QString> availableSessionTypes() const;
QList<QString> availableProfiles() const;
/**
* Returns the session information object for the session type with the specified
* key or 0 if no session type with the specified key exists.
* Returns the session information object for the profile with the specified
* key or 0 if no profile with the specified key exists.
*
* If @p key is empty, a pointer to the default session type is returned.
* If @p key is empty, a pointer to the default profile is returned.
*/
Profile* sessionType(const QString& key) const;
Profile* profile(const QString& key) const;
/**
* Registers a new type of session and returns the key
......@@ -322,18 +322,18 @@ public:
* The favorite status of the session ( as returned by isFavorite() ) is set
* to false by default.
*/
QString addSessionType(Profile* type);
QString addProfile(Profile* type);
/**
* Returns a Profile object describing the default type of session, which is used
* if createSession() is called with an empty configPath argument.
*/
Profile* defaultSessionType() const;
Profile* defaultProfile() const;
/**
* Returns the key for the default session type.
* Returns the key for the default profile.
*/
QString defaultSessionKey() const;
QString defaultProfileKey() const;
/**
* Adds a setting which will be considered when creating new sessions.
......@@ -341,7 +341,7 @@ public:
* can be specified by multiple different sources. The
*
* For example, the working directory in which a new session starts is specified
* in the configuration file for that session type, but can be overridden
* in the configuration file for that profile, but can be overridden
* by creating a new session from a bookmark or specifying what to use on
* the command line.
*
......@@ -370,9 +370,9 @@ public:
QVariant activeSetting( Setting setting ) const;
/**
* Creates a new session of the specified type, using the settings specified
* using addSetting() and from session type associated with the specified key.
* The session type must have been previously registered using addSessionType()
* Creates a new session from the specified profile, using the settings specified
* using addSetting() and from profile associated with the specified key.
* The profile must have been previously registered using addprofile()
* or upon construction of the SessionManager.
*
* The new session has no views associated with it. A new TerminalDisplay view
......@@ -390,25 +390,25 @@ public:
const QList<Session*> sessions();
/**
* Deletes the session type with the specified key.
* The configuration file associated with the session type is
* Deletes the profile with the specified key.
* The configuration file associated with the profile is
* deleted if possible.
*/
void deleteSessionType(const QString& key);
void deleteProfile(const QString& key);
/**
* Sets the session type with the specified key
* Sets the profile with the specified key
* as the default type.
*/
void setDefaultSessionType(const QString& key);
void setDefaultProfile(const QString& key);
/**
* Returns the set of keys for the user's favorite session types.
* Returns the set of keys for the user's favorite profiles.
*/
QSet<QString> favorites() const;
/**
* Specifies whether a session type should be included in the user's
* Specifies whether a profile should be included in the user's
* list of favorite sessions.
*/
void setFavorite(const QString& key , bool favorite);
......@@ -423,14 +423,14 @@ public:
static SessionManager* instance();
signals:
/** Emitted when a session type is added to the manager. */
void sessionTypeAdded(const QString& key);