Skip to content
Permalink
Browse files

Do not consider a default hostname from clipboard to be custom

The connect dialog has the capability to pre-fill itself from
mumble:// style URLs in the users clipboard. If those are not
given a custom ?title= argument the name was defaulted to the
host name which caused them to be considered custom by the
edit dialog. This patch resolves this issue.
  • Loading branch information...
hacst committed May 7, 2015
1 parent 78d0db8 commit 4e459a9b1ffbee16148dbd73a3078c6316d893d7
Showing with 28 additions and 6 deletions.
  1. +4 −4 src/mumble/ConnectDialog.cpp
  2. +24 −2 src/mumble/ConnectDialog.h
@@ -364,7 +364,7 @@ ServerItem::~ServerItem() {
delete si;
}

ServerItem *ServerItem::fromMimeData(const QMimeData *mime, QWidget *p) {
ServerItem *ServerItem::fromMimeData(const QMimeData *mime, bool default_name, QWidget *p) {
if (mime->hasFormat(QLatin1String("OriginatedInMumble")))
return NULL;

@@ -413,15 +413,15 @@ ServerItem *ServerItem::fromMimeData(const QMimeData *mime, QWidget *p) {
}

#if QT_VERSION >= 0x050000
if (! query.hasQueryItem(QLatin1String("title")))
if (! query.hasQueryItem(QLatin1String("title")) && default_name)
query.addQueryItem(QLatin1String("title"), url.host());

ServerItem *si = new ServerItem(query.queryItemValue(QLatin1String("title")), url.host(), static_cast<unsigned short>(url.port(DEFAULT_MUMBLE_PORT)), url.userName(), url.password());

if (query.hasQueryItem(QLatin1String("url")))
si->qsUrl = query.queryItemValue(QLatin1String("url"));
#else
if (! url.hasQueryItem(QLatin1String("title")))
if (! url.hasQueryItem(QLatin1String("title")) && default_name)
url.addQueryItem(QLatin1String("title"), url.host());

ServerItem *si = new ServerItem(url.queryItemValue(QLatin1String("title")), url.host(), static_cast<unsigned short>(url.port(DEFAULT_MUMBLE_PORT)), url.userName(), url.password());
@@ -1017,7 +1017,7 @@ void ConnectDialog::on_qaFavoriteAddNew_triggered() {

// Try to fill out fields if possible
{
ServerItem *si = ServerItem::fromMimeData(QApplication::clipboard()->mimeData());
ServerItem *si = ServerItem::fromMimeData(QApplication::clipboard()->mimeData(), false);
if (si) {
// If there is server information in the clipboard assume user wants to add it
name = si->qsName;
@@ -166,7 +166,23 @@ class ServerItem : public QTreeWidgetItem, public PingStats {
ServerItem(const QString &name, ItemType itype, const QString &continent = QString(), const QString &country = QString());
ServerItem(const ServerItem *si);
~ServerItem();
static ServerItem *fromMimeData(const QMimeData *mime, QWidget *p = NULL);

/// Converts given mime data into a ServerItem object
///
/// This function checks the clipboard for a valid mumble:// style
/// URL and converts it into a ServerItem ready to add to the connect
/// dialog. It also parses .lnk files of InternetShortcut/URL type
/// to enable those to be dropped onto the clipboard.
///
/// @note If needed can query the user for a user name using a modal dialog.
/// @note If a server item is returned it's the callers reponsibility to delete it.
///
/// @param mime Mime data to analyze
/// @param default_name If true the hostname is set as item name if none is given
/// @param p Parent widget to use in case the user has to be queried
/// @return Server item or NULL if mime data invalid.
///
static ServerItem *fromMimeData(const QMimeData *mime, bool default_name = true, QWidget *p = NULL);

void addServerItem(ServerItem *child);

@@ -201,7 +217,13 @@ class ConnectDialogEdit : public QDialog, protected Ui::ConnectDialogEdit {
public:
QString qsName, qsHostname, qsUsername, qsPassword;
unsigned short usPort;
ConnectDialogEdit(QWidget *parent, const QString &name = QString(), const QString &host = QString(), const QString &user = QString(), unsigned short port = DEFAULT_MUMBLE_PORT, const QString &password = QString(), bool add = false);
ConnectDialogEdit(QWidget *parent,
const QString &name = QString(),
const QString &host = QString(),
const QString &user = QString(),
unsigned short port = DEFAULT_MUMBLE_PORT,
const QString &password = QString(),
bool add = false);
};

class ConnectDialog : public QDialog, public Ui::ConnectDialog {

0 comments on commit 4e459a9

Please sign in to comment.
You can’t perform that action at this time.