From 405bd41472665d92cad485c24e762983a7c503da Mon Sep 17 00:00:00 2001 From: Michal Kubecek Date: Fri, 17 Apr 2015 14:54:41 +0200 Subject: automatic conversion of getprofilenameform.ui --- src/gui/getprofilenameform.cpp | 81 ++++++++++++ src/gui/getprofilenameform.h | 26 ++++ src/gui/getprofilenameform.ui | 283 +++++++++++++++++----------------------- src/gui/getprofilenameform.ui.h | 80 ------------ src/gui/twinkle.pro | 6 +- 5 files changed, 234 insertions(+), 242 deletions(-) create mode 100644 src/gui/getprofilenameform.cpp create mode 100644 src/gui/getprofilenameform.h delete mode 100644 src/gui/getprofilenameform.ui.h diff --git a/src/gui/getprofilenameform.cpp b/src/gui/getprofilenameform.cpp new file mode 100644 index 0000000..8716efb --- /dev/null +++ b/src/gui/getprofilenameform.cpp @@ -0,0 +1,81 @@ +#include "getprofilenameform.h" + +#include +#include +#include "user.h" +#include "protocol.h" + +/* + * Constructs a GetProfileNameForm which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + * + * The dialog will by default be modeless, unless you set 'modal' to + * true to construct a modal dialog. + */ +GetProfileNameForm::GetProfileNameForm(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl) + : QDialog(parent, name, modal, fl) +{ + setupUi(this); +} + +/* + * Destroys the object and frees any allocated resources + */ +GetProfileNameForm::~GetProfileNameForm() +{ + // no need to delete child widgets, Qt does it all for us +} + +void GetProfileNameForm::init() +{ + // Letters, digits, underscore, minus + QRegExp rxFilenameChars("[\\w\\-][\\w\\-@\\.]*"); + + // Set validators + // USER + profileLineEdit->setValidator(new QRegExpValidator(rxFilenameChars, this)); +} + +void GetProfileNameForm::validate() +{ + if (profileLineEdit->text().isEmpty()) return; + + // Find the .twinkle directory in HOME + QDir d = QDir::home(); + if (!d.cd(USER_DIR)) { + QMessageBox::critical(this, PRODUCT_NAME, + tr("Cannot find .twinkle directory in your home directory.")); + reject(); + } + + QString filename = profileLineEdit->text(); + filename.append(USER_FILE_EXT); + QString fullname = d.filePath(filename); + if (QFile::exists(fullname)) { + QMessageBox::warning(this, PRODUCT_NAME, + tr("Profile already exists.")); + return; + } + + accept(); +} + +QString GetProfileNameForm:: getProfileName() +{ + return profileLineEdit->text(); +} + +// Execute a dialog to get a name for a new profile +int GetProfileNameForm::execNewName() +{ + profileTextLabel->setText(tr("Enter a name for your profile:")); + return exec(); +} + +// Execute this dialog to get a new name for an existing profile +int GetProfileNameForm::execRename(const QString &oldName) +{ + QString s = tr("Rename profile '%1' to:").arg(oldName); + profileTextLabel->setText(s); + return exec(); +} diff --git a/src/gui/getprofilenameform.h b/src/gui/getprofilenameform.h new file mode 100644 index 0000000..be49368 --- /dev/null +++ b/src/gui/getprofilenameform.h @@ -0,0 +1,26 @@ +#ifndef GETPROFILENAMEFORM_H +#define GETPROFILENAMEFORM_H + +#include +#include "ui_getprofilenameform.h" + +class GetProfileNameForm : public QDialog, private Ui::GetProfileNameForm +{ + Q_OBJECT + +public: + GetProfileNameForm(QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WindowFlags fl = 0); + ~GetProfileNameForm(); + + QString getProfileName(); + int execNewName(); + int execRename( const QString & oldName ); + +public slots: + void validate(); + +private: + void init(); +}; + +#endif // GETPROFILENAMEFORM_H diff --git a/src/gui/getprofilenameform.ui b/src/gui/getprofilenameform.ui index 599d778..e6d17ba 100644 --- a/src/gui/getprofilenameform.ui +++ b/src/gui/getprofilenameform.ui @@ -1,174 +1,137 @@ - -GetProfileNameForm - - - GetProfileNameForm - + + + + + + GetProfileNameForm + - - 0 - 0 - 430 - 127 - + + 0 + 0 + 430 + 127 + - - Twinkle - Profile name + + Twinkle - Profile name - - - unnamed - - - - userIconTextLabel - - - WidgetOrigin - - - - - - penguin_big.png - - - - - layout24 - - - - unnamed - - - - spacer41 - - - Horizontal - - - Expanding - - - - 81 - 20 - - - - - - okPushButton - - - &OK - - - true - - - - - cancelPushButton - - - &Cancel - - - + + + + + + + + penguin_big.png + + + false + - - - layout26 - - - - unnamed - - - - profileTextLabel - - - - 5 - 0 - 0 - 0 - - - - Enter a name for your profile: - - - false - - - AlignVCenter - - - - - profileLineEdit - - - - - - <b>The name of your profile</b> + + + + + + + + 81 + 20 + + + + QSizePolicy::Expanding + + + Qt::Horizontal + + + + + + + &OK + + + true + + + + + + + &Cancel + + + + + + + + + + + + 5 + 0 + 0 + 0 + + + + Enter a name for your profile: + + + false + + + Qt::AlignVCenter + + + false + + + + + + + + + + <b>The name of your profile</b> <br><br> A profile contains your user settings, e.g. your user name and password. You have to give each profile a name. <br><br> If you have multiple SIP accounts, you can create multiple profiles. When you startup Twinkle it will show you the list of profile names from which you can select the profile you want to run. <br><br> To remember your profiles easily you could use your SIP user name as a profile name, e.g. <b>example@example.com</b> - - - - - - - + + + + + + + + + qPixmapFromMimeSource + + profileLineEdit + okPushButton + cancelPushButton + + - cancelPushButton - clicked() - GetProfileNameForm - reject() + cancelPushButton + clicked() + GetProfileNameForm + reject() - okPushButton - clicked() - GetProfileNameForm - validate() + okPushButton + clicked() + GetProfileNameForm + validate() - - - profileLineEdit - okPushButton - cancelPushButton - - - qlineedit.h - qregexp.h - qvalidator.h - protocol.h - qmessagebox.h - qdir.h - qfile.h - user.h - getprofilenameform.ui.h - - - validate() - - - init() - getProfileName() - execNewName() - execRename( const QString & oldName ) - - - - + + diff --git a/src/gui/getprofilenameform.ui.h b/src/gui/getprofilenameform.ui.h deleted file mode 100644 index 00c2f18..0000000 --- a/src/gui/getprofilenameform.ui.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. -** -** If you wish to add, delete or rename functions or slots use -** Qt Designer which will update this file, preserving your code. Create an -** init() function in place of a constructor, and a destroy() function in -** place of a destructor. -*****************************************************************************/ -/* - Copyright (C) 2005-2009 Michel de Boer - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - - -void GetProfileNameForm::init() -{ - // Letters, digits, underscore, minus - QRegExp rxFilenameChars("[\\w\\-][\\w\\-@\\.]*"); - - // Set validators - // USER - profileLineEdit->setValidator(new QRegExpValidator(rxFilenameChars, this)); -} - -void GetProfileNameForm::validate() -{ - if (profileLineEdit->text().isEmpty()) return; - - // Find the .twinkle directory in HOME - QDir d = QDir::home(); - if (!d.cd(USER_DIR)) { - QMessageBox::critical(this, PRODUCT_NAME, - tr("Cannot find .twinkle directory in your home directory.")); - reject(); - } - - QString filename = profileLineEdit->text(); - filename.append(USER_FILE_EXT); - QString fullname = d.filePath(filename); - if (QFile::exists(fullname)) { - QMessageBox::warning(this, PRODUCT_NAME, - tr("Profile already exists.")); - return; - } - - accept(); -} - -QString GetProfileNameForm:: getProfileName() -{ - return profileLineEdit->text(); -} - -// Execute a dialog to get a name for a new profile -int GetProfileNameForm::execNewName() -{ - profileTextLabel->setText(tr("Enter a name for your profile:")); - return exec(); -} - -// Execute this dialog to get a new name for an existing profile -int GetProfileNameForm::execRename(const QString &oldName) -{ - QString s = tr("Rename profile '%1' to:").arg(oldName); - profileTextLabel->setText(s); - return exec(); -} diff --git a/src/gui/twinkle.pro b/src/gui/twinkle.pro index b4c73c2..0fee90b 100644 --- a/src/gui/twinkle.pro +++ b/src/gui/twinkle.pro @@ -14,6 +14,7 @@ HEADERS += gui.h \ deregisterform.h \ logviewform.h \ numberconversionform.h \ + getprofilenameform.h \ historylistview.h \ freedesksystray.h \ twinklesystray.h \ @@ -34,6 +35,7 @@ SOURCES += main.cpp \ deregisterform.cpp \ logviewform.cpp \ numberconversionform.cpp \ + getprofilenameform.cpp \ historylistview.cpp \ freedesksystray.cpp \ twinklesystray.cpp \ @@ -47,7 +49,8 @@ SOURCES += main.cpp \ FORMS = dtmfform.ui \ deregisterform.ui \ logviewform.ui \ - numberconversionform.ui + numberconversionform.ui \ + getprofilenameform.ui #The following line was changed from FORMS to FORMS3 by qt3to4 FORMS3 = mphoneform.ui \ @@ -59,7 +62,6 @@ FORMS3 = mphoneform.ui \ authenticationform.ui \ userprofileform.ui \ selectprofileform.ui \ - getprofilenameform.ui \ transferform.ui \ syssettingsform.ui \ wizardform.ui \ -- cgit v1.2.3