~ubuntu-branches/ubuntu/quantal/psi/quantal

« back to all changes in this revision

Viewing changes to src/activeprofiles.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2008-08-28 18:46:52 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080828184652-iiik12dl91nq7cdi
Tags: 0.12-2
Uploading to unstable (Closes: Bug#494352)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * activeprofiles.cpp - Class for interacting with other psi instances
 
3
 * Copyright (C) 2006  Maciej Niedzielski
 
4
 * Copyright (C) 2006-2007  Martin Hostettler
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU General Public License
 
8
 * as published by the Free Software Foundation; either version 2
 
9
 * of the License, or (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this library; if not, write to the Free Software
 
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
19
 *
 
20
 */
 
21
 
 
22
#include "activeprofiles.h"
 
23
#include <QMessageBox>
 
24
#include "profiles.h"
 
25
 
 
26
 
 
27
ActiveProfiles* ActiveProfiles::instance_ = 0;
 
28
 
 
29
/**
 
30
 * \fn virtual ActiveProfiles::~ActiveProfiles();
 
31
 * \brief Destroys the object.
 
32
 */
 
33
 
 
34
/**
 
35
 * \fn bool ActiveProfiles::isActive(const QString &profile) const;
 
36
 * \brief Returns true is \a profile is running.
 
37
 */
 
38
 
 
39
/**
 
40
 * \fn bool ActiveProfiles::setThisProfile(const QString &profile);
 
41
 * \brief Registeres this application instance as \a profile.
 
42
 * Note: you can call this function multiple times with the same value of \a profile.
 
43
 */
 
44
 
 
45
/**
 
46
 * \fn void ActiveProfiles::unsetThisProfile();
 
47
 * \brief Unregistered this application profile.
 
48
 */
 
49
 
 
50
/**
 
51
 * \fn QString ActiveProfiles::thisProfile() const;
 
52
 * \brief Returns the profile name registered for this application instance.
 
53
 * Returns empty string if no profile is registered.
 
54
 */
 
55
 
 
56
/**
 
57
 * \fn ActiveProfiles::ActiveProfiles(const QString &name);
 
58
 * \brief Creates new object and registers this application with its \a name.
 
59
 */
 
60
 
 
61
/**
 
62
 * \brief Returns the instance of ActiveProfiles.
 
63
 */
 
64
ActiveProfiles* ActiveProfiles::instance()
 
65
{
 
66
        if (!instance_) {
 
67
                instance_ = new ActiveProfiles();
 
68
        }
 
69
 
 
70
        return instance_;
 
71
}
 
72
 
 
73
/**
 
74
 * \fn ActiveProfiles::ActiveProfiles()
 
75
 * \brief Creates new object.
 
76
 */
 
77
 
 
78
 
 
79
/**
 
80
 * \fn bool ActiveProfiles::raiseOther(QString profile, bool withUI) const
 
81
 * \brief raises the main windows of another psi instance.
 
82
 */
 
83
 
 
84
/**
 
85
 * \brief Requests other Psi instance to open \a uri.
 
86
 * If \a profile is not running, other active instance is selected.
 
87
 * If the request cannot be sent, function returns false.
 
88
 */
 
89
bool ActiveProfiles::sendOpenUri(const QUrl &uri, const QString &profile) const
 
90
{
 
91
        return sendOpenUri(uri.toString(), profile);
 
92
}
 
93
 
 
94
/**
 
95
 * \fn bool ActiveProfiles::sendOpenUri(const QString &uri, const QString &profile) const
 
96
 * \brief Requests other Psi instance to open \a uri.
 
97
 * If \a profile is not running, other active instance is selected.
 
98
 * If the request cannot be sent, function returns false.
 
99
 */
 
100
 
 
101
 
 
102
/**
 
103
 * \fn void ActiveProfiles::openUri(const QUrl &uri);
 
104
 * \brief Signal emitted when other Psi instance requested to open \a uri.
 
105
 */
 
106
 
 
107
/**
 
108
 * \brief Picks one of running Psi instances and returns its profile name.
 
109
 */
 
110
QString ActiveProfiles::pickProfile() const
 
111
{
 
112
        QStringList profiles = getProfilesList();
 
113
        foreach (QString p, profiles) {
 
114
                if (isActive(p)) {
 
115
                        return p;
 
116
                }
 
117
        }
 
118
        return "";
 
119
}