Commit 8d9b8424 authored by Tomas Mecir's avatar Tomas Mecir

A bunch of dialog fixes. Add sorting to the profile window.

parent 232e2e98
......@@ -113,12 +113,12 @@ cTelnet::cTelnet (int sess) : cActionBase ("telnet", sess)
{
d = new cTelnetPrivate;
d->socket = 0;
d->socket = nullptr;
d->termType = "KMuddy";
d->codec = 0;
d->inCoder = 0;
d->outCoder = 0;
d->codec = nullptr;
d->inCoder = nullptr;
d->outCoder = nullptr;
d->iac = d->iac2 = d->insb = false;
d->command = "";
......@@ -167,7 +167,7 @@ cTelnet::~cTelnet()
delete d->outCoder;
delete d;
d = 0;
d = nullptr;
}
void cTelnet::eventNothingHandler (QString event, int)
......@@ -223,7 +223,7 @@ void cTelnet::socketFailed ()
d->_connected = false;
d->_connecting = false;
d->socket->deleteLater ();
d->socket = 0;
d->socket = nullptr;
}
/** establishes a new connection */
......@@ -252,6 +252,7 @@ void cTelnet::connectIt (const QString &address, int port, cProfileSettings *set
d->hostName = address;
d->hostPort = port;
d->socket = KSocketFactory::connectToHost ("telnet", address, port);
d->socket->setSocketOption (QAbstractSocket::KeepAliveOption, 1);
setupSocketHandlers ();
}
......@@ -346,7 +347,7 @@ void cTelnet::disconnect ()
// schedule socket deletion
d->socket->deleteLater ();
d->socket = 0;
d->socket = nullptr;
}
//alright - we're disconnected
......@@ -372,7 +373,7 @@ bool cTelnet::isConnected ()
void cTelnet::setMSPGlobalPaths (const QStringList &paths)
{
if (d->MSP != 0)
if (d->MSP)
d->MSP->setGlobalPaths (paths);
}
......@@ -383,20 +384,20 @@ bool cTelnet::usingMSP ()
void cTelnet::setMSPAllowed (bool allow)
{
if (d->MSP != 0)
if (d->MSP)
d->MSP->setMSPAllowed (allow);
}
void cTelnet::setDownloadAllowed (bool allow)
{
if (d->MSP != 0)
if (d->MSP)
d->MSP->setDownloadAllowed (allow);
}
void cTelnet::processSoundRequest (bool isSOUND, QString fName, int volume, int repeats,
int priority, QString type, QString url)
{
if (d->MSP != 0)
if (d->MSP)
d->MSP->processRequest (isSOUND, fName, volume, repeats, priority, type, url);
}
......
......@@ -26,6 +26,7 @@
#include <QCheckBox>
#include <QDialogButtonBox>
#include <QGridLayout>
#include <QSortFilterProxyModel>
#include <QTreeView>
#include <QVBoxLayout>
......@@ -43,14 +44,20 @@ dlgConnect::dlgConnect(QWidget *parent) : QDialog (parent)
//put some widgets there
lw = new QTreeView (this);
lw->setModel (cProfileManager::self()->model());
QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel (this);
proxyModel->setSourceModel (cProfileManager::self()->model());
proxyModel->setSortCaseSensitivity (Qt::CaseInsensitive);
lw->setModel (proxyModel);
lw->setUniformRowHeights (true);
lw->setRootIsDecorated (false);
lw->setItemsExpandable (false);
lw->setSortingEnabled (true);
lw->sortByColumn (0, Qt::AscendingOrder);
lw->setWhatsThis(
i18n ("This list shows currently defined profiles.<p><b>Profiles</b> "
"allow you to speed up connecting to your MUD, as well as to use "
"more advanced features like <i>aliases</i> or <i>triggers</i>."));
QWidget *vb = new QWidget (this);
QVBoxLayout *vblayout = new QVBoxLayout (vb);
vblayout->setSpacing (5);
......@@ -119,6 +126,9 @@ QString dlgConnect::selectedProfile ()
{
QItemSelection sel = lw->selectionModel()->selection();
if (sel.empty()) return QString();
QSortFilterProxyModel *model = dynamic_cast<QSortFilterProxyModel *> (lw->model());
if (!model) return QString();
sel = model->mapSelectionToSource (sel);
int idx = sel.indexes().first().row();
return cProfileManager::self()->profileList()[idx];
}
......
......@@ -22,9 +22,9 @@
#include <QDialogButtonBox>
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>
#include <KLocalizedString>
#include <kvbox.h>
dlgGrabKey::dlgGrabKey (QWidget *parent) : QDialog (parent)
{
......@@ -32,21 +32,23 @@ dlgGrabKey::dlgGrabKey (QWidget *parent) : QDialog (parent)
//initial dialog size
setWindowTitle (i18n ("Keygrabber"));
QVBoxLayout *layout = new QVBoxLayout (this);
//create main dialog's widget
KVBox *vbox = new KVBox (this);
new QLabel (i18n ("Press the desired shortcut..."), vbox);
QLabel *label = new QLabel (i18n ("Press the desired shortcut..."), this);
QDialogButtonBox *buttons = new QDialogButtonBox (QDialogButtonBox::Cancel, vbox);
QDialogButtonBox *buttons = new QDialogButtonBox (QDialogButtonBox::Cancel,this);
QPushButton *button = buttons->button (QDialogButtonBox::Cancel);
button->setDefault(true);
connect (buttons, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect (buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
layout->addWidget (label);
layout->addWidget (buttons);
}
dlgGrabKey::~dlgGrabKey ()
{
KMuddy::self()->setGrabDialog (0);
KMuddy::self()->setGrabDialog (nullptr);
}
QSize dlgGrabKey::sizeHint() const
......
......@@ -36,7 +36,7 @@ KDE people say...). I don't use QAction here, so macro keys are not affected.
class dlgGrabKey : public QDialog {
Q_OBJECT
public:
dlgGrabKey (QWidget *parent=0);
dlgGrabKey (QWidget *parent);
~dlgGrabKey ();
virtual QSize sizeHint() const override;
/** key is here - sent by KMuddy::eventFilter */
......
......@@ -38,6 +38,11 @@ dlgMXPConsole::~dlgMXPConsole ()
{
}
QSize dlgMXPConsole::sizeHint() const
{
return QSize (500, 300);
}
void dlgMXPConsole::createDialog ()
{
setWindowTitle (i18n ("MXP Console"));
......@@ -60,10 +65,6 @@ void dlgMXPConsole::addLine (const QString &line)
sb->setValue (sb->maximum ());
}
QSize dlgMXPConsole::sizeHint() const
{
return QSize (300, 200);
}
#endif //HAVE_MXP
......@@ -26,12 +26,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <kapplication.h>
#include <klocale.h>
#include <kpushbutton.h>
#include <QDialogButtonBox>
#include <QLabel>
#include <QGridLayout>
#include <QListWidget>
#include <QPushButton>
#include <QVBoxLayout>
dlgWindows::dlgWindows(cWindowList *wlist, QWidget *parent) : QDialog(parent)
......@@ -63,9 +63,9 @@ void dlgWindows::createDialog()
QFrame *buttons = new QFrame (this);
QVBoxLayout *buttonslayout = new QVBoxLayout (buttons);
btshow = new KPushButton (i18n("&Show"), buttons);
bthide = new KPushButton (i18n("&Hide"), buttons);
btdelete = new KPushButton (i18n("&Delete"), buttons);
btshow = new QPushButton (i18n("&Show"), buttons);
bthide = new QPushButton (i18n("&Hide"), buttons);
btdelete = new QPushButton (i18n("&Delete"), buttons);
buttonslayout->setSpacing (5);
......@@ -74,9 +74,7 @@ void dlgWindows::createDialog()
buttonslayout->addWidget (btdelete);
buttonslayout->addStretch (10);
QDialogButtonBox *dlgbuttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
QPushButton *button = dlgbuttons->button (QDialogButtonBox::Ok);
button->setText (i18n ("&Dont"));
QDialogButtonBox *dlgbuttons = new QDialogButtonBox (QDialogButtonBox::Close, this);
connect (dlgbuttons, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect (dlgbuttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
......@@ -87,6 +85,7 @@ void dlgWindows::createDialog()
layout->addWidget (label, 0, 0);
layout->addWidget (box, 1, 0);
layout->addWidget (buttons, 1, 1);
layout->addWidget (dlgbuttons, 2, 0, 1, 2);
updateMe();
......
......@@ -27,7 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QLabel>
class QListWidget;
class KPushButton;
class QPushButton;
class QStringList;
class cWindowList;
......@@ -58,7 +58,7 @@ protected:
cWindowList *winlist;
QListWidget *box;
KPushButton *btshow, *bthide, *btdelete;
QPushButton *btshow, *bthide, *btdelete;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment