rconpassworddialog.cpp
1 //------------------------------------------------------------------------------
2 // rconpassworddialog.cpp
3 //------------------------------------------------------------------------------
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., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301, USA.
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2009 "Blzut3" <admin@maniacsvault.net>
22 //------------------------------------------------------------------------------
23 #include "configuration/doomseekerconfig.h"
24 #include "rconpassworddialog.h"
25 #include "ui_rconpassworddialog.h"
26 #include "plugins/engineplugin.h"
27 #include "plugins/pluginloader.h"
28 
29 DClass<RconPasswordDialog> : public Ui::RconPasswordDialog
30 {
31 };
32 
33 DPointered(RconPasswordDialog)
34 
35 RconPasswordDialog::RconPasswordDialog(QWidget *parent, bool connection)
36 : QDialog(parent)
37 {
38  d->setupUi(this);
39 
40  if (connection)
41  {
42  // Populate engines box.
43  d->engines->clear();
44  for(unsigned int i = 0;i < gPlugins->numPlugins();i++)
45  {
46  const EnginePlugin* info = gPlugins->plugin(i)->info();
47  d->engines->addItem(info->icon(), info->data()->name, i);
48  }
49  }
50  else
51  {
52  d->connectionBox->hide();
53  }
54 
55  if(gConfig.doomseeker.bHidePasswords)
56  d->lePassword->setEchoMode(QLineEdit::Password);
57 
58  // Adjust the size and prevent resizing.
59  adjustSize();
60  setMinimumHeight(height());
61  setMaximumHeight(height());
62 }
63 
64 RconPasswordDialog::~RconPasswordDialog()
65 {
66 }
67 
68 QString RconPasswordDialog::connectPassword() const
69 {
70  return d->lePassword->text();
71 }
72 
73 const EnginePlugin *RconPasswordDialog::selectedEngine() const
74 {
75  const PluginLoader::Plugin *plugin = gPlugins->plugin(d->engines->currentIndex());
76  if(plugin == NULL)
77  return NULL;
78 
79  return plugin->info();
80 }
81 
82 QString RconPasswordDialog::serverAddress() const
83 {
84  return d->leServerAddress->text();
85 }
EnginePlugin * info() const
Main plugin interface.