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