~ubuntu-branches/ubuntu/oneiric/psi/oneiric

« back to all changes in this revision

Viewing changes to src/profiledlg.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2005-01-10 17:41:43 UTC
  • mfrom: (1.2.1 upstream) (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050110174143-ltocv5zapl6blf5d
Tags: 0.9.3-1
* New upstream release
* Cleaned up debian/rules (some things are done by upstream Makefiles now)
* Fixed some lintian warnings:
  - removed executable bit from some .png files
  - moved psi.desktop to /usr/share/applications
* Updated menu files

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/****************************************************************************
2
 
** profiledlg.cpp - dialogs for manipulating profiles
3
 
** Copyright (C) 2001, 2002  Justin Karneges
4
 
**
5
 
** This program is free software; you can redistribute it and/or
6
 
** modify it under the terms of the GNU General Public License
7
 
** as published by the Free Software Foundation; either version 2
8
 
** of the License, or (at your option) any later version.
9
 
**
10
 
** This program is distributed in the hope that it will be useful,
11
 
** but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
** GNU General Public License for more details.
14
 
**
15
 
** You should have received a copy of the GNU General Public License
16
 
** along with this program; if not, write to the Free Software
17
 
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 
**
19
 
****************************************************************************/
 
1
/*
 
2
 * profiledlg.cpp - dialogs for manipulating profiles
 
3
 * Copyright (C) 2001-2003  Justin Karneges
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU General Public License
 
7
 * as published by the Free Software Foundation; either version 2
 
8
 * of the License, or (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this library; if not, write to the Free Software
 
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
 *
 
19
 */
20
20
 
21
21
#include"profiledlg.h"
22
22
#include"common.h"
31
31
#include<qfile.h>
32
32
#include<qfileinfo.h>
33
33
#include<qbuttongroup.h>
 
34
#include<qwhatsthis.h>
34
35
#include"profiles.h"
35
 
 
 
36
#include"iconwidget.h"
 
37
 
 
38
#include <qpainter.h>
 
39
class StretchLogoLabel : public QLabel
 
40
{
 
41
public:
 
42
        StretchLogoLabel(QPixmap pix, QWidget *label, const char *name = 0)
 
43
        : QLabel((QWidget*)label->parent(), name)
 
44
        {
 
45
                setPixmap(pix);
 
46
                setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
 
47
                replaceWidget(label, this);
 
48
        }
 
49
 
 
50
        void drawContents(QPainter *p)
 
51
        {
 
52
                p->drawTiledPixmap(0, 0, width(), height(), *pixmap());
 
53
        }
 
54
};
36
55
 
37
56
ProfileOpenDlg::ProfileOpenDlg(const QString &def, const VarList &_langs, const QString &curLang, QWidget *parent, const char *name)
38
57
:ProfileOpenUI(parent, name, TRUE)
39
58
{
40
 
        setCaption(CAP(tr("Open Profile")));
 
59
        setCaption(CAP(caption()));
41
60
 
42
61
        langs = _langs;
43
62
 
44
63
        // insert the logo
45
 
        QPixmap *logo = pix_logo;
46
 
        lb_logo->setPixmap(*logo);
47
 
        lb_logo->setFixedSize(logo->width(), logo->height());
 
64
        QPixmap logo = (QPixmap)IconsetFactory::icon("psi/psiLogo").pixmap();
 
65
        lb_logo->setPixmap(logo);
 
66
        lb_logo->setFixedSize(logo.width(), logo.height());
48
67
        lb_logo->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
49
 
        setFixedWidth(logo->width());
 
68
        //setFixedWidth(logo->width());
 
69
 
 
70
        QImage logoImg = logo.convertToImage();
 
71
 
 
72
        QPixmap tmp;
 
73
        tmp.convertFromImage( logoImg.copy(0, 0, 1, logoImg.height()) );
 
74
        StretchLogoLabel *stretch = new StretchLogoLabel(tmp, lb_left);
 
75
 
 
76
        tmp.convertFromImage( logoImg.copy(logoImg.width()-1, 0, 1, logoImg.height()) );
 
77
        stretch = new StretchLogoLabel(tmp, lb_right);
50
78
 
51
79
        // setup signals
52
80
        connect(pb_open, SIGNAL(clicked()), SLOT(accept()));
55
83
        connect(cb_lang, SIGNAL(activated(int)), SLOT(langChange(int)));
56
84
 
57
85
        int x = 0;
 
86
        langSel = x;
58
87
        for(VarList::ConstIterator it = langs.begin(); it != langs.end(); ++it) {
59
88
                cb_lang->insertItem((*it).data());
60
89
                if((curLang.isEmpty() && x == 0) || (curLang == (*it).key())) {
61
90
                        cb_lang->setCurrentItem(x);
 
91
                        langSel = x;
62
92
                }
63
93
                ++x;
64
94
        }
65
95
 
 
96
        // QWhatsThis helpers
 
97
        QWhatsThis::add(cb_profile,
 
98
                tr("Select a profile to open from this list."));
 
99
        QWhatsThis::add(cb_lang,
 
100
                tr("Select a language you would like Psi to use from this "
 
101
                "list.  You can download extra language packs from the Psi homepage."));
 
102
        QWhatsThis::add(ck_auto,
 
103
                tr("Automatically open this profile when Psi is started.  Useful if "
 
104
                "you only have one profile."));
 
105
 
66
106
        reload(def);
67
107
}
68
108
 
 
109
ProfileOpenDlg::~ProfileOpenDlg()
 
110
{
 
111
}
 
112
 
69
113
void ProfileOpenDlg::reload(const QString &choose)
70
114
{
71
115
        QStringList list = getProfilesList();
86
130
                        }
87
131
                        ++x;
88
132
                }
 
133
 
89
134
                gb_open->setEnabled(TRUE);
90
135
                pb_open->setEnabled(TRUE);
91
136
                pb_open->setFocus();
104
149
 
105
150
void ProfileOpenDlg::langChange(int x)
106
151
{
 
152
        if(x == langSel)
 
153
                return;
 
154
        langSel = x;
 
155
 
107
156
        VarList::Iterator it = langs.findByNum(x);
108
157
        newLang = (*it).key();
109
158
        done(10);
113
162
ProfileManageDlg::ProfileManageDlg(const QString &choose, QWidget *parent, const char *name)
114
163
:ProfileManageUI(parent, name, TRUE)
115
164
{
116
 
        setCaption(CAP(tr("Manage Profiles")));
 
165
        setCaption(CAP(caption()));
117
166
 
118
167
        // setup signals
119
168
        connect(pb_new, SIGNAL(clicked()), SLOT(slotProfileNew()));
194
243
        // prompt first
195
244
        int r = QMessageBox::warning(this,
196
245
                CAP(tr("Delete Profile")),
197
 
                tr(QString(
 
246
                tr(
198
247
                "<qt>Are you sure you want to delete the \"<b>%1</b>\" profile?  "
199
248
                "This will delete all of the profile's message history as well as associated settings!</qt>"
200
 
                ).arg(name)),
 
249
                ).arg(name),
201
250
                tr("No, I changed my mind"),
202
251
                tr("Delete it!"));
203
252
 
206
255
 
207
256
        r = QMessageBox::information(this,
208
257
                CAP(tr("Delete Profile")),
209
 
                tr(QString(
 
258
                tr(
210
259
                "<qt>As a precaution, you are being asked one last time if this is what you really want.  "
211
260
                "The following folder will be deleted!<br><br>\n"
212
261
                "&nbsp;&nbsp;<b>%1</b><br><br>\n"
213
262
                "Proceed?"
214
 
                ).arg(path)),
 
263
                ).arg(path),
215
264
                tr("&No"),
216
265
                tr("&Yes"));
217
266
 
243
292
ProfileNewDlg::ProfileNewDlg(QWidget *parent, const char *name)
244
293
:ProfileNewUI(parent, name, TRUE)
245
294
{
246
 
        setCaption(CAP(tr("New Profile")));
 
295
        setCaption(CAP(caption()));
247
296
 
248
297
        bg_defAct->setButton(bg_defAct->id((QButton *)rb_chat));
249
298
        le_name->setFocus();
272
321
        // save config
273
322
        UserProfile p;
274
323
        p.prefs.defaultAction = bg_defAct->selected() == (QButton *)rb_message ? 0: 1;
 
324
        p.prefs.useEmoticons = ck_useEmoticons->isChecked();
275
325
        p.toFile(pathToProfileConfig(name));
276
326
 
277
327
        accept();